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
|
<!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: NLLIGO::CZoneTemplate 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 Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NLLIGO::CZoneTemplate Class Reference</h1><code>#include <<a class="el" href="a06781.html">zone_template.h</a>></code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Ligo zone template<p>
<dl compact><dt><b>Author:</b></dt><dd>Cyril 'Hulud' Corvazier <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2001 </dd></dl>
<p>
<p>
Definition at line <a class="el" href="a06781.html#l00049">49</a> of file <a class="el" href="a06781.html">zone_template.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>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplatea0">build</a> (const std::vector< <a class="el" href="a03128.html">NLMISC::CVector</a> > &vertices, const std::vector< std::pair< <a class="el" href="a04558.html#a15">uint</a>, <a class="el" href="a04558.html#a15">uint</a> > > &indexes, const <a class="el" href="a02756.html">CLigoConfig</a> &config, <a class="el" href="a02757.html">CLigoError</a> &errors)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const std::vector< <a class="el" href="a03737.html">CZoneEdge</a> > & </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplatea1">getEdges</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get the vertex array of the template. <a href="#NLLIGO_1_1CZoneTemplatea1"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplatea2">getMask</a> (std::vector< bool > &mask, <a class="el" href="a04558.html#a15">uint</a> &<a class="el" href="a04223.html#a632">width</a>, <a class="el" href="a04558.html#a15">uint</a> &<a class="el" href="a04223.html#a633">height</a>)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get the mask of the template. <a href="#NLLIGO_1_1CZoneTemplatea2"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplatea3">serial</a> (<a class="el" href="a02270.html">NLMISC::IStream</a> &<a class="el" href="a04223.html#a626">s</a>)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Serialisation. <a href="#NLLIGO_1_1CZoneTemplatea3"></a><br><br></td></tr>
<tr><td colspan=2><br><h2>Static Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a10">sint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (float <a class="el" href="a04223.html#a658">value</a>, float resolution, float snap)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the interger index of a snappable value. <a href="#NLLIGO_1_1CZoneTemplateh0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplateh1">isSnapedOnGrid</a> (float <a class="el" href="a04223.html#a658">value</a>, float resolution, float snap)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return true if this value is snapped. <a href="#NLLIGO_1_1CZoneTemplateh1"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplateh2">snap</a> (float &<a class="el" href="a04223.html#a658">value</a>, float snap)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Round a value on the snap resolution. <a href="#NLLIGO_1_1CZoneTemplateh2"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplateh3">snapOnGrid</a> (float &<a class="el" href="a04223.html#a658">value</a>, float resolution, float snap)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Snap a value on the grid. <a href="#NLLIGO_1_1CZoneTemplateh3"></a><br><br></td></tr>
<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a03737.html">CZoneEdge</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Vertex array. <a href="#NLLIGO_1_1CZoneTemplater0"></a><br><br></td></tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NLLIGO_1_1CZoneTemplatea0" doxytag="NLLIGO::CZoneTemplate::build" ></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 NLLIGO::CZoneTemplate::build </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const std::vector< <a class="el" href="a03128.html">NLMISC::CVector</a> > & </td>
<td class="mdname" nowrap> <em>vertices</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const std::vector< std::pair< <a class="el" href="a04558.html#a15">uint</a>, <a class="el" href="a04558.html#a15">uint</a> > > & </td>
<td class="mdname" nowrap> <em>indexes</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const <a class="el" href="a02756.html">CLigoConfig</a> & </td>
<td class="mdname" nowrap> <em>config</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap><a class="el" href="a02757.html">CLigoError</a> & </td>
<td class="mdname" nowrap> <em>errors</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Build method. Build the zone template with a vertex list and an edge list.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign=top><em>vertices</em> </td><td>is the vertex array </td></tr>
<tr><td valign=top><em>indexes</em> </td><td>is the edge array </td></tr>
<tr><td valign=top><em>config</em> </td><td>is the current lingo config file </td></tr>
<tr><td valign=top><em>errors</em> </td><td>is the error structure </td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>true if the build success, else return false</dd></dl>
<p>
Definition at line <a class="el" href="a06780.html#l00107">107</a> of file <a class="el" href="a06780.html">zone_template.cpp</a>.
<p>
References <a class="el" href="a06781.html#l00088">_Edges</a>, <a class="el" href="a05904.html#l00069">NLLIGO::CLigoConfig::CellSize</a>, <a class="el" href="a05905.html#l00080">NLLIGO::CLigoError::clear()</a>, <a class="el" href="a06780.html#l00093">getSnappedIndex()</a>, <a class="el" href="a06780.html#l00084">isSnapedOnGrid()</a>, <a class="el" href="a05906.html#l00124">NLLIGO::CLigoError::MainError</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05587.html#l00079">NLMISC::Pi</a>, <a class="el" href="a05905.html#l00040">NLLIGO::CLigoError::pushVertexError()</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a05904.html#l00072">NLLIGO::CLigoConfig::Snap</a>, <a class="el" href="a06780.html#l00039">NLLIGO::SnappedXFlag</a>, <a class="el" href="a06780.html#l00040">NLLIGO::SnappedYFlag</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>00108 {
00109 <span class="comment">// Clear the error message</span>
00110 errors.clear ();
00111
00112 <span class="comment">// Make an boundary flag array</span>
00113 vector<uint> boundaryFlags;
00114
00115 <span class="comment">// Vertices count</span>
00116 <a class="code" href="a04558.html#a15">uint</a> vertexCount = vertices.size();
00117
00118 <span class="comment">// Resize the array</span>
00119 boundaryFlags.resize (vertexCount, 0);
00120
00121 <span class="comment">// *** Build the flag array and the snapped vertex array</span>
00122
00123 <span class="comment">// For each vertices</span>
00124 <a class="code" href="a04558.html#a15">uint</a> vertex;
00125 <span class="keywordflow">for</span> (vertex = 0; vertex < vertexCount; vertex++)
00126 {
00127 <span class="comment">// Snap the point on the X grid</span>
00128 <span class="keywordflow">if</span> (<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh1">isSnapedOnGrid</a> (vertices[vertex].<a class="code" href="a04223.html#a572">x</a>, config.CellSize, config.Snap))
00129 <span class="comment">// Flag on X</span>
00130 boundaryFlags[vertex]|=<a class="code" href="a05375.html#a0">SnappedXFlag</a>;
00131
00132 <span class="comment">// Snap the point on the Y grid</span>
00133 <span class="keywordflow">if</span> (<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh1">isSnapedOnGrid</a> (vertices[vertex].<a class="code" href="a04223.html#a573">y</a>, config.CellSize, config.Snap))
00134 <span class="comment">// Flag on Y</span>
00135 boundaryFlags[vertex]|=<a class="code" href="a05375.html#a1">SnappedYFlag</a>;
00136 }
00137
00138 <span class="comment">// *** Build the edge set</span>
00139 multimap<uint, uint> edgePair;
00140 multimap<uint, uint> edgePairReverse;
00141
00142 <span class="comment">// Index count</span>
00143 <a class="code" href="a04558.html#a15">uint</a> edgeCount = indexes.size();
00144
00145 <span class="comment">// For each vertices</span>
00146 <a class="code" href="a04558.html#a15">uint</a> edge;
00147 <span class="keywordflow">for</span> (edge = 0; edge < edgeCount; edge++)
00148 {
00149 <span class="comment">// Ref on the pair</span>
00150 <span class="keyword">const</span> pair<uint, uint> &theEdge = indexes[edge];
00151
00152 <span class="comment">// Vertex snapped ?</span>
00153 <span class="keywordflow">if</span> ( boundaryFlags[theEdge.first] && boundaryFlags[theEdge.second] )
00154 {
00155 <span class="comment">// Common coordinates</span>
00156 <a class="code" href="a04558.html#a15">uint</a> common = boundaryFlags[theEdge.first] & boundaryFlags[theEdge.second];
00157
00158 <span class="comment">// Snapped on the same kind of coordinates ?</span>
00159 <span class="keywordflow">if</span> ( common )
00160 {
00161 <span class="comment">// Keep this edge ?</span>
00162 <span class="keywordtype">bool</span> keep = <span class="keyword">false</span>;
00163
00164 <span class="comment">// Snapped both on X ?</span>
00165 <span class="keywordflow">if</span> ( common & <a class="code" href="a05375.html#a0">SnappedXFlag</a> )
00166 {
00167 <span class="comment">// Keep it</span>
00168 keep = <span class="keyword">true</span>;
00169 }
00170
00171 <span class="comment">// Snapped both on X ?</span>
00172 <span class="keywordflow">if</span> ( common & <a class="code" href="a05375.html#a1">SnappedYFlag</a> )
00173 {
00174 <span class="comment">// Keep it</span>
00175 keep = <span class="keyword">true</span>;
00176 }
00177
00178 <span class="comment">// Keep this edge ?</span>
00179 <span class="keywordflow">if</span> (keep)
00180 {
00181 <span class="comment">// Already inserted ?</span>
00182 <span class="keywordtype">bool</span> first = edgePair.find (theEdge.first) != edgePair.end();
00183 <span class="keywordtype">bool</span> second = edgePairReverse.find (theEdge.second) != edgePairReverse.end();
00184
00185 <span class="comment">// First already inserted</span>
00186 <span class="keywordflow">if</span> (first || second)
00187 {
00188 <span class="comment">// Error, two times the same vertex</span>
00189 errors.MainError = CLigoError::VertexAlreadyUsed;
00190
00191 <span class="keywordflow">if</span> (first)
00192 errors.pushVertexError (CLigoError::VertexAlreadyUsed, theEdge.first, 0);
00193
00194 <span class="keywordflow">if</span> (second)
00195 errors.pushVertexError (CLigoError::VertexAlreadyUsed, theEdge.second, 0);
00196
00197 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00198 }
00199
00200 <span class="keywordflow">if</span> ((!first) && (!second))
00201 {
00202 <span class="comment">// Add to the map</span>
00203 edgePair.insert (map<uint, uint>::value_type(theEdge.first, theEdge.second));
00204 edgePairReverse.insert (map<uint, uint>::value_type(theEdge.second, theEdge.first));
00205 }
00206 }
00207 }
00208 }
00209 }
00210
00211 <span class="comment">// *** Build the list of non included vertices</span>
00212
00213 <span class="comment">// For each vertices</span>
00214 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<vertexCount; i++)
00215 {
00216 <span class="comment">// Vertex is inserted ?</span>
00217 <span class="keywordflow">if</span> (edgePair.find (i) == edgePair.end())
00218 {
00219 <span class="comment">// No, add an error message</span>
00220 errors.pushVertexError (CLigoError::NotInserted, i, 0);
00221 }
00222 <span class="keywordflow">else</span>
00223 {
00224 <span class="comment">// No, add an error message</span>
00225 errors.pushVertexError (CLigoError::Inserted, i, 0);
00226 }
00227 }
00228
00229 <span class="comment">// *** Build the linked list</span>
00230
00231 <span class="comment">// No vertices found ?</span>
00232 <span class="keywordflow">if</span> (edgePair.begin() == edgePair.end())
00233 {
00234 <span class="comment">// Error message</span>
00235 errors.MainError = CLigoError::NoEdgeVertices;
00236 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00237 }
00238
00239 <span class="comment">// Build the linked segments</span>
00240 <a class="code" href="a03889.html">list<list<uint></a> > segmentList;
00241 multimap<uint, uint>::iterator currentVert = edgePair.begin();
00242
00243 <span class="comment">// For each remaining segment</span>
00244 <span class="keywordflow">while</span> (currentVert != edgePair.end())
00245 {
00246 <span class="comment">// Get next vert</span>
00247 <a class="code" href="a04558.html#a15">uint</a> first = currentVert->first;
00248 <a class="code" href="a04558.html#a15">uint</a> next = currentVert->second;
00249
00250 <span class="comment">// New list</span>
00251 segmentList.push_front (<a class="code" href="a03889.html">list<uint></a>());
00252 <a class="code" href="a03889.html">list<uint></a> &listVert = *segmentList.begin();
00253
00254 <span class="comment">// Put the first vertices of the edge list</span>
00255 listVert.push_back (first);
00256 listVert.push_back (next);
00257
00258 <span class="comment">// Erase it and</span>
00259 edgePair.erase (currentVert);
00260
00261 <span class="comment">// Erase the reverse one</span>
00262 currentVert = edgePairReverse.find (next);
00263 <a class="code" href="a04199.html#a6">nlassert</a> (currentVert != edgePairReverse.end());
00264 edgePairReverse.erase (currentVert);
00265
00266 <span class="comment">// Look forward</span>
00267 currentVert = edgePair.find (next);
00268 <span class="keywordflow">while</span> (currentVert != edgePair.end())
00269 {
00270 <span class="comment">// Backup</span>
00271 <span class="comment">//uint current = currentVert->first;</span>
00272 next = currentVert->second;
00273
00274 <span class="comment">// Push the next vertex</span>
00275 listVert.push_back (next);
00276
00277 <span class="comment">// Erase it and</span>
00278 edgePair.erase (currentVert);
00279
00280 <span class="comment">// Erase the reverse one</span>
00281 currentVert = edgePairReverse.find (next);
00282 <a class="code" href="a04199.html#a6">nlassert</a> (currentVert != edgePairReverse.end());
00283 edgePairReverse.erase (currentVert);
00284
00285 <span class="comment">// Look forward</span>
00286 currentVert = edgePair.find (next);
00287 }
00288
00289 <span class="comment">// Edgelist ok ?</span>
00290 <span class="keywordflow">if</span> (next != first)
00291 {
00292 <span class="comment">// No, look backward</span>
00293 currentVert = edgePairReverse.find (first);
00294 <span class="keywordflow">while</span> (currentVert != edgePairReverse.end())
00295 {
00296 <span class="comment">// Backup</span>
00297 <a class="code" href="a04558.html#a15">uint</a> current = currentVert->second;
00298 next = currentVert->first;
00299
00300 <span class="comment">// Push the next vertex</span>
00301 listVert.push_front (current);
00302
00303 <span class="comment">// Erase it</span>
00304 edgePairReverse.erase (currentVert);
00305
00306 <span class="comment">// Erase the reverse one</span>
00307 currentVert = edgePair.find (current);
00308 <a class="code" href="a04199.html#a6">nlassert</a> (currentVert != edgePair.end());
00309 edgePair.erase (currentVert);
00310
00311 <span class="comment">// Look forward</span>
00312 currentVert = edgePairReverse.find (current);
00313 }
00314 }
00315
00316 <span class="comment">// Next edge list</span>
00317 currentVert = edgePair.begin();
00318 }
00319
00320 <span class="comment">// ** Error traitment</span>
00321
00322 <span class="comment">// Ok</span>
00323 <span class="keywordtype">bool</span> ok = <span class="keyword">true</span>;
00324
00325 <span class="comment">// Edge index</span>
00326 <a class="code" href="a04558.html#a15">uint</a> edgeIndex = 0;
00327
00328 <span class="comment">// List ok ?</span>
00329 <a class="code" href="a03889.html">list<list<uint></a> >::iterator iteList = segmentList.begin ();
00330 <span class="keywordflow">while</span> (iteList != segmentList.end())
00331 {
00332 <span class="comment">// Only one list</span>
00333 <a class="code" href="a03889.html">list<uint></a> &listVert = *iteList;
00334
00335 <span class="comment">// First and last edge</span>
00336 <a class="code" href="a04558.html#a15">uint</a> first = *listVert.begin();
00337 <a class="code" href="a04558.html#a15">uint</a> last = *(--listVert.end());
00338
00339 <span class="comment">// Opened edge ?</span>
00340 <span class="keywordflow">if</span> ( first != last )
00341 {
00342 <span class="comment">// Opened edge</span>
00343 errors.pushVertexError (CLigoError::OpenedEdge, first, edgeIndex);
00344 errors.pushVertexError (CLigoError::OpenedEdge, last, edgeIndex);
00345
00346 <span class="comment">// Main error</span>
00347 errors.MainError = CLigoError::OpenedEdge;
00348
00349 <span class="comment">// Not ko</span>
00350 ok = <span class="keyword">false</span>;
00351 }
00352
00353 <span class="comment">// Next edge list</span>
00354 edgeIndex++;
00355 iteList++;
00356 }
00357
00358 <span class="keywordflow">if</span> (segmentList.size () > 1)
00359 {
00360 <span class="comment">// Main error</span>
00361 errors.MainError = CLigoError::MultipleEdge;
00362
00363 <span class="comment">// Not ok</span>
00364 ok = <span class="keyword">false</span>;
00365 }
00366
00367 <span class="comment">// Ok ?</span>
00368 <span class="keywordflow">if</span> (ok)
00369 {
00370 <span class="comment">// Only one list</span>
00371 <a class="code" href="a03889.html">list<uint></a> &listVert = *segmentList.begin ();
00372
00373 <span class="comment">// Test vertex enchainement</span>
00374 <a class="code" href="a03889.html">list<uint></a>::iterator vertIte = listVert.begin();
00375
00376 <span class="comment">// Current vertex id</span>
00377 <a class="code" href="a04558.html#a15">uint</a> previous = *(--listVert.end());
00378 vertIte++;
00379
00380 <span class="comment">// Error vertex set</span>
00381 set<uint> errored;
00382
00383 <span class="comment">// For each vertices</span>
00384 <span class="keywordflow">while</span> (vertIte != listVert.end ())
00385 {
00386 <span class="comment">// Vertex id</span>
00387 <a class="code" href="a04558.html#a15">uint</a> next = *vertIte;
00388
00389 <span class="comment">// Common flags</span>
00390 <a class="code" href="a04558.html#a15">uint</a> commonFlags = boundaryFlags[previous]&boundaryFlags[next];
00391
00392 <span class="comment">// The both on X ?</span>
00393 <span class="keywordflow">if</span> ( commonFlags & <a class="code" href="a05375.html#a0">SnappedXFlag</a> )
00394 {
00395 <span class="comment">// Get x index</span>
00396 <a class="code" href="a04558.html#a10">sint32</a> prevIndex = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (vertices[previous].<a class="code" href="a04223.html#a572">x</a>, config.CellSize, config.Snap);
00397 <a class="code" href="a04558.html#a10">sint32</a> nextIndex = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (vertices[next].<a class="code" href="a04223.html#a572">x</a>, config.CellSize, config.Snap);
00398
00399 <span class="comment">// Not the same ?</span>
00400 <span class="keywordflow">if</span> (prevIndex != nextIndex)
00401 {
00402 <span class="comment">// Vertex list error</span>
00403 <span class="keywordflow">if</span> (errored.insert (previous).second)
00404 errors.pushVertexError (CLigoError::VertexList, previous, 0);
00405 <span class="keywordflow">if</span> (errored.insert (next).second)
00406 errors.pushVertexError (CLigoError::VertexList, next, 0);
00407
00408 <span class="comment">// Main error</span>
00409 errors.MainError = CLigoError::VertexList;
00410 }
00411 }
00412
00413 <span class="comment">// Next vertex</span>
00414 previous = next;
00415 vertIte++;
00416 }
00417
00418 <span class="comment">// No error ?</span>
00419 <span class="keywordflow">if</span> (errored.empty())
00420 {
00421 <span class="comment">// Only one list</span>
00422 <a class="code" href="a04199.html#a6">nlassert</a> (segmentList.size()==1);
00423
00424 <span class="comment">// First of the list</span>
00425 vertIte = listVert.begin();
00426
00427 <span class="comment">// Remove first</span>
00428 listVert.erase (vertIte);
00429
00430 <span class="comment">// Find a corner</span>
00431 <a class="code" href="a03889.html">list<uint></a>::iterator firstIte = listVert.begin();
00432 <span class="keywordflow">while</span> (firstIte != listVert.end())
00433 {
00434 <span class="comment">// Corner ?</span>
00435 <span class="keywordflow">if</span> ( (boundaryFlags[*firstIte] & (<a class="code" href="a05375.html#a0">SnappedXFlag</a>|<a class="code" href="a05375.html#a1">SnappedYFlag</a>)) == (<a class="code" href="a05375.html#a0">SnappedXFlag</a>|<a class="code" href="a05375.html#a1">SnappedYFlag</a>) )
00436 <span class="comment">// Yes, exit</span>
00437 <span class="keywordflow">break</span>;
00438
00439 <span class="comment">// Next </span>
00440 firstIte++;
00441 }
00442
00443 <span class="comment">// Can't be the last</span>
00444 <span class="keywordflow">if</span> (firstIte == listVert.end())
00445 {
00446 <span class="comment">// No corner found</span>
00447 errors.MainError = CLigoError::NoCornerFound;
00448
00449 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00450 }
00451
00452 <span class="comment">// First of the segment</span>
00453 vertIte = firstIte;
00454
00455 <span class="comment">// Current edge list</span>
00456 std::vector<uint32> edge;
00457
00458 <span class="comment">// Push the first</span>
00459 edge.push_back (*vertIte);
00460
00461 <span class="comment">// Next </span>
00462 vertIte++;
00463
00464 <span class="comment">// End ?</span>
00465 <span class="keywordflow">if</span> (vertIte == listVert.end())
00466 <span class="comment">// Start</span>
00467 vertIte = listVert.begin();
00468
00469 <span class="comment">// Edge index</span>
00470 <a class="code" href="a04558.html#a15">uint</a> edgeIndex = 0;
00471
00472 <span class="comment">// Build the edges</span>
00473 <span class="keywordflow">while</span> (1)
00474 {
00475 <span class="comment">// Add it</span>
00476 edge.push_back (*vertIte);
00477
00478 <span class="comment">// Corner ?</span>
00479 <span class="keywordflow">if</span> ( (boundaryFlags[*vertIte] & (<a class="code" href="a05375.html#a0">SnappedXFlag</a>|<a class="code" href="a05375.html#a1">SnappedYFlag</a>)) == (<a class="code" href="a05375.html#a0">SnappedXFlag</a>|<a class="code" href="a05375.html#a1">SnappedYFlag</a>) )
00480 {
00481 <span class="comment">// Get the index of start and end of the edge</span>
00482 <a class="code" href="a04558.html#a10">sint32</a> startX = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (vertices[edge[0]].<a class="code" href="a04223.html#a572">x</a>, config.CellSize, config.Snap);
00483 <a class="code" href="a04558.html#a10">sint32</a> startY = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (vertices[edge[0]].<a class="code" href="a04223.html#a573">y</a>, config.CellSize, config.Snap);
00484 <a class="code" href="a04558.html#a10">sint32</a> endX = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (vertices[edge[edge.size()-1]].x, config.CellSize, config.Snap);
00485 <a class="code" href="a04558.html#a10">sint32</a> endY = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (vertices[edge[edge.size()-1]].y, config.CellSize, config.Snap);
00486
00487 <span class="comment">// Same point ?</span>
00488 <span class="keywordflow">if</span> ((startX==endX) && (startY==endY))
00489 {
00490 <span class="comment">// Error, two times the same vertex</span>
00491 errors.MainError = CLigoError::TwoCornerVertices;
00492 errors.pushVertexError (CLigoError::TwoCornerVertices, edge[0], 0);
00493 errors.pushVertexError (CLigoError::TwoCornerVertices, edge[edge.size()-1], 0);
00494
00495 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00496 }
00497
00498 <span class="comment">// Same point ?</span>
00499 <span class="keywordflow">if</span> ((abs(startX-endX)>1) || (abs(startY-endY)>1))
00500 {
00501 <span class="comment">// Error, two times the same vertex</span>
00502 errors.MainError = CLigoError::CornerIsMissing;
00503 errors.pushVertexError (CLigoError::CornerIsMissing, edge[0], 0);
00504 errors.pushVertexError (CLigoError::CornerIsMissing, edge[edge.size()-1], 0);
00505
00506 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00507 }
00508
00509 <span class="comment">// Get rotation</span>
00510 <a class="code" href="a04558.html#a15">uint</a> rotation = 4;
00511 <span class="keywordflow">if</span> ((endX-startX)==1)
00512 {
00513 <span class="keywordflow">if</span> ((endY-startY)==0)
00514 rotation = 0;
00515 }
00516 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((endX-startX)==-1)
00517 {
00518 <span class="keywordflow">if</span> ((endY-startY)==0)
00519 rotation = 2;
00520 }
00521 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((endX-startX)==0)
00522 {
00523 <span class="keywordflow">if</span> ((endY-startY)==1)
00524 rotation = 1;
00525 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((endY-startY)==-1)
00526 rotation = 3;
00527 }
00528
00529 <span class="comment">// Checks</span>
00530 <a class="code" href="a04199.html#a6">nlassert</a> (rotation != 4);
00531
00532 <span class="comment">// Build the vertex array</span>
00533 vector<CVector> vertexArray;
00534 vertexArray.resize (edge.size());
00535
00536 <span class="comment">// Rotate matrix</span>
00537 <a class="code" href="a02851.html">CMatrix</a> mat;
00538 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_0">identity</a>();
00539 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1965_4">rotateZ</a> ((<span class="keywordtype">float</span>)rotation * (<span class="keywordtype">float</span>)Pi / 2);
00540 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a> (CVector (vertices[edge[0]].<a class="code" href="a04223.html#a572">x</a>, vertices[edge[0]].<a class="code" href="a04223.html#a573">y</a>, 0));
00541 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1967_0">invert</a> ();
00542
00543 <span class="comment">// Rotate the array</span>
00544 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<edge.size(); i++)
00545 {
00546 <span class="comment">// Get the value on the edge</span>
00547 vertexArray[i] = mat * vertices[edge[i]];
00548 }
00549
00550 <span class="comment">// Build the edge</span>
00551 <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>.resize (edgeIndex+1);
00552
00553 <span class="comment">// It must work without errors</span>
00554 CLigoError errorBis;
00555 <span class="keywordflow">if</span> (!<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>[edgeIndex].build (vertexArray, edge, rotation, startX, startY, config, errorBis))
00556 {
00557 <span class="comment">// Flat zone</span>
00558 errors.MainError = CLigoError::FlatZone;
00559
00560 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00561 }
00562
00563 <span class="comment">// One more edge</span>
00564 edgeIndex++;
00565
00566 <span class="comment">// Exit ?</span>
00567 <span class="keywordflow">if</span> (vertIte == firstIte)
00568 <span class="keywordflow">break</span>;
00569
00570 <span class="comment">// Clear the temp edge</span>
00571 edge.clear ();
00572
00573 <span class="comment">// Push back the last vertex</span>
00574 edge.push_back (*vertIte);
00575 }
00576
00577 <span class="comment">// Next vertex</span>
00578 vertIte++;
00579
00580 <span class="comment">// End ?</span>
00581 <span class="keywordflow">if</span> (vertIte == listVert.end())
00582 <span class="comment">// Start</span>
00583 vertIte = listVert.begin();
00584 }
00585
00586 <a class="code" href="a04558.html#a10">sint32</a> bestX = 0x7fffffff;
00587 <a class="code" href="a04558.html#a10">sint32</a> bestY = 0x80000000;
00588 <a class="code" href="a04558.html#a15">uint</a> bestEdge = 0xffffffff;
00589
00590 <span class="comment">// Sort edges : the first as the lower x then greater y</span>
00591 <a class="code" href="a04558.html#a15">uint</a> edgeId;
00592 <span class="keywordflow">for</span> (edgeId=0; edgeId<<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>.size(); edgeId++)
00593 {
00594 <span class="comment">// Get the matrix</span>
00595 <a class="code" href="a02851.html">CMatrix</a> mat;
00596 <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>[edgeId].buildMatrix (mat, config);
00597
00598 <span class="comment">// First vertex</span>
00599 CVector pos = mat * <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>[edgeId].getVertex (0);
00600
00601 <span class="comment">// Get X and Y</span>
00602 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a572">x</a> = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (pos.x, config.CellSize, config.Snap);
00603 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a573">y</a> = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh0">getSnappedIndex</a> (pos.y, config.CellSize, config.Snap);
00604
00605 <span class="comment">// Best ?</span>
00606 <span class="keywordflow">if</span> ((<a class="code" href="a04223.html#a572">x<bestX)||((x==bestX)&&(y></a>bestY)))
00607 {
00608 <span class="comment">// This edgeId is best</span>
00609 bestX=<a class="code" href="a04223.html#a572">x</a>;
00610 bestY=<a class="code" href="a04223.html#a573">y</a>;
00611 bestEdge = edgeId;
00612 }
00613 }
00614
00615 <span class="comment">// Check</span>
00616 <a class="code" href="a04199.html#a6">nlassert</a> (bestEdge!=0xffffffff);
00617
00618 <span class="comment">// Reoder</span>
00619 std::vector<CZoneEdge> newEdge (<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>.size());
00620 <span class="keywordflow">for</span> (edgeId=0; edgeId<<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>.size(); edgeId++)
00621 {
00622 <span class="comment">// Copy the edge</span>
00623 newEdge[edgeId]=<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>[bestEdge++];
00624
00625 <span class="comment">// Next</span>
00626 <span class="keywordflow">if</span> (bestEdge==_Edges.size())
00627 bestEdge=0;
00628 }
00629
00630 <span class="comment">// Copy the final array</span>
00631 <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>=newEdge;
00632
00633 <span class="comment">// Return ok</span>
00634 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00635 }
00636 }
00637
00638 <span class="comment">// Errors.</span>
00639 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00640 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLLIGO_1_1CZoneTemplatea1" doxytag="NLLIGO::CZoneTemplate::getEdges" ></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 std::vector<<a class="el" href="a03737.html">CZoneEdge</a>>& NLLIGO::CZoneTemplate::getEdges </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Get the vertex array of the template.
<p>
<p>
Definition at line <a class="el" href="a06781.html#l00068">68</a> of file <a class="el" href="a06781.html">zone_template.h</a>.
<p>
References <a class="el" href="a06781.html#l00088">_Edges</a>.
<p>
Referenced by <a class="el" href="a05907.html#l00038">NLLIGO::CMaterial::build()</a>, and <a class="el" href="a06578.html#l00228">NLLIGO::CTransition::check()</a>.
<p>
<div class="fragment"><pre>00068 { <span class="keywordflow">return</span> <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>; }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLLIGO_1_1CZoneTemplatea2" doxytag="NLLIGO::CZoneTemplate::getMask" ></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 NLLIGO::CZoneTemplate::getMask </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">std::vector< bool > & </td>
<td class="mdname" nowrap> <em>mask</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> & </td>
<td class="mdname" nowrap> <em>width</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> & </td>
<td class="mdname" nowrap> <em>height</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Get the mask of the template.
<p>
<p>
Definition at line <a class="el" href="a06780.html#l00667">667</a> of file <a class="el" href="a06780.html">zone_template.cpp</a>.
<p>
References <a class="el" href="a06781.html#l00088">_Edges</a>, <a class="el" href="a05646.html#l01013">height</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, <a class="el" href="a05646.html#l01013">width</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>00668 {
00669 <span class="comment">// Some constantes</span>
00670 <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="a04558.html#a10">sint32</a> addX[4] = { 1, 0, -1, 0 };
00671 <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="a04558.html#a10">sint32</a> addY[4] = { 0, 1, 0, -1 };
00672 <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="a04558.html#a10">sint32</a> cellX[4] = { 0, -1, -1, 0 };
00673 <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="a04558.html#a10">sint32</a> cellY[4] = { 0, 0, -1, -1 };
00674 <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="a04558.html#a10">sint32</a> moveX[4] = { 0, 1, 0, -1 };
00675 <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="a04558.html#a10">sint32</a> moveY[4] = { -1, 0, 1, 0 };
00676
00677 <span class="comment">// Max</span>
00678 <a class="code" href="a04558.html#a10">sint32</a> xMax = 0x80000000;
00679 <a class="code" href="a04558.html#a10">sint32</a> yMax = 0x80000000;
00680
00681 <span class="comment">// For each edges</span>
00682 <a class="code" href="a04558.html#a15">uint</a> edges;
00683 <span class="keywordflow">for</span> (edges=0; edges<<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>.size(); edges++)
00684 {
00685 <span class="comment">// Get the rotation</span>
00686 <a class="code" href="a04558.html#a11">uint32</a> rot = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>[edges].getRotation ();
00687 <a class="code" href="a04199.html#a6">nlassert</a> (rot<4);
00688
00689 <span class="comment">// Get X and Y max coordinates</span>
00690 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a572">x</a> = _Edges[edges].getOffsetX () + addX[rot];
00691 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a573">y</a> = _Edges[edges].getOffsetY () + addY[rot];
00692
00693 <span class="comment">// Greater ?</span>
00694 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a572">x</a> > xMax)
00695 xMax = <a class="code" href="a04223.html#a572">x</a>;
00696 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a573">y</a> > yMax)
00697 yMax = <a class="code" href="a04223.html#a573">y</a>;
00698 }
00699
00700 <span class="comment">// Build the array</span>
00701 <a class="code" href="a04223.html#a632">width</a> = (<a class="code" href="a04558.html#a11">uint32</a>) xMax;
00702 <a class="code" href="a04223.html#a633">height</a> = (<a class="code" href="a04558.html#a11">uint32</a>) yMax;
00703
00704 <span class="comment">// Bit array for each cell</span>
00705 vector<uint32> edgeArray (xMax*yMax, 0);
00706
00707 <span class="comment">// Resize it</span>
00708 mask.resize (xMax*yMax, <span class="keyword">false</span>);
00709
00710 <span class="comment">// Set of the cells in the mask</span>
00711 set<pair<sint32, sint32> > setCell;
00712
00713 <span class="comment">// For each edge</span>
00714 <span class="keywordflow">for</span> (edges=0; edges<<a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>.size(); edges++)
00715 {
00716 <span class="comment">// Get the rotation</span>
00717 <a class="code" href="a04558.html#a11">uint32</a> rot = <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplater0">_Edges</a>[edges].getRotation ();
00718 <a class="code" href="a04199.html#a6">nlassert</a> (rot<4);
00719
00720 <span class="comment">// Get its x and y cell coordinate</span>
00721 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a572">x</a> = _Edges[edges].getOffsetX () + cellX[rot];
00722 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a573">y</a> = _Edges[edges].getOffsetY () + cellY[rot];
00723
00724 <span class="comment">// Fill the edge array</span>
00725 edgeArray[<a class="code" href="a04223.html#a572">x</a>+<a class="code" href="a04223.html#a573">y</a>*<a class="code" href="a04223.html#a632">width</a>] |= (1<<rot);
00726
00727 <span class="comment">// Insert the cell</span>
00728 setCell.insert ( pair<sint32, sint32> (x, y) );
00729 }
00730
00731 <span class="comment">// Second set</span>
00732 set<pair<sint32, sint32> > setCell2;
00733
00734 <span class="comment">// For each element in the set</span>
00735 set<pair<sint32, sint32> >::iterator ite = setCell.begin();
00736 <span class="keywordflow">while</span> (ite != setCell.end())
00737 {
00738 <span class="comment">// For each direction</span>
00739 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> dir=0; dir<4; dir++)
00740 {
00741 <span class="comment">// Get its x and y cell coordinate</span>
00742 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a572">x</a> = ite->first;
00743 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a573">y</a> = ite->second;
00744
00745 <span class="comment">// Edge in this direction ?</span>
00746 <span class="keywordflow">while</span> ( (edgeArray[<a class="code" href="a04223.html#a572">x</a>+<a class="code" href="a04223.html#a573">y</a>*<a class="code" href="a04223.html#a632">width</a>] & (1<<dir) ) == 0)
00747 {
00748 <span class="comment">// Move in this direction</span>
00749 <a class="code" href="a04223.html#a572">x</a> += moveX[dir];
00750 <a class="code" href="a04223.html#a573">y</a> += moveY[dir];
00751
00752 <span class="comment">// insert it</span>
00753 setCell2.insert ( pair<sint32, sint32> (x, y) );
00754
00755 <span class="comment">// Some checks</span>
00756 <a class="code" href="a04199.html#a6">nlassert</a> (x>=0);
00757 <a class="code" href="a04199.html#a6">nlassert</a> (x<(<a class="code" href="a04558.html#a10">sint32</a>)width);
00758 <a class="code" href="a04199.html#a6">nlassert</a> (y>=0);
00759 <a class="code" href="a04199.html#a6">nlassert</a> (y<(<a class="code" href="a04558.html#a10">sint32</a>)height);
00760 }
00761 }
00762
00763 <span class="comment">// Next one</span>
00764 ite++;
00765 }
00766
00767 <span class="comment">// Merge the two set</span>
00768 ite = setCell2.begin();
00769 <span class="keywordflow">while</span> (ite != setCell2.end())
00770 {
00771 <span class="comment">// Merge</span>
00772 setCell.insert (*ite);
00773
00774 <span class="comment">// Next element</span>
00775 ite++;
00776 }
00777
00778 <span class="comment">// Done, fill the array</span>
00779 ite = setCell.begin();
00780 <span class="keywordflow">while</span> (ite != setCell.end())
00781 {
00782 <span class="comment">// Merge</span>
00783 mask[ite->first+ite->second*<a class="code" href="a04223.html#a632">width</a>] = <span class="keyword">true</span>;
00784
00785 <span class="comment">// Next element</span>
00786 ite++;
00787 }
00788 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLLIGO_1_1CZoneTemplateh0" doxytag="NLLIGO::CZoneTemplate::getSnappedIndex" ></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#a10">sint32</a> NLLIGO::CZoneTemplate::getSnappedIndex </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">float </td>
<td class="mdname" nowrap> <em>value</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>float </td>
<td class="mdname" nowrap> <em>resolution</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>float </td>
<td class="mdname" nowrap> <em>snap</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [inline, static, private]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Return the interger index of a snappable value.
<p>
<p>
Definition at line <a class="el" href="a06780.html#l00093">93</a> of file <a class="el" href="a06780.html">zone_template.cpp</a>.
<p>
References <a class="el" href="a05622.html#l00355">nlverify</a>, <a class="el" href="a05981.html#l00099">sint32</a>, and <a class="el" href="a05646.html#l01132">value</a>.
<p>
Referenced by <a class="el" href="a06780.html#l00107">build()</a>.
<p>
<div class="fragment"><pre>00094 {
00095 <span class="comment">// Snapped</span>
00096 <span class="keywordtype">float</span> snapped = <a class="code" href="a04223.html#a658">value</a>;
00097
00098 <span class="comment">// This value must be snapped</span>
00099 <a class="code" href="a04199.html#a9">nlverify</a> (snapOnGrid (snapped, resolution, snap));
00100
00101 <span class="comment">// Return the index</span>
00102 <span class="keywordflow">return</span> (<a class="code" href="a04558.html#a10">sint32</a>) floor ( (snapped / resolution) + 0.5f );
00103 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLLIGO_1_1CZoneTemplateh1" doxytag="NLLIGO::CZoneTemplate::isSnapedOnGrid" ></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 NLLIGO::CZoneTemplate::isSnapedOnGrid </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">float </td>
<td class="mdname" nowrap> <em>value</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>float </td>
<td class="mdname" nowrap> <em>resolution</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>float </td>
<td class="mdname" nowrap> <em>snap</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [inline, static, private]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Return true if this value is snapped.
<p>
<p>
Definition at line <a class="el" href="a06780.html#l00084">84</a> of file <a class="el" href="a06780.html">zone_template.cpp</a>.
<p>
References <a class="el" href="a06780.html#l00052">snapOnGrid()</a>, and <a class="el" href="a05646.html#l01132">value</a>.
<p>
Referenced by <a class="el" href="a06780.html#l00107">build()</a>.
<p>
<div class="fragment"><pre>00085 {
00086 <span class="comment">// Snapped</span>
00087 <span class="keywordtype">float</span> snapped = <a class="code" href="a04223.html#a658">value</a>;
00088 <span class="keywordflow">return</span> <a class="code" href="a03764.html#NLLIGO_1_1CZoneTemplateh3">snapOnGrid</a> (snapped, resolution, snap);
00089 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLLIGO_1_1CZoneTemplatea3" doxytag="NLLIGO::CZoneTemplate::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 NLLIGO::CZoneTemplate::serial </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top"><a class="el" href="a02270.html">NLMISC::IStream</a> & </td>
<td class="mdname1" valign="top" nowrap> <em>s</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Serialisation.
<p>
<p>
Definition at line <a class="el" href="a06780.html#l00644">644</a> of file <a class="el" href="a06780.html">zone_template.cpp</a>.
<p>
References <a class="el" href="a06781.html#l00088">_Edges</a>, and <a class="el" href="a05646.html#l00977">s</a>.
<p>
<div class="fragment"><pre>00645 {
00646 <span class="comment">// open an XML node</span>
00647 <a class="code" href="a04223.html#a626">s</a>.xmlPush (<span class="stringliteral">"LIGO_ZONE_TEMPLATE"</span>);
00648
00649 <span class="comment">// An header file</span>
00650 <a class="code" href="a04223.html#a626">s</a>.serialCheck (string (<span class="stringliteral">"LigoZoneTemplate"</span>) );
00651
00652 <span class="comment">// Node for the boundaries</span>
00653 <a class="code" href="a04223.html#a626">s</a>.xmlPush (<span class="stringliteral">"EDGES"</span>);
00654
00655 <span class="comment">// Serial the Vertices</span>
00656 <a class="code" href="a04223.html#a626">s</a>.serialCont (_Edges);
00657
00658 <span class="comment">// Node for the boundaries</span>
00659 <a class="code" href="a04223.html#a626">s</a>.xmlPop ();
00660
00661 <span class="comment">// Close the node</span>
00662 <a class="code" href="a04223.html#a626">s</a>.xmlPop ();
00663 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLLIGO_1_1CZoneTemplateh2" doxytag="NLLIGO::CZoneTemplate::snap" ></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 NLLIGO::CZoneTemplate::snap </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">float & </td>
<td class="mdname" nowrap> <em>value</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>float </td>
<td class="mdname" nowrap> <em>snap</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [inline, static, private]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Round a value on the snap resolution.
<p>
<p>
Definition at line <a class="el" href="a06780.html#l00044">44</a> of file <a class="el" href="a06780.html">zone_template.cpp</a>.
<p>
References <a class="el" href="a05646.html#l01132">value</a>.
<p>
<div class="fragment"><pre>00045 {
00046 <span class="comment">// Snap it</span>
00047 <a class="code" href="a04223.html#a658">value</a> = snap * (<span class="keywordtype">float</span>) floor ( (value / snap) + 0.5f );
00048 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLLIGO_1_1CZoneTemplateh3" doxytag="NLLIGO::CZoneTemplate::snapOnGrid" ></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 NLLIGO::CZoneTemplate::snapOnGrid </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">float & </td>
<td class="mdname" nowrap> <em>value</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>float </td>
<td class="mdname" nowrap> <em>resolution</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>float </td>
<td class="mdname" nowrap> <em>snap</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [inline, static, private]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Snap a value on the grid.
<p>
<p>
Definition at line <a class="el" href="a06780.html#l00052">52</a> of file <a class="el" href="a06780.html">zone_template.cpp</a>.
<p>
References <a class="el" href="a05622.html#l00290">nlassert</a>, and <a class="el" href="a05646.html#l01132">value</a>.
<p>
Referenced by <a class="el" href="a06780.html#l00084">isSnapedOnGrid()</a>.
<p>
<div class="fragment"><pre>00053 {
00054 <span class="comment">// Calc the floor</span>
00055 <span class="keywordtype">float</span> _floor = (<span class="keywordtype">float</span>) ( resolution * floor (value / resolution) );
00056 <a class="code" href="a04199.html#a6">nlassert</a> (_floor<=value);
00057
00058 <span class="comment">// Calc the remainder</span>
00059 <span class="keywordtype">float</span> remainder = <a class="code" href="a04223.html#a658">value</a> - _floor;
00060 <span class="comment">//nlassert ( (remainder>=0) && (remainder<resolution) );</span>
00061
00062 <span class="comment">// Check the snape</span>
00063 <span class="keywordflow">if</span> ( remainder <= snap )
00064 {
00065 <span class="comment">// Flag it</span>
00066 <a class="code" href="a04223.html#a658">value</a> = _floor;
00067
00068 <span class="comment">// Floor is good</span>
00069 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00070 }
00071 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( (resolution - remainder) <= snap )
00072 {
00073 <span class="comment">// Flag it</span>
00074 <a class="code" href="a04223.html#a658">value</a> = _floor + resolution;
00075
00076 <span class="comment">// Floor + resolution is good</span>
00077 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00078 }
00079 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00080 }
</pre></div> </td>
</tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NLLIGO_1_1CZoneTemplater0" doxytag="NLLIGO::CZoneTemplate::_Edges" ></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<<a class="el" href="a03737.html">CZoneEdge</a>> <a class="el" href="a03764.html#NLLIGO_1_1CZoneTemplater0">NLLIGO::CZoneTemplate::_Edges</a><code> [private]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Vertex array.
<p>
<p>
Definition at line <a class="el" href="a06781.html#l00088">88</a> of file <a class="el" href="a06781.html">zone_template.h</a>.
<p>
Referenced by <a class="el" href="a06780.html#l00107">build()</a>, <a class="el" href="a06781.html#l00068">getEdges()</a>, <a class="el" href="a06780.html#l00667">getMask()</a>, and <a class="el" href="a06780.html#l00644">serial()</a>. </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a06781.html">zone_template.h</a><li><a class="el" href="a06780.html">zone_template.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 12:52:18 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>
|