aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/3d_2quad__grid_8h-source.html
blob: 8284721d2a455a4d0757e6fe522ea5f9f95fd7ea (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
<!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="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><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="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/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="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/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="/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:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>quad_grid.h</h1><a href="3d_2quad__grid_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 <font class="preprocessor">#ifndef NL_QUAD_GRID_H</font>
00027 <font class="preprocessor"></font><font class="preprocessor">#define NL_QUAD_GRID_H</font>
00028 <font class="preprocessor"></font>
00029 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="vector_8h.html">nel/misc/vector.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="plane_8h.html">nel/misc/plane.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="matrix_8h.html">nel/misc/matrix.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="stl__block__list_8h.html">nel/misc/stl_block_list.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
00035 <font class="preprocessor">#include &lt;vector&gt;</font>
00036 
00037 
00038 <font class="keyword">namespace </font>NL3D 
00039 {
00040 
00041 
00042 <font class="keyword">using</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>;
00043 
00044 <font class="comment">// ***************************************************************************</font>
00045 <font class="comment">// Default Size of a block for allocation of elements and elements node list in the grid.</font>
<a name="l00046"></a><a class="code" href="3d_2quad__grid_8h.html#a0">00046</a> <font class="preprocessor">#define NL3D_QUAD_GRID_ALLOC_BLOCKSIZE  16</font>
00047 <font class="preprocessor"></font>
00048 
00049 <font class="comment">// ***************************************************************************</font>
<a name="l00076"></a><a class="code" href="classNL3D_1_1CQuadGrid.html">00076</a> <font class="comment"></font><font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">class   </font>CQuadGrid
00077 {
00078 <font class="keyword">public</font>:
00080         <font class="keyword">class   </font><a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>;
<a name="l00081"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#l0">00081</a>         <font class="keyword">friend</font> <font class="keyword">class    </font><a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>;
00082 
00083 <font class="keyword">public</font>:
00084 
00086         <a class="code" href="classNL3D_1_1CQuadGrid.html#a0">CQuadGrid</a>(uint memoryBlockSize= <a class="code" href="3d_2quad__grid_8h.html#a0">NL3D_QUAD_GRID_ALLOC_BLOCKSIZE</a>);
00087 
00089         <a class="code" href="classNL3D_1_1CQuadGrid.html#a1">~CQuadGrid</a>();
00090 
00092 
00093 
00108         <font class="keywordtype">void</font>                    <a class="code" href="classNL3D_1_1CQuadGrid.html#z741_0">changeBase</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a>&amp; base);
00109 
00116         <font class="keywordtype">void</font>                    <a class="code" href="classNL3D_1_1CQuadGrid.html#z741_1">create</a>(uint size, <font class="keywordtype">float</font> eltSize);
00117 
00118         <font class="comment">// Get creation parameters.</font>
<a name="l00119"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z741_2">00119</a>         <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a>   &amp;<a class="code" href="classNL3D_1_1CQuadGrid.html#z741_2">getBasis</a>()<font class="keyword"> const </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>;}
<a name="l00120"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z741_3">00120</a>         uint                                    <a class="code" href="classNL3D_1_1CQuadGrid.html#z741_3">getSize</a>()<font class="keyword"> const </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>;}
<a name="l00121"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z741_4">00121</a>         <font class="keywordtype">float</font>                                   <a class="code" href="classNL3D_1_1CQuadGrid.html#z741_4">getEltSize</a>()<font class="keyword"> const </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#o3">_EltSize</a>;}
00123 
00125 
00126 
00129         <font class="keywordtype">void</font>                    <a class="code" href="classNL3D_1_1CQuadGrid.html#z742_0">clear</a>();
00130 
00138         <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>               <a class="code" href="classNL3D_1_1CQuadGrid.html#z742_1">erase</a>(<a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a> it);
00139 
00165         <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>               <a class="code" href="classNL3D_1_1CQuadGrid.html#z742_2">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 
00174         <font class="keywordtype">void</font>                    <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_0">clearSelection</a>();
00175 
00179         <font class="keywordtype">void</font>                    <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_1">selectAll</a>();
00180 
00187         <font class="keywordtype">void</font>                    <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_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);
00188 
00189 
00193         <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>               <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_3">begin</a>();
00194 
00198         <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>               <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_4">end</a>();
00200 
00201 
00202 <font class="comment">// =================</font>
00203 <font class="comment">// =================</font>
00204 <font class="comment">// IMPLEMENTATION.</font>
00205 <font class="comment">// =================</font>
00206 <font class="comment">// =================</font>
00207 <font class="keyword">private</font>:<font class="comment">// Classes.</font>
00208 
<a name="l00209"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html">00209</a>         <font class="keyword">class   </font>CBaseNode
00210         {
00211         <font class="keyword">public</font>:
<a name="l00212"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m0">00212</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#a0">CBaseNode</a>       *<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m0">Prev</a>,*<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>;    <font class="comment">// For selection.</font>
<a name="l00213"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m2">00213</a>                 <font class="keywordtype">bool</font>            <a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m2">Selected</a>;               <font class="comment">// true if owned by _SelectedList, or by _UnSelectedList.</font>
<a name="l00214"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#a0">00214</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#a0">CBaseNode</a>() {Prev= Next= NULL;}
00215         };
00216 
<a name="l00217"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html">00217</a>         <font class="keyword">class   </font>CNode : <font class="keyword">public</font> CBaseNode
00218         {
00219         <font class="keyword">public</font>:
<a name="l00220"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m0">00220</a>                 T               <a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m0">Elt</a>;
<a name="l00221"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m2">00221</a>                 uint16  <a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m1">x0</a>,<a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m2">x1</a>;                  <font class="comment">// The location of the elt in the grid. Used for erase().</font>
<a name="l00222"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m4">00222</a>                 uint16  <a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m3">y0</a>,<a class="code" href="classNL3D_1_1CQuadGrid_1_1CNode.html#m4">y1</a>;
00223         };
00224 
<a name="l00225"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CQuadNode.html">00225</a>         <font class="keyword">class   </font>CQuadNode
00226         {
00227         <font class="keyword">public</font>:
<a name="l00228"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CQuadNode.html#m0">00228</a>                 <a class="code" href="classNLMISC_1_1CSTLBlockList.html">NLMISC::CSTLBlockList&lt;CNode*&gt;</a>   <a class="code" href="classNL3D_1_1CQuadGrid_1_1CQuadNode.html#m0">Nodes</a>;
00229 
<a name="l00230"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CQuadNode.html#a0">00230</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CQuadNode.html#a0">CQuadNode</a>(<a class="code" href="classNLMISC_1_1CBlockMemory.html">NLMISC::CBlockMemory&lt;CNode*, false&gt;</a> *bm) : Nodes(bm) {}
00231         };
00232 
00233 <font class="keyword">private</font>:<font class="comment">// Atttributes.</font>
<a name="l00234"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o0">00234</a>         std::vector&lt;CQuadNode&gt;  <a class="code" href="classNL3D_1_1CQuadGrid.html#o0">_Grid</a>;
<a name="l00235"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o1">00235</a>         sint                            <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>;
<a name="l00236"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o2">00236</a>         sint                            <a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>;
<a name="l00237"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o3">00237</a>         <font class="keywordtype">float</font>                           <a class="code" href="classNL3D_1_1CQuadGrid.html#o3">_EltSize</a>;
<a name="l00238"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o4">00238</a>         <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a>         <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>;
00239         <font class="comment">// Selection. Elements are either in _SelectedList or in _UnSelectedList</font>
<a name="l00240"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o5">00240</a>         CBaseNode                       <a class="code" href="classNL3D_1_1CQuadGrid.html#o5">_SelectedList</a>;          <font class="comment">// list of elements selected.</font>
<a name="l00241"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o6">00241</a>         CBaseNode                       <a class="code" href="classNL3D_1_1CQuadGrid.html#o6">_UnSelectedList</a>;        <font class="comment">// circular list of elements not selected</font>
00242         <font class="comment">// The memory for nodes</font>
<a name="l00243"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o7">00243</a>         <a class="code" href="classNLMISC_1_1CBlockMemory.html">NLMISC::CBlockMemory&lt;CNode&gt;</a>                                     <a class="code" href="classNL3D_1_1CQuadGrid.html#o7">_NodeBlockMemory</a>;
00244         <font class="comment">// The memory for node list</font>
<a name="l00245"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#o8">00245</a>         <a class="code" href="classNLMISC_1_1CBlockMemory.html">NLMISC::CBlockMemory&lt;CNode*, false&gt;</a>                     <a class="code" href="classNL3D_1_1CQuadGrid.html#o8">_NodeListBlockMemory</a>;
00246 
00247 
00248 <font class="keyword">private</font>:<font class="comment">// Methods.</font>
00249 
00250         <font class="comment">// link a node to a root: Selected or UnSelected list</font>
<a name="l00251"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#c0">00251</a>         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadGrid.html#c0">linkToRoot</a>(CBaseNode &amp;root, CBaseNode *ptr)
00252         {
00253                 ptr-&gt;Prev= &amp;root;
00254                 ptr-&gt;Next= root.Next;
00255                 ptr-&gt;Prev-&gt;Next= ptr;
00256                 <font class="keywordflow">if</font>(ptr-&gt;Next)
00257                         ptr-&gt;Next-&gt;Prev= ptr;
00258         }
00259 
00260         <font class="comment">// return the coordinates on the grid of what include the bbox.</font>
<a name="l00261"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#c1">00261</a>         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadGrid.html#c1">selectQuads</a>(CVector bmin, CVector bmax, sint &amp;x0, sint &amp;x1, sint &amp;y0, sint &amp;y1)
00262         {
00263                 CVector         bminp, bmaxp;
00264                 bminp= bmin;
00265                 bmaxp= bmax;
00266                 bmin.minof(bminp, bmaxp);
00267                 bmax.maxof(bminp, bmaxp);
00268                 bmin/= <a class="code" href="classNL3D_1_1CQuadGrid.html#o3">_EltSize</a>;
00269                 bmax/= <a class="code" href="classNL3D_1_1CQuadGrid.html#o3">_EltSize</a>;
00270                 x0= (sint)(floor(bmin.x));
00271                 x1= (sint)(ceil(bmax.x));
00272                 y0= (sint)(floor(bmin.y));
00273                 y1= (sint)(ceil(bmax.y));
00274 
00275                 <font class="comment">// Very special case where the bbox.size==0 AND position is JUST on an edge of a case.</font>
00276                 <font class="keywordflow">if</font>(x0==x1)
00277                         x1++;
00278                 <font class="keywordflow">if</font>(y0==y1)
00279                         y1++;
00280 
00281                 <font class="comment">// Manage tiling.</font>
00282                 <font class="keywordflow">if</font>(x1-x0&gt;=<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>)
00283                         x0=0, x1= <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>;
00284                 <font class="keywordflow">else</font>
00285                 {
00286                         x0&amp;= <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1;
00287                         x1&amp;= <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1;
00288                         <font class="keywordflow">if</font>(x1&lt;=x0)
00289                                 x1+=<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>;
00290                 }
00291                 <font class="keywordflow">if</font>(y1-y0&gt;=<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>)
00292                         y0=0, y1= <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>;
00293                 <font class="keywordflow">else</font>
00294                 {
00295                         y0&amp;= <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1;
00296                         y1&amp;= <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1;
00297                         <font class="keywordflow">if</font>(y1&lt;=y0)
00298                                 y1+=<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>;
00299                 }
00300         }
00301 
00302         <font class="comment">// If not done, add the node to the selection.</font>
<a name="l00303"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#c2">00303</a>         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadGrid.html#c2">addToSelection</a>(CNode    *ptr)
00304         {
00305                 <font class="comment">// if not selected</font>
00306                 <font class="keywordflow">if</font>(!ptr-&gt;Selected)
00307                 {
00308                         <font class="comment">// remove from the unselected list.</font>
00309                         ptr-&gt;Prev-&gt;Next= ptr-&gt;Next;
00310                         <font class="keywordflow">if</font>(ptr-&gt;Next)
00311                                 ptr-&gt;Next-&gt;Prev= ptr-&gt;Prev;
00312 
00313                         <font class="comment">// Append to front of the _Selected list.</font>
00314                         <a class="code" href="classNL3D_1_1CQuadGrid.html#c0">linkToRoot</a>(_SelectedList, ptr);
00315 
00316                         <font class="comment">// mark it</font>
00317                         ptr-&gt;Selected= <font class="keyword">true</font>;
00318                 }
00319         }
00320 
00321         <font class="comment">// Try to add each node of the quad node list.</font>
<a name="l00322"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#c3">00322</a>         <font class="keywordtype">void</font>            <a class="code" href="classNL3D_1_1CQuadGrid.html#c3">addQuadNodeToSelection</a>(CQuadNode        &amp;quad)
00323         {
00324                 <font class="keyword">typename</font> <a class="code" href="classNLMISC_1_1CSTLBlockList.html">NLMISC::CSTLBlockList&lt;CNode*&gt;</a>::iterator        itNode;
00325                 <font class="keywordflow">for</font>(itNode= quad.Nodes.begin();itNode!=quad.Nodes.end();itNode++)
00326                 {
00327                         <a class="code" href="classNL3D_1_1CQuadGrid.html#c2">addToSelection</a>(*itNode);
00328                 }
00329         }
00330 
00331 
00332 <font class="keyword">public</font>:
00333         <font class="comment">// CLASS const_iterator.</font>
<a name="l00334"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html">00334</a>         <font class="keyword">class </font>const_iterator
00335         {
00336         <font class="keyword">public</font>:
<a name="l00337"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">00337</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a>()        {<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>=NULL;}
<a name="l00338"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a1">00338</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a>(CNode *p) : <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>(p) {}
<a name="l00339"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a2">00339</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadGrid_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_1CQuadGrid_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_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>) {}
00340 
<a name="l00341"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a3">00341</a>                 <font class="keyword">const</font> T&amp;        <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a3">operator*</a>()<font class="keyword"> const</font>
00342 <font class="keyword">                        </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>-&gt;Elt; }
00343                 <font class="comment">// Doesn't work...</font>
00344                 <font class="comment">/*const T*      operator-&gt;() const</font>
00345 <font class="comment">                        {return (&amp;**this); }*/</font>
<a name="l00346"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a4">00346</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a4">operator++</a>()
00347                         {<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>-&gt;Next); <font class="keywordflow">return</font> (*this); }
<a name="l00348"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a5">00348</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a> <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a4">operator++</a>(<font class="keywordtype">int</font>)
00349                         {<a class="code" href="classNL3D_1_1CQuadGrid_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="l00350"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a6">00350</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a6">operator--</a>()
00351                         {<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>-&gt;Prev); <font class="keywordflow">return</font> (*this); }
<a name="l00352"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a7">00352</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a> <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a6">operator--</a>(<font class="keywordtype">int</font>)
00353                         {<a class="code" href="classNL3D_1_1CQuadGrid_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="l00354"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a8">00354</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a8">operator==</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadGrid_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>
00355 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a> == x._Ptr); }
<a name="l00356"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a9">00356</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a9">operator!=</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadGrid_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>
00357 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (!(*<font class="keyword">this</font> == x)); }
00358         <font class="keyword">protected</font>:
<a name="l00359"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">00359</a>                 CNode   *<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>;
<a name="l00360"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#l0">00360</a>                 <font class="keyword">friend</font> <font class="keyword">class </font>CQuadGrid&lt;T&gt;;
<a name="l00361"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#l1">00361</a>                 <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#l1">CIterator</a>;
00362         };
00363 
00364         <font class="comment">// CLASS CIterator</font>
<a name="l00365"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html">00365</a>         <font class="keyword">class </font><a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a> : <font class="keyword">public</font> const_iterator
00366         {
00367         <font class="keyword">public</font>:
<a name="l00368"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a0">00368</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a0">CIterator</a>()                     {<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>=NULL;}
<a name="l00369"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a1">00369</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a0">CIterator</a>(CNode *p) : <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#a0">const_iterator</a>(p) {}
<a name="l00370"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a2">00370</a>                 T&amp;      <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a2">operator*</a>()<font class="keyword"> const</font>
00371 <font class="keyword">                        </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>-&gt;Elt; }
00372                 <font class="comment">// Doesn't work...</font>
00373                 <font class="comment">/*T*    operator-&gt;() const</font>
00374 <font class="comment">                        {return (&amp;**this); }*/</font>
<a name="l00375"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a3">00375</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a0">CIterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a3">operator++</a>()
00376                         {<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>-&gt;Next); <font class="keywordflow">return</font> (*this); }
<a name="l00377"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a4">00377</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a0">CIterator</a> <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a3">operator++</a>(<font class="keywordtype">int</font>)
00378                         {<a class="code" href="classNL3D_1_1CQuadGrid_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="l00379"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a5">00379</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a0">CIterator</a>&amp; <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a5">operator--</a>()
00380                         {<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a> = (CNode*)(<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a>-&gt;Prev); <font class="keywordflow">return</font> (*this); }
<a name="l00381"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a6">00381</a>                 <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a0">CIterator</a> <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a5">operator--</a>(<font class="keywordtype">int</font>)
00382                         {<a class="code" href="classNL3D_1_1CQuadGrid_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="l00383"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a7">00383</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a7">operator==</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadGrid_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>
00384 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CQuadGrid_1_1const__iterator.html#n0">_Ptr</a> == x._Ptr); }
<a name="l00385"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a8">00385</a>                 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#a8">operator!=</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CQuadGrid_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>
00386 <font class="keyword">                        </font>{<font class="keywordflow">return</font> (!(*<font class="keyword">this</font> == x)); }
00387         <font class="keyword">protected</font>:
<a name="l00388"></a><a class="code" href="classNL3D_1_1CQuadGrid_1_1CIterator.html#l0">00388</a>                 <font class="keyword">friend</font> <font class="keyword">class </font>CQuadGrid&lt;T&gt;;
00389         };
00390 
00391 
00392 };
00393 
00394 
00395 <font class="comment">// ***************************************************************************</font>
00396 <font class="comment">// ***************************************************************************</font>
00397 <font class="comment">// ***************************************************************************</font>
00398 <font class="comment">// ***************************************************************************</font>
00399 <font class="comment">// Template CQuadGrid implementation.</font>
00400 <font class="comment">// ***************************************************************************</font>
00401 <font class="comment">// ***************************************************************************</font>
00402 <font class="comment">// ***************************************************************************</font>
00403 <font class="comment">// ***************************************************************************</font>
00404 
00405 
00406 <font class="comment">// ***************************************************************************</font>
00407 <font class="comment">// Init.</font>
00408 <font class="comment">// ***************************************************************************</font>
00409 
00410 
00411 <font class="comment">// ***************************************************************************</font>
<a name="l00412"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#a0">00412</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       CQuadGrid&lt;T&gt;::CQuadGrid(uint memoryBlockSize) : 
00413         _NodeBlockMemory(memoryBlockSize), _NodeListBlockMemory(memoryBlockSize)
00414 {
00415         <a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>=4;
00416         <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>=1&lt;&lt;<a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>;
00417         <a class="code" href="classNL3D_1_1CQuadGrid.html#o3">_EltSize</a>=1;
00418         <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a>();
00419 }
00420 <font class="comment">// ***************************************************************************</font>
<a name="l00421"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#a1">00421</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       CQuadGrid&lt;T&gt;::~CQuadGrid()
00422 {
00423         <a class="code" href="classNL3D_1_1CQuadGrid.html#z742_0">clear</a>();
00424         <font class="comment">// must clear the array, before _NodeListBlockMemory.purge() is called.</font>
00425         <a class="code" href="classNL3D_1_1CQuadGrid.html#o0">_Grid</a>.clear();
00426 }
00427 <font class="comment">// ***************************************************************************</font>
<a name="l00428"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z741_0">00428</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadGrid&lt;T&gt;::changeBase(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a>&amp; base)
00429 {
00430         <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>= base;
00431 }
00432 <font class="comment">// ***************************************************************************</font>
<a name="l00433"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z741_1">00433</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadGrid&lt;T&gt;::create(uint size, <font class="keywordtype">float</font> eltSize)
00434 {
00435         <a class="code" href="classNL3D_1_1CQuadGrid.html#z742_0">clear</a>();
00436 
00437         <a class="code" href="debug_8h.html#a6">nlassert</a>(NLMISC::isPowerOf2(size));
00438         <a class="code" href="debug_8h.html#a6">nlassert</a>(size&lt;=32768);
00439         <a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>= <a class="code" href="namespaceNLMISC.html#a224">NLMISC::getPowerOf2</a>(size);
00440         <a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>=1&lt;&lt;<a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>;
00441         <a class="code" href="classNL3D_1_1CQuadGrid.html#o0">_Grid</a>.resize(<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>*<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>, CQuadNode(&amp;<a class="code" href="classNL3D_1_1CQuadGrid.html#o8">_NodeListBlockMemory</a>));
00442 
00443         <a class="code" href="debug_8h.html#a6">nlassert</a>(eltSize&gt;0);
00444         <a class="code" href="classNL3D_1_1CQuadGrid.html#o3">_EltSize</a>= eltSize;
00445 }
00446 
00447 
00448 <font class="comment">// ***************************************************************************</font>
00449 <font class="comment">// insert/erase.</font>
00450 <font class="comment">// ***************************************************************************</font>
00451 
00452 
00453 <font class="comment">// ***************************************************************************</font>
<a name="l00454"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z742_0">00454</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>            CQuadGrid&lt;T&gt;::clear()
00455 {
00456         <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>       it;
00457         <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_1">selectAll</a>();
00458         <font class="keywordflow">while</font>( (it=<a class="code" href="classNL3D_1_1CQuadGrid.html#z743_3">begin</a>())!=<a class="code" href="classNL3D_1_1CQuadGrid.html#z743_4">end</a>())
00459         {
00460                 <a class="code" href="classNL3D_1_1CQuadGrid.html#z742_1">erase</a>(it);
00461         }
00462 
00463         <font class="comment">// Clear the 2 selection...</font>
00464         <a class="code" href="classNL3D_1_1CQuadGrid.html#o5">_SelectedList</a>.<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>= NULL;
00465         <a class="code" href="classNL3D_1_1CQuadGrid.html#o6">_UnSelectedList</a>.<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>= NULL;
00466 }
00467 <font class="comment">// ***************************************************************************</font>
00468 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">typename</font> CQuadGrid&lt;T&gt;::CIterator        CQuadGrid&lt;T&gt;::erase(<font class="keyword">typename</font> CQuadGrid&lt;T&gt;::CIterator it)
00469 {
00470         sint    <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
00471         CNode   *ptr= it._Ptr;
00472 
00473         <font class="keywordflow">if</font>(!ptr)
00474                 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_4">end</a>();
00475 
00476         <font class="comment">// First erase all references to it.</font>
00477         <font class="comment">//==================================</font>
00478         <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= ptr-&gt;y0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;ptr-&gt;y1;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
00479         {
00480                 sint    xe,ye;
00481                 ye= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &amp;(<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1);
00482                 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= ptr-&gt;x0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;ptr-&gt;x1;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
00483                 {
00484                         xe= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> &amp;(<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1);
00485                         CQuadNode       &amp;quad= <a class="code" href="classNL3D_1_1CQuadGrid.html#o0">_Grid</a>[(ye&lt;&lt;<a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>)+xe];
00486                         <font class="keyword">typename</font> <a class="code" href="classNLMISC_1_1CSTLBlockList.html">NLMISC::CSTLBlockList&lt;CNode*&gt;</a>::iterator        itNode;
00487                         <font class="keywordflow">for</font>(itNode= quad.Nodes.begin();itNode!=quad.Nodes.end();itNode++)
00488                         {
00489                                 <font class="keywordflow">if</font>((*itNode)==ptr)
00490                                 {
00491                                         quad.Nodes.erase(itNode);
00492                                         <font class="keywordflow">break</font>;
00493                                 }
00494                         }
00495                 }
00496         }
00497 
00498         <font class="comment">// Then delete it..., and update selection linked list.</font>
00499         <font class="comment">//=====================================================</font>
00500         <font class="comment">// remove it from _SelectedList or _UnSelectedList</font>
00501         CBaseNode       *next= NULL;
00502         next= ptr-&gt;Next;
00503         <font class="keywordflow">if</font>(next)
00504                 next-&gt;Prev=ptr-&gt;Prev;
00505         ptr-&gt;Prev-&gt;Next= next;
00506         <font class="comment">// if not selected, then must return NULL</font>
00507         <font class="keywordflow">if</font>(!ptr-&gt;Selected)
00508                 next= NULL;
00509         <font class="comment">// delete the object.</font>
00510         <a class="code" href="classNL3D_1_1CQuadGrid.html#o7">_NodeBlockMemory</a>.<a class="code" href="classNLMISC_1_1CBlockMemory.html#a4">free</a>(ptr);
00511 
00512 
00513         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>((CNode*)next);
00514 }
00515 <font class="comment">// ***************************************************************************</font>
<a name="l00516"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z742_2">00516</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">typename</font> CQuadGrid&lt;T&gt;::CIterator        CQuadGrid&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)
00517 {
00518         CVector         bmin,bmax;
00519         bmin= <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>*bboxmin;
00520         bmax= <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>*bboxmax;
00521 
00522         <font class="comment">// init the object.</font>
00523         CNode   *ptr= <a class="code" href="classNL3D_1_1CQuadGrid.html#o7">_NodeBlockMemory</a>.<a class="code" href="classNLMISC_1_1CBlockMemory.html#a3">allocate</a>();
00524         ptr-&gt;Elt= val;
00525         <font class="comment">// Link to _Unselected list.</font>
00526         <a class="code" href="classNL3D_1_1CQuadGrid.html#c0">linkToRoot</a>(<a class="code" href="classNL3D_1_1CQuadGrid.html#o6">_UnSelectedList</a>, ptr);
00527         <font class="comment">// mark as not selected.</font>
00528         ptr-&gt;Selected= <font class="keyword">false</font>;
00529 
00530 
00531         <font class="comment">// Find which quad include the object.</font>
00532         <font class="comment">//===================================</font>
00533         sint    x0,y0;
00534         sint    x1,y1;
00535         <a class="code" href="classNL3D_1_1CQuadGrid.html#c1">selectQuads</a>(bmin, bmax, x0,x1, y0,y1);
00536 
00537         ptr-&gt;x0= x0;
00538         ptr-&gt;x1= x1;
00539         ptr-&gt;y0= y0;
00540         ptr-&gt;y1= y1;
00541 
00542         <font class="comment">// Then for all of them, insert the node in their list.</font>
00543         <font class="comment">//=====================================================</font>
00544         sint    <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
00545         <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= ptr-&gt;y0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;ptr-&gt;y1;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
00546         {
00547                 sint    xe,ye;
00548                 ye= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &amp;(<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1);
00549                 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= ptr-&gt;x0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;ptr-&gt;x1;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
00550                 {
00551                         xe= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> &amp;(<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1);
00552                         CQuadNode       &amp;quad= <a class="code" href="classNL3D_1_1CQuadGrid.html#o0">_Grid</a>[(ye&lt;&lt;<a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>)+xe];
00553                         quad.Nodes.push_back(ptr);
00554                 }
00555         }
00556 
00557         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>(ptr);
00558 }
00559 
00560 
00561 <font class="comment">// ***************************************************************************</font>
00562 <font class="comment">// selection.</font>
00563 <font class="comment">// ***************************************************************************</font>
00564 
00565 
00566 <font class="comment">// ***************************************************************************</font>
<a name="l00567"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z743_0">00567</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>                    CQuadGrid&lt;T&gt;::clearSelection()
00568 {
00569         CBaseNode       *ptr= <a class="code" href="classNL3D_1_1CQuadGrid.html#o5">_SelectedList</a>.<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>;
00570         <font class="keywordflow">while</font>(ptr)
00571         {
00572                 <font class="comment">// next selected.</font>
00573                 CBaseNode       *nextSelected= ptr-&gt;Next;
00574 
00575                 <font class="comment">// Link to _Unselected list.</font>
00576                 <a class="code" href="classNL3D_1_1CQuadGrid.html#c0">linkToRoot</a>(<a class="code" href="classNL3D_1_1CQuadGrid.html#o6">_UnSelectedList</a>, ptr);
00577 
00578                 <font class="comment">// mark as not selected.</font>
00579                 ptr-&gt;Selected= <font class="keyword">false</font>;
00580 
00581                 <font class="comment">// next.</font>
00582                 ptr= nextSelected;
00583         }
00584 
00585         <font class="comment">// the selected list is now empty.</font>
00586         <a class="code" href="classNL3D_1_1CQuadGrid.html#o5">_SelectedList</a>.<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>= NULL;
00587 }
00588 <font class="comment">// ***************************************************************************</font>
<a name="l00589"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z743_1">00589</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>                    CQuadGrid&lt;T&gt;::selectAll()
00590 {
00591         <font class="comment">// This is the opposite of clearSelection(). get all that are in _UnSelectedList,</font>
00592         <font class="comment">// and put them in _SelectedList</font>
00593         CBaseNode       *ptr= <a class="code" href="classNL3D_1_1CQuadGrid.html#o6">_UnSelectedList</a>.<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>;
00594         <font class="keywordflow">while</font>(ptr)
00595         {
00596                 <font class="comment">// next selected.</font>
00597                 CBaseNode       *nextUnSelected= ptr-&gt;Next;
00598 
00599                 <font class="comment">// Link to _Selected list.</font>
00600                 <a class="code" href="classNL3D_1_1CQuadGrid.html#c0">linkToRoot</a>(<a class="code" href="classNL3D_1_1CQuadGrid.html#o5">_SelectedList</a>, ptr);
00601 
00602                 <font class="comment">// mark as selected.</font>
00603                 ptr-&gt;Selected= <font class="keyword">true</font>;
00604 
00605                 <font class="comment">// next.</font>
00606                 ptr= nextUnSelected;
00607         }
00608 
00609         <font class="comment">// the Unselected list is now empty.</font>
00610         <a class="code" href="classNL3D_1_1CQuadGrid.html#o6">_UnSelectedList</a>.<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>= NULL;
00611 }
00612 <font class="comment">// ***************************************************************************</font>
<a name="l00613"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z743_2">00613</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keywordtype">void</font>                    CQuadGrid&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)
00614 {
00615         CVector         bmin,bmax;
00616         bmin= <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>*bboxmin;
00617         bmax= <a class="code" href="classNL3D_1_1CQuadGrid.html#o4">_ChangeBasis</a>*bboxmax;
00618 
00619         <a class="code" href="classNL3D_1_1CQuadGrid.html#z743_0">clearSelection</a>();
00620 
00621         <font class="comment">// What are the quads to access?</font>
00622         sint    x0,y0;
00623         sint    x1,y1;
00624         <a class="code" href="classNL3D_1_1CQuadGrid.html#c1">selectQuads</a>(bmin, bmax, x0,x1, y0,y1);
00625 
00626         sint    <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
00627         <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= y0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;y1;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
00628         {
00629                 sint    xe,ye;
00630                 ye= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &amp;(<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1);
00631                 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= x0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;x1;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
00632                 {
00633                         xe= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> &amp;(<a class="code" href="classNL3D_1_1CQuadGrid.html#o1">_Size</a>-1);
00634                         CQuadNode       &amp;quad= <a class="code" href="classNL3D_1_1CQuadGrid.html#o0">_Grid</a>[(ye&lt;&lt;<a class="code" href="classNL3D_1_1CQuadGrid.html#o2">_SizePower</a>)+xe];
00635                         <a class="code" href="classNL3D_1_1CQuadGrid.html#c3">addQuadNodeToSelection</a>(quad);
00636                 }
00637         }
00638 
00639 }
00640 <font class="comment">// ***************************************************************************</font>
<a name="l00641"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z743_3">00641</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">typename</font> CQuadGrid&lt;T&gt;::CIterator                CQuadGrid&lt;T&gt;::begin()
00642 {
00643         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>((CNode*)(<a class="code" href="classNL3D_1_1CQuadGrid.html#o5">_SelectedList</a>.<a class="code" href="classNL3D_1_1CQuadGrid_1_1CBaseNode.html#m1">Next</a>));
00644 }
00645 <font class="comment">// ***************************************************************************</font>
<a name="l00646"></a><a class="code" href="classNL3D_1_1CQuadGrid.html#z743_4">00646</a> <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">typename</font> CQuadGrid&lt;T&gt;::CIterator                CQuadGrid&lt;T&gt;::end()
00647 {
00648         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CQuadGrid.html#l0">CIterator</a>(NULL);
00649 }
00650 
00651 
00652 } <font class="comment">// NL3D</font>
00653 
00654 
00655 <font class="preprocessor">#endif // NL_QUAD_GRID_H</font>
00656 <font class="preprocessor"></font>
00657 <font class="comment">/* End of quad_grid.h */</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=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>