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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>surface_quad.cpp</h1><a href="surface__quad_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025
00026 <font class="preprocessor">#include "<a class="code" href="stdpacs_8h.html">stdpacs.h</a>"</font>
00027
00028 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
00029
00030 <font class="preprocessor">#include "<a class="code" href="surface__quad_8h.html">pacs/surface_quad.h</a>"</font>
00031
00032 <font class="preprocessor">#include <vector></font>
00033
00034 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00035 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00036
<a name="l00037"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a0">00037</a> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a0">NLPACS::CSurfaceQuadTree::CSurfaceQuadTree</a>()
00038 {
00039 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = NULL;
00040 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n1">_MaxThickness</a> = FLT_MAX;
00041 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a> = 1;
00042 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_0">setCenter</a>(CVector::Null);
00043 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_2">setSize</a>(CVector::Null);
00044 }
00045
<a name="l00046"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a1">00046</a> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a0">NLPACS::CSurfaceQuadTree::CSurfaceQuadTree</a>(<font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html">NLPACS::CSurfaceQuadTree</a> &quad)
00047 {
00048 *<font class="keyword">this</font> = quad;
00049 }
00050
<a name="l00051"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a2">00051</a> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html">NLPACS::CSurfaceQuadTree</a> &<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a2">NLPACS::CSurfaceQuadTree::operator = </a>(<font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html">NLPACS::CSurfaceQuadTree</a> &quad)
00052 {
00053 <font class="keywordflow">if</font> (&quad == <font class="keyword">this</font>)
00054 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00055
00056 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n1">_MaxThickness</a> = quad.<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n1">_MaxThickness</a>;
00057 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a> = quad.<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a>;
00058 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a> = quad.<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>;
00059
00060 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = NULL;
00061 <font class="keywordflow">if</font> (quad.<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> != NULL)
00062 {
00063 <font class="keywordflow">if</font> (quad.<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->isLeaf())
00064 {
00065 CQuadLeaf *newLeaf = <font class="keyword">new</font> CQuadLeaf();
00066 *newLeaf = *((CQuadLeaf *)(quad.<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>));
00067 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = newLeaf;
00068 }
00069 <font class="keywordflow">else</font>
00070 {
00071 CQuadBranch *newBranch = <font class="keyword">new</font> CQuadBranch();
00072 *newBranch = *((CQuadBranch *)(quad.<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>));
00073 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = newBranch;
00074 }
00075 }
00076
00077 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00078 }
00079
<a name="l00080"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a7">00080</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a7">NLPACS::CSurfaceQuadTree::clear</a>()
00081 {
00082 <font class="keyword">delete</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>;
00083 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = NULL;
00084 }
00085
<a name="l00086"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a8">00086</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a8">NLPACS::CSurfaceQuadTree::init</a>(<font class="keywordtype">float</font> maxThickness, uint maxLevel, <font class="keyword">const</font> CVector &center, <font class="keywordtype">float</font> halfSize)
00087 {
00088 <a class="code" href="debug_8h.html#a6">nlassert</a>(maxLevel > 0);
00089 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a7">clear</a>();
00090 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n1">_MaxThickness</a> = maxThickness;
00091 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a> = maxLevel;
00092 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_0">setCenter</a>(center);
00093 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_1">setHalfSize</a>(CVector(halfSize, halfSize, 10000.0f));
00094 }
00095
<a name="l00096"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a9">00096</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a9">NLPACS::CSurfaceQuadTree::addVertex</a>(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
00097 {
00098 <font class="keywordflow">if</font> (!<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z265_2">include</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>))
00099 <font class="keywordflow">return</font>;
00100
00101 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> == NULL)
00102 {
00103 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a> == 1)
00104 {
00105 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = <font class="keyword">new</font> CQuadLeaf(<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a>);
00106 }
00107 <font class="keywordflow">else</font>
00108 {
00109 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = <font class="keyword">new</font> CQuadBranch(<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a>);
00110 }
00111
00112 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->_MaxThickness = <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n1">_MaxThickness</a>;
00113 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->_HalfSize = <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z264_5">getHalfSize</a>().x;
00114 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->_MinHeight = FLT_MAX;
00115 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->_MaxHeight = -FLT_MAX;
00116 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->_XCenter = <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z264_4">getCenter</a>().x;
00117 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->_YCenter = <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z264_4">getCenter</a>().y;
00118 }
00119
00120 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->addVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00121 }
00122
<a name="l00123"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a10">00123</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a10">NLPACS::CSurfaceQuadTree::compile</a>()
00124 {
00125 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> != NULL &&
00126 !<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->isLeaf() &&
00127 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->getMaxHeight()-<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->getMinHeight() <= <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n1">_MaxThickness</a>)
00128 {
00129 CQuadLeaf *leaf = <font class="keyword">new</font> CQuadLeaf();
00130 *((IQuadNode *)leaf) = *<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>;
00131 <font class="keyword">delete</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>;
00132 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = leaf;
00133 }
00134 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> != NULL &&
00135 !<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->isLeaf())
00136 {
00137 ((CQuadBranch *)<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>)->reduceChildren();
00138 }
00139 }
00140
00141
<a name="l00142"></a><a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">00142</a> <a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">NLPACS::CQuadBranch::CQuadBranch</a>(<font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html">NLPACS::CQuadBranch</a> &branch) : NLPACS::IQuadNode(branch)
00143 {
00144 *<font class="keyword">this</font> = branch;
00145 }
00146
<a name="l00147"></a><a class="code" href="classNLPACS_1_1CQuadBranch.html#a3">00147</a> <a class="code" href="classNLPACS_1_1CQuadBranch.html">NLPACS::CQuadBranch</a> &<a class="code" href="classNLPACS_1_1CQuadBranch.html#a3">NLPACS::CQuadBranch::operator = </a>(<font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html">NLPACS::CQuadBranch</a> &branch)
00148 {
00149 IQuadNode::operator=(branch);
00150
00151 uint child;
00152 <font class="keywordflow">for</font> (child=0; child<4; ++child)
00153 {
00154 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = NULL;
00155 <font class="keywordflow">if</font> (branch.<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] != NULL)
00156 {
00157 <font class="keywordflow">if</font> (branch.<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->isLeaf())
00158 {
00159 <a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a> *newLeaf = <font class="keyword">new</font> <a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a>();
00160 *newLeaf = *((<a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a> *)(branch.<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]));
00161 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = newLeaf;
00162 }
00163 <font class="keywordflow">else</font>
00164 {
00165 <a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">CQuadBranch</a> *newBranch = <font class="keyword">new</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">CQuadBranch</a>();
00166 *newBranch = *((<a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">CQuadBranch</a> *)(branch.<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]));
00167 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = newBranch;
00168 }
00169 }
00170 }
00171 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00172 }
00173
<a name="l00174"></a><a class="code" href="classNLPACS_1_1CQuadBranch.html#b0">00174</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#b0">NLPACS::CQuadBranch::reduceChildren</a>()
00175 {
00176 uint i;
00177
00178 <font class="keywordflow">for</font> (i=0; i<4; ++i)
00179 {
00180 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i] != NULL &&
00181 !<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i]->isLeaf() &&
00182 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i]->getMaxHeight()-<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i]->getMinHeight() <= <a class="code" href="classNLPACS_1_1IQuadNode.html#n2">_MaxThickness</a>)
00183 {
00184 <a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a> *leaf = <font class="keyword">new</font> <a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a>();
00185 *((<a class="code" href="classNLPACS_1_1IQuadNode.html#b0">IQuadNode</a> *)leaf) = *<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i];
00186 <font class="keyword">delete</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i];
00187 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i] = leaf;
00188 }
00189 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i] != NULL &&
00190 !<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i]->isLeaf())
00191 {
00192 ((<a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">CQuadBranch</a> *)<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[i])->reduceChildren();
00193 }
00194 }
00195 }
00196
<a name="l00197"></a><a class="code" href="classNLPACS_1_1CQuadBranch.html#a7">00197</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#a7">NLPACS::CQuadBranch::addVertex</a>(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
00198 {
00199 IQuadNode::addVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00200 uint child;
00201 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x > <a class="code" href="classNLPACS_1_1IQuadNode.html#n4">_XCenter</a>)
00202 child = (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y > <a class="code" href="classNLPACS_1_1IQuadNode.html#n5">_YCenter</a>) ? 2 : 1;
00203 <font class="keywordflow">else</font>
00204 child = (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y > <a class="code" href="classNLPACS_1_1IQuadNode.html#n5">_YCenter</a>) ? 3 : 0;
00205
00206 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] == NULL)
00207 {
00208 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1IQuadNode.html#n3">_Level</a> == 2)
00209 {
00210 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = <font class="keyword">new</font> <a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a>(<a class="code" href="classNLPACS_1_1IQuadNode.html#n3">_Level</a>-1);
00211 }
00212 <font class="keywordflow">else</font>
00213 {
00214 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = <font class="keyword">new</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">CQuadBranch</a>(<a class="code" href="classNLPACS_1_1IQuadNode.html#n3">_Level</a>-1);
00215 }
00216
00217 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_MaxThickness = <a class="code" href="classNLPACS_1_1IQuadNode.html#n2">_MaxThickness</a>;
00218 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_HalfSize = <a class="code" href="classNLPACS_1_1IQuadNode.html#n6">_HalfSize</a>/2.0f;
00219 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_MinHeight = FLT_MAX;
00220 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_MaxHeight = -FLT_MAX;
00221 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_XCenter = <a class="code" href="classNLPACS_1_1IQuadNode.html#n4">_XCenter</a>+<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_HalfSize*((child == 1 || child == 2) ? 1.0f : -1.0f);
00222 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_YCenter = <a class="code" href="classNLPACS_1_1IQuadNode.html#n5">_YCenter</a>+<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->_HalfSize*((child == 2 || child == 3) ? 1.0f : -1.0f);
00223 }
00224
00225 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->addVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00226 }
00227
<a name="l00228"></a><a class="code" href="classNLPACS_1_1CQuadBranch.html#a8">00228</a> <font class="keywordtype">bool</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#a8">NLPACS::CQuadBranch::check</a>()<font class="keyword"> const</font>
00229 <font class="keyword"></font>{
00230 <font class="keywordflow">if</font> (!IQuadNode::check())
00231 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00232
00233 uint child;
00234 <font class="keywordflow">for</font> (child=0; child<4; ++child)
00235 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] != NULL && !<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->check())
00236 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00237 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00238 }
00239
00240
00241 <font class="comment">/*</font>
00242 <font class="comment"> * Serialization methods...</font>
00243 <font class="comment"> */</font>
00244
00245
<a name="l00246"></a><a class="code" href="classNLPACS_1_1CQuadBranch.html#a10">00246</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#a10">NLPACS::CQuadBranch::serial</a>(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f)
00247 {
00248 IQuadNode::serial(f);
00249
00250 uint child;
00251 <font class="keywordflow">for</font> (child=0; child<4; ++child)
00252 {
00253 uint8 childType = 0;
00254
00255 <font class="keywordflow">if</font> (f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
00256 {
00257 <a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a> *leaf;
00258 <a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">CQuadBranch</a> *branch;
00259 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(childType);
00260 <font class="keywordflow">switch</font> (childType)
00261 {
00262 <font class="keywordflow">case</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#s3s0">NoChild</a>:
00263 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = NULL;
00264 <font class="keywordflow">break</font>;
00265 <font class="keywordflow">case</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#s3s1">LeafChild</a>:
00266 leaf = <font class="keyword">new</font> <a class="code" href="classNLPACS_1_1IQuadNode.html#l1">CQuadLeaf</a>();
00267 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = leaf;
00268 leaf->serial(f);
00269 <font class="keywordflow">break</font>;
00270 <font class="keywordflow">case</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#s3s2">BranchChild</a>:
00271 branch = <font class="keyword">new</font> <a class="code" href="classNLPACS_1_1CQuadBranch.html#a0">CQuadBranch</a>();;
00272 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] = branch;
00273 branch->serial(f);
00274 <font class="keywordflow">break</font>;
00275 <font class="keywordflow">default</font>:
00276 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"While serializing (read) CQuadBranch: unknown child type"</font>);
00277 <font class="keywordflow">break</font>;
00278 }
00279 }
00280 <font class="keywordflow">else</font>
00281 {
00282 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child] == NULL)
00283 {
00284 childType = <a class="code" href="classNLPACS_1_1CQuadBranch.html#s3s0">NoChild</a>;
00285 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(childType);
00286 }
00287 <font class="keywordflow">else</font>
00288 {
00289 childType = (<a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->isLeaf()) ? <a class="code" href="classNLPACS_1_1CQuadBranch.html#s3s1">LeafChild</a> : <a class="code" href="classNLPACS_1_1CQuadBranch.html#s3s2">BranchChild</a>;
00290 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(childType);
00291 <a class="code" href="classNLPACS_1_1CQuadBranch.html#n0">_Children</a>[child]->serial(f);
00292 }
00293 }
00294 }
00295 }
00296
<a name="l00297"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a11">00297</a> <font class="keywordtype">bool</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a11">NLPACS::CSurfaceQuadTree::check</a>()<font class="keyword"> const</font>
00298 <font class="keyword"></font>{
00299 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> != NULL)
00300 <font class="keywordflow">return</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->check();
00301 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00302 }
00303
<a name="l00304"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a12">00304</a> <font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CQuadLeaf.html">NLPACS::CQuadLeaf</a> *<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a12">NLPACS::CSurfaceQuadTree::getLeaf</a>(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)<font class="keyword"> const</font>
00305 <font class="keyword"></font>{
00306 CVector pos = CVector(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y, 0.0f);
00307 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> == NULL || !<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z265_2">include</a>(pos))
00308 <font class="keywordflow">return</font> NULL;
00309
00310 <font class="keyword">const</font> IQuadNode *node = <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>;
00311
00312 <font class="keywordflow">while</font> (node != NULL && !node->isLeaf())
00313 {
00314 <a class="code" href="debug_8h.html#a6">nlassert</a>(node->getBBox().include(pos));
00315 uint child;
00316
00317 <font class="keywordflow">if</font> (pos.x > node->_XCenter)
00318 child = ((pos.y > node->_YCenter) ? 2 : 1);
00319 <font class="keywordflow">else</font>
00320 child = ((pos.y > node->_YCenter) ? 3 : 0);
00321
00322 node = node->getChild(child);
00323 }
00324
00325 <font class="keywordflow">return</font> (<font class="keyword">const</font> CQuadLeaf *)node;
00326 }
00327
00328
<a name="l00329"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a15">00329</a> <font class="keywordtype">void</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a15">NLPACS::CSurfaceQuadTree::serial</a>(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f)
00330 {
00331 <font class="comment">/*</font>
00332 <font class="comment"> Version 0:</font>
00333 <font class="comment"> - base version.</font>
00334 <font class="comment"> */</font>
00335 (void)f.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>(0);
00336
00337 uint8 childType = 0;
00338 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n1">_MaxThickness</a>);
00339 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n2">_MaxLevel</a>);
00340 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>);
00341 <font class="keywordflow">if</font> (f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
00342 {
00343 CQuadLeaf *leaf;
00344 CQuadBranch *branch;
00345
00346 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(childType);
00347 <font class="keywordflow">switch</font> (childType)
00348 {
00349 <font class="keywordflow">case</font> CQuadBranch::NoChild:
00350 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = NULL;
00351 <font class="keywordflow">break</font>;
00352 <font class="keywordflow">case</font> CQuadBranch::LeafChild:
00353 leaf = <font class="keyword">new</font> CQuadLeaf();
00354 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = leaf;
00355 leaf->serial(f);
00356 <font class="keywordflow">break</font>;
00357 <font class="keywordflow">case</font> CQuadBranch::BranchChild:
00358 branch = <font class="keyword">new</font> CQuadBranch();
00359 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> = branch;
00360 branch->serial(f);
00361 <font class="keywordflow">break</font>;
00362 <font class="keywordflow">default</font>:
00363 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"While serializing (read) CQuadBranch: unknown child type"</font>);
00364 <font class="keywordflow">break</font>;
00365 }
00366 }
00367 <font class="keywordflow">else</font>
00368 {
00369 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> == NULL)
00370 {
00371 childType = CQuadBranch::NoChild;
00372 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(childType);
00373 }
00374 <font class="keywordflow">else</font>
00375 {
00376 childType = (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->isLeaf()) ? CQuadBranch::LeafChild : CQuadBranch::BranchChild;
00377 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(childType);
00378 <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>->serial(f);
00379 }
00380 }
00381 }
00382
00383 <font class="comment">//</font>
<a name="l00384"></a><a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a13">00384</a> <font class="keywordtype">float</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#a13">NLPACS::CSurfaceQuadTree::getInterpZ</a>(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)<font class="keyword"> const</font>
00385 <font class="keyword"></font>{
00386 <font class="comment">// first get final leaf for position</font>
00387 CVector pos = CVector(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y, 0.0f);
00388 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a> == NULL || !<a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n3">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z265_2">include</a>(pos))
00389 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; <font class="comment">// return unmodified z</font>
00390
00391 <font class="keyword">const</font> IQuadNode *node = <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html#n0">_Root</a>;
00392 vector<uint> children;
00393 vector<const IQuadNode*> nodes;
00394
00395 <font class="keywordflow">while</font> (node != NULL && !node->isLeaf())
00396 {
00397 nodes.push_back(node);
00398
00399 <a class="code" href="debug_8h.html#a6">nlassert</a>(node->getBBox().include(pos));
00400 uint child;
00401
00402 <font class="keywordflow">if</font> (pos.x > node->_XCenter)
00403 child = ((pos.y > node->_YCenter) ? 2 : 1);
00404 <font class="keywordflow">else</font>
00405 child = ((pos.y > node->_YCenter) ? 3 : 0);
00406
00407 children.push_back(child);
00408
00409 node = node->getChild(child);
00410 }
00411
00412 <font class="keywordflow">if</font> (node == NULL)
00413 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; <font class="comment">// return unmodified z</font>
00414
00415 nodes.push_back(node);
00416
00417 vector<const CQuadLeaf*> leaves;
00418 vector<const IQuadNode*> explore;
00419
00420 leaves.push_back((<font class="keyword">const</font> CQuadLeaf*)node);
00421
00422 <font class="comment">// for each side of the leaf, find neighbor leaves</font>
00423 uint side;
00424 <font class="keywordflow">for</font> (side=0; side<4; ++side)
00425 {
00426 <font class="keyword">static</font> <font class="keyword">const</font> sint ct[4][4] = { {-1, 1, 3,-1}, {-1,-1, 2, 0}, { 1,-1,-1, 3}, { 0, 2,-1,-1} }; <font class="comment">// child table</font>
00427 <font class="keyword">static</font> <font class="keyword">const</font> sint nt[4][4] = { { 3, 1, 3, 1}, { 2, 0, 2, 0}, { 1, 3, 1, 3}, { 0, 2, 0, 2} }; <font class="comment">// neighbor table</font>
00428
00429 sint nlev = nodes.size()-1;
00430 sint child = -1;
00431
00432 <font class="keywordflow">while</font> (nlev > 0)
00433 {
00434 child = ct[children[nlev-1]][side];
00435
00436 <font class="keywordflow">if</font> (child >= 0)
00437 <font class="keywordflow">break</font>;
00438
00439 --nlev;
00440 }
00441
00442 <font class="comment">// neighbor not found in root, leave</font>
00443 <font class="keywordflow">if</font> (nlev == 0)
00444 <font class="keywordflow">continue</font>;
00445
00446 <font class="comment">// get father</font>
00447 node = nodes[nlev-1];
00448
00449 <font class="keywordflow">while</font> (nlev < (sint)nodes.size() && node!=NULL && !node->isLeaf())
00450 {
00451 child = nt[children[nlev-1]][side];
00452 node = node->getChild(child);
00453
00454 ++nlev;
00455 }
00456
00457 <font class="keywordflow">if</font> (node == NULL)
00458 <font class="keywordflow">continue</font>;
00459
00460 <font class="keywordflow">if</font> (node->isLeaf())
00461 {
00462 leaves.push_back((<font class="keyword">const</font> CQuadLeaf*)node);
00463 }
00464 <font class="keywordflow">else</font>
00465 {
00466 explore.push_back(node);
00467
00468 <font class="keywordflow">while</font> (!explore.empty())
00469 {
00470 node = explore.back();
00471 explore.pop_back();
00472
00473 <font class="keywordflow">if</font> (node == NULL)
00474 <font class="keywordflow">continue</font>;
00475
00476 <font class="keywordflow">if</font> (node->isLeaf())
00477 leaves.push_back((<font class="keyword">const</font> CQuadLeaf*)node);
00478 <font class="keywordflow">else</font>
00479 {
00480 explore.push_back(node->getChild((side+2)&3));
00481 explore.push_back(node->getChild((side+3)&3));
00482 }
00483 }
00484 }
00485 }
00486
00487 uint i;
00488 <font class="keywordtype">float</font> di, wi;
00489 <font class="keywordtype">float</font> sum = 0.0;
00490 <font class="keywordtype">float</font> interpZ = 0.0;
00491
00492 <font class="keywordflow">for</font> (i=0; i<leaves.size(); ++i)
00493 {
00494 di = (float)sqrt(<a class="code" href="namespaceNLMISC.html#a214">sqr</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x-leaves[i]->_XCenter)+<a class="code" href="namespaceNLMISC.html#a214">sqr</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y-leaves[i]->_YCenter))*(float)pow(1.5, leaves[i]->_Level);
00495 wi = 1.0f/di;
00496 sum += wi;
00497 interpZ += (leaves[i]->getMinHeight()+leaves[i]->getMaxHeight())*0.5f*wi;
00498 }
00499
00500 <font class="keywordflow">return</font> interpZ / sum;
00501 }
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|