2 Copyright (C) 2005,2006,2007,2008 Eugene K. Ressler, Jr.
4 This file is part of Sketch, a small, simple system for making
5 3d drawings with LaTeX and the PSTricks or TikZ package.
7 Sketch is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 Sketch is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Sketch; see the file COPYING.txt. If not, see
19 http://www.gnu.org/copyleft */
26 typedef enum bsp_node_type_t
33 #define BASE_BSP_NODE_FIELDS \
35 struct bsp_node_t *prev, *next, *mark, *in, *on, *out; \
39 typedef struct bsp_node_t
45 typedef struct bsp_vertex_attr_t
53 typedef struct bsp_polygon_attr_t
55 DYNAMIC_ARRAY_FIELDS (BSP_VERTEX_ATTR
, elt
, n_elts
);
59 DECLARE_DYNAMIC_ARRAY_PROTOS (BSP_POLYGON_ATTR
, BSP_VERTEX_ATTR
,
60 polygon_attr
, elt
, n_elts
)
61 typedef struct bsp_polygon_node_t
65 POLYGON_3D polygon
[1];
66 BSP_POLYGON_ATTR polygon_attr
[1]; // attributes of polygon vertices
70 typedef struct bsp_polyline_node_t
73 POLYLINE_3D polyline
[1];
78 void add_polygon_to_bsp (BSP_TREE
* bsp
, POLYGON_3D
* polygon
,
81 void add_polyline_to_bsp (BSP_TREE
* bsp
, POLYLINE_3D
* polylines
,
84 typedef void (*BSP_NODE_FUNC
) (BSP_NODE
* node
, void *env
);
86 void traverse_bsp (BSP_NODE
* bsp
, BSP_NODE_FUNC func
, void *env
);
88 void traverse_depth_sort (BSP_NODE
* bsp
, BSP_NODE_FUNC func
, void *env
);
90 void print_bsp (FILE * f
, BSP_NODE
* bsp
);
92 void add_polygon_to_sort (BSP_TREE
* bsp
, POLYGON_3D
* polygon
,
95 void add_polyline_to_sort (BSP_TREE
* bsp
, POLYLINE_3D
* polyline
,
98 void sort_by_depth (BSP_TREE
* bsp
);