aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a03100.html
blob: 17c16dc5b67857c77d0d06958db2ff65a9e4adbd (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
<!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::CPolygon 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::CPolygon 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 polygon, with an unlimited size of vertices. <dl compact><dt><b>Author:</b></dt><dd>Lionel Berenguier <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2000 </dd></dl>

<p>

<p>
Definition at line <a class="el" href="a06191.html#l00052">52</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 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="a03100.html#NLMISC_1_1CPolygona0">buildBasis</a> (<a class="el" href="a02851.html">CMatrix</a> &amp;dest)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona1">chain</a> (const std::vector&lt; <a class="el" href="a03100.html">CPolygon</a> &gt; &amp;other, const <a class="el" href="a02851.html">CMatrix</a> &amp;basis)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona2">clip</a> (const std::vector&lt; <a class="el" href="a03082.html">CPlane</a> &gt; &amp;planes)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Clip a polygon with a set of planes. Cohen-sutherland clipping... clipPolygonBack() is used on planes.  <a href="#NLMISC_1_1CPolygona2"></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="a03100.html#NLMISC_1_1CPolygona3">clip</a> (const <a class="el" href="a03082.html">CPlane</a> *planes, <a class="el" href="a04558.html#a15">uint</a> nPlanes)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Clip a polygon with a set of planes. Cohen-sutherland... clipPolygonBack() is used on planes.  <a href="#NLMISC_1_1CPolygona3"></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="a03100.html#NLMISC_1_1CPolygona4">CPolygon</a> (const <a class="el" href="a03128.html">CVector</a> &amp;a, const <a class="el" href="a03128.html">CVector</a> &amp;b, const <a class="el" href="a03128.html">CVector</a> &amp;c)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor. Init with a triangle.  <a href="#NLMISC_1_1CPolygona4"></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="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor.  <a href="#NLMISC_1_1CPolygona5"></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="a03100.html#NLMISC_1_1CPolygona6">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 from this poly (the one that has the highest area)  <a href="#NLMISC_1_1CPolygona6"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a14">sint</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona8">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_1CPolygona8"></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="a03100.html#NLMISC_1_1CPolygona9">toConvexPolygons</a> (std::list&lt; <a class="el" href="a03100.html">CPolygon</a> &gt; &amp;outputPolygons, const <a class="el" href="a02851.html">CMatrix</a> &amp;basis) const </td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona10">toConvexPolygonsLocalAndBSP</a> (std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;localVertices, <a class="el" href="a02292.html">CBSPNode2v</a> &amp;root, const <a class="el" href="a02851.html">CMatrix</a> &amp;basis) const </td></tr>

<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;vertex, const <a class="el" href="a02292.html">CBSPNode2v</a> &amp;bsp, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone1">toConvexPolygonsEdgeIntersect</a> (const <a class="el" href="a03660.html">CVector2f</a> &amp;a0, const <a class="el" href="a03660.html">CVector2f</a> &amp;a1, const <a class="el" href="a03660.html">CVector2f</a> &amp;b0, const <a class="el" href="a03660.html">CVector2f</a> &amp;b1)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone2">toConvexPolygonsInCone</a> (const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;vertex, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> (const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;vertex, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b, <a class="el" href="a04558.html#a15">uint</a> c)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone4">toConvexPolygonsLeftOn</a> (const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;vertex, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b, <a class="el" href="a04558.html#a15">uint</a> c)</td></tr>

<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a></td></tr>

</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="NLMISC_1_1CPolygona5" doxytag="NLMISC::CPolygon::CPolygon" ></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::CPolygon::CPolygon </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>
Constructor. 
<p>

<p>
Definition at line <a class="el" href="a06191.html#l00060">60</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00440">toConvexPolygons()</a>.
<p>
<div class="fragment"><pre>00060 {}
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona4" doxytag="NLMISC::CPolygon::CPolygon" ></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::CPolygon::CPolygon </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03128.html">CVector</a> &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>const <a class="el" href="a03128.html">CVector</a> &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>const <a class="el" href="a03128.html">CVector</a> &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"></td>
        </tr>

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

<p>
Constructor. Init with a triangle. 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l00046">46</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
<div class="fragment"><pre>00047 {
00048         <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.reserve(3);
00049         <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.push_back(a);
00050         <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.push_back(b);
00051         <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.push_back(c);
00052 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NLMISC_1_1CPolygona0" doxytag="NLMISC::CPolygon::buildBasis" ></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::CPolygon::buildBasis </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02851.html">CMatrix</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></td>
        </tr>

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

<p>
Takes the best triplet from this poly to build a normal. From this normal and a points, build a basis (the normal is the K vector of the basis) This can be used to transform the poly in 2D after it has been inverted
<p>
Definition at line <a class="el" href="a06190.html#l00141">141</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l00106">getBestTriplet()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05972.html#l00267">NLMISC::CMatrix::setPos()</a>, <a class="el" href="a05972.html#l00209">NLMISC::CMatrix::setRot()</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
<div class="fragment"><pre>00142 {
00143         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size() &gt; 3);
00144         <a class="code" href="a04558.html#a15">uint</a> i1, i2, i3;
00145         <a class="code" href="a03100.html#NLMISC_1_1CPolygona6">getBestTriplet</a>(i1, i2, i3);
00146         CVector v1 = (<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>[i2] - Vertices[i1]).normed();
00147         CVector v2 = (Vertices[i3] - Vertices[i1]).normed();
00148         CVector K = v2 ^ v1;
00149         CVector I = v1 - (v1 * K) * v1;
00150         CVector J = K ^ I;
00151         dest.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_10">setRot</a>(I, J, K);
00152         dest.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(Vertices[i1]);
00153 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona1" doxytag="NLMISC::CPolygon::chain" ></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::CPolygon::chain </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a03100.html">CPolygon</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>other</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>basis</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>
Chain the arg polygons with this polygon testing 2d intersections. The 2d intersection test has been done in the XY plane of the basis passed at the function.<p>
The polygon a-b-c-d-e chained with f-g-h-i-j will give the polygon a-b-f-g-h-i-j-f-b-c-d-e if the edge b-f is not 2d clipped by any edge plane in the XY plane of basis.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>basis</em>&nbsp;</td><td>is the basis of the polygon projection. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>false if chain failed. else true.</dd></dl>

<p>
Definition at line <a class="el" href="a06190.html#l00624">624</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="a06190.html#l00299">NLMISC::CBSPNode2v::intersect()</a>, <a class="el" href="a06190.html#l00392">toConvexPolygonsLocalAndBSP()</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a06191.html#l00055">Vertices</a>.
<p>
<div class="fragment"><pre>00625 {
00626         <span class="comment">// Local vertices</span>
00627         std::vector&lt;CVector&gt;    localVertices;
00628 
00629         <span class="comment">// Build the BSP root</span>
00630         <a class="code" href="a02292.html">CBSPNode2v</a> root;
00631 
00632         <span class="comment">// Build the local array and the BSP</span>
00633         <a class="code" href="a03100.html#NLMISC_1_1CPolygona10">toConvexPolygonsLocalAndBSP</a> (localVertices, root, basis);
00634 
00635         <span class="comment">// Local vertices</span>
00636         std::vector&lt;std::vector&lt;CVector&gt; &gt;      localVerticesOther (other.size());
00637 
00638         <span class="comment">// Build the BSP root</span>
00639         std::vector&lt;CBSPNode2v&gt; rootOther (other.size());
00640 
00641         <span class="comment">// Build a copy of the polygons</span>
00642         std::vector&lt;CPolygon&gt; copy = other;
00643 
00644         <span class="comment">// Main copy</span>
00645         <a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> mainCopy = *<span class="keyword">this</span>;
00646 
00647         <span class="comment">// For each other polygons</span>
00648         <a class="code" href="a04558.html#a15">uint</a> o;
00649         <span class="keywordflow">for</span> (o=0; o&lt;other.size(); o++)
00650         {
00651                 <span class="comment">// Build the local array and the BSP</span>
00652                 other[o].toConvexPolygonsLocalAndBSP (localVerticesOther[o], rootOther[o], basis);
00653         }
00654 
00655         <span class="comment">// Look for a couple..</span>
00656         <a class="code" href="a04558.html#a15">uint</a> thisCount = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size();
00657         <a class="code" href="a04558.html#a15">uint</a> i, j;
00658         <span class="keywordflow">for</span> (o=0; o&lt;other.size(); o++)
00659         {
00660                 <a class="code" href="a04558.html#a15">uint</a> otherCount = other[o].Vertices.size();
00661 
00662                 <span class="comment">// Try to link in the main polygon</span>
00663                 <span class="keywordflow">for</span> (i=0; i&lt;thisCount; i++)
00664                 {
00665                         <span class="keywordflow">for</span> (j=0; j&lt;otherCount; j++)
00666                         {
00667                                 <span class="comment">// Test this segement</span>
00668                                 <span class="keywordflow">if</span> (!root.<a class="code" href="a02292.html#NLMISC_1_1CBSPNode2va3">intersect</a> (localVertices[i], localVerticesOther[o][j], i, 0xffffffff))
00669                                 {
00670                                         <span class="comment">// Test each other polygons</span>
00671                                         <a class="code" href="a04558.html#a15">uint</a> otherO;
00672                                         <span class="keywordflow">for</span> (otherO=0; otherO&lt;other.size(); otherO++)
00673                                         {
00674                                                 <span class="comment">// Intersect ?</span>
00675                                                 <span class="keywordflow">if</span> (rootOther[otherO].intersect (localVertices[i], localVerticesOther[o][j], 0xffffffff, (otherO == o)?j:0xffffffff))
00676                                                         <span class="keywordflow">break</span>;
00677                                         }
00678 
00679                                         <span class="comment">// Continue ?</span>
00680                                         <span class="keywordflow">if</span> (otherO==other.size())
00681                                         {
00682                                                 <span class="comment">// Insert new vertices</span>
00683                                                 mainCopy.Vertices.insert (mainCopy.Vertices.begin()+i, 2+otherCount, CVector());
00684 
00685                                                 <span class="comment">// Copy the first vertex</span>
00686                                                 mainCopy.Vertices[i] = mainCopy.Vertices[i+otherCount+2];
00687 
00688                                                 <span class="comment">// Copy the new vertices</span>
00689                                                 <a class="code" href="a04558.html#a15">uint</a> k;
00690                                                 <span class="keywordflow">for</span> (k=0; k&lt;otherCount; k++)
00691                                                 {
00692                                                         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a> = j+k;
00693                                                         <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a566">index</a>&gt;=otherCount)
00694                                                                 <a class="code" href="a04223.html#a566">index</a> -= otherCount;
00695                                                         mainCopy.Vertices[i+k+1] = copy[o].Vertices[<a class="code" href="a04223.html#a566">index</a>];
00696                                                 }
00697 
00698                                                 <span class="comment">// Copy the last one</span>
00699                                                 mainCopy.Vertices[i+otherCount+1] = copy[o].Vertices[j];
00700                                                 <span class="keywordflow">break</span>;
00701                                         }
00702                                 }
00703                         }
00704                         <span class="keywordflow">if</span> (j!=otherCount)
00705                                 <span class="keywordflow">break</span>;
00706                 }
00707 
00708                 <span class="comment">// Not found ?</span>
00709                 <span class="keywordflow">if</span> (i==thisCount)
00710                 {
00711                         <span class="comment">// Try to link in the sub polygons</span>
00712                         <a class="code" href="a04558.html#a15">uint</a> otherToCheck;
00713                         <span class="keywordflow">for</span> (otherToCheck=o+1; otherToCheck&lt;other.size(); otherToCheck++)
00714                         {
00715                                 <a class="code" href="a04558.html#a15">uint</a> otherToCheckCount = other[otherToCheck].Vertices.size();
00716                                 <span class="keywordflow">for</span> (i=0; i&lt;otherToCheckCount; i++)
00717                                 {
00718                                         <span class="keywordflow">for</span> (j=0; j&lt;otherCount; j++)
00719                                         {
00720                                                 <span class="comment">// Test this segement</span>
00721                                                 <span class="keywordflow">if</span> (!rootOther[otherToCheck].intersect (localVerticesOther[otherToCheck][i], localVerticesOther[o][j], i, 0xffffffff))
00722                                                 {
00723                                                         <span class="comment">// Test each other polygons</span>
00724                                                         <a class="code" href="a04558.html#a15">uint</a> otherO;
00725                                                         <span class="keywordflow">for</span> (otherO=0; otherO&lt;other.size(); otherO++)
00726                                                         {
00727                                                                 <span class="comment">// Intersect ?</span>
00728                                                                 <span class="keywordflow">if</span> (rootOther[otherO].intersect (localVerticesOther[otherToCheck][i], localVerticesOther[o][j],  (otherToCheck == otherO)?i:0xffffffff,  (otherO == o)?j:0xffffffff))
00729                                                                         <span class="keywordflow">break</span>;
00730                                                         }
00731 
00732                                                         <span class="comment">// Continue ?</span>
00733                                                         <span class="keywordflow">if</span> (otherO==other.size())
00734                                                         {
00735                                                                 <span class="comment">// Insert new vertices</span>
00736                                                                 copy[otherToCheck].Vertices.insert (copy[otherToCheck].<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.begin()+i, 2+otherCount, CVector());
00737 
00738                                                                 <span class="comment">// Copy the first vertex</span>
00739                                                                 copy[otherToCheck].Vertices[i] = copy[otherToCheck].Vertices[i+otherCount+2];
00740 
00741                                                                 <span class="comment">// Copy the new vertices</span>
00742                                                                 <a class="code" href="a04558.html#a15">uint</a> k;
00743                                                                 <span class="keywordflow">for</span> (k=0; k&lt;otherCount; k++)
00744                                                                 {
00745                                                                         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a> = j+k;
00746                                                                         <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a566">index</a>&gt;=otherCount)
00747                                                                                 <a class="code" href="a04223.html#a566">index</a> -= otherCount;
00748                                                                         copy[otherToCheck].Vertices[i+k+1] = copy[otherO].Vertices[<a class="code" href="a04223.html#a566">index</a>];
00749                                                                 }
00750 
00751                                                                 <span class="comment">// Copy the last one</span>
00752                                                                 copy[otherToCheck].Vertices[i+otherCount+1] = copy[otherO].Vertices[j];
00753                                                                 <span class="keywordflow">break</span>;
00754                                                         }
00755                                                 }
00756                                         }
00757                                         <span class="keywordflow">if</span> (j!=otherCount)
00758                                                 <span class="keywordflow">break</span>;
00759                                 }
00760                                 <span class="keywordflow">if</span> (i!=otherToCheckCount)
00761                                         <span class="keywordflow">break</span>;
00762                         }
00763                         <span class="keywordflow">if</span> (otherToCheck==other.size())
00764                         {
00765                                 <span class="comment">// Not ok</span>
00766                                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00767                         }
00768                 }
00769         }
00770 
00771         <span class="comment">// Ok</span>
00772         *<span class="keyword">this</span> = mainCopy;
00773         <span class="keywordflow">return</span> <span class="keyword">true</span>;
00774 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona2" doxytag="NLMISC::CPolygon::clip" ></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::CPolygon::clip </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a03082.html">CPlane</a> &gt; &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>planes</em>          </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>
Clip a polygon with a set of planes. Cohen-sutherland clipping... clipPolygonBack() is used on planes. 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l00089">89</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l00056">clip()</a>.
<p>
<div class="fragment"><pre>00090 {
00091         <span class="keywordflow">if</span>(planes.size()==0)
00092                 <span class="keywordflow">return</span>;
00093         <a class="code" href="a03100.html#NLMISC_1_1CPolygona3">clip</a>(&amp;(*planes.begin()), planes.size());
00094 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona3" doxytag="NLMISC::CPolygon::clip" ></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::CPolygon::clip </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03082.html">CPlane</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>planes</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>&nbsp;</td>
          <td class="mdname" nowrap> <em>nPlanes</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>
Clip a polygon with a set of planes. Cohen-sutherland... clipPolygonBack() is used on planes. 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l00056">56</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06170.html#l00097">NLMISC::CPlane::clipPolygonBack()</a>, <a class="el" href="a06191.html#l00064">getNumVertices()</a>, <a class="el" href="a05646.html#l01122">in</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#l00089">clip()</a>, <a class="el" href="a06193.html#l00083">NL3D::CPortal::clipPyramid()</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="a06350.html#l01224">NL3D::CInstanceGroup::displayDebugClusters()</a>, and <a class="el" href="a05384.html#l00121">NLMISC::CAABBox::intersect()</a>.
<p>
<div class="fragment"><pre>00057 {
00058         <span class="keywordflow">if</span>(nPlanes==0 || <a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>()==0)
00059                 <span class="keywordflow">return</span>;
00060 
00061         <span class="comment">// The final polygon has at maximum currentVertices+number of clipping planes.</span>
00062         <span class="comment">// For performance, the vectors are static, so reallocation rarely occurs.</span>
00063         <span class="keyword">static</span>  vector&lt;CVector&gt;         tab0, tab1;
00064         tab0.resize(<a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>()+nPlanes);
00065         tab1.resize(<a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>()+nPlanes);
00066         <span class="comment">// Init tab0 with Vertices.</span>
00067         copy(<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.begin(), <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.end(), tab0.begin());
00068         CVector                         *<a class="code" href="a04223.html#a647">in</a>=&amp;(*tab0.begin()), *out= &amp;(*tab1.begin());
00069         <a class="code" href="a04558.html#a14">sint</a>                            nin= <a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>(), nout;
00070         <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a14">sint</a> i=0;i&lt;(<a class="code" href="a04558.html#a14">sint</a>)nPlanes;i++)
00071         {
00072                 nout= planes[i].clipPolygonBack(in, out, nin);
00073                 swap(in, out);
00074                 nin= nout;
00075                 <span class="keywordflow">if</span>(nin==0)
00076                         <span class="keywordflow">break</span>;
00077         }
00078 
00079         <span class="comment">// Final result in "in".</span>
00080         <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.resize(nin);
00081         <span class="keywordflow">if</span>(nin&gt;0)
00082         {
00083                 memcpy(&amp;(*<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.begin()), <a class="code" href="a04223.html#a647">in</a>, nin*<span class="keyword">sizeof</span>(CVector));
00084         }
00085 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona6" doxytag="NLMISC::CPolygon::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::CPolygon::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 from this poly (the one that has the highest area) 
<p>

<p>
Definition at line <a class="el" href="a06190.html#l00106">106</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="a06682.html#l00115">NLMISC::CVector::norm()</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00141">buildBasis()</a>.
<p>
<div class="fragment"><pre>00107 {
00108         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size() &gt;= 3);
00109         <a class="code" href="a04558.html#a15">uint</a> i, j, k;
00110         <span class="keywordtype">float</span> bestArea = 0.f;
00111         <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> numVerts = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size();
00112         <span class="keywordflow">for</span> (i = 0; i &lt; numVerts; ++i)
00113         {
00114                 <span class="keywordflow">for</span> (j = 0; j &lt; numVerts; ++j)
00115                 {
00116                         <span class="keywordflow">if</span> (i != j)
00117                         {
00118                                 <span class="keywordflow">for</span> (k = 0; k &lt; numVerts; ++k)
00119                                 {
00120                                         <span class="keywordflow">if</span> (k != i &amp;&amp; k != j)
00121                                         {
00122                                                 CVector v0 = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>[j] - Vertices[i];
00123                                                 CVector v1 = Vertices[k] - Vertices[i];                                         
00124                                                 <span class="keywordtype">float</span> area = (v0 ^ v1).norm();
00125                                                 <span class="keywordflow">if</span> (area &gt; bestArea)
00126                                                 {
00127                                                         bestArea = area;
00128                                                         index0 = i;
00129                                                         index1 = j;
00130                                                         index2 = k;
00131                                                 }
00132                                         }
00133                                 }
00134                         }
00135                 }
00136         }
00137 
00138 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona7" doxytag="NLMISC::CPolygon::getNumVertices" ></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="a04558.html#a14">sint</a> NLMISC::CPolygon::getNumVertices </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<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#l00064">64</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
References <a class="el" href="a05981.html#l00104">sint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00056">clip()</a>, <a class="el" href="a05384.html#l00121">NLMISC::CAABBox::intersect()</a>, and <a class="el" href="a06768.html#l02927">NL3D::CZoneLighter::lightWater()</a>.
<p>
<div class="fragment"><pre>00064 {<span class="keywordflow">return</span> <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size();}
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona8" doxytag="NLMISC::CPolygon::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::CPolygon::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#l00099">99</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
<div class="fragment"><pre>00100 {
00101         f.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_8">serialVersion</a>(0);
00102         f.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(Vertices);
00103 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona9" doxytag="NLMISC::CPolygon::toConvexPolygons" ></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::CPolygon::toConvexPolygons </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">std::list&lt; <a class="el" href="a03100.html">CPolygon</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>outputPolygons</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>basis</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>
Convert a concave polygon into a list of convex polygons using a 2d projection. The polygon mustn't overlap itself in the XY plane of the basis passed in parameter. The polygon must be direct in the XY plane of the basis passed in parameter. (Counter clock wise)<p>
The subdivison is in non-constant n*log(n) with n is the number of vertices.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>outputPolygons</em>&nbsp;</td><td>is the list filled with clipped convex polygons. The list is not cleared at the begining. New polygons are just appended at the end. </td></tr>
    <tr><td valign=top><em>basis</em>&nbsp;</td><td>is the basis of the polygon projection. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>true if the polygon has been subdivided. false if the polygon overlap itself in the XY plane of the basis or if the polygon is not direct (clock wise).</dd></dl>

<p>
Definition at line <a class="el" href="a06190.html#l00440">440</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06191.html#l00060">CPolygon()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06190.html#l00375">toConvexPolygonsDiagonal()</a>, <a class="el" href="a06190.html#l00392">toConvexPolygonsLocalAndBSP()</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a06191.html#l00055">Vertices</a>.
<p>
<div class="fragment"><pre>00441 {
00442         <span class="comment">// Some vertices ?</span>
00443         <span class="keywordflow">if</span> (<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size()&gt;2)
00444         {
00445                 <span class="comment">// Local vertices</span>
00446                 std::vector&lt;CVector&gt;    localVertices;
00447 
00448                 <span class="comment">// Build the BSP root</span>
00449                 <a class="code" href="a02292.html">CBSPNode2v</a> root;
00450 
00451                 <span class="comment">// Build the local array and the BSP</span>
00452                 <a class="code" href="a03100.html#NLMISC_1_1CPolygona10">toConvexPolygonsLocalAndBSP</a> (localVertices, root, basis);
00453 
00454                 <span class="comment">// Build a vertex list</span>
00455                 std::list&lt;uint&gt; vertexList;
00456                 <a class="code" href="a04558.html#a15">uint</a> i;
00457                 <span class="keywordflow">for</span> (i=0; i&lt;<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size(); i++)
00458                         vertexList.push_back (i);
00459 
00460                 <span class="comment">// Clip ears while there is some polygons</span>
00461                 std::list&lt;uint&gt;::iterator current=vertexList.begin();
00462                 std::list&lt;uint&gt;::iterator begin=vertexList.begin();
00463                 <span class="keywordflow">do</span>
00464                 {
00465 again:;
00466                         <span class="comment">// Search for a diagonal</span>
00467                         <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;
00468 
00469                         <span class="comment">// Get next vertex</span>
00470                         std::list&lt;uint&gt;::iterator first = current;
00471                         std::list&lt;uint&gt;::iterator lastPreviousPrevious=current;
00472                         std::list&lt;uint&gt;::iterator lastPrevious=current;
00473                         lastPrevious++;
00474                         <span class="keywordflow">if</span> (lastPrevious==vertexList.end())
00475                                 lastPrevious = vertexList.begin();
00476                         std::list&lt;uint&gt;::iterator currentNext = lastPrevious;
00477                         std::list&lt;uint&gt;::iterator last = lastPrevious;
00478                         last++;
00479                         <span class="keywordflow">if</span> (last==vertexList.end())
00480                                 last = vertexList.begin();
00481                         <span class="keywordflow">while</span> (last != current)
00482                         {
00483                                 <span class="comment">// Is a diagonal ?</span>
00484                                 <span class="keywordflow">if</span> ( 
00485                                         (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *lastPreviousPrevious, *last)) &amp;&amp;
00486                                         (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *currentNext, *last)) &amp;&amp;
00487                                         (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *last, *current)) 
00488                                         )
00489                                 {
00490                                         <span class="comment">// Find one</span>
00491                                         found = <span class="keyword">true</span>;
00492                                 }
00493                                 <span class="keywordflow">else</span>
00494                                 {
00495                                         <span class="comment">// Come back</span>
00496                                         last = lastPrevious;
00497                                         lastPrevious = lastPreviousPrevious;
00498                                         <span class="keywordflow">break</span>;
00499                                 }
00500 
00501                                 <span class="comment">// Next vertex</span>
00502                                 lastPreviousPrevious = lastPrevious;
00503                                 lastPrevious = last++;
00504                                 <span class="keywordflow">if</span> (last==vertexList.end())
00505                                         last = vertexList.begin();
00506                         }
00507 
00508                         <span class="comment">// Last polygon ?</span>
00509                         <span class="keywordflow">if</span> (last==current)
00510                         {
00511                                 <span class="comment">// Add a polygon</span>
00512                                 outputPolygons.push_back (<a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a>());
00513                                 <a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> &amp;back = outputPolygons.back ();
00514                                 back.Vertices.reserve (vertexList.size());
00515 
00516                                 <span class="comment">// Add each vertex in the new polygon</span>
00517                                 current=vertexList.begin();
00518                                 <span class="keywordflow">while</span> (current!=vertexList.end())
00519                                 {
00520                                         back.Vertices.push_back (Vertices[*current]);
00521                                         current++;
00522                                 }
00523 
00524                                 <span class="comment">// Exit</span>
00525                                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00526                         }
00527                         <span class="keywordflow">else</span>
00528                         {
00529                                 std::list&lt;uint&gt;::iterator firstNext = current;
00530                                 std::list&lt;uint&gt;::iterator firstNextNext = currentNext;
00531                                 <span class="keywordflow">if</span> (first != vertexList.begin())
00532                                         first--;
00533                                 <span class="keywordflow">else</span>
00534                                 {
00535                                         first = vertexList.end();
00536                                         first--;
00537                                 }
00538 
00539                                 <span class="keywordflow">while</span> (current != first)
00540                                 {
00541                                         <span class="comment">// Is a diagonal ?</span>
00542                                         <span class="keywordflow">if</span> (
00543                                                 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *firstNextNext, *first)) &amp;&amp;
00544                                                 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *lastPrevious, *first)) &amp;&amp;
00545                                                 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *last, *first)) 
00546                                                 )
00547                                         {
00548                                                 <span class="comment">// Find one</span>
00549                                                 found = <span class="keyword">true</span>;
00550                                         }
00551                                         <span class="keywordflow">else</span>
00552                                         {
00553                                                 <span class="comment">// Come back</span>
00554                                                 first = firstNext;
00555                                                 <span class="keywordflow">break</span>;
00556                                         }
00557 
00558                                         <span class="comment">// Next vertex</span>
00559                                         firstNextNext = firstNext;
00560                                         firstNext = first;
00561                                         <span class="keywordflow">if</span> (first==vertexList.begin())
00562                                         {
00563                                                 first = vertexList.end();
00564                                                 first--;
00565                                         }
00566                                         <span class="keywordflow">else</span>
00567                                                 first--;
00568                                 }
00569                         }
00570 
00571                         <span class="comment">// Found ?</span>
00572                         <span class="keywordflow">if</span> (found)
00573                         {
00574                                 <span class="comment">// Count vertex</span>
00575                                 outputPolygons.push_back (<a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a>());
00576                                 <a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> &amp;back = outputPolygons.back ();
00577 
00578                                 <span class="comment">// Vertex count</span>
00579                                 <a class="code" href="a04558.html#a15">uint</a> vertexCount = 1;
00580                                 current = first;
00581                                 <span class="keywordflow">while</span> (current != last)
00582                                 {
00583                                         vertexCount++;
00584                                         current++;
00585                                         <span class="keywordflow">if</span> (current == vertexList.end())
00586                                                 current = vertexList.begin();
00587                                 }
00588 
00589                                 <span class="comment">// Alloc vertices</span>
00590                                 back.Vertices.reserve (vertexCount);
00591 
00592                                 <span class="comment">// Copy and remove vertices</span>
00593                                 back.Vertices.push_back (Vertices[*first]);
00594                                 first++;
00595                                 <span class="keywordflow">if</span> (first == vertexList.end())
00596                                         first = vertexList.begin();
00597                                 <span class="keywordflow">while</span> (first != last)
00598                                 {
00599                                         back.Vertices.push_back (Vertices[*first]);
00600 
00601                                         <span class="comment">// Remove from list</span>
00602                                         first = vertexList.erase (first);
00603                                         <span class="keywordflow">if</span> (first == vertexList.end())
00604                                                 first = vertexList.begin();
00605                                         <a class="code" href="a04199.html#a6">nlassert</a> (first != vertexList.end());
00606                                 }
00607                                 back.Vertices.push_back (Vertices[*first]);
00608                                 current = begin = last;
00609                                 <span class="keywordflow">goto</span> again;
00610                         }
00611 
00612                         <span class="comment">// Next current</span>
00613                         current++;
00614                         <span class="keywordflow">if</span> (current == vertexList.end())
00615                                 current = vertexList.begin ();
00616                 }
00617                 <span class="keywordflow">while</span> (current != begin);
00618         }
00619         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00620 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygone0" doxytag="NLMISC::CPolygon::toConvexPolygonsDiagonal" ></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::CPolygon::toConvexPolygonsDiagonal </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>vertex</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a02292.html">CBSPNode2v</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>bsp</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>&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><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>b</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</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="a06190.html#l00375">375</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l00299">NLMISC::CBSPNode2v::intersect()</a>, <a class="el" href="a06190.html#l00351">toConvexPolygonsInCone()</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00440">toConvexPolygons()</a>.
<p>
<div class="fragment"><pre>00376 {
00377         <span class="comment">// Check it is a border</span>
00378         <span class="keywordflow">if</span> ( ( (b - a) == 1) || ( (a - b) == 1) || ( (a==0) &amp;&amp; (b ==(vertex.size()-1))) || ( (b==0) &amp;&amp; (a ==(vertex.size()-1))) )
00379                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00380 
00381         <span class="comment">// Check visibility</span>
00382         <span class="keywordflow">if</span> (<a class="code" href="a03100.html#NLMISC_1_1CPolygone2">toConvexPolygonsInCone</a> (vertex, a, b) &amp;&amp; <a class="code" href="a03100.html#NLMISC_1_1CPolygone2">toConvexPolygonsInCone</a> (vertex, b, a))
00383         {
00384                 <span class="comment">// Intersection ?</span>
00385                 <span class="keywordflow">return</span> !bsp.<a class="code" href="a02292.html#NLMISC_1_1CBSPNode2va3">intersect</a> (vertex[a], vertex[b], a, b);
00386         }
00387         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00388 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygone1" doxytag="NLMISC::CPolygon::toConvexPolygonsEdgeIntersect" ></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::CPolygon::toConvexPolygonsEdgeIntersect </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="mdname" nowrap> <em>a0</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a03660.html">CVector2f</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>a1</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a03660.html">CVector2f</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>b0</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a03660.html">CVector2f</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>b1</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</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="a06190.html#l00177">177</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <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>00178 {
00179         <span class="keywordtype">float</span> Aa = (a0.y - a1.y) / (a0.x - a1.x);
00180         <span class="keywordtype">float</span> Ba = a0.y - a0.x * Aa;
00181         <span class="keywordtype">float</span> Ab = (b0.y - b1.y) / (b0.x - b1.x);
00182         <span class="keywordtype">float</span> Bb = b0.y - b0.x * Ab;
00183 
00184         <span class="comment">// Intersection </span>
00185         CVector2f intersection;
00186         intersection.x = (Bb - Ba) / (Aa - Ab);
00187         intersection.y = Aa * intersection.x + Ba;
00188 
00189         <span class="comment">// In it ?</span>
00190         <span class="keywordflow">return</span> ( ( (a0-intersection)*(a1-intersection) &lt; 0 ) &amp;&amp; ( (b0-intersection)*(b1-intersection) &lt; 0 ) );
00191 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygone2" doxytag="NLMISC::CPolygon::toConvexPolygonsInCone" ></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::CPolygon::toConvexPolygonsInCone </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>vertex</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>&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><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>b</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</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="a06190.html#l00351">351</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l00337">toConvexPolygonsLeft()</a>, <a class="el" href="a06190.html#l00344">toConvexPolygonsLeftOn()</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00375">toConvexPolygonsDiagonal()</a>.
<p>
<div class="fragment"><pre>00352 {
00353         <span class="comment">// Prev and next</span>
00354         <a class="code" href="a04558.html#a15">uint</a> a0 = a+1;
00355         <span class="keywordflow">if</span> (a0==vertex.size())
00356                 a0=0;
00357         <a class="code" href="a04558.html#a15">uint</a> a1;
00358         <span class="keywordflow">if</span> (a==0)
00359                 a1=vertex.size()-1;
00360         <span class="keywordflow">else</span>
00361                 a1= a-1;
00362 
00363         <span class="keywordflow">if</span> (<a class="code" href="a03100.html#NLMISC_1_1CPolygone4">toConvexPolygonsLeftOn</a> (vertex, a, a1, a0) )
00364         {
00365                 <span class="keywordflow">return</span> <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, a, b, a0) &amp;&amp; <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, b, a, a1);
00366         }
00367         <span class="keywordflow">else</span>
00368         {
00369                 <span class="keywordflow">return</span> !( <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, a, b, a1) &amp;&amp; <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, b, a, a0) );
00370         }
00371 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygone3" doxytag="NLMISC::CPolygon::toConvexPolygonsLeft" ></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::CPolygon::toConvexPolygonsLeft </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>vertex</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>&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><a class="el" href="a04558.html#a15">uint</a>&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><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>c</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</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="a06190.html#l00337">337</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00351">toConvexPolygonsInCone()</a>.
<p>
<div class="fragment"><pre>00338 {
00339         <span class="keywordflow">return</span> ( (vertex[b].x - vertex[a].x) * (vertex[c].y - vertex[a].y) - (vertex[c].x - vertex[a].x) * (vertex[b].y - vertex[a].y) ) &lt; 0;
00340 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygone4" doxytag="NLMISC::CPolygon::toConvexPolygonsLeftOn" ></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::CPolygon::toConvexPolygonsLeftOn </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>vertex</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>&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><a class="el" href="a04558.html#a15">uint</a>&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><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>c</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</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="a06190.html#l00344">344</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06190.html#l00351">toConvexPolygonsInCone()</a>.
<p>
<div class="fragment"><pre>00345 {
00346         <span class="keywordflow">return</span> ( (vertex[b].x - vertex[a].x) * (vertex[c].y - vertex[a].y) - (vertex[c].x - vertex[a].x) * (vertex[b].y - vertex[a].y) ) &lt;= 0;
00347 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CPolygona10" doxytag="NLMISC::CPolygon::toConvexPolygonsLocalAndBSP" ></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::CPolygon::toConvexPolygonsLocalAndBSP </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>localVertices</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a02292.html">CBSPNode2v</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>root</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>basis</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>

<p>
Definition at line <a class="el" href="a06190.html#l00392">392</a> of file <a class="el" href="a06190.html">polygon.cpp</a>.
<p>
References <a class="el" href="a06190.html#l00219">NLMISC::CBSPNode2v::insert()</a>, <a class="el" href="a05972.html#l00914">NLMISC::CMatrix::invert()</a>, <a class="el" href="a06170.html#l00036">NLMISC::CPlane::make()</a>, <a class="el" href="a06190.html#l00173">NLMISC::TCConcavePolygonsVertexMap</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>
Referenced by <a class="el" href="a06190.html#l00624">chain()</a>, and <a class="el" href="a06190.html#l00440">toConvexPolygons()</a>.
<p>
<div class="fragment"><pre>00393 {
00394         <span class="comment">// Invert matrix</span>
00395         <a class="code" href="a02851.html">CMatrix</a> invert = basis;
00396         invert.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1967_0">invert</a> ();
00397 
00398         <span class="comment">// Insert vertices in an ordered table</span>
00399         <a class="code" href="a04558.html#a15">uint</a> vertexCount = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size();
00400         <a class="code" href="a05378.html#a33">TCConcavePolygonsVertexMap</a> vertexMap;
00401         localVertices.resize (vertexCount);
00402         <a class="code" href="a04558.html#a15">uint</a> i, j;
00403         
00404         <span class="comment">// Transform the vertex</span>
00405         <span class="keywordflow">for</span> (i=0; i&lt;vertexCount; i++)
00406         {
00407                 CVector local = invert*<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>[i];
00408                 localVertices[i] = CVector (local.x, local.y, 0);
00409         }
00410 
00411         <span class="comment">// Plane direction</span>
00412         i=0;
00413         j=<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size()-1;
00414         CVector normal = localVertices[i] - localVertices[j];
00415         normal = normal ^ CVector::K;
00416         CPlane clipPlane;
00417         clipPlane.make(normal, localVertices[i]);
00418 
00419         <span class="comment">// Build the BSP root</span>
00420         root = <a class="code" href="a02292.html">CBSPNode2v</a> (clipPlane, localVertices[i], localVertices[j], i, j);
00421 
00422         <span class="comment">// Insert all others edges</span>
00423         j=i++;
00424         <span class="keywordflow">for</span> (; i&lt;<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size(); i++)
00425         {
00426                 <span class="comment">// Plane direction</span>
00427                 normal = localVertices[i] - localVertices[j];
00428                 normal = normal ^ CVector::K;
00429                 clipPlane.make(normal, localVertices[i]);
00430 
00431                 <span class="comment">// Build the BSP root</span>
00432                 root.<a class="code" href="a02292.html#NLMISC_1_1CBSPNode2va2">insert</a> ( <span class="keyword">new</span> CBSPNode2v (clipPlane, localVertices[i], localVertices[j], i, j) );
00433 
00434                 j=i;
00435         }
00436 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NLMISC_1_1CPolygono0" doxytag="NLMISC::CPolygon::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"> std::vector&lt;<a class="el" href="a03128.html">CVector</a>&gt; <a class="el" href="a03100.html#NLMISC_1_1CPolygono0">NLMISC::CPolygon::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#l00055">55</a> of file <a class="el" href="a06191.html">polygon.h</a>.
<p>
Referenced by <a class="el" href="a05929.html#l00714">NLPACS::CLocalRetriever::build3dSurfacePolygons()</a>, <a class="el" href="a05929.html#l00655">NLPACS::CLocalRetriever::buildSurfacePolygons()</a>, <a class="el" href="a06190.html#l00624">chain()</a>, <a class="el" href="a06737.html#l01130">NL3D::CWaterModel::clip()</a>, <a class="el" href="a06193.html#l00083">NL3D::CPortal::clipPyramid()</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="a06350.html#l01224">NL3D::CInstanceGroup::displayDebugClusters()</a>, <a class="el" href="a06737.html#l01170">NL3D::CWaterModel::doSimpleRender()</a>, <a class="el" href="a06737.html#l00387">NL3D::DrawPoly2D()</a>, <a class="el" href="a06741.html#l00609">NL3D::CWaterShape::getShapeInWorldSpace()</a>, <a class="el" href="a06768.html#l02927">NL3D::CZoneLighter::lightWater()</a>, <a class="el" href="a06190.html#l00440">toConvexPolygons()</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:27:57 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>