1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
//[MSH_START]
// 02/01/98: moved FetchCoordinate3State(), FetchMaterialState(), and
// FetchMaterialBindingState() into class BRep.
// 01/01/98: added new material retrieval code (msh)
// 05/05/97: added new constructor (msh)
// 04/03/97: added display of coordinate3 stack (msh)
//[MSH_END]
#include <QvState.h>
const char *QvState::stackNames[NumStacks] = {
"Camera",
"Coordinate3",
"Light",
"MaterialBinding",
"Material",
"NormalBinding",
"Normal",
"ShapeHints",
"Texture2",
"Texture2Transformation",
"TextureCoordinate2",
"Transformation",
};
//[MSH_START]
QvState::QvState( BSPLIB_NAMESPACE::VrmlFile *base )
{
vrmlfile_base = base;
//stacks = new QvElement[NumStacks];
//stacks = (QvElement **) new QvElement[NumStacks];
//stacks = new QvElement * [NumStacks];
for (int i = 0; i < NumStacks; i++){
stacks[i] = NULL;
}
depth = 0;
}
//[MSH_END]
QvState::QvState()
{
//[MSH_START]
vrmlfile_base = NULL;
//[MSH_END]
//stacks = new QvElement[NumStacks];
//stacks = (QvElement **) new QvElement[NumStacks];
//stacks = new QvElement * [NumStacks];
int i = 0;
for (i = 0; i < NumStacks; i++){
stacks[i] = NULL;
}
depth = 0;
}
QvState::~QvState()
{
while (depth > 0)
pop();
//delete [] stacks;
}
void
QvState::addElement(StackIndex stackIndex, QvElement *elt)
{
elt->depth = depth;
elt->next = stacks[stackIndex];
stacks[stackIndex] = elt;
}
void
QvState::push()
{
depth++;
}
void
QvState::pop()
{
depth--;
for (int i = 0; i < NumStacks; i++)
while (stacks[i] != NULL && stacks[i]->depth > depth)
popElement((StackIndex) i);
}
void
QvState::popElement(StackIndex stackIndex)
{
QvElement *elt = stacks[stackIndex];
stacks[stackIndex] = elt->next;
delete elt;
}
void
QvState::print()
{
printf("Traversal state:\n");
for (int i = 0; i < NumStacks; i++) {
printf("\tStack [%2d] (%s):\n", i, stackNames[i]);
if (stacks[i] == NULL){
printf("\t\tNULL\n");
} else {
for (QvElement *elt = stacks[i]; elt != NULL; elt = elt->next) {
elt->print();
//[MSH_START]
/*
if ( i == Coordinate3Index ) {
QvCoordinate3 *c3 = (QvCoordinate3 *) elt->data;
for ( int j = 0; j < c3->point.num; j++ )
printf( "point[%d]=%f %f %f\n", j, c3->point.values[ j*3 ], c3->point.values[ j*3 + 1 ], c3->point.values[ j*3 + 2 ] );
}
*/
//[MSH_END]
}
}
}
}
|