initial setup of thesis repository
[cluster_expansion_thesis.git] / little_helpers / tikz / sketch-0.2.161 / bsp.h
blob9bba981eae1ebda6230a752a201ef976a9c6e9f0
1 /* bsp.h
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)
10 any later version.
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 */
21 #ifndef __BSP_H
22 #define __BSP_H
24 #include "geometry.h"
26 typedef enum bsp_node_type_t
28 BSP_POLYGON,
29 BSP_POLYLINE,
31 BSP_NODE_TYPE;
33 #define BASE_BSP_NODE_FIELDS \
34 BSP_NODE_TYPE tag; \
35 struct bsp_node_t *prev, *next, *mark, *in, *on, *out; \
36 void *attr; \
37 BOX_3D extent[1]
39 typedef struct bsp_node_t
41 BASE_BSP_NODE_FIELDS;
43 BSP_NODE, *BSP_TREE;
45 typedef struct bsp_vertex_attr_t
47 int border_p;
48 int parent_vtx;
49 int cut_p;
51 BSP_VERTEX_ATTR;
53 typedef struct bsp_polygon_attr_t
55 DYNAMIC_ARRAY_FIELDS (BSP_VERTEX_ATTR, elt, n_elts);
57 BSP_POLYGON_ATTR;
59 DECLARE_DYNAMIC_ARRAY_PROTOS (BSP_POLYGON_ATTR, BSP_VERTEX_ATTR,
60 polygon_attr, elt, n_elts)
61 typedef struct bsp_polygon_node_t
63 BASE_BSP_NODE_FIELDS;
64 PLANE plane[1];
65 POLYGON_3D polygon[1];
66 BSP_POLYGON_ATTR polygon_attr[1]; // attributes of polygon vertices
68 BSP_POLYGON_NODE;
70 typedef struct bsp_polyline_node_t
72 BASE_BSP_NODE_FIELDS;
73 POLYLINE_3D polyline[1];
74 int first_p, last_p;
76 BSP_POLYLINE_NODE;
78 void add_polygon_to_bsp (BSP_TREE * bsp, POLYGON_3D * polygon,
79 void *attr);
81 void add_polyline_to_bsp (BSP_TREE * bsp, POLYLINE_3D * polylines,
82 void *attr);
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,
93 void *attr);
95 void add_polyline_to_sort (BSP_TREE * bsp, POLYLINE_3D * polyline,
96 void *attr);
98 void sort_by_depth (BSP_TREE * bsp);
100 #endif