aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/local__retriever_8cpp-source.html
blob: dcd66f72c38b8358cac69215aa9a68f77f14174a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
<!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=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="/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>local_retriever.cpp</h1><a href="local__retriever_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="stdpacs_8h.html">stdpacs.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="plane_8h.html">nel/misc/plane.h</a>"</font>
00029 
00030 <font class="preprocessor">#include "<a class="code" href="local__retriever_8h.html">pacs/local_retriever.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="collision__desc_8h.html">pacs/collision_desc.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="retriever__instance_8h.html">pacs/retriever_instance.h</a>"</font>
00033 
00034 <font class="preprocessor">#include "<a class="code" href="hierarchical__timer_8h.html">nel/misc/hierarchical_timer.h</a>"</font>
00035 
00036 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00037 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00038 
<a name="l00040"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#q0">00040</a> <font class="keyword">const</font> <font class="keywordtype">float</font>     <a class="code" href="classNLPACS_1_1CLocalRetriever.html#q0">NLPACS::CLocalRetriever::_TipThreshold</a> = 0.1f;
<a name="l00041"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#q1">00041</a> <font class="keyword">const</font> <font class="keywordtype">float</font>     <a class="code" href="classNLPACS_1_1CLocalRetriever.html#q1">NLPACS::CLocalRetriever::_EdgeTipThreshold</a> = 0.1f;
00042 
<a name="l00044"></a><a class="code" href="local__retriever_8cpp.html#a0">00044</a> <font class="keyword">const</font> <font class="keywordtype">float</font>     <a class="code" href="local__retriever_8cpp.html#a0">InsurePositionThreshold</a> = 2.0e-2f;
00045 
00046 <font class="comment">//static float  hybrid2dNorm(const CVector &amp;v)</font>
00047 <font class="comment">//{</font>
00048 <font class="comment">//      return (float)(sqrt(sqr(v.x)+sqr(v.y))+fabs(v.z)*0.1);</font>
00049 <font class="comment">//}</font>
00050 
00051 
00052 
00053 
00054 
<a name="l00055"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z943_0">00055</a> <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z943_0">NLPACS::CLocalRetriever::CLocalRetriever</a>()
00056 {
00057         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n9">_Type</a> = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#s2s0">Landscape</a>;
00058         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_3">_FaceGrid</a>.clear();
00059 }
00060 
00061 
00062 
<a name="l00063"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a6">00063</a> <font class="keyword">const</font> CVector   &amp;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#a6">NLPACS::CLocalRetriever::getStartVector</a>(uint32 chain)<font class="keyword"> const</font>
00064 <font class="keyword"></font>{
00065         <font class="keyword">const</font> COrderedChain3f   &amp;ochain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getSubChains().front()];
00066         <font class="keywordflow">return</font> (ochain.isForward()) ? ochain.getVertices().front() : ochain.getVertices().back();
00067 }
00068 
<a name="l00069"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a7">00069</a> <font class="keyword">const</font> CVector   &amp;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#a7">NLPACS::CLocalRetriever::getStopVector</a>(uint32 chain)<font class="keyword"> const</font>
00070 <font class="keyword"></font>{
00071         <font class="keyword">const</font> COrderedChain3f   &amp;ochain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getSubChains().back()];
00072         <font class="keywordflow">return</font> (ochain.isForward()) ? ochain.getVertices().back() : ochain.getVertices().front();
00073 }
00074 
00075 
00076 
00077 
<a name="l00078"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a8">00078</a> <font class="keyword">const</font> CVector   &amp;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#a6">NLPACS::CLocalRetriever::getStartVector</a>(uint32 chain, sint32 surface)<font class="keyword"> const</font>
00079 <font class="keyword"></font>{
00080         <font class="keywordtype">bool</font>                                    onLeft = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface;
00081         <font class="keyword">const</font> COrderedChain3f   &amp;ochain = onLeft ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getSubChains().front()] :
00082                                                                                            <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getSubChains().back()];
00083 
00084         <font class="keywordflow">if</font> (ochain.isForward() &amp;&amp; onLeft || !ochain.isForward() &amp;&amp; !onLeft)
00085                 <font class="keywordflow">return</font> ochain.getVertices().front();
00086         <font class="keywordflow">else</font>
00087                 <font class="keywordflow">return</font> ochain.getVertices().back();
00088 }
00089 
<a name="l00090"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a9">00090</a> <font class="keyword">const</font> CVector   &amp;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#a7">NLPACS::CLocalRetriever::getStopVector</a>(uint32 chain, sint32 surface)<font class="keyword"> const</font>
00091 <font class="keyword"></font>{
00092         <font class="keywordtype">bool</font>                                    onLeft = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface;
00093         <font class="keyword">const</font> COrderedChain3f   &amp;ochain = onLeft ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getSubChains().back()] :
00094                                                                                            <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getSubChains().front()];
00095 
00096         <font class="keywordflow">if</font> (ochain.isForward() &amp;&amp; onLeft || !ochain.isForward() &amp;&amp; !onLeft)
00097                 <font class="keywordflow">return</font> ochain.getVertices().back();
00098         <font class="keywordflow">else</font>
00099                 <font class="keywordflow">return</font> ochain.getVertices().front();
00100 }
00101 
00102 
00103 
00104 
<a name="l00105"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a10">00105</a> uint16                  <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a10">NLPACS::CLocalRetriever::getStartTip</a>(uint32 chain, sint32 surface)<font class="keyword"> const</font>
00106 <font class="keyword"></font>{
00107         <font class="keywordflow">return</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface) ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getStartTip() : <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getStopTip();
00108 }
00109 
<a name="l00110"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a11">00110</a> uint16                  <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a11">NLPACS::CLocalRetriever::getStopTip</a>(uint32 chain, sint32 surface)<font class="keyword"> const</font>
00111 <font class="keyword"></font>{
00112         <font class="keywordflow">return</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface) ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getStopTip() : <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getStartTip();
00113 }
00114 
00115 
00116 
00117 
00118 
<a name="l00119"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a12">00119</a> <font class="keywordtype">void</font>                    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a12">NLPACS::CLocalRetriever::setStartTip</a>(uint32 chain, sint32 surface, uint16 startTip)
00120 {
00121         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface)
00122                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._StartTip = startTip;
00123         <font class="keywordflow">else</font>
00124                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._StopTip = startTip;
00125 }
00126 
<a name="l00127"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a13">00127</a> <font class="keywordtype">void</font>                    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a13">NLPACS::CLocalRetriever::setStopTip</a>(uint32 chain, sint32 surface, uint16 stopTip)
00128 {
00129         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface)
00130                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._StopTip = stopTip;
00131         <font class="keywordflow">else</font>
00132                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._StartTip = stopTip;
00133 }
00134 
00135 
00136 
00137 
<a name="l00138"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a14">00138</a> uint32                  <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a14">NLPACS::CLocalRetriever::getPreviousChain</a>(uint32 chain, sint32 surface)<font class="keyword"> const</font>
00139 <font class="keyword"></font>{
00140         uint                                                            loop;
00141         uint                                                            loopIndex;
00142 
00143         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface)
00144         {
00145                 loop = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._LeftLoop;
00146                 loopIndex = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._LeftLoopIndex;
00147         }
00148         <font class="keywordflow">else</font>
00149         {
00150                 loop = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._RightLoop;
00151                 loopIndex = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._RightLoopIndex;
00152         }
00153 
00154         <font class="keyword">const</font> CRetrievableSurface                       &amp;surf = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surface];
00155         <font class="keyword">const</font> CRetrievableSurface::TLoop        &amp;sLoop = surf._Loops[loop];
00156         <font class="keywordflow">return</font> surf._Chains[sLoop[(loopIndex+sLoop.size()-1)%sLoop.size()]].Chain;
00157 }
00158 
<a name="l00159"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a15">00159</a> uint32                  <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a15">NLPACS::CLocalRetriever::getNextChain</a>(uint32 chain, sint32 surface)<font class="keyword"> const</font>
00160 <font class="keyword"></font>{
00161         uint                                                            loop;
00162         uint                                                            loopIndex;
00163 
00164         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() == surface)
00165         {
00166                 loop = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._LeftLoop;
00167                 loopIndex = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._LeftLoopIndex;
00168         }
00169         <font class="keywordflow">else</font>
00170         {
00171                 loop = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._RightLoop;
00172                 loopIndex = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._RightLoopIndex;
00173         }
00174 
00175         <font class="keyword">const</font> CRetrievableSurface                       &amp;surf = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surface];
00176         <font class="keyword">const</font> CRetrievableSurface::TLoop        &amp;sLoop = surf._Loops[loop];
00177         <font class="keywordflow">return</font> surf._Chains[sLoop[(loopIndex+1)%sLoop.size()]].Chain;
00178 }
00179 
00180 
00181 
00182 
<a name="l00183"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a5">00183</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a5">NLPACS::CLocalRetriever::unify</a>()
00184 {
00185         uint    i, j;
00186 
00187         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>.size(); ++i)
00188                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[i].unify(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>);
00189 
00190         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>.size(); ++i)
00191         {
00192                 <a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html">NLPACS::CLocalRetriever::CTip</a>   &amp;tip = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>[i];
00193                 CVector2s ptip = tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m0">Point</a>;
00194 
00195                 <font class="keywordflow">for</font> (j=0; j&lt;tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>.size(); ++j)
00196                 {
00197                         <font class="keywordflow">if</font> (tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>[j].Start)
00198                         {
00199                                 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>[j].Chain].getStartVector(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>) != ptip)
00200                                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"chain %d is not stuck to tip %d"</font>, tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>[j].Chain, i);
00201                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>[j].Chain].setStartVector(ptip, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>);
00202                         }
00203                         <font class="keywordflow">else</font>
00204                         {
00205                                 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>[j].Chain].getStopVector(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>) != ptip)
00206                                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"chain %d is not stuck to tip %d"</font>, tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>[j].Chain, i);
00207                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[tip.<a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CTip.html#m1">Chains</a>[j].Chain].setStopVector(ptip, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>);
00208                         }
00209                 }
00210         }
00211 
00212         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>.resize(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>.size());
00213         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>.size(); ++i)
00214                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[i].unpack(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[i]);
00215 }
00216 
00217 
00218 
00219 
00220 
00221 
00222 
<a name="l00223"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a16">00223</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a16">NLPACS::CLocalRetriever::dumpSurface</a>(uint surf, <font class="keyword">const</font> CVector &amp;vect)<font class="keyword"> const</font>
00224 <font class="keyword"></font>{
00225         <font class="keyword">const</font> CRetrievableSurface       &amp;surface = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surf];
00226 
00227         <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"dump surf %d"</font>, surf);
00228         <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"%d chains, %d loops"</font>, surface._Chains.size(), surface._Loops.size());
00229         
00230         uint    i, j, k;
00231 
00232         <font class="keywordflow">for</font> (i=0; i&lt;surface._Chains.size(); ++i)
00233         {
00234                 uint                    chainId = surface._Chains[i].Chain;
00235                 <font class="keyword">const</font> CChain    &amp;chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chainId];
00236                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"-- chain %d[%d]: %d sub left=%d right=%d start=%d stop=%d"</font>, i, chainId, chain.getSubChains().size(), chain.getLeft(), chain.getRight(), chain.getStartTip(), chain.getStopTip());
00237 
00238                 <font class="keywordflow">for</font> (j=0; j&lt;chain.getSubChains().size(); ++j)
00239                 {
00240                         <font class="keyword">const</font> COrderedChain3f   &amp;ochain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>[chain.getSubChain(j)];
00241                         <font class="keyword">const</font> COrderedChain             &amp;ochains = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[chain.getSubChain(j)];
00242                         <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"     subchain %d[%d]: fwd=%d parent=%d idx=%d"</font>, j, chain.getSubChain(j), ochain.isForward(), ochain.getParentId(), ochain.getIndexInParent());
00243                         <font class="keywordflow">for</font> (k=0; k&lt;ochain.getVertices().size(); ++k)
00244                                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"       v[%d]=(%.3f,%.3f,%.3f) (%d,%d)"</font>, k, ochain.getVertices()[k].x+vect.x, ochain.getVertices()[k].y+vect.y, ochain.getVertices()[k].z+vect.z, ochains.getVertices()[k].x, ochains.getVertices()[k].y);
00245                 }
00246 
00247         }
00248 
00249         <font class="keywordflow">for</font> (i=0; i&lt;surface._Loops.size(); ++i)
00250         {
00251                 <font class="keyword">const</font> CRetrievableSurface::TLoop        &amp;loop = surface._Loops[i];
00252                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"-- loop %d: %d chains length=%.2f"</font>, i, loop.size(), loop.Length);
00253                 <font class="keyword">static</font> <font class="keywordtype">char</font>     wbuffer[256];
00254                 <font class="keyword">static</font> <font class="keywordtype">char</font>     buffer[10240];
00255                 sprintf(buffer, <font class="stringliteral">"    chains:"</font>);
00256                 <font class="keywordflow">for</font> (j=0; j&lt;loop.size(); ++j)
00257                 {
00258                         sprintf(wbuffer, <font class="stringliteral">" %d[%d]"</font>, loop[j], surface._Chains[loop[j]].Chain);
00259                         strcat(buffer, wbuffer);
00260                 }
00261                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"%s"</font>, buffer);
00262         }
00263 }
00264 
00265 
<a name="l00266"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a17">00266</a> <font class="keywordtype">float</font>   <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a17">NLPACS::CLocalRetriever::distanceToBorder</a>(<font class="keyword">const</font> ULocalPosition &amp;pos)<font class="keyword"> const</font>
00267 <font class="keyword"></font>{
00268         <font class="keyword">const</font> CRetrievableSurface       &amp;surf = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[pos.Surface];
00269         uint                                            i, j;
00270         <font class="keywordtype">float</font>                                           minDist = 1.0e10f, dist;
00271 
00272         <font class="keywordflow">for</font> (i=0; i&lt;surf._Chains.size(); ++i)
00273         {
00274                 <font class="keyword">const</font> CChain    &amp;chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[surf._Chains[i].Chain];
00275                 <font class="keywordflow">for</font> (j=0; j&lt;chain.getSubChains().size(); ++j)
00276                 {
00277                         dist = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[chain.getSubChain(j)].distance(pos.Estimation);
00278                         <font class="keywordflow">if</font> (dist &lt; minDist)
00279                         {
00280                                 minDist = dist;
00281                         }
00282                 }
00283         }
00284 
00285         <font class="keywordflow">return</font> minDist;
00286 }
00287 
00288 
00289 
00290 
00291 
<a name="l00292"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_0">00292</a> sint32  <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_0">NLPACS::CLocalRetriever::addSurface</a>(uint8 normalq, uint8 orientationq,
00293                                                                                         uint8 mat, uint8 charact, uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>,
00294                                                                                         <font class="keywordtype">bool</font> isUnderWater, <font class="keywordtype">float</font> waterHeight,
00295                                                                                         <font class="keyword">const</font> CVector &amp;center,
00296                                                                                         <font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CSurfaceQuadTree.html">NLPACS::CSurfaceQuadTree</a> &amp;quad)
00297 {
00298         <font class="comment">// creates a new surface...</font>
00299         sint32  newId = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size();
00300         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.resize(newId+1);
00301         CRetrievableSurface     &amp;surf = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.back();
00302 
00303         <font class="comment">// ... and fills it</font>
00304         surf._NormalQuanta = normalq;
00305         surf._OrientationQuanta = orientationq;
00306         surf._Material = mat;
00307         surf._Character = charact;
00308         surf._Level = <a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>;
00309         surf._Quad = quad;
00310         surf._Center = center;
00311 
00312         <font class="comment">// WARNING!! MODIFY THESE IF QUANTAS VALUES CHANGE !!</font>
00313         surf._IsFloor = (surf._NormalQuanta &lt;= 1);
00314         surf._IsCeiling = (surf._NormalQuanta &gt;= 3);
00315 
00316         surf._Flags = 0;
00317         surf._Flags |= (surf._IsFloor) ? (1&lt;&lt;CRetrievableSurface::IsFloorBit) : 0;
00318         surf._Flags |= (surf._IsCeiling) ? (1&lt;&lt;CRetrievableSurface::IsCeilingBit) : 0;
00319         surf._Flags |= (!surf._IsFloor &amp;&amp; !surf._IsCeiling) ? (1&lt;&lt;CRetrievableSurface::IsSlantBit) : 0;
00320 
00321         surf._Flags |= (isUnderWater) ? (1&lt;&lt;CRetrievableSurface::IsUnderWaterBit) : 0;
00322         surf._WaterHeight = waterHeight;
00323 
00324         surf._Flags |= ((0xffffffff&lt;&lt;(CRetrievableSurface::NormalQuantasStartBit)) &amp; CRetrievableSurface::NormalQuantasBitMask);
00325 
00326         <font class="keywordflow">return</font> newId;
00327 }
00328 
00329 sint32  <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_1">NLPACS::CLocalRetriever::addChain</a>(<font class="keyword">const</font> vector&lt;CVector&gt; &amp;verts,
00330                                                                                   sint32 left, sint32 right)
00331 {
00332         vector&lt;CVector&gt; vertices = verts;
00333         uint            i;
00334 
00335         <font class="keywordflow">if</font> (vertices.size() &lt; 2)
00336         {
00337                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::addChain()"</font>);
00338                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"The chain has less than 2 vertices"</font>);
00339                 <font class="keywordflow">return</font> -1;
00340         }
00341 
00342         <font class="comment">// Remove doubled vertices due to CVector2s snapping</font>
00343         vector&lt;CVector2s&gt;       converts;
00344 
00345         <font class="keywordflow">for</font> (i=0; i&lt;vertices.size(); ++i)
00346                 converts.push_back(CVector2s(vertices[i]));
00347 
00348         vector&lt;CVector2s&gt;::iterator     next2s = converts.begin(), it2s, prev2s;
00349         prev2s = next2s; ++next2s;
00350         it2s = next2s; ++next2s;
00351 
00352         vector&lt;CVector&gt;::iterator       it3f = vertices.begin();
00353         CVector                                         prev3f = *it3f;
00354         ++it3f;
00355 
00356 
00357         <font class="keywordflow">for</font> (; it2s != converts.end() &amp;&amp; next2s != converts.end(); )
00358         {
00359                 <font class="comment">// if the next point is equal to the previous</font>
00360                 <font class="keywordflow">if</font> (*it2s == *prev2s || *it2s == *next2s)
00361                 {
00362                         <font class="comment">// then remove the next point</font>
00363                         it2s = converts.erase(it2s);
00364                         it3f = vertices.erase(it3f);
00365 
00366                         prev2s = it2s;
00367                         --prev2s;
00368                         next2s = it2s;
00369                         ++next2s;
00370                 }
00371                 <font class="keywordflow">else</font>
00372                 {
00373                         <font class="comment">// else remember the next point, and step to the next...</font>
00374                         ++prev2s;
00375                         ++it2s;
00376                         ++next2s;
00377                         ++it3f;
00378                         prev3f = *it3f;
00379                 }
00380         }
00381         
00382         <font class="keywordflow">if</font> (vertices.size() &lt; 2)
00383         {
00384                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::addChain()"</font>);
00385                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"The chain was snapped to a single point"</font>);
00386                 <font class="keywordflow">return</font> -1;
00387         }
00388 
00389         sint32          newId = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>.size();
00390         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>.resize(newId+1);
00391         CChain          &amp;chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>.back();
00392 
00393         <font class="keywordflow">if</font> (left&gt;(sint)<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size())
00394                 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"left surface id MUST be id&lt;%d (id=%d)"</font>, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(), left);
00395         <font class="keywordflow">if</font> (right&gt;(sint)<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size())
00396                 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"right surface id MUST be id&lt;%d (id=%d)"</font>, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(), right);
00397 
00398         <font class="comment">// checks if we can build the chain.</font>
00399         <font class="keywordflow">if</font> (newId &gt; 65535)
00400                 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::addChain(): reached the maximum number of chains"</font>);
00401 
00402         CRetrievableSurface     *leftSurface = (left&gt;=0) ? &amp;(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[left]) : NULL;
00403         CRetrievableSurface     *rightSurface = (right&gt;=0) ? &amp;(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[right]) : NULL;
00404 
00405         <font class="comment">// adds the chain and the link to the surface links vector.</font>
00406         <font class="keywordflow">if</font> (leftSurface != NULL)
00407                 leftSurface-&gt;_Chains.push_back(CRetrievableSurface::CSurfaceLink(newId, right));
00408         <font class="keywordflow">if</font> (rightSurface != NULL)
00409                 rightSurface-&gt;_Chains.push_back(CRetrievableSurface::CSurfaceLink(newId, left));
00410 
00411         chain._StartTip = 0xffff;
00412         chain._StopTip = 0xffff;
00413 
00414         <font class="comment">// make the chain and its subchains.</font>
00415         chain.make(vertices, left, right, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>, (uint16)newId, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>);
00416 
00417         <font class="keywordflow">return</font> newId;
00418 }
00419 
00420 
00421 
00422 
<a name="l00423"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_11">00423</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_11">NLPACS::CLocalRetriever::computeLoopsAndTips</a>()
00424 {
00425         <font class="comment">// for each surface,</font>
00426         <font class="comment">// examine each chain tip to match another tip inside the surface tips</font>
00427         <font class="comment">// if there is no matching tip, then creates a new one</font>
00428 
00429         uint    i, j;
00430 
00431         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(); ++i)
00432         {
00433                 CRetrievableSurface     &amp;surface = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i];
00434 
00435                 vector&lt;bool&gt;            chainFlags;
00436                 chainFlags.resize(surface._Chains.size());
00437                 <font class="keywordflow">for</font> (j=0; j&lt;chainFlags.size(); ++j)
00438                         chainFlags[j] = <font class="keyword">false</font>;
00439 
00440                 uint    totalAdded = 0;
00441 
00442                 <font class="keywordflow">while</font> (true)
00443                 {
00444                         <font class="keywordflow">for</font> (j=0; j&lt;chainFlags.size() &amp;&amp; chainFlags[j]; ++j)
00445                                 ;
00446 
00447                         <font class="keywordflow">if</font> (j == chainFlags.size())
00448                                 <font class="keywordflow">break</font>;
00449 
00450                         uint32                                          loopId = surface._Loops.size();
00451                         surface._Loops.push_back(CRetrievableSurface::TLoop());
00452                         CRetrievableSurface::TLoop      &amp;loop = surface._Loops.back();
00453 
00454                         CVector loopStart = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a6">getStartVector</a>(surface._Chains[j].Chain, i);
00455                         CVector currentEnd = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a7">getStopVector</a>(surface._Chains[j].Chain, i);
00456                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[surface._Chains[j].Chain].setLoopIndexes(i, loopId, loop.size());
00457                         loop.push_back(j);
00458                         chainFlags[j] = <font class="keyword">true</font>;
00459 
00460                         <font class="keywordtype">float</font>   loopCloseDistance;
00461 
00462                         <font class="keywordflow">while</font> (true)
00463                         {
00464 <font class="comment">//                              loopCloseDistance = hybrid2dNorm(loopStart-currentEnd);</font>
00465                                 loopCloseDistance = (loopStart-currentEnd).norm();
00466 
00467                                 <font class="comment">// choose the best matching start vector</font>
00468                                 sint    bestChain = -1;
00469                                 <font class="keywordtype">float</font>   best = 1.0e10f;
00470                                 CVector thisStart;
00471                                 <font class="keywordflow">for</font> (j=0; j&lt;chainFlags.size(); ++j)
00472                                 {
00473                                         <font class="keywordflow">if</font> (chainFlags[j])
00474                                                 <font class="keywordflow">continue</font>;
00475                                         thisStart = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a6">getStartVector</a>(surface._Chains[j].Chain, i);
00476 <font class="comment">//                                      float   d = hybrid2dNorm(thisStart-currentEnd);</font>
00477                                         <font class="keywordtype">float</font>   d = (thisStart-currentEnd).norm();
00478                                         <font class="keywordflow">if</font> (d &lt; best)
00479                                         {
00480                                                 best = d;
00481                                                 bestChain = j;
00482                                         }
00483                                 }
00484 
00485                                 <font class="keywordflow">if</font> ((bestChain == -1 || best &gt; 3.0e-2f)&amp;&amp; loopCloseDistance &gt; 3.0e-2f)
00486                                 {
00487                                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::computeTips()"</font>);
00488 
00489                                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a16">dumpSurface</a>(i);
00490 
00491                                         <font class="keywordflow">for</font> (j=0; j&lt;surface._Chains.size(); ++j)
00492                                         {
00493                                                 CVector start = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a6">getStartVector</a>(surface._Chains[j].Chain, i);
00494                                                 CVector end = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a7">getStopVector</a>(surface._Chains[j].Chain, i);
00495                                                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"surf=%d chain=%d"</font>, i, surface._Chains[j].Chain);
00496                                                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"start=(%f,%f,%f)"</font>, start.x, start.y, start.z);
00497                                                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"end=(%f,%f,%f)"</font>, end.x, end.y, end.z);
00498                                         }
00499                                         
00500                                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"bestChain=%d best=%f"</font>, bestChain, best);
00501                                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"loopCloseDistance=%f"</font>, loopCloseDistance);
00502                                         <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Couldn't close loop on surface=%d"</font>, i);
00503                                 }
00504                                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (best &gt; 1.0e0f &amp;&amp; loopCloseDistance &lt; 3.0e-2f ||
00505                                                  loopCloseDistance &lt; 1.0e-3f)
00506                                 {
00507                                         <font class="keywordflow">break</font>;
00508                                 }
00509 
00510                                 currentEnd = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a7">getStopVector</a>(surface._Chains[bestChain].Chain, i);
00511                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[surface._Chains[bestChain].Chain].setLoopIndexes(i, loopId, loop.size());
00512                                 loop.push_back(bestChain);
00513                                 chainFlags[bestChain] = <font class="keyword">true</font>;
00514                                 ++totalAdded;
00515                         }
00516                 }
00517         }
00518 
00519         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>.size(); ++i)
00520         {
00521 <font class="comment">/*              if (i == 431)</font>
00522 <font class="comment">                        nlstop;</font>
00523 <font class="comment">*/</font>
00524                 uint    whichTip;
00525                 <font class="comment">// for both tips (start and stop)</font>
00526                 <font class="keywordflow">for</font> (whichTip=0; whichTip&lt;=1; ++whichTip)
00527                 {
00528                         <font class="comment">// get the tip id</font>
00529                         uint    thisTip = (whichTip) ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[i].getStopTip() : <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[i].getStartTip();
00530 
00531                         <font class="keywordflow">if</font> (thisTip != 0xffff &amp;&amp; thisTip &gt;= <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>.size())
00532                         {
00533                                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::computeLoopsAndTips()"</font>);
00534                                 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"checked a tip that doesn't exist on chain %d (tipId=%d)"</font>, i, thisTip);
00535                         }
00536 
00537                         <font class="comment">// if it is unaffected yet creates an new tip and affect it to the common chains</font>
00538                         <font class="keywordflow">if</font> (thisTip == 0xffff)
00539                         {
00540                                 uint    turn;
00541                                 uint    tipId = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>.size();
00542 <font class="comment">/*</font>
00543 <font class="comment">                                if (tipId == 310)</font>
00544 <font class="comment">                                        nlstop;</font>
00545 <font class="comment">*/</font>
00546                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>.resize(tipId+1);
00547                                 CTip    &amp;tip = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>[tipId];
00548                                 tip.Point = (whichTip) ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a7">getStopVector</a>(i) : <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a6">getStartVector</a>(i);
00549 
00550                                 <font class="keywordflow">for</font> (turn=0; turn&lt;=1; ++turn)
00551                                 {
00552                                         uint    chain = i;
00553 
00554                                         <font class="comment">//</font>
00555                                         <font class="keywordflow">if</font> (whichTip)
00556                                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._StopTip = tipId;
00557                                         <font class="keywordflow">else</font>
00558                                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._StartTip = tipId;
00559 
00560                                         sint32  surf = (!turn &amp;&amp; !whichTip || turn &amp;&amp; whichTip) ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getLeft() : <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].getRight();
00561 
00562                                         <font class="keywordflow">while</font> (surf &gt;= 0)
00563                                         {
00564 
00565                                                 CChain  &amp;nextChain = (turn) ? <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a15">getNextChain</a>(chain, surf)] : <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a14">getPreviousChain</a>(chain, surf)];
00566                                                 <font class="keywordtype">bool</font>    isForward = (nextChain.getLeft() == surf);      <font class="comment">// tells if the left surf is the current surf</font>
00567                                                 <font class="keywordtype">bool</font>    selectTip = isForward &amp;&amp; !turn || !isForward &amp;&amp; turn;
00568                                                 uint16  &amp;tipRef = selectTip ? nextChain._StopTip : nextChain._StartTip;
00569                                                 surf = (isForward) ? nextChain.getRight() : nextChain.getLeft();
00570 
00571                                                 <font class="keywordflow">if</font> (tipRef != 0xffff &amp;&amp; tipRef != tipId)
00572                                                 {
00573                                                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::computeLoopsAndTips()"</font>);
00574                                                         <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Trying to setup a already created tip (tipId=%d, previous=%d)"</font>, tipId, tipRef);
00575                                                 }
00576                                                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (tipRef != 0xffff)
00577                                                 {
00578                                                         <font class="keywordflow">break</font>;
00579                                                 }
00580 
00581                                                 tipRef = tipId;
00582                                         }
00583                                 }
00584                         }
00585                 }
00586         }
00587 
00588         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>.size(); ++i)
00589         {
00590                 uint    startTip = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[i].getStartTip(),
00591                                 stopTip = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[i].getStopTip();
00592 
00593 <font class="comment">/*</font>
00594 <font class="comment">                if (_Chains[i].getEdge() &gt;= 0 &amp;&amp; startTip == stopTip)</font>
00595 <font class="comment">                {</font>
00596 <font class="comment">                        nlwarning("NLPACS::CLocalRetriever::computeLoopsAndTips(): chain %d on edge %d has same StartTip and StopTip", i, _Chains[i].getEdge(), startTip, stopTip);</font>
00597 <font class="comment">                }</font>
00598 <font class="comment">*/</font>
00599 
00600                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>[startTip].Chains.push_back(CTip::CChainTip(i, <font class="keyword">true</font>));
00601                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>[stopTip].Chains.push_back(CTip::CChainTip(i, <font class="keyword">false</font>));
00602         }
00603 
00604         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(); ++i)
00605         {
00606                 <font class="keywordflow">for</font> (j=0; j&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i]._Loops.size(); ++j)
00607                 {
00608                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i]._Loops[j].Length = 0.0f;
00609                         uint    k;
00610 
00611                         <font class="keywordflow">for</font> (k=0; k&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i]._Loops[j].size(); ++k)
00612                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i]._Loops[j].Length += <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i]._Chains[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i]._Loops[j][k]].Chain].getLength();
00613                 }
00614         }
00615 }
00616 
00617 
00618 <font class="comment">//</font>
<a name="l00619"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z944_19">00619</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z944_19">NLPACS::CLocalRetriever::buildSurfacePolygons</a>(uint32 surface, list&lt;CPolygon&gt; &amp;polygons)<font class="keyword"> const</font>
00620 <font class="keyword"></font>{
00621         <font class="keyword">const</font> CRetrievableSurface       &amp;surf = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surface];
00622 
00623         uint    i, j, k, <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>;
00624 
00625         <font class="keywordflow">for</font> (i=0; i&lt;surf._Loops.size(); ++i)
00626         {
00627                 polygons.push_back();
00628                 CPolygon        &amp;poly = polygons.back();
00629 
00630                 <font class="keywordflow">for</font> (j=0; j&lt;surf._Loops[i].size(); ++j)
00631                 {
00632                         <font class="keyword">const</font> CChain    &amp;chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[surf._Loops[i][j]];
00633                         <font class="keywordtype">bool</font>                    chainforward = ((uint32)chain._Left == surface);
00634 
00635                         <font class="keywordflow">if</font> (chainforward)
00636                         {
00637                                 <font class="keywordflow">for</font> (k=0; k&lt;chain._SubChains.size(); ++k)
00638                                 {
00639                                         <font class="keyword">const</font> COrderedChain             &amp;ochain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[chain._SubChains[k]];
00640                                         <font class="keywordtype">bool</font>                                    ochainforward = ochain.isForward();
00641 
00642                                         <font class="keywordflow">if</font> (ochainforward)
00643                                         {
00644                                                 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>=0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>&lt;ochain.getVertices().size()-1; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00645                                                         poly.Vertices.push_back(ochain[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>].unpack3f());
00646                                         }
00647                                         <font class="keywordflow">else</font>
00648                                         {
00649                                                 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>=ochain.getVertices().size()-1; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>&gt;0; --<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00650                                                         poly.Vertices.push_back(ochain[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>].unpack3f());
00651                                         }
00652                                 }
00653                         }
00654                         <font class="keywordflow">else</font>
00655                         {
00656                                 <font class="keywordflow">for</font> (k=chain._SubChains.size(); (sint)k&gt;0; --k)
00657                                 {
00658                                         <font class="keyword">const</font> COrderedChain             &amp;ochain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[chain._SubChains[k]];
00659                                         <font class="keywordtype">bool</font>                                    ochainforward = ochain.isForward();
00660 
00661                                         <font class="keywordflow">if</font> (ochainforward)
00662                                         {
00663                                                 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>=ochain.getVertices().size()-1; (sint)<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>&gt;0; --<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00664                                                         poly.Vertices.push_back(ochain[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>].unpack3f());
00665                                         }
00666                                         <font class="keywordflow">else</font>
00667                                         {
00668                                                 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>=0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>&lt;ochain.getVertices().size()-1; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00669                                                         poly.Vertices.push_back(ochain[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>].unpack3f());
00670                                         }
00671                                 }
00672                         }
00673                 }
00674         }
00675 }
00676 
00677 
00678 <font class="comment">// not implemented...</font>
<a name="l00679"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_14">00679</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_14">NLPACS::CLocalRetriever::sortTips</a>()
00680 {
00681 }
00682 
00683 
00684 
00685 
<a name="l00686"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_12">00686</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_12">NLPACS::CLocalRetriever::findBorderChains</a>()
00687 {
00688         uint    chain;
00689 
00690         <font class="comment">// for each chain, if it belongs to an edge of the</font>
00691         <font class="comment">// local retriever, then adds it to the _BorderChains.</font>
00692         <font class="keywordflow">for</font> (chain=0; chain&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>.size(); ++chain)
00693                 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].isBorderChain())
00694                 {
00695                         sint32  <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n6">_BorderChains</a>.size();
00696                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n6">_BorderChains</a>.push_back(chain);
00697                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain].setBorderChainIndex(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00698                 }
00699 }
00700 
<a name="l00701"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_13">00701</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_13">NLPACS::CLocalRetriever::updateChainIds</a>()
00702 {
00703         uint    surf, link;
00704 
00705         <font class="keywordflow">for</font> (surf=0; surf&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(); ++surf)
00706         {
00707                 CRetrievableSurface     &amp;surface = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surf];
00708 
00709                 <font class="keywordflow">for</font> (link=0; link&lt;surface._Chains.size(); ++link)
00710                 {
00711                         sint32  chain = surface._Chains[link].Chain;
00712 
00713                         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._Left == (sint32)surf)
00714                                 surface._Chains[link].Surface = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._Right;
00715                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._Right == (sint32)surf)
00716                                 surface._Chains[link].Surface = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain]._Left;
00717                         <font class="keywordflow">else</font>
00718                         {
00719                                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::updateEdgesOnSurfaces()"</font>);
00720                                 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Can't find back point to surface %d on chain %d"</font>, surf, chain);
00721                         }
00722                 }
00723         }
00724 }
00725 
<a name="l00726"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_10">00726</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_10">NLPACS::CLocalRetriever::computeTopologies</a>()
00727 {
00728         <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"compute topologies"</font>);
00729 
00730         <font class="comment">// Find topologies out...</font>
00731         uint            character;
00732         <font class="keywordflow">for</font> (character=0; character&lt;<a class="code" href="namespaceNLPACS.html#a30a8">NumCreatureModels</a>; ++character)
00733         {
00734                 <font class="comment">// for each type of creature, flood fill surfaces...</font>
00735                 sint32  surface;
00736                 uint    topology = 0;
00737 
00738                 <font class="keywordflow">for</font> (surface=0; surface&lt;(sint)<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(); ++surface)
00739                 {
00740                         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surface]._Topologies[character] == -1 &amp;&amp;
00741                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surface]._Character == character)
00742                         {
00743                                 vector&lt;sint32&gt;  surfacesStack;
00744                                 surfacesStack.push_back(surface);
00745 
00746                                 <font class="keywordflow">while</font> (!surfacesStack.empty())
00747                                 {
00748                                         CRetrievableSurface     &amp;current = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surfacesStack.back()];
00749                                         surfacesStack.pop_back();
00750                                         current._Topologies[character] = topology;
00751 
00752                                         uint    i;
00753                                         <font class="keywordflow">for</font> (i=0; i&lt;current._Chains.size(); ++i)
00754                                         {
00755                                                 CChain  &amp;chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[current._Chains[i].Chain];
00756                                                 sint32  link = (chain.getLeft() == surface) ? chain.getRight() : chain.getLeft();
00757                                                 <font class="keywordflow">if</font> (link&gt;=0 &amp;&amp; link&lt;(sint)<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size() &amp;&amp;
00758                                                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[link]._Topologies[character] == -1 &amp;&amp;
00759                                                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[link]._Character &gt;= character)
00760                                                 {
00761                                                         surfacesStack.push_back(link);
00762                                                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[link]._Topologies[character] = topology;
00763                                                 }
00764                                         }
00765                                 }
00766 
00767                                 ++topology;
00768                         }
00769                 }
00770 
00771                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n7">_Topologies</a>[character].resize(topology);
00772                 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"generated %d topologies for character %d"</font>, topology, character);
00773         }
00774 
00775         uint            surface;
00776         <font class="keywordflow">for</font> (surface=0; surface&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(); ++surface)
00777         {
00778                 CRetrievableSurface     &amp;current = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surface];
00779 
00780                 <font class="keywordflow">for</font> (character=0; character&lt;<a class="code" href="namespaceNLPACS.html#a30a8">NumCreatureModels</a>; ++character)
00781                         <font class="keywordflow">if</font> (current._Topologies[character] &gt;= 0)
00782                                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n7">_Topologies</a>[character][current._Topologies[character]].push_back(surface);
00783         }
00784 }
00785 
<a name="l00786"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_15">00786</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_15">NLPACS::CLocalRetriever::translate</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;translation)
00787 {
00788         uint    i;
00789         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>.size(); ++i)
00790                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[i].translate(translation);
00791         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(); ++i)
00792                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[i].translate(translation);
00793         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>.size(); ++i)
00794                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>[i].translate(translation);
00795 }
00796 
<a name="l00797"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_17">00797</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_17">NLPACS::CLocalRetriever::serial</a>(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
00798 {
00799         <font class="comment">/*</font>
00800 <font class="comment">        Version 0:</font>
00801 <font class="comment">                - base version (with collision info).</font>
00802 <font class="comment">        Version 1:</font>
00803 <font class="comment">                - interior vertices and faces, for interior ground snapping</font>
00804 <font class="comment">        Version 2:</font>
00805 <font class="comment">                - face grid added.</font>
00806 <font class="comment">        Version 3:</font>
00807 <font class="comment">                - identifier added.</font>
00808 <font class="comment">        */</font>
00809         sint    ver= f.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>(3);
00810 
00811         uint    i;
00812         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>);
00813         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>);
00814         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n1">_FullOrderedChains</a>);
00815         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>);
00816         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n5">_Tips</a>);
00817         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n6">_BorderChains</a>);
00818         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="namespaceNLPACS.html#a30a8">NumCreatureModels</a>; ++i)
00819                 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n7">_Topologies</a>[i]);
00820         f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n8">_ChainQuad</a>);
00821         f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n4">_BBox</a>);
00822         f.<a class="code" href="classNLMISC_1_1IStream.html#a6">serialEnum</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n9">_Type</a>);
00823         f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_0">_ExteriorMesh</a>);
00824 
00825         <font class="comment">// a fix for old versions (with wrong _Type value)</font>
00826         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n9">_Type</a> != CLocalRetriever::Interior) <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n9">_Type</a> = CLocalRetriever::Landscape;
00827 
00828         <font class="keywordflow">if</font> (ver &gt;= 1)
00829         {
00830                 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>);
00831                 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_2">_InteriorFaces</a>);
00832 
00833         }
00834         <font class="keywordflow">if</font> (ver &gt;= 2)
00835         {
00836                 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_3">_FaceGrid</a>);
00837         }
00838         <font class="keywordflow">if</font> (ver &gt;= 3)
00839         {
00840                 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_4">_Id</a>);
00841         }
00842 }
00843 
00844 
00845 
00846 
00847 
00848 
00849 
00850 
<a name="l00851"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a0">00851</a> <font class="keywordtype">bool</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a0">NLPACS::CLocalRetriever::insurePosition</a>(<a class="code" href="classNLPACS_1_1ULocalPosition.html">NLPACS::ULocalPosition</a> &amp;local)<font class="keyword"> const</font>
00852 <font class="keyword"></font>{
00853         <font class="keywordflow">if</font> (local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a> &lt; 0 || local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a> &gt;= (sint)<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size())
00854         {
00855                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"PACS: can't insure position to inexistant surface %d"</font>, local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>);
00856                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00857         }
00858 
00859         <font class="comment">// the surface</font>
00860         <font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CRetrievableSurface.html">NLPACS::CRetrievableSurface</a>       &amp;surface = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>];
00861 
00862         uint            i, j, k;
00863         CVector2f       M = CVector2f(local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>);
00864         <font class="keywordtype">bool</font>            moved = <font class="keyword">false</font>;
00865 
00866         <font class="comment">// for each chain and each subchain of the surface,</font>
00867         <font class="comment">// check if point is located on the good side of the border (and far enough to avoid accuracy issues)</font>
00868         <font class="keywordflow">for</font> (i=0; i&lt;surface.<a class="code" href="classNLPACS_1_1CRetrievableSurface.html#a12">getChains</a>().size(); ++i)
00869         {
00870                 uint                                    ichain = surface.<a class="code" href="classNLPACS_1_1CRetrievableSurface.html#a13">getChain</a>(i).Chain;
00871                 <font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CChain.html">NLPACS::CChain</a>    &amp;chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[ichain];
00872 
00873                 for (j=0; j&lt;chain.getSubChains().size(); ++j)
00874                 {
00875                         uint                                            iochain = chain.getSubChain(j);
00876                         <font class="keyword">const</font> <a class="code" href="classNLPACS_1_1COrderedChain.html">NLPACS::COrderedChain</a>     &amp;ochain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[iochain];
00877 
00878                         uint                                            isAtLeft = ((chain.getLeft() == local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>) ? 1 : 0);
00879                         uint                                            isForward = (ochain.<a class="code" href="classNLPACS_1_1COrderedChain.html#a1">isForward</a>() ? 1 : 0);
00880                         <font class="keywordtype">bool</font>                                            shouldBeUpper = !((isAtLeft ^ isForward) != 0); <font class="comment">// shouldBeAtLeft for vertical segment</font>
00881 
00882                         <font class="keywordflow">for</font> (k=0; (sint)k&lt;(sint)(ochain.<a class="code" href="classNLPACS_1_1COrderedChain.html#a0">getVertices</a>().size()-1); ++k)
00883                         {
00884                                 CVector2f       A = ochain[k].unpack();
00885                                 CVector2f       B = ochain[k+1].unpack();
00886                                 CVector2f       AB = B-A;
00887 
00888                                 <font class="keywordtype">float</font>           lambda = ((M-A)*AB)/AB.sqrnorm();
00889 
00890                                 <font class="keywordflow">if</font> (lambda&lt;0.0f || lambda&gt;1.0f)
00891                                         <font class="keywordflow">continue</font>;
00892 
00893                                 CVector2f       n = (shouldBeUpper ? CVector2f(-AB.y, AB.x) : CVector2f(AB.y, -AB.x)).normed();
00894                                 <font class="keywordtype">float</font>           d = (M-A)*n;
00895 
00896                                 <font class="comment">// if point is too close of the border or on the wrong side</font>
00897                                 <font class="comment">// move it far enough</font>
00898                                 <font class="keywordflow">if</font> (d &lt; InsurePositionThreshold &amp;&amp; d &gt; -<a class="code" href="local__retriever_8cpp.html#a0">InsurePositionThreshold</a>)
00899                                 {
00900                                         M += (<a class="code" href="local__retriever_8cpp.html#a0">InsurePositionThreshold</a>*1.1f-d)*n;
00901                                         moved = <font class="keyword">true</font>;
00902                                 }
00903                         }
00904                 }
00905         }
00906 
00907         <a class="code" href="classNLPACS_1_1CRetrieverInstance.html#z955_0">NLPACS::CRetrieverInstance::snapVector</a>(M);
00908 
00909         local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = M.x;
00910         local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = M.y;
00911 
00912         {
00913                 <font class="keywordtype">float</font>   fx1024 = local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * 1024.0f;
00914                 <font class="keywordtype">float</font>   fy1024 = local.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * 1024.0f;
00915                 sint32  ix1024 = (sint32)floor(fx1024);
00916                 sint32  iy1024 = (sint32)floor(fy1024);
00917 
00918                 <a class="code" href="debug_8h.html#a6">nlassert</a> ((<font class="keywordtype">float</font>)ix1024 == fx1024);
00919                 <a class="code" href="debug_8h.html#a6">nlassert</a> ((<font class="keywordtype">float</font>)iy1024 == fy1024);
00920         }
00921 
00922         <font class="keywordflow">return</font> moved;
00923 }
00924 
00925 
<a name="l00926"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a1">00926</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a1">NLPACS::CLocalRetriever::retrievePosition</a>(CVector estimated, <font class="comment">/*std::vector&lt;uint8&gt; &amp;retrieveTable,*/</font> CCollisionSurfaceTemp &amp;cst)<font class="keyword"> const</font>
00927 <font class="keyword"></font>{
00928         CAABBox                 box;
00929         <font class="keyword">const</font> <font class="keywordtype">double</font>    BorderThreshold = 2.0e-2f;
00930         box.setMinMax(CVector(estimated.x-(<font class="keywordtype">float</font>)BorderThreshold, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n4">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z264_0">getMin</a>().y, 0.0f), CVector(estimated.x+(<font class="keywordtype">float</font>)BorderThreshold, <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n4">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z264_1">getMax</a>().y, 0.0f));
00931         uint                    numEdges = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n8">_ChainQuad</a>.selectEdges(box, cst);
00932 
00933         uint                    ochain, i;
00934         CVector2s               estim = CVector2s(estimated);
00935 
00936         cst.PossibleSurfaces.clear();
00937 
00938         <font class="comment">// WARNING!!</font>
00939         <font class="comment">// cst.SurfaceLUT is assumed to be 0 filled !!</font>
00940 
00941 <font class="comment">//      nldebug("estim=(%d,%d)", estim.x, estim.y);</font>
00942 
00943         <font class="comment">// for each ordered chain, checks if the estimated position is between the min and max.</font>
00944         <font class="keywordflow">for</font> (i=0; i&lt;numEdges; ++i)
00945         {
00946                 ochain = cst.EdgeChainEntries[i].OChainId;
00947 
00948                 <font class="keyword">const</font> COrderedChain     &amp;sub = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[ochain];
00949                 <font class="keyword">const</font> CVector2s &amp;<a class="code" href="bit__set_8cpp.html#a0">min</a> = sub.getMin(),
00950                                                 &amp;max = sub.getMax();
00951 
00952                 <font class="comment">// checks the position against the min and max of the chain</font>
00953                 <font class="keywordflow">if</font> (estim.x &lt; <a class="code" href="bit__set_8cpp.html#a0">min</a>.x || estim.x &gt; max.x)
00954                         <font class="keywordflow">continue</font>;
00955 
00956                 <font class="keywordtype">bool</font>    isUpper;
00957                 <font class="keywordtype">bool</font>    isOnBorder = <font class="keyword">false</font>;
00958 
00959                 sint32  left = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[sub.getParentId()].getLeft(),
00960                                 right = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[sub.getParentId()].getRight();
00961 
00962                 <font class="keywordflow">if</font> (estim.y &lt; <a class="code" href="bit__set_8cpp.html#a0">min</a>.y)
00963                 {
00964                         <font class="keywordflow">if</font> (estim.x == max.x)
00965                                 <font class="keywordflow">continue</font>;
00966                         isUpper = <font class="keyword">false</font>;
00967 <font class="comment">//                      nlinfo("Box: min(%d,%d) max(%d,%d) forward=%d left=%d right=%d upper=false", min.x, min.y, max.x, max.y, sub.isForward(), left, right);</font>
00968                 }
00969                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (estim.y &gt; max.y)
00970                 {
00971                         <font class="keywordflow">if</font> (estim.x == max.x)
00972                                 <font class="keywordflow">continue</font>;
00973                         isUpper = <font class="keyword">true</font>;
00974 <font class="comment">//                      nlinfo("Box: min(%d,%d) max(%d,%d) forward=%d left=%d right=%d upper=true", min.x, min.y, max.x, max.y, sub.isForward(), left, right);</font>
00975                 }
00976                 <font class="keywordflow">else</font>
00977                 {
00978                         <font class="keyword">const</font> vector&lt;CVector2s&gt; &amp;vertices = sub.getVertices();
00979                         uint                                    start = 0, stop = vertices.size()-1;
00980 
00982 
00983                         <font class="comment">// then finds the smallest segment of the chain that includes the estimated position.</font>
00984                         <font class="keywordflow">while</font> (stop-start &gt; 1)
00985                         {
00986                                 uint    mid = (start+stop)/2;
00987 
00988                                 <font class="keywordflow">if</font> (vertices[mid].x &gt; estim.x)
00989                                         stop = mid;
00990                                 <font class="keywordflow">else</font>
00991                                         start = mid;
00992                         }
00993 
00994                         <font class="comment">// if a vertical edge</font>
00995                         <font class="keywordflow">if</font> (vertices[start].x == vertices[stop].x)
00996                         {
00997                                 <font class="comment">// look for maximal bounds</font>
00998                                 <font class="keywordflow">while</font> (start &gt; 0 &amp;&amp; vertices[start].x == vertices[start-1].x)
00999                                         --start;
01000 
01001                                 <font class="keywordflow">while</font> (stop &lt; vertices.size()-1 &amp;&amp; vertices[stop].x == vertices[stop+1].x)
01002                                         ++stop;
01003 
01004                                 <font class="comment">// if upper or lower the bounds, do nothing</font>
01005                                 <font class="keywordflow">if</font> (estim.y &gt; vertices[start].y &amp;&amp; estim.y &gt; vertices[stop].y ||
01006                                         estim.y &lt; vertices[start].y &amp;&amp; estim.y &lt; vertices[stop].y)
01007                                         <font class="keywordflow">continue</font>;
01008 
01009                                 isOnBorder = <font class="keyword">true</font>;
01010                                 cst.incSurface(left);
01011                                 cst.incSurface(right);
01012                                 <font class="keywordflow">if</font> (left &gt;= 0)  cst.SurfaceLUT[left].FoundCloseEdge = <font class="keyword">true</font>;
01013                                 <font class="keywordflow">if</font> (right &gt;= 0) cst.SurfaceLUT[right].FoundCloseEdge = <font class="keyword">true</font>;
01014                                 <font class="keywordflow">continue</font>;
01015 <font class="comment">//                              nlinfo("Edge: start(%d,%d) stop(%d,%d) forward=%d left=%d right=%d border=true", vertices[start].x, vertices[start].y, vertices[stop].x, vertices[stop].y, sub.isForward(), left, right);</font>
01016                         }
01017                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (vertices[stop].x == estim.x)
01018                         {
01019                                 <font class="comment">// if </font>
01020                                 <font class="keywordflow">continue</font>;
01021                         }
01022 
01023                         <font class="comment">// and then checks if the estimated position is up or down the chain.</font>
01024 
01025                         <font class="comment">// first trivial case (up both tips)</font>
01026                         <font class="keywordflow">if</font> (estim.y &gt; vertices[start].y &amp;&amp; estim.y &gt; vertices[stop].y)
01027                         {
01028                                 isUpper = <font class="keyword">true</font>;
01029 <font class="comment">//                              nlinfo("Edge: start(%d,%d) stop(%d,%d) forward=%d left=%d right=%d upper=true", vertices[start].x, vertices[start].y, vertices[stop].x, vertices[stop].y, sub.isForward(), left, right);</font>
01030                         }
01031                         <font class="comment">// second trivial case (down both tips)</font>
01032                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (estim.y &lt; vertices[start].y &amp;&amp; estim.y &lt; vertices[stop].y)
01033                         {
01034                                 isUpper = <font class="keyword">false</font>;
01035 <font class="comment">//                              nlinfo("Edge: start(%d,%d) stop(%d,%d) forward=%d left=%d right=%d upper=false", vertices[start].x, vertices[start].y, vertices[stop].x, vertices[stop].y, sub.isForward(), left, right);</font>
01036                         }
01037                         <font class="comment">// full test...</font>
01038                         <font class="keywordflow">else</font>
01039                         {
01040                                 <font class="keyword">const</font> CVector2s &amp;vstart = vertices[start],
01041                                                                 &amp;vstop = vertices[stop];
01042 
01043                                 sint16                  intersect = vstart.y + (vstop.y-vstart.y)*(estim.x-vstart.x)/(vstop.x-vstart.x);
01044 
01045                                 isUpper = estim.y &gt; intersect;
01046                                 isOnBorder = (fabs(estim.y - intersect)&lt;BorderThreshold*<a class="code" href="namespaceNLPACS.html#a14">Vector2sAccuracy</a>);
01047 <font class="comment">//                              nlinfo("Edge: start(%d,%d) stop(%d,%d) forward=%d left=%d right=%d upper=%s border=%s", vertices[start].x, vertices[start].y, vertices[stop].x, vertices[stop].y, sub.isForward(), left, right, isUpper ? "true":"false", isOnBorder ? "true":"false");</font>
01048                         }
01049                 }
01050 
01051                 <font class="keywordflow">if</font> (isOnBorder)
01052                 {
01053                         cst.incSurface(left);
01054                         cst.incSurface(right);
01055                         <font class="keywordflow">if</font> (left &gt;= 0)  cst.SurfaceLUT[left].FoundCloseEdge = <font class="keyword">true</font>;
01056                         <font class="keywordflow">if</font> (right &gt;= 0) cst.SurfaceLUT[right].FoundCloseEdge = <font class="keyword">true</font>;
01057                         <font class="keywordflow">continue</font>;
01058                 }
01059 
01060                 <font class="comment">// Depending on the chain is forward, up the position, increase/decrease the surface table...</font>
01061                 <font class="keywordflow">if</font> (sub.isForward())
01062                 {
01063                         <font class="keywordflow">if</font> (isUpper)
01064                         {
01065                                 cst.incSurface(left);
01066                                 cst.decSurface(right);
01067                         }
01068                         <font class="keywordflow">else</font>
01069                         {
01070                                 cst.decSurface(left);
01071                                 cst.incSurface(right);
01072                         }
01073                 }
01074                 <font class="keywordflow">else</font>
01075                 {
01076                         <font class="keywordflow">if</font> (isUpper)
01077                         {
01078                                 cst.decSurface(left);
01079                                 cst.incSurface(right);
01080                         }
01081                         <font class="keywordflow">else</font>
01082                         {
01083                                 cst.incSurface(left);
01084                                 cst.decSurface(right);
01085                         }
01086                 }
01087         }
01088 }
01089 
01090 
<a name="l01091"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_9">01091</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z945_9">NLPACS::CLocalRetriever::initFaceGrid</a>()
01092 {
01093         CFaceGrid::CFaceGridBuild       fgb;
01094         fgb.init(64, 4.0f);
01095 
01096         uint    i;
01097         <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_2">_InteriorFaces</a>.size(); ++i)
01098         {
01099                 CAABBox                 box;
01100                 CInteriorFace   &amp;f = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_2">_InteriorFaces</a>[i];
01101                 box.setCenter(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[0]]);
01102                 box.extend(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[1]]);
01103                 box.extend(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[2]]);
01104 
01105                 fgb.insert(box.getMin(), box.getMax(), i);
01106         }
01107 
01108         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_3">_FaceGrid</a>.create(fgb);
01109 }
01110 
<a name="l01111"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a2">01111</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a2">NLPACS::CLocalRetriever::snapToInteriorGround</a>(<a class="code" href="classNLPACS_1_1ULocalPosition.html">NLPACS::ULocalPosition</a> &amp;position, <font class="keywordtype">bool</font> &amp;snapped)<font class="keyword"> const</font>
01112 <font class="keyword"></font>{
01113         <font class="comment">// first preselect faces around the (x, y) position (CQuadGrid ?)</font>
01114         vector&lt;uint32&gt;  selection;
01115         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_3">_FaceGrid</a>.select(position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>, selection);
01116 
01117         <font class="comment">// from the preselect faces, look for the only face that belongs to the surface</font>
01118         <font class="comment">// and that contains the position</font>
01119         CVector                                         pos = position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>;
01120         CVector                                         posh = pos+CVector(0.0f, 0.0f, 1.0f);
01121         CVector2f                                       pos2d = position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>;
01122         <font class="keywordtype">float</font>                                           bestDist = 1.0e10f;
01123         CVector                                         best;
01124         vector&lt;uint32&gt;::iterator        it;
01125         snapped = <font class="keyword">false</font>;
01126         <font class="keywordflow">for</font> (it=selection.begin(); it!=selection.end(); ++it)
01127         {
01128                 <font class="keyword">const</font> CInteriorFace     &amp;f = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_2">_InteriorFaces</a>[*it];
01129                 <font class="keywordflow">if</font> (f.Surface == (uint32)position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>)
01130                 {
01131                         CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[3];
01132                         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0] = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[0]];
01133                         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1] = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[1]];
01134                         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2] = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[2]];
01135 
01136                         CVector2f       n;
01137                         <font class="keywordtype">float</font>           c;                      <font class="comment">// 2D cartesian coefficients of line in plane X/Y.</font>
01138                         <font class="comment">// Line p0-p1.</font>
01139                         n = CVector2f(-(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>), (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)).normed();
01140                         c = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].x*n.x + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].y*n.y);
01141                         <font class="keywordflow">if</font> (n*pos2d + c &lt; -1.0f/<a class="code" href="namespaceNLPACS.html#a14">Vector2sAccuracy</a>)       <font class="keywordflow">continue</font>;
01142                         <font class="comment">// Line p1-p2.</font>
01143                         n = CVector2f(-(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>), (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)).normed();
01144                         c = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].x*n.x + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].y*n.y);
01145                         <font class="keywordflow">if</font> (n*pos2d + c &lt; -1.0f/<a class="code" href="namespaceNLPACS.html#a14">Vector2sAccuracy</a>)       <font class="keywordflow">continue</font>;
01146                         <font class="comment">//  Line p2-p0.</font>
01147                         n = CVector2f(-(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>), (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)).normed();
01148                         c = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].x*n.x + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].y*n.y);
01149                         <font class="keywordflow">if</font> (n*pos2d + c &lt; -1.0f/<a class="code" href="namespaceNLPACS.html#a14">Vector2sAccuracy</a>)       <font class="keywordflow">continue</font>;
01150 
01151                         CPlane  p;
01152                         p.make(<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]);
01153 
01154                         CVector i = p.intersect(pos, posh);
01155 
01156                         <font class="keywordtype">float</font>   d = (float)fabs(pos.z-i.z);
01157 
01158                         <font class="keywordflow">if</font> (d &lt; bestDist)
01159                         {
01160                                 bestDist = d;
01161                                 best = i;
01162                         }
01163                 }
01164         }
01165 
01166         <font class="comment">// and computes the real position on this face</font>
01167         <font class="keywordflow">if</font> (bestDist &lt; 50.0f)
01168         {
01169                 snapped = <font class="keyword">true</font>;
01170                 position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a> = best;
01171         }
01172 }
01173 
<a name="l01174"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#a3">01174</a> <font class="keywordtype">float</font>   <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a3">NLPACS::CLocalRetriever::getHeight</a>(<font class="keyword">const</font> <a class="code" href="classNLPACS_1_1ULocalPosition.html">NLPACS::ULocalPosition</a> &amp;position)<font class="keyword"> const</font>
01175 <font class="keyword"></font>{
01176         <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n9">_Type</a> == <a class="code" href="classNLPACS_1_1CLocalRetriever.html#s2s1">Interior</a>)
01177         {
01178                 <font class="comment">// first preselect faces around the (x, y) position (CQuadGrid ?)</font>
01179                 vector&lt;uint32&gt;  selection;
01180                 <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_3">_FaceGrid</a>.select(position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>, selection);
01181 
01182                 <font class="comment">// from the preselect faces, look for the only face that belongs to the surface</font>
01183                 <font class="comment">// and that contains the position</font>
01184                 CVector pos = position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>;
01185                 CVector posh = pos+CVector(0.0f, 0.0f, 1.0f);
01186                 <font class="keywordtype">float</font>   bestDist = 1.0e10f;
01187                 CVector best;
01188                 vector&lt;uint32&gt;::iterator        it;
01189                 <font class="keywordflow">for</font> (it=selection.begin(); it!=selection.end(); ++it)
01190                 {
01191                         <font class="keyword">const</font> CInteriorFace     &amp;f = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_2">_InteriorFaces</a>[*it];
01192                         <font class="keywordflow">if</font> (f.Surface == (uint32)position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>)
01193                         {
01194                                 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[3];
01195                                 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0] = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[0]];
01196                                 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1] = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[1]];
01197                                 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2] = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[f.Verts[2]];
01198 
01199                                 <font class="keywordtype">float</font>           a,b,c;          <font class="comment">// 2D cartesian coefficients of line in plane X/Y.</font>
01200                                 <font class="comment">// Line p0-p1.</font>
01201                                 a = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].y-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].y);
01202                                 b =  (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].x-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].x);
01203                                 c = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].x*a + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].y*b);
01204                                 <font class="keywordflow">if</font> (a*pos.x + b*pos.y + c &lt; 0)  <font class="keywordflow">continue</font>;
01205                                 <font class="comment">// Line p1-p2.</font>
01206                                 a = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].y-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].y);
01207                                 b =  (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].x-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].x);
01208                                 c = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].x*a + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1].y*b);
01209                                 <font class="keywordflow">if</font> (a*pos.x + b*pos.y + c &lt; 0)  <font class="keywordflow">continue</font>;
01210                                 <font class="comment">//  Line p2-p0.</font>
01211                                 a = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].y-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].y);
01212                                 b =  (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0].x-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].x);
01213                                 c = -(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].x*a + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2].y*b);
01214                                 <font class="keywordflow">if</font> (a*pos.x + b*pos.y + c &lt; 0)  <font class="keywordflow">continue</font>;
01215 
01216                                 CPlane  p;
01217                                 p.make(<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]);
01218 
01219                                 CVector i = p.intersect(pos, posh);
01220 
01221                                 <font class="keywordtype">float</font>   d = (float)fabs(pos.z-i.z);
01222 
01223                                 <font class="keywordflow">if</font> (d &lt; bestDist)
01224                                 {
01225                                         bestDist = d;
01226                                         best = i;
01227                                 }
01228                         }
01229                 }
01230 
01231                 <font class="comment">// and computes the real position on this face</font>
01232                 <font class="keywordflow">return</font> (bestDist &lt; 50.0f) ?     best.z : position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>;
01233         }
01234         <font class="keywordflow">else</font>
01235         {
01236 
01237                 <font class="comment">// find quad leaf.</font>
01238                 <font class="keyword">const</font> CQuadLeaf *leaf = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>].getQuadTree().getLeaf(position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>);
01239 
01240                 <font class="comment">// if there is no acceptable leaf, just give up</font>
01241                 <font class="keywordflow">if</font> (leaf == NULL)
01242                 {
01243                         <font class="comment">//nlinfo("COL: quadtree: don't find the quadLeaf!");</font>
01244                         <font class="keywordflow">return</font> position.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>;
01245                 }
01246                 <font class="keywordflow">else</font>
01247                 {
01248                         <font class="comment">// else return mean height.</font>
01249                         <font class="keywordtype">float</font>   meanHeight = (leaf-&gt;getMinHeight()+leaf-&gt;getMaxHeight())*0.5f;
01250                         <font class="keywordflow">return</font> meanHeight;
01251                 }
01252 
01253 <font class="comment">//              return _Surfaces[position.Surface].getQuadTree().getInterpZ(position.Estimation);</font>
01254         }
01255 }
01256 
01257 
01258 
01259 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
01260 <font class="preprocessor"></font><font class="preprocessor">#pragma optimize( "", off )</font>
01261 <font class="preprocessor"></font><font class="preprocessor">#endif // NL_OS_WINDOWS</font>
01262 <font class="preprocessor"></font>
01263 <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#a4">NLPACS::CLocalRetriever::findPath</a>(<font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CLocalPosition.html">NLPACS::CLocalRetriever::CLocalPosition</a> &amp;A, 
01264                                                                                   <font class="keyword">const</font> <a class="code" href="classNLPACS_1_1CLocalRetriever_1_1CLocalPosition.html">NLPACS::CLocalRetriever::CLocalPosition</a> &amp;B, 
01265                                                                                   std::vector&lt;NLPACS::CVector2s&gt; &amp;path, 
01266                                                                                   <a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html">NLPACS::CCollisionSurfaceTemp</a> &amp;cst)<font class="keyword"> const</font>
01267 <font class="keyword"></font>{
01268         <font class="keywordflow">if</font> (A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a> != B.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>)
01269         {
01270                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::findPath()"</font>);
01271                 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Try to find a path between 2 points that are not in the same surface (A=%d, B=%d)"</font>, A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>, B.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>);
01272         }
01273 
01274         CVector         a = A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>,
01275                                 b = B.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>,
01276                                 n = CVector(a.y-b.y, b.x-a.x, 0.0f);
01277 
01278         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n8">_ChainQuad</a>.selectEdges(a, b, cst);
01279 
01281         vector&lt;CIntersectionMarker&gt;     intersections;
01282 
01283         uint    i, j;
01284         sint32  surfaceId = A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m0">Surface</a>;
01285         <font class="keyword">const</font> CRetrievableSurface       &amp;surface = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>[surfaceId];
01286 
01287         <font class="keywordflow">for</font> (i=0; i&lt;cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m1">EdgeChainEntries</a>.size(); ++i)
01288         {
01289                 CEdgeChainEntry         &amp;entry = cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m1">EdgeChainEntries</a>[i];
01290                 <font class="keyword">const</font> COrderedChain     &amp;chain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[entry.OChainId];
01291 
01292                 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain.getParentId()].getLeft() != surfaceId &amp;&amp;
01293                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain.getParentId()].getRight() != surfaceId)
01294                         <font class="keywordflow">continue</font>;
01295 
01296                 <font class="keywordflow">for</font> (j=entry.EdgeStart; j&lt;entry.EdgeEnd; ++j)
01297                 {
01298                         <font class="comment">// here the edge collision test</font>
01299 
01300                         CVector p0 = chain[j].unpack3f(),
01301                                         p1 = chain[j+1].unpack3f();
01302 
01303                         <font class="keywordtype">float</font>   vp0 = (p0-a)*n,
01304                                         vp1 = (p1-a)*n;
01305 
01306                         <font class="keywordflow">if</font> (vp0*vp1 &lt;= 0.0f)
01307                         {
01308                                 CVector np = CVector(p0.y-p1.y, p1.x-p0.x, 0.0f);
01309 
01310                                 <font class="keywordtype">float</font>   va = (a-p0)*np,
01311                                                 vb = (b-p0)*np;
01312 
01313                                 <font class="comment">// here we have an intersection</font>
01314                                 <font class="keywordflow">if</font> (va*vb &lt;= 0.0f)
01315                                 {
01316                                         <font class="keyword">const</font> CChain    &amp;parent = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[chain.getParentId()];
01317                                         <font class="keywordtype">bool</font>                    isIn = (va-vb &lt; 0.0f) ^ (parent.getLeft() == surfaceId) ^ chain.isForward();
01318 
01319                                         intersections.push_back(CIntersectionMarker(va/(va-vb), entry.OChainId, j, isIn));
01320                                 }
01321                         }
01322                 }
01323         }
01324 
01325         sort(intersections.begin(), intersections.end());
01326 
01327         uint    intersStart = 0;
01328         uint    intersEnd = intersections.size();
01329 
01330         <font class="keywordflow">if</font> (intersEnd &gt; 0)
01331         {
01332                 <font class="keywordflow">while</font> (intersStart &lt; intersections.size() &amp;&amp;
01333                            intersections[intersStart].In &amp;&amp; intersections[intersStart].Position &lt; 1.0e-4f)
01334                         ++intersStart;
01335 
01336                 <font class="keywordflow">while</font> (intersStart &lt; intersEnd &amp;&amp;
01337                            !intersections[intersEnd-1].In &amp;&amp; intersections[intersEnd-1].Position &gt; 1.0f-1.0e-4f)
01338                         --intersEnd;
01339 
01340                 <font class="comment">// Check intersections have a valid order</font>
01341                 <font class="keywordflow">if</font> ((intersEnd-intersStart) &amp; 1)
01342                 {
01343                         <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::findPath()"</font>);
01344                         <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Found an odd (%d) number of intersections"</font>, intersections.size());
01345                 }
01346                 
01347                 <font class="keywordflow">for</font> (i=intersStart; i&lt;intersEnd; )
01348                 {
01349                         uint    exitLoop, enterLoop;
01350 
01351                         <font class="keyword">const</font> CChain    &amp;exitChain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[intersections[i].OChain].getParentId()];
01352                         exitLoop = (exitChain.getLeft() == surfaceId) ? exitChain.getLeftLoop() : exitChain.getRightLoop();
01353 
01354                         <font class="keywordflow">if</font> (intersections[i++].In)
01355                         {
01356                                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::findPath()"</font>);
01357                                 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Entered the surface before exited"</font>, intersections.size());
01358                         }
01359 
01360                         <font class="keyword">const</font> CChain    &amp;enterChain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[intersections[i].OChain].getParentId()];
01361                         enterLoop = (enterChain.getLeft() == surfaceId) ? enterChain.getLeftLoop() : enterChain.getRightLoop();
01362 
01363                         <font class="keywordflow">if</font> (!intersections[i++].In)
01364                         {
01365                                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::findPath()"</font>);
01366                                 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Exited twice the surface"</font>, intersections.size());
01367                         }
01368 
01369                         <font class="keywordflow">if</font> (exitLoop != enterLoop)
01370                         {
01371                                 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"in NLPACS::CLocalRetriever::findPath()"</font>);
01372                                 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Exited and rentered by a different loop"</font>);
01373                         }
01374                 }
01375         }
01376 
01377 <font class="comment">//      dumpSurface(surfaceId);</font>
01378 
01379         path.push_back(CVector2s(A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>));
01380 
01381         <font class="keywordflow">for</font> (i=intersStart; i&lt;intersEnd; )
01382         {
01383                 uint                                                            exitChainId = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[intersections[i].OChain].getParentId(),
01384                                                                                         enterChainId = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[intersections[i+1].OChain].getParentId();
01385                 <font class="keyword">const</font> CChain                                            &amp;exitChain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[exitChainId],
01386                                                                                         &amp;enterChain = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[enterChainId];
01387                 uint                                                            loopId, exitLoopIndex, enterLoopIndex;
01388 
01389                 <font class="keywordflow">if</font> (exitChain.getLeft() == surfaceId)
01390                 {
01391                         loopId = exitChain.getLeftLoop();
01392                         exitLoopIndex = exitChain.getLeftLoopIndex();
01393                 }
01394                 <font class="keywordflow">else</font>
01395                 {
01396                         loopId = exitChain.getRightLoop();
01397                         exitLoopIndex = exitChain.getRightLoopIndex();
01398                 }
01399 
01400                 <font class="keyword">const</font> CRetrievableSurface::TLoop        &amp;loop = surface._Loops[loopId];
01401 
01402                 <font class="keywordflow">if</font> (enterChain.getLeft() == surfaceId)
01403                         enterLoopIndex = enterChain.getLeftLoopIndex();
01404                 <font class="keywordflow">else</font>
01405                         enterLoopIndex = enterChain.getRightLoopIndex();
01406 
01407                 <font class="keywordtype">float</font>                   forwardLength = (exitChain.getLength()+enterChain.getLength())*0.5f;
01408 
01409                 sint    loopIndex = exitLoopIndex;
01410                 uint    thisChainId = exitChainId;
01411                 <font class="keywordtype">bool</font>    thisChainForward = (enterChain.getLeft() == surfaceId);
01412                 uint    thisOChainId = intersections[i].OChain;
01413                 sint    thisOChainIndex = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[thisOChainId].getIndexInParent();
01414                 <font class="keywordtype">bool</font>    forward;
01415 
01416                 <font class="keywordflow">if</font> (exitChainId != enterChainId)
01417                 {
01418                         <font class="keywordflow">for</font> (j=(exitLoopIndex+1)%loop.size(); j!=enterLoopIndex; j=(j+1)%loop.size())
01419                                 forwardLength += <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[surface._Chains[loop[j]].Chain].getLength();
01420                         forward = (forwardLength &lt;= loop.Length-forwardLength);
01421                 }
01422                 <font class="keywordflow">else</font>
01423                 {
01424                         forward = !thisChainForward ^ (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[intersections[i].OChain].getIndexInParent() &lt; <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[intersections[i+1].OChain].getIndexInParent());
01425                 }
01426 
01427                 path.push_back(CVector2s(A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>+intersections[i].Position*(B.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>-A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>)));
01428 
01429                 <font class="keywordflow">while</font> (true)
01430                 {
01431                         sint    from = (thisOChainId == intersections[i].OChain) ? intersections[i].Edge : -1,
01432                                         to = (thisOChainId == intersections[i+1].OChain) ? intersections[i+1].Edge : -1;
01433                         <font class="keywordtype">bool</font>    oforward = thisChainForward ^ forward ^ <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[thisOChainId].isForward();
01434 
01435                         <font class="keywordflow">if</font> (from != -1 &amp;&amp; to != -1)
01436                                 oforward = (intersections[i].Edge &lt; intersections[i+1].Edge);
01437 
01438                         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>[thisOChainId].traverse(from, to, oforward, path);
01439 
01440                         <font class="keywordflow">if</font> (thisOChainId == intersections[i+1].OChain)
01441                                 <font class="keywordflow">break</font>;
01442 
01443                         thisOChainIndex = (thisChainForward ^ forward) ? thisOChainIndex-1 : thisOChainIndex+1;
01444 
01445                         <font class="keywordflow">if</font> (thisOChainIndex &lt; 0 || thisOChainIndex &gt;= (sint)<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[thisChainId]._SubChains.size())
01446                         {
01447                                 <font class="keywordflow">if</font> (forward)
01448                                 {
01449                                         loopIndex++;
01450                                         <font class="keywordflow">if</font> (loopIndex == (sint)loop.size())
01451                                                 loopIndex = 0;
01452                                 }
01453                                 <font class="keywordflow">else</font>
01454                                 {
01455                                         loopIndex--;
01456                                         <font class="keywordflow">if</font> (loopIndex &lt; 0)
01457                                                 loopIndex = loop.size()-1;
01458                                 }
01459 
01460                                 thisChainId = surface._Chains[loop[loopIndex]].Chain;
01461                                 thisChainForward = (<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[thisChainId].getLeft() == surfaceId);
01462                                 thisOChainIndex = (thisChainForward &amp;&amp; forward || !thisChainForward &amp;&amp; !forward) ? 
01463                                         0 : <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[thisChainId]._SubChains.size()-1;
01464                         }
01465 
01466                         thisOChainId = <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n2">_Chains</a>[thisChainId]._SubChains[thisOChainIndex];
01467                 }
01468 
01469                 path.push_back(CVector2s(A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>+intersections[i+1].Position*(B.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>-A.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>)));
01470                 i += 2;
01471         }
01472 
01473         path.push_back(CVector2s(B.<a class="code" href="classNLPACS_1_1ULocalPosition.html#m1">Estimation</a>));
01474 }
01475 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
01476 <font class="preprocessor"></font><font class="preprocessor">#pragma optimize( "", on ) </font>
01477 <font class="preprocessor"></font><font class="preprocessor">#endif // NL_OS_WINDOWS</font>
01478 <font class="preprocessor"></font>
01479 <font class="comment">// ***************************************************************************</font>
01480 <font class="comment">// ***************************************************************************</font>
01481 <font class="comment">// Collisions part.</font>
01482 <font class="comment">// ***************************************************************************</font>
01483 <font class="comment">// ***************************************************************************</font>
01484 
01485 
01486 <font class="comment">// ***************************************************************************</font>
<a name="l01487"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z946_0">01487</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z946_0">NLPACS::CLocalRetriever::computeCollisionChainQuad</a>()
01488 {
01489         <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n8">_ChainQuad</a>.build(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n0">_OrderedChains</a>);
01490 }
01491 
01492 
01493 <font class="comment">// ***************************************************************************</font>
<a name="l01494"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z946_1">01494</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z946_1">NLPACS::CLocalRetriever::testCollision</a>(CCollisionSurfaceTemp &amp;cst, <font class="keyword">const</font> CAABBox &amp;bboxMove, <font class="keyword">const</font> CVector2f &amp;transBase)<font class="keyword"> const</font>
01495 <font class="keyword"></font>{
01496 <font class="comment">//      H_AUTO(PACS_LR_testCollision);</font>
01497 
01498         sint    i;
01499 
01500         <font class="comment">// 0. select ordered chains in the chainquad.</font>
01501         <font class="comment">//=====================================</font>
01502 <font class="comment">//      H_BEFORE(PACS_LR_testCol_selEdges);</font>
01503         sint    nEce= <a class="code" href="classNLPACS_1_1CLocalRetriever.html#n8">_ChainQuad</a>.selectEdges(bboxMove, cst);
01504 <font class="comment">//      H_AFTER(PACS_LR_testCol_selEdges);</font>
01505         <font class="comment">// NB: cst.OChainLUT is assured to be full of 0xFFFF after this call (if was right before).</font>
01506 
01507 
01508         <font class="comment">// 1. regroup them in chains. build cst.CollisionChains</font>
01509         <font class="comment">//=====================================</font>
01510         <font class="comment">// NB: use cst.OChainLUT to look if a Chain has been inserted before.</font>
01511         uint16  *chainLUT= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m0">OChainLUT</a>;
01512 
01513         <font class="comment">// bkup where we begin to add chains.</font>
01514         uint    firstChainAdded= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>.size();
01515 
01516         <font class="comment">// For all edgechain entry.</font>
01517         <font class="keywordflow">for</font>(i=0;i&lt;nEce;i++)
01518         {
01519                 CEdgeChainEntry         &amp;ece= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m1">EdgeChainEntries</a>[i];
01520                 <font class="comment">// this is the ordered chain in the retriever.</font>
01521                 <font class="keyword">const</font>   COrderedChain   &amp;oChain= this-&gt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z944_2">getOrderedChains</a>()[ece.OChainId];
01522                 <font class="comment">// this is the id of the chain is the local retriever.</font>
01523                 uint16                          chainId= oChain.getParentId();
01524 
01525 
01526                 <font class="comment">// add/retrieve the id in cst.CollisionChains.</font>
01527                 <font class="comment">//=================================</font>
01528                 uint                            ccId;
01529                 <font class="comment">// if never added.</font>
01530                 <font class="keywordflow">if</font>(chainLUT[chainId]==0xFFFF)
01531                 {
01532 <font class="comment">//                      H_AUTO(PACS_LR_testCol_addToLUT);</font>
01533                         <font class="comment">// add a new CCollisionChain.</font>
01534                         ccId= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>.size();
01535                         cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>.push_back(CCollisionChain());
01536                         <font class="comment">// Fill it with default.</font>
01537                         cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[ccId].Tested= <font class="keyword">false</font>;
01538                         cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[ccId].ExteriorEdge = <font class="keyword">false</font>;
01539                         cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[ccId].FirstEdgeCollide= 0xFFFFFFFF;
01540                         cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[ccId].ChainId= chainId;
01541                         <font class="comment">// Fill Left right info.</font>
01542                         cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[ccId].LeftSurface.SurfaceId= this-&gt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z944_6">getChains</a>()[chainId].getLeft();
01543                         cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[ccId].RightSurface.SurfaceId= this-&gt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z944_6">getChains</a>()[chainId].getRight();
01544                         <font class="comment">// NB: cst.CollisionChains[ccId].*Surface.RetrieverInstanceId is not filled here because we don't have</font>
01545                         <font class="comment">// this info at this level.</font>
01546 
01547                         <font class="comment">// store this Id in the LUT of chains.</font>
01548                         chainLUT[chainId]= ccId;
01549                 }
01550                 <font class="keywordflow">else</font>
01551                 {
01552                         <font class="comment">// get the id of this collision chain.</font>
01553                         ccId= chainLUT[chainId];
01554                 }
01555 
01556                 <font class="comment">// add edge collide to the list.</font>
01557                 <font class="comment">//=================================</font>
01558 <font class="comment">//              H_BEFORE(PACS_LR_testCol_addToList);</font>
01559                 CCollisionChain                 &amp;colChain= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[ccId];
01560                 <font class="keyword">const</font> std::vector&lt;CVector2s&gt;    &amp;oChainVertices= oChain.getVertices();
01561                 <font class="keywordflow">for</font>(sint edge=ece.EdgeStart; edge&lt;ece.EdgeEnd; edge++)
01562                 {
01563                         CVector2f       p0= oChainVertices[edge].unpack();
01564                         CVector2f       p1= oChainVertices[edge+1].unpack();
01565 
01566                         <font class="comment">// alloc a new edgeCollide.</font>
01567                         uint32  ecnId= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#z930_1">allocEdgeCollideNode</a>();
01568                         CEdgeCollideNode        &amp;ecn= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#z930_2">getEdgeCollideNode</a>(ecnId);
01569 
01570                         <font class="comment">// append to the front of the list.</font>
01571                         ecn.Next= colChain.FirstEdgeCollide;
01572                         colChain.FirstEdgeCollide= ecnId;
01573 
01574                         <font class="comment">// build this edge.</font>
01575                         p0+= transBase;
01576                         p1+= transBase;
01577                         ecn.make(p0, p1);
01578                 }
01579 <font class="comment">//              H_AFTER(PACS_LR_testCol_addToList);</font>
01580         }
01581 
01582 
01583 
01584         <font class="comment">// 2. Reset LUT to 0xFFFF.</font>
01585         <font class="comment">//=====================================</font>
01586 
01587 <font class="comment">//      H_BEFORE(PACS_LR_testCol_resetLUT);</font>
01588         <font class="comment">// for all collisions chains inserted (starting from firstChainAdded), reset LUT.</font>
01589         <font class="keywordflow">for</font>(i=firstChainAdded; i&lt;(sint)cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>.size(); i++)
01590         {
01591                 uint    ccId= cst.<a class="code" href="classNLPACS_1_1CCollisionSurfaceTemp.html#m7">CollisionChains</a>[i].ChainId;
01592                 chainLUT[ccId]= 0xFFFF;
01593         }
01594 <font class="comment">//      H_AFTER(PACS_LR_testCol_resetLUT);</font>
01595 }
01596 
01597 
01598 <font class="comment">// ***************************************************************************</font>
01599 <font class="comment">// ***************************************************************************</font>
01600 <font class="comment">// ***************************************************************************</font>
01601 <font class="comment">// ***************************************************************************</font>
01602 
01603 
01604 <font class="comment">// ***************************************************************************</font>
<a name="l01605"></a><a class="code" href="classNLPACS_1_1CLocalRetriever.html#z944_18">01605</a> <font class="keywordtype">void</font>    <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z944_18">NLPACS::CLocalRetriever::buildInteriorSurfaceBBoxes</a>(std::vector&lt;NLMISC::CAABBox&gt;        &amp;surfaceBBoxes)<font class="keyword"> const</font>
01606 <font class="keyword"></font>{
01607         <font class="comment">// resize dest, and init.</font>
01608         vector&lt;bool&gt;    firstTriangle;
01609         surfaceBBoxes.clear();
01610         surfaceBBoxes.resize(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size());
01611         firstTriangle.resize(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size(), <font class="keyword">true</font>);
01612 
01613         <font class="comment">// For all _InteriorFaces.</font>
01614         <font class="keywordflow">for</font>(uint iIntFace=0; iIntFace&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_2">_InteriorFaces</a>.size(); iIntFace++)
01615         {
01616                 <font class="keyword">const</font> CInteriorFace     &amp;intFace= <a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_2">_InteriorFaces</a>[iIntFace];
01617 
01618                 <font class="comment">// Extend the surface of this face with her 3 points.</font>
01619 
01620                 <font class="comment">// check good id.</font>
01621                 <font class="keywordflow">if</font>(intFace.Surface==(uint)-1)
01622                         <font class="keywordflow">continue</font>;
01623                 <a class="code" href="debug_8h.html#a6">nlassert</a>(intFace.Surface&lt;<a class="code" href="classNLPACS_1_1CLocalRetriever.html#n3">_Surfaces</a>.size());
01624 
01625                 <font class="comment">// If first time we extend the bbox of this surface</font>
01626                 <font class="keywordflow">if</font>(firstTriangle[intFace.Surface])
01627                 {
01628                         surfaceBBoxes[intFace.Surface].setCenter(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[intFace.Verts[0]] );
01629                         firstTriangle[intFace.Surface]= <font class="keyword">false</font>;
01630                 }
01631                 <font class="keywordflow">else</font>
01632                         surfaceBBoxes[intFace.Surface].extend(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[intFace.Verts[0]] );
01633 
01634                 <font class="comment">// extend with other 2 points</font>
01635                 surfaceBBoxes[intFace.Surface].extend(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[intFace.Verts[1]] );
01636                 surfaceBBoxes[intFace.Surface].extend(<a class="code" href="classNLPACS_1_1CLocalRetriever.html#z942_1">_InteriorVertices</a>[intFace.Verts[2]] );
01637         }
01638 
01639 }
</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>