1 /*
2  * Copyright (C) 2001-2005  Terence M. Welsh
3  *
4  * This file is part of Implicit.
5  *
6  * Implicit is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License version 2.1 as published by the Free Software Foundation.
9  *
10  * Implicit is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 
20 
21 #ifndef IMPCUBETABLE_H
22 #define IMPCUBETABLE_H
23 
24 
25 /****************************************
26 
27 OpenGL coordinate system
28 
29          Y
30          |
31          |
32          |
33          |
34          |
35          /--------X
36         /
37        /
38 	  Z
39 
40 
41 Indices for vertices and edge on cube
42 
43 
44           2-----6-----6
45          /|          /|
46         3 |        11 |
47        /  1        /  9
48       3-----7-----7   |
49       |   |       |   |
50       |   0-----4-|---4
51       2  /       10  /
52       | 0         | 8
53       |/          |/
54       1-----5-----5
55 
56 
57 *****************************************/
58 
59 
60 // corners
61 // left-right-bottom-top-far-near notation
62 #define LBF 0x01
63 #define LBN 0x02
64 #define LTF 0x04
65 #define LTN 0x08
66 #define RBF 0x10
67 #define RBN 0x20
68 #define RTF 0x40
69 #define RTN 0x80
70 
71 
72 
73 class impCubeTables{
74 public:
75 	// This table describes the sequence of edges to visit
76 	// in order to build triangle strips in a cube  There are
77 	// a maximum of 16 integers that can result from a cube
78 	// configuration.  We have 17 integers in each row so that
79 	// each row can end with a 0.  The zero signifies the end
80 	// of the data in each row.
81 	//int** cubetable;
82 	int triStripPatterns[256][17];
83 	// 256 x 6 array of true/false values.  For each of the 256
84 	// entries in the cubetable, this table indicates which
85 	// neighboring cubes will also contain parts of the surface.
86 	//bool** crawltable;
87 	bool crawlDirections[256][6];
88 
89 	impCubeTables();
~impCubeTables()90 	~impCubeTables(){};
91 
92 private:
93 	// edge connectivity
94 	// This array defines which vertices are connected by each edge.
95 	int ec[12][2];
96 
97 	// vertex connectivity
98 	// This array defines which edges extend from each vertex.
99 	int vc[8][3];
100 
101 	int nextedge(int vertex, int edge);
102 	void addtotable(int row, int edgecount, int *edgelist);
103 	void makeTriStripPatterns();
104 	void makeCrawlDirections();
105 };
106 
107 
108 #endif
109