aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a03101.html
blob: ad9605cc8b34060f33fe9c7bdbb6429feaedeaae (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
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: NLMISC::CPolygon2D class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NLMISC::CPolygon2D Class Reference</h1><code>#include &lt;<a class="el" href="a06191.html">polygon.h</a>&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A 2d convex polygon 
<p>

<p>
Definition at line <a class="el" href="a06191.html#l00122">122</a> of file <a class="el" href="a06191.html">polygon.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::pair&lt; <a class="el" href="a04558.html#a14">sint</a>, <a class="el" href="a04558.html#a14">sint</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw0">TRaster</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::vector&lt; <a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw0">TRaster</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">TRasterVect</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::vector&lt; <a class="el" href="a03660.html">CVector2f</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw2">TVec2fVect</a></td></tr>

<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da0">buildConvexHull</a> (<a class="el" href="a03101.html">CPolygon2D</a> &amp;dest) const </td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da1">computeBorders</a> (<a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">TRasterVect</a> &amp;borders, <a class="el" href="a04558.html#a14">sint</a> &amp;minimumY)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da2">computeInnerBorders</a> (<a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">TRasterVect</a> &amp;borders, <a class="el" href="a04558.html#a14">sint</a> &amp;minimumY)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da3">computeOuterBorders</a> (<a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">TRasterVect</a> &amp;borders, <a class="el" href="a04558.html#a14">sint</a> &amp;minimumY)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da4">contains</a> (const <a class="el" href="a03660.html">CVector2f</a> &amp;p) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Check wether a point is contained by this poly.  <a href="#NLMISC_1_1CPolygon2Da4"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da5">CPolygon2D</a> (const <a class="el" href="a03616.html">CTriangle</a> &amp;tri, const <a class="el" href="a02851.html">CMatrix</a> &amp;projMat=<a class="el" href="a02851.html#NLMISC_1_1CMatrixs0">CMatrix::Identity</a>)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da6">CPolygon2D</a> (const <a class="el" href="a03100.html">CPolygon</a> &amp;<a class="el" href="a04223.html#a652">src</a>, const <a class="el" href="a02851.html">CMatrix</a> &amp;projMat=<a class="el" href="a02851.html#NLMISC_1_1CMatrixs0">CMatrix::Identity</a>)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da7">CPolygon2D</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">default ctor  <a href="#NLMISC_1_1CPolygon2Da7"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da8">getBestTriplet</a> (<a class="el" href="a04558.html#a15">uint</a> &amp;index0, <a class="el" href="a04558.html#a15">uint</a> &amp;index1, <a class="el" href="a04558.html#a15">uint</a> &amp;index2)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">get the best triplet of vector. e.g the triplet that has the best surface  <a href="#NLMISC_1_1CPolygon2Da8"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da9">getLineEquation</a> (<a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a566">index</a>, float &amp;a, float &amp;b, float &amp;c) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get a line equation of the seg starting at the given index.  <a href="#NLMISC_1_1CPolygon2Da9"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da10">getNonNullSeg</a> (<a class="el" href="a04558.html#a15">uint</a> &amp;seg) const </td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da11">intersect</a> (const <a class="el" href="a03101.html">CPolygon2D</a> &amp;other) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Test wether this polygon intersect another convex polygon. Currently not optimized.  <a href="#NLMISC_1_1CPolygon2Da11"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da12">isConvex</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Check wether this polygon is convex;.  <a href="#NLMISC_1_1CPolygon2Da12"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da13">serial</a> (<a class="el" href="a02270.html">NLMISC::IStream</a> &amp;f)  throw (NLMISC::EStream)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Serial this polygon.  <a href="#NLMISC_1_1CPolygon2Da13"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Da14">swap</a> (<a class="el" href="a03101.html">CPolygon2D</a> &amp;other)</td></tr>

<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw2">TVec2fVect</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a></td></tr>

<tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03660.html">CVector2f</a> &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dd0">getSegRef0</a> (<a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a566">index</a>) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get ref to the first vertex that start at index.  <a href="#NLMISC_1_1CPolygon2Dd0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03660.html">CVector2f</a> &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dd1">getSegRef1</a> (<a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a566">index</a>) const </td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>float&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dd2">sumDPAgainstLine</a> (float a, float b, float c) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sum the dot product of this poly vertices against a plane.  <a href="#NLMISC_1_1CPolygon2Dd2"></a><br><br></td></tr>
</table>
<hr><h2>Member Typedef Documentation</h2>
<a class="anchor" name="NLMISC_1_1CPolygon2Dw0" doxytag="NLMISC::CPolygon2D::TRaster" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> typedef std::pair&lt;<a class="el" href="a04558.html#a14">sint</a>, <a class="el" href="a04558.html#a14">sint</a>&gt; <a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw0">NLMISC::CPolygon2D::TRaster</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06191.html#l00159">159</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
Referenced by <a class="el" href="a06768.html#l00444">RenderTriangle()</a>, <a class="el" href="a06190.html#l01517">NLMISC::ScanInnerEdge()</a>, <a class="el" href="a06190.html#l01288">NLMISC::ScanOuterEdgeLeft()</a>, and <a class="el" href="a06190.html#l01232">NLMISC::ScanOuterEdgeRight()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Dw1" doxytag="NLMISC::CPolygon2D::TRasterVect" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> typedef std::vector&lt;<a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw0">TRaster</a>&gt; <a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">NLMISC::CPolygon2D::TRasterVect</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06191.html#l00160">160</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
Referenced by <a class="el" href="a05937.html#l00066">NL3D::CLodCharacterShapeBuild::compile()</a>, <a class="el" href="a06190.html#l01075">computeBorders()</a>, <a class="el" href="a06190.html#l01618">computeInnerBorders()</a>, <a class="el" href="a06190.html#l01344">computeOuterBorders()</a>, <a class="el" href="a06768.html#l00444">RenderTriangle()</a>, <a class="el" href="a06768.html#l00633">NL3D::CRenderZBuffer::run()</a>, <a class="el" href="a06190.html#l01003">NLMISC::ScanEdge()</a>, and <a class="el" href="a06737.html#l00437">NL3D::CWaterModel::traverseRender()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Dw2" doxytag="NLMISC::CPolygon2D::TVec2fVect" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> typedef std::vector&lt;<a class="el" href="a03660.html">CVector2f</a>&gt; <a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw2">NLMISC::CPolygon2D::TVec2fVect</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06191.html#l00125">125</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
Referenced by <a class="el" href="a06190.html#l01075">computeBorders()</a>, <a class="el" href="a06190.html#l01057">NLMISC::Next()</a>, and <a class="el" href="a06190.html#l01067">NLMISC::Prev()</a>.    </td>
  </tr>
</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="NLMISC_1_1CPolygon2Da7" doxytag="NLMISC::CPolygon2D::CPolygon2D" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> NLMISC::CPolygon2D::CPolygon2D </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
default ctor 
<p>

<p>
Definition at line <a class="el" href="a06191.html#l00129">129</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
<div class="fragment"><pre>00129 {}
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da6" doxytag="NLMISC::CPolygon2D::CPolygon2D" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> NLMISC::CPolygon2D::CPolygon2D </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03100.html">CPolygon</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>src</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a02851.html">CMatrix</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>projMat</em> = <a class="el" href="a02851.html#NLMISC_1_1CMatrixs0">CMatrix::Identity</a></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Build a 2D polygon from this 3D polygon, by using the given projection matrix The x and y components of projected vertices are used to create the 2D polygon
<p>
Definition at line <a class="el" href="a06190.html#l00785">785</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05646.html#l00645">size</a>, <a class="el" href="a05646.html#l01124">src</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06673.html#l00051">NLMISC::CVector::x</a>, and <a class="el" href="a06673.html#l00051">NLMISC::CVector::y</a>.
<p>
<div class="fragment"><pre>00786 {
00787         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a587">size</a> = <a class="code" href="a04223.html#a652">src</a>.Vertices.size();
00788         <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.resize(size);
00789         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k &lt; <a class="code" href="a04223.html#a587">size</a>; ++k)
00790         {
00791                 CVector proj = projMat * <a class="code" href="a04223.html#a652">src</a>.Vertices[k];
00792                 <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[k].set(proj.x, proj.y);
00793         }
00794 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da5" doxytag="NLMISC::CPolygon2D::CPolygon2D" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> NLMISC::CPolygon2D::CPolygon2D </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03616.html">CTriangle</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>tri</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a02851.html">CMatrix</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>projMat</em> = <a class="el" href="a02851.html#NLMISC_1_1CMatrixs0">CMatrix::Identity</a></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Build a 2D polygon from the given triangle, by using the given projection matrix The x and y components of projected vertices are used to create the 2D polygon
<p>
Definition at line <a class="el" href="a06190.html#l01928">1928</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06585.html#l00051">NLMISC::CTriangle::V0</a>, <a class="el" href="a06585.html#l00051">NLMISC::CTriangle::V1</a>, <a class="el" href="a06585.html#l00051">NLMISC::CTriangle::V2</a>, <a class="el" href="a05646.html#l00236">x</a>, and <a class="el" href="a05646.html#l00236">y</a>.
<p>
<div class="fragment"><pre>01929 {
01930         <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.resize(3);
01931         <a class="code" href="a03128.html">NLMISC::CVector</a> proj[3] = { projMat * tri.<a class="code" href="a03616.html#NLMISC_1_1CTriangleUVo3">V0</a>, projMat * tri.<a class="code" href="a03616.html#NLMISC_1_1CTriangleUVo4">V1</a>, projMat * tri.<a class="code" href="a03616.html#NLMISC_1_1CTriangleUVo5">V2</a> };
01932         <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[0].set(proj[0].<a class="code" href="a04223.html#a572">x</a>, proj[0].<a class="code" href="a04223.html#a573">y</a>);
01933         <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[1].set(proj[1].<a class="code" href="a04223.html#a572">x</a>, proj[1].<a class="code" href="a04223.html#a573">y</a>);
01934         <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[2].set(proj[2].<a class="code" href="a04223.html#a572">x</a>, proj[2].<a class="code" href="a04223.html#a573">y</a>);
01935 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NLMISC_1_1CPolygon2Da0" doxytag="NLMISC::CPolygon2D::buildConvexHull" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::buildConvexHull </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a03101.html">CPolygon2D</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>dest</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const</td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Build a convex hull from this polygon. The result poly is ordered, so it can also be used to order a convex poly given its set of vertices. NB: require this != &amp;dest
<p>
Definition at line <a class="el" href="a06190.html#l00836">836</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06191.html#l00126">Vertices</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
<div class="fragment"><pre>00837 {
00838         <a class="code" href="a04199.html#a6">nlassert</a>(&amp;dest != <span class="keyword">this</span>);
00839 
00840         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size() == 3) <span class="comment">// with 3 points it is always convex</span>
00841         {
00842                 dest = *<span class="keyword">this</span>;
00843                 <span class="keywordflow">return</span>;
00844         }
00845         <a class="code" href="a04558.html#a15">uint</a> k, <a class="code" href="a05373.html#a2">l</a>;
00846         <a class="code" href="a04558.html#a15">uint</a> numVerts = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size();        
00847         CVector2f p, curr, prev;
00848         <a class="code" href="a04558.html#a15">uint</a>      pIndex, p1Index, p2Index, pCurr, pPrev;
00849         <span class="comment">// this is not optimized, but not used in realtime.. =)</span>
00850         <a class="code" href="a04199.html#a6">nlassert</a>(numVerts &gt;= 3);
00851         dest.Vertices.clear();
00852 
00853         <span class="keyword">typedef</span> std::set&lt;uint&gt; TIndexSet;
00854         TIndexSet leftIndex;
00855         <span class="keywordflow">for</span> (k = 0; k &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size(); ++k)
00856         {
00857                 leftIndex.insert(k);
00858         }
00859         
00860 
00861         <span class="comment">// 1) find the highest point p of the set. We are sure it belongs to the hull</span>
00862         pIndex = 0;
00863         p = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[0];
00864         <span class="keywordflow">for</span> (k = 1; k &lt; numVerts; ++k)
00865         {
00866                 <span class="keywordflow">if</span> (Vertices[k].y &lt; p.y)
00867                 {
00868                         pIndex = k;
00869                         p = Vertices[k];
00870                 }
00871         }
00872 
00873         leftIndex.erase(pIndex);
00874 
00875 
00876         <span class="keywordtype">float</span> bestCP = 1.1f;
00877         p1Index = p2Index = pIndex;
00878 
00879         <span class="keywordflow">for</span> (k = 0; k &lt; numVerts; ++k)
00880         {
00881                 <span class="keywordflow">if</span> (k != pIndex)
00882                 {
00883                         <span class="keywordflow">for</span> (<a class="code" href="a05373.html#a2">l</a> = 0; <a class="code" href="a05373.html#a2">l</a> &lt; numVerts; ++<a class="code" href="a05373.html#a2">l</a>)
00884                         {
00885                                 <span class="keywordflow">if</span> (<a class="code" href="a05373.html#a2">l</a> != pIndex &amp;&amp; <a class="code" href="a05373.html#a2">l</a> != k)
00886                                 {
00887                                         CVector2f seg1 = (Vertices[<a class="code" href="a05373.html#a2">l</a>] - p).normed();
00888                                         CVector2f seg2 = (Vertices[k] - p).normed();
00889 
00890                                         <span class="comment">//CVector cp = CVector(seg1.x, seg1.y, 0) ^ CVector(seg2.x, seg2.y, 0);</span>
00891                                         <span class="comment">//float n = fabsf(cp.z);</span>
00892                                         <span class="keywordtype">float</span> n = seg1 * seg2;
00893                                         <span class="keywordflow">if</span> (n &lt; bestCP)
00894                                         {
00895                                                 p1Index = <a class="code" href="a05373.html#a2">l</a>;
00896                                                 p2Index = k;
00897                                                 bestCP  = n;
00898                                         }
00899                                 }
00900                         }
00901                 }
00902         }
00903 
00904 
00905         leftIndex.erase(p2Index);
00906 
00907         
00908 
00909         <span class="comment">// start from the given triplet, and complete the poly until we reach the first point</span>
00910         pCurr = p2Index;
00911         pPrev = pIndex;
00912 
00913         curr = Vertices[pCurr];
00914         prev = Vertices[pPrev];
00915 
00916         <span class="comment">// create the first triplet vertices</span>
00917         dest.Vertices.push_back(Vertices[p1Index]);
00918         dest.Vertices.push_back(prev);
00919         dest.Vertices.push_back(curr); 
00920 
00921         <a class="code" href="a04558.html#a15">uint</a> step = 0;
00922 
00923         <span class="keywordflow">for</span>(;;)
00924         {               
00925                 bestCP = 1.1f;          
00926                 CVector2f seg2 = (prev - curr).normed();
00927                 TIndexSet::const_iterator bestIt = leftIndex.end();
00928                 <span class="keywordflow">for</span> (TIndexSet::const_iterator it =  leftIndex.begin(); it != leftIndex.end(); ++it)
00929                 {       
00930                         <span class="keywordflow">if</span> (step == 0 &amp;&amp; *it == p1Index) <span class="keywordflow">continue</span>;
00931                         CVector2f seg1 = (Vertices[*it] - curr).normed();                                                       
00932                         <span class="keywordtype">float</span> n = seg1 * seg2;
00933                         <span class="keywordflow">if</span> (n &lt; bestCP)
00934                         {                               
00935                                 bestCP = n;
00936                                 bestIt = it;                            
00937                         }                       
00938                 }
00939 
00940                 <a class="code" href="a04199.html#a6">nlassert</a>(bestIt != leftIndex.end());            
00941                 <span class="keywordflow">if</span> (*bestIt == p1Index)
00942                 {                       
00943                         <span class="keywordflow">return</span>; <span class="comment">// if we reach the start point we have finished</span>
00944                 }                               
00945                 prev = curr;
00946                 curr = Vertices[*bestIt];
00947                 pPrev = pCurr;
00948                 pCurr = *bestIt;
00949                 <span class="comment">// add new point to the destination</span>
00950                 dest.Vertices.push_back(curr);
00951                 ++step;
00952                 leftIndex.erase(bestIt);
00953         }
00954 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da1" doxytag="NLMISC::CPolygon2D::computeBorders" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::computeBorders </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">TRasterVect</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>borders</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a14">sint</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>minimumY</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Compute the borders of this poly with sub-pixel accuracy. No clipping is performed. Only points exactly inside or exactly on the left border of the polygon are kept. This means that pixels are seen as points, not as surfaces. The output is in a vector of sint pairs. minimumY is filled with the minimum y value of the poly. Each pairs gives [xmin, xmax] for the current segment. if xmin &gt; xmax, then no point is valid for this segment. Otherwise, all points from x = xmin (included) to x = xmax (included) are valids.
<p>
Definition at line <a class="el" href="a06190.html#l01075">1075</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l01057">NLMISC::Next()</a>, <a class="el" href="a06190.html#l01067">NLMISC::Prev()</a>, <a class="el" href="a06190.html#l01003">NLMISC::ScanEdge()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a06191.html#l00160">TRasterVect</a>, <a class="el" href="a06191.html#l00125">TVec2fVect</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a05937.html#l00066">NL3D::CLodCharacterShapeBuild::compile()</a>, <a class="el" href="a06768.html#l00444">RenderTriangle()</a>, and <a class="el" href="a06737.html#l00437">NL3D::CWaterModel::traverseRender()</a>.
<p>
<div class="fragment"><pre>01076 {
01077         <span class="comment">// an 'alias' to the vertices</span>
01078         <span class="keyword">const</span> <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dw2">TVec2fVect</a> &amp;V = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>;
01079         <span class="keywordflow">if</span> (Vertices.size() &lt; 3)
01080         {
01081                 borders.clear();
01082                 <span class="keywordflow">return</span>;
01083         }
01084         <span class="keywordtype">bool</span>    ccw;  <span class="comment">// set to true when it has a counter clock wise orientation</span>
01085                    
01086         <span class="comment">// compute highest and lowest pos of the poly</span>
01087         <span class="keywordtype">float</span> fHighest = V[0].y;
01088         <span class="keywordtype">float</span> fLowest  = fHighest;
01089 
01090         <span class="comment">// iterators to the thighest and lowest vertex</span>
01091         TVec2fVect::const_iterator pLowest = V.begin(), pHighest = V.begin();
01092         TVec2fVect::const_iterator it = V.begin() ;
01093         <span class="keyword">const</span> TVec2fVect::const_iterator endIt = V.end();
01094         <span class="keywordflow">do</span>
01095         {
01096                 <span class="keywordflow">if</span> (it-&gt;y &gt; fLowest)
01097                 {
01098                         fLowest = it-&gt;y;
01099                         pLowest = it;
01100                 }
01101                 <span class="keywordflow">else</span>
01102                 <span class="keywordflow">if</span> (it-&gt;y &lt; fHighest)
01103                 {
01104                         fHighest = it-&gt;y;
01105                         pHighest = it;
01106                 }
01107                 ++it;
01108         }
01109         <span class="keywordflow">while</span> (it != endIt);
01110         
01111 
01112         <a class="code" href="a04558.html#a14">sint</a> iHighest = (<a class="code" href="a04558.html#a14">sint</a>) ceilf(fHighest) ;
01113         <a class="code" href="a04558.html#a14">sint</a> iLowest  = (<a class="code" href="a04558.html#a14">sint</a>) ceilf(fLowest) ;
01114 
01115         highestY = iHighest;
01116 
01117 
01119         <a class="code" href="a04558.html#a15">uint</a> polyHeight = iLowest - iHighest;
01120         <span class="keywordflow">if</span> (polyHeight &lt;= 0)
01121         {
01122                 borders.clear();
01123                 <span class="keywordflow">return</span>;
01124         }
01125 
01126         borders.resize(polyHeight);
01127 
01128         <span class="comment">// iterator to the first vertex that has an y different from the top vertex</span>
01129         TVec2fVect::const_iterator pHighestRight = pHighest; 
01130         <span class="comment">// we seek this vertex  </span>
01131         <span class="keywordflow">while</span> (<a class="code" href="a05378.html#a346">Next</a>(pHighestRight, V)-&gt;y == fHighest)
01132         {
01133                 pHighestRight = <a class="code" href="a05378.html#a346">Next</a>(pHighestRight, V);
01134         }       
01135 
01136         <span class="comment">// iterator to the first vertex after pHighestRight, that has the same y than the highest vertex</span>
01137         TVec2fVect::const_iterator pHighestLeft = <a class="code" href="a05378.html#a346">Next</a>(pHighestRight, V);
01138         <span class="comment">// seek the vertex</span>
01139         <span class="keywordflow">while</span> (pHighestLeft-&gt;y != fHighest)
01140         {
01141                 pHighestLeft = <a class="code" href="a05378.html#a346">Next</a>(pHighestLeft, V);
01142         }
01143 
01144         TVec2fVect::const_iterator pPrevHighestLeft = <a class="code" href="a05378.html#a347">Prev</a>(pHighestLeft, V);
01145   
01146         <span class="comment">// we need to get the orientation of the polygon</span>
01147         <span class="comment">// There are 2 case : flat, and non-flat top</span>
01148 
01149         <span class="comment">// check for flat top</span>
01150         <span class="keywordflow">if</span> (pHighestLeft-&gt;x != pHighestRight-&gt;x)
01151         {
01152                 <span class="comment">// compare right and left side</span>
01153                 <span class="keywordflow">if</span> (pHighestLeft-&gt;x &gt; pHighestRight-&gt;x)
01154                 {
01155                         ccw = <span class="keyword">true</span>;  <span class="comment">// the list is CCW oriented</span>
01156                         std::swap(pHighestLeft, pHighestRight);         
01157                 }
01158                 <span class="keywordflow">else</span>
01159                 {
01160                         ccw = <span class="keyword">false</span>; <span class="comment">// the list is CW oriented </span>
01161                 }
01162         }
01163         <span class="keywordflow">else</span>
01164         {
01165                 <span class="comment">// The top of the poly is sharp</span>
01166                 <span class="comment">// We perform a cross product of the 2 highest vect to get its orientation</span>
01167 
01168                  <span class="keyword">const</span> <span class="keywordtype">float</span> deltaXN = <a class="code" href="a05378.html#a346">Next</a>(pHighestRight, V)-&gt;x - pHighestRight-&gt;x;
01169                  <span class="keyword">const</span> <span class="keywordtype">float</span> deltaYN = <a class="code" href="a05378.html#a346">Next</a>(pHighestRight, V)-&gt;y - pHighestRight-&gt;y;
01170                  <span class="keyword">const</span> <span class="keywordtype">float</span> deltaXP = pPrevHighestLeft-&gt;x - pHighestLeft-&gt;x;
01171                  <span class="keyword">const</span> <span class="keywordtype">float</span> deltaYP = pPrevHighestLeft-&gt;y - pHighestLeft-&gt;y;
01172                  <span class="keywordflow">if</span> ((deltaXN * deltaYP - deltaYN * deltaXP) &lt; 0)
01173                  {
01174                         ccw = <span class="keyword">true</span>;  <span class="comment">// the list is CCW oriented</span>
01175                         std::swap(pHighestLeft, pHighestRight);                            
01176                  }
01177                  <span class="keywordflow">else</span>
01178                  {
01179                         ccw = <span class="keyword">false</span>; <span class="comment">// the list is CW oriented</span>
01180                  }
01181         }
01182 
01183 
01184         <span class="comment">// compute borders</span>
01185         TVec2fVect::const_iterator currV, nextV; <span class="comment">// current and next vertex</span>
01186         <span class="keywordflow">if</span> (!ccw) <span class="comment">// clock wise order ?</span>
01187         {
01188                 currV = pHighestRight ;
01189                 <span class="comment">// compute right edge from top to bottom</span>
01190                 <span class="keywordflow">do</span>
01191                 {
01192                         nextV = <a class="code" href="a05378.html#a346">Next</a>(currV, V);
01193                         <a class="code" href="a05378.html#a345">ScanEdge</a>(borders, iHighest, *currV, *nextV, <span class="keyword">true</span>);
01194             currV = nextV;            
01195                 }
01196                 <span class="keywordflow">while</span> (currV != pLowest); <span class="comment">// repeat until we reach the bottom vertex</span>
01197 
01198                 <span class="comment">// compute left edge from bottom to top</span>
01199                 <span class="keywordflow">do</span>
01200                 {
01201                         nextV = <a class="code" href="a05378.html#a346">Next</a>(currV, V);
01202                         <a class="code" href="a05378.html#a345">ScanEdge</a>(borders, iHighest, *nextV, *currV, <span class="keyword">false</span>);
01203                         currV = nextV;
01204                 }
01205                 <span class="keywordflow">while</span> (currV != pHighestLeft);
01206         }
01207         <span class="keywordflow">else</span> <span class="comment">// ccw order</span>
01208         {        
01209                 currV = pHighestLeft;
01210                 <span class="comment">// compute left edge from top to bottom</span>
01211                 <span class="keywordflow">do</span>
01212                 {
01213                         nextV = <a class="code" href="a05378.html#a346">Next</a>(currV, V);
01214                         <a class="code" href="a05378.html#a345">ScanEdge</a>(borders, iHighest, *currV, *nextV, <span class="keyword">false</span>) ;
01215                         currV = nextV;
01216                 }
01217                 <span class="keywordflow">while</span> (currV != pLowest) ;
01218 
01219                 <span class="comment">// compute right edge from bottom to top</span>
01220                 <span class="keywordflow">do</span>
01221                 {
01222                         nextV = <a class="code" href="a05378.html#a346">Next</a>(currV, V);
01223                         <a class="code" href="a05378.html#a345">ScanEdge</a>(borders, iHighest, *nextV, *currV, <span class="keyword">true</span>);
01224                         currV = nextV;
01225                 }
01226                 <span class="keywordflow">while</span> (currV != pHighestRight)  ;
01227         }
01228 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da2" doxytag="NLMISC::CPolygon2D::computeInnerBorders" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::computeInnerBorders </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">TRasterVect</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>borders</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a14">sint</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>minimumY</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
The same as compute borders, but pixel are seen as surfaces and not as points In this version, only pixels that are entirely INSIDE the poly are kept
<p>
Definition at line <a class="el" href="a06190.html#l01618">1618</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05484.html#l00038">min</a>, <a class="el" href="a06190.html#l01517">NLMISC::ScanInnerEdge()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a06191.html#l00160">TRasterVect</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
<div class="fragment"><pre>01619 {
01620         <span class="keywordflow">if</span> (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.empty())
01621         {
01622                 borders.clear();
01623                 minimumY = -1;
01624                 <span class="keywordflow">return</span>;
01625         }
01626         <span class="keyword">const</span> CVector2f *first = &amp;<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[0];
01627         <span class="keyword">const</span> CVector2f *last  = first + Vertices.size();
01628 
01629         <span class="keyword">const</span> CVector2f *curr = first, *next, *plowest ,*phighest;
01630         <span class="keyword">const</span> CVector2f *pHighestRight, *pHighestRightNext, *pHighestLeft;
01631         <span class="keyword">const</span> CVector2f *pPrevHighestLeft;
01632         <span class="keywordtype">double</span>              deltaXN, deltaYN, deltaXP, deltaYP;
01633         <span class="keywordtype">bool</span>                ccw;  <span class="comment">// true if CCW oriented</span>
01634         <a class="code" href="a04558.html#a14">sint</a>            polyHeight;
01635         <a class="code" href="a04558.html#a14">sint</a>            highest, lowest;                                           
01636         
01637         <span class="keywordtype">float</span> fright   = curr-&gt;x;
01638         <span class="keywordtype">float</span> fleft    = curr-&gt;x;
01639         <span class="keywordtype">float</span> fhighest = curr-&gt;y;
01640         <span class="keywordtype">float</span> flowest  = curr-&gt;y;
01641         plowest = phighest = curr;
01642 
01643         <span class="comment">// compute highest (with lowest y) and lowest (with highest y) points of the poly</span>
01644         <span class="keywordflow">do</span>
01645         {               
01646                 fright = std::max(fright, curr-&gt;x);
01647                 fleft  = <a class="code" href="a04061.html#a0">std::min</a>(fleft, curr-&gt;x);
01648                 <span class="keywordflow">if</span> (curr-&gt;y &gt; flowest)
01649                 {
01650                         flowest = curr-&gt;y;
01651                         plowest = curr;
01652                 }
01653                 <span class="keywordflow">if</span> (curr-&gt;y &lt; fhighest)
01654                 {
01655                         fhighest = curr-&gt;y;
01656                         phighest = curr;
01657                 }
01658                 ++curr;
01659         }
01660         <span class="keywordflow">while</span> (curr != last);
01661 
01662                 
01663         highest = (<a class="code" href="a04558.html#a14">sint</a>) floorf(fhighest);
01664         lowest = (<a class="code" href="a04558.html#a14">sint</a>) ceilf(flowest);
01665 
01666         polyHeight = lowest - highest;
01667         <span class="keywordflow">if</span> (polyHeight == 0) <span class="keywordflow">return</span>;
01668 
01669         <span class="comment">// make room for rasters</span>
01670         borders.resize(polyHeight);
01671         <span class="comment">// fill with xmin / xman</span>
01672         <a class="code" href="a04558.html#a14">sint</a> ileft = (<a class="code" href="a04558.html#a14">sint</a>) floorf(fleft) - 1;
01673         <a class="code" href="a04558.html#a14">sint</a> iright = (<a class="code" href="a04558.html#a14">sint</a>) ceilf(fright);
01674         <span class="keywordflow">for</span>(TRasterVect::iterator it = borders.begin(); it != borders.end(); ++it)
01675         {
01676                 it-&gt;second = iright;
01677                 it-&gt;first = ileft;
01678         }
01679 
01680         minimumY = highest;
01681         pHighestRight = phighest;
01682         <span class="keywordflow">for</span> (;;)
01683         {       
01684                 pHighestRightNext  = pHighestRight + 1;
01685                 <span class="keywordflow">if</span> (pHighestRightNext == last) pHighestRightNext = first;
01686                 <span class="keywordflow">if</span> (pHighestRightNext-&gt;y != pHighestRight-&gt;y) <span class="keywordflow">break</span>;
01687                 pHighestRight = pHighestRightNext;
01688         }       
01689 
01690         pPrevHighestLeft = pHighestRight;
01691         pHighestLeft = pHighestRight;
01692         ++pHighestLeft;
01693         <span class="keywordflow">if</span> (pHighestLeft == last) pHighestLeft = first;
01694         
01695         <span class="keywordflow">while</span> (pHighestLeft-&gt;y != fhighest)
01696         {
01697                 pPrevHighestLeft = pHighestLeft;
01698                 ++pHighestLeft;
01699                 <span class="keywordflow">if</span> (pHighestLeft == last) pHighestLeft = first;
01700         }
01701         
01702 
01703         <span class="comment">// we need to get the orientation of the polygon</span>
01704         <span class="comment">// There are 2 case : flat, and non-flat top</span>
01705         
01706         <span class="comment">// check for flat top</span>
01707         <span class="keywordflow">if</span> (pHighestLeft-&gt;x != pHighestRight-&gt;x)
01708         {
01709                 <span class="comment">// compare right and left side</span>
01710                 <span class="keywordflow">if</span> (pHighestLeft-&gt;x &gt; pHighestRight-&gt;x)
01711                 {
01712                         ccw = <span class="keyword">true</span>;  <span class="comment">// the list is CCW oriented</span>
01713                         std::swap(pHighestLeft, pHighestRight);         
01714                 }
01715                 <span class="keywordflow">else</span>
01716                 {
01717                         ccw = <span class="keyword">false</span>; <span class="comment">// the list is CW oriented</span>
01718                 }
01719         }
01720         <span class="keywordflow">else</span>
01721         {               
01722                 pHighestRightNext = pHighestRight + 1;
01723                 <span class="keywordflow">if</span> (pHighestRightNext == last) pHighestRightNext = first;
01724                  deltaXN = pHighestRightNext-&gt;x - pHighestRight-&gt;x;
01725                  deltaYN = pHighestRightNext-&gt;y - pHighestRight-&gt;y;
01726                  deltaXP = pPrevHighestLeft-&gt;x - pHighestLeft-&gt;x;
01727                  deltaYP = pPrevHighestLeft-&gt;y - pHighestLeft-&gt;y;
01728                  <span class="keywordflow">if</span> ((deltaXN * deltaYP - deltaYN * deltaXP) &lt; 0)
01729                  {
01730                         ccw = <span class="keyword">true</span>;
01731                         std::swap(pHighestLeft, pHighestRight);                            
01732                  }
01733                  <span class="keywordflow">else</span>
01734                  {
01735                         ccw = <span class="keyword">false</span>;
01736                  }
01737         }
01738         
01739         <span class="keywordflow">if</span> (!ccw)
01740         {               
01741                 <span class="comment">// cw oriented</span>
01742                 curr = pHighestRight;           
01743                 <span class="keywordflow">do</span>
01744                 {
01745                         next = curr + 1;
01746                         <span class="keywordflow">if</span> (next == last) next = first;
01747                         <a class="code" href="a05378.html#a350">ScanInnerEdge</a>(&amp;borders[0], curr-&gt;x, curr-&gt;y, next-&gt;x, next-&gt;y, minimumY, <span class="keyword">true</span>); 
01748                         curr = next;                    
01749                 }
01750                 <span class="keywordflow">while</span> (curr != plowest);                
01751                 <span class="keywordflow">do</span>
01752                 {
01753                         next = curr + 1;
01754                         <span class="keywordflow">if</span> (next == last) next = first;
01755                         <a class="code" href="a05378.html#a350">ScanInnerEdge</a>(&amp;borders[0], next-&gt;x, next-&gt;y, curr-&gt;x, curr-&gt;y, minimumY, <span class="keyword">false</span>);
01756                         curr = next;
01757                 }
01758                 <span class="keywordflow">while</span> (curr != pHighestLeft);
01759         }
01760         <span class="keywordflow">else</span>
01761         {
01762                 <span class="comment">// ccw oriented</span>
01763                 curr = pHighestLeft;            
01764                 <span class="keywordflow">do</span>
01765                 {
01766                         next = curr + 1;
01767                         <span class="keywordflow">if</span> (next == last) next = first;                                 
01768                         <a class="code" href="a05378.html#a350">ScanInnerEdge</a>(&amp;borders[0], curr-&gt;x, curr-&gt;y, next-&gt;x, next-&gt;y, minimumY, <span class="keyword">false</span>);
01769                         curr = next;
01770                 }
01771                 <span class="keywordflow">while</span> (curr != plowest);                
01772                 <span class="keywordflow">do</span>
01773                 {
01774                         next = curr + 1;
01775                         <span class="keywordflow">if</span> (next == last) next = first;
01776                         <a class="code" href="a05378.html#a350">ScanInnerEdge</a>(&amp;borders[0], next-&gt;x, next-&gt;y, curr-&gt;x, curr-&gt;y, minimumY, <span class="keyword">true</span>);
01777                         curr = next;
01778                 }
01779                 <span class="keywordflow">while</span> (curr != pHighestRight);
01780         }
01781         <span class="comment">// fix for top</span>
01782         <span class="keywordflow">if</span> (floorf(fhighest) != fhighest)
01783         {
01784                 borders[0].first = 1;
01785                 borders[0].second = 0;
01786         }
01787         <span class="comment">// fix for bottom</span>
01788         <span class="keywordflow">if</span> (floorf(flowest) != flowest)
01789         {
01790                 borders.back().first = 1;
01791                 borders.back().second = 0;
01792         }
01793 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da3" doxytag="NLMISC::CPolygon2D::computeOuterBorders" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::computeOuterBorders </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw1">TRasterVect</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>borders</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a14">sint</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>minimumY</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
The same as compute borders, but pixel are seen as surfaces and not as points. Any pixel that is touched by the poly will be selected
<p>
Definition at line <a class="el" href="a06190.html#l01344">1344</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05484.html#l00038">min</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06190.html#l01288">NLMISC::ScanOuterEdgeLeft()</a>, <a class="el" href="a06190.html#l01232">NLMISC::ScanOuterEdgeRight()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a06191.html#l00160">TRasterVect</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
<div class="fragment"><pre>01345 {
01346         <span class="comment">// NB : this version is not much optimized, because of the min/max test</span>
01347         <span class="comment">// during rasterization.</span>
01348         <span class="comment">// TODO : optimize if needed ...</span>
01349         
01350         <span class="keywordflow">if</span> (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.empty())
01351         {
01352                 borders.clear();
01353                 minimumY = -1;
01354                 <span class="keywordflow">return</span>;
01355         }
01356         <span class="keyword">const</span> CVector2f *first = &amp;<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[0];
01357         <span class="keyword">const</span> CVector2f *last  = first + Vertices.size();
01358 
01359         <span class="keyword">const</span> CVector2f *curr = first, *next, *plowest ,*phighest;
01360         <span class="keyword">const</span> CVector2f *pHighestRight, *pHighestRightNext, *pHighestLeft;
01361         <span class="keyword">const</span> CVector2f *pPrevHighestLeft;
01362         <span class="keywordtype">double</span>              deltaXN, deltaYN, deltaXP, deltaYP;
01363         <span class="keywordtype">bool</span>                ccw;  <span class="comment">// true if CCW oriented</span>
01364         <a class="code" href="a04558.html#a14">sint</a>            polyHeight;
01365         <a class="code" href="a04558.html#a14">sint</a>            highest, lowest;                                           
01366         
01367         <span class="keywordtype">float</span> fright   = curr-&gt;x;
01368         <span class="keywordtype">float</span> fleft    = curr-&gt;x;
01369         <span class="keywordtype">float</span> fhighest = curr-&gt;y;
01370         <span class="keywordtype">float</span> flowest  = curr-&gt;y;
01371         plowest = phighest = curr;
01372 
01373         <span class="comment">// compute highest and lowest pos of the poly</span>
01374         <span class="keywordflow">do</span>
01375         {               
01376                 fright = std::max(fright, curr-&gt;x);
01377                 fleft  = <a class="code" href="a04061.html#a0">std::min</a>(fleft, curr-&gt;x);
01378                 <span class="keywordflow">if</span> (curr-&gt;y &gt; flowest)
01379                 {
01380                         flowest = curr-&gt;y;
01381                         plowest = curr;
01382                 }
01383                 <span class="keywordflow">if</span> (curr-&gt;y &lt; fhighest)
01384                 {
01385                         fhighest = curr-&gt;y;
01386                         phighest = curr;
01387                 }
01388                 ++curr;
01389         }
01390         <span class="keywordflow">while</span> (curr != last);
01391 
01392                 
01393         highest = (<a class="code" href="a04558.html#a14">sint</a>) floorf(fhighest);
01394         lowest = (<a class="code" href="a04558.html#a14">sint</a>) floorf(flowest);
01395 
01396         polyHeight = lowest - highest + 1;
01397         <a class="code" href="a04199.html#a6">nlassert</a>(polyHeight &gt; 0);
01398 
01399         <span class="comment">// make room for rasters</span>
01400         borders.resize(polyHeight);
01401         <span class="comment">// fill with xmin / xman</span>
01402         <a class="code" href="a04558.html#a14">sint</a> ileft = (<a class="code" href="a04558.html#a14">sint</a>) floorf(fleft);
01403         <a class="code" href="a04558.html#a14">sint</a> iright = (<a class="code" href="a04558.html#a14">sint</a>) ceilf(fright);
01404         <span class="keywordflow">for</span>(TRasterVect::iterator it = borders.begin(); it != borders.end(); ++it)
01405         {
01406                 it-&gt;second = ileft;
01407                 it-&gt;first = iright;
01408         }
01409 
01410 
01411         minimumY = highest;
01412         pHighestRight = phighest;
01413         <span class="keywordflow">for</span> (;;)
01414         {       
01415                 pHighestRightNext  = pHighestRight + 1;
01416                 <span class="keywordflow">if</span> (pHighestRightNext == last) pHighestRightNext = first;
01417                 <span class="keywordflow">if</span> (pHighestRightNext-&gt;y != pHighestRight-&gt;y) <span class="keywordflow">break</span>;
01418                 pHighestRight = pHighestRightNext;
01419         }       
01420 
01421         pPrevHighestLeft = pHighestRight;
01422         pHighestLeft = pHighestRight;
01423         ++pHighestLeft;
01424         <span class="keywordflow">if</span> (pHighestLeft == last) pHighestLeft = first;
01425         
01426         <span class="keywordflow">while</span> (pHighestLeft-&gt;y != fhighest)
01427         {
01428                 pPrevHighestLeft = pHighestLeft;
01429                 ++pHighestLeft;
01430                 <span class="keywordflow">if</span> (pHighestLeft == last) pHighestLeft = first;
01431         }
01432         
01433 
01434         <span class="comment">// we need to get the orientation of the polygon</span>
01435         <span class="comment">// There are 2 case : flat, and non-flat top</span>
01436         
01437         <span class="comment">// check for flat top</span>
01438         <span class="keywordflow">if</span> (pHighestLeft-&gt;x != pHighestRight-&gt;x)
01439         {
01440                 <span class="comment">// compare right and left side</span>
01441                 <span class="keywordflow">if</span> (pHighestLeft-&gt;x &gt; pHighestRight-&gt;x)
01442                 {
01443                         ccw = <span class="keyword">true</span>;  <span class="comment">// the list is CCW oriented</span>
01444                         std::swap(pHighestLeft, pHighestRight);         
01445                 }
01446                 <span class="keywordflow">else</span>
01447                 {
01448                         ccw = <span class="keyword">false</span>; <span class="comment">// the list is CW oriented</span>
01449                 }
01450         }
01451         <span class="keywordflow">else</span>
01452         {               
01453                 pHighestRightNext = pHighestRight + 1;
01454                 <span class="keywordflow">if</span> (pHighestRightNext == last) pHighestRightNext = first;
01455                  deltaXN = pHighestRightNext-&gt;x - pHighestRight-&gt;x;
01456                  deltaYN = pHighestRightNext-&gt;y - pHighestRight-&gt;y;
01457                  deltaXP = pPrevHighestLeft-&gt;x - pHighestLeft-&gt;x;
01458                  deltaYP = pPrevHighestLeft-&gt;y - pHighestLeft-&gt;y;
01459                  <span class="keywordflow">if</span> ((deltaXN * deltaYP - deltaYN * deltaXP) &lt; 0)
01460                  {
01461                         ccw = <span class="keyword">true</span>;
01462                         std::swap(pHighestLeft, pHighestRight);                            
01463                  }
01464                  <span class="keywordflow">else</span>
01465                  {
01466                         ccw = <span class="keyword">false</span>;
01467                  }
01468         }
01469         
01470         <span class="keywordflow">if</span> (!ccw)
01471         {
01472                 <span class="comment">// clock wise oriented list             </span>
01473                 curr = pHighestRight;           
01474                 <span class="keywordflow">do</span>
01475                 {
01476                         next = curr + 1;
01477                         <span class="keywordflow">if</span> (next == last) next = first;
01478                         <a class="code" href="a05378.html#a348">ScanOuterEdgeRight</a>(&amp;borders[0], curr-&gt;x, curr-&gt;y, next-&gt;x, next-&gt;y, minimumY); 
01479                         curr = next;                    
01480                 }
01481                 <span class="keywordflow">while</span> (curr != plowest);                
01482                 <span class="keywordflow">do</span>
01483                 {
01484                         next = curr + 1;
01485                         <span class="keywordflow">if</span> (next == last) next = first;
01486                         <a class="code" href="a05378.html#a349">ScanOuterEdgeLeft</a>(&amp;borders[0], next-&gt;x, next-&gt;y, curr-&gt;x, curr-&gt;y, minimumY);
01487                         curr = next;
01488                 }
01489                 <span class="keywordflow">while</span> (curr != pHighestLeft);
01490         }
01491         <span class="keywordflow">else</span>
01492         {
01493                 <span class="comment">// ccw oriented         </span>
01494                 curr = pHighestLeft;            
01495                 <span class="keywordflow">do</span>
01496                 {
01497                         next = curr + 1;
01498                         <span class="keywordflow">if</span> (next == last) next = first;                                 
01499                         <a class="code" href="a05378.html#a349">ScanOuterEdgeLeft</a>(&amp;borders[0], curr-&gt;x, curr-&gt;y, next-&gt;x, next-&gt;y, minimumY);
01500                         curr = next;
01501                 }
01502                 <span class="keywordflow">while</span> (curr != plowest);                
01503                 <span class="keywordflow">do</span>
01504                 {
01505                         next = curr + 1;
01506                         <span class="keywordflow">if</span> (next == last) next = first;
01507                         <a class="code" href="a05378.html#a348">ScanOuterEdgeRight</a>(&amp;borders[0], next-&gt;x, next-&gt;y, curr-&gt;x, curr-&gt;y, minimumY);
01508                         curr = next;
01509                 }
01510                 <span class="keywordflow">while</span> (curr != pHighestRight);
01511         }
01512 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da4" doxytag="NLMISC::CPolygon2D::contains" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> bool NLMISC::CPolygon2D::contains </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03660.html">CVector2f</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>p</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const</td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Check wether a point is contained by this poly. 
<p>
get the orientation of this poly<p>
contains the seg 2d equation<p>
don't check against a null segment<p>
get the line equation of the current segment<p>
contains the seg 2d equation 
<p>
Definition at line <a class="el" href="a06190.html#l01896">1896</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l01844">getLineEquation()</a>, <a class="el" href="a06190.html#l01810">getNonNullSeg()</a>, <a class="el" href="a06191.html#l00197">getSegRef0()</a>, <a class="el" href="a06191.html#l00201">getSegRef1()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
Referenced by <a class="el" href="a06190.html#l01857">intersect()</a>.
<p>
<div class="fragment"><pre>01897 {
01898         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size() &gt; 0);
01899         <a class="code" href="a04558.html#a15">uint</a> nonNullSegIndex;
01901         <span class="keywordflow">if</span> (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Da10">getNonNullSeg</a>(nonNullSegIndex))
01902         {
01903                 <span class="keywordtype">float</span> a0, b0, c0; 
01904                 <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Da9">getLineEquation</a>(nonNullSegIndex, a0, b0, c0);
01905 
01906                 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size(); ++k)
01907                 {
01909                     <span class="keywordflow">if</span> ( (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dd0">getSegRef0</a>(k) - <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dd1">getSegRef1</a>(k)).sqrnorm() == 0.f) <span class="keywordflow">continue</span>;
01910 
01912                         <span class="keywordtype">float</span> a, b, c; 
01913                         <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Da9">getLineEquation</a>(k, a, b, c);
01914 
01915                         <span class="keywordflow">if</span> (a * p.x + b * p.y + c &lt; 0) <span class="keywordflow">return</span> <span class="keyword">false</span>;
01916                         
01917                 }
01918                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
01919         }
01920         <span class="keywordflow">else</span> <span class="comment">// this poly is just a point</span>
01921         {
01922                 <span class="keywordflow">return</span> p == <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[0];
01923         }               
01924 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da8" doxytag="NLMISC::CPolygon2D::getBestTriplet" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::getBestTriplet </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>index0</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>index1</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>index2</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
get the best triplet of vector. e.g the triplet that has the best surface 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l00967">967</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
<div class="fragment"><pre>00968 {
00969         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size() &gt;= 3);
00970         <a class="code" href="a04558.html#a15">uint</a> i, j, k;
00971         <span class="keywordtype">float</span> bestArea = 0.f;
00972         <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> numVerts = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size();
00973         <span class="keywordflow">for</span> (i = 0; i &lt; numVerts; ++i)
00974         {
00975                 <span class="keywordflow">for</span> (j = 0; j &lt; numVerts; ++j)
00976                 {
00977                         <span class="keywordflow">if</span> (i != j)
00978                         {
00979                                 <span class="keywordflow">for</span> (k = 0; k &lt; numVerts; ++k)
00980                                 {
00981                                         <span class="keywordflow">if</span> (k != i &amp;&amp; k != j)
00982                                         {
00983                                                 CVector2f v0 = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[j] - Vertices[i];
00984                                                 CVector2f v1 = Vertices[k] - Vertices[i];                                               
00985                                                 <span class="keywordtype">float</span> area = fabsf((CVector(v0.x, v0.y, 0) ^ CVector(v1.x, v1.y, 0)).norm());
00986                                                 <span class="keywordflow">if</span> (area &gt; bestArea)
00987                                                 {
00988                                                         bestArea = area;
00989                                                         index0 = i;
00990                                                         index1 = j;
00991                                                         index2 = k;
00992                                                 }
00993                                         }
00994                                 }
00995                         }
00996                 }
00997         }
00998 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da9" doxytag="NLMISC::CPolygon2D::getLineEquation" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::getLineEquation </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>index</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>a</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>b</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>c</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"> const</td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get a line equation of the seg starting at the given index. 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l01844">1844</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06191.html#l00197">getSegRef0()</a>, <a class="el" href="a06191.html#l00201">getSegRef1()</a>, <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
Referenced by <a class="el" href="a06190.html#l01896">contains()</a>, and <a class="el" href="a06190.html#l01857">intersect()</a>.
<p>
<div class="fragment"><pre>01845 {
01846         <a class="code" href="a04199.html#a6">nlassert</a>(index &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size());
01847         <span class="keyword">const</span> CVector2f &amp;v0 = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dd0">getSegRef0</a>(index);
01848         <span class="keyword">const</span> CVector2f &amp;v1 = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dd1">getSegRef1</a>(index);
01849         
01850         <a class="code" href="a03660.html">NLMISC::CVector2f</a> seg = v0 - v1;
01851         a = seg.<a class="code" href="a03660.html#NLMISC_1_1CVector2fo1">y</a>;
01852         b = - seg.<a class="code" href="a03660.html#NLMISC_1_1CVector2fo0">x</a>;
01853         c = - v0.x * a - v0.y * b;
01854 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da10" doxytag="NLMISC::CPolygon2D::getNonNullSeg" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> bool NLMISC::CPolygon2D::getNonNullSeg </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>seg</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const</td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get the index of a segment of this poly that is a non null segment. <dl compact><dt><b>Returns:</b></dt><dd>true if such a segment was found</dd></dl>

<p>
Definition at line <a class="el" href="a06190.html#l01810">1810</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00104">sint</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l01896">contains()</a>, and <a class="el" href="a06190.html#l01857">intersect()</a>.
<p>
<div class="fragment"><pre>01811 {
01812         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size() &gt; 0);
01813         <span class="keywordtype">float</span> bestLength = 0.f;
01814         <a class="code" href="a04558.html#a14">sint</a>  bestIndex = -1;
01815         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size() - 1; ++k)
01816         {
01817                 <span class="keywordtype">float</span> norm2 = (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[k + 1] - Vertices[k]).sqrnorm();
01818                 <span class="keywordflow">if</span> ( norm2 &gt; bestLength)
01819                 {
01820                         bestLength = norm2;
01821                         bestIndex = (<span class="keywordtype">int</span>) k;
01822                 }
01823         }
01824         <span class="keywordtype">float</span> norm2 = (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[Vertices.size() - 1] - Vertices[0]).sqrnorm();
01825         <span class="keywordflow">if</span> ( norm2 &gt; bestLength) 
01826         { 
01827                 <a class="code" href="a04223.html#a566">index</a> = Vertices.size() - 1;
01828                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
01829         }
01830 
01831         <span class="keywordflow">if</span> (bestIndex != -1)
01832         {
01833                 <a class="code" href="a04223.html#a566">index</a> = bestIndex;
01834                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
01835         }
01836         <span class="keywordflow">else</span>
01837         {
01838                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
01839         }       
01840 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Dd0" doxytag="NLMISC::CPolygon2D::getSegRef0" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> const <a class="el" href="a03660.html">CVector2f</a>&amp; NLMISC::CPolygon2D::getSegRef0 </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>index</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline, private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get ref to the first vertex that start at index. 
<p>

<p>
Definition at line <a class="el" href="a06191.html#l00197">197</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
References <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l01896">contains()</a>, <a class="el" href="a06190.html#l01844">getLineEquation()</a>, and <a class="el" href="a06190.html#l01857">intersect()</a>.
<p>
<div class="fragment"><pre>00198         { 
00199                 <a class="code" href="a04199.html#a6">nlassert</a>(index &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size()); <span class="keywordflow">return</span> <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[<a class="code" href="a04223.html#a566">index</a>]; 
00200         }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Dd1" doxytag="NLMISC::CPolygon2D::getSegRef1" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> const <a class="el" href="a03660.html">CVector2f</a>&amp; NLMISC::CPolygon2D::getSegRef1 </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>index</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline, private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06191.html#l00201">201</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
References <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l01896">contains()</a>, <a class="el" href="a06190.html#l01844">getLineEquation()</a>, and <a class="el" href="a06190.html#l01857">intersect()</a>.
<p>
<div class="fragment"><pre>00202         { 
00203                 <a class="code" href="a04199.html#a6">nlassert</a>(index &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size());              
00204                 <span class="keywordflow">return</span> <a class="code" href="a04223.html#a566">index</a> == <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size() - 1 ?
00205                            <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[0]                 :
00206                        <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[<a class="code" href="a04223.html#a566">index</a> + 1];
00207         }       
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da11" doxytag="NLMISC::CPolygon2D::intersect" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> bool NLMISC::CPolygon2D::intersect </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03101.html">CPolygon2D</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>other</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const</td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Test wether this polygon intersect another convex polygon. Currently not optimized. 
<p>
get the orientation of this poly<p>
contains the seg 2d equation<p>
don't check against a null segment<p>
get the line equation of the current segment<p>
contains the seg 2d equation 
<p>
Definition at line <a class="el" href="a06190.html#l01857">1857</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l01896">contains()</a>, <a class="el" href="a06190.html#l01844">getLineEquation()</a>, <a class="el" href="a06190.html#l01810">getNonNullSeg()</a>, <a class="el" href="a06191.html#l00197">getSegRef0()</a>, <a class="el" href="a06191.html#l00201">getSegRef1()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06190.html#l01797">sumDPAgainstLine()</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06191.html#l00126">Vertices</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
Referenced by <a class="el" href="a06768.html#l03563">NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater()</a>.
<p>
<div class="fragment"><pre>01858 {
01859         <a class="code" href="a04199.html#a6">nlassert</a>(other.Vertices.size() &gt; 0);
01860         <a class="code" href="a04558.html#a15">uint</a> nonNullSegIndex;
01862         <span class="keywordflow">if</span> (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Da10">getNonNullSeg</a>(nonNullSegIndex))
01863         {
01864                 <span class="keywordtype">float</span> a0, b0, c0; 
01865                 <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Da9">getLineEquation</a>(nonNullSegIndex, a0, b0, c0);
01866                 <span class="keywordtype">float</span> orient = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dd2">sumDPAgainstLine</a>(a0, b0, c0);
01867 
01868                 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size(); ++k)
01869                 {
01871                     <span class="keywordflow">if</span> ( (<a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dd0">getSegRef0</a>(k) - <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Dd1">getSegRef1</a>(k)).sqrnorm() == 0.f) <span class="keywordflow">continue</span>;
01872 
01874                         <span class="keywordtype">float</span> a, b, c; 
01875                         <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Da9">getLineEquation</a>(k, a, b, c);
01876                         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a05373.html#a2">l</a>;
01877                         <span class="keywordflow">for</span> (<a class="code" href="a05373.html#a2">l</a> = 0; <a class="code" href="a05373.html#a2">l</a> &lt; other.Vertices.size(); ++<a class="code" href="a05373.html#a2">l</a>)
01878                         {
01879                                 <span class="keyword">const</span> CVector2f &amp;ov = other.Vertices[<a class="code" href="a05373.html#a2">l</a>];
01880                                 <span class="keywordflow">if</span> ( orient * (ov.x * a + ov.y * b +c) &gt; 0.f) <span class="keywordflow">break</span>;
01881                         }
01882                         <span class="keywordflow">if</span> (<a class="code" href="a05373.html#a2">l</a> == other.Vertices.size()) <span class="comment">// all point on the outside</span>
01883                         {
01884                                 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// outside</span>
01885                         }
01886                 }
01887                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
01888         }
01889         <span class="keywordflow">else</span> <span class="comment">// this poly is just a point</span>
01890         {
01891                 <span class="keywordflow">return</span> other.contains(Vertices[0]);
01892         }
01893 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da12" doxytag="NLMISC::CPolygon2D::isConvex" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> bool NLMISC::CPolygon2D::isConvex </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Check wether this polygon is convex;. 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l00798">798</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06170.html#l00036">NLMISC::CPlane::make()</a>, <a class="el" href="a06682.html#l00136">NLMISC::CVector::set()</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05646.html#l00236">x</a>, and <a class="el" href="a05646.html#l00236">y</a>.
<p>
<div class="fragment"><pre>00799 {
00800         <span class="keywordtype">bool</span> Front  = <span class="keyword">true</span>, Back = <span class="keyword">false</span>;       
00801         <span class="comment">// we apply a dummy algo for now : check wether every vertex is in the same side </span>
00802         <span class="comment">// of every plane defined by a segment of this poly</span>
00803         <a class="code" href="a04558.html#a15">uint</a> numVerts = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size();
00804         <span class="keywordflow">if</span> (numVerts &lt; 3) <span class="keywordflow">return</span> <span class="keyword">true</span>;
00805         CVector         segStart, segEnd;
00806         CPlane          clipPlane;
00807         <span class="keywordflow">for</span> (TVec2fVect::const_iterator it = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.begin(); it != <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.end(); ++it)
00808         {               
00809                 segStart.set(it-&gt;x, it-&gt;y, 0);            <span class="comment">// segment start</span>
00810                 segEnd.set((it + 1)-&gt;<a class="code" href="a04223.html#a572">x</a>, (it + 1)-&gt;<a class="code" href="a04223.html#a573">y</a>, 0);  <span class="comment">// segment end</span>
00811                 <span class="keywordtype">float</span> n = (segStart - segEnd).norm();     <span class="comment">// segment norm</span>
00812                 <span class="keywordflow">if</span> (n != 0)
00813                 {
00814                         clipPlane.make(segStart, segEnd, (n &gt; 10 ? n : 10) * CVector::K + segStart); <span class="comment">// make a plane, with this segment and the poly normal</span>
00815                         <span class="comment">// check each other vertices against this plane</span>
00816                         <span class="keywordflow">for</span> (TVec2fVect::const_iterator it2 = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.begin(); it2 != <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.end(); ++it2)
00817                         {
00818                                 <span class="keywordflow">if</span> (it2 != it &amp;&amp; it2 != (it + 1)) <span class="comment">// the vertices must not be part of the test plane (because of imprecision)</span>
00819                                 {
00820 
00821                                         <span class="keywordtype">float</span> dist  = clipPlane * CVector(it2-&gt;x, it2-&gt; <a class="code" href="a04223.html#a573">y</a>, 0);
00822                                         <span class="keywordflow">if</span> (dist != 0) <span class="comment">// midlle pos</span>
00823                                         {
00824                                                 <span class="keywordflow">if</span> (dist &gt; 0) Front = <span class="keyword">true</span>; <span class="keywordflow">else</span> Back = <span class="keyword">true</span>;                                   
00825                                                 <span class="keywordflow">if</span> (Front &amp;&amp; Back) <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// there are both front end back vertices -&gt; failure</span>
00826                                         }
00827                                 }
00828                         }
00829                 }
00830         }
00831         <span class="keywordflow">return</span> <span class="keyword">true</span>;
00832 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da13" doxytag="NLMISC::CPolygon2D::serial" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::serial </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02270.html">NLMISC::IStream</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>f</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap>  throw (<a class="el" href="a03781.html">NLMISC::EStream</a>)</td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Serial this polygon. 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l00959">959</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
<div class="fragment"><pre>00960 {
00961         (<span class="keywordtype">void</span>)f.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_8">serialVersion</a>(0);
00962         f.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(Vertices);
00963 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Dd2" doxytag="NLMISC::CPolygon2D::sumDPAgainstLine" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> float NLMISC::CPolygon2D::sumDPAgainstLine </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">float&nbsp;</td>
          <td class="mdname" nowrap> <em>a</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>b</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>c</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"> const<code> [private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Sum the dot product of this poly vertices against a plane. 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l01797">1797</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>.
<p>
Referenced by <a class="el" href="a06190.html#l01857">intersect()</a>.
<p>
<div class="fragment"><pre>01798 {
01799         <span class="keywordtype">float</span> sum = 0.f;
01800         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k &lt; <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.size(); ++k)
01801         {
01802                 <span class="keyword">const</span> CVector2f &amp;p = <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>[k];
01803                 sum += a * p.x + b * p.y + c;
01804         }
01805         <span class="keywordflow">return</span> sum;
01806 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygon2Da14" doxytag="NLMISC::CPolygon2D::swap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NLMISC::CPolygon2D::swap </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a03101.html">CPolygon2D</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>other</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06191.html#l00132">132</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
References <a class="el" href="a06191.html#l00126">Vertices</a>.
<p>
<div class="fragment"><pre>00132 { <a class="code" href="a03101.html#NLMISC_1_1CPolygon2Do0">Vertices</a>.swap(other.Vertices); }      
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NLMISC_1_1CPolygon2Do0" doxytag="NLMISC::CPolygon2D::Vertices" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03101.html#NLMISC_1_1CPolygon2Dw2">TVec2fVect</a> <a class="el" href="a03101.html#NLMISC_1_1CPolygon2Do0">NLMISC::CPolygon2D::Vertices</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06191.html#l00126">126</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00836">buildConvexHull()</a>, <a class="el" href="a05937.html#l00066">NL3D::CLodCharacterShapeBuild::compile()</a>, <a class="el" href="a06741.html#l00410">NL3D::CWaterShape::computeBBox()</a>, <a class="el" href="a06737.html#l01054">NL3D::CWaterModel::computeClippedPoly()</a>, <a class="el" href="a06737.html#l01026">NL3D::CWaterModel::computeSimpleClippedPoly()</a>, <a class="el" href="a06768.html#l03563">NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater()</a>, <a class="el" href="a06737.html#l01170">NL3D::CWaterModel::doSimpleRender()</a>, <a class="el" href="a06741.html#l00609">NL3D::CWaterShape::getShapeInWorldSpace()</a>, <a class="el" href="a06190.html#l01857">intersect()</a>, <a class="el" href="a06190.html#l01945">NLMISC::operator&lt;()</a>, <a class="el" href="a06190.html#l01938">NLMISC::operator==()</a>, <a class="el" href="a06768.html#l00444">RenderTriangle()</a>, <a class="el" href="a06741.html#l00401">NL3D::CWaterShape::setShape()</a>, <a class="el" href="a06191.html#l00132">swap()</a>, and <a class="el" href="a06737.html#l00437">NL3D::CWaterModel::traverseRender()</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a06191.html">polygon.h</a><li><a class="el" href="a06190.html">polygon.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:28:15 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>