1 // File: HLRBRep_PolyAlgo.cxx
2 // Created: Fri May 5 15:58:19 1995
3 // Author: Christophe MARION
5 // Modified by cma, Tue Apr 1 11:39:48 1997
6 // Modified by cma, Tue Apr 1 11:40:30 1997
8 #include <Standard_Stream.hxx>
9 #include <HLRBRep_PolyAlgo.ixx>
10 #include <Standard_ErrorHandler.hxx>
11 #include <TColStd_HArray1OfTransient.hxx>
12 #include <TColStd_HArray1OfInteger.hxx>
14 #include <CSLib_DerivativeStatus.hxx>
15 #include <CSLib_NormalStatus.hxx>
16 #include <Geom_Surface.hxx>
17 #include <Geom_RectangularTrimmedSurface.hxx>
18 #include <HLRAlgo_ListIteratorOfListOfBPoint.hxx>
19 #include <HLRAlgo_PolyShellData.hxx>
20 #include <HLRAlgo_PolyData.hxx>
21 #include <HLRAlgo_BiPoint.hxx>
24 #include <TopExp_Explorer.hxx>
25 #include <TopTools_Array1OfShape.hxx>
26 #include <TopTools_ListIteratorOfListOfShape.hxx>
27 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
28 #include <Poly_Triangulation.hxx>
29 #include <Poly_Polygon3D.hxx>
30 #include <Poly_PolygonOnTriangulation.hxx>
31 #include <BRep_Builder.hxx>
32 #include <BRep_Tool.hxx>
33 #include <BRepLib_MakeEdge.hxx>
34 #include <Precision.hxx>
37 #define EMskOutLin1 ((Standard_Boolean) 1)
38 #define EMskOutLin2 ((Standard_Boolean) 2)
39 #define EMskOutLin3 ((Standard_Boolean) 4)
40 #define EMskGrALin1 ((Standard_Boolean) 8)
41 #define EMskGrALin2 ((Standard_Boolean) 16)
42 #define EMskGrALin3 ((Standard_Boolean) 32)
43 #define FMskBack ((Standard_Boolean) 64)
44 #define FMskSide ((Standard_Boolean) 128)
45 #define FMskHiding ((Standard_Boolean) 256)
46 #define FMskFlat ((Standard_Boolean) 512)
47 #define FMskOnOutL ((Standard_Boolean)1024)
48 #define FMskOrBack ((Standard_Boolean)2048)
49 #define FMskFrBack ((Standard_Boolean)4096)
51 #define NMskVert ((Standard_Boolean) 1)
52 #define NMskOutL ((Standard_Boolean) 2)
53 #define NMskNorm ((Standard_Boolean) 4)
54 #define NMskFuck ((Standard_Boolean) 8)
55 #define NMskEdge ((Standard_Boolean)16)
56 #define NMskMove ((Standard_Boolean)32)
58 #define PntXTI1 ((Standard_Real*)Coordinates)[ 0]
59 #define PntYTI1 ((Standard_Real*)Coordinates)[ 1]
60 #define PntZTI1 ((Standard_Real*)Coordinates)[ 2]
61 #define PntXTI2 ((Standard_Real*)Coordinates)[ 3]
62 #define PntYTI2 ((Standard_Real*)Coordinates)[ 4]
63 #define PntZTI2 ((Standard_Real*)Coordinates)[ 5]
64 #define PntX1 ((Standard_Real*)Coordinates)[ 6]
65 #define PntY1 ((Standard_Real*)Coordinates)[ 7]
66 #define PntZ1 ((Standard_Real*)Coordinates)[ 8]
67 #define PntX2 ((Standard_Real*)Coordinates)[ 9]
68 #define PntY2 ((Standard_Real*)Coordinates)[10]
69 #define PntZ2 ((Standard_Real*)Coordinates)[11]
71 #define Pn2XTI1 ((Standard_Real*)Coordinate2)[ 0]
72 #define Pn2YTI1 ((Standard_Real*)Coordinate2)[ 1]
73 #define Pn2ZTI1 ((Standard_Real*)Coordinate2)[ 2]
74 #define Pn2XTI2 ((Standard_Real*)Coordinate2)[ 3]
75 #define Pn2YTI2 ((Standard_Real*)Coordinate2)[ 4]
76 #define Pn2ZTI2 ((Standard_Real*)Coordinate2)[ 5]
77 #define Pn2X1 ((Standard_Real*)Coordinate2)[ 6]
78 #define Pn2Y1 ((Standard_Real*)Coordinate2)[ 7]
79 #define Pn2Z1 ((Standard_Real*)Coordinate2)[ 8]
80 #define Pn2X2 ((Standard_Real*)Coordinate2)[ 9]
81 #define Pn2Y2 ((Standard_Real*)Coordinate2)[10]
82 #define Pn2Z2 ((Standard_Real*)Coordinate2)[11]
84 #define Tri1Node1 ((Standard_Integer*)Tri1Indices)[0]
85 #define Tri1Node2 ((Standard_Integer*)Tri1Indices)[1]
86 #define Tri1Node3 ((Standard_Integer*)Tri1Indices)[2]
87 #define Tri1Flags ((Standard_Boolean*)Tri1Indices)[3]
89 #define Tri2Node1 ((Standard_Integer*)Tri2Indices)[0]
90 #define Tri2Node2 ((Standard_Integer*)Tri2Indices)[1]
91 #define Tri2Node3 ((Standard_Integer*)Tri2Indices)[2]
92 #define Tri2Flags ((Standard_Boolean*)Tri2Indices)[3]
94 #define Tri3Node1 ((Standard_Integer*)Tri3Indices)[0]
95 #define Tri3Node2 ((Standard_Integer*)Tri3Indices)[1]
96 #define Tri3Node3 ((Standard_Integer*)Tri3Indices)[2]
97 #define Tri3Flags ((Standard_Boolean*)Tri3Indices)[3]
99 #define Seg1LstSg1 ((Standard_Integer*)Seg1Indices)[0]
100 #define Seg1LstSg2 ((Standard_Integer*)Seg1Indices)[1]
101 #define Seg1NxtSg1 ((Standard_Integer*)Seg1Indices)[2]
102 #define Seg1NxtSg2 ((Standard_Integer*)Seg1Indices)[3]
103 #define Seg1Conex1 ((Standard_Integer*)Seg1Indices)[4]
104 #define Seg1Conex2 ((Standard_Integer*)Seg1Indices)[5]
106 #define Seg2LstSg1 ((Standard_Integer*)Seg2Indices)[0]
107 #define Seg2LstSg2 ((Standard_Integer*)Seg2Indices)[1]
108 #define Seg2NxtSg1 ((Standard_Integer*)Seg2Indices)[2]
109 #define Seg2NxtSg2 ((Standard_Integer*)Seg2Indices)[3]
110 #define Seg2Conex1 ((Standard_Integer*)Seg2Indices)[4]
111 #define Seg2Conex2 ((Standard_Integer*)Seg2Indices)[5]
113 #define Nod1NdSg ((Standard_Integer*)Nod1Indices)[0]
114 #define Nod1Flag ((Standard_Boolean*)Nod1Indices)[1]
115 #define Nod1Edg1 ((Standard_Boolean*)Nod1Indices)[2]
116 #define Nod1Edg2 ((Standard_Boolean*)Nod1Indices)[3]
118 #define Nod1PntX ((Standard_Real*)Nod1RValues)[ 0]
119 #define Nod1PntY ((Standard_Real*)Nod1RValues)[ 1]
120 #define Nod1PntZ ((Standard_Real*)Nod1RValues)[ 2]
121 #define Nod1PntU ((Standard_Real*)Nod1RValues)[ 3]
122 #define Nod1PntV ((Standard_Real*)Nod1RValues)[ 4]
123 #define Nod1NrmX ((Standard_Real*)Nod1RValues)[ 5]
124 #define Nod1NrmY ((Standard_Real*)Nod1RValues)[ 6]
125 #define Nod1NrmZ ((Standard_Real*)Nod1RValues)[ 7]
126 #define Nod1PCu1 ((Standard_Real*)Nod1RValues)[ 8]
127 #define Nod1PCu2 ((Standard_Real*)Nod1RValues)[ 9]
128 #define Nod1Scal ((Standard_Real*)Nod1RValues)[10]
130 #define NodANdSg ((Standard_Integer*)NodAIndices)[0]
131 #define NodAFlag ((Standard_Boolean*)NodAIndices)[1]
132 #define NodAEdg1 ((Standard_Boolean*)NodAIndices)[2]
133 #define NodAEdg2 ((Standard_Boolean*)NodAIndices)[3]
135 #define NodAPntX ((Standard_Real*)NodARValues)[ 0]
136 #define NodAPntY ((Standard_Real*)NodARValues)[ 1]
137 #define NodAPntZ ((Standard_Real*)NodARValues)[ 2]
138 #define NodAPntU ((Standard_Real*)NodARValues)[ 3]
139 #define NodAPntV ((Standard_Real*)NodARValues)[ 4]
140 #define NodANrmX ((Standard_Real*)NodARValues)[ 5]
141 #define NodANrmY ((Standard_Real*)NodARValues)[ 6]
142 #define NodANrmZ ((Standard_Real*)NodARValues)[ 7]
143 #define NodAPCu1 ((Standard_Real*)NodARValues)[ 8]
144 #define NodAPCu2 ((Standard_Real*)NodARValues)[ 9]
145 #define NodAScal ((Standard_Real*)NodARValues)[10]
147 #define NodBNdSg ((Standard_Integer*)NodBIndices)[0]
148 #define NodBFlag ((Standard_Boolean*)NodBIndices)[1]
149 #define NodBEdg1 ((Standard_Boolean*)NodBIndices)[2]
150 #define NodBEdg2 ((Standard_Boolean*)NodBIndices)[3]
152 #define NodBPntX ((Standard_Real*)NodBRValues)[ 0]
153 #define NodBPntY ((Standard_Real*)NodBRValues)[ 1]
154 #define NodBPntZ ((Standard_Real*)NodBRValues)[ 2]
155 #define NodBPntU ((Standard_Real*)NodBRValues)[ 3]
156 #define NodBPntV ((Standard_Real*)NodBRValues)[ 4]
157 #define NodBNrmX ((Standard_Real*)NodBRValues)[ 5]
158 #define NodBNrmY ((Standard_Real*)NodBRValues)[ 6]
159 #define NodBNrmZ ((Standard_Real*)NodBRValues)[ 7]
160 #define NodBPCu1 ((Standard_Real*)NodBRValues)[ 8]
161 #define NodBPCu2 ((Standard_Real*)NodBRValues)[ 9]
162 #define NodBScal ((Standard_Real*)NodBRValues)[10]
164 #define Nod2NdSg ((Standard_Integer*)Nod2Indices)[0]
165 #define Nod2Flag ((Standard_Boolean*)Nod2Indices)[1]
166 #define Nod2Edg1 ((Standard_Boolean*)Nod2Indices)[2]
167 #define Nod2Edg2 ((Standard_Boolean*)Nod2Indices)[3]
169 #define Nod2PntX ((Standard_Real*)Nod2RValues)[ 0]
170 #define Nod2PntY ((Standard_Real*)Nod2RValues)[ 1]
171 #define Nod2PntZ ((Standard_Real*)Nod2RValues)[ 2]
172 #define Nod2PntU ((Standard_Real*)Nod2RValues)[ 3]
173 #define Nod2PntV ((Standard_Real*)Nod2RValues)[ 4]
174 #define Nod2NrmX ((Standard_Real*)Nod2RValues)[ 5]
175 #define Nod2NrmY ((Standard_Real*)Nod2RValues)[ 6]
176 #define Nod2NrmZ ((Standard_Real*)Nod2RValues)[ 7]
177 #define Nod2PCu1 ((Standard_Real*)Nod2RValues)[ 8]
178 #define Nod2PCu2 ((Standard_Real*)Nod2RValues)[ 9]
179 #define Nod2Scal ((Standard_Real*)Nod2RValues)[10]
181 #define Nod3NdSg ((Standard_Integer*)Nod3Indices)[0]
182 #define Nod3Flag ((Standard_Boolean*)Nod3Indices)[1]
183 #define Nod3Edg1 ((Standard_Boolean*)Nod3Indices)[2]
184 #define Nod3Edg2 ((Standard_Boolean*)Nod3Indices)[3]
186 #define Nod3PntX ((Standard_Real*)Nod3RValues)[ 0]
187 #define Nod3PntY ((Standard_Real*)Nod3RValues)[ 1]
188 #define Nod3PntZ ((Standard_Real*)Nod3RValues)[ 2]
189 #define Nod3PntU ((Standard_Real*)Nod3RValues)[ 3]
190 #define Nod3PntV ((Standard_Real*)Nod3RValues)[ 4]
191 #define Nod3NrmX ((Standard_Real*)Nod3RValues)[ 5]
192 #define Nod3NrmY ((Standard_Real*)Nod3RValues)[ 6]
193 #define Nod3NrmZ ((Standard_Real*)Nod3RValues)[ 7]
194 #define Nod3PCu1 ((Standard_Real*)Nod3RValues)[ 8]
195 #define Nod3PCu2 ((Standard_Real*)Nod3RValues)[ 9]
196 #define Nod3Scal ((Standard_Real*)Nod3RValues)[10]
198 #define Nod4NdSg ((Standard_Integer*)Nod4Indices)[0]
199 #define Nod4Flag ((Standard_Boolean*)Nod4Indices)[1]
200 #define Nod4Edg1 ((Standard_Boolean*)Nod4Indices)[2]
201 #define Nod4Edg2 ((Standard_Boolean*)Nod4Indices)[3]
203 #define Nod4PntX ((Standard_Real*)Nod4RValues)[ 0]
204 #define Nod4PntY ((Standard_Real*)Nod4RValues)[ 1]
205 #define Nod4PntZ ((Standard_Real*)Nod4RValues)[ 2]
206 #define Nod4PntU ((Standard_Real*)Nod4RValues)[ 3]
207 #define Nod4PntV ((Standard_Real*)Nod4RValues)[ 4]
208 #define Nod4NrmX ((Standard_Real*)Nod4RValues)[ 5]
209 #define Nod4NrmY ((Standard_Real*)Nod4RValues)[ 6]
210 #define Nod4NrmZ ((Standard_Real*)Nod4RValues)[ 7]
211 #define Nod4PCu1 ((Standard_Real*)Nod4RValues)[ 8]
212 #define Nod4PCu2 ((Standard_Real*)Nod4RValues)[ 9]
213 #define Nod4Scal ((Standard_Real*)Nod4RValues)[10]
215 #define Nod11NdSg ((Standard_Integer*)Nod11Indices)[0]
216 #define Nod11Flag ((Standard_Boolean*)Nod11Indices)[1]
217 #define Nod11Edg1 ((Standard_Boolean*)Nod11Indices)[2]
218 #define Nod11Edg2 ((Standard_Boolean*)Nod11Indices)[3]
220 #define Nod11PntX ((Standard_Real*)Nod11RValues)[ 0]
221 #define Nod11PntY ((Standard_Real*)Nod11RValues)[ 1]
222 #define Nod11PntZ ((Standard_Real*)Nod11RValues)[ 2]
223 #define Nod11PntU ((Standard_Real*)Nod11RValues)[ 3]
224 #define Nod11PntV ((Standard_Real*)Nod11RValues)[ 4]
225 #define Nod11NrmX ((Standard_Real*)Nod11RValues)[ 5]
226 #define Nod11NrmY ((Standard_Real*)Nod11RValues)[ 6]
227 #define Nod11NrmZ ((Standard_Real*)Nod11RValues)[ 7]
228 #define Nod11PCu1 ((Standard_Real*)Nod11RValues)[ 8]
229 #define Nod11PCu2 ((Standard_Real*)Nod11RValues)[ 9]
230 #define Nod11Scal ((Standard_Real*)Nod11RValues)[10]
232 #define Nod1ANdSg ((Standard_Integer*)Nod1AIndices)[0]
233 #define Nod1AFlag ((Standard_Boolean*)Nod1AIndices)[1]
234 #define Nod1AEdg1 ((Standard_Boolean*)Nod1AIndices)[2]
235 #define Nod1AEdg2 ((Standard_Boolean*)Nod1AIndices)[3]
237 #define Nod1APntX ((Standard_Real*)Nod1ARValues)[ 0]
238 #define Nod1APntY ((Standard_Real*)Nod1ARValues)[ 1]
239 #define Nod1APntZ ((Standard_Real*)Nod1ARValues)[ 2]
240 #define Nod1APntU ((Standard_Real*)Nod1ARValues)[ 3]
241 #define Nod1APntV ((Standard_Real*)Nod1ARValues)[ 4]
242 #define Nod1ANrmX ((Standard_Real*)Nod1ARValues)[ 5]
243 #define Nod1ANrmY ((Standard_Real*)Nod1ARValues)[ 6]
244 #define Nod1ANrmZ ((Standard_Real*)Nod1ARValues)[ 7]
245 #define Nod1APCu1 ((Standard_Real*)Nod1ARValues)[ 8]
246 #define Nod1APCu2 ((Standard_Real*)Nod1ARValues)[ 9]
247 #define Nod1AScal ((Standard_Real*)Nod1ARValues)[10]
249 #define Nod1BNdSg ((Standard_Integer*)Nod1BIndices)[0]
250 #define Nod1BFlag ((Standard_Boolean*)Nod1BIndices)[1]
251 #define Nod1BEdg1 ((Standard_Boolean*)Nod1BIndices)[2]
252 #define Nod1BEdg2 ((Standard_Boolean*)Nod1BIndices)[3]
254 #define Nod1BPntX ((Standard_Real*)Nod1BRValues)[ 0]
255 #define Nod1BPntY ((Standard_Real*)Nod1BRValues)[ 1]
256 #define Nod1BPntZ ((Standard_Real*)Nod1BRValues)[ 2]
257 #define Nod1BPntU ((Standard_Real*)Nod1BRValues)[ 3]
258 #define Nod1BPntV ((Standard_Real*)Nod1BRValues)[ 4]
259 #define Nod1BNrmX ((Standard_Real*)Nod1BRValues)[ 5]
260 #define Nod1BNrmY ((Standard_Real*)Nod1BRValues)[ 6]
261 #define Nod1BNrmZ ((Standard_Real*)Nod1BRValues)[ 7]
262 #define Nod1BPCu1 ((Standard_Real*)Nod1BRValues)[ 8]
263 #define Nod1BPCu2 ((Standard_Real*)Nod1BRValues)[ 9]
264 #define Nod1BScal ((Standard_Real*)Nod1BRValues)[10]
266 #define Nod12NdSg ((Standard_Integer*)Nod12Indices)[0]
267 #define Nod12Flag ((Standard_Boolean*)Nod12Indices)[1]
268 #define Nod12Edg1 ((Standard_Boolean*)Nod12Indices)[2]
269 #define Nod12Edg2 ((Standard_Boolean*)Nod12Indices)[3]
271 #define Nod12PntX ((Standard_Real*)Nod12RValues)[ 0]
272 #define Nod12PntY ((Standard_Real*)Nod12RValues)[ 1]
273 #define Nod12PntZ ((Standard_Real*)Nod12RValues)[ 2]
274 #define Nod12PntU ((Standard_Real*)Nod12RValues)[ 3]
275 #define Nod12PntV ((Standard_Real*)Nod12RValues)[ 4]
276 #define Nod12NrmX ((Standard_Real*)Nod12RValues)[ 5]
277 #define Nod12NrmY ((Standard_Real*)Nod12RValues)[ 6]
278 #define Nod12NrmZ ((Standard_Real*)Nod12RValues)[ 7]
279 #define Nod12PCu1 ((Standard_Real*)Nod12RValues)[ 8]
280 #define Nod12PCu2 ((Standard_Real*)Nod12RValues)[ 9]
281 #define Nod12Scal ((Standard_Real*)Nod12RValues)[10]
283 #define Nod13NdSg ((Standard_Integer*)Nod13Indices)[0]
284 #define Nod13Flag ((Standard_Boolean*)Nod13Indices)[1]
285 #define Nod13Edg1 ((Standard_Boolean*)Nod13Indices)[2]
286 #define Nod13Edg2 ((Standard_Boolean*)Nod13Indices)[3]
288 #define Nod13PntX ((Standard_Real*)Nod13RValues)[ 0]
289 #define Nod13PntY ((Standard_Real*)Nod13RValues)[ 1]
290 #define Nod13PntZ ((Standard_Real*)Nod13RValues)[ 2]
291 #define Nod13PntU ((Standard_Real*)Nod13RValues)[ 3]
292 #define Nod13PntV ((Standard_Real*)Nod13RValues)[ 4]
293 #define Nod13NrmX ((Standard_Real*)Nod13RValues)[ 5]
294 #define Nod13NrmY ((Standard_Real*)Nod13RValues)[ 6]
295 #define Nod13NrmZ ((Standard_Real*)Nod13RValues)[ 7]
296 #define Nod13PCu1 ((Standard_Real*)Nod13RValues)[ 8]
297 #define Nod13PCu2 ((Standard_Real*)Nod13RValues)[ 9]
298 #define Nod13Scal ((Standard_Real*)Nod13RValues)[10]
300 #define Nod14NdSg ((Standard_Integer*)Nod14Indices)[0]
301 #define Nod14Flag ((Standard_Boolean*)Nod14Indices)[1]
302 #define Nod14Edg1 ((Standard_Boolean*)Nod14Indices)[2]
303 #define Nod14Edg2 ((Standard_Boolean*)Nod14Indices)[3]
305 #define Nod14PntX ((Standard_Real*)Nod14RValues)[ 0]
306 #define Nod14PntY ((Standard_Real*)Nod14RValues)[ 1]
307 #define Nod14PntZ ((Standard_Real*)Nod14RValues)[ 2]
308 #define Nod14PntU ((Standard_Real*)Nod14RValues)[ 3]
309 #define Nod14PntV ((Standard_Real*)Nod14RValues)[ 4]
310 #define Nod14NrmX ((Standard_Real*)Nod14RValues)[ 5]
311 #define Nod14NrmY ((Standard_Real*)Nod14RValues)[ 6]
312 #define Nod14NrmZ ((Standard_Real*)Nod14RValues)[ 7]
313 #define Nod14PCu1 ((Standard_Real*)Nod14RValues)[ 8]
314 #define Nod14PCu2 ((Standard_Real*)Nod14RValues)[ 9]
315 #define Nod14Scal ((Standard_Real*)Nod14RValues)[10]
317 #define Nod21NdSg ((Standard_Integer*)Nod21Indices)[0]
318 #define Nod21Flag ((Standard_Boolean*)Nod21Indices)[1]
319 #define Nod21Edg1 ((Standard_Boolean*)Nod21Indices)[2]
320 #define Nod21Edg2 ((Standard_Boolean*)Nod21Indices)[3]
322 #define Nod21PntX ((Standard_Real*)Nod21RValues)[ 0]
323 #define Nod21PntY ((Standard_Real*)Nod21RValues)[ 1]
324 #define Nod21PntZ ((Standard_Real*)Nod21RValues)[ 2]
325 #define Nod21PntU ((Standard_Real*)Nod21RValues)[ 3]
326 #define Nod21PntV ((Standard_Real*)Nod21RValues)[ 4]
327 #define Nod21NrmX ((Standard_Real*)Nod21RValues)[ 5]
328 #define Nod21NrmY ((Standard_Real*)Nod21RValues)[ 6]
329 #define Nod21NrmZ ((Standard_Real*)Nod21RValues)[ 7]
330 #define Nod21PCu1 ((Standard_Real*)Nod21RValues)[ 8]
331 #define Nod21PCu2 ((Standard_Real*)Nod21RValues)[ 9]
332 #define Nod21Scal ((Standard_Real*)Nod21RValues)[10]
334 #define Nod2ANdSg ((Standard_Integer*)Nod2AIndices)[0]
335 #define Nod2AFlag ((Standard_Boolean*)Nod2AIndices)[1]
336 #define Nod2AEdg1 ((Standard_Boolean*)Nod2AIndices)[2]
337 #define Nod2AEdg2 ((Standard_Boolean*)Nod2AIndices)[3]
339 #define Nod2APntX ((Standard_Real*)Nod2ARValues)[ 0]
340 #define Nod2APntY ((Standard_Real*)Nod2ARValues)[ 1]
341 #define Nod2APntZ ((Standard_Real*)Nod2ARValues)[ 2]
342 #define Nod2APntU ((Standard_Real*)Nod2ARValues)[ 3]
343 #define Nod2APntV ((Standard_Real*)Nod2ARValues)[ 4]
344 #define Nod2ANrmX ((Standard_Real*)Nod2ARValues)[ 5]
345 #define Nod2ANrmY ((Standard_Real*)Nod2ARValues)[ 6]
346 #define Nod2ANrmZ ((Standard_Real*)Nod2ARValues)[ 7]
347 #define Nod2APCu1 ((Standard_Real*)Nod2ARValues)[ 8]
348 #define Nod2APCu2 ((Standard_Real*)Nod2ARValues)[ 9]
349 #define Nod2AScal ((Standard_Real*)Nod2ARValues)[10]
351 #define Nod2BNdSg ((Standard_Integer*)Nod2BIndices)[0]
352 #define Nod2BFlag ((Standard_Boolean*)Nod2BIndices)[1]
353 #define Nod2BEdg1 ((Standard_Boolean*)Nod2BIndices)[2]
354 #define Nod2BEdg2 ((Standard_Boolean*)Nod2BIndices)[3]
356 #define Nod2BPntX ((Standard_Real*)Nod2BRValues)[ 0]
357 #define Nod2BPntY ((Standard_Real*)Nod2BRValues)[ 1]
358 #define Nod2BPntZ ((Standard_Real*)Nod2BRValues)[ 2]
359 #define Nod2BPntU ((Standard_Real*)Nod2BRValues)[ 3]
360 #define Nod2BPntV ((Standard_Real*)Nod2BRValues)[ 4]
361 #define Nod2BNrmX ((Standard_Real*)Nod2BRValues)[ 5]
362 #define Nod2BNrmY ((Standard_Real*)Nod2BRValues)[ 6]
363 #define Nod2BNrmZ ((Standard_Real*)Nod2BRValues)[ 7]
364 #define Nod2BPCu1 ((Standard_Real*)Nod2BRValues)[ 8]
365 #define Nod2BPCu2 ((Standard_Real*)Nod2BRValues)[ 9]
366 #define Nod2BScal ((Standard_Real*)Nod2BRValues)[10]
368 #define Nod22NdSg ((Standard_Integer*)Nod22Indices)[0]
369 #define Nod22Flag ((Standard_Boolean*)Nod22Indices)[1]
370 #define Nod22Edg1 ((Standard_Boolean*)Nod22Indices)[2]
371 #define Nod22Edg2 ((Standard_Boolean*)Nod22Indices)[3]
373 #define Nod22PntX ((Standard_Real*)Nod22RValues)[ 0]
374 #define Nod22PntY ((Standard_Real*)Nod22RValues)[ 1]
375 #define Nod22PntZ ((Standard_Real*)Nod22RValues)[ 2]
376 #define Nod22PntU ((Standard_Real*)Nod22RValues)[ 3]
377 #define Nod22PntV ((Standard_Real*)Nod22RValues)[ 4]
378 #define Nod22NrmX ((Standard_Real*)Nod22RValues)[ 5]
379 #define Nod22NrmY ((Standard_Real*)Nod22RValues)[ 6]
380 #define Nod22NrmZ ((Standard_Real*)Nod22RValues)[ 7]
381 #define Nod22PCu1 ((Standard_Real*)Nod22RValues)[ 8]
382 #define Nod22PCu2 ((Standard_Real*)Nod22RValues)[ 9]
383 #define Nod22Scal ((Standard_Real*)Nod22RValues)[10]
385 #define Nod23NdSg ((Standard_Integer*)Nod23Indices)[0]
386 #define Nod23Flag ((Standard_Boolean*)Nod23Indices)[1]
387 #define Nod23Edg1 ((Standard_Boolean*)Nod23Indices)[2]
388 #define Nod23Edg2 ((Standard_Boolean*)Nod23Indices)[3]
390 #define Nod23PntX ((Standard_Real*)Nod23RValues)[ 0]
391 #define Nod23PntY ((Standard_Real*)Nod23RValues)[ 1]
392 #define Nod23PntZ ((Standard_Real*)Nod23RValues)[ 2]
393 #define Nod23PntU ((Standard_Real*)Nod23RValues)[ 3]
394 #define Nod23PntV ((Standard_Real*)Nod23RValues)[ 4]
395 #define Nod23NrmX ((Standard_Real*)Nod23RValues)[ 5]
396 #define Nod23NrmY ((Standard_Real*)Nod23RValues)[ 6]
397 #define Nod23NrmZ ((Standard_Real*)Nod23RValues)[ 7]
398 #define Nod23PCu1 ((Standard_Real*)Nod23RValues)[ 8]
399 #define Nod23PCu2 ((Standard_Real*)Nod23RValues)[ 9]
400 #define Nod23Scal ((Standard_Real*)Nod23RValues)[10]
402 #define Nod24NdSg ((Standard_Integer*)Nod24Indices)[0]
403 #define Nod24Flag ((Standard_Boolean*)Nod24Indices)[1]
404 #define Nod24Edg1 ((Standard_Boolean*)Nod24Indices)[2]
405 #define Nod24Edg2 ((Standard_Boolean*)Nod24Indices)[3]
407 #define Nod24PntX ((Standard_Real*)Nod24RValues)[ 0]
408 #define Nod24PntY ((Standard_Real*)Nod24RValues)[ 1]
409 #define Nod24PntZ ((Standard_Real*)Nod24RValues)[ 2]
410 #define Nod24PntU ((Standard_Real*)Nod24RValues)[ 3]
411 #define Nod24PntV ((Standard_Real*)Nod24RValues)[ 4]
412 #define Nod24NrmX ((Standard_Real*)Nod24RValues)[ 5]
413 #define Nod24NrmY ((Standard_Real*)Nod24RValues)[ 6]
414 #define Nod24NrmZ ((Standard_Real*)Nod24RValues)[ 7]
415 #define Nod24PCu1 ((Standard_Real*)Nod24RValues)[ 8]
416 #define Nod24PCu2 ((Standard_Real*)Nod24RValues)[ 9]
417 #define Nod24Scal ((Standard_Real*)Nod24RValues)[10]
419 #define ShapeIndex ((Standard_Integer*)IndexPtr)[0]
420 #define F1Index ((Standard_Integer*)IndexPtr)[1]
421 #define F1Pt1Index ((Standard_Integer*)IndexPtr)[2]
422 #define F1Pt2Index ((Standard_Integer*)IndexPtr)[3]
423 #define F2Index ((Standard_Integer*)IndexPtr)[4]
424 #define F2Pt1Index ((Standard_Integer*)IndexPtr)[5]
425 #define F2Pt2Index ((Standard_Integer*)IndexPtr)[6]
426 #define MinSeg ((Standard_Integer*)IndexPtr)[7]
427 #define MaxSeg ((Standard_Integer*)IndexPtr)[8]
428 #define SegFlags ((Standard_Integer*)IndexPtr)[9]
430 static Standard_Integer DoTrace = Standard_False;
431 static Standard_Integer DoError = Standard_False;
432 static Standard_Integer IndexPlusOnePerCentThree [] = { 1 , 2 , 0 };
434 //=======================================================================
435 //function : HLRBRep_PolyAlgo
437 //=======================================================================
439 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo () :
440 myDebug (Standard_False),
441 myAngle (5 * PI / 180.),
446 myAlgo = new HLRAlgo_PolyAlgo();
449 //=======================================================================
450 //function : HLRBRep_PolyAlgo
452 //=======================================================================
454 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const Handle(HLRBRep_PolyAlgo)& A)
456 myDebug = A->Debug();
457 myAngle = A->Angle();
458 myTolAngular = A->TolAngular();
459 myTolSta = A->TolCoef();
460 myTolEnd = 1 - myTolSta;
462 myProj = A->Projector();
464 Standard_Integer n = A->NbShapes();
466 for (Standard_Integer i = 1; i <= n; i++)
470 //=======================================================================
471 //function : HLRBRep_PolyAlgo
473 //=======================================================================
475 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const TopoDS_Shape& S) :
476 myDebug (Standard_False),
477 myAngle (5 * PI / 180.),
483 myAlgo = new HLRAlgo_PolyAlgo();
486 //=======================================================================
489 //=======================================================================
491 TopoDS_Shape & HLRBRep_PolyAlgo::Shape (const Standard_Integer I)
493 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
494 "HLRBRep_PolyAlgo::Shape : unknown Shape");
498 //=======================================================================
501 //=======================================================================
503 void HLRBRep_PolyAlgo::Remove (const Standard_Integer I)
505 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
506 "HLRBRep_PolyAlgo::Remove : unknown Shape");
513 //=======================================================================
516 //=======================================================================
518 Standard_Integer HLRBRep_PolyAlgo::Index (const TopoDS_Shape& S) const
520 Standard_Integer n = myShapes.Length();
522 for (Standard_Integer i = 1; i <= n; i++)
523 if (myShapes(i) == S) return i;
528 //=======================================================================
531 //=======================================================================
533 Handle(HLRAlgo_PolyAlgo) HLRBRep_PolyAlgo::Algo () const
538 //=======================================================================
541 //=======================================================================
543 void HLRBRep_PolyAlgo::Update ()
548 TopoDS_Shape Shape = MakeShape();
550 if (!Shape.IsNull()) {
551 TopExp_Explorer exshell;
552 Standard_Boolean IsoledF,IsoledE;//,closed;
554 TopTools_MapOfShape ShapeMap1,ShapeMap2;
555 TopExp::MapShapes(Shape,TopAbs_EDGE,myEMap);
556 TopExp::MapShapes(Shape,TopAbs_FACE,myFMap);
557 Standard_Integer nbEdge = myEMap.Extent();
558 Standard_Integer nbFace = myFMap.Extent();
559 TColStd_Array1OfInteger ES (0,nbEdge); // index of the Shell
560 TColStd_Array1OfTransient PD (0,nbFace); // HLRAlgo_PolyData
561 TColStd_Array1OfTransient PID(0,nbFace); // PolyInternalData
562 Standard_Integer nbShell = InitShape(Shape,IsoledF,IsoledE);
564 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
565 Standard_Integer iShell = 0;
567 for (exshell.Init(Shape, TopAbs_SHELL);
570 StoreShell(exshell.Current(),iShell,Shell,
571 Standard_False,Standard_False,
572 ES,PD,PID,ShapeMap1,ShapeMap2);
574 StoreShell(Shape,iShell,Shell,IsoledF,Standard_False,
575 ES,PD,PID,ShapeMap1,ShapeMap2);
577 StoreShell(Shape,iShell,Shell,Standard_False,IsoledE,
578 ES,PD,PID,ShapeMap1,ShapeMap2);
584 //=======================================================================
585 //function : MakeShape
587 //=======================================================================
589 TopoDS_Shape HLRBRep_PolyAlgo::MakeShape () const
591 Standard_Integer n = myShapes.Length();
592 Standard_Boolean FirstTime = Standard_True;
596 for (Standard_Integer i = 1; i <= n; i++) {
598 FirstTime = Standard_False;
599 B.MakeCompound(TopoDS::Compound(Shape));
601 B.Add(Shape,myShapes(i));
606 //=======================================================================
607 //function : InitShape
609 //=======================================================================
612 HLRBRep_PolyAlgo::InitShape (const TopoDS_Shape& Shape,
613 Standard_Boolean& IsoledF,
614 Standard_Boolean& IsoledE)
616 TopTools_MapOfShape ShapeMap0;
617 Standard_Integer nbShell = 0;
618 IsoledF = Standard_False;
619 IsoledE = Standard_False;
620 TopExp_Explorer exshell,exface,exedge;
623 for (exshell.Init(Shape, TopAbs_SHELL);
626 Standard_Boolean withTrian = Standard_False;
628 for (exface.Init(exshell.Current(), TopAbs_FACE);
631 const TopoDS_Face& F = TopoDS::Face(exface.Current());
632 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
633 if (ShapeMap0.Add(F))
634 withTrian = Standard_True;
637 if (withTrian) nbShell++;
640 for (exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
641 exface.More() && !IsoledF;
643 const TopoDS_Face& F = TopoDS::Face(exface.Current());
644 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
645 if (ShapeMap0.Add(F))
646 IsoledF = Standard_True;
649 if (IsoledF) nbShell++;
651 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
652 exedge.More() && !IsoledE;
654 IsoledE = Standard_True;
655 if (IsoledE) nbShell++;
657 myAlgo->Init(new TColStd_HArray1OfTransient(1,nbShell));
661 //=======================================================================
662 //function : StoreShell
664 //=======================================================================
666 void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
667 Standard_Integer& iShell,
668 TColStd_Array1OfTransient& Shell,
669 const Standard_Boolean IsoledF,
670 const Standard_Boolean IsoledE,
671 TColStd_Array1OfInteger& ES,
672 TColStd_Array1OfTransient& PD,
673 TColStd_Array1OfTransient& PID,
674 TopTools_MapOfShape& ShapeMap1,
675 TopTools_MapOfShape& ShapeMap2)
678 TopExp_Explorer exface,exedge;
679 Standard_Integer f,i,j;
680 Standard_Integer nbFaceShell = 0;
681 Standard_Boolean reversed;
682 Standard_Boolean closed = Standard_False;
683 const gp_Trsf& T = myProj.Transformation();
684 const gp_Trsf& TI = myProj.InvertedTransformation();
685 const gp_XYZ& tloc = T.TranslationPart();
689 const gp_Mat& tmat = T.VectorialPart();
690 TMat[0][0] = tmat.Value(1,1);
691 TMat[0][1] = tmat.Value(1,2);
692 TMat[0][2] = tmat.Value(1,3);
693 TMat[1][0] = tmat.Value(2,1);
694 TMat[1][1] = tmat.Value(2,2);
695 TMat[1][2] = tmat.Value(2,3);
696 TMat[2][0] = tmat.Value(3,1);
697 TMat[2][1] = tmat.Value(3,2);
698 TMat[2][2] = tmat.Value(3,3);
699 const gp_XYZ& tilo = TI.TranslationPart();
703 const gp_Mat& tima = TI.VectorialPart();
704 TIMa[0][0] = tima.Value(1,1);
705 TIMa[0][1] = tima.Value(1,2);
706 TIMa[0][2] = tima.Value(1,3);
707 TIMa[1][0] = tima.Value(2,1);
708 TIMa[1][1] = tima.Value(2,2);
709 TIMa[1][2] = tima.Value(2,3);
710 TIMa[2][0] = tima.Value(3,1);
711 TIMa[2][1] = tima.Value(3,2);
712 TIMa[2][2] = tima.Value(3,3);
715 closed = Shape.Closed();
717 TopTools_IndexedMapOfShape EM;
718 TopExp::MapShapes(Shape,TopAbs_EDGE,EM);
720 Standard_Integer nbEdge = EM.Extent ();
721 Standard_Integer *flag = new Standard_Integer[nbEdge + 1];
723 for (ie = 1; ie <= nbEdge; ie++)
726 for (exedge.Init(Shape, TopAbs_EDGE);
729 const TopoDS_Edge& E = TopoDS::Edge(exedge.Current());
730 ie = EM.FindIndex(E);
731 TopAbs_Orientation orient = E.Orientation();
732 if (!BRep_Tool::Degenerated(E)) {
733 if (orient == TopAbs_FORWARD ) flag[ie] += 1;
734 else if (orient == TopAbs_REVERSED) flag[ie] -= 1;
737 closed = Standard_True;
739 for (ie = 1; ie <= nbEdge && closed; ie++)
740 closed = (flag[ie] == 0);
745 exface.Init(Shape, TopAbs_FACE);
748 exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
750 for (; exface.More(); exface.Next()) {
751 const TopoDS_Face& F = TopoDS::Face(exface.Current());
752 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
753 if (ShapeMap1.Add(F))
758 if (nbFaceShell > 0 || IsoledE) {
760 Shell(iShell) = new HLRAlgo_PolyShellData(nbFaceShell);
762 if (nbFaceShell > 0) {
763 const Handle(HLRAlgo_PolyShellData)& psd =
764 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
765 Standard_Integer iFace = 0;
766 if (!IsoledF) exface.Init(Shape, TopAbs_FACE);
767 else exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
768 TopTools_MapOfShape ShapeMapBis;
770 for (; exface.More(); exface.Next()) {
771 const TopoDS_Face& F = TopoDS::Face(exface.Current());
772 const Handle(Poly_Triangulation)& Tr = BRep_Tool::Triangulation(F,L);
774 if (ShapeMap2.Add(F)) {
776 f = myFMap.FindIndex(F);
777 reversed = F.Orientation() == TopAbs_REVERSED;
778 gp_Trsf TT = L.Transformation();
780 const gp_XYZ& ttlo = TT.TranslationPart();
784 const gp_Mat& ttma = TT.VectorialPart();
785 TTMa[0][0] = ttma.Value(1,1);
786 TTMa[0][1] = ttma.Value(1,2);
787 TTMa[0][2] = ttma.Value(1,3);
788 TTMa[1][0] = ttma.Value(2,1);
789 TTMa[1][1] = ttma.Value(2,2);
790 TTMa[1][2] = ttma.Value(2,3);
791 TTMa[2][0] = ttma.Value(3,1);
792 TTMa[2][1] = ttma.Value(3,2);
793 TTMa[2][2] = ttma.Value(3,3);
794 Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
795 TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
796 Standard_Integer nbN = Nod.Upper();
797 Standard_Integer nbT = Tri.Upper();
798 PD (f) = new HLRAlgo_PolyData();
799 psd->PolyData().ChangeValue(iFace) = PD(f);
800 PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
801 Handle(HLRAlgo_PolyInternalData)& pid =
802 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(f));
803 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
804 if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface))
805 S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
806 GeomAdaptor_Surface AS(S);
807 pid->Planar(AS.GetType() == GeomAbs_Plane);
808 Standard_Address TData = &pid->TData();
809 Standard_Address PISeg = &pid->PISeg();
810 Standard_Address PINod = &pid->PINod();
811 Poly_Triangle * OT = &(Tri.ChangeValue(1));
812 HLRAlgo_TriangleData* NT =
813 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
815 for (i = 1; i <= nbT; i++) {
816 Standard_Address Tri2Indices = NT->Indices();
817 OT->Get(Tri2Node1,Tri2Node2,Tri2Node3);
821 Tri2Node1 = Tri2Node3;
828 gp_Pnt * ON = &(Nod.ChangeValue(1));
829 Handle(HLRAlgo_PolyInternalNode)* NN =
830 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
832 for (i = 1; i <= nbN; i++) {
833 const Standard_Address Nod1RValues = (*NN)->RValues();
834 const Standard_Address Nod1Indices = (*NN)->Indices();
840 TTMultiply(Nod1PntX,Nod1PntY,Nod1PntZ);
844 pid->UpdateLinks(TData,PISeg,PINod);
845 if (Tr->HasUVNodes()) {
846 myBSurf.Initialize(F,Standard_False);
847 TColgp_Array1OfPnt2d & UVN = Tr->ChangeUVNodes();
848 gp_Pnt2d* OUVN = &(UVN.ChangeValue(1));
849 NN = &(((HLRAlgo_Array1OfPINod*)PINod)->
852 for (i = 1; i <= nbN; i++) {
853 const Standard_Address Nod1Indices = (*NN)->Indices();
854 const Standard_Address Nod1RValues = (*NN)->RValues();
855 Nod1PntU = OUVN->X();
856 Nod1PntV = OUVN->Y();
857 if (Normal(i,Nod1Indices,Nod1RValues,
858 TData,PISeg,PINod,Standard_False))
859 Nod1Flag |= NMskNorm;
861 Nod1Flag &= ~NMskNorm;
870 cout << " HLRBRep_PolyAlgo::StoreShell : Face ";
871 cout << f << " non triangulated" << endl;
874 NT = &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
876 for (i = 1; i <= nbT; i++) {
877 const Standard_Address Tri1Indices = NT->Indices();
878 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
879 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
880 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
881 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
882 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
883 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
884 const Standard_Address Nod1Indices = (*PN1)->Indices();
885 const Standard_Address Nod2Indices = (*PN2)->Indices();
886 const Standard_Address Nod3Indices = (*PN3)->Indices();
887 const Standard_Address Nod1RValues = (*PN1)->RValues();
888 const Standard_Address Nod2RValues = (*PN2)->RValues();
889 const Standard_Address Nod3RValues = (*PN3)->RValues();
890 OrientTriangle(i,Tri1Indices,
891 Nod1Indices,Nod1RValues,
892 Nod2Indices,Nod2RValues,
893 Nod3Indices,Nod3RValues);
900 cout << "HLRBRep_PolyAlgo::StoreShell : Face ";
901 cout << f << " deja stockee" << endl;
905 Standard_Integer nbFace = myFMap.Extent();
906 HLRAlgo_ListOfBPoint& List = psd->Edges();
907 TopTools_IndexedDataMapOfShapeListOfShape EF;
908 TopExp::MapShapesAndAncestors(Shape,TopAbs_EDGE,TopAbs_FACE,EF);
909 Handle(HLRAlgo_PolyInternalData)* pid =
910 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
912 for (f = 1; f <= nbFace; f++) {
913 if (!(*pid).IsNull()) {
915 for (exedge.Init(myFMap(f),TopAbs_EDGE);
918 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
919 if (ShapeMap1.Add(E)) {
920 Standard_Integer e = myEMap.FindIndex(E);
922 Standard_Integer i = EF.FindIndex(E);
924 TopTools_ListOfShape& LS = EF(i);
925 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_True);
928 TopTools_ListOfShape LS;
929 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
936 InsertOnOutLine(PID);
937 CheckFrBackTriangles(List,PID);
938 UpdateOutLines(List,PID);
939 UpdateEdgesBiPoints(List,PID,closed);
940 UpdatePolyData(PD,PID,closed);
941 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
943 for (f = 1; f <= nbFace; f++) {
949 const Handle(HLRAlgo_PolyShellData)& psd =
950 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
951 HLRAlgo_ListOfBPoint& List = psd->Edges();
953 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
956 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
957 if (ShapeMap1.Add(E)) {
958 Standard_Integer e = myEMap.FindIndex(E);
960 TopTools_ListOfShape LS;
961 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
967 //=======================================================================
970 //=======================================================================
972 Standard_Boolean HLRBRep_PolyAlgo::
973 Normal (const Standard_Integer iNode,
974 const Standard_Address Nod1Indices,
975 const Standard_Address Nod1RValues,
976 Standard_Address& TData,
977 Standard_Address& PISeg,
978 Standard_Address& PINod,
979 const Standard_Boolean orient) const
981 gp_Vec D1U,D1V,D2U,D2V,D2UV;
985 CSLib_DerivativeStatus Status;
986 CSLib_NormalStatus NStat;
987 myBSurf.D1(Nod1PntU,Nod1PntV,P,D1U,D1V);
988 CSLib::Normal(D1U,D1V,Standard_Real(Precision::Angular()),
990 if (Status != CSLib_Done) {
991 myBSurf.D2(Nod1PntU,Nod1PntV,P,D1U,D1V,D2U,D2V,D2UV);
992 CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,
993 Precision::Angular(),OK,NStat,Norma);
995 return Standard_False;
997 Standard_Real EyeX = 0;
998 Standard_Real EyeY = 0;
999 Standard_Real EyeZ = -1;
1000 if (myProj.Perspective()) {
1003 EyeZ = Nod1PntZ - myProj.Focus();
1004 Standard_Real d = sqrt(EyeX * EyeX + EyeY * EyeY + EyeZ * EyeZ);
1011 Nod1NrmX = Norma.X();
1012 Nod1NrmY = Norma.Y();
1013 Nod1NrmZ = Norma.Z();
1014 // TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ);
1015 TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ,myProj.Perspective()); //OCC349
1016 Standard_Real NormX,NormY,NormZ;
1018 if (AverageNormal(iNode,Nod1Indices,TData,PISeg,PINod,
1019 NormX,NormY,NormZ)) {
1020 if (Nod1NrmX * NormX +
1022 Nod1NrmZ * NormZ < 0) {
1023 Nod1NrmX = -Nod1NrmX;
1024 Nod1NrmY = -Nod1NrmY;
1025 Nod1NrmZ = -Nod1NrmZ;
1027 Nod1Scal = (Nod1NrmX * EyeX +
1038 cout << "HLRBRep_PolyAlgo::Normal : AverageNormal error";
1044 if ( Nod1Scal < myTolAngular) {
1046 Nod1Flag |= NMskOutL;
1050 if (-Nod1Scal < myTolAngular) {
1052 Nod1Flag |= NMskOutL;
1055 if (orient) UpdateAroundNode(iNode,Nod1Indices,
1057 return Standard_True;
1060 //=======================================================================
1061 //function : AverageNormal
1063 //=======================================================================
1066 HLRBRep_PolyAlgo::AverageNormal(const Standard_Integer iNode,
1067 const Standard_Address Nod1Indices,
1068 Standard_Address& TData,
1069 Standard_Address& PISeg,
1070 Standard_Address& PINod,
1073 Standard_Real& Z) const
1075 Standard_Boolean OK = Standard_False;
1076 Standard_Integer jNode = 0,kNode,iiii,iTri1,iTri2;
1082 while (iiii != 0 && !OK) {
1083 const Standard_Address Seg2Indices =
1084 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1087 if ( iTri1 != 0) AddNormalOnTriangle
1088 (iTri1,iNode,jNode,TData,PINod,X,Y,Z,OK);
1089 if ( iTri2 != 0) AddNormalOnTriangle
1090 (iTri2,iNode,jNode,TData,PINod,X,Y,Z,OK);
1091 if (Seg2LstSg1 == iNode) iiii = Seg2NxtSg1;
1092 else iiii = Seg2NxtSg2;
1096 const Standard_Address Nod2Indices =
1097 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(jNode)->Indices();
1100 while (iiii != 0 && !OK) {
1101 const Standard_Address Seg2Indices =
1102 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1105 if ( iTri1 != 0) AddNormalOnTriangle
1106 (iTri1,jNode,kNode,TData,PINod,X,Y,Z,OK);
1107 if ( iTri2 != 0) AddNormalOnTriangle
1108 (iTri2,jNode,kNode,TData,PINod,X,Y,Z,OK);
1109 if (Seg2LstSg1 == jNode) iiii = Seg2NxtSg1;
1110 else iiii = Seg2NxtSg2;
1113 Standard_Real d = sqrt (X * X + Y * Y + Z * Z);
1114 if (OK && d < 1.e-10) {
1115 OK = Standard_False;
1118 cout << "HLRAlgo_PolyInternalData:: inverted normals on ";
1119 cout << "node " << iNode << endl;
1126 //=======================================================================
1127 //function : AddNormalOnTriangle
1129 //=======================================================================
1133 AddNormalOnTriangle(const Standard_Integer iTri,
1134 const Standard_Integer iNode,
1135 Standard_Integer& jNode,
1136 Standard_Address& TData,
1137 Standard_Address& PINod,
1141 Standard_Boolean& OK) const
1143 Standard_Real dn,dnx,dny,dnz;
1144 Standard_Real d1,dx1,dy1,dz1;
1145 Standard_Real d2,dx2,dy2,dz2;
1146 Standard_Real d3,dx3,dy3,dz3;
1147 const Standard_Address Tri2Indices =
1148 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri).Indices();
1149 const Standard_Address Nod1RValues =
1150 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1)->RValues();
1151 const Standard_Address Nod2RValues =
1152 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2)->RValues();
1153 const Standard_Address Nod3RValues =
1154 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3)->RValues();
1155 dx1 = Nod2PntX - Nod1PntX;
1156 dy1 = Nod2PntY - Nod1PntY;
1157 dz1 = Nod2PntZ - Nod1PntZ;
1158 d1 = sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
1160 if (Tri2Node1 == iNode) jNode = Tri2Node2;
1161 else if (Tri2Node2 == iNode) jNode = Tri2Node1;
1164 dx2 = Nod3PntX - Nod2PntX;
1165 dy2 = Nod3PntY - Nod2PntY;
1166 dz2 = Nod3PntZ - Nod2PntZ;
1167 d2 = sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
1169 if (Tri2Node2 == iNode) jNode = Tri2Node3;
1170 else if (Tri2Node3 == iNode) jNode = Tri2Node2;
1173 dx3 = Nod1PntX - Nod3PntX;
1174 dy3 = Nod1PntY - Nod3PntY;
1175 dz3 = Nod1PntZ - Nod3PntZ;
1176 d3 = sqrt(dx3 * dx3 + dy3 * dy3 + dz3 * dz3);
1178 if (Tri2Node3 == iNode) jNode = Tri2Node1;
1179 else if (Tri2Node1 == iNode) jNode = Tri2Node3;
1183 dnx = (dy1 * dz2 - dy2 * dz1) * dn;
1184 dny = (dz1 * dx2 - dz2 * dx1) * dn;
1185 dnz = (dx1 * dy2 - dx2 * dy1) * dn;
1186 dn = sqrt(dnx * dnx + dny * dny + dnz * dnz);
1198 //=======================================================================
1199 //function : InitBiPointsWithConnexity
1201 //=======================================================================
1203 void HLRBRep_PolyAlgo::
1204 InitBiPointsWithConnexity (const Standard_Integer e,
1206 HLRAlgo_ListOfBPoint& List,
1207 TColStd_Array1OfTransient& PID,
1208 TopTools_ListOfShape& LS,
1209 const Standard_Boolean connex)
1211 Standard_Integer iPol,nbPol,i1,i1p1,i1p2,i2,i2p1,i2p2;
1212 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
1213 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
1214 Standard_Real U1,U2;
1215 Handle(Poly_PolygonOnTriangulation) HPol[2];
1217 myBCurv.Initialize(E);
1219 Standard_Integer nbConnex = LS.Extent();
1220 if (nbConnex == 1) {
1221 TopTools_ListIteratorOfListOfShape itn(LS);
1222 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1223 i1 = myFMap.FindIndex(F1);
1224 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1225 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1226 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1227 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1228 if (!HPol[0].IsNull()) {
1229 myPC.Initialize(E,F1);
1230 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1231 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1232 nbPol = Pol1.Upper();
1233 Standard_Address TData1 = &pid1->TData();
1234 Standard_Address PISeg1 = &pid1->PISeg();
1235 Standard_Address PINod1 = &pid1->PINod();
1236 Standard_Address Nod11Indices,Nod12Indices;
1237 Standard_Address Nod11RValues,Nod12RValues;
1238 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1239 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1240 Nod11Indices = (*pi1p1)->Indices();
1241 Nod11RValues = (*pi1p1)->RValues();
1242 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1243 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1244 Nod12Indices = (*pi1p2)->Indices();
1245 Nod12RValues = (*pi1p2)->RValues();
1246 Nod11Flag |= NMskVert;
1247 Nod12Flag |= NMskVert;
1249 for (iPol = 1; iPol <= nbPol; iPol++) {
1250 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1251 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1252 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1253 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1254 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1256 Nod1APCu1 = par->Value(iPol);
1260 Nod1APCu2 = par->Value(iPol);
1265 Nod12Indices = Nod11Indices;
1266 Nod12RValues = Nod11RValues;
1267 XTI2 = X2 = Nod12PntX;
1268 YTI2 = Y2 = Nod12PntY;
1269 ZTI2 = Z2 = Nod12PntZ;
1270 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1271 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1274 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1275 cout << "Parameter error on Node " << i1p2 << endl;
1278 Nod12Flag |= NMskEdge;
1279 TIMultiply(XTI2,YTI2,ZTI2);
1280 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1281 U2 = U2 - myPC.Period();
1283 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1284 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1285 Nod12Indices,Nod12RValues);
1286 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1287 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1291 for (iPol = 2; iPol <= nbPol; iPol++) {
1293 Nod11Indices = Nod12Indices;
1294 Nod11RValues = Nod12RValues;
1296 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1297 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1298 Nod12Indices = (*pi1p2)->Indices();
1299 Nod12RValues = (*pi1p2)->RValues();
1302 if (Nod11NrmX*Nod12NrmX +
1303 Nod11NrmY*Nod12NrmY +
1304 Nod11NrmZ*Nod12NrmZ < 0) {
1305 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1306 cout << "Too big angle between " << i1p1 << setw(6);
1307 cout << " and " << i1p2 << setw(6);
1308 cout << " in face " << i1 << endl;
1319 XTI2 = X2 = Nod12PntX;
1320 YTI2 = Y2 = Nod12PntY;
1321 ZTI2 = Z2 = Nod12PntZ;
1322 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1323 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1326 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1327 cout << "Parameter error on Node " << i1p2 << endl;
1330 Nod12Flag |= NMskEdge;
1331 TIMultiply(XTI2,YTI2,ZTI2);
1333 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1334 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1336 Nod11Indices,Nod11RValues,
1337 Nod12Indices,Nod12RValues,
1338 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1);
1344 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1345 cout << e << " connex 1 sans PolygonOnTriangulation" << endl;
1349 else if (nbConnex == 2) {
1350 TopTools_ListIteratorOfListOfShape itn(LS);
1351 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1352 i1 = myFMap.FindIndex(F1);
1353 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1354 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1356 const TopoDS_Face& F2 = TopoDS::Face(itn.Value());
1357 i2 = myFMap.FindIndex(F2);
1358 if (i1 == i2) E.Reverse();
1359 const Handle(Poly_Triangulation)& Tr2 = BRep_Tool::Triangulation(F2,L);
1360 HPol[1] = BRep_Tool::PolygonOnTriangulation(E,Tr2,L);
1361 GeomAbs_Shape rg = BRep_Tool::Continuity(E,F1,F2);
1362 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1363 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1364 const Handle(HLRAlgo_PolyInternalData)& pid2 =
1365 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i2));
1366 if (!HPol[0].IsNull() && !HPol[1].IsNull()) {
1367 myPC.Initialize(E,F1);
1368 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1369 const TColStd_Array1OfInteger& Pol2 = HPol[1]->Nodes();
1370 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1371 Standard_Integer nbPol = Pol1.Upper();
1372 Standard_Address TData1 = &pid1->TData();
1373 Standard_Address PISeg1 = &pid1->PISeg();
1374 Standard_Address PINod1 = &pid1->PINod();
1375 Standard_Address TData2 = &pid2->TData();
1376 Standard_Address PISeg2 = &pid2->PISeg();
1377 Standard_Address PINod2 = &pid2->PINod();
1378 Standard_Address Nod11Indices,Nod11RValues;
1379 Standard_Address Nod12Indices,Nod12RValues;
1380 Standard_Address Nod21Indices,Nod21RValues;
1381 Standard_Address Nod22Indices,Nod22RValues;
1382 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1383 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1384 Nod11Indices = (*pi1p1)->Indices();
1385 Nod11RValues = (*pi1p1)->RValues();
1386 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1387 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1388 Nod12Indices = (*pi1p2)->Indices();
1389 Nod12RValues = (*pi1p2)->RValues();
1390 const Handle(HLRAlgo_PolyInternalNode)* pi2p1 =
1391 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(1 )));
1392 Nod21Indices = (*pi2p1)->Indices();
1393 Nod21RValues = (*pi2p1)->RValues();
1394 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1395 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(nbPol)));
1396 Nod22Indices = (*pi2p2)->Indices();
1397 Nod22RValues = (*pi2p2)->RValues();
1398 Nod11Flag |= NMskVert;
1399 Nod12Flag |= NMskVert;
1400 Nod21Flag |= NMskVert;
1401 Nod22Flag |= NMskVert;
1403 for (iPol = 1; iPol <= nbPol; iPol++) {
1404 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1405 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1406 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1407 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1408 const Handle(HLRAlgo_PolyInternalNode)* pi2pA =
1409 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1410 Standard_Address Nod2AIndices = (*pi2pA)->Indices();
1411 Standard_Address Nod2ARValues = (*pi2pA)->RValues();
1412 Standard_Real PCu = par->Value(iPol);
1413 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1421 if (Nod2AEdg1 == 0 || Nod2AEdg1 == (Standard_Boolean) e) {
1432 Nod12Indices = Nod11Indices;
1433 Nod12RValues = Nod11RValues;
1435 Nod22Indices = Nod21Indices;
1436 Nod22RValues = Nod21RValues;
1437 XTI2 = X2 = Nod12PntX;
1438 YTI2 = Y2 = Nod12PntY;
1439 ZTI2 = Z2 = Nod12PntZ;
1440 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1441 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1444 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1445 cout << "Parameter error on Node " << i1p2 << endl;
1448 Nod12Flag |= NMskEdge;
1449 Nod22Flag |= NMskEdge;
1450 TIMultiply(XTI2,YTI2,ZTI2);
1451 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1452 U2 = U2 - myPC.Period();
1454 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1455 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1456 Nod12Indices,Nod12RValues);
1457 CheckDegeneratedSegment(Nod21Indices,Nod21RValues,
1458 Nod22Indices,Nod22RValues);
1459 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1460 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1461 UpdateAroundNode(Pol2(1 ),Nod21Indices,TData2,PISeg2,PINod2);
1462 UpdateAroundNode(Pol2(nbPol),Nod22Indices,TData2,PISeg2,PINod2);
1466 for (iPol = 2; iPol <= nbPol; iPol++) {
1468 Nod11Indices = Nod12Indices;
1469 Nod11RValues = Nod12RValues;
1471 Nod21Indices = Nod22Indices;
1472 Nod21RValues = Nod22RValues;
1474 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1475 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1476 Nod12Indices = (*pi1p2)->Indices();
1477 Nod12RValues = (*pi1p2)->RValues();
1479 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1480 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1481 Nod22Indices = (*pi2p2)->Indices();
1482 Nod22RValues = (*pi2p2)->RValues();
1485 if (Nod11NrmX*Nod12NrmX +
1486 Nod11NrmY*Nod12NrmY +
1487 Nod11NrmZ*Nod12NrmZ < 0) {
1488 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1489 cout << "To big angle between " << i1p1 << setw(6);
1490 cout << " and " << i1p2 << setw(6);
1491 cout << " in face " << i1 << endl;
1493 if (Nod21NrmX*Nod22NrmX +
1494 Nod21NrmY*Nod22NrmY +
1495 Nod21NrmZ*Nod22NrmZ < 0) {
1496 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1497 cout << "To big angle between " << i2p1 << setw(6);
1498 cout << " and " << i2p2 << setw(6);
1499 cout<< " in face " << i2 << endl;
1510 XTI2 = X2 = Nod12PntX;
1511 YTI2 = Y2 = Nod12PntY;
1512 ZTI2 = Z2 = Nod12PntZ;
1513 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1514 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1517 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1518 cout << "Parameter error on Node " << i1p2 << endl;
1521 Nod12Flag |= NMskEdge;
1522 Nod22Flag |= NMskEdge;
1523 TIMultiply(XTI2,YTI2,ZTI2);
1525 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1526 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1528 Nod11Indices,Nod11RValues,
1529 Nod12Indices,Nod12RValues,
1530 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1531 Nod21Indices,Nod21RValues,
1532 Nod22Indices,Nod22RValues,
1533 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2);
1539 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1540 cout << e << " connect 2 without PolygonOnTriangulation" << endl;
1545 else { // no connexity
1546 const Handle(Poly_Polygon3D)& Polyg = BRep_Tool::Polygon3D(E,L);
1547 if (!Polyg.IsNull()) {
1548 const TColgp_Array1OfPnt& Pol = Polyg->Nodes();
1549 gp_Trsf TT = L.Transformation();
1550 const gp_Trsf& T = myProj.Transformation();
1552 const gp_XYZ& ttlo = TT.TranslationPart();
1556 const gp_Mat& ttma = TT.VectorialPart();
1557 TTMa[0][0] = ttma.Value(1,1);
1558 TTMa[0][1] = ttma.Value(1,2);
1559 TTMa[0][2] = ttma.Value(1,3);
1560 TTMa[1][0] = ttma.Value(2,1);
1561 TTMa[1][1] = ttma.Value(2,2);
1562 TTMa[1][2] = ttma.Value(2,3);
1563 TTMa[2][0] = ttma.Value(3,1);
1564 TTMa[2][1] = ttma.Value(3,2);
1565 TTMa[2][2] = ttma.Value(3,3);
1566 Standard_Integer nbPol = Pol.Upper();
1567 const gp_XYZ& P1 = Pol(1).XYZ();
1571 TTMultiply(X2,Y2,Z2);
1575 TIMultiply(XTI2,YTI2,ZTI2);
1577 for (Standard_Integer iPol = 2; iPol <= nbPol; iPol++) {
1584 const gp_XYZ& P2 = Pol(iPol).XYZ();
1588 TTMultiply(X2,Y2,Z2);
1592 TIMultiply(XTI2,YTI2,ZTI2);
1593 List.Prepend(HLRAlgo_BiPoint
1594 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1595 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1601 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1602 cout << e << " Isolated, without Polygone 3D" << endl;
1608 //=======================================================================
1609 //function : Interpolation
1611 //=======================================================================
1615 Interpolation (HLRAlgo_ListOfBPoint& List,
1622 Standard_Real& XTI1,
1623 Standard_Real& YTI1,
1624 Standard_Real& ZTI1,
1625 Standard_Real& XTI2,
1626 Standard_Real& YTI2,
1627 Standard_Real& ZTI2,
1628 const Standard_Integer e,
1631 Standard_Address& Nod11Indices,
1632 Standard_Address& Nod11RValues,
1633 Standard_Address& Nod12Indices,
1634 Standard_Address& Nod12RValues,
1635 const Standard_Integer i1p1,
1636 const Standard_Integer i1p2,
1637 const Standard_Integer i1,
1638 const Handle(HLRAlgo_PolyInternalData)& pid1,
1639 Standard_Address& TData1,
1640 Standard_Address& PISeg1,
1641 Standard_Address& PINod1) const
1643 Standard_Boolean insP3,mP3P1;
1644 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1646 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1647 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1648 MoveOrInsertPoint(List,
1649 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1650 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1652 Nod11Indices,Nod11RValues,
1653 Nod12Indices,Nod12RValues,
1654 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1655 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,0);
1658 //=======================================================================
1659 //function : Interpolation
1661 //=======================================================================
1665 Interpolation (HLRAlgo_ListOfBPoint& List,
1672 Standard_Real& XTI1,
1673 Standard_Real& YTI1,
1674 Standard_Real& ZTI1,
1675 Standard_Real& XTI2,
1676 Standard_Real& YTI2,
1677 Standard_Real& ZTI2,
1678 const Standard_Integer e,
1681 const GeomAbs_Shape rg,
1682 Standard_Address& Nod11Indices,
1683 Standard_Address& Nod11RValues,
1684 Standard_Address& Nod12Indices,
1685 Standard_Address& Nod12RValues,
1686 const Standard_Integer i1p1,
1687 const Standard_Integer i1p2,
1688 const Standard_Integer i1,
1689 const Handle(HLRAlgo_PolyInternalData)& pid1,
1690 Standard_Address& TData1,
1691 Standard_Address& PISeg1,
1692 Standard_Address& PINod1,
1693 Standard_Address& Nod21Indices,
1694 Standard_Address& Nod21RValues,
1695 Standard_Address& Nod22Indices,
1696 Standard_Address& Nod22RValues,
1697 const Standard_Integer i2p1,
1698 const Standard_Integer i2p2,
1699 const Standard_Integer i2,
1700 const Handle(HLRAlgo_PolyInternalData)& pid2,
1701 Standard_Address& TData2,
1702 Standard_Address& PISeg2,
1703 Standard_Address& PINod2) const
1705 Standard_Boolean insP3,mP3P1,insP4,mP4P1;
1706 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1707 Standard_Real X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4;
1708 // gp_Pnt P3,PT3,P4,PT4;
1709 Standard_Boolean flag = 0;
1710 if (rg >= GeomAbs_G1) flag += 1;
1711 if (rg >= GeomAbs_G2) flag += 2;
1712 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1713 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1714 insP4 = Interpolation(U1,U2,Nod21RValues,Nod22RValues,
1715 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,mP4P1);
1716 Standard_Boolean OK = insP3 || insP4;
1718 if (!insP4) // p1 i1p3 p2
1719 MoveOrInsertPoint(List,
1720 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1721 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1723 Nod11Indices,Nod11RValues,
1724 Nod12Indices,Nod12RValues,
1725 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1726 Nod21Indices,Nod21RValues,
1727 Nod22Indices,Nod22RValues,
1728 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1729 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1730 else if (!insP3) // p1 i2p4 p2
1731 MoveOrInsertPoint(List,
1732 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1733 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1735 Nod21Indices,Nod21RValues,
1736 Nod22Indices,Nod22RValues,
1737 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1738 Nod11Indices,Nod11RValues,
1739 Nod12Indices,Nod12RValues,
1740 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1741 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1742 else if (Abs(coef4 - coef3) < myTolSta) // p1 i1p3-i2p4 p2
1743 MoveOrInsertPoint(List,
1744 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1745 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1747 Nod21Indices,Nod21RValues,
1748 Nod22Indices,Nod22RValues,
1749 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1750 Nod11Indices,Nod11RValues,
1751 Nod12Indices,Nod12RValues,
1752 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1753 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1754 else if (coef4 < coef3) // p1 i2p4 i1p3 p2
1755 MoveOrInsertPoint(List,
1756 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1757 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1759 Nod21Indices,Nod21RValues,
1760 Nod22Indices,Nod22RValues,
1761 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1762 Nod11Indices,Nod11RValues,
1763 Nod12Indices,Nod12RValues,
1764 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1765 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,
1766 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1767 else // p1 i1p3 i2p4 p2
1768 MoveOrInsertPoint(List,
1769 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1770 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1772 Nod11Indices,Nod11RValues,
1773 Nod12Indices,Nod12RValues,
1774 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1775 Nod21Indices,Nod21RValues,
1776 Nod22Indices,Nod22RValues,
1777 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1778 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,
1779 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1782 List.Prepend(HLRAlgo_BiPoint
1783 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1784 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1785 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
1788 //=======================================================================
1789 //function : Interpolation
1791 //=======================================================================
1795 Interpolation (const Standard_Real U1,
1796 const Standard_Real U2,
1797 const Standard_Address Nod1RValues,
1798 const Standard_Address Nod2RValues,
1802 Standard_Real& XTI3,
1803 Standard_Real& YTI3,
1804 Standard_Real& ZTI3,
1805 Standard_Real& coef3,
1807 Standard_Boolean& mP3P1) const
1809 if (NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1)) {
1810 U3 = U1 + (U2 - U1) * coef3;
1811 const gp_Pnt& P3 = myBCurv.Value(U3);
1815 TMultiply(X3,Y3,Z3);
1816 return Standard_True;
1818 return Standard_False;
1821 //=======================================================================
1822 //function : MoveOrInsertPoint
1824 //=======================================================================
1828 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1835 Standard_Real& XTI1,
1836 Standard_Real& YTI1,
1837 Standard_Real& ZTI1,
1838 Standard_Real& XTI2,
1839 Standard_Real& YTI2,
1840 Standard_Real& ZTI2,
1841 const Standard_Integer e,
1844 Standard_Address& Nod11Indices,
1845 Standard_Address& Nod11RValues,
1846 Standard_Address& Nod12Indices,
1847 Standard_Address& Nod12RValues,
1848 const Standard_Integer i1p1,
1849 const Standard_Integer i1p2,
1850 const Standard_Integer i1,
1851 const Handle(HLRAlgo_PolyInternalData)& pid1,
1852 Standard_Address& TData1,
1853 Standard_Address& PISeg1,
1854 Standard_Address& PINod1,
1855 const Standard_Real X3,
1856 const Standard_Real Y3,
1857 const Standard_Real Z3,
1858 const Standard_Real XTI3,
1859 const Standard_Real YTI3,
1860 const Standard_Real ZTI3,
1861 const Standard_Real coef3,
1862 const Standard_Real U3,
1863 const Standard_Boolean insP3,
1864 const Standard_Boolean mP3P1,
1865 const Standard_Boolean flag) const
1867 Standard_Address TData2 = 0;
1868 Standard_Address PISeg2 = 0;
1869 Standard_Address PINod2 = 0;
1870 Standard_Boolean ins3 = insP3;
1871 if (ins3 && mP3P1) { // P1 ---> P3
1872 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
1873 ins3 = Standard_False;
1874 ChangeNode(i1p1,i1p2,
1875 Nod11Indices,Nod11RValues,
1876 Nod12Indices,Nod12RValues,
1877 coef3,X3,Y3,Z3,Standard_True,
1878 TData1,PISeg1,PINod1);
1889 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
1890 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
1893 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1894 cout << "Parameter error on Node " << i1p1 << endl;
1898 Nod11Flag |= NMskOutL;
1899 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
1900 Standard_Address Coordinates = List.First().Coordinates();
1909 if (ins3 && !mP3P1) { // P2 ---> P3
1910 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
1911 ins3 = Standard_False;
1912 ChangeNode(i1p1,i1p2,
1913 Nod11Indices,Nod11RValues,
1914 Nod12Indices,Nod12RValues,
1915 coef3,X3,Y3,Z3,Standard_False,
1916 TData1,PISeg1,PINod1);
1927 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
1928 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
1931 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1932 cout << "Parameter error on Node " << i1p2 << endl;
1936 Nod12Flag |= NMskOutL;
1937 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
1940 if (ins3) { // p1 i1p3 p2
1941 Standard_Integer i1p3 = pid1->AddNode
1942 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
1943 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
1944 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
1945 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
1946 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
1950 Nod13Flag |= NMskOutL;
1951 Nod13Flag |= NMskEdge;
1952 pid1->UpdateLinks(i1p1,i1p2,i1p3,
1953 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
1954 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
1955 List.Prepend(HLRAlgo_BiPoint
1956 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
1957 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
1958 i1 ,i1p1,i1p3,flag));
1959 List.Prepend(HLRAlgo_BiPoint
1960 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
1961 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
1962 i1 ,i1p3,i1p2,flag));
1965 List.Prepend(HLRAlgo_BiPoint
1966 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1967 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1968 i1 ,i1p1,i1p2,flag));
1971 //=======================================================================
1972 //function : MoveOrInsertPoint
1974 //=======================================================================
1978 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1985 Standard_Real& XTI1,
1986 Standard_Real& YTI1,
1987 Standard_Real& ZTI1,
1988 Standard_Real& XTI2,
1989 Standard_Real& YTI2,
1990 Standard_Real& ZTI2,
1991 const Standard_Integer e,
1994 Standard_Address& Nod11Indices,
1995 Standard_Address& Nod11RValues,
1996 Standard_Address& Nod12Indices,
1997 Standard_Address& Nod12RValues,
1998 const Standard_Integer i1p1,
1999 const Standard_Integer i1p2,
2000 const Standard_Integer i1,
2001 const Handle(HLRAlgo_PolyInternalData)& pid1,
2002 Standard_Address& TData1,
2003 Standard_Address& PISeg1,
2004 Standard_Address& PINod1,
2005 Standard_Address& Nod21Indices,
2006 Standard_Address& Nod21RValues,
2007 Standard_Address& Nod22Indices,
2008 Standard_Address& Nod22RValues,
2009 const Standard_Integer i2p1,
2010 const Standard_Integer i2p2,
2011 const Standard_Integer i2,
2012 const Handle(HLRAlgo_PolyInternalData)& pid2,
2013 Standard_Address& TData2,
2014 Standard_Address& PISeg2,
2015 Standard_Address& PINod2,
2016 const Standard_Real X3,
2017 const Standard_Real Y3,
2018 const Standard_Real Z3,
2019 const Standard_Real XTI3,
2020 const Standard_Real YTI3,
2021 const Standard_Real ZTI3,
2022 const Standard_Real coef3,
2023 const Standard_Real U3,
2024 const Standard_Boolean insP3,
2025 const Standard_Boolean mP3P1,
2026 const Standard_Boolean flag) const
2028 Standard_Boolean ins3 = insP3;
2029 if (ins3 && mP3P1) { // P1 ---> P3
2030 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2031 ins3 = Standard_False;
2032 ChangeNode(i1p1,i1p2,
2033 Nod11Indices,Nod11RValues,
2034 Nod12Indices,Nod12RValues,
2035 coef3,X3,Y3,Z3,Standard_True,
2036 TData1,PISeg1,PINod1);
2037 ChangeNode(i2p1,i2p2,
2038 Nod21Indices,Nod21RValues,
2039 Nod22Indices,Nod22RValues,
2040 coef3,X3,Y3,Z3,Standard_True,
2041 TData2,PISeg2,PINod2);
2052 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2053 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2056 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2057 cout << "Parameter error on Node " << i1p1 << endl;
2061 Nod11Flag |= NMskOutL;
2062 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2066 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2067 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2070 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2071 cout << "Parameter error on Node " << i2p1 << endl;
2075 Nod21Flag |= NMskOutL;
2076 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2077 Standard_Address Coordinates = List.First().Coordinates();
2086 if (ins3 && !mP3P1) { // P2 ---> P3
2087 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
2088 ins3 = Standard_False;
2089 ChangeNode(i1p1,i1p2,
2090 Nod11Indices,Nod11RValues,
2091 Nod12Indices,Nod12RValues,
2092 coef3,X3,Y3,Z3,Standard_False,
2093 TData1,PISeg1,PINod1);
2094 ChangeNode(i2p1,i2p2,
2095 Nod21Indices,Nod21RValues,
2096 Nod22Indices,Nod22RValues,
2097 coef3,X3,Y3,Z3,Standard_False,
2098 TData2,PISeg2,PINod2);
2109 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
2110 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
2113 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2114 cout << "Parameter error on Node " << i1p2 << endl;
2118 Nod12Flag |= NMskOutL;
2119 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2123 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U3;
2124 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U3;
2127 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2128 cout << "Parameter error on Node " << i2p2 << endl;
2132 Nod22Flag |= NMskOutL;
2133 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2136 if (ins3) { // p1 i1p3 p2
2137 Standard_Integer i1p3 = pid1->AddNode
2138 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2139 Standard_Integer i2p3 = pid2->AddNode
2140 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2141 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2142 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2143 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2144 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2145 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2146 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2147 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2148 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2152 Nod13Flag |= NMskOutL;
2153 Nod13Flag |= NMskEdge;
2157 Nod23Flag |= NMskOutL;
2158 Nod23Flag |= NMskEdge;
2159 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2160 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2161 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2162 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2163 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2164 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2165 List.Prepend(HLRAlgo_BiPoint
2166 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2167 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2168 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2169 List.Prepend(HLRAlgo_BiPoint
2170 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
2171 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
2172 i1 ,i1p3,i1p2,i2 ,i2p3,i2p2,flag));
2175 List.Prepend(HLRAlgo_BiPoint
2176 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2177 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2178 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2181 //=======================================================================
2182 //function : MoveOrInsertPoint
2184 //=======================================================================
2188 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
2195 Standard_Real& XTI1,
2196 Standard_Real& YTI1,
2197 Standard_Real& ZTI1,
2198 Standard_Real& XTI2,
2199 Standard_Real& YTI2,
2200 Standard_Real& ZTI2,
2201 const Standard_Integer e,
2204 Standard_Address& Nod11Indices,
2205 Standard_Address& Nod11RValues,
2206 Standard_Address& Nod12Indices,
2207 Standard_Address& Nod12RValues,
2208 const Standard_Integer i1p1,
2209 const Standard_Integer i1p2,
2210 const Standard_Integer i1,
2211 const Handle(HLRAlgo_PolyInternalData)& pid1,
2212 Standard_Address& TData1,
2213 Standard_Address& PISeg1,
2214 Standard_Address& PINod1,
2215 Standard_Address& Nod21Indices,
2216 Standard_Address& Nod21RValues,
2217 Standard_Address& Nod22Indices,
2218 Standard_Address& Nod22RValues,
2219 const Standard_Integer i2p1,
2220 const Standard_Integer i2p2,
2221 const Standard_Integer i2,
2222 const Handle(HLRAlgo_PolyInternalData)& pid2,
2223 Standard_Address& TData2,
2224 Standard_Address& PISeg2,
2225 Standard_Address& PINod2,
2226 const Standard_Real X3,
2227 const Standard_Real Y3,
2228 const Standard_Real Z3,
2229 const Standard_Real XTI3,
2230 const Standard_Real YTI3,
2231 const Standard_Real ZTI3,
2232 const Standard_Real coef3,
2233 const Standard_Real U3,
2234 const Standard_Boolean insP3,
2235 const Standard_Boolean mP3P1,
2236 const Standard_Real X4,
2237 const Standard_Real Y4,
2238 const Standard_Real Z4,
2239 const Standard_Real XTI4,
2240 const Standard_Real YTI4,
2241 const Standard_Real ZTI4,
2242 const Standard_Real coef4,
2243 const Standard_Real U4,
2244 const Standard_Boolean insP4,
2245 const Standard_Boolean mP4P1,
2246 const Standard_Boolean flag) const
2248 Standard_Boolean ins3 = insP3;
2249 Standard_Boolean ins4 = insP4;
2250 if (ins3 && mP3P1) { // P1 ---> P3
2251 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2252 ins3 = Standard_False;
2253 ChangeNode(i1p1,i1p2,
2254 Nod11Indices,Nod11RValues,
2255 Nod12Indices,Nod12RValues,
2256 coef3,X3,Y3,Z3,Standard_True,
2257 TData1,PISeg1,PINod1);
2258 ChangeNode(i2p1,i2p2,
2259 Nod21Indices,Nod21RValues,
2260 Nod22Indices,Nod22RValues,
2261 coef3,X3,Y3,Z3,Standard_True,
2262 TData2,PISeg2,PINod2);
2273 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2274 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2277 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2278 cout << "Parameter error on Node " << i1p1 << endl;
2282 Nod11Flag |= NMskOutL;
2283 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2287 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2288 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2291 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2292 cout << "Parameter error on Node " << i2p1 << endl;
2296 Nod21Flag |= NMskOutL;
2297 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2298 Standard_Address Coordinates = List.First().Coordinates();
2307 if (ins4 && !mP4P1) { // P2 ---> P4
2308 if (!(Nod12Flag & NMskVert) && coef4 > myTolEnd) {
2309 ins4 = Standard_False;
2310 ChangeNode(i2p1,i2p2,
2311 Nod21Indices,Nod21RValues,
2312 Nod22Indices,Nod22RValues,
2313 coef4,X4,Y4,Z4,Standard_False,
2314 TData2,PISeg2,PINod2);
2315 ChangeNode(i1p1,i1p2,
2316 Nod11Indices,Nod11RValues,
2317 Nod12Indices,Nod12RValues,
2318 coef4,X4,Y4,Z4,Standard_False,
2319 TData1,PISeg1,PINod1);
2330 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U4;
2331 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U4;
2334 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2335 cout << "Parameter error on Node " << i1p2 << endl;
2339 Nod12Flag |= NMskOutL;
2340 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2344 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U4;
2345 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U4;
2348 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2349 cout << "Parameter error on Node " << i2p2 << endl;
2353 Nod22Flag |= NMskOutL;
2354 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2358 if (!ins4) // p1 i1p3 p2
2359 MoveOrInsertPoint(List,
2360 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2361 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2363 Nod11Indices,Nod11RValues,
2364 Nod12Indices,Nod12RValues,
2365 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2366 Nod21Indices,Nod21RValues,
2367 Nod22Indices,Nod22RValues,
2368 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2369 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
2370 else if (!ins3) // p1 i2p4 p2
2371 MoveOrInsertPoint(List,
2372 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2373 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2375 Nod21Indices,Nod21RValues,
2376 Nod22Indices,Nod22RValues,
2377 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2378 Nod11Indices,Nod11RValues,
2379 Nod12Indices,Nod12RValues,
2380 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2381 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
2382 else { // p1 i1p3 i2p4 p2
2383 Standard_Integer i1p3 = pid1->AddNode
2384 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2385 Standard_Integer i2p3 = pid2->AddNode
2386 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2387 Standard_Integer i1p4 = pid1->AddNode
2388 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef4,X4,Y4,Z4);
2389 Standard_Integer i2p4 = pid2->AddNode
2390 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef4,X4,Y4,Z4);
2391 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2392 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2393 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2394 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2395 const Handle(HLRAlgo_PolyInternalNode)* pi1p4 =
2396 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p4));
2397 const Standard_Address Nod14Indices = (*pi1p4)->Indices();
2398 const Standard_Address Nod14RValues = (*pi1p4)->RValues();
2399 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2400 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2401 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2402 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2403 const Handle(HLRAlgo_PolyInternalNode)* pi2p4 =
2404 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p4));
2405 const Standard_Address Nod24Indices = (*pi2p4)->Indices();
2406 const Standard_Address Nod24RValues = (*pi2p4)->RValues();
2410 Nod13Flag |= NMskOutL;
2411 Nod13Flag |= NMskEdge;
2415 Nod23Flag |= NMskOutL;
2416 Nod23Flag |= NMskEdge;
2420 Nod14Flag |= NMskOutL;
2421 Nod14Flag |= NMskEdge;
2425 Nod24Flag |= NMskOutL;
2426 Nod24Flag |= NMskEdge;
2427 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2428 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2429 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2430 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2431 pid2->UpdateLinks(i2p3,i2p2,i2p4,
2432 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2433 pid1->UpdateLinks(i1p3,i1p2,i1p4,
2434 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2435 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2436 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2437 UpdateAroundNode(i1p4,Nod14Indices,TData1,PISeg1,PINod1);
2438 UpdateAroundNode(i2p4,Nod24Indices,TData2,PISeg2,PINod2);
2439 List.Prepend(HLRAlgo_BiPoint
2440 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2441 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2442 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2443 List.Prepend(HLRAlgo_BiPoint
2444 (XTI3,YTI3,ZTI3,XTI4,YTI4,ZTI4,
2445 X3 ,Y3 ,Z3 ,X4 ,Y4 ,Z4 , e,
2446 i1 ,i1p3,i1p4,i2 ,i2p3,i2p4,flag));
2447 List.Prepend(HLRAlgo_BiPoint
2448 (XTI4,YTI4,ZTI4,XTI2,YTI2,ZTI2,
2449 X4 ,Y4 ,Z4 ,X2 ,Y2 ,Z2 , e,
2450 i1 ,i1p4,i1p2,i2 ,i2p4,i2p2,flag));
2454 List.Prepend(HLRAlgo_BiPoint
2455 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2456 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2457 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2460 //=======================================================================
2461 //function : InsertOnOutLine
2463 //=======================================================================
2466 HLRBRep_PolyAlgo::InsertOnOutLine (TColStd_Array1OfTransient& PID)
2468 Standard_Address TData2 = 0;
2469 Standard_Address PISeg2 = 0;
2470 Standard_Address PINod2 = 0;
2471 Standard_Address Seg1Indices;
2472 Standard_Address Nod1Indices,Nod1RValues;
2473 Standard_Address Nod2Indices,Nod2RValues;
2474 Handle(HLRAlgo_PolyInternalData)* pid =
2475 (Handle(HLRAlgo_PolyInternalData)*) (&(PID.ChangeValue(1)));
2478 Standard_Boolean insP3,mP3P1,IntOutL;
2479 Standard_Integer f,ip1,ip2,ip3;//, i;
2480 Standard_Real U3,V3,coef3,X3,Y3,Z3;
2482 const gp_Trsf& T = myProj.Transformation();
2484 Standard_Integer nbFace = myFMap.Extent();
2485 for (f = 1; f <= nbFace; f++) {
2487 if (!((*pid).IsNull())) {
2488 IntOutL = Standard_False;
2489 Standard_Address TData1= &((*pid)->TData());
2490 Standard_Address PISeg1= &((*pid)->PISeg());
2491 Standard_Address PINod1= &((*pid)->PINod());
2492 TopoDS_Shape LocalShape = myFMap(f);
2493 const TopoDS_Face& F = TopoDS::Face(LocalShape);
2494 myBSurf.Initialize(F,Standard_False);
2495 myGSurf = BRep_Tool::Surface(F,L);
2496 gp_Trsf TT = L.Transformation();
2498 const gp_XYZ& ttlo = TT.TranslationPart();
2502 const gp_Mat& ttma = TT.VectorialPart();
2503 TTMa[0][0] = ttma.Value(1,1);
2504 TTMa[0][1] = ttma.Value(1,2);
2505 TTMa[0][2] = ttma.Value(1,3);
2506 TTMa[1][0] = ttma.Value(2,1);
2507 TTMa[1][1] = ttma.Value(2,2);
2508 TTMa[1][2] = ttma.Value(2,3);
2509 TTMa[2][0] = ttma.Value(3,1);
2510 TTMa[2][1] = ttma.Value(3,2);
2511 TTMa[2][2] = ttma.Value(3,3);
2512 Standard_Integer iseg,nbT,nbS,nbN;
2514 nbT = (*pid)->NbTData();
2515 nbN = (*pid)->NbPINod();
2516 nbS = (*pid)->NbPISeg();
2520 cout << " InsertOnOutLine : NbTData " << nbT << endl;
2521 cout << " InsertOnOutLine : NbPISeg " << nbS << endl;
2522 cout << " InsertOnOutLine : NbPINod " << nbN << endl;
2526 for (iseg = 1; iseg <= nbS; iseg++) {
2528 ((HLRAlgo_Array1OfPISeg*)PISeg1)->ChangeValue(iseg).Indices();
2529 // Standard_Boolean Cutted = Standard_False;
2530 if (Seg1Conex1 != 0 && Seg1Conex2 != 0) {
2533 const Handle(HLRAlgo_PolyInternalNode)* pip1 =
2534 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip1));
2535 Nod1Indices = (*pip1)->Indices();
2536 Nod1RValues = (*pip1)->RValues();
2537 const Handle(HLRAlgo_PolyInternalNode)* pip2 =
2538 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip2));
2539 Nod2Indices = (*pip2)->Indices();
2540 Nod2RValues = (*pip2)->RValues();
2541 if (Nod1Flag & NMskOutL && Nod2Flag & NMskOutL)
2542 IntOutL = Standard_True;
2543 else if ((Nod1Scal >= myTolAngular &&
2544 Nod2Scal <= -myTolAngular) ||
2545 (Nod2Scal >= myTolAngular &&
2546 Nod1Scal <= -myTolAngular)) {
2547 IntOutL = Standard_True;
2548 insP3 = NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1);
2550 UVNode(Nod1RValues,Nod2RValues,coef3,U3,V3);
2551 const gp_Pnt& PT3 = myGSurf->Value(U3,V3);
2555 TTMultiply(X3,Y3,Z3);
2558 if (insP3 && mP3P1) { // P1 ---> P3
2559 if ((Nod1Flag & NMskEdge) == 0 && coef3 < myTolSta) {
2560 insP3 = Standard_False;
2562 Nod1Indices,Nod1RValues,
2563 Nod2Indices,Nod2RValues,
2564 coef3,X3,Y3,Z3,Standard_True,
2565 TData1,PISeg1,PINod1);
2567 Nod1Flag |= NMskOutL;
2570 if (insP3 && !mP3P1) { // P2 ---> P3
2571 if ((Nod2Flag & NMskEdge) == 0 && coef3 > myTolEnd) {
2572 insP3 = Standard_False;
2574 Nod1Indices,Nod1RValues,
2575 Nod2Indices,Nod2RValues,
2576 coef3,X3,Y3,Z3,Standard_False,
2577 TData1,PISeg1,PINod1);
2579 Nod2Flag |= NMskOutL;
2582 if (insP3) { // p1 ip3 p2
2583 ip3 = (*pid)->AddNode(Nod1RValues,Nod2RValues,PINod1,PINod2,
2585 const Handle(HLRAlgo_PolyInternalNode)* pip3 =
2586 (&((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip3));
2587 const Standard_Address Nod3Indices = (*pip3)->Indices();
2588 const Standard_Address Nod3RValues = (*pip3)->RValues();
2589 (*pid)->UpdateLinks(ip1,ip2,ip3,
2590 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2591 UpdateAroundNode(ip3,Nod3Indices,TData1,PISeg1,PINod1);
2593 Nod3Flag |= NMskOutL;
2599 (*pid)->IntOutL(Standard_True);
2601 nbT = (*pid)->NbTData();
2602 nbN = (*pid)->NbPINod();
2603 nbS = (*pid)->NbPISeg();
2607 cout << " InsertOnOutLine : NbTData " << nbT << endl;
2608 cout << " InsertOnOutLine : NbPISeg " << nbS << endl;
2609 cout << " InsertOnOutLine : NbPINod " << nbN << endl;
2617 //=======================================================================
2618 //function : CheckFrBackTriangles
2620 //=======================================================================
2623 HLRBRep_PolyAlgo::CheckFrBackTriangles (HLRAlgo_ListOfBPoint& List,
2624 TColStd_Array1OfTransient& PID)
2626 Standard_Integer f,i,nbN,nbT,nbFace;
2627 Standard_Real X1 =0.,Y1 =0.,X2 =0.,Y2 =0.,X3 =0.,Y3 =0.;
2628 Standard_Real D1,D2,D3;
2629 Standard_Real dd,dX,dY,nX,nY;
2630 Standard_Boolean FrBackInList;
2631 Standard_Address TData ,PISeg ,PINod ;
2633 /* Standard_Address IndexPtr = NULL;
2634 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2635 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2636 Standard_Address TData1 = &pid1->TData(),
2637 PISeg1 = &pid1->PISeg(),
2638 PINod1 = &pid1->PINod();
2640 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2641 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2642 Standard_Address TData2 = &pid2->TData(),
2643 PISeg2 = &pid2->PISeg(),
2644 PINod2 = &pid2->PISeg();*/
2645 Standard_Address TData1 = NULL,PISeg1 = NULL,PINod1 = NULL;
2646 Standard_Address TData2 = NULL,PISeg2 = NULL,PINod2 = NULL;
2648 Standard_Address TData1,PISeg1,PINod1;
2649 Standard_Address TData2,PISeg2,PINod2;
2651 Standard_Address Nod11Indices,Nod12Indices,Nod13Indices;
2652 Standard_Address Nod11RValues,Nod12RValues,Nod13RValues;
2653 Standard_Address Tri1Indices;
2655 Handle(HLRAlgo_PolyInternalData)* pid;
2657 nbFace = myFMap.Extent();
2658 Standard_Boolean Modif = Standard_True;
2659 Standard_Integer iLoop = 0;
2661 while (Modif && iLoop < 4) {
2663 Modif = Standard_False;
2664 FrBackInList = Standard_False;
2665 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2667 for (f = 1; f <= nbFace; f++) {
2668 if (!(*pid).IsNull()) {
2669 nbT = (*pid)->NbTData();
2670 TData = &(*pid)->TData();
2671 PISeg = &(*pid)->PISeg();
2672 PINod = &(*pid)->PINod();
2673 HLRAlgo_TriangleData* tdata =
2674 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
2676 for (i = 1; i <= nbT; i++) {
2677 Tri1Indices = tdata->Indices();
2678 if ((Tri1Flags & FMskSide) == 0 &&
2679 (Tri1Flags & FMskFrBack)) {
2682 cout << " face : " << f << " , triangle " << i << endl;
2684 Modif = Standard_True;
2685 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
2686 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
2687 Nod11Indices = (*pi1p1)->Indices();
2688 Nod11RValues = (*pi1p1)->RValues();
2689 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
2690 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
2691 Nod12Indices = (*pi1p2)->Indices();
2692 Nod12RValues = (*pi1p2)->RValues();
2693 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2694 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
2695 Nod13Indices = (*pi1p3)->Indices();
2696 Nod13RValues = (*pi1p3)->RValues();
2697 D1 = 0.; D2 = 0.; D3 = 0.;
2698 if (((Nod11Flag & NMskEdge) == 0 || iLoop > 1) &&
2699 ((Nod11Flag & NMskOutL) == 0 || iLoop > 1) &&
2700 ((Nod11Flag & NMskVert) == 0)) {
2701 dX = Nod13PntX - Nod12PntX; dY = Nod13PntY - Nod12PntY;
2702 D1 = dX * dX + dY * dY;
2704 nX = - dY / D1; nY = dX / D1;
2705 dX = Nod11PntX - Nod12PntX; dY = Nod11PntY - Nod12PntY;
2706 dd = - (dX * nX + dY * nY);
2707 if (dd < 0) dd -= D1 * 0.01;
2708 else dd += D1 * 0.01;
2709 X1 = nX * dd; Y1 = nY * dd;
2711 if (((Nod12Flag & NMskEdge) == 0 || iLoop > 1) &&
2712 ((Nod12Flag & NMskOutL) == 0 || iLoop > 1) &&
2713 ((Nod12Flag & NMskVert) == 0)) {
2714 dX = Nod11PntX - Nod13PntX; dY = Nod11PntY - Nod13PntY;
2715 D2 = dX * dX + dY * dY;
2717 nX = - dY / D2; nY = dX / D2;
2718 dX = Nod12PntX - Nod13PntX; dY = Nod12PntY - Nod13PntY;
2719 dd = - (dX * nX + dY * nY);
2720 if (dd < 0) dd -= D2 * 0.01;
2721 else dd += D2 * 0.01;
2722 X2 = nX * dd; Y2 = nY * dd;
2724 if (((Nod13Flag & NMskEdge) == 0 || iLoop > 1) &&
2725 ((Nod13Flag & NMskOutL) == 0 || iLoop > 1) &&
2726 ((Nod13Flag & NMskVert) == 0)) {
2727 dX = Nod12PntX - Nod11PntX; dY = Nod12PntY - Nod11PntY;
2728 D3 = dX * dX + dY * dY;
2730 nX = - dY / D3; nY = dX / D3;
2731 dX = Nod13PntX - Nod11PntX; dY = Nod13PntY - Nod11PntY;
2732 dd = - (dX * nX + dY * nY);
2733 if (dd < 0) dd -= D3 * 0.01;
2734 else dd += D3 * 0.01;
2735 X3 = nX * dd; Y3 = nY * dd;
2737 if (D1 > D2 && D1 > D3) {
2738 Nod11PntX += X1; Nod11PntY += Y1;
2739 Nod11Flag |= NMskMove;
2740 UpdateAroundNode(Tri1Node1,Nod11Indices,TData,PISeg,PINod);
2741 FrBackInList = Standard_True;
2744 cout << Tri1Node1 << " modifies : DX,DY ";
2745 cout << X1 << " , " << Y1 << endl;
2749 else if (D2 > D3 && D2 > D1) {
2750 Nod12PntX += X2; Nod12PntY += Y2;
2751 Nod12Flag |= NMskMove;
2752 UpdateAroundNode(Tri1Node2,Nod12Indices,TData,PISeg,PINod);
2753 FrBackInList = Standard_True;
2756 cout << Tri1Node2 << " modifies : DX,DY ";
2757 cout << X2 << " , " << Y2 << endl;
2761 else if (D3 > D1 && D3 > D2) {
2762 Nod13PntX += X3; Nod13PntY += Y3;
2763 Nod13Flag |= NMskMove;
2764 UpdateAroundNode(Tri1Node3,Nod13Indices,TData,PISeg,PINod);
2765 FrBackInList = Standard_True;
2768 cout << Tri1Node3 << " modifies : DX,DY ";
2769 cout << X3 << " , " << Y3 << endl;
2775 cout << "modification error" << endl;
2784 Standard_Address IndexPtr,Coordinates;
2785 HLRAlgo_ListIteratorOfListOfBPoint it;
2787 for (it.Initialize(List); it.More(); it.Next()) {
2788 HLRAlgo_BiPoint& BP = it.Value();
2789 IndexPtr = BP.Indices();
2791 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2792 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2793 TData1 = &pid1->TData();
2794 PISeg1 = &pid1->PISeg();
2795 PINod1 = &pid1->PINod();
2798 if (F1Index == F2Index) {
2804 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2805 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2806 TData2 = &pid2->TData();
2807 PISeg2 = &pid2->PISeg();
2808 PINod2 = &pid2->PINod();
2812 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2813 ChangeValue(F1Pt1Index))->Indices();
2814 if (Nod11Flag & NMskMove) {
2817 cout << F1Pt1Index << " modifies 11" << endl;
2819 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2820 ChangeValue(F1Pt1Index))->RValues();
2821 Coordinates = BP.Coordinates();
2822 PntXTI1 = PntX1 = Nod11PntX;
2823 PntYTI1 = PntY1 = Nod11PntY;
2824 PntZTI1 = PntZ1 = Nod11PntZ;
2825 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2827 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2828 ChangeValue(F2Pt1Index))->Indices();
2829 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2830 ChangeValue(F2Pt1Index))->RValues();
2831 Nod12PntX = Nod11PntX;
2832 Nod12PntY = Nod11PntY;
2833 UpdateAroundNode(F2Pt1Index,Nod12Indices,
2834 TData2,PISeg2,PINod2);
2837 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2838 ChangeValue(F1Pt2Index))->Indices();
2839 if (Nod11Flag & NMskMove) {
2842 cout << F1Pt2Index << " modifies 12" << endl;
2844 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2845 ChangeValue(F1Pt2Index))->RValues();
2846 Coordinates = BP.Coordinates();
2847 PntXTI2 = PntX2 = Nod11PntX;
2848 PntYTI2 = PntY2 = Nod11PntY;
2849 PntZTI2 = PntZ2 = Nod11PntZ;
2850 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2852 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2853 ChangeValue(F2Pt2Index))->Indices();
2854 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2855 ChangeValue(F2Pt2Index))->RValues();
2856 Nod12PntX = Nod11PntX;
2857 Nod12PntY = Nod11PntY;
2858 UpdateAroundNode(F2Pt2Index,Nod12Indices,
2859 TData2,PISeg2,PINod2);
2864 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2865 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2866 PINod2 = &pid2->PINod();
2867 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2868 ChangeValue(F2Pt1Index))->Indices();
2869 if (Nod11Flag & NMskMove) {
2872 cout << F2Pt1Index << " modifies 21" << endl;
2874 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2875 ChangeValue(F2Pt1Index))->RValues();
2876 Coordinates = BP.Coordinates();
2877 PntXTI1 = PntX1 = Nod11PntX;
2878 PntYTI1 = PntY1 = Nod11PntY;
2879 PntZTI1 = PntZ1 = Nod11PntZ;
2880 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2882 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2883 ChangeValue(F1Pt1Index))->Indices();
2884 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2885 ChangeValue(F1Pt1Index))->RValues();
2886 Nod12PntX = Nod11PntX;
2887 Nod12PntY = Nod11PntY;
2888 UpdateAroundNode(F1Pt1Index,Nod12Indices,
2889 TData1,PISeg1,PINod1);
2892 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2893 ChangeValue(F2Pt2Index))->Indices();
2894 if (Nod11Flag & NMskMove) {
2897 cout << F2Pt2Index << " modifies 22" << endl;
2899 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2900 ChangeValue(F2Pt2Index))->RValues();
2901 Coordinates = BP.Coordinates();
2902 PntXTI2 = PntX2 = Nod11PntX;
2903 PntYTI2 = PntY2 = Nod11PntY;
2904 PntZTI2 = PntZ2 = Nod11PntZ;
2905 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2907 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2908 ChangeValue(F1Pt2Index))->Indices();
2909 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2910 ChangeValue(F1Pt2Index))->RValues();
2911 Nod12PntX = Nod11PntX;
2912 Nod12PntY = Nod11PntY;
2913 UpdateAroundNode(F1Pt2Index,Nod12Indices,
2914 TData1,PISeg1,PINod1);
2919 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2921 for (f = 1; f <= nbFace; f++) {
2922 if (!(*pid).IsNull()) {
2923 nbN = (*pid)->NbPINod();
2924 PINod = &(*pid)->PINod();
2925 Handle(HLRAlgo_PolyInternalNode)* NN =
2926 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
2928 for (i = 1; i <= nbN; i++) {
2929 Nod11Indices = (*NN)->Indices();
2930 Nod11Flag &= ~NMskMove;
2940 //=======================================================================
2941 //function : FindEdgeOnTriangle
2943 //=======================================================================
2947 FindEdgeOnTriangle (const Standard_Address Tri1Indices,
2948 const Standard_Integer ip1,
2949 const Standard_Integer ip2,
2950 Standard_Integer& jtrouv,
2951 Standard_Boolean& isDirect) const
2953 Standard_Integer n1 = Tri1Node1;
2954 Standard_Integer n2 = Tri1Node2;
2955 Standard_Integer n3 = Tri1Node3;
2956 if (ip1 == n1 && ip2 == n2) {
2958 isDirect = Standard_True;
2961 else if (ip2 == n1 && ip1 == n2) {
2963 isDirect = Standard_False;
2966 else if (ip1 == n2 && ip2 == n3) {
2968 isDirect = Standard_True;
2971 else if (ip2 == n2 && ip1 == n3) {
2973 isDirect = Standard_False;
2976 else if (ip1 == n3 && ip2 == n1) {
2978 isDirect = Standard_True;
2981 else if (ip2 == n3 && ip1 == n1) {
2983 isDirect = Standard_False;
2988 //=======================================================================
2989 //function : ChangeNode
2991 //=======================================================================
2993 void HLRBRep_PolyAlgo::ChangeNode (const Standard_Integer ip1,
2994 const Standard_Integer ip2,
2995 const Standard_Address Nod1Indices,
2996 const Standard_Address Nod1RValues,
2997 const Standard_Address Nod2Indices,
2998 const Standard_Address Nod2RValues,
2999 const Standard_Real coef1,
3000 const Standard_Real X3,
3001 const Standard_Real Y3,
3002 const Standard_Real Z3,
3003 const Standard_Boolean first,
3004 Standard_Address& TData,
3005 Standard_Address& PISeg,
3006 Standard_Address& PINod) const
3008 Standard_Real coef2 = 1 - coef1;
3013 Nod1PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3014 Nod1PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3015 Nod1Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3016 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3017 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3018 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3019 Standard_Real D = sqrt (x * x + y * y + z * z);
3031 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip1;
3032 cout << " and " << ip2 << endl;
3036 UpdateAroundNode(ip1,Nod1Indices,TData,PISeg,PINod);
3042 Nod2PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3043 Nod2PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3044 Nod2Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3045 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3046 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3047 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3048 Standard_Real D = sqrt (x * x + y * y + z * z);
3061 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip2;
3062 cout << " and " << ip1 << endl;
3066 UpdateAroundNode(ip2,Nod2Indices,TData,PISeg,PINod);
3070 //=======================================================================
3071 //function : UpdateAroundNode
3073 //=======================================================================
3075 void HLRBRep_PolyAlgo::
3076 UpdateAroundNode (const Standard_Integer iNode,
3077 const Standard_Address Nod1Indices,
3078 const Standard_Address TData,
3079 const Standard_Address PISeg,
3080 const Standard_Address PINod) const
3082 Standard_Integer iiii,iTri1,iTri2;
3086 const Standard_Address Seg1Indices =
3087 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3091 const Standard_Address Tri1Indices =
3092 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri1).Indices();
3093 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3094 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
3095 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3096 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
3097 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3098 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
3099 const Standard_Address Nod1Indices = (*PN1)->Indices();
3100 const Standard_Address Nod2Indices = (*PN2)->Indices();
3101 const Standard_Address Nod3Indices = (*PN3)->Indices();
3102 const Standard_Address Nod1RValues = (*PN1)->RValues();
3103 const Standard_Address Nod2RValues = (*PN2)->RValues();
3104 const Standard_Address Nod3RValues = (*PN3)->RValues();
3105 OrientTriangle(iTri1,Tri1Indices,
3106 Nod1Indices,Nod1RValues,
3107 Nod2Indices,Nod2RValues,
3108 Nod3Indices,Nod3RValues);
3111 const Standard_Address Tri2Indices =
3112 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri2).Indices();
3113 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3114 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1));
3115 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3116 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2));
3117 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3118 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3));
3119 const Standard_Address Nod1Indices = (*PN1)->Indices();
3120 const Standard_Address Nod2Indices = (*PN2)->Indices();
3121 const Standard_Address Nod3Indices = (*PN3)->Indices();
3122 const Standard_Address Nod1RValues = (*PN1)->RValues();
3123 const Standard_Address Nod2RValues = (*PN2)->RValues();
3124 const Standard_Address Nod3RValues = (*PN3)->RValues();
3125 OrientTriangle(iTri2,Tri2Indices,
3126 Nod1Indices,Nod1RValues,
3127 Nod2Indices,Nod2RValues,
3128 Nod3Indices,Nod3RValues);
3130 if (Seg1LstSg1 == iNode) iiii = Seg1NxtSg1;
3131 else iiii = Seg1NxtSg2;
3135 //=======================================================================
3136 //function : OrientTriangle
3138 //=======================================================================
3141 HLRBRep_PolyAlgo::OrientTriangle(const Standard_Integer iTri,
3142 const Standard_Address Tri1Indices,
3143 const Standard_Address Nod1Indices,
3144 const Standard_Address Nod1RValues,
3145 const Standard_Address Nod2Indices,
3146 const Standard_Address Nod2RValues,
3147 const Standard_Address Nod3Indices,
3148 const Standard_Address Nod3RValues) const
3150 Standard_Boolean o1 = Nod1Flag & NMskOutL;
3151 Standard_Boolean o2 = Nod2Flag & NMskOutL;
3152 Standard_Boolean o3 = Nod3Flag & NMskOutL;
3153 Tri1Flags &= ~FMskFlat;
3154 Tri1Flags &= ~FMskOnOutL;
3155 if (o1 && o2 && o3) {
3156 Tri1Flags |= FMskSide;
3157 Tri1Flags &= ~FMskBack;
3158 Tri1Flags |= FMskOnOutL;
3161 cout << "HLRBRep_PolyAlgo::OrientTriangle : OnOutL";
3162 cout << " triangle " << iTri << endl;
3167 Standard_Real s1 = Nod1Scal;
3168 Standard_Real s2 = Nod2Scal;
3169 Standard_Real s3 = Nod3Scal;
3170 Standard_Real as1 = s1;
3171 Standard_Real as2 = s2;
3172 Standard_Real as3 = s3;
3173 if (s1 < 0) as1 = -s1;
3174 if (s2 < 0) as2 = -s2;
3175 if (s3 < 0) as3 = -s3;
3176 Standard_Real s = 0;
3177 Standard_Real as = 0;
3178 if (!o1 ) {s = s1; as = as1;}
3179 if (!o2 && as < as2) {s = s2; as = as2;}
3180 if (!o3 && as < as3) {s = s3; as = as3;}
3182 Tri1Flags &= ~FMskSide;
3183 Tri1Flags |= FMskBack;
3186 Tri1Flags &= ~FMskSide;
3187 Tri1Flags &= ~FMskBack;
3189 Standard_Real dx12 = Nod2PntX - Nod1PntX;
3190 Standard_Real dy12 = Nod2PntY - Nod1PntY;
3191 Standard_Real dz12 = Nod2PntZ - Nod1PntZ;
3192 Standard_Real d12 = sqrt(dx12 * dx12 + dy12 * dy12 + dz12 * dz12);
3193 if (d12 <= 1.e-10) {
3196 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3197 cout << " triangle " << iTri << endl;
3200 Tri1Flags |= FMskFlat;
3201 Tri1Flags |= FMskSide;
3202 Tri1Flags &= ~FMskBack;
3205 Standard_Real dx23 = Nod3PntX - Nod2PntX;
3206 Standard_Real dy23 = Nod3PntY - Nod2PntY;
3207 Standard_Real dz23 = Nod3PntZ - Nod2PntZ;
3208 Standard_Real d23 = sqrt(dx23 * dx23 + dy23 * dy23 + dz23 * dz23);
3212 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3213 cout << " triangle " << iTri << endl;
3216 Tri1Flags |= FMskFlat;
3217 Tri1Flags |= FMskSide;
3218 Tri1Flags &= ~FMskBack;
3221 Standard_Real dx31 = Nod1PntX - Nod3PntX;
3222 Standard_Real dy31 = Nod1PntY - Nod3PntY;
3223 Standard_Real dz31 = Nod1PntZ - Nod3PntZ;
3224 Standard_Real d31 = sqrt(dx31 * dx31 + dy31 * dy31 + dz31 * dz31);
3228 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3229 cout << " triangle " << iTri << endl;
3232 Tri1Flags |= FMskFlat;
3233 Tri1Flags |= FMskSide;
3234 Tri1Flags &= ~FMskBack;
3243 Standard_Real dx = dy12 * dz23 - dz12 * dy23;
3244 Standard_Real dy = dz12 * dx23 - dx12 * dz23;
3245 Standard_Real dz = dx12 * dy23 - dy12 * dx23;
3246 Standard_Real d = sqrt(dx * dx + dy * dy + dz * dz);
3250 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3251 cout << " triangle " << iTri << endl;
3254 Tri1Flags |= FMskFlat;
3255 Tri1Flags |= FMskSide;
3256 Tri1Flags &= ~FMskBack;
3260 if (myProj.Perspective()) {
3264 o = ( dz * myProj.Focus()
3272 Tri1Flags |= FMskOrBack;
3276 Tri1Flags &= ~FMskOrBack;
3278 Tri1Flags |= FMskSide;
3279 Tri1Flags &= ~FMskBack;
3286 if ((!(Tri1Flags & FMskBack) && (Tri1Flags & FMskOrBack)) ||
3287 ( (Tri1Flags & FMskBack) && !(Tri1Flags & FMskOrBack)))
3288 Tri1Flags |= FMskFrBack;
3290 Tri1Flags &= ~FMskFrBack;
3293 //=======================================================================
3294 //function : Triangles
3296 //=======================================================================
3299 HLRBRep_PolyAlgo::Triangles(const Standard_Integer ip1,
3300 const Standard_Integer ip2,
3301 const Standard_Address Nod1Indices,
3302 Standard_Address& PISeg,
3303 Standard_Integer& iTri1,
3304 Standard_Integer& iTri2) const
3306 Standard_Address Seg1Indices;
3307 Standard_Integer iiii = Nod1NdSg;
3311 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3312 if (Seg1LstSg1 == ip1) {
3313 if (Seg1LstSg2 == ip2) {
3316 return Standard_True;
3318 else iiii = Seg1NxtSg1;
3321 if (Seg1LstSg1 == ip2) {
3324 return Standard_True;
3326 else iiii = Seg1NxtSg2;
3333 cout << "HLRBRep_PolyAlgo::Triangles : error";
3334 cout << " between " << ip1 << " and " << ip2 << endl;
3337 return Standard_False;
3340 //=======================================================================
3341 //function : NewNode
3343 //=======================================================================
3347 NewNode (const Standard_Address Nod1RValues,
3348 const Standard_Address Nod2RValues,
3349 Standard_Real& coef1,
3350 Standard_Boolean& moveP1) const
3352 Standard_Real TolAng = myTolAngular * 0.5;
3353 if ((Nod1Scal >= TolAng && Nod2Scal <= -TolAng) ||
3354 (Nod2Scal >= TolAng && Nod1Scal <= -TolAng)) {
3355 coef1 = Nod1Scal / ( Nod2Scal - Nod1Scal );
3356 if (coef1 < 0) coef1 = - coef1;
3357 moveP1 = coef1 < 0.5;
3358 return Standard_True;
3360 return Standard_False;
3363 //=======================================================================
3366 //=======================================================================
3369 HLRBRep_PolyAlgo::UVNode (const Standard_Address Nod1RValues,
3370 const Standard_Address Nod2RValues,
3371 const Standard_Real coef1,
3373 Standard_Real& V3) const
3375 Standard_Real coef2 = 1 - coef1;
3376 U3 = Nod1PntU * coef2 + Nod2PntU * coef1;
3377 V3 = Nod1PntV * coef2 + Nod2PntV * coef1;
3380 //=======================================================================
3381 //function : CheckDegeneratedSegment
3383 //=======================================================================
3387 CheckDegeneratedSegment(const Standard_Address Nod1Indices,
3388 const Standard_Address Nod1RValues,
3389 const Standard_Address Nod2Indices,
3390 const Standard_Address Nod2RValues) const
3392 Nod1Flag |= NMskFuck;
3393 Nod2Flag |= NMskFuck;
3394 if ((Nod1Scal >= myTolAngular && Nod2Scal <= -myTolAngular) ||
3395 (Nod2Scal >= myTolAngular && Nod1Scal <= -myTolAngular)) {
3397 Nod1Flag |= NMskOutL;
3399 Nod2Flag |= NMskOutL;
3403 //=======================================================================
3404 //function : UpdateOutLines
3406 //=======================================================================
3409 HLRBRep_PolyAlgo::UpdateOutLines (HLRAlgo_ListOfBPoint& List,
3410 TColStd_Array1OfTransient& PID)
3413 Standard_Integer nbFace = myFMap.Extent();
3414 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
3415 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
3417 Handle(HLRAlgo_PolyInternalData)* pid =
3418 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3420 for (f = 1; f <= nbFace; f++) {
3421 if (!(*pid).IsNull()) {
3422 if ((*pid)->IntOutL()) {
3423 Standard_Address TData = &((*pid)->TData());
3424 Standard_Address PISeg = &((*pid)->PISeg());
3425 Standard_Address PINod = &((*pid)->PINod());
3426 Standard_Integer i,j,it1,it2,tn1,tn2,tn3,pd,pf;
3427 Standard_Address Seg2Indices,Tri1Indices,Tri2Indices;
3428 Standard_Boolean outl;
3429 Standard_Integer nbS = (*pid)->NbPISeg();
3430 HLRAlgo_PolyInternalSegment* psg =
3431 &(((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(1));
3433 for (i = 1; i <= nbS; i++) {
3434 Seg2Indices = psg->Indices();
3437 if (it1 != 0 && it2 != 0 && it1 != it2) { // debile but sure !
3438 Tri1Indices = ((HLRAlgo_Array1OfTData*)TData)->
3439 ChangeValue(it1).Indices();
3440 Tri2Indices = ((HLRAlgo_Array1OfTData*)TData)->
3441 ChangeValue(it2).Indices();
3442 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3443 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3444 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3445 outl = Standard_False;
3446 else if ( Tri1Flags & FMskSide)
3447 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3449 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3457 if (!(Tri1Flags & FMskSide) && (Tri1Flags & FMskOrBack)) {
3462 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3463 Tri1Flags |= EMskOutLin1;
3464 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3465 Tri1Flags |= EMskOutLin2;
3466 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3467 Tri1Flags |= EMskOutLin3;
3470 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3471 cout << " : segment not found" << endl;
3477 if (!(Tri2Flags & FMskSide) && (Tri2Flags & FMskOrBack)) {
3482 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3483 Tri2Flags |= EMskOutLin1;
3484 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3485 Tri2Flags |= EMskOutLin2;
3486 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3487 Tri2Flags |= EMskOutLin3;
3490 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3491 cout << " : segment not found" << endl;
3494 Standard_Address Nod1RValues =
3495 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pd)->RValues();
3496 Standard_Address Nod2RValues =
3497 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pf)->RValues();
3498 XTI1 = X1 = Nod1PntX;
3499 YTI1 = Y1 = Nod1PntY;
3500 ZTI1 = Z1 = Nod1PntZ;
3501 XTI2 = X2 = Nod2PntX;
3502 YTI2 = Y2 = Nod2PntY;
3503 ZTI2 = Z2 = Nod2PntZ;
3504 TIMultiply(XTI1,YTI1,ZTI1);
3505 TIMultiply(XTI2,YTI2,ZTI2);
3506 List.Append(HLRAlgo_BiPoint(XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
3507 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
3508 f,f,pd,pf,f,pd,pf,12));
3519 //=======================================================================
3520 //function : UpdateEdgesBiPoints
3522 //=======================================================================
3524 void HLRBRep_PolyAlgo::
3525 UpdateEdgesBiPoints (HLRAlgo_ListOfBPoint& List,
3526 const TColStd_Array1OfTransient& PID,
3527 const Standard_Boolean closed)
3529 Standard_Integer itri1,itri2,tbid;
3530 Standard_Boolean OK;
3531 HLRAlgo_ListIteratorOfListOfBPoint it;
3533 for (it.Initialize(List); it.More(); it.Next()) {
3534 HLRAlgo_BiPoint& BP = it.Value();
3535 // Standard_Integer i[5];
3536 Standard_Address IndexPtr = BP.Indices();
3537 if (F1Index != 0 && F2Index != 0) {
3538 const Handle(HLRAlgo_PolyInternalData)& pid1 =
3539 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
3540 const Handle(HLRAlgo_PolyInternalData)& pid2 =
3541 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
3542 Standard_Address PISeg1 = &pid1->PISeg();
3543 Standard_Address PISeg2 = &pid2->PISeg();
3544 Standard_Address Nod11Indices =
3545 pid1->PINod().ChangeValue(F1Pt1Index)->Indices();
3546 Standard_Address Nod21Indices =
3547 pid2->PINod().ChangeValue(F2Pt1Index)->Indices();
3548 OK = Triangles(F1Pt1Index,F1Pt2Index,Nod11Indices,PISeg1,itri1,tbid);
3549 OK = Triangles(F2Pt1Index,F2Pt2Index,Nod21Indices,PISeg2,itri2,tbid);
3551 if (itri1 != 0 && itri2 != 0) {
3552 if (F1Index != F2Index || itri1 != itri2) {
3553 Standard_Address TData1 = &pid1->TData();
3554 Standard_Address TData2 = &pid2->TData();
3555 Standard_Address Tri1Indices =
3556 ((HLRAlgo_Array1OfTData*)TData1)->ChangeValue(itri1).Indices();
3557 Standard_Address Tri2Indices =
3558 ((HLRAlgo_Array1OfTData*)TData2)->ChangeValue(itri2).Indices();
3560 if (((Tri1Flags & FMskBack) && (Tri2Flags & FMskBack)) ||
3561 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskSide)) ||
3562 ((Tri1Flags & FMskBack) && (Tri2Flags & FMskSide)) ||
3563 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskBack)))
3564 BP.Hidden(Standard_True);
3566 Standard_Boolean outl;
3567 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3568 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3569 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3570 outl = Standard_False;
3571 else if ( (Tri1Flags & FMskSide))
3572 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3574 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3580 cout << "HLRBRep_PolyAlgo::UpdateEdgesBiPoints : error ";
3581 cout << " between " << F1Index << setw(6);
3582 cout << " and " << F2Index << endl;
3589 //=======================================================================
3590 //function : UpdatePolyData
3592 //=======================================================================
3595 HLRBRep_PolyAlgo::UpdatePolyData (TColStd_Array1OfTransient& PD,
3596 TColStd_Array1OfTransient& PID,
3597 const Standard_Boolean closed)
3599 Standard_Integer f,i;//,n[3];
3600 Handle(TColgp_HArray1OfXYZ) HNodes;
3601 Handle(HLRAlgo_HArray1OfTData) HTData;
3602 Handle(HLRAlgo_HArray1OfPHDat) HPHDat;
3603 Standard_Integer nbFace = myFMap.Extent();
3604 Handle(HLRAlgo_PolyInternalData)* pid =
3605 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3606 Handle(HLRAlgo_PolyData)* pd =
3607 (Handle(HLRAlgo_PolyData)*)&(PD.ChangeValue(1));
3609 for (f = 1; f <= nbFace; f++) {
3610 if (!(*pid).IsNull()) {
3611 Standard_Integer nbN = (*pid)->NbPINod();
3612 Standard_Integer nbT = (*pid)->NbTData();
3613 HNodes = new TColgp_HArray1OfXYZ (1,nbN);
3614 HTData = new HLRAlgo_HArray1OfTData(1,nbT);
3615 TColgp_Array1OfXYZ& Nodes = HNodes->ChangeArray1();
3616 HLRAlgo_Array1OfTData& Trian = HTData->ChangeArray1();
3617 Standard_Address TData = &(*pid)->TData();
3618 Standard_Address PINod = &(*pid)->PINod();
3619 Standard_Integer nbHide = 0;
3620 Handle(HLRAlgo_PolyInternalNode)* ON =
3621 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
3622 gp_XYZ * NN = &(Nodes.ChangeValue(1));
3624 for (i = 1; i <= nbN; i++) {
3625 const Standard_Address Nod1RValues = (*ON)->RValues();
3626 NN->SetCoord(Nod1PntX,Nod1PntY,Nod1PntZ);
3631 HLRAlgo_TriangleData* OT =
3632 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
3633 HLRAlgo_TriangleData* NT = &(Trian.ChangeValue(1));
3634 Standard_Address Tri1Indices,Tri2Indices;
3636 for (i = 1; i <= nbT; i++) {
3637 Tri1Indices = OT->Indices();
3638 Tri2Indices = NT->Indices();
3639 if (!(Tri1Flags & FMskSide)) {
3641 if ((Tri1Flags & FMskFrBack) && DoTrace) {
3642 cout << "HLRBRep_PolyAlgo::ReverseBackTriangle :";
3643 cout << " face " << f << setw(6);
3644 cout << " triangle " << i << endl;
3647 if (Tri1Flags & FMskOrBack) {
3648 Standard_Integer j = Tri1Node1;
3649 Tri1Node1 = Tri1Node3;
3651 Tri1Flags |= FMskBack;
3654 Tri1Flags &= ~FMskBack;
3655 //Tri1Flags |= FMskBack;//OCC349
3657 Tri2Node1 = Tri1Node1;
3658 Tri2Node2 = Tri1Node2;
3659 Tri2Node3 = Tri1Node3;
3660 Tri2Flags = Tri1Flags;
3661 if (!(Tri2Flags & FMskSide) &&
3662 (!(Tri2Flags & FMskBack) || !closed)) {
3663 Tri2Flags |= FMskHiding;
3667 Tri2Flags &= ~FMskHiding;
3671 if (nbHide > 0) HPHDat = new HLRAlgo_HArray1OfPHDat(1,nbHide);
3672 else HPHDat.Nullify();
3673 (*pd)->HNodes(HNodes);
3674 (*pd)->HTData(HTData);
3675 (*pd)->HPHDat(HPHDat);
3676 (*pd)->FaceIndex(f);
3683 //=======================================================================
3684 //function : TMultiply
3686 //=======================================================================
3689 HLRBRep_PolyAlgo::TMultiply (Standard_Real& X,
3692 const Standard_Boolean VPO) const
3694 Standard_Real Xt = TMat[0][0]*X + TMat[0][1]*Y + TMat[0][2]*Z + (VPO ? 0 : TLoc[0]);//OCC349
3695 Standard_Real Yt = TMat[1][0]*X + TMat[1][1]*Y + TMat[1][2]*Z + (VPO ? 0 : TLoc[1]);//OCC349
3696 Z = TMat[2][0]*X + TMat[2][1]*Y + TMat[2][2]*Z + (VPO ? 0 : TLoc[2]);//OCC349
3701 //=======================================================================
3702 //function : TTMultiply
3704 //=======================================================================
3707 HLRBRep_PolyAlgo::TTMultiply (Standard_Real& X,
3710 const Standard_Boolean VPO) const
3712 Standard_Real Xt = TTMa[0][0]*X + TTMa[0][1]*Y + TTMa[0][2]*Z + (VPO ? 0 : TTLo[0]);//OCC349
3713 Standard_Real Yt = TTMa[1][0]*X + TTMa[1][1]*Y + TTMa[1][2]*Z + (VPO ? 0 : TTLo[1]);//OCC349
3714 Z = TTMa[2][0]*X + TTMa[2][1]*Y + TTMa[2][2]*Z + (VPO ? 0 : TTLo[2]);//OCC349
3719 //=======================================================================
3720 //function : TIMultiply
3722 //=======================================================================
3725 HLRBRep_PolyAlgo::TIMultiply (Standard_Real& X,
3728 const Standard_Boolean VPO) const
3730 Standard_Real Xt = TIMa[0][0]*X + TIMa[0][1]*Y + TIMa[0][2]*Z + (VPO ? 0 : TILo[0]);//OCC349
3731 Standard_Real Yt = TIMa[1][0]*X + TIMa[1][1]*Y + TIMa[1][2]*Z + (VPO ? 0 : TILo[1]);//OCC349
3732 Z = TIMa[2][0]*X + TIMa[2][1]*Y + TIMa[2][2]*Z + (VPO ? 0 : TILo[2]);//OCC349
3737 //=======================================================================
3740 //=======================================================================
3742 void HLRBRep_PolyAlgo::Hide (Standard_Address& Coordinates,
3743 HLRAlgo_EdgeStatus& status,
3745 Standard_Boolean& reg1,
3746 Standard_Boolean& regn,
3747 Standard_Boolean& outl,
3748 Standard_Boolean& intl)
3750 Standard_Integer index;
3751 myAlgo->Hide(Coordinates,status,index,reg1,regn,outl,intl);
3752 if (intl) S = myFMap(index);
3753 else S = myEMap(index);
3756 //=======================================================================
3759 //=======================================================================
3761 void HLRBRep_PolyAlgo::Show (Standard_Address& Coordinates,
3763 Standard_Boolean& reg1,
3764 Standard_Boolean& regn,
3765 Standard_Boolean& outl,
3766 Standard_Boolean& intl)
3768 Standard_Integer index;
3769 myAlgo->Show(Coordinates,index,reg1,regn,outl,intl);
3770 if (intl) S = myFMap(index);
3771 else S = myEMap(index);
3774 //=======================================================================
3775 //function : OutLinedShape
3777 //=======================================================================
3780 HLRBRep_PolyAlgo::OutLinedShape (const TopoDS_Shape& S) const
3782 TopoDS_Shape Result;
3786 B.MakeCompound(TopoDS::Compound(Result));
3789 TopTools_MapOfShape Map;
3791 for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next())
3792 Map.Add(ex.Current());
3793 for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next())
3794 Map.Add(ex.Current());
3796 Standard_Integer nbFace = myFMap.Extent();
3798 TopTools_Array1OfShape NewF(1,nbFace);
3799 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
3800 Standard_Integer nbShell = Shell.Upper();
3801 HLRAlgo_ListIteratorOfListOfBPoint it;
3803 for (Standard_Integer iShell = 1; iShell <= nbShell; iShell++) {
3804 HLRAlgo_ListOfBPoint& List =
3805 (*(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell)))->Edges();
3807 for (it.Initialize(List); it.More(); it.Next()) {
3808 HLRAlgo_BiPoint& BP = it.Value();
3810 Standard_Address IndexPtr = BP.Indices();
3811 if (Map.Contains(myFMap(ShapeIndex))) {
3812 Standard_Address Coordinates = BP.Coordinates();
3813 B.Add(Result,BRepLib_MakeEdge
3814 (gp_Pnt(PntXTI1,PntYTI1,PntZTI1),
3815 gp_Pnt(PntXTI2,PntYTI2,PntZTI2)));