aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/quad__tree_8h-source.html
blob: 90bd7e41ad6dbc1011f0644d27853cf672df4c90 (plain)
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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
<!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>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</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>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</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>
&nbsp;

<!-- 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>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <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> &nbsp; </center>
<hr><h1>quad_tree.h</h1><a href="quad__tree_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000 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 
00027 <font class="preprocessor">#ifndef NL_QUAD_TREE_H</font>
00028 <font class="preprocessor"></font><font class="preprocessor">#define NL_QUAD_TREE_H</font>
00029 <font class="preprocessor"></font>
00030 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="vector_8h.html">nel/misc/vector.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="plane_8h.html">nel/misc/plane.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="matrix_8h.html">nel/misc/matrix.h</a>"</font>
00034 <font class="preprocessor">#include &lt;list&gt;</font>
00035 <font class="preprocessor">#include &lt;vector&gt;</font>
00036 
00037 
00038 <font class="keyword">namespace       </font>NL3D
00039 {
00040 
00041 
00042 
<a name="l00096"></a><a class="code" href="classNL3D_1_1CQuadTree.html">00096</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">class   </font>CQuadTree
00097 {
00098 
00099 <font class="keyword">public</font>:
00101         <font class="keyword">class   </font><a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>;
<a name="l00102"></a><a class="code" href="classNL3D_1_1CQuadTree.html#l0">00102</a>         <font class="keyword">friend</font> <font class="keyword">class    </font><a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>;
00104         <font class="keyword">class   </font><a class="code" href="classNL3D_1_1CQuadTree.html#l1">CConstIterator</a>;
<a name="l00105"></a><a class="code" href="classNL3D_1_1CQuadTree.html#l1">00105</a>         <font class="keyword">friend</font> <font class="keyword">class    </font><a class="code" href="classNL3D_1_1CQuadTree.html#l1">CConstIterator</a>;
00106 
00107 <font class="keyword">public</font>:
00108 
00110         <a class="code" href="classNL3D_1_1CQuadTree.html#a0">CQuadTree</a>();
00111 
00113         <a class="code" href="classNL3D_1_1CQuadTree.html#a1">~CQuadTree</a>();
00114 
00116 
00117 
00132         <font class="keywordtype">void</font> <a class="code" href="classNL3D_1_1CQuadTree.html#z0_0">changeBase</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a>&amp; base);
00133 
00140         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z0_1">create</a>(uint DepthMax, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; center, <font class="keywordtype">float</font> size);
00142 
00143 
00145 
00146 
00147         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z1_0">clear</a>();
00148 
00151         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z1_1">eraseAll</a>();
00152 
00157         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z1_2">erase</a>(<a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a> it);
00158 
00165         <a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>       <a class="code" href="classNL3D_1_1CQuadTree.html#z1_3">insert</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmax, <font class="keyword">const</font> T &amp;val);
00167 
00168 
00170 
00171 
00173         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z2_0">clearSelection</a>();
00174 
00177         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z2_1">selectAll</a>();
00178 
00184         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z2_2">select</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmax);
00185 
00191         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z2_2">select</a>(<font class="keyword">const</font> std::vector&lt;NLMISC::CPlane&gt; &amp;BVolume);
00192 
00198         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z2_4">selectRay</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; source, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; dir);
00199 
00205         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree.html#z2_5">selectSegment</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; source, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; dest);
00206 
00209         <a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>       <a class="code" href="classNL3D_1_1CQuadTree.html#z2_6">begin</a>();
00210 
00213         <a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>       <a class="code" href="classNL3D_1_1CQuadTree.html#z2_7">end</a>();
00215 
00216 
00217 
00218 <font class="comment">// =================</font>
00219 <font class="comment">// =================</font>
00220 <font class="comment">// IMPLEMENTATION.</font>
00221 <font class="comment">// =================</font>
00222 <font class="comment">// =================</font>
00223 <font class="keyword">private</font>:<font class="comment">// Classes.</font>
00224 
00225 
00226         <font class="comment">// =================</font>
00227         <font class="comment">// =================</font>
00228         <font class="comment">// CBaseNode.</font>
00229         <font class="comment">// =================</font>
00230         <font class="comment">// =================</font>
00231         <font class="comment">// Links fo an element node class.</font>
<a name="l00232"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html">00232</a>         <font class="keyword">class                   </font>CBaseNode
00233         {
00234         <font class="keyword">public</font>:
00235                 <font class="comment">// for the Selection list.</font>
<a name="l00236"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m0">00236</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a0">CBaseNode</a>       *<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m0">Prev</a>, *<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m1">Next</a>;
00237                 <font class="comment">// for the quadnode list. A node MAY be pointed by 4 quad (each having the same level).</font>
<a name="l00238"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m2">00238</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a0">CBaseNode</a>       *<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m2">QuadPrevs</a>[4];
<a name="l00239"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m3">00239</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a0">CBaseNode</a>       *<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m3">QuadNexts</a>[4];
00240 
00241 
00242         <font class="keyword">public</font>:
<a name="l00243"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a0">00243</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a0">CBaseNode</a>()
00244                 {
00245                         Prev=Next=NULL;
00246                         QuadPrevs[0]= QuadPrevs[1]= QuadPrevs[2]= QuadPrevs[3]= NULL;
00247                         QuadNexts[0]= QuadNexts[1]= QuadNexts[2]= QuadNexts[3]= NULL;
00248                 }
<a name="l00249"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a1">00249</a>                 <font class="keyword">virtual</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a1">~CBaseNode</a>() {}         <font class="comment">// Empty destructor, but declare it as virtual...</font>
<a name="l00250"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a2">00250</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a2">clear</a>()                         <font class="comment">// update links.</font>
00251                 {
00252                         <font class="comment">// On le retire de la selection.</font>
00253                         <font class="keywordflow">if</font>(Prev)        Prev-&gt;Next= Next;
00254                         <font class="keywordflow">if</font>(Next)        Next-&gt;Prev= Prev;
00255                         Prev=Next=NULL;
00256                         <font class="comment">// On le retire des listes dans les quads.</font>
00257                         <font class="keywordflow">for</font>(uint i=0;i&lt;4;i++)
00258                         {
00259                                 <font class="keywordflow">if</font>(QuadPrevs[i])        {<a class="code" href="debug_8h.html#a6">nlassert</a>(QuadPrevs[i]-&gt;QuadNexts[i]==<font class="keyword">this</font>); QuadPrevs[i]-&gt;QuadNexts[i]= QuadNexts[i];}
00260                                 <font class="keywordflow">if</font>(QuadNexts[i])        {<a class="code" href="debug_8h.html#a6">nlassert</a>(QuadNexts[i]-&gt;QuadPrevs[i]==<font class="keyword">this</font>); QuadNexts[i]-&gt;QuadPrevs[i]= QuadPrevs[i];}
00261                                 QuadPrevs[i]=NULL;
00262                                 QuadNexts[i]=NULL;
00263                         }
00264                 }
<a name="l00265"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a3">00265</a>                 <font class="keywordtype">bool</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#a3">isSelected</a>()    <font class="comment">// return true if Prev is not NULL!!!</font>
00266                 {
00267                         <font class="keywordflow">return</font> Prev!=NULL;
00268                 }
00269         };
00270 
00271 
00272         <font class="comment">// =================</font>
00273         <font class="comment">// =================</font>
00274         <font class="comment">// CNode.</font>
00275         <font class="comment">// =================</font>
00276         <font class="comment">// =================</font>
00277         <font class="comment">// An element node class.</font>
<a name="l00278"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CNode.html">00278</a>         <font class="keyword">class                   </font>CNode : <font class="keyword">public</font> CBaseNode
00279         {
00280         <font class="keyword">public</font>:
00281                 <font class="comment">// A base node, plus the Value.</font>
<a name="l00282"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CNode.html#m0">00282</a>                 T                       <a class="code" href="classNL3D_1_1CQuadTree_1_1CNode.html#m0">Value</a>;
<a name="l00283"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CNode.html#a0">00283</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CNode.html#a0">CNode</a>(<font class="keyword">const</font> T &amp;val) : <a class="code" href="classNL3D_1_1CQuadTree_1_1CNode.html#m0">Value</a>(val) {}
00284         };
00285 
00286 
00287         <font class="comment">// =================</font>
00288         <font class="comment">// =================</font>
00289         <font class="comment">// CQuadNode.</font>
00290         <font class="comment">// =================</font>
00291         <font class="comment">// =================</font>
<a name="l00292"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html">00292</a>         <font class="keyword">class                           </font>CQuadNode
00293         {
00294         <font class="keyword">public</font>:
<a name="l00295"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m0">00295</a>                 uint                    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m0">Level</a>;
<a name="l00296"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m1">00296</a>                 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m1">BBoxMin</a>, <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m2">BBoxMax</a>;
<a name="l00297"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m3">00297</a>                 <font class="keywordtype">bool</font>                    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m3">BBoxNeverRescale</a>;
<a name="l00298"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m4">00298</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a0">CQuadNode</a>               *<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m4">Sons</a>[4];
<a name="l00299"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m5">00299</a>                 CBaseNode               <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m5">RootNode</a>;               <font class="comment">// First element of the element list in this quad.</font>
<a name="l00300"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">00300</a>                 uint                    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>;              <font class="comment">// [0,3]. index of wich list to follow in "Node.QuadNexts[]".</font>
00301                 <font class="comment">/* Topology of sons (top view: axe x/z):</font>
00302 <font class="comment">                        0--1</font>
00303 <font class="comment">                        |  |</font>
00304 <font class="comment">                        2--3</font>
00305 <font class="comment">                */</font>
00306                 
00307 
00308         <font class="keyword">public</font>:
00309                 <font class="comment">// ============================================================================================</font>
<a name="l00310"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a0">00310</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a0">CQuadNode</a>()
00311                 {
00312                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m0">Level</a>=0; Sons[0]= Sons[1]= Sons[2]= Sons[3]= NULL;
00313                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>= 0;
00314                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m3">BBoxNeverRescale</a>=<font class="keyword">true</font>;
00315                 }
00316                 <font class="comment">// ============================================================================================</font>
<a name="l00317"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a1">00317</a>                 <font class="keywordtype">bool</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a1">isLeaf</a>()
00318                 {
00319                         <font class="keywordflow">return</font> Sons[0]==NULL;
00320                 }
00321                 <font class="comment">// ============================================================================================</font>
<a name="l00322"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a2">00322</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a2">clear</a>()
00323                 {
00324                         <font class="comment">// Deletons les element dans ce quad node.</font>
00325                         CBaseNode       *p;
00326                         <font class="keywordflow">while</font>( (p=RootNode.QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>]) )
00327                         {
00328                                 p-&gt;clear();     <font class="comment">// On clear les links. =&gt; RootNode.QuadNexts[ListIndex] modifi� implicitement.</font>
00329                                 <font class="keyword">delete</font> p;       <font class="comment">// On delete cet element!!</font>
00330                         }
00331 
00332                         <font class="comment">// Deletons les quad fils.</font>
00333                         <font class="keywordflow">for</font>(uint i=0;i&lt;4;i++)
00334                         {
00335                                 <font class="keywordflow">if</font>(Sons[i])
00336                                 {
00337                                         Sons[i]-&gt;clear();
00338                                         <font class="keyword">delete</font> Sons[i];
00339                                         Sons[i]= NULL;
00340                                 }
00341                         }
00342                 }
00343                 <font class="comment">// ============================================================================================</font>
<a name="l00344"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a3">00344</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a3">split</a>()
00345                 {
00346                         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a1">isLeaf</a>());
00347                         sint    i;
00348 
00349                         <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
00350                         {
00351                                 Sons[i]= <font class="keyword">new</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a0">CQuadNode</a>;
00352                                 Sons[i]-&gt;Level= <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m0">Level</a>+1;
00353                                 Sons[i]-&gt;ListIndex= i;
00354                         }
00355                         <font class="comment">// Middle compute.</font>
00356                         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>         MidLeft(0,0,0), MidRight(0,0,0), MidTop(0,0,0), MidBottom(0,0,0), Middle(0,0,0);
00357                         MidLeft.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>  = BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>; MidLeft.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>       = (BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)/2;
00358                         MidRight.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>; MidRight.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>      = (BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)/2;
00359                         MidTop.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>   = (BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>)/2; MidTop.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>   = BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>;
00360                         MidBottom.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>= (BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>)/2; MidBottom.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>= BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>;
00361                         Middle.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>   = MidTop.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>; Middle.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = MidLeft.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>;
00362                         <font class="comment">// Sons compute.</font>
00363                         <font class="comment">// Don't care of Y.</font>
00364                         Sons[0]-&gt;BBoxMin = BBoxMin; Sons[0]-&gt;BBoxMax = Middle; 
00365                         Sons[1]-&gt;BBoxMin = MidTop ; Sons[1]-&gt;BBoxMax = MidRight; 
00366                         Sons[2]-&gt;BBoxMin = MidLeft; Sons[2]-&gt;BBoxMax = MidBottom; 
00367                         Sons[3]-&gt;BBoxMin = Middle;  Sons[3]-&gt;BBoxMax = BBoxMax;
00368 
00369                 }
00370 
00371 
00372                 <font class="comment">// ============================================================================================</font>
00373                 <font class="comment">// This is a quadtree, so those tests just test against x/z. (the base of the box).</font>
<a name="l00374"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a4">00374</a>                 <font class="keywordtype">bool</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a4">includeBoxQuad</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmax)
00375                 {
00376                         <font class="keywordflow">if</font>( BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>&lt;= boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> &amp;&amp; BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>&gt;= boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> &amp;&amp; 
00377                                 BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>&lt;= boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> &amp;&amp; BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>&gt;= boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)
00378                                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00379                         <font class="keywordflow">else</font>
00380                                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00381                 }
00382                 <font class="comment">// ============================================================================================</font>
<a name="l00383"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a5">00383</a>                 <font class="keywordtype">bool</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a5">intersectBoxQuad</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmax)
00384                 {
00385                         <font class="comment">// inequality and equality is very important, to ensure that a element box will not fit in too many quad boxes.</font>
00386                         <font class="keywordflow">if</font>(boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> &gt; BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>)        <font class="keywordflow">return</font> <font class="keyword">false</font>;
00387                         <font class="keywordflow">if</font>(boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> &gt; BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)        <font class="keywordflow">return</font> <font class="keyword">false</font>;
00388                         <font class="keywordflow">if</font>(boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> &lt;= BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>)       <font class="keywordflow">return</font> <font class="keyword">false</font>;
00389                         <font class="keywordflow">if</font>(boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> &lt;= BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)       <font class="keywordflow">return</font> <font class="keyword">false</font>;
00390                         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00391                 }
00392                 <font class="comment">// ============================================================================================</font>
<a name="l00393"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a6">00393</a>                 <font class="keywordtype">bool</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a6">intersectBox</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmax)
00394                 {
00395                         <font class="comment">// inequality and equality is very important, to ensure that a element box will not fit in too many quad boxes.</font>
00396                         <font class="keywordflow">if</font>(boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> &gt; BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>)        <font class="keywordflow">return</font> <font class="keyword">false</font>;
00397                         <font class="keywordflow">if</font>(boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> &gt; BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>)        <font class="keywordflow">return</font> <font class="keyword">false</font>;
00398                         <font class="keywordflow">if</font>(boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> &gt; BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)        <font class="keywordflow">return</font> <font class="keyword">false</font>;
00399                         <font class="keywordflow">if</font>(boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> &lt;= BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>)       <font class="keywordflow">return</font> <font class="keyword">false</font>;
00400                         <font class="keywordflow">if</font>(boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> &lt;= BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>)       <font class="keywordflow">return</font> <font class="keyword">false</font>;
00401                         <font class="keywordflow">if</font>(boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> &lt;= BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)       <font class="keywordflow">return</font> <font class="keyword">false</font>;
00402                         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00403                 }
00404                 <font class="comment">// ============================================================================================</font>
<a name="l00405"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a7">00405</a>                 <font class="keywordtype">bool</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a6">intersectBox</a>(std::vector&lt;NLMISC::CPlane&gt; &amp;BVolume)
00406                 {
00407                         <font class="keyword">const</font>   <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;b1=BBoxMin;
00408                         <font class="keyword">const</font>   <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;b2=BBoxMax;
00409 
00410                         <font class="keywordflow">for</font>(sint i=0;i&lt;(int)BVolume.size();i++)
00411                         {
00412                                 <font class="keyword">const</font>   <a class="code" href="classNLMISC_1_1CPlane.html">NLMISC::CPlane</a>  &amp;plane=BVolume[i];
00413                                 <font class="comment">// If only one of the box vertex is IN the plane, then all the box is IN this plane.</font>
00414                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b1.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00415                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b1.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00416                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b1.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00417                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b1.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00418                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00419                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00420                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b1.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00421                                 <font class="keywordflow">if</font>(plane* <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(b2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, b2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>)&lt;=0) <font class="keywordflow">continue</font>;
00422                                 <font class="comment">// If ALL box vertices are OUT of this plane, then the box is OUT of the entire volume.</font>
00423                                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00424                         }
00425                         <font class="comment">// TODO. This is a simple box detection. The box is not really clipped and sometimes, the box will said</font>
00426                         <font class="comment">// it intersect but it is not the case... Here, We should test the real box volume, against BVolume.</font>
00427                         <font class="comment">// But this is more expensive...</font>
00428                         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00429                 }
00430 
00431                 <font class="comment">// ============================================================================================</font>
<a name="l00432"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a8">00432</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a8">addElement</a>(CNode *newNode)
00433                 {
00434                         <a class="code" href="debug_8h.html#a6">nlassert</a>(newNode-&gt;QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>]==NULL);
00435                         newNode-&gt;QuadPrevs[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>]= &amp;RootNode;
00436                         newNode-&gt;QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>]= RootNode.QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>];
00437                         <font class="keywordflow">if</font>(RootNode.QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>])
00438                                 RootNode.QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>]-&gt;QuadPrevs[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>]= newNode;
00439                         RootNode.QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>]= newNode;
00440                 }
00441                 <font class="comment">// ============================================================================================</font>
00442                 <font class="comment">// Insertion of a node in this quad node, or his sons...</font>
<a name="l00443"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a9">00443</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a9">insert</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;boxmax, uint wantdepth, CNode *newNode)
00444                 {
00445                         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m0">Level</a>==0)
00446                         {
00447                                 <font class="comment">// Tous les elements qui sortent du quadtree sont forc�ment dans le noeud root.</font>
00448                                 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a4">includeBoxQuad</a>(boxmin, boxmax))
00449                                 {
00450                                         <font class="comment">// Il faut agrandir la BBox en Y du quadnode.</font>
00451                                         <font class="keywordflow">if</font>(BBoxNeverRescale)
00452                                         {
00453                                                 BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00454                                                 BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00455                                                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m3">BBoxNeverRescale</a>= <font class="keyword">false</font>;
00456                                         }
00457                                         <font class="keywordflow">else</font>
00458                                         {
00459                                                 BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>);
00460                                                 BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= std::max(boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>);
00461                                         }
00462                                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a8">addElement</a>(newNode);
00463                                         <font class="keywordflow">return</font>;
00464                                 }
00465                         }
00466 
00467                         <font class="comment">// Si au moins une partie de l'element n'est pas dans le noeud de ce quad, exit.</font>
00468                         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a5">intersectBoxQuad</a>(boxmin, boxmax))
00469                                 <font class="keywordflow">return</font>;
00470 
00471                         <font class="comment">// Que l'on insere ici ou dans les fils, il faut agrandir la BBox en Y du quadnode.</font>
00472                         <font class="keywordflow">if</font>(BBoxNeverRescale)
00473                         {
00474                                 BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00475                                 BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00476                                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m3">BBoxNeverRescale</a>= <font class="keyword">false</font>;
00477                         }
00478                         <font class="keywordflow">else</font>
00479                         {
00480                                 BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(boxmin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, BBoxMin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>);
00481                                 BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>= std::max(boxmax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, BBoxMax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>);
00482                         }
00483 
00484                         <font class="comment">// Si on est au bon, niveau, on a plus qu'� l'ins�rer dans ce node.</font>
00485                         <font class="keywordflow">if</font>(wantdepth==<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m0">Level</a>)
00486                         {
00487                                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a8">addElement</a>(newNode);
00488                         }
00489                         <font class="keywordflow">else</font>
00490                         {
00491                                 <font class="comment">// Si le quad est une feuille, il faut le splitter (car on est pas encore arriv� au bon niveau).</font>
00492                                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a1">isLeaf</a>())
00493                                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a3">split</a>();
00494 
00495                                 <font class="comment">// Et on cherche � mettre l'�l�ment dans un de ces noeuds.</font>
00496                                 Sons[0]-&gt;insert(boxmin, boxmax, wantdepth, newNode);
00497                                 Sons[1]-&gt;insert(boxmin, boxmax, wantdepth, newNode);
00498                                 Sons[2]-&gt;insert(boxmin, boxmax, wantdepth, newNode);
00499                                 Sons[3]-&gt;insert(boxmin, boxmax, wantdepth, newNode);
00500                         }
00501 
00502                 }
00503 
00504                 
00505                 <font class="comment">// ============================================================================================</font>
00506                 <font class="comment">// Selection.</font>
<a name="l00507"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a10">00507</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a10">selectLocalNodes</a>(CBaseNode      &amp;selroot)
00508                 {
00509                         CBaseNode       *p= RootNode.QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>];
00510                         <font class="keywordflow">while</font>(p)
00511                         {
00512                                 <font class="keywordflow">if</font>(!p-&gt;isSelected())
00513                                 {
00514                                         p-&gt;Prev= &amp;selroot;
00515                                         p-&gt;Next= selroot.Next;
00516                                         <font class="keywordflow">if</font>(selroot.Next)
00517                                                 selroot.Next-&gt;Prev= p;
00518                                         selroot.Next= p;
00519                                 }
00520                                 p=p-&gt;QuadNexts[<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m6">ListIndex</a>];
00521                         }
00522                 }
00523                 <font class="comment">// ============================================================================================</font>
<a name="l00524"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a11">00524</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a11">selectAll</a>(CBaseNode     &amp;selroot)
00525                 {
00526                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a10">selectLocalNodes</a>(selroot);
00527                         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a1">isLeaf</a>())
00528                         {
00529                                 Sons[0]-&gt;selectAll(selroot);
00530                                 Sons[1]-&gt;selectAll(selroot);
00531                                 Sons[2]-&gt;selectAll(selroot);
00532                                 Sons[3]-&gt;selectAll(selroot);
00533                         }
00534                 }
00535                 <font class="comment">// ============================================================================================</font>
<a name="l00536"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a12">00536</a>                 <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a12">select</a>(CBaseNode &amp;selroot, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmax)
00537                 {
00538                         <font class="comment">// TODO:</font>
00539                         <font class="comment">// ya un bug avec le level0: en effet la bbox n'a pas �t� agrandie pour contenir les elements.</font>
00540                         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a6">intersectBox</a>(bboxmin, bboxmax))
00541                                 <font class="keywordflow">return</font>;
00542                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a10">selectLocalNodes</a>(selroot);
00543                         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a1">isLeaf</a>())
00544                         {
00545                                 Sons[0]-&gt;select(selroot, bboxmin, bboxmax);
00546                                 Sons[1]-&gt;select(selroot, bboxmin, bboxmax);
00547                                 Sons[2]-&gt;select(selroot, bboxmin, bboxmax);
00548                                 Sons[3]-&gt;select(selroot, bboxmin, bboxmax);
00549                         }
00550                 }
00551                 <font class="comment">// ============================================================================================</font>
<a name="l00552"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a13">00552</a>                 <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a12">select</a>(CBaseNode &amp;selroot, std::vector&lt;NLMISC::CPlane&gt; &amp;BVolume)
00553                 {
00554                         <font class="comment">// TODO:</font>
00555                         <font class="comment">// ya un bug avec le level0: en effet la bbox n'a pas �t� agrandie pour contenir les elements.</font>
00556                         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a6">intersectBox</a>(BVolume))
00557                                 <font class="keywordflow">return</font>;
00558                         <a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a10">selectLocalNodes</a>(selroot);
00559                         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a1">isLeaf</a>())
00560                         {
00561                                 Sons[0]-&gt;select(selroot, BVolume);
00562                                 Sons[1]-&gt;select(selroot, BVolume);
00563                                 Sons[2]-&gt;select(selroot, BVolume);
00564                                 Sons[3]-&gt;select(selroot, BVolume);
00565                         }
00566                 }
00567         };
00568 
00569 
00570 
00571 <font class="comment">// =================</font>
00572 <font class="comment">// =================</font>
00573 <font class="comment">// Attributes/Methods/iterators..</font>
00574 <font class="comment">// =================</font>
00575 <font class="comment">// =================</font>
00576 <font class="keyword">private</font>:<font class="comment">// Attributes.</font>
<a name="l00577"></a><a class="code" href="classNL3D_1_1CQuadTree.html#o0">00577</a>         CQuadNode       <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>;
<a name="l00578"></a><a class="code" href="classNL3D_1_1CQuadTree.html#o1">00578</a>         CBaseNode       <a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>;
<a name="l00579"></a><a class="code" href="classNL3D_1_1CQuadTree.html#o2">00579</a>         uint            <a class="code" href="classNL3D_1_1CQuadTree.html#o2">_DepthMax</a>;
<a name="l00580"></a><a class="code" href="classNL3D_1_1CQuadTree.html#o3">00580</a>         <font class="keywordtype">float</font>           <a class="code" href="classNL3D_1_1CQuadTree.html#o3">_Size</a>;
<a name="l00581"></a><a class="code" href="classNL3D_1_1CQuadTree.html#o4">00581</a>         <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a>         <a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>;
00582 
00583 <font class="keyword">private</font>:<font class="comment">// Methods.</font>
00584 
00585 
00586 
00587 <font class="keyword">public</font>:
00588         <font class="comment">// CLASS const_iterator.</font>
<a name="l00589"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html">00589</a>         <font class="keyword">class </font>const_iterator
00590         {
00591         <font class="keyword">public</font>:
<a name="l00592"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">00592</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>()        {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>=NULL;}
<a name="l00593"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a1">00593</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>(CNode *p) : <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>(p) {}
<a name="l00594"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a2">00594</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#l1">CIterator</a>&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>) : <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>) {}
00595 
<a name="l00596"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a3">00596</a>                 <font class="keyword">const</font> T&amp;        <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a3">operator*</a>()<font class="keyword"> const</font>
00597 <font class="keyword">                        </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>-&gt;Value; }
00598                 <font class="comment">// Doesn't work...</font>
00599                 <font class="comment">/*const T*      operator-&gt;() const</font>
00600 <font class="comment">                        {return (&amp;**this); }*/</font>
<a name="l00601"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a4">00601</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a4">operator++</a>()
00602                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>-&gt;Next); <font class="keywordflow">return</font> (*this); }
<a name="l00603"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a5">00603</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a4">operator++</a>(<font class="keywordtype">int</font>)
00604                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a> tmp = *<font class="keyword">this</font>; ++*<font class="keyword">this</font>; <font class="keywordflow">return</font> (tmp); }
<a name="l00605"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a6">00605</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a6">operator--</a>()
00606                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>-&gt;Prev); <font class="keywordflow">return</font> (*this); }
<a name="l00607"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a7">00607</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a6">operator--</a>(<font class="keywordtype">int</font>)
00608                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a> tmp = *<font class="keyword">this</font>; --*<font class="keyword">this</font>; <font class="keywordflow">return</font> (tmp); }
<a name="l00609"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a8">00609</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a8">operator==</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)<font class="keyword"> const</font>
00610 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a> == x._Ptr); }
<a name="l00611"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a9">00611</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a9">operator!=</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)<font class="keyword"> const</font>
00612 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (!(*<font class="keyword">this</font> == x)); }
00613         <font class="keyword">protected</font>:
<a name="l00614"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">00614</a>                 CNode   *<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>;
<a name="l00615"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#l0">00615</a>                 <font class="keyword">friend</font> <font class="keyword">class </font>CQuadTree&lt;T&gt;;
<a name="l00616"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#l1">00616</a>                 <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#l1">CIterator</a>;
00617         };
00618 
00619         <font class="comment">// CLASS CIterator</font>
<a name="l00620"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html">00620</a>         <font class="keyword">class </font><a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a> : <font class="keyword">public</font> const_iterator
00621         {
00622         <font class="keyword">public</font>:
<a name="l00623"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">00623</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a>()                     {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>=NULL;}
<a name="l00624"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a1">00624</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a>(CNode *p) : <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>(p) {}
<a name="l00625"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a2">00625</a>                 T&amp;      <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a2">operator*</a>()<font class="keyword"> const</font>
00626 <font class="keyword">                        </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>-&gt;Value; }
00627                 <font class="comment">// Doesn't work...</font>
00628                 <font class="comment">/*T*    operator-&gt;() const</font>
00629 <font class="comment">                        {return (&amp;**this); }*/</font>
<a name="l00630"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a3">00630</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a3">operator++</a>()
00631                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>-&gt;Next); <font class="keywordflow">return</font> (*this); }
<a name="l00632"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a4">00632</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a> <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a3">operator++</a>(<font class="keywordtype">int</font>)
00633                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a> tmp = *<font class="keyword">this</font>; ++*<font class="keyword">this</font>; <font class="keywordflow">return</font> (tmp); }
<a name="l00634"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a5">00634</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a5">operator--</a>()
00635                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a>-&gt;Prev); <font class="keywordflow">return</font> (*this); }
<a name="l00636"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a6">00636</a>                 <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a> <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a5">operator--</a>(<font class="keywordtype">int</font>)
00637                         {<a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a0">CIterator</a> tmp = *<font class="keyword">this</font>; --*<font class="keyword">this</font>; <font class="keywordflow">return</font> (tmp); }
<a name="l00638"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a7">00638</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a7">operator==</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)<font class="keyword"> const</font>
00639 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#n0">_Ptr</a> == x._Ptr); }
<a name="l00640"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a8">00640</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#a8">operator!=</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadTree_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)<font class="keyword"> const</font>
00641 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (!(*<font class="keyword">this</font> == x)); }
00642         <font class="keyword">protected</font>:
<a name="l00643"></a><a class="code" href="classNL3D_1_1CQuadTree_1_1CIterator.html#l0">00643</a>                 <font class="keyword">friend</font> <font class="keyword">class </font>CQuadTree&lt;T&gt;;
00644         };
00645 
00646 };
00647 
00648 
00649 
00650 <font class="comment">// ============================================================================================</font>
00651 <font class="comment">// ============================================================================================</font>
00652 <font class="comment">// Template CQuadTree implementation. Construction/Destruction.</font>
00653 <font class="comment">// ============================================================================================</font>
00654 <font class="comment">// ============================================================================================</font>
00655 
00656                 
00657 <font class="comment">// ============================================================================================</font>
<a name="l00658"></a><a class="code" href="classNL3D_1_1CQuadTree.html#a0">00658</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       CQuadTree&lt;T&gt;::CQuadTree()
00659 {
00660         <a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m1">Next</a>= NULL;
00661         <a class="code" href="classNL3D_1_1CQuadTree.html#o2">_DepthMax</a>= 0;
00662         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m1">BBoxMin</a>.<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(-0.5, 0, -0.5);
00663         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m2">BBoxMax</a>.<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>( 0.5, 0,  0.5);
00664         <a class="code" href="classNL3D_1_1CQuadTree.html#o3">_Size</a>=1;
00665 
00666         <a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a>();
00667 }
00668 <font class="comment">// ============================================================================================</font>
<a name="l00669"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z0_0">00669</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font> CQuadTree&lt;T&gt;::changeBase(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a>&amp; base)
00670 {
00671         <a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>=base;
00672 }
00673 <font class="comment">// ============================================================================================</font>
00674 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       CQuadTree&lt;T&gt;::~CQuadTree&lt;T&gt;()
00675 {
00676         clear();
00677 }
00678 <font class="comment">// ============================================================================================</font>
<a name="l00679"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z1_0">00679</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::clear()
00680 {
00681         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a2">clear</a>();
00682         <a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m1">Next</a>= NULL;
00683 }
00684 <font class="comment">// ============================================================================================</font>
<a name="l00685"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z0_1">00685</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::create(uint DepthMax, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; center, <font class="keywordtype">float</font> size)
00686 {
00687         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> mycenter=<a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>*center;
00688         <a class="code" href="classNL3D_1_1CQuadTree.html#z1_0">clear</a>();
00689         <a class="code" href="classNL3D_1_1CQuadTree.html#o2">_DepthMax</a>= DepthMax;
00690         <a class="code" href="classNL3D_1_1CQuadTree.html#o3">_Size</a>= size;
00691         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m1">BBoxMin</a>= mycenter-<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(size/2, 0 , size/2);
00692         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#m2">BBoxMax</a>= mycenter+<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(size/2, 0 , size/2);
00693 }
00694 
00695 
00696 <font class="comment">// ============================================================================================</font>
00697 <font class="comment">// ============================================================================================</font>
00698 <font class="comment">// Template CQuadTree implementation.  Element Insertion/Deletion.</font>
00699 <font class="comment">// ============================================================================================</font>
00700 <font class="comment">// ============================================================================================</font>
00701 
00702 
00703 <font class="comment">// ============================================================================================</font>
<a name="l00704"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z1_1">00704</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::eraseAll()
00705 {
00706         <a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>                               it;
00707         std::vector&lt;CIterator&gt;  its;
00708 
00709         <font class="comment">// First, make a copy of all elements.</font>
00710         <a class="code" href="classNL3D_1_1CQuadTree.html#z2_1">selectAll</a>();
00711         <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CQuadTree.html#z2_6">begin</a>();it!=<a class="code" href="classNL3D_1_1CQuadTree.html#z2_7">end</a>();it++)
00712         {
00713                 its.push_back(it);
00714         }
00715 
00716         <font class="comment">// Then erase them. Must do it OUTSIDE the select loop.</font>
00717         <font class="keywordflow">for</font>(sint i=0;i&lt;(sint)its.size();i++)
00718         {
00719                 <a class="code" href="classNL3D_1_1CQuadTree.html#z1_2">erase</a>(its[i]);
00720         }
00721 }
00722 <font class="comment">// ============================================================================================</font>
<a name="l00723"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z1_2">00723</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::erase(CIterator it)
00724 {
00725         CNode   *p=it._Ptr;
00726         <font class="keywordflow">if</font>(p)
00727         {
00728                 <font class="comment">// Clear links.</font>
00729                 p-&gt;clear();
00730 
00731                 <font class="comment">// delete it!!</font>
00732                 <font class="keyword">delete</font> p;
00733         }
00734 }
00735 <font class="comment">// ============================================================================================</font>
<a name="l00736"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z1_3">00736</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       CQuadTree&lt;T&gt;::CIterator CQuadTree&lt;T&gt;::insert(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmax, <font class="keyword">const</font> T &amp;val)
00737 {
00738         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> myboxmin2=<a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>*bboxmin;
00739         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> myboxmax2=<a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>*bboxmax;
00740         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> myboxmin (std::min (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>), std::min (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>), std::min (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>));
00741         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> myboxmax (std::max (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>), std::max (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>), std::max (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>));
00742 
00743         CNode   *newNode=<font class="keyword">new</font> CNode(val);
00744 
00745         <a class="code" href="debug_8h.html#a6">nlassert</a>(myboxmax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>&gt;=myboxmin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>);
00746         <a class="code" href="debug_8h.html#a6">nlassert</a>(myboxmax.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>&gt;=myboxmin.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>);
00747         <a class="code" href="debug_8h.html#a6">nlassert</a>(myboxmax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>&gt;=myboxmin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>);
00748 
00749         <font class="keywordtype">float</font>   boxsize= std::max(myboxmax.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>-myboxmin.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, myboxmax.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>-myboxmin.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> );
00750         <font class="comment">// Prevent float precision problems. Increase bbox size a little.</font>
00751         boxsize*=1.01f;
00752         <font class="comment">// We must find the level quad which is just bigger.</font>
00753         <font class="keywordtype">float</font>   wantsize=<a class="code" href="classNL3D_1_1CQuadTree.html#o3">_Size</a>;
00754         uint    wantdepth=0;
00755         <font class="keywordflow">while</font>(boxsize&lt;wantsize/2 &amp;&amp; wantdepth&lt;<a class="code" href="classNL3D_1_1CQuadTree.html#o2">_DepthMax</a>)
00756         {
00757                 wantsize/=2;
00758                 wantdepth++;
00759         }
00760 
00761         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a9">insert</a>(myboxmin, myboxmax, wantdepth, newNode);
00762 
00763         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>(newNode);
00764 }
00765 
00766 
00767 <font class="comment">// ============================================================================================</font>
00768 <font class="comment">// ============================================================================================</font>
00769 <font class="comment">// Template CQuadTree implementation. Quad Selection, element iteration.</font>
00770 <font class="comment">// ============================================================================================</font>
00771 <font class="comment">// ============================================================================================</font>
00772 
00773 
00774 <font class="comment">// ============================================================================================</font>
<a name="l00775"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_0">00775</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::clearSelection()
00776 {
00777         CBaseNode       *p;
00778         <font class="keywordflow">while</font>(p=<a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m1">Next</a>)
00779         {
00780                 <font class="comment">// On retire ce noeud de la selection. Ce qui va modifier implicitement _Selection.Next.</font>
00781                 <font class="keywordflow">if</font>(p-&gt;Prev)     p-&gt;Prev-&gt;Next= p-&gt;Next;
00782                 <font class="keywordflow">if</font>(p-&gt;Next)     p-&gt;Next-&gt;Prev= p-&gt;Prev;
00783                 p-&gt;Prev=p-&gt;Next=NULL;
00784         }
00785 }
00786 <font class="comment">// ============================================================================================</font>
<a name="l00787"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_1">00787</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::selectAll()
00788 {
00789         <a class="code" href="classNL3D_1_1CQuadTree.html#z2_0">clearSelection</a>();
00790         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a11">selectAll</a>(<a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>);
00791 }
00792 <font class="comment">// ============================================================================================</font>
<a name="l00793"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_2">00793</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::select(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmin, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;bboxmax)
00794 {
00795         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> myboxmin2=<a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>*bboxmin;
00796         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> myboxmax2=<a class="code" href="classNL3D_1_1CQuadTree.html#o4">_ChangeBasis</a>*bboxmax;
00797         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> bboxminCopy (std::min (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>), std::min (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>), std::min (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>));
00798         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> bboxmaxCopy (std::max (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>), std::max (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>), std::max (myboxmin2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>, myboxmax2.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>));
00799 
00800         <a class="code" href="classNL3D_1_1CQuadTree.html#z2_0">clearSelection</a>();
00801         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a12">select</a>(<a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>, bboxminCopy, bboxmaxCopy);
00802 }
00803 <font class="comment">// ============================================================================================</font>
<a name="l00804"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_3">00804</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::select(<font class="keyword">const</font> std::vector&lt;NLMISC::CPlane&gt; &amp;BVolume)
00805 {
00806         std::vector&lt;NLMISC::CPlane&gt; BVolumeCopy;
00807         BVolumeCopy.resize (BVolume.size());
00808         <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i=0; i&lt;(int)BVolumeCopy.size(); i++)
00809         {
00810                 BVolumeCopy[i]=BVolume[i]*((_ChangeBasis).inverted());
00811         }
00812 
00813         <a class="code" href="classNL3D_1_1CQuadTree.html#z2_0">clearSelection</a>();
00814         <a class="code" href="classNL3D_1_1CQuadTree.html#o0">_QuadRoot</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CQuadNode.html#a12">select</a>(<a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>, BVolumeCopy);
00815 }
00816 <font class="comment">// ============================================================================================</font>
<a name="l00817"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_4">00817</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::selectRay(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; source, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; dir)
00818 {
00819         <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> mat;
00820         mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a> ();
00821 
00822         <font class="comment">// Set a wrong matrix</font>
00823         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> vTmp=dir^((fabs(vTmp*CVector(1,0,0))&gt;0.f)?CVector(1,0,0):CVector(0,1,0));
00824         mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_1">setRot</a> (dir, vTmp, dir^vTmp);
00825 
00826         <font class="comment">// Normalize it Yoyo!</font>
00827         mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z293_8">normalize</a> (<a class="code" href="classNLMISC_1_1CMatrix.html#s6s0">NLMISC::CMatrix::XYZ</a>);
00828 
00829         <font class="comment">// Get the planes..</font>
00830         std::vector&lt;NLMISC::CPlane&gt; BVolume;
00831         BVolume.reserve (4);
00832         
00833         <font class="comment">// Setup the planes</font>
00834         <a class="code" href="classNLMISC_1_1CPlane.html">NLMISC::CPlane</a> plane;
00835         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>(), source);
00836         BVolume.push_back (plane);
00837         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">getK</a>(), source);
00838         BVolume.push_back (plane);
00839         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (-mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>(), source);
00840         BVolume.push_back (plane);
00841         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (-mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">getK</a>(), source);
00842         BVolume.push_back (plane);
00843 
00844         <font class="comment">// Select the nodes</font>
00845         <a class="code" href="classNL3D_1_1CQuadTree.html#z2_2">select</a> (BVolume);
00846 }
00847 <font class="comment">// ============================================================================================</font>
<a name="l00848"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_5">00848</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadTree&lt;T&gt;::selectSegment(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; source, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; dest)
00849 {
00850         <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> mat;
00851         mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a> ();
00852 
00853         <font class="comment">// Set a wrong matrix</font>
00854         CVector dir=dest-source;
00855         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> vTmp=dir^((fabs(vTmp*CVector(1,0,0))&gt;0.f)?CVector(1,0,0):CVector(0,1,0));
00856         mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_1">setRot</a> (dir, vTmp, dir^vTmp);
00857 
00858         <font class="comment">// Normalize it Yoyo!</font>
00859         mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z293_8">normalize</a> (<a class="code" href="classNLMISC_1_1CMatrix.html#s6s0">NLMISC::CMatrix::XYZ</a>);
00860 
00861         <font class="comment">// Get the planes..</font>
00862         std::vector&lt;NLMISC::CPlane&gt; BVolume;
00863         BVolume.reserve (4);
00864         
00865         <font class="comment">// Setup the planes</font>
00866         <a class="code" href="classNLMISC_1_1CPlane.html">NLMISC::CPlane</a> plane;
00867         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>(), source);
00868         BVolume.push_back (plane);
00869         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">getK</a>(), source);
00870         BVolume.push_back (plane);
00871         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (-mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>(), source);
00872         BVolume.push_back (plane);
00873         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (-mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">getK</a>(), source);
00874         BVolume.push_back (plane);
00875         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_7">getI</a>(), dest);
00876         BVolume.push_back (plane);
00877         plane.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a> (-mat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_7">getI</a>(), source);
00878         BVolume.push_back (plane);
00879 
00880         <font class="comment">// Select the nodes</font>
00881         <a class="code" href="classNL3D_1_1CQuadTree.html#z2_2">select</a> (BVolume);
00882 }
00883 <font class="comment">// ============================================================================================</font>
<a name="l00884"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_6">00884</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       CQuadTree&lt;T&gt;::CIterator CQuadTree&lt;T&gt;::begin()
00885 {
00886         <font class="keywordflow">return</font> (CNode*)(<a class="code" href="classNL3D_1_1CQuadTree.html#o1">_Selection</a>.<a class="code" href="classNL3D_1_1CQuadTree_1_1CBaseNode.html#m1">Next</a>);
00887 }
00888 <font class="comment">// ============================================================================================</font>
<a name="l00889"></a><a class="code" href="classNL3D_1_1CQuadTree.html#z2_7">00889</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       CQuadTree&lt;T&gt;::CIterator CQuadTree&lt;T&gt;::end()
00890 {
00891         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadTree.html#l0">CIterator</a>(NULL);
00892 }
00893 
00894 
00895 }
00896 
00897 <font class="preprocessor">#endif</font>
00898 <font class="preprocessor"></font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </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>