aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/build__indoor_8cpp-source.html
blob: fab34f41be7031adb76bda36f695e1ab09cf98f9 (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
<!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>build_indoor.cpp</h1><a href="build__indoor_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include &lt;map&gt;</font>
00027 <font class="preprocessor">#include &lt;vector&gt;</font>
00028 
00029 <font class="preprocessor">#include "<a class="code" href="stdpacs_8h.html">stdpacs.h</a>"</font>
00030 
00031 <font class="preprocessor">#include "<a class="code" href="collision__mesh__build_8h.html">pacs/collision_mesh_build.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="local__retriever_8h.html">pacs/local_retriever.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="exterior__mesh_8h.html">pacs/exterior_mesh.h</a>"</font>
00034 
00035 <font class="preprocessor">#include "<a class="code" href="build__indoor_8h.html">build_indoor.h</a>"</font>
00036 
00037 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00038 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00039 
00040 <font class="keyword">namespace </font>NLPACS
00041 {
00042 
<a name="l00049"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html">00049</a> <font class="keyword">class </font>CInteriorSurface
00050 {
00051 <font class="keyword">public</font>:
<a name="l00053"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html#m0">00053</a>         CCollisionMeshBuild                             *<a class="code" href="classNLPACS_1_1CInteriorSurface.html#m0">CollisionMeshBuild</a>;
00054 
<a name="l00056"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html#m1">00056</a>         std::vector&lt;uint32&gt;                             <a class="code" href="classNLPACS_1_1CInteriorSurface.html#m1">Faces</a>;
00057 
<a name="l00059"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html#m2">00059</a>         sint32                                                  <a class="code" href="classNLPACS_1_1CInteriorSurface.html#m2">Id</a>;
00060 
<a name="l00062"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html#m3">00062</a>         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>                                 <a class="code" href="classNLPACS_1_1CInteriorSurface.html#m3">Center</a>;
00063 
<a name="l00065"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html#m4">00065</a>         sint32                                                  <a class="code" href="classNLPACS_1_1CInteriorSurface.html#m4">Material</a>;
00066 
00067 <font class="keyword">public</font>:
<a name="l00068"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html#a0">00068</a>         CCollisionFace                                  &amp;<a class="code" href="classNLPACS_1_1CInteriorSurface.html#a0">getFace</a>(uint face) { <font class="keywordflow">return</font> <a class="code" href="classNLPACS_1_1CInteriorSurface.html#m0">CollisionMeshBuild</a>-&gt;Faces[<a class="code" href="classNLPACS_1_1CInteriorSurface.html#m1">Faces</a>[face]]; }
<a name="l00069"></a><a class="code" href="classNLPACS_1_1CInteriorSurface.html#a1">00069</a>         CCollisionFace                                  &amp;<a class="code" href="classNLPACS_1_1CInteriorSurface.html#a1">getNeighbor</a>(uint face, uint edge)
00070         {
00071                 <font class="keywordflow">return</font> <a class="code" href="classNLPACS_1_1CInteriorSurface.html#m0">CollisionMeshBuild</a>-&gt;Faces[<a class="code" href="classNLPACS_1_1CInteriorSurface.html#a0">getFace</a>(face).Edge[edge]];
00072         }
00073 };
00074 
00075 
<a name="l00082"></a><a class="code" href="classNLPACS_1_1CInteriorBorder.html">00082</a> <font class="keyword">class</font> CInteriorBorder
00083 {
00084 <font class="keyword">public</font>:
<a name="l00086"></a><a class="code" href="classNLPACS_1_1CInteriorBorder.html#m0">00086</a>         std::vector&lt;NLMISC::CVector&gt;    Vertices;
00087 
<a name="l00089"></a><a class="code" href="classNLPACS_1_1CInteriorBorder.html#m2">00089</a>         sint32                                                  Left, Right;
00090 
00091 <font class="keyword">public</font>:
00092 };
00093 
00094 
00095 <font class="comment">// how to build interior snapping data</font>
00096 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a15">buildSnapping</a>(CCollisionMeshBuild &amp;cmb, CLocalRetriever &amp;lr);
00097 
00098 
00099 <font class="comment">// how to build surfaces</font>
00100 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a16">buildSurfaces</a>(CCollisionMeshBuild &amp;cmb, CLocalRetriever &amp;lr);
00101 
00102 
00103 
00104 <font class="comment">//</font>
00105 <font class="comment">// functions to build interior surfaces and borders from mesh</font>
00106 <font class="comment">//</font>
00107 
00108 <font class="comment">// how to generate connex surfaces</font>
00109 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a17">floodFillSurfaces</a>(CCollisionMeshBuild &amp;cmb, vector&lt;CInteriorSurface&gt; &amp;surfaces)
00110 {
00111         sint32  currentId = 0;
00112 
00113         uint    i;
00114 
00115         <font class="keywordflow">for</font> (i=0; i&lt;cmb.Faces.size(); ++i)
00116                 cmb.Faces[i].InternalSurface = -1;
00117 
00118         <font class="keywordflow">for</font> (i=0; i&lt;cmb.Faces.size(); ++i)
00119         {
00120                 CCollisionFace  &amp;face = cmb.Faces[i];
00121                 <font class="keywordflow">if</font> (face.Surface == CCollisionFace::ExteriorSurface || face.InternalSurface != -1)
00122                         <font class="keywordflow">continue</font>;
00123 
00124                 vector&lt;uint&gt;    stack;
00125                 stack.push_back(i);
00126                 face.InternalSurface = currentId;
00127 
00128                 surfaces.resize(surfaces.size()+1);
00129                 surfaces.back().Id = currentId;
00130                 surfaces.back().CollisionMeshBuild = &amp;cmb;
00131                 surfaces.back().Material = face.Material;
00132 
00133                 <font class="keywordflow">while</font> (!stack.empty())
00134                 {
00135                         uint    pop = stack.back();
00136                         stack.pop_back();
00137 
00138                         surfaces.back().Faces.push_back(pop);
00139                         CCollisionFace  &amp;popFace = cmb.Faces[pop];
00140 
00141                         uint    edge, neighb;
00142                         <font class="keywordflow">for</font> (edge=0; edge&lt;3; ++edge)
00143                         {
00144                                 <font class="keywordflow">if</font> ((neighb = popFace.Edge[edge]) != -1 &amp;&amp; 
00145                                         cmb.Faces[neighb].InternalSurface == -1 &amp;&amp;
00146                                         cmb.Faces[neighb].Surface == popFace.Surface)
00147                                 {
00148                                         cmb.Faces[neighb].InternalSurface = currentId;
00149                                         stack.push_back(neighb);
00150                                 }
00151                         }
00152                 }
00153 
00154                 ++currentId;
00155         }
00156 }
00157 
00158 
00159 <font class="comment">// reset the edge flags of the whole collision mesh build</font>
00160 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a18">resetEdgeFlags</a>(CCollisionMeshBuild &amp;cmb)
00161 {
00162         uint    face, edge;
00163 
00164         <font class="keywordflow">for</font> (face=0; face&lt;cmb.Faces.size(); ++face)
00165                 <font class="keywordflow">for</font> (edge=0; edge&lt;3; ++edge)
00166                         cmb.Faces[face].EdgeFlags[edge] = <font class="keyword">false</font>;
00167 }
00168 
00169 
00170 
00171 <font class="comment">// how to generate the borders of a given surface</font>
00172 
00173 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a19">followBorder</a>(CInteriorSurface &amp;surface, uint first, uint edge, uint sens, vector&lt;CVector&gt; &amp;vstore, <font class="keywordtype">bool</font> &amp;loop)
00174 {
00175         CCollisionFace  *current = &amp;surface.getFace(first);
00176         CCollisionFace  *next = (current-&gt;Edge[edge] == -1) ? NULL : &amp;surface.CollisionMeshBuild-&gt;Faces[current-&gt;Edge[edge]];
00177         current-&gt;EdgeFlags[edge] = <font class="keyword">true</font>;
00178         sint32                  currentFace = surface.Faces[first];
00179 
00180         <font class="keyword">const</font> sint32    currentSurfId = current-&gt;InternalSurface;
00181         <font class="keyword">const</font> sint32    oppositeSurfId = (next != NULL) ? next-&gt;InternalSurface : (current-&gt;Visibility[edge] ? -1 : -2);
00182         sint                    oedge;
00183 
00184         sint                    pivot = (edge+sens)%3;
00185         sint                    nextEdge = edge;
00186 
00187         <font class="keywordtype">bool</font>                    allowThis = <font class="keyword">true</font>;
00188 
00189         <font class="comment">// adds the pivot to the border and its normal</font>
00190         vstore.push_back(surface.CollisionMeshBuild-&gt;Vertices[current-&gt;V[pivot]]);
00191 
00192         <font class="keywordflow">while</font> (true)
00193         {
00194                 loop = <font class="keyword">false</font>;
00195                 <font class="comment">// -1 means no neighbor at all, -2 means a neighbor that is not available yet</font>
00196                 sint32  thisOpposite = (next != NULL) ? next-&gt;InternalSurface : (current-&gt;Visibility[nextEdge] ? -1 : -2);
00197                 <font class="keywordflow">if</font> (thisOpposite != currentSurfId &amp;&amp; thisOpposite != oppositeSurfId ||
00198                         (loop = (current-&gt;EdgeFlags[nextEdge] &amp;&amp; !allowThis)))
00199                 {
00200                         <font class="comment">// if reaches the end of the border, then quits.</font>
00201                         <font class="keywordflow">break</font>;
00202                 }
00203                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (thisOpposite == oppositeSurfId)
00204                 {
00205                         <font class="comment">// if the next edge belongs to the border, then go on the same element</font>
00206                         current-&gt;EdgeFlags[nextEdge] = <font class="keyword">true</font>;
00207                         <font class="keywordflow">if</font> (oppositeSurfId &gt;= 0)
00208                         {
00209                                 <font class="keywordflow">for</font> (oedge=0; oedge&lt;3 &amp;&amp; next-&gt;Edge[oedge]!=currentFace; ++oedge)
00210                                         ;
00211                                 <a class="code" href="debug_8h.html#a6">nlassert</a>(oedge != 3);
00212                                 <a class="code" href="debug_8h.html#a6">nlassert</a>(allowThis || !next-&gt;EdgeFlags[oedge]);
00213                                 next-&gt;EdgeFlags[oedge] = <font class="keyword">true</font>;
00214                         }
00215                         pivot = (pivot+sens)%3;
00216                         nextEdge = (nextEdge+sens)%3;
00217                         next = (current-&gt;Edge[nextEdge] == -1) ? NULL : &amp;surface.CollisionMeshBuild-&gt;Faces[current-&gt;Edge[nextEdge]];
00218                         vstore.push_back(surface.CollisionMeshBuild-&gt;Vertices[current-&gt;V[pivot]]);
00219                 }
00220                 <font class="keywordflow">else</font> 
00221                 {
00222                         <font class="comment">// if the next element is inside the surface, then go to the next element</font>
00223                         <a class="code" href="debug_8h.html#a6">nlassert</a>(next-&gt;InternalSurface == currentSurfId);
00224 
00225                         <font class="keywordflow">for</font> (oedge=0; oedge&lt;3 &amp;&amp; next-&gt;Edge[oedge]!=currentFace; ++oedge)
00226                                 ;
00227                         <a class="code" href="debug_8h.html#a6">nlassert</a>(oedge != 3);
00228                         currentFace = current-&gt;Edge[nextEdge];
00229                         current = next;
00230                         pivot = (oedge+3-sens)%3;
00231                         nextEdge = (oedge+sens)%3;
00232                         next = (current-&gt;Edge[nextEdge] == -1) ? NULL : &amp;surface.CollisionMeshBuild-&gt;Faces[current-&gt;Edge[nextEdge]];
00233                 }
00234 
00235                 allowThis = <font class="keyword">false</font>;
00236         }
00237 }
00238 
00239 
00240 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a20">computeSurfaceBorders</a>(CInteriorSurface &amp;surface, vector&lt;CInteriorBorder&gt; &amp;borders)
00241 {
00242         uint    face, edge;
00243 
00244         <font class="keywordflow">for</font> (face=0; face&lt;surface.Faces.size(); ++face)
00245         {
00246                 <font class="comment">// for each element,</font>
00247                 <font class="comment">// scan for a edge that points to a different surface</font>
00248                 CCollisionFace  &amp;cf = surface.getFace(face);
00249 
00250                 <font class="keywordflow">for</font> (edge=0; edge&lt;3; ++edge)
00251                 {
00252                         <font class="keywordflow">if</font> ((cf.Edge[edge] == -1 || surface.getNeighbor(face, edge).InternalSurface != surface.Id) &amp;&amp;
00253                                 !cf.EdgeFlags[edge])
00254                         {
00255                                 borders.resize(borders.size()+1);
00256                                 CInteriorBorder &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a> = borders.back();
00257 
00258                                 <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>.Left = cf.InternalSurface;
00259 
00260                                 <font class="keywordflow">if</font> (cf.Edge[edge] == -1)
00261                                 {
00262                                         <font class="comment">// link on a neighbor retriever or not at all</font>
00263                                         <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>.Right = cf.Visibility[edge] ? -1 : -2;
00264                                 }
00265                                 <font class="keywordflow">else</font>
00266                                 {
00267                                         <font class="comment">// link on the neighbor surface</font>
00268                                         <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>.Right = surface.CollisionMeshBuild-&gt;Faces[cf.Edge[edge]].InternalSurface;
00269                                 }
00270 
00271                                 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"generate border %d (%d-%d)"</font>, borders.size()-1, <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>.Left, <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>.Right);
00272 
00273                                 <font class="keywordtype">bool</font>                            loop;
00274                                 vector&lt;CVector&gt;         bwdVerts;
00275                                 vector&lt;CVector&gt;         &amp;fwdVerts = <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>.Vertices;
00276 
00277                                 <a class="code" href="namespaceNLPACS.html#a19">followBorder</a>(surface, face, edge, 2, bwdVerts, loop);
00278 
00279                                 sint    i;
00280 
00281                                 fwdVerts.reserve(bwdVerts.size());
00282                                 fwdVerts.clear();
00283 
00284                                 <font class="keywordflow">for</font> (i=(sint)(bwdVerts.size()-1); i&gt;=0; --i)
00285                                 {
00286                                         fwdVerts.push_back(bwdVerts[i]);
00287                                 }
00288 
00289                                 <font class="keywordflow">if</font> (loop)
00290                                 {
00291                                         fwdVerts.push_back(fwdVerts.front());
00292                                 }
00293                                 <font class="keywordflow">else</font>
00294                                 {
00295                                         fwdVerts.resize(fwdVerts.size()-2);
00296                                         <a class="code" href="namespaceNLPACS.html#a19">followBorder</a>(surface, face, edge, 1, fwdVerts, loop);
00297                                 }
00298                         }
00299                 }
00300         }
00301 }
00302 
00303 
00304 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a21">computeSurfaceCenter</a>(CInteriorSurface &amp;surface)
00305 {
00306         CCollisionMeshBuild     &amp;cmb = *(surface.CollisionMeshBuild);
00307 
00308         CVector         center = CVector::Null;
00309         <font class="keywordtype">float</font>           totalWeight = 0.0f;
00310 
00311         uint    i, j;
00312 
00313         <font class="keywordflow">for</font> (i=0; i&lt;surface.Faces.size(); ++i)
00314         {
00315                 CCollisionFace  &amp;face = surface.getFace(i);
00316                 CVector                 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[3];
00317                 
00318                 <font class="keywordflow">for</font> (j=0; j&lt;3; ++j)
00319                         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[j] = cmb.Vertices[face.V[j]];
00320 
00321                 <font class="keywordtype">float</font>   weight = ((<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2]-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0])^(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1]-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0])).norm();
00322 
00323                 center += (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0]+<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1]+<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2])*(weight/3.0f);
00324                 totalWeight += weight;
00325         }
00326 
00327         surface.Center = center/totalWeight;
00328 }
00329 
00330 
00331 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a22">computeSurfaceQuadTree</a>(CInteriorSurface &amp;surface, CSurfaceQuadTree &amp;quad)
00332 {
00333         uint    i, j;
00334 
00335         CAABBox box;
00336         <font class="keywordtype">bool</font>    first = <font class="keyword">true</font>;
00337         <font class="keywordflow">for</font> (i=0; i&lt;surface.Faces.size(); ++i)
00338         {
00339                 <font class="keywordflow">for</font> (j=0; j&lt;3; ++j)
00340                 {
00341                         <font class="keyword">const</font> CVector   &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = surface.CollisionMeshBuild-&gt;Vertices[surface.CollisionMeshBuild-&gt;Faces[surface.Faces[i]].V[j]];
00342                         <font class="keywordflow">if</font> (first)
00343                                 box.setCenter(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>), first=<font class="keyword">false</font>;
00344                         <font class="keywordflow">else</font>
00345                                 box.extend(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00346                 }
00347         }
00348 
00349         quad.clear();
00350         quad.init(4.0f, 6, box.getCenter(), std::max(box.getHalfSize().x, box.getHalfSize().y));
00351 
00352         <font class="keywordflow">for</font> (i=0; i&lt;surface.Faces.size(); ++i)
00353         {
00354                 <font class="keywordflow">for</font> (j=0; j&lt;3; ++j)
00355                 {
00356                         <font class="keyword">const</font> CVector   &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = surface.CollisionMeshBuild-&gt;Vertices[surface.CollisionMeshBuild-&gt;Faces[surface.Faces[i]].V[j]];
00357                         quad.addVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00358                 }
00359         }
00360 
00361         quad.compile();
00362 }
00363 
00364 
00365 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a16">buildSurfaces</a>(CCollisionMeshBuild &amp;cmb, CLocalRetriever &amp;lr)
00366 {
00367         vector&lt;CInteriorSurface&gt;        surfaces;
00368         vector&lt;CInteriorBorder&gt;         borders;
00369 
00370         <a class="code" href="namespaceNLPACS.html#a17">floodFillSurfaces</a>(cmb, surfaces);
00371 
00372         <a class="code" href="namespaceNLPACS.html#a18">resetEdgeFlags</a>(cmb);
00373 
00374         uint    surf, bord;
00375 
00377         <font class="keywordflow">for</font> (surf=0; surf&lt;surfaces.size(); ++surf)
00378         {
00379                 CSurfaceQuadTree        quad;
00380                 <a class="code" href="namespaceNLPACS.html#a20">computeSurfaceBorders</a>(surfaces[surf], borders);
00381                 <a class="code" href="namespaceNLPACS.html#a21">computeSurfaceCenter</a>(surfaces[surf]);
00382                 <a class="code" href="namespaceNLPACS.html#a22">computeSurfaceQuadTree</a>(surfaces[surf], quad);
00383                 lr.addSurface(0, 0, (uint8)surfaces[surf].<a class="code" href="classNLPACS_1_1CInteriorSurface.html#m4">Material</a>, 0, 0, <font class="keyword">false</font>, 0.0f, surfaces[surf].Center, quad);
00384         }
00385 
00386         sint    numBorderChains = 0;
00387 
00388         <font class="keywordflow">for</font> (bord=0; bord&lt;borders.size(); ++bord)
00389         {
00390                 sint32  left = borders[bord].Left;
00391                 sint32  right = (borders[bord].Right == -2) ? CChain::convertBorderChainId(numBorderChains++) : borders[bord].Right;
00392 
00393                 <font class="keywordflow">if</font> (left&lt;0 || left&gt;=(sint)surfaces.size() ||
00394                         right&gt;(sint)surfaces.size())
00395                         <a class="code" href="debug_8h.html#a12">nlstop</a>;
00396 
00397                 lr.addChain(borders[bord].Vertices, left, right);
00398         }
00399 }
00400 
00401 
00402 <font class="comment">//</font>
00403 
00404 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a15">buildSnapping</a>(CCollisionMeshBuild &amp;cmb, CLocalRetriever &amp;lr)
00405 {
00406         <font class="comment">// copy the vertices</font>
00407         lr.getInteriorVertices() = cmb.Vertices;
00408 
00409         <font class="comment">// create the faces</font>
00410         uint    i;
00411         vector&lt;CLocalRetriever::CInteriorFace&gt;  &amp;faces = lr.getInteriorFaces();
00412         <font class="keywordflow">for</font> (i=0; i&lt;cmb.Faces.size(); ++i)
00413         {
00414                 faces.push_back(CLocalRetriever::CInteriorFace());
00415                 faces.back().Verts[0] = cmb.Faces[i].V[0];
00416                 faces.back().Verts[1] = cmb.Faces[i].V[1];
00417                 faces.back().Verts[2] = cmb.Faces[i].V[2];
00418                 faces.back().Surface = cmb.Faces[i].InternalSurface;
00419         }
00420 
00421         <font class="comment">// create the face grid</font>
00422         lr.initFaceGrid();
00423 }
00424 
00425 
00426 <font class="comment">//</font>
00427 <font class="comment">// functions to build local retrievers</font>
00428 <font class="comment">//</font>
00429 
00430 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a23">buildExteriorMesh</a>(CCollisionMeshBuild &amp;cmb, CExteriorMesh &amp;em)
00431 {
00432         <font class="comment">// find the first non interior face</font>
00433         uint    i, edge;
00434         <font class="keywordtype">bool</font>    found = <font class="keyword">false</font>;
00435         <font class="keywordflow">for</font> (i=0; i&lt;cmb.Faces.size() &amp;&amp; !found; ++i)
00436         {
00437                 <font class="keywordflow">if</font> (cmb.Faces[i].Surface != CCollisionFace::ExteriorSurface)
00438                         <font class="keywordflow">continue</font>;
00439 
00440                 <font class="keywordflow">for</font> (edge=0; edge&lt;3 &amp;&amp; !found; ++edge)
00441                         <font class="keywordflow">if</font> (cmb.Faces[i].Edge[edge] == -1)
00442                         {
00443                                 found = <font class="keyword">true</font>;
00444                                 <font class="keywordflow">break</font>;
00445                         }
00446 
00447                 <font class="keywordflow">if</font> (found)
00448                         <font class="keywordflow">break</font>;
00449         }
00450 
00451         <font class="comment">//</font>
00452         <font class="keywordflow">if</font> (!found)
00453                 <font class="keywordflow">return</font>;
00454 
00455         sint32                          current = i;
00456         sint32                          next = cmb.Faces[current].Edge[edge];
00457         <font class="keywordflow">for</font> (i=0; i&lt;cmb.Faces.size(); ++i)
00458         {
00459                 cmb.Faces[i].EdgeFlags[0] = <font class="keyword">false</font>;
00460                 cmb.Faces[i].EdgeFlags[1] = <font class="keyword">false</font>;
00461                 cmb.Faces[i].EdgeFlags[2] = <font class="keyword">false</font>;
00462         }
00463         
00464         sint                    oedge;
00465         sint                    pivot = (edge+1)%3;
00466         sint                    nextEdge = edge;
00467 
00468         <font class="keywordtype">bool</font>                    allowThis = <font class="keyword">true</font>;
00469 
00470         vector&lt;CExteriorMesh::CEdge&gt;    edges;
00471         uint                                                    numLink = 0;
00472 
00473         <font class="keywordflow">while</font> (true)
00474         {
00475                 <font class="keywordflow">if</font> (cmb.Faces[current].EdgeFlags[nextEdge])
00476                 {
00477                         <font class="comment">// if reaches the end of the border, then quits.</font>
00478                         <font class="keywordflow">break</font>;
00479                 }
00480                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (next == -1)
00481                 {
00482                         <font class="comment">// if the next edge belongs to the border, then go on the same element</font>
00483                         cmb.Faces[current].EdgeFlags[nextEdge] = <font class="keyword">true</font>;
00485                         sint    link = (cmb.Faces[current].Visibility[nextEdge]) ? -1 : (numLink++);
00486                         edges.push_back(CExteriorMesh::CEdge(cmb.Vertices[cmb.Faces[current].V[pivot]], link));
00487                         <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"border: vertex=%d (%.2f,%.2f,%.2f) link=%d"</font>, cmb.Faces[current].V[pivot], cmb.Vertices[cmb.Faces[current].V[pivot]].x, cmb.Vertices[cmb.Faces[current].V[pivot]].y, cmb.Vertices[cmb.Faces[current].V[pivot]].z, link);
00488                         pivot = (pivot+1)%3;
00489                         nextEdge = (nextEdge+1)%3;
00490                         next = cmb.Faces[current].Edge[nextEdge];
00491                 }
00492                 <font class="keywordflow">else</font>
00493                 {
00494                         <font class="comment">// if the next element is inside the surface, then go to the next element</font>
00495                         <font class="keywordflow">for</font> (oedge=0; oedge&lt;3 &amp;&amp; cmb.Faces[next].Edge[oedge]!=current; ++oedge)
00496                                 ;
00497                         <a class="code" href="debug_8h.html#a6">nlassert</a>(oedge != 3);
00498                         current = next;
00499                         pivot = (oedge+2)%3;
00500                         nextEdge = (oedge+1)%3;
00501                         next = cmb.Faces[current].Edge[nextEdge];
00502                 }
00503         }
00504 
00505         edges.push_back(edges.front());
00506         edges.back().Link = -1;
00507 
00508         em.setEdges(edges);
00509 }
00510 
00511 
00512 <font class="comment">//</font>
00513 <font class="keywordtype">void</font>    <a class="code" href="namespaceNLPACS.html#a24">linkExteriorToInterior</a>(CLocalRetriever &amp;lr)
00514 {
00515         CExteriorMesh                                   em = lr.getExteriorMesh();
00516         vector&lt;CExteriorMesh::CEdge&gt;    edges = em.getEdges();
00517         vector&lt;CExteriorMesh::CLink&gt;    links;
00518         <font class="keyword">const</font> vector&lt;CChain&gt;                    &amp;chains = lr.getChains();
00519         <font class="keyword">const</font> vector&lt;COrderedChain3f&gt;   &amp;ochains = lr.getFullOrderedChains();
00520         <font class="keyword">const</font> vector&lt;uint16&gt;                    &amp;bchains = lr.getBorderChains();
00521 
00522         {
00523                 uint    i;
00524 
00525                 <font class="keywordflow">for</font> (i=0; i&lt;bchains.size(); ++i)
00526                 {
00527                         <font class="keyword">static</font> <font class="keywordtype">char</font>     buf[512], <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>[256];
00528                         <font class="keyword">const</font> CChain    &amp;chain = chains[bchains[i]];
00529                         sprintf(buf, <font class="stringliteral">"chain=%d "</font>, bchains[i]);
00530                         uint    och;
00531                         <font class="keywordflow">for</font> (och=0; och&lt;chain.getSubChains().size(); ++och)
00532                         {
00533                                 <font class="keyword">const</font> COrderedChain3f   &amp;ochain = ochains[chain.getSubChain(och)];
00534                                 sprintf(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, <font class="stringliteral">"subchain=%d"</font>, chain.getSubChain(och));
00535                                 strcat(buf, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00536                                 uint    <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
00537                                 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&lt;ochain.getVertices().size(); ++<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
00538                                 {
00539                                         sprintf(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, <font class="stringliteral">" (%.2f,%.2f)"</font>, ochain[<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>].<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, ochain[<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>].<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
00540                                         strcat(buf, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00541                                 }
00542                         }
00543 
00544                         <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"%s"</font>, buf);
00545                 }
00546         }
00547 
00548         uint    edge, ch;
00549         <font class="keywordflow">for</font> (edge=0; edge+1&lt;edges.size(); ++edge)
00550         {
00551                 <font class="keywordflow">if</font> (edges[edge].Link == -1)
00552                         <font class="keywordflow">continue</font>;
00553 
00554                 CVector start = edges[edge].Start, stop = edges[edge+1].Start;
00555                 <font class="keywordtype">bool</font>    found = <font class="keyword">false</font>;
00556 
00557                 <font class="keywordflow">for</font> (ch=0; ch&lt;bchains.size() &amp;&amp; !found; ++ch)
00558                 {
00559                         <font class="comment">// get the border chain.</font>
00560                         <font class="comment">//const CChain  &amp;chain = chains[bchains[ch]];</font>
00561 
00562                         <font class="keyword">const</font> CVector   &amp;cstart = lr.getStartVector(bchains[ch]),
00563                                                         &amp;cstop = lr.getStopVector(bchains[ch]);
00564 
00565                         <font class="keywordtype">float</font> d = (start-cstart).norm()+(stop-cstop).norm();
00566                         <font class="keywordflow">if</font> (d &lt; 1.0e-1f)
00567                         {
00568                                 found = <font class="keyword">true</font>;
00569                                 <font class="keywordflow">break</font>;
00570                         }
00571                 }
00572 
00573                 <font class="comment">// create a link</font>
00574                 CExteriorMesh::CLink    link;
00575 
00576                 <font class="keywordflow">if</font> (!found)
00577                 {
00578                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in linkInteriorToExterior():"</font>);
00579                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"couldn't find any link to the exterior edge %d!!"</font>, edge);
00580                 }
00581                 <font class="keywordflow">else</font>
00582                 {
00583                         <font class="comment">// set it up to point on the chain and surface</font>
00584                         link.BorderChainId = ch;
00585                         link.ChainId = bchains[ch];
00586                         link.SurfaceId = (uint16)chains[link.ChainId].getLeft();
00587                 }
00588 
00589                 <font class="comment">// enlarge the links</font>
00590                 <font class="keywordflow">if</font> (edges[edge].Link &gt;= (sint)links.size())
00591                         links.resize(edges[edge].Link+1);
00592 
00593                 <font class="comment">// if the link already exists, warning</font>
00594                 <font class="keywordflow">if</font> (links[edges[edge].Link].BorderChainId != 0xFFFF ||
00595                         links[edges[edge].Link].ChainId != 0xFFFF ||
00596                         links[edges[edge].Link].SurfaceId != 0xFFFF)
00597                 {
00598                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in linkInteriorToExterior():"</font>);
00599                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"link %d already set!!"</font>, edges[edge].Link);
00600                 }
00601 
00602                 <font class="comment">// setup the link</font>
00603                 links[edges[edge].Link] = link;
00604         }
00605 
00606         em.setEdges(edges);
00607         em.setLinks(links);
00608         lr.setExteriorMesh(em);
00609 }
00610 
00611 
00612 
00613 
00614 
00615 <font class="comment">//</font>
00616 <font class="keywordtype">bool</font>    <a class="code" href="namespaceNLPACS.html#a25">computeRetriever</a>(CCollisionMeshBuild &amp;cmb, CLocalRetriever &amp;lr, CVector &amp;translation, string &amp;error, <font class="keywordtype">bool</font> useCmbTrivialTranslation)
00617 {
00618         <font class="comment">// set the retriever</font>
00619         lr.setType(CLocalRetriever::Interior);
00620 
00621         <font class="comment">// if should use the own cmb bbox, then compute it</font>
00622         <font class="keywordflow">if</font> (useCmbTrivialTranslation)
00623         {
00624                 translation = cmb.computeTrivialTranslation();
00625                 <font class="comment">// snap the translation vector to a meter wide grid</font>
00626                 translation.x = (float)ceil(translation.x);
00627                 translation.y = (float)ceil(translation.y);
00628                 translation.z = 0.0f;
00629         }
00630         
00631         vector&lt;string&gt;  errors;
00632         
00633         cmb.link(<font class="keyword">false</font>, errors);
00634         cmb.link(<font class="keyword">true</font>, errors);
00635 
00636         <font class="keywordflow">if</font> (!errors.empty())
00637         {
00638                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Edge issues reported !!"</font>);
00639                 uint    i;
00640                 error = <font class="stringliteral">""</font>;
00641                 <font class="keywordflow">for</font> (i=0; i&lt;errors.size(); ++i)
00642                         error += errors[i]+<font class="stringliteral">"\n"</font>;
00643                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00644         }
00645         
00646         <font class="comment">// translate the meshbuild to the local axis</font>
00647         cmb.translate(translation);
00648 
00649         <font class="comment">// find the exterior mesh border</font>
00650         CExteriorMesh   extMesh;
00651         <a class="code" href="namespaceNLPACS.html#a23">buildExteriorMesh</a>(cmb, extMesh);
00652         lr.setExteriorMesh(extMesh);
00653 
00654         <font class="comment">// build the surfaces in the local retriever</font>
00655         <a class="code" href="namespaceNLPACS.html#a16">buildSurfaces</a>(cmb, lr);
00656 
00657         <font class="comment">// create the snapping faces and vertices</font>
00658         <font class="comment">// after the build surfaces because the InternalSurfaceId is filled within buildSurfaces()...</font>
00659         <a class="code" href="namespaceNLPACS.html#a15">buildSnapping</a>(cmb, lr);
00660 
00661         <font class="comment">//</font>
00662         lr.computeLoopsAndTips();
00663 
00664         lr.findBorderChains();
00665         lr.updateChainIds();
00666         lr.computeTopologies();
00667 
00668         lr.unify();
00669 
00670         lr.computeCollisionChainQuad();
00671 <font class="comment">/*</font>
00672 <font class="comment">        //</font>
00673 <font class="comment">        for (i=0; i&lt;lr.getSurfaces().size(); ++i)</font>
00674 <font class="comment">                lr.dumpSurface(i);</font>
00675 <font class="comment">*/</font>
00676         <font class="comment">//</font>
00677         <a class="code" href="namespaceNLPACS.html#a24">linkExteriorToInterior</a>(lr);
00678 
00679         <font class="comment">// compute the bbox of the retriever</font>
00680         uint    i, j;
00681         CAABBox bbox;
00682         <font class="keywordtype">bool</font>    first = <font class="keyword">true</font>;
00683 
00684         <font class="keywordflow">for</font> (i=0; i&lt;extMesh.getEdges().size(); ++i)
00685                 <font class="keywordflow">if</font> (!first)
00686                         bbox.extend(extMesh.getEdge(i).Start);
00687                 <font class="keywordflow">else</font>
00688                         bbox.setCenter(extMesh.getEdge(i).Start), first=<font class="keyword">false</font>;
00689 
00690         <font class="keywordflow">for</font> (i=0; i&lt;lr.getOrderedChains().size(); ++i)
00691                 <font class="keywordflow">for</font> (j=0; j&lt;lr.getOrderedChain(i).getVertices().size(); ++j)
00692                         <font class="keywordflow">if</font> (!first)
00693                                 bbox.extend(lr.getOrderedChain(i)[j].unpack3f());
00694                         <font class="keywordflow">else</font>
00695                                 bbox.setCenter(lr.getOrderedChain(i)[j].unpack3f()), first=<font class="keyword">false</font>;
00696 
00697         CVector bboxhs = bbox.getHalfSize();
00698         bboxhs.z = 10000.0f;
00699         bbox.setHalfSize(bboxhs);
00700 
00701         lr.setBBox(bbox);
00702 
00703         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00704 }
00705 
00706 } <font class="comment">// NLPACS</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>