1 // File: HLRBRep_PolyAlgo.cxx
2 // Created: Fri May 5 15:58:19 1995
3 // Author: Christophe MARION
4 // Copyright: OPEN CASCADE 2000
6 // Modified by cma, Tue Apr 1 11:39:48 1997
7 // Modified by cma, Tue Apr 1 11:40:30 1997
9 #include <Standard_Stream.hxx>
10 #include <HLRBRep_PolyAlgo.ixx>
11 #include <Standard_ErrorHandler.hxx>
12 #include <TColStd_HArray1OfTransient.hxx>
13 #include <TColStd_HArray1OfInteger.hxx>
15 #include <CSLib_DerivativeStatus.hxx>
16 #include <CSLib_NormalStatus.hxx>
17 #include <Geom_Surface.hxx>
18 #include <Geom_RectangularTrimmedSurface.hxx>
19 #include <HLRAlgo_ListIteratorOfListOfBPoint.hxx>
20 #include <HLRAlgo_PolyShellData.hxx>
21 #include <HLRAlgo_PolyData.hxx>
22 #include <HLRAlgo_BiPoint.hxx>
25 #include <TopExp_Explorer.hxx>
26 #include <TopTools_Array1OfShape.hxx>
27 #include <TopTools_ListIteratorOfListOfShape.hxx>
28 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
29 #include <Poly_Triangulation.hxx>
30 #include <Poly_Polygon3D.hxx>
31 #include <Poly_PolygonOnTriangulation.hxx>
32 #include <BRep_Builder.hxx>
33 #include <BRep_Tool.hxx>
34 #include <BRepLib_MakeEdge.hxx>
35 #include <Precision.hxx>
38 #define EMskOutLin1 ((Standard_Boolean) 1)
39 #define EMskOutLin2 ((Standard_Boolean) 2)
40 #define EMskOutLin3 ((Standard_Boolean) 4)
41 #define EMskGrALin1 ((Standard_Boolean) 8)
42 #define EMskGrALin2 ((Standard_Boolean) 16)
43 #define EMskGrALin3 ((Standard_Boolean) 32)
44 #define FMskBack ((Standard_Boolean) 64)
45 #define FMskSide ((Standard_Boolean) 128)
46 #define FMskHiding ((Standard_Boolean) 256)
47 #define FMskFlat ((Standard_Boolean) 512)
48 #define FMskOnOutL ((Standard_Boolean)1024)
49 #define FMskOrBack ((Standard_Boolean)2048)
50 #define FMskFrBack ((Standard_Boolean)4096)
52 #define NMskVert ((Standard_Boolean) 1)
53 #define NMskOutL ((Standard_Boolean) 2)
54 #define NMskNorm ((Standard_Boolean) 4)
55 #define NMskFuck ((Standard_Boolean) 8)
56 #define NMskEdge ((Standard_Boolean)16)
57 #define NMskMove ((Standard_Boolean)32)
59 #define PntXTI1 ((Standard_Real*)Coordinates)[ 0]
60 #define PntYTI1 ((Standard_Real*)Coordinates)[ 1]
61 #define PntZTI1 ((Standard_Real*)Coordinates)[ 2]
62 #define PntXTI2 ((Standard_Real*)Coordinates)[ 3]
63 #define PntYTI2 ((Standard_Real*)Coordinates)[ 4]
64 #define PntZTI2 ((Standard_Real*)Coordinates)[ 5]
65 #define PntX1 ((Standard_Real*)Coordinates)[ 6]
66 #define PntY1 ((Standard_Real*)Coordinates)[ 7]
67 #define PntZ1 ((Standard_Real*)Coordinates)[ 8]
68 #define PntX2 ((Standard_Real*)Coordinates)[ 9]
69 #define PntY2 ((Standard_Real*)Coordinates)[10]
70 #define PntZ2 ((Standard_Real*)Coordinates)[11]
72 #define Pn2XTI1 ((Standard_Real*)Coordinate2)[ 0]
73 #define Pn2YTI1 ((Standard_Real*)Coordinate2)[ 1]
74 #define Pn2ZTI1 ((Standard_Real*)Coordinate2)[ 2]
75 #define Pn2XTI2 ((Standard_Real*)Coordinate2)[ 3]
76 #define Pn2YTI2 ((Standard_Real*)Coordinate2)[ 4]
77 #define Pn2ZTI2 ((Standard_Real*)Coordinate2)[ 5]
78 #define Pn2X1 ((Standard_Real*)Coordinate2)[ 6]
79 #define Pn2Y1 ((Standard_Real*)Coordinate2)[ 7]
80 #define Pn2Z1 ((Standard_Real*)Coordinate2)[ 8]
81 #define Pn2X2 ((Standard_Real*)Coordinate2)[ 9]
82 #define Pn2Y2 ((Standard_Real*)Coordinate2)[10]
83 #define Pn2Z2 ((Standard_Real*)Coordinate2)[11]
85 #define Tri1Node1 ((Standard_Integer*)Tri1Indices)[0]
86 #define Tri1Node2 ((Standard_Integer*)Tri1Indices)[1]
87 #define Tri1Node3 ((Standard_Integer*)Tri1Indices)[2]
88 #define Tri1Flags ((Standard_Boolean*)Tri1Indices)[3]
90 #define Tri2Node1 ((Standard_Integer*)Tri2Indices)[0]
91 #define Tri2Node2 ((Standard_Integer*)Tri2Indices)[1]
92 #define Tri2Node3 ((Standard_Integer*)Tri2Indices)[2]
93 #define Tri2Flags ((Standard_Boolean*)Tri2Indices)[3]
95 #define Tri3Node1 ((Standard_Integer*)Tri3Indices)[0]
96 #define Tri3Node2 ((Standard_Integer*)Tri3Indices)[1]
97 #define Tri3Node3 ((Standard_Integer*)Tri3Indices)[2]
98 #define Tri3Flags ((Standard_Boolean*)Tri3Indices)[3]
100 #define Seg1LstSg1 ((Standard_Integer*)Seg1Indices)[0]
101 #define Seg1LstSg2 ((Standard_Integer*)Seg1Indices)[1]
102 #define Seg1NxtSg1 ((Standard_Integer*)Seg1Indices)[2]
103 #define Seg1NxtSg2 ((Standard_Integer*)Seg1Indices)[3]
104 #define Seg1Conex1 ((Standard_Integer*)Seg1Indices)[4]
105 #define Seg1Conex2 ((Standard_Integer*)Seg1Indices)[5]
107 #define Seg2LstSg1 ((Standard_Integer*)Seg2Indices)[0]
108 #define Seg2LstSg2 ((Standard_Integer*)Seg2Indices)[1]
109 #define Seg2NxtSg1 ((Standard_Integer*)Seg2Indices)[2]
110 #define Seg2NxtSg2 ((Standard_Integer*)Seg2Indices)[3]
111 #define Seg2Conex1 ((Standard_Integer*)Seg2Indices)[4]
112 #define Seg2Conex2 ((Standard_Integer*)Seg2Indices)[5]
114 #define Nod1NdSg ((Standard_Integer*)Nod1Indices)[0]
115 #define Nod1Flag ((Standard_Boolean*)Nod1Indices)[1]
116 #define Nod1Edg1 ((Standard_Boolean*)Nod1Indices)[2]
117 #define Nod1Edg2 ((Standard_Boolean*)Nod1Indices)[3]
119 #define Nod1PntX ((Standard_Real*)Nod1RValues)[ 0]
120 #define Nod1PntY ((Standard_Real*)Nod1RValues)[ 1]
121 #define Nod1PntZ ((Standard_Real*)Nod1RValues)[ 2]
122 #define Nod1PntU ((Standard_Real*)Nod1RValues)[ 3]
123 #define Nod1PntV ((Standard_Real*)Nod1RValues)[ 4]
124 #define Nod1NrmX ((Standard_Real*)Nod1RValues)[ 5]
125 #define Nod1NrmY ((Standard_Real*)Nod1RValues)[ 6]
126 #define Nod1NrmZ ((Standard_Real*)Nod1RValues)[ 7]
127 #define Nod1PCu1 ((Standard_Real*)Nod1RValues)[ 8]
128 #define Nod1PCu2 ((Standard_Real*)Nod1RValues)[ 9]
129 #define Nod1Scal ((Standard_Real*)Nod1RValues)[10]
131 #define NodANdSg ((Standard_Integer*)NodAIndices)[0]
132 #define NodAFlag ((Standard_Boolean*)NodAIndices)[1]
133 #define NodAEdg1 ((Standard_Boolean*)NodAIndices)[2]
134 #define NodAEdg2 ((Standard_Boolean*)NodAIndices)[3]
136 #define NodAPntX ((Standard_Real*)NodARValues)[ 0]
137 #define NodAPntY ((Standard_Real*)NodARValues)[ 1]
138 #define NodAPntZ ((Standard_Real*)NodARValues)[ 2]
139 #define NodAPntU ((Standard_Real*)NodARValues)[ 3]
140 #define NodAPntV ((Standard_Real*)NodARValues)[ 4]
141 #define NodANrmX ((Standard_Real*)NodARValues)[ 5]
142 #define NodANrmY ((Standard_Real*)NodARValues)[ 6]
143 #define NodANrmZ ((Standard_Real*)NodARValues)[ 7]
144 #define NodAPCu1 ((Standard_Real*)NodARValues)[ 8]
145 #define NodAPCu2 ((Standard_Real*)NodARValues)[ 9]
146 #define NodAScal ((Standard_Real*)NodARValues)[10]
148 #define NodBNdSg ((Standard_Integer*)NodBIndices)[0]
149 #define NodBFlag ((Standard_Boolean*)NodBIndices)[1]
150 #define NodBEdg1 ((Standard_Boolean*)NodBIndices)[2]
151 #define NodBEdg2 ((Standard_Boolean*)NodBIndices)[3]
153 #define NodBPntX ((Standard_Real*)NodBRValues)[ 0]
154 #define NodBPntY ((Standard_Real*)NodBRValues)[ 1]
155 #define NodBPntZ ((Standard_Real*)NodBRValues)[ 2]
156 #define NodBPntU ((Standard_Real*)NodBRValues)[ 3]
157 #define NodBPntV ((Standard_Real*)NodBRValues)[ 4]
158 #define NodBNrmX ((Standard_Real*)NodBRValues)[ 5]
159 #define NodBNrmY ((Standard_Real*)NodBRValues)[ 6]
160 #define NodBNrmZ ((Standard_Real*)NodBRValues)[ 7]
161 #define NodBPCu1 ((Standard_Real*)NodBRValues)[ 8]
162 #define NodBPCu2 ((Standard_Real*)NodBRValues)[ 9]
163 #define NodBScal ((Standard_Real*)NodBRValues)[10]
165 #define Nod2NdSg ((Standard_Integer*)Nod2Indices)[0]
166 #define Nod2Flag ((Standard_Boolean*)Nod2Indices)[1]
167 #define Nod2Edg1 ((Standard_Boolean*)Nod2Indices)[2]
168 #define Nod2Edg2 ((Standard_Boolean*)Nod2Indices)[3]
170 #define Nod2PntX ((Standard_Real*)Nod2RValues)[ 0]
171 #define Nod2PntY ((Standard_Real*)Nod2RValues)[ 1]
172 #define Nod2PntZ ((Standard_Real*)Nod2RValues)[ 2]
173 #define Nod2PntU ((Standard_Real*)Nod2RValues)[ 3]
174 #define Nod2PntV ((Standard_Real*)Nod2RValues)[ 4]
175 #define Nod2NrmX ((Standard_Real*)Nod2RValues)[ 5]
176 #define Nod2NrmY ((Standard_Real*)Nod2RValues)[ 6]
177 #define Nod2NrmZ ((Standard_Real*)Nod2RValues)[ 7]
178 #define Nod2PCu1 ((Standard_Real*)Nod2RValues)[ 8]
179 #define Nod2PCu2 ((Standard_Real*)Nod2RValues)[ 9]
180 #define Nod2Scal ((Standard_Real*)Nod2RValues)[10]
182 #define Nod3NdSg ((Standard_Integer*)Nod3Indices)[0]
183 #define Nod3Flag ((Standard_Boolean*)Nod3Indices)[1]
184 #define Nod3Edg1 ((Standard_Boolean*)Nod3Indices)[2]
185 #define Nod3Edg2 ((Standard_Boolean*)Nod3Indices)[3]
187 #define Nod3PntX ((Standard_Real*)Nod3RValues)[ 0]
188 #define Nod3PntY ((Standard_Real*)Nod3RValues)[ 1]
189 #define Nod3PntZ ((Standard_Real*)Nod3RValues)[ 2]
190 #define Nod3PntU ((Standard_Real*)Nod3RValues)[ 3]
191 #define Nod3PntV ((Standard_Real*)Nod3RValues)[ 4]
192 #define Nod3NrmX ((Standard_Real*)Nod3RValues)[ 5]
193 #define Nod3NrmY ((Standard_Real*)Nod3RValues)[ 6]
194 #define Nod3NrmZ ((Standard_Real*)Nod3RValues)[ 7]
195 #define Nod3PCu1 ((Standard_Real*)Nod3RValues)[ 8]
196 #define Nod3PCu2 ((Standard_Real*)Nod3RValues)[ 9]
197 #define Nod3Scal ((Standard_Real*)Nod3RValues)[10]
199 #define Nod4NdSg ((Standard_Integer*)Nod4Indices)[0]
200 #define Nod4Flag ((Standard_Boolean*)Nod4Indices)[1]
201 #define Nod4Edg1 ((Standard_Boolean*)Nod4Indices)[2]
202 #define Nod4Edg2 ((Standard_Boolean*)Nod4Indices)[3]
204 #define Nod4PntX ((Standard_Real*)Nod4RValues)[ 0]
205 #define Nod4PntY ((Standard_Real*)Nod4RValues)[ 1]
206 #define Nod4PntZ ((Standard_Real*)Nod4RValues)[ 2]
207 #define Nod4PntU ((Standard_Real*)Nod4RValues)[ 3]
208 #define Nod4PntV ((Standard_Real*)Nod4RValues)[ 4]
209 #define Nod4NrmX ((Standard_Real*)Nod4RValues)[ 5]
210 #define Nod4NrmY ((Standard_Real*)Nod4RValues)[ 6]
211 #define Nod4NrmZ ((Standard_Real*)Nod4RValues)[ 7]
212 #define Nod4PCu1 ((Standard_Real*)Nod4RValues)[ 8]
213 #define Nod4PCu2 ((Standard_Real*)Nod4RValues)[ 9]
214 #define Nod4Scal ((Standard_Real*)Nod4RValues)[10]
216 #define Nod11NdSg ((Standard_Integer*)Nod11Indices)[0]
217 #define Nod11Flag ((Standard_Boolean*)Nod11Indices)[1]
218 #define Nod11Edg1 ((Standard_Boolean*)Nod11Indices)[2]
219 #define Nod11Edg2 ((Standard_Boolean*)Nod11Indices)[3]
221 #define Nod11PntX ((Standard_Real*)Nod11RValues)[ 0]
222 #define Nod11PntY ((Standard_Real*)Nod11RValues)[ 1]
223 #define Nod11PntZ ((Standard_Real*)Nod11RValues)[ 2]
224 #define Nod11PntU ((Standard_Real*)Nod11RValues)[ 3]
225 #define Nod11PntV ((Standard_Real*)Nod11RValues)[ 4]
226 #define Nod11NrmX ((Standard_Real*)Nod11RValues)[ 5]
227 #define Nod11NrmY ((Standard_Real*)Nod11RValues)[ 6]
228 #define Nod11NrmZ ((Standard_Real*)Nod11RValues)[ 7]
229 #define Nod11PCu1 ((Standard_Real*)Nod11RValues)[ 8]
230 #define Nod11PCu2 ((Standard_Real*)Nod11RValues)[ 9]
231 #define Nod11Scal ((Standard_Real*)Nod11RValues)[10]
233 #define Nod1ANdSg ((Standard_Integer*)Nod1AIndices)[0]
234 #define Nod1AFlag ((Standard_Boolean*)Nod1AIndices)[1]
235 #define Nod1AEdg1 ((Standard_Boolean*)Nod1AIndices)[2]
236 #define Nod1AEdg2 ((Standard_Boolean*)Nod1AIndices)[3]
238 #define Nod1APntX ((Standard_Real*)Nod1ARValues)[ 0]
239 #define Nod1APntY ((Standard_Real*)Nod1ARValues)[ 1]
240 #define Nod1APntZ ((Standard_Real*)Nod1ARValues)[ 2]
241 #define Nod1APntU ((Standard_Real*)Nod1ARValues)[ 3]
242 #define Nod1APntV ((Standard_Real*)Nod1ARValues)[ 4]
243 #define Nod1ANrmX ((Standard_Real*)Nod1ARValues)[ 5]
244 #define Nod1ANrmY ((Standard_Real*)Nod1ARValues)[ 6]
245 #define Nod1ANrmZ ((Standard_Real*)Nod1ARValues)[ 7]
246 #define Nod1APCu1 ((Standard_Real*)Nod1ARValues)[ 8]
247 #define Nod1APCu2 ((Standard_Real*)Nod1ARValues)[ 9]
248 #define Nod1AScal ((Standard_Real*)Nod1ARValues)[10]
250 #define Nod1BNdSg ((Standard_Integer*)Nod1BIndices)[0]
251 #define Nod1BFlag ((Standard_Boolean*)Nod1BIndices)[1]
252 #define Nod1BEdg1 ((Standard_Boolean*)Nod1BIndices)[2]
253 #define Nod1BEdg2 ((Standard_Boolean*)Nod1BIndices)[3]
255 #define Nod1BPntX ((Standard_Real*)Nod1BRValues)[ 0]
256 #define Nod1BPntY ((Standard_Real*)Nod1BRValues)[ 1]
257 #define Nod1BPntZ ((Standard_Real*)Nod1BRValues)[ 2]
258 #define Nod1BPntU ((Standard_Real*)Nod1BRValues)[ 3]
259 #define Nod1BPntV ((Standard_Real*)Nod1BRValues)[ 4]
260 #define Nod1BNrmX ((Standard_Real*)Nod1BRValues)[ 5]
261 #define Nod1BNrmY ((Standard_Real*)Nod1BRValues)[ 6]
262 #define Nod1BNrmZ ((Standard_Real*)Nod1BRValues)[ 7]
263 #define Nod1BPCu1 ((Standard_Real*)Nod1BRValues)[ 8]
264 #define Nod1BPCu2 ((Standard_Real*)Nod1BRValues)[ 9]
265 #define Nod1BScal ((Standard_Real*)Nod1BRValues)[10]
267 #define Nod12NdSg ((Standard_Integer*)Nod12Indices)[0]
268 #define Nod12Flag ((Standard_Boolean*)Nod12Indices)[1]
269 #define Nod12Edg1 ((Standard_Boolean*)Nod12Indices)[2]
270 #define Nod12Edg2 ((Standard_Boolean*)Nod12Indices)[3]
272 #define Nod12PntX ((Standard_Real*)Nod12RValues)[ 0]
273 #define Nod12PntY ((Standard_Real*)Nod12RValues)[ 1]
274 #define Nod12PntZ ((Standard_Real*)Nod12RValues)[ 2]
275 #define Nod12PntU ((Standard_Real*)Nod12RValues)[ 3]
276 #define Nod12PntV ((Standard_Real*)Nod12RValues)[ 4]
277 #define Nod12NrmX ((Standard_Real*)Nod12RValues)[ 5]
278 #define Nod12NrmY ((Standard_Real*)Nod12RValues)[ 6]
279 #define Nod12NrmZ ((Standard_Real*)Nod12RValues)[ 7]
280 #define Nod12PCu1 ((Standard_Real*)Nod12RValues)[ 8]
281 #define Nod12PCu2 ((Standard_Real*)Nod12RValues)[ 9]
282 #define Nod12Scal ((Standard_Real*)Nod12RValues)[10]
284 #define Nod13NdSg ((Standard_Integer*)Nod13Indices)[0]
285 #define Nod13Flag ((Standard_Boolean*)Nod13Indices)[1]
286 #define Nod13Edg1 ((Standard_Boolean*)Nod13Indices)[2]
287 #define Nod13Edg2 ((Standard_Boolean*)Nod13Indices)[3]
289 #define Nod13PntX ((Standard_Real*)Nod13RValues)[ 0]
290 #define Nod13PntY ((Standard_Real*)Nod13RValues)[ 1]
291 #define Nod13PntZ ((Standard_Real*)Nod13RValues)[ 2]
292 #define Nod13PntU ((Standard_Real*)Nod13RValues)[ 3]
293 #define Nod13PntV ((Standard_Real*)Nod13RValues)[ 4]
294 #define Nod13NrmX ((Standard_Real*)Nod13RValues)[ 5]
295 #define Nod13NrmY ((Standard_Real*)Nod13RValues)[ 6]
296 #define Nod13NrmZ ((Standard_Real*)Nod13RValues)[ 7]
297 #define Nod13PCu1 ((Standard_Real*)Nod13RValues)[ 8]
298 #define Nod13PCu2 ((Standard_Real*)Nod13RValues)[ 9]
299 #define Nod13Scal ((Standard_Real*)Nod13RValues)[10]
301 #define Nod14NdSg ((Standard_Integer*)Nod14Indices)[0]
302 #define Nod14Flag ((Standard_Boolean*)Nod14Indices)[1]
303 #define Nod14Edg1 ((Standard_Boolean*)Nod14Indices)[2]
304 #define Nod14Edg2 ((Standard_Boolean*)Nod14Indices)[3]
306 #define Nod14PntX ((Standard_Real*)Nod14RValues)[ 0]
307 #define Nod14PntY ((Standard_Real*)Nod14RValues)[ 1]
308 #define Nod14PntZ ((Standard_Real*)Nod14RValues)[ 2]
309 #define Nod14PntU ((Standard_Real*)Nod14RValues)[ 3]
310 #define Nod14PntV ((Standard_Real*)Nod14RValues)[ 4]
311 #define Nod14NrmX ((Standard_Real*)Nod14RValues)[ 5]
312 #define Nod14NrmY ((Standard_Real*)Nod14RValues)[ 6]
313 #define Nod14NrmZ ((Standard_Real*)Nod14RValues)[ 7]
314 #define Nod14PCu1 ((Standard_Real*)Nod14RValues)[ 8]
315 #define Nod14PCu2 ((Standard_Real*)Nod14RValues)[ 9]
316 #define Nod14Scal ((Standard_Real*)Nod14RValues)[10]
318 #define Nod21NdSg ((Standard_Integer*)Nod21Indices)[0]
319 #define Nod21Flag ((Standard_Boolean*)Nod21Indices)[1]
320 #define Nod21Edg1 ((Standard_Boolean*)Nod21Indices)[2]
321 #define Nod21Edg2 ((Standard_Boolean*)Nod21Indices)[3]
323 #define Nod21PntX ((Standard_Real*)Nod21RValues)[ 0]
324 #define Nod21PntY ((Standard_Real*)Nod21RValues)[ 1]
325 #define Nod21PntZ ((Standard_Real*)Nod21RValues)[ 2]
326 #define Nod21PntU ((Standard_Real*)Nod21RValues)[ 3]
327 #define Nod21PntV ((Standard_Real*)Nod21RValues)[ 4]
328 #define Nod21NrmX ((Standard_Real*)Nod21RValues)[ 5]
329 #define Nod21NrmY ((Standard_Real*)Nod21RValues)[ 6]
330 #define Nod21NrmZ ((Standard_Real*)Nod21RValues)[ 7]
331 #define Nod21PCu1 ((Standard_Real*)Nod21RValues)[ 8]
332 #define Nod21PCu2 ((Standard_Real*)Nod21RValues)[ 9]
333 #define Nod21Scal ((Standard_Real*)Nod21RValues)[10]
335 #define Nod2ANdSg ((Standard_Integer*)Nod2AIndices)[0]
336 #define Nod2AFlag ((Standard_Boolean*)Nod2AIndices)[1]
337 #define Nod2AEdg1 ((Standard_Boolean*)Nod2AIndices)[2]
338 #define Nod2AEdg2 ((Standard_Boolean*)Nod2AIndices)[3]
340 #define Nod2APntX ((Standard_Real*)Nod2ARValues)[ 0]
341 #define Nod2APntY ((Standard_Real*)Nod2ARValues)[ 1]
342 #define Nod2APntZ ((Standard_Real*)Nod2ARValues)[ 2]
343 #define Nod2APntU ((Standard_Real*)Nod2ARValues)[ 3]
344 #define Nod2APntV ((Standard_Real*)Nod2ARValues)[ 4]
345 #define Nod2ANrmX ((Standard_Real*)Nod2ARValues)[ 5]
346 #define Nod2ANrmY ((Standard_Real*)Nod2ARValues)[ 6]
347 #define Nod2ANrmZ ((Standard_Real*)Nod2ARValues)[ 7]
348 #define Nod2APCu1 ((Standard_Real*)Nod2ARValues)[ 8]
349 #define Nod2APCu2 ((Standard_Real*)Nod2ARValues)[ 9]
350 #define Nod2AScal ((Standard_Real*)Nod2ARValues)[10]
352 #define Nod2BNdSg ((Standard_Integer*)Nod2BIndices)[0]
353 #define Nod2BFlag ((Standard_Boolean*)Nod2BIndices)[1]
354 #define Nod2BEdg1 ((Standard_Boolean*)Nod2BIndices)[2]
355 #define Nod2BEdg2 ((Standard_Boolean*)Nod2BIndices)[3]
357 #define Nod2BPntX ((Standard_Real*)Nod2BRValues)[ 0]
358 #define Nod2BPntY ((Standard_Real*)Nod2BRValues)[ 1]
359 #define Nod2BPntZ ((Standard_Real*)Nod2BRValues)[ 2]
360 #define Nod2BPntU ((Standard_Real*)Nod2BRValues)[ 3]
361 #define Nod2BPntV ((Standard_Real*)Nod2BRValues)[ 4]
362 #define Nod2BNrmX ((Standard_Real*)Nod2BRValues)[ 5]
363 #define Nod2BNrmY ((Standard_Real*)Nod2BRValues)[ 6]
364 #define Nod2BNrmZ ((Standard_Real*)Nod2BRValues)[ 7]
365 #define Nod2BPCu1 ((Standard_Real*)Nod2BRValues)[ 8]
366 #define Nod2BPCu2 ((Standard_Real*)Nod2BRValues)[ 9]
367 #define Nod2BScal ((Standard_Real*)Nod2BRValues)[10]
369 #define Nod22NdSg ((Standard_Integer*)Nod22Indices)[0]
370 #define Nod22Flag ((Standard_Boolean*)Nod22Indices)[1]
371 #define Nod22Edg1 ((Standard_Boolean*)Nod22Indices)[2]
372 #define Nod22Edg2 ((Standard_Boolean*)Nod22Indices)[3]
374 #define Nod22PntX ((Standard_Real*)Nod22RValues)[ 0]
375 #define Nod22PntY ((Standard_Real*)Nod22RValues)[ 1]
376 #define Nod22PntZ ((Standard_Real*)Nod22RValues)[ 2]
377 #define Nod22PntU ((Standard_Real*)Nod22RValues)[ 3]
378 #define Nod22PntV ((Standard_Real*)Nod22RValues)[ 4]
379 #define Nod22NrmX ((Standard_Real*)Nod22RValues)[ 5]
380 #define Nod22NrmY ((Standard_Real*)Nod22RValues)[ 6]
381 #define Nod22NrmZ ((Standard_Real*)Nod22RValues)[ 7]
382 #define Nod22PCu1 ((Standard_Real*)Nod22RValues)[ 8]
383 #define Nod22PCu2 ((Standard_Real*)Nod22RValues)[ 9]
384 #define Nod22Scal ((Standard_Real*)Nod22RValues)[10]
386 #define Nod23NdSg ((Standard_Integer*)Nod23Indices)[0]
387 #define Nod23Flag ((Standard_Boolean*)Nod23Indices)[1]
388 #define Nod23Edg1 ((Standard_Boolean*)Nod23Indices)[2]
389 #define Nod23Edg2 ((Standard_Boolean*)Nod23Indices)[3]
391 #define Nod23PntX ((Standard_Real*)Nod23RValues)[ 0]
392 #define Nod23PntY ((Standard_Real*)Nod23RValues)[ 1]
393 #define Nod23PntZ ((Standard_Real*)Nod23RValues)[ 2]
394 #define Nod23PntU ((Standard_Real*)Nod23RValues)[ 3]
395 #define Nod23PntV ((Standard_Real*)Nod23RValues)[ 4]
396 #define Nod23NrmX ((Standard_Real*)Nod23RValues)[ 5]
397 #define Nod23NrmY ((Standard_Real*)Nod23RValues)[ 6]
398 #define Nod23NrmZ ((Standard_Real*)Nod23RValues)[ 7]
399 #define Nod23PCu1 ((Standard_Real*)Nod23RValues)[ 8]
400 #define Nod23PCu2 ((Standard_Real*)Nod23RValues)[ 9]
401 #define Nod23Scal ((Standard_Real*)Nod23RValues)[10]
403 #define Nod24NdSg ((Standard_Integer*)Nod24Indices)[0]
404 #define Nod24Flag ((Standard_Boolean*)Nod24Indices)[1]
405 #define Nod24Edg1 ((Standard_Boolean*)Nod24Indices)[2]
406 #define Nod24Edg2 ((Standard_Boolean*)Nod24Indices)[3]
408 #define Nod24PntX ((Standard_Real*)Nod24RValues)[ 0]
409 #define Nod24PntY ((Standard_Real*)Nod24RValues)[ 1]
410 #define Nod24PntZ ((Standard_Real*)Nod24RValues)[ 2]
411 #define Nod24PntU ((Standard_Real*)Nod24RValues)[ 3]
412 #define Nod24PntV ((Standard_Real*)Nod24RValues)[ 4]
413 #define Nod24NrmX ((Standard_Real*)Nod24RValues)[ 5]
414 #define Nod24NrmY ((Standard_Real*)Nod24RValues)[ 6]
415 #define Nod24NrmZ ((Standard_Real*)Nod24RValues)[ 7]
416 #define Nod24PCu1 ((Standard_Real*)Nod24RValues)[ 8]
417 #define Nod24PCu2 ((Standard_Real*)Nod24RValues)[ 9]
418 #define Nod24Scal ((Standard_Real*)Nod24RValues)[10]
420 #define ShapeIndex ((Standard_Integer*)IndexPtr)[0]
421 #define F1Index ((Standard_Integer*)IndexPtr)[1]
422 #define F1Pt1Index ((Standard_Integer*)IndexPtr)[2]
423 #define F1Pt2Index ((Standard_Integer*)IndexPtr)[3]
424 #define F2Index ((Standard_Integer*)IndexPtr)[4]
425 #define F2Pt1Index ((Standard_Integer*)IndexPtr)[5]
426 #define F2Pt2Index ((Standard_Integer*)IndexPtr)[6]
427 #define MinSeg ((Standard_Integer*)IndexPtr)[7]
428 #define MaxSeg ((Standard_Integer*)IndexPtr)[8]
429 #define SegFlags ((Standard_Integer*)IndexPtr)[9]
431 static Standard_Integer DoTrace = Standard_False;
432 static Standard_Integer DoError = Standard_False;
433 static Standard_Integer IndexPlusOnePerCentThree [] = { 1 , 2 , 0 };
435 //=======================================================================
436 //function : HLRBRep_PolyAlgo
438 //=======================================================================
440 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo () :
441 myDebug (Standard_False),
442 myAngle (5 * M_PI / 180.),
447 myAlgo = new HLRAlgo_PolyAlgo();
450 //=======================================================================
451 //function : HLRBRep_PolyAlgo
453 //=======================================================================
455 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const Handle(HLRBRep_PolyAlgo)& A)
457 myDebug = A->Debug();
458 myAngle = A->Angle();
459 myTolAngular = A->TolAngular();
460 myTolSta = A->TolCoef();
461 myTolEnd = 1 - myTolSta;
463 myProj = A->Projector();
465 Standard_Integer n = A->NbShapes();
467 for (Standard_Integer i = 1; i <= n; i++)
471 //=======================================================================
472 //function : HLRBRep_PolyAlgo
474 //=======================================================================
476 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const TopoDS_Shape& S) :
477 myDebug (Standard_False),
478 myAngle (5 * M_PI / 180.),
484 myAlgo = new HLRAlgo_PolyAlgo();
487 //=======================================================================
490 //=======================================================================
492 TopoDS_Shape & HLRBRep_PolyAlgo::Shape (const Standard_Integer I)
494 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
495 "HLRBRep_PolyAlgo::Shape : unknown Shape");
499 //=======================================================================
502 //=======================================================================
504 void HLRBRep_PolyAlgo::Remove (const Standard_Integer I)
506 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
507 "HLRBRep_PolyAlgo::Remove : unknown Shape");
514 //=======================================================================
517 //=======================================================================
519 Standard_Integer HLRBRep_PolyAlgo::Index (const TopoDS_Shape& S) const
521 Standard_Integer n = myShapes.Length();
523 for (Standard_Integer i = 1; i <= n; i++)
524 if (myShapes(i) == S) return i;
529 //=======================================================================
532 //=======================================================================
534 Handle(HLRAlgo_PolyAlgo) HLRBRep_PolyAlgo::Algo () const
539 //=======================================================================
542 //=======================================================================
544 void HLRBRep_PolyAlgo::Update ()
549 TopoDS_Shape Shape = MakeShape();
551 if (!Shape.IsNull()) {
552 TopExp_Explorer exshell;
553 Standard_Boolean IsoledF,IsoledE;//,closed;
555 TopTools_MapOfShape ShapeMap1,ShapeMap2;
556 TopExp::MapShapes(Shape,TopAbs_EDGE,myEMap);
557 TopExp::MapShapes(Shape,TopAbs_FACE,myFMap);
558 Standard_Integer nbEdge = myEMap.Extent();
559 Standard_Integer nbFace = myFMap.Extent();
560 TColStd_Array1OfInteger ES (0,nbEdge); // index of the Shell
561 TColStd_Array1OfTransient PD (0,nbFace); // HLRAlgo_PolyData
562 TColStd_Array1OfTransient PID(0,nbFace); // PolyInternalData
563 Standard_Integer nbShell = InitShape(Shape,IsoledF,IsoledE);
565 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
566 Standard_Integer iShell = 0;
568 for (exshell.Init(Shape, TopAbs_SHELL);
571 StoreShell(exshell.Current(),iShell,Shell,
572 Standard_False,Standard_False,
573 ES,PD,PID,ShapeMap1,ShapeMap2);
575 StoreShell(Shape,iShell,Shell,IsoledF,Standard_False,
576 ES,PD,PID,ShapeMap1,ShapeMap2);
578 StoreShell(Shape,iShell,Shell,Standard_False,IsoledE,
579 ES,PD,PID,ShapeMap1,ShapeMap2);
585 //=======================================================================
586 //function : MakeShape
588 //=======================================================================
590 TopoDS_Shape HLRBRep_PolyAlgo::MakeShape () const
592 Standard_Integer n = myShapes.Length();
593 Standard_Boolean FirstTime = Standard_True;
597 for (Standard_Integer i = 1; i <= n; i++) {
599 FirstTime = Standard_False;
600 B.MakeCompound(TopoDS::Compound(Shape));
602 B.Add(Shape,myShapes(i));
607 //=======================================================================
608 //function : InitShape
610 //=======================================================================
613 HLRBRep_PolyAlgo::InitShape (const TopoDS_Shape& Shape,
614 Standard_Boolean& IsoledF,
615 Standard_Boolean& IsoledE)
617 TopTools_MapOfShape ShapeMap0;
618 Standard_Integer nbShell = 0;
619 IsoledF = Standard_False;
620 IsoledE = Standard_False;
621 TopExp_Explorer exshell,exface,exedge;
624 for (exshell.Init(Shape, TopAbs_SHELL);
627 Standard_Boolean withTrian = Standard_False;
629 for (exface.Init(exshell.Current(), TopAbs_FACE);
632 const TopoDS_Face& F = TopoDS::Face(exface.Current());
633 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
634 if (ShapeMap0.Add(F))
635 withTrian = Standard_True;
638 if (withTrian) nbShell++;
641 for (exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
642 exface.More() && !IsoledF;
644 const TopoDS_Face& F = TopoDS::Face(exface.Current());
645 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
646 if (ShapeMap0.Add(F))
647 IsoledF = Standard_True;
650 if (IsoledF) nbShell++;
652 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
653 exedge.More() && !IsoledE;
655 IsoledE = Standard_True;
656 if (IsoledE) nbShell++;
658 myAlgo->Init(new TColStd_HArray1OfTransient(1,nbShell));
662 //=======================================================================
663 //function : StoreShell
665 //=======================================================================
667 void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
668 Standard_Integer& iShell,
669 TColStd_Array1OfTransient& Shell,
670 const Standard_Boolean IsoledF,
671 const Standard_Boolean IsoledE,
672 TColStd_Array1OfInteger& ES,
673 TColStd_Array1OfTransient& PD,
674 TColStd_Array1OfTransient& PID,
675 TopTools_MapOfShape& ShapeMap1,
676 TopTools_MapOfShape& ShapeMap2)
679 TopExp_Explorer exface,exedge;
680 Standard_Integer f,i,j;
681 Standard_Integer nbFaceShell = 0;
682 Standard_Boolean reversed;
683 Standard_Boolean closed = Standard_False;
684 const gp_Trsf& T = myProj.Transformation();
685 const gp_Trsf& TI = myProj.InvertedTransformation();
686 const gp_XYZ& tloc = T.TranslationPart();
690 const gp_Mat& tmat = T.VectorialPart();
691 TMat[0][0] = tmat.Value(1,1);
692 TMat[0][1] = tmat.Value(1,2);
693 TMat[0][2] = tmat.Value(1,3);
694 TMat[1][0] = tmat.Value(2,1);
695 TMat[1][1] = tmat.Value(2,2);
696 TMat[1][2] = tmat.Value(2,3);
697 TMat[2][0] = tmat.Value(3,1);
698 TMat[2][1] = tmat.Value(3,2);
699 TMat[2][2] = tmat.Value(3,3);
700 const gp_XYZ& tilo = TI.TranslationPart();
704 const gp_Mat& tima = TI.VectorialPart();
705 TIMa[0][0] = tima.Value(1,1);
706 TIMa[0][1] = tima.Value(1,2);
707 TIMa[0][2] = tima.Value(1,3);
708 TIMa[1][0] = tima.Value(2,1);
709 TIMa[1][1] = tima.Value(2,2);
710 TIMa[1][2] = tima.Value(2,3);
711 TIMa[2][0] = tima.Value(3,1);
712 TIMa[2][1] = tima.Value(3,2);
713 TIMa[2][2] = tima.Value(3,3);
716 closed = Shape.Closed();
718 TopTools_IndexedMapOfShape EM;
719 TopExp::MapShapes(Shape,TopAbs_EDGE,EM);
721 Standard_Integer nbEdge = EM.Extent ();
722 Standard_Integer *flag = new Standard_Integer[nbEdge + 1];
724 for (ie = 1; ie <= nbEdge; ie++)
727 for (exedge.Init(Shape, TopAbs_EDGE);
730 const TopoDS_Edge& E = TopoDS::Edge(exedge.Current());
731 ie = EM.FindIndex(E);
732 TopAbs_Orientation orient = E.Orientation();
733 if (!BRep_Tool::Degenerated(E)) {
734 if (orient == TopAbs_FORWARD ) flag[ie] += 1;
735 else if (orient == TopAbs_REVERSED) flag[ie] -= 1;
738 closed = Standard_True;
740 for (ie = 1; ie <= nbEdge && closed; ie++)
741 closed = (flag[ie] == 0);
746 exface.Init(Shape, TopAbs_FACE);
749 exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
751 for (; exface.More(); exface.Next()) {
752 const TopoDS_Face& F = TopoDS::Face(exface.Current());
753 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
754 if (ShapeMap1.Add(F))
759 if (nbFaceShell > 0 || IsoledE) {
761 Shell(iShell) = new HLRAlgo_PolyShellData(nbFaceShell);
763 if (nbFaceShell > 0) {
764 const Handle(HLRAlgo_PolyShellData)& psd =
765 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
766 Standard_Integer iFace = 0;
767 if (!IsoledF) exface.Init(Shape, TopAbs_FACE);
768 else exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
769 TopTools_MapOfShape ShapeMapBis;
771 for (; exface.More(); exface.Next()) {
772 const TopoDS_Face& F = TopoDS::Face(exface.Current());
773 const Handle(Poly_Triangulation)& Tr = BRep_Tool::Triangulation(F,L);
775 if (ShapeMap2.Add(F)) {
777 f = myFMap.FindIndex(F);
778 reversed = F.Orientation() == TopAbs_REVERSED;
779 gp_Trsf TT = L.Transformation();
781 const gp_XYZ& ttlo = TT.TranslationPart();
785 const gp_Mat& ttma = TT.VectorialPart();
786 TTMa[0][0] = ttma.Value(1,1);
787 TTMa[0][1] = ttma.Value(1,2);
788 TTMa[0][2] = ttma.Value(1,3);
789 TTMa[1][0] = ttma.Value(2,1);
790 TTMa[1][1] = ttma.Value(2,2);
791 TTMa[1][2] = ttma.Value(2,3);
792 TTMa[2][0] = ttma.Value(3,1);
793 TTMa[2][1] = ttma.Value(3,2);
794 TTMa[2][2] = ttma.Value(3,3);
795 Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
796 TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
797 Standard_Integer nbN = Nod.Upper();
798 Standard_Integer nbT = Tri.Upper();
799 PD (f) = new HLRAlgo_PolyData();
800 psd->PolyData().ChangeValue(iFace) = PD(f);
801 PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
802 Handle(HLRAlgo_PolyInternalData)& pid =
803 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(f));
804 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
805 if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface))
806 S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
807 GeomAdaptor_Surface AS(S);
808 pid->Planar(AS.GetType() == GeomAbs_Plane);
809 Standard_Address TData = &pid->TData();
810 Standard_Address PISeg = &pid->PISeg();
811 Standard_Address PINod = &pid->PINod();
812 Poly_Triangle * OT = &(Tri.ChangeValue(1));
813 HLRAlgo_TriangleData* NT =
814 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
816 for (i = 1; i <= nbT; i++) {
817 Standard_Address Tri2Indices = NT->Indices();
818 OT->Get(Tri2Node1,Tri2Node2,Tri2Node3);
822 Tri2Node1 = Tri2Node3;
829 gp_Pnt * ON = &(Nod.ChangeValue(1));
830 Handle(HLRAlgo_PolyInternalNode)* NN =
831 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
833 for (i = 1; i <= nbN; i++) {
834 const Standard_Address Nod1RValues = (*NN)->RValues();
835 const Standard_Address Nod1Indices = (*NN)->Indices();
841 TTMultiply(Nod1PntX,Nod1PntY,Nod1PntZ);
845 pid->UpdateLinks(TData,PISeg,PINod);
846 if (Tr->HasUVNodes()) {
847 myBSurf.Initialize(F,Standard_False);
848 TColgp_Array1OfPnt2d & UVN = Tr->ChangeUVNodes();
849 gp_Pnt2d* OUVN = &(UVN.ChangeValue(1));
850 NN = &(((HLRAlgo_Array1OfPINod*)PINod)->
853 for (i = 1; i <= nbN; i++) {
854 const Standard_Address Nod1Indices = (*NN)->Indices();
855 const Standard_Address Nod1RValues = (*NN)->RValues();
856 Nod1PntU = OUVN->X();
857 Nod1PntV = OUVN->Y();
858 if (Normal(i,Nod1Indices,Nod1RValues,
859 TData,PISeg,PINod,Standard_False))
860 Nod1Flag |= NMskNorm;
862 Nod1Flag &= ~NMskNorm;
871 cout << " HLRBRep_PolyAlgo::StoreShell : Face ";
872 cout << f << " non triangulated" << endl;
875 NT = &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
877 for (i = 1; i <= nbT; i++) {
878 const Standard_Address Tri1Indices = NT->Indices();
879 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
880 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
881 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
882 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
883 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
884 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
885 const Standard_Address Nod1Indices = (*PN1)->Indices();
886 const Standard_Address Nod2Indices = (*PN2)->Indices();
887 const Standard_Address Nod3Indices = (*PN3)->Indices();
888 const Standard_Address Nod1RValues = (*PN1)->RValues();
889 const Standard_Address Nod2RValues = (*PN2)->RValues();
890 const Standard_Address Nod3RValues = (*PN3)->RValues();
891 OrientTriangle(i,Tri1Indices,
892 Nod1Indices,Nod1RValues,
893 Nod2Indices,Nod2RValues,
894 Nod3Indices,Nod3RValues);
901 cout << "HLRBRep_PolyAlgo::StoreShell : Face ";
902 cout << f << " deja stockee" << endl;
906 Standard_Integer nbFace = myFMap.Extent();
907 HLRAlgo_ListOfBPoint& List = psd->Edges();
908 TopTools_IndexedDataMapOfShapeListOfShape EF;
909 TopExp::MapShapesAndAncestors(Shape,TopAbs_EDGE,TopAbs_FACE,EF);
910 Handle(HLRAlgo_PolyInternalData)* pid =
911 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
913 for (f = 1; f <= nbFace; f++) {
914 if (!(*pid).IsNull()) {
916 for (exedge.Init(myFMap(f),TopAbs_EDGE);
919 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
920 if (ShapeMap1.Add(E)) {
921 Standard_Integer e = myEMap.FindIndex(E);
923 Standard_Integer i = EF.FindIndex(E);
925 TopTools_ListOfShape& LS = EF(i);
926 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_True);
929 TopTools_ListOfShape LS;
930 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
937 InsertOnOutLine(PID);
938 CheckFrBackTriangles(List,PID);
939 UpdateOutLines(List,PID);
940 UpdateEdgesBiPoints(List,PID,closed);
941 UpdatePolyData(PD,PID,closed);
942 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
944 for (f = 1; f <= nbFace; f++) {
950 const Handle(HLRAlgo_PolyShellData)& psd =
951 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
952 HLRAlgo_ListOfBPoint& List = psd->Edges();
954 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
957 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
958 if (ShapeMap1.Add(E)) {
959 Standard_Integer e = myEMap.FindIndex(E);
961 TopTools_ListOfShape LS;
962 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
968 //=======================================================================
971 //=======================================================================
973 Standard_Boolean HLRBRep_PolyAlgo::
974 Normal (const Standard_Integer iNode,
975 const Standard_Address Nod1Indices,
976 const Standard_Address Nod1RValues,
977 Standard_Address& TData,
978 Standard_Address& PISeg,
979 Standard_Address& PINod,
980 const Standard_Boolean orient) const
982 gp_Vec D1U,D1V,D2U,D2V,D2UV;
986 CSLib_DerivativeStatus Status;
987 CSLib_NormalStatus NStat;
988 myBSurf.D1(Nod1PntU,Nod1PntV,P,D1U,D1V);
989 CSLib::Normal(D1U,D1V,Standard_Real(Precision::Angular()),
991 if (Status != CSLib_Done) {
992 myBSurf.D2(Nod1PntU,Nod1PntV,P,D1U,D1V,D2U,D2V,D2UV);
993 CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,
994 Precision::Angular(),OK,NStat,Norma);
996 return Standard_False;
998 Standard_Real EyeX = 0;
999 Standard_Real EyeY = 0;
1000 Standard_Real EyeZ = -1;
1001 if (myProj.Perspective()) {
1004 EyeZ = Nod1PntZ - myProj.Focus();
1005 Standard_Real d = sqrt(EyeX * EyeX + EyeY * EyeY + EyeZ * EyeZ);
1012 Nod1NrmX = Norma.X();
1013 Nod1NrmY = Norma.Y();
1014 Nod1NrmZ = Norma.Z();
1015 // TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ);
1016 TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ,myProj.Perspective()); //OCC349
1017 Standard_Real NormX,NormY,NormZ;
1019 if (AverageNormal(iNode,Nod1Indices,TData,PISeg,PINod,
1020 NormX,NormY,NormZ)) {
1021 if (Nod1NrmX * NormX +
1023 Nod1NrmZ * NormZ < 0) {
1024 Nod1NrmX = -Nod1NrmX;
1025 Nod1NrmY = -Nod1NrmY;
1026 Nod1NrmZ = -Nod1NrmZ;
1028 Nod1Scal = (Nod1NrmX * EyeX +
1039 cout << "HLRBRep_PolyAlgo::Normal : AverageNormal error";
1045 if ( Nod1Scal < myTolAngular) {
1047 Nod1Flag |= NMskOutL;
1051 if (-Nod1Scal < myTolAngular) {
1053 Nod1Flag |= NMskOutL;
1056 if (orient) UpdateAroundNode(iNode,Nod1Indices,
1058 return Standard_True;
1061 //=======================================================================
1062 //function : AverageNormal
1064 //=======================================================================
1067 HLRBRep_PolyAlgo::AverageNormal(const Standard_Integer iNode,
1068 const Standard_Address Nod1Indices,
1069 Standard_Address& TData,
1070 Standard_Address& PISeg,
1071 Standard_Address& PINod,
1074 Standard_Real& Z) const
1076 Standard_Boolean OK = Standard_False;
1077 Standard_Integer jNode = 0,kNode,iiii,iTri1,iTri2;
1083 while (iiii != 0 && !OK) {
1084 const Standard_Address Seg2Indices =
1085 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1088 if ( iTri1 != 0) AddNormalOnTriangle
1089 (iTri1,iNode,jNode,TData,PINod,X,Y,Z,OK);
1090 if ( iTri2 != 0) AddNormalOnTriangle
1091 (iTri2,iNode,jNode,TData,PINod,X,Y,Z,OK);
1092 if (Seg2LstSg1 == iNode) iiii = Seg2NxtSg1;
1093 else iiii = Seg2NxtSg2;
1097 const Standard_Address Nod2Indices =
1098 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(jNode)->Indices();
1101 while (iiii != 0 && !OK) {
1102 const Standard_Address Seg2Indices =
1103 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1106 if ( iTri1 != 0) AddNormalOnTriangle
1107 (iTri1,jNode,kNode,TData,PINod,X,Y,Z,OK);
1108 if ( iTri2 != 0) AddNormalOnTriangle
1109 (iTri2,jNode,kNode,TData,PINod,X,Y,Z,OK);
1110 if (Seg2LstSg1 == jNode) iiii = Seg2NxtSg1;
1111 else iiii = Seg2NxtSg2;
1114 Standard_Real d = sqrt (X * X + Y * Y + Z * Z);
1115 if (OK && d < 1.e-10) {
1116 OK = Standard_False;
1119 cout << "HLRAlgo_PolyInternalData:: inverted normals on ";
1120 cout << "node " << iNode << endl;
1127 //=======================================================================
1128 //function : AddNormalOnTriangle
1130 //=======================================================================
1134 AddNormalOnTriangle(const Standard_Integer iTri,
1135 const Standard_Integer iNode,
1136 Standard_Integer& jNode,
1137 Standard_Address& TData,
1138 Standard_Address& PINod,
1142 Standard_Boolean& OK) const
1144 Standard_Real dn,dnx,dny,dnz;
1145 Standard_Real d1,dx1,dy1,dz1;
1146 Standard_Real d2,dx2,dy2,dz2;
1147 Standard_Real d3,dx3,dy3,dz3;
1148 const Standard_Address Tri2Indices =
1149 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri).Indices();
1150 const Standard_Address Nod1RValues =
1151 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1)->RValues();
1152 const Standard_Address Nod2RValues =
1153 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2)->RValues();
1154 const Standard_Address Nod3RValues =
1155 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3)->RValues();
1156 dx1 = Nod2PntX - Nod1PntX;
1157 dy1 = Nod2PntY - Nod1PntY;
1158 dz1 = Nod2PntZ - Nod1PntZ;
1159 d1 = sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
1161 if (Tri2Node1 == iNode) jNode = Tri2Node2;
1162 else if (Tri2Node2 == iNode) jNode = Tri2Node1;
1165 dx2 = Nod3PntX - Nod2PntX;
1166 dy2 = Nod3PntY - Nod2PntY;
1167 dz2 = Nod3PntZ - Nod2PntZ;
1168 d2 = sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
1170 if (Tri2Node2 == iNode) jNode = Tri2Node3;
1171 else if (Tri2Node3 == iNode) jNode = Tri2Node2;
1174 dx3 = Nod1PntX - Nod3PntX;
1175 dy3 = Nod1PntY - Nod3PntY;
1176 dz3 = Nod1PntZ - Nod3PntZ;
1177 d3 = sqrt(dx3 * dx3 + dy3 * dy3 + dz3 * dz3);
1179 if (Tri2Node3 == iNode) jNode = Tri2Node1;
1180 else if (Tri2Node1 == iNode) jNode = Tri2Node3;
1184 dnx = (dy1 * dz2 - dy2 * dz1) * dn;
1185 dny = (dz1 * dx2 - dz2 * dx1) * dn;
1186 dnz = (dx1 * dy2 - dx2 * dy1) * dn;
1187 dn = sqrt(dnx * dnx + dny * dny + dnz * dnz);
1199 //=======================================================================
1200 //function : InitBiPointsWithConnexity
1202 //=======================================================================
1204 void HLRBRep_PolyAlgo::
1205 InitBiPointsWithConnexity (const Standard_Integer e,
1207 HLRAlgo_ListOfBPoint& List,
1208 TColStd_Array1OfTransient& PID,
1209 TopTools_ListOfShape& LS,
1210 const Standard_Boolean connex)
1212 Standard_Integer iPol,nbPol,i1,i1p1,i1p2,i2,i2p1,i2p2;
1213 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
1214 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
1215 Standard_Real U1,U2;
1216 Handle(Poly_PolygonOnTriangulation) HPol[2];
1218 myBCurv.Initialize(E);
1220 Standard_Integer nbConnex = LS.Extent();
1221 if (nbConnex == 1) {
1222 TopTools_ListIteratorOfListOfShape itn(LS);
1223 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1224 i1 = myFMap.FindIndex(F1);
1225 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1226 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1227 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1228 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1229 if (!HPol[0].IsNull()) {
1230 myPC.Initialize(E,F1);
1231 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1232 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1233 nbPol = Pol1.Upper();
1234 Standard_Address TData1 = &pid1->TData();
1235 Standard_Address PISeg1 = &pid1->PISeg();
1236 Standard_Address PINod1 = &pid1->PINod();
1237 Standard_Address Nod11Indices,Nod12Indices;
1238 Standard_Address Nod11RValues,Nod12RValues;
1239 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1240 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1241 Nod11Indices = (*pi1p1)->Indices();
1242 Nod11RValues = (*pi1p1)->RValues();
1243 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1244 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1245 Nod12Indices = (*pi1p2)->Indices();
1246 Nod12RValues = (*pi1p2)->RValues();
1247 Nod11Flag |= NMskVert;
1248 Nod12Flag |= NMskVert;
1250 for (iPol = 1; iPol <= nbPol; iPol++) {
1251 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1252 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1253 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1254 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1255 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1257 Nod1APCu1 = par->Value(iPol);
1261 Nod1APCu2 = par->Value(iPol);
1266 Nod12Indices = Nod11Indices;
1267 Nod12RValues = Nod11RValues;
1268 XTI2 = X2 = Nod12PntX;
1269 YTI2 = Y2 = Nod12PntY;
1270 ZTI2 = Z2 = Nod12PntZ;
1271 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1272 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1275 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1276 cout << "Parameter error on Node " << i1p2 << endl;
1279 Nod12Flag |= NMskEdge;
1280 TIMultiply(XTI2,YTI2,ZTI2);
1281 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1282 U2 = U2 - myPC.Period();
1284 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1285 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1286 Nod12Indices,Nod12RValues);
1287 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1288 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1292 for (iPol = 2; iPol <= nbPol; iPol++) {
1294 Nod11Indices = Nod12Indices;
1295 Nod11RValues = Nod12RValues;
1297 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1298 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1299 Nod12Indices = (*pi1p2)->Indices();
1300 Nod12RValues = (*pi1p2)->RValues();
1303 if (Nod11NrmX*Nod12NrmX +
1304 Nod11NrmY*Nod12NrmY +
1305 Nod11NrmZ*Nod12NrmZ < 0) {
1306 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1307 cout << "Too big angle between " << i1p1 << setw(6);
1308 cout << " and " << i1p2 << setw(6);
1309 cout << " in face " << i1 << endl;
1320 XTI2 = X2 = Nod12PntX;
1321 YTI2 = Y2 = Nod12PntY;
1322 ZTI2 = Z2 = Nod12PntZ;
1323 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1324 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1327 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1328 cout << "Parameter error on Node " << i1p2 << endl;
1331 Nod12Flag |= NMskEdge;
1332 TIMultiply(XTI2,YTI2,ZTI2);
1334 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1335 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1337 Nod11Indices,Nod11RValues,
1338 Nod12Indices,Nod12RValues,
1339 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1);
1345 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1346 cout << e << " connex 1 sans PolygonOnTriangulation" << endl;
1350 else if (nbConnex == 2) {
1351 TopTools_ListIteratorOfListOfShape itn(LS);
1352 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1353 i1 = myFMap.FindIndex(F1);
1354 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1355 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1357 const TopoDS_Face& F2 = TopoDS::Face(itn.Value());
1358 i2 = myFMap.FindIndex(F2);
1359 if (i1 == i2) E.Reverse();
1360 const Handle(Poly_Triangulation)& Tr2 = BRep_Tool::Triangulation(F2,L);
1361 HPol[1] = BRep_Tool::PolygonOnTriangulation(E,Tr2,L);
1362 GeomAbs_Shape rg = BRep_Tool::Continuity(E,F1,F2);
1363 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1364 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1365 const Handle(HLRAlgo_PolyInternalData)& pid2 =
1366 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i2));
1367 if (!HPol[0].IsNull() && !HPol[1].IsNull()) {
1368 myPC.Initialize(E,F1);
1369 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1370 const TColStd_Array1OfInteger& Pol2 = HPol[1]->Nodes();
1371 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1372 Standard_Integer nbPol = Pol1.Upper();
1373 Standard_Address TData1 = &pid1->TData();
1374 Standard_Address PISeg1 = &pid1->PISeg();
1375 Standard_Address PINod1 = &pid1->PINod();
1376 Standard_Address TData2 = &pid2->TData();
1377 Standard_Address PISeg2 = &pid2->PISeg();
1378 Standard_Address PINod2 = &pid2->PINod();
1379 Standard_Address Nod11Indices,Nod11RValues;
1380 Standard_Address Nod12Indices,Nod12RValues;
1381 Standard_Address Nod21Indices,Nod21RValues;
1382 Standard_Address Nod22Indices,Nod22RValues;
1383 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1384 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1385 Nod11Indices = (*pi1p1)->Indices();
1386 Nod11RValues = (*pi1p1)->RValues();
1387 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1388 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1389 Nod12Indices = (*pi1p2)->Indices();
1390 Nod12RValues = (*pi1p2)->RValues();
1391 const Handle(HLRAlgo_PolyInternalNode)* pi2p1 =
1392 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(1 )));
1393 Nod21Indices = (*pi2p1)->Indices();
1394 Nod21RValues = (*pi2p1)->RValues();
1395 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1396 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(nbPol)));
1397 Nod22Indices = (*pi2p2)->Indices();
1398 Nod22RValues = (*pi2p2)->RValues();
1399 Nod11Flag |= NMskVert;
1400 Nod12Flag |= NMskVert;
1401 Nod21Flag |= NMskVert;
1402 Nod22Flag |= NMskVert;
1404 for (iPol = 1; iPol <= nbPol; iPol++) {
1405 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1406 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1407 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1408 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1409 const Handle(HLRAlgo_PolyInternalNode)* pi2pA =
1410 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1411 Standard_Address Nod2AIndices = (*pi2pA)->Indices();
1412 Standard_Address Nod2ARValues = (*pi2pA)->RValues();
1413 Standard_Real PCu = par->Value(iPol);
1414 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1422 if (Nod2AEdg1 == 0 || Nod2AEdg1 == (Standard_Boolean) e) {
1433 Nod12Indices = Nod11Indices;
1434 Nod12RValues = Nod11RValues;
1436 Nod22Indices = Nod21Indices;
1437 Nod22RValues = Nod21RValues;
1438 XTI2 = X2 = Nod12PntX;
1439 YTI2 = Y2 = Nod12PntY;
1440 ZTI2 = Z2 = Nod12PntZ;
1441 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1442 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1445 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1446 cout << "Parameter error on Node " << i1p2 << endl;
1449 Nod12Flag |= NMskEdge;
1450 Nod22Flag |= NMskEdge;
1451 TIMultiply(XTI2,YTI2,ZTI2);
1452 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1453 U2 = U2 - myPC.Period();
1455 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1456 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1457 Nod12Indices,Nod12RValues);
1458 CheckDegeneratedSegment(Nod21Indices,Nod21RValues,
1459 Nod22Indices,Nod22RValues);
1460 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1461 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1462 UpdateAroundNode(Pol2(1 ),Nod21Indices,TData2,PISeg2,PINod2);
1463 UpdateAroundNode(Pol2(nbPol),Nod22Indices,TData2,PISeg2,PINod2);
1467 for (iPol = 2; iPol <= nbPol; iPol++) {
1469 Nod11Indices = Nod12Indices;
1470 Nod11RValues = Nod12RValues;
1472 Nod21Indices = Nod22Indices;
1473 Nod21RValues = Nod22RValues;
1475 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1476 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1477 Nod12Indices = (*pi1p2)->Indices();
1478 Nod12RValues = (*pi1p2)->RValues();
1480 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1481 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1482 Nod22Indices = (*pi2p2)->Indices();
1483 Nod22RValues = (*pi2p2)->RValues();
1486 if (Nod11NrmX*Nod12NrmX +
1487 Nod11NrmY*Nod12NrmY +
1488 Nod11NrmZ*Nod12NrmZ < 0) {
1489 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1490 cout << "To big angle between " << i1p1 << setw(6);
1491 cout << " and " << i1p2 << setw(6);
1492 cout << " in face " << i1 << endl;
1494 if (Nod21NrmX*Nod22NrmX +
1495 Nod21NrmY*Nod22NrmY +
1496 Nod21NrmZ*Nod22NrmZ < 0) {
1497 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1498 cout << "To big angle between " << i2p1 << setw(6);
1499 cout << " and " << i2p2 << setw(6);
1500 cout<< " in face " << i2 << endl;
1511 XTI2 = X2 = Nod12PntX;
1512 YTI2 = Y2 = Nod12PntY;
1513 ZTI2 = Z2 = Nod12PntZ;
1514 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1515 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1518 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1519 cout << "Parameter error on Node " << i1p2 << endl;
1522 Nod12Flag |= NMskEdge;
1523 Nod22Flag |= NMskEdge;
1524 TIMultiply(XTI2,YTI2,ZTI2);
1526 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1527 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1529 Nod11Indices,Nod11RValues,
1530 Nod12Indices,Nod12RValues,
1531 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1532 Nod21Indices,Nod21RValues,
1533 Nod22Indices,Nod22RValues,
1534 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2);
1540 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1541 cout << e << " connect 2 without PolygonOnTriangulation" << endl;
1546 else { // no connexity
1547 const Handle(Poly_Polygon3D)& Polyg = BRep_Tool::Polygon3D(E,L);
1548 if (!Polyg.IsNull()) {
1549 const TColgp_Array1OfPnt& Pol = Polyg->Nodes();
1550 gp_Trsf TT = L.Transformation();
1551 const gp_Trsf& T = myProj.Transformation();
1553 const gp_XYZ& ttlo = TT.TranslationPart();
1557 const gp_Mat& ttma = TT.VectorialPart();
1558 TTMa[0][0] = ttma.Value(1,1);
1559 TTMa[0][1] = ttma.Value(1,2);
1560 TTMa[0][2] = ttma.Value(1,3);
1561 TTMa[1][0] = ttma.Value(2,1);
1562 TTMa[1][1] = ttma.Value(2,2);
1563 TTMa[1][2] = ttma.Value(2,3);
1564 TTMa[2][0] = ttma.Value(3,1);
1565 TTMa[2][1] = ttma.Value(3,2);
1566 TTMa[2][2] = ttma.Value(3,3);
1567 Standard_Integer nbPol = Pol.Upper();
1568 const gp_XYZ& P1 = Pol(1).XYZ();
1572 TTMultiply(X2,Y2,Z2);
1576 TIMultiply(XTI2,YTI2,ZTI2);
1578 for (Standard_Integer iPol = 2; iPol <= nbPol; iPol++) {
1585 const gp_XYZ& P2 = Pol(iPol).XYZ();
1589 TTMultiply(X2,Y2,Z2);
1593 TIMultiply(XTI2,YTI2,ZTI2);
1594 List.Prepend(HLRAlgo_BiPoint
1595 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1596 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1602 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1603 cout << e << " Isolated, without Polygone 3D" << endl;
1609 //=======================================================================
1610 //function : Interpolation
1612 //=======================================================================
1616 Interpolation (HLRAlgo_ListOfBPoint& List,
1623 Standard_Real& XTI1,
1624 Standard_Real& YTI1,
1625 Standard_Real& ZTI1,
1626 Standard_Real& XTI2,
1627 Standard_Real& YTI2,
1628 Standard_Real& ZTI2,
1629 const Standard_Integer e,
1632 Standard_Address& Nod11Indices,
1633 Standard_Address& Nod11RValues,
1634 Standard_Address& Nod12Indices,
1635 Standard_Address& Nod12RValues,
1636 const Standard_Integer i1p1,
1637 const Standard_Integer i1p2,
1638 const Standard_Integer i1,
1639 const Handle(HLRAlgo_PolyInternalData)& pid1,
1640 Standard_Address& TData1,
1641 Standard_Address& PISeg1,
1642 Standard_Address& PINod1) const
1644 Standard_Boolean insP3,mP3P1;
1645 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1647 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1648 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1649 MoveOrInsertPoint(List,
1650 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1651 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1653 Nod11Indices,Nod11RValues,
1654 Nod12Indices,Nod12RValues,
1655 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1656 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,0);
1659 //=======================================================================
1660 //function : Interpolation
1662 //=======================================================================
1666 Interpolation (HLRAlgo_ListOfBPoint& List,
1673 Standard_Real& XTI1,
1674 Standard_Real& YTI1,
1675 Standard_Real& ZTI1,
1676 Standard_Real& XTI2,
1677 Standard_Real& YTI2,
1678 Standard_Real& ZTI2,
1679 const Standard_Integer e,
1682 const GeomAbs_Shape rg,
1683 Standard_Address& Nod11Indices,
1684 Standard_Address& Nod11RValues,
1685 Standard_Address& Nod12Indices,
1686 Standard_Address& Nod12RValues,
1687 const Standard_Integer i1p1,
1688 const Standard_Integer i1p2,
1689 const Standard_Integer i1,
1690 const Handle(HLRAlgo_PolyInternalData)& pid1,
1691 Standard_Address& TData1,
1692 Standard_Address& PISeg1,
1693 Standard_Address& PINod1,
1694 Standard_Address& Nod21Indices,
1695 Standard_Address& Nod21RValues,
1696 Standard_Address& Nod22Indices,
1697 Standard_Address& Nod22RValues,
1698 const Standard_Integer i2p1,
1699 const Standard_Integer i2p2,
1700 const Standard_Integer i2,
1701 const Handle(HLRAlgo_PolyInternalData)& pid2,
1702 Standard_Address& TData2,
1703 Standard_Address& PISeg2,
1704 Standard_Address& PINod2) const
1706 Standard_Boolean insP3,mP3P1,insP4,mP4P1;
1707 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1708 Standard_Real X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4;
1709 // gp_Pnt P3,PT3,P4,PT4;
1710 Standard_Boolean flag = 0;
1711 if (rg >= GeomAbs_G1) flag += 1;
1712 if (rg >= GeomAbs_G2) flag += 2;
1713 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1714 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1715 insP4 = Interpolation(U1,U2,Nod21RValues,Nod22RValues,
1716 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,mP4P1);
1717 Standard_Boolean OK = insP3 || insP4;
1719 if (!insP4) // p1 i1p3 p2
1720 MoveOrInsertPoint(List,
1721 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1722 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1724 Nod11Indices,Nod11RValues,
1725 Nod12Indices,Nod12RValues,
1726 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1727 Nod21Indices,Nod21RValues,
1728 Nod22Indices,Nod22RValues,
1729 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1730 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1731 else if (!insP3) // p1 i2p4 p2
1732 MoveOrInsertPoint(List,
1733 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1734 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1736 Nod21Indices,Nod21RValues,
1737 Nod22Indices,Nod22RValues,
1738 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1739 Nod11Indices,Nod11RValues,
1740 Nod12Indices,Nod12RValues,
1741 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1742 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1743 else if (Abs(coef4 - coef3) < myTolSta) // p1 i1p3-i2p4 p2
1744 MoveOrInsertPoint(List,
1745 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1746 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1748 Nod21Indices,Nod21RValues,
1749 Nod22Indices,Nod22RValues,
1750 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1751 Nod11Indices,Nod11RValues,
1752 Nod12Indices,Nod12RValues,
1753 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1754 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1755 else if (coef4 < coef3) // p1 i2p4 i1p3 p2
1756 MoveOrInsertPoint(List,
1757 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1758 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1760 Nod21Indices,Nod21RValues,
1761 Nod22Indices,Nod22RValues,
1762 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1763 Nod11Indices,Nod11RValues,
1764 Nod12Indices,Nod12RValues,
1765 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1766 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,
1767 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1768 else // p1 i1p3 i2p4 p2
1769 MoveOrInsertPoint(List,
1770 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1771 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1773 Nod11Indices,Nod11RValues,
1774 Nod12Indices,Nod12RValues,
1775 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1776 Nod21Indices,Nod21RValues,
1777 Nod22Indices,Nod22RValues,
1778 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1779 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,
1780 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1783 List.Prepend(HLRAlgo_BiPoint
1784 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1785 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1786 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
1789 //=======================================================================
1790 //function : Interpolation
1792 //=======================================================================
1796 Interpolation (const Standard_Real U1,
1797 const Standard_Real U2,
1798 const Standard_Address Nod1RValues,
1799 const Standard_Address Nod2RValues,
1803 Standard_Real& XTI3,
1804 Standard_Real& YTI3,
1805 Standard_Real& ZTI3,
1806 Standard_Real& coef3,
1808 Standard_Boolean& mP3P1) const
1810 if (NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1)) {
1811 U3 = U1 + (U2 - U1) * coef3;
1812 const gp_Pnt& P3 = myBCurv.Value(U3);
1816 TMultiply(X3,Y3,Z3);
1817 return Standard_True;
1819 return Standard_False;
1822 //=======================================================================
1823 //function : MoveOrInsertPoint
1825 //=======================================================================
1829 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1836 Standard_Real& XTI1,
1837 Standard_Real& YTI1,
1838 Standard_Real& ZTI1,
1839 Standard_Real& XTI2,
1840 Standard_Real& YTI2,
1841 Standard_Real& ZTI2,
1842 const Standard_Integer e,
1845 Standard_Address& Nod11Indices,
1846 Standard_Address& Nod11RValues,
1847 Standard_Address& Nod12Indices,
1848 Standard_Address& Nod12RValues,
1849 const Standard_Integer i1p1,
1850 const Standard_Integer i1p2,
1851 const Standard_Integer i1,
1852 const Handle(HLRAlgo_PolyInternalData)& pid1,
1853 Standard_Address& TData1,
1854 Standard_Address& PISeg1,
1855 Standard_Address& PINod1,
1856 const Standard_Real X3,
1857 const Standard_Real Y3,
1858 const Standard_Real Z3,
1859 const Standard_Real XTI3,
1860 const Standard_Real YTI3,
1861 const Standard_Real ZTI3,
1862 const Standard_Real coef3,
1863 const Standard_Real U3,
1864 const Standard_Boolean insP3,
1865 const Standard_Boolean mP3P1,
1866 const Standard_Boolean flag) const
1868 Standard_Address TData2 = 0;
1869 Standard_Address PISeg2 = 0;
1870 Standard_Address PINod2 = 0;
1871 Standard_Boolean ins3 = insP3;
1872 if (ins3 && mP3P1) { // P1 ---> P3
1873 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
1874 ins3 = Standard_False;
1875 ChangeNode(i1p1,i1p2,
1876 Nod11Indices,Nod11RValues,
1877 Nod12Indices,Nod12RValues,
1878 coef3,X3,Y3,Z3,Standard_True,
1879 TData1,PISeg1,PINod1);
1890 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
1891 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
1894 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1895 cout << "Parameter error on Node " << i1p1 << endl;
1899 Nod11Flag |= NMskOutL;
1900 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
1901 Standard_Address Coordinates = List.First().Coordinates();
1910 if (ins3 && !mP3P1) { // P2 ---> P3
1911 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
1912 ins3 = Standard_False;
1913 ChangeNode(i1p1,i1p2,
1914 Nod11Indices,Nod11RValues,
1915 Nod12Indices,Nod12RValues,
1916 coef3,X3,Y3,Z3,Standard_False,
1917 TData1,PISeg1,PINod1);
1928 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
1929 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
1932 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1933 cout << "Parameter error on Node " << i1p2 << endl;
1937 Nod12Flag |= NMskOutL;
1938 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
1941 if (ins3) { // p1 i1p3 p2
1942 Standard_Integer i1p3 = pid1->AddNode
1943 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
1944 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
1945 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
1946 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
1947 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
1951 Nod13Flag |= NMskOutL;
1952 Nod13Flag |= NMskEdge;
1953 pid1->UpdateLinks(i1p1,i1p2,i1p3,
1954 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
1955 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
1956 List.Prepend(HLRAlgo_BiPoint
1957 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
1958 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
1959 i1 ,i1p1,i1p3,flag));
1960 List.Prepend(HLRAlgo_BiPoint
1961 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
1962 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
1963 i1 ,i1p3,i1p2,flag));
1966 List.Prepend(HLRAlgo_BiPoint
1967 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1968 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1969 i1 ,i1p1,i1p2,flag));
1972 //=======================================================================
1973 //function : MoveOrInsertPoint
1975 //=======================================================================
1979 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1986 Standard_Real& XTI1,
1987 Standard_Real& YTI1,
1988 Standard_Real& ZTI1,
1989 Standard_Real& XTI2,
1990 Standard_Real& YTI2,
1991 Standard_Real& ZTI2,
1992 const Standard_Integer e,
1995 Standard_Address& Nod11Indices,
1996 Standard_Address& Nod11RValues,
1997 Standard_Address& Nod12Indices,
1998 Standard_Address& Nod12RValues,
1999 const Standard_Integer i1p1,
2000 const Standard_Integer i1p2,
2001 const Standard_Integer i1,
2002 const Handle(HLRAlgo_PolyInternalData)& pid1,
2003 Standard_Address& TData1,
2004 Standard_Address& PISeg1,
2005 Standard_Address& PINod1,
2006 Standard_Address& Nod21Indices,
2007 Standard_Address& Nod21RValues,
2008 Standard_Address& Nod22Indices,
2009 Standard_Address& Nod22RValues,
2010 const Standard_Integer i2p1,
2011 const Standard_Integer i2p2,
2012 const Standard_Integer i2,
2013 const Handle(HLRAlgo_PolyInternalData)& pid2,
2014 Standard_Address& TData2,
2015 Standard_Address& PISeg2,
2016 Standard_Address& PINod2,
2017 const Standard_Real X3,
2018 const Standard_Real Y3,
2019 const Standard_Real Z3,
2020 const Standard_Real XTI3,
2021 const Standard_Real YTI3,
2022 const Standard_Real ZTI3,
2023 const Standard_Real coef3,
2024 const Standard_Real U3,
2025 const Standard_Boolean insP3,
2026 const Standard_Boolean mP3P1,
2027 const Standard_Boolean flag) const
2029 Standard_Boolean ins3 = insP3;
2030 if (ins3 && mP3P1) { // P1 ---> P3
2031 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2032 ins3 = Standard_False;
2033 ChangeNode(i1p1,i1p2,
2034 Nod11Indices,Nod11RValues,
2035 Nod12Indices,Nod12RValues,
2036 coef3,X3,Y3,Z3,Standard_True,
2037 TData1,PISeg1,PINod1);
2038 ChangeNode(i2p1,i2p2,
2039 Nod21Indices,Nod21RValues,
2040 Nod22Indices,Nod22RValues,
2041 coef3,X3,Y3,Z3,Standard_True,
2042 TData2,PISeg2,PINod2);
2053 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2054 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2057 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2058 cout << "Parameter error on Node " << i1p1 << endl;
2062 Nod11Flag |= NMskOutL;
2063 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2067 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2068 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2071 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2072 cout << "Parameter error on Node " << i2p1 << endl;
2076 Nod21Flag |= NMskOutL;
2077 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2078 Standard_Address Coordinates = List.First().Coordinates();
2087 if (ins3 && !mP3P1) { // P2 ---> P3
2088 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
2089 ins3 = Standard_False;
2090 ChangeNode(i1p1,i1p2,
2091 Nod11Indices,Nod11RValues,
2092 Nod12Indices,Nod12RValues,
2093 coef3,X3,Y3,Z3,Standard_False,
2094 TData1,PISeg1,PINod1);
2095 ChangeNode(i2p1,i2p2,
2096 Nod21Indices,Nod21RValues,
2097 Nod22Indices,Nod22RValues,
2098 coef3,X3,Y3,Z3,Standard_False,
2099 TData2,PISeg2,PINod2);
2110 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
2111 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
2114 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2115 cout << "Parameter error on Node " << i1p2 << endl;
2119 Nod12Flag |= NMskOutL;
2120 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2124 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U3;
2125 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U3;
2128 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2129 cout << "Parameter error on Node " << i2p2 << endl;
2133 Nod22Flag |= NMskOutL;
2134 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2137 if (ins3) { // p1 i1p3 p2
2138 Standard_Integer i1p3 = pid1->AddNode
2139 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2140 Standard_Integer i2p3 = pid2->AddNode
2141 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2142 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2143 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2144 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2145 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2146 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2147 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2148 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2149 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2153 Nod13Flag |= NMskOutL;
2154 Nod13Flag |= NMskEdge;
2158 Nod23Flag |= NMskOutL;
2159 Nod23Flag |= NMskEdge;
2160 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2161 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2162 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2163 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2164 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2165 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2166 List.Prepend(HLRAlgo_BiPoint
2167 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2168 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2169 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2170 List.Prepend(HLRAlgo_BiPoint
2171 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
2172 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
2173 i1 ,i1p3,i1p2,i2 ,i2p3,i2p2,flag));
2176 List.Prepend(HLRAlgo_BiPoint
2177 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2178 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2179 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2182 //=======================================================================
2183 //function : MoveOrInsertPoint
2185 //=======================================================================
2189 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
2196 Standard_Real& XTI1,
2197 Standard_Real& YTI1,
2198 Standard_Real& ZTI1,
2199 Standard_Real& XTI2,
2200 Standard_Real& YTI2,
2201 Standard_Real& ZTI2,
2202 const Standard_Integer e,
2205 Standard_Address& Nod11Indices,
2206 Standard_Address& Nod11RValues,
2207 Standard_Address& Nod12Indices,
2208 Standard_Address& Nod12RValues,
2209 const Standard_Integer i1p1,
2210 const Standard_Integer i1p2,
2211 const Standard_Integer i1,
2212 const Handle(HLRAlgo_PolyInternalData)& pid1,
2213 Standard_Address& TData1,
2214 Standard_Address& PISeg1,
2215 Standard_Address& PINod1,
2216 Standard_Address& Nod21Indices,
2217 Standard_Address& Nod21RValues,
2218 Standard_Address& Nod22Indices,
2219 Standard_Address& Nod22RValues,
2220 const Standard_Integer i2p1,
2221 const Standard_Integer i2p2,
2222 const Standard_Integer i2,
2223 const Handle(HLRAlgo_PolyInternalData)& pid2,
2224 Standard_Address& TData2,
2225 Standard_Address& PISeg2,
2226 Standard_Address& PINod2,
2227 const Standard_Real X3,
2228 const Standard_Real Y3,
2229 const Standard_Real Z3,
2230 const Standard_Real XTI3,
2231 const Standard_Real YTI3,
2232 const Standard_Real ZTI3,
2233 const Standard_Real coef3,
2234 const Standard_Real U3,
2235 const Standard_Boolean insP3,
2236 const Standard_Boolean mP3P1,
2237 const Standard_Real X4,
2238 const Standard_Real Y4,
2239 const Standard_Real Z4,
2240 const Standard_Real XTI4,
2241 const Standard_Real YTI4,
2242 const Standard_Real ZTI4,
2243 const Standard_Real coef4,
2244 const Standard_Real U4,
2245 const Standard_Boolean insP4,
2246 const Standard_Boolean mP4P1,
2247 const Standard_Boolean flag) const
2249 Standard_Boolean ins3 = insP3;
2250 Standard_Boolean ins4 = insP4;
2251 if (ins3 && mP3P1) { // P1 ---> P3
2252 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2253 ins3 = Standard_False;
2254 ChangeNode(i1p1,i1p2,
2255 Nod11Indices,Nod11RValues,
2256 Nod12Indices,Nod12RValues,
2257 coef3,X3,Y3,Z3,Standard_True,
2258 TData1,PISeg1,PINod1);
2259 ChangeNode(i2p1,i2p2,
2260 Nod21Indices,Nod21RValues,
2261 Nod22Indices,Nod22RValues,
2262 coef3,X3,Y3,Z3,Standard_True,
2263 TData2,PISeg2,PINod2);
2274 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2275 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2278 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2279 cout << "Parameter error on Node " << i1p1 << endl;
2283 Nod11Flag |= NMskOutL;
2284 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2288 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2289 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2292 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2293 cout << "Parameter error on Node " << i2p1 << endl;
2297 Nod21Flag |= NMskOutL;
2298 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2299 Standard_Address Coordinates = List.First().Coordinates();
2308 if (ins4 && !mP4P1) { // P2 ---> P4
2309 if (!(Nod12Flag & NMskVert) && coef4 > myTolEnd) {
2310 ins4 = Standard_False;
2311 ChangeNode(i2p1,i2p2,
2312 Nod21Indices,Nod21RValues,
2313 Nod22Indices,Nod22RValues,
2314 coef4,X4,Y4,Z4,Standard_False,
2315 TData2,PISeg2,PINod2);
2316 ChangeNode(i1p1,i1p2,
2317 Nod11Indices,Nod11RValues,
2318 Nod12Indices,Nod12RValues,
2319 coef4,X4,Y4,Z4,Standard_False,
2320 TData1,PISeg1,PINod1);
2331 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U4;
2332 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U4;
2335 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2336 cout << "Parameter error on Node " << i1p2 << endl;
2340 Nod12Flag |= NMskOutL;
2341 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2345 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U4;
2346 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U4;
2349 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2350 cout << "Parameter error on Node " << i2p2 << endl;
2354 Nod22Flag |= NMskOutL;
2355 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2359 if (!ins4) // p1 i1p3 p2
2360 MoveOrInsertPoint(List,
2361 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2362 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2364 Nod11Indices,Nod11RValues,
2365 Nod12Indices,Nod12RValues,
2366 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2367 Nod21Indices,Nod21RValues,
2368 Nod22Indices,Nod22RValues,
2369 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2370 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
2371 else if (!ins3) // p1 i2p4 p2
2372 MoveOrInsertPoint(List,
2373 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2374 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2376 Nod21Indices,Nod21RValues,
2377 Nod22Indices,Nod22RValues,
2378 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2379 Nod11Indices,Nod11RValues,
2380 Nod12Indices,Nod12RValues,
2381 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2382 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
2383 else { // p1 i1p3 i2p4 p2
2384 Standard_Integer i1p3 = pid1->AddNode
2385 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2386 Standard_Integer i2p3 = pid2->AddNode
2387 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2388 Standard_Integer i1p4 = pid1->AddNode
2389 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef4,X4,Y4,Z4);
2390 Standard_Integer i2p4 = pid2->AddNode
2391 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef4,X4,Y4,Z4);
2392 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2393 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2394 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2395 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2396 const Handle(HLRAlgo_PolyInternalNode)* pi1p4 =
2397 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p4));
2398 const Standard_Address Nod14Indices = (*pi1p4)->Indices();
2399 const Standard_Address Nod14RValues = (*pi1p4)->RValues();
2400 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2401 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2402 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2403 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2404 const Handle(HLRAlgo_PolyInternalNode)* pi2p4 =
2405 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p4));
2406 const Standard_Address Nod24Indices = (*pi2p4)->Indices();
2407 const Standard_Address Nod24RValues = (*pi2p4)->RValues();
2411 Nod13Flag |= NMskOutL;
2412 Nod13Flag |= NMskEdge;
2416 Nod23Flag |= NMskOutL;
2417 Nod23Flag |= NMskEdge;
2421 Nod14Flag |= NMskOutL;
2422 Nod14Flag |= NMskEdge;
2426 Nod24Flag |= NMskOutL;
2427 Nod24Flag |= NMskEdge;
2428 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2429 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2430 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2431 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2432 pid2->UpdateLinks(i2p3,i2p2,i2p4,
2433 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2434 pid1->UpdateLinks(i1p3,i1p2,i1p4,
2435 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2436 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2437 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2438 UpdateAroundNode(i1p4,Nod14Indices,TData1,PISeg1,PINod1);
2439 UpdateAroundNode(i2p4,Nod24Indices,TData2,PISeg2,PINod2);
2440 List.Prepend(HLRAlgo_BiPoint
2441 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2442 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2443 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2444 List.Prepend(HLRAlgo_BiPoint
2445 (XTI3,YTI3,ZTI3,XTI4,YTI4,ZTI4,
2446 X3 ,Y3 ,Z3 ,X4 ,Y4 ,Z4 , e,
2447 i1 ,i1p3,i1p4,i2 ,i2p3,i2p4,flag));
2448 List.Prepend(HLRAlgo_BiPoint
2449 (XTI4,YTI4,ZTI4,XTI2,YTI2,ZTI2,
2450 X4 ,Y4 ,Z4 ,X2 ,Y2 ,Z2 , e,
2451 i1 ,i1p4,i1p2,i2 ,i2p4,i2p2,flag));
2455 List.Prepend(HLRAlgo_BiPoint
2456 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2457 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2458 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2461 //=======================================================================
2462 //function : InsertOnOutLine
2464 //=======================================================================
2467 HLRBRep_PolyAlgo::InsertOnOutLine (TColStd_Array1OfTransient& PID)
2469 Standard_Address TData2 = 0;
2470 Standard_Address PISeg2 = 0;
2471 Standard_Address PINod2 = 0;
2472 Standard_Address Seg1Indices;
2473 Standard_Address Nod1Indices,Nod1RValues;
2474 Standard_Address Nod2Indices,Nod2RValues;
2475 Handle(HLRAlgo_PolyInternalData)* pid =
2476 (Handle(HLRAlgo_PolyInternalData)*) (&(PID.ChangeValue(1)));
2479 Standard_Boolean insP3,mP3P1,IntOutL;
2480 Standard_Integer f,ip1,ip2,ip3;//, i;
2481 Standard_Real U3,V3,coef3,X3,Y3,Z3;
2483 const gp_Trsf& T = myProj.Transformation();
2485 Standard_Integer nbFace = myFMap.Extent();
2486 for (f = 1; f <= nbFace; f++) {
2488 if (!((*pid).IsNull())) {
2489 IntOutL = Standard_False;
2490 Standard_Address TData1= &((*pid)->TData());
2491 Standard_Address PISeg1= &((*pid)->PISeg());
2492 Standard_Address PINod1= &((*pid)->PINod());
2493 TopoDS_Shape LocalShape = myFMap(f);
2494 const TopoDS_Face& F = TopoDS::Face(LocalShape);
2495 myBSurf.Initialize(F,Standard_False);
2496 myGSurf = BRep_Tool::Surface(F,L);
2497 gp_Trsf TT = L.Transformation();
2499 const gp_XYZ& ttlo = TT.TranslationPart();
2503 const gp_Mat& ttma = TT.VectorialPart();
2504 TTMa[0][0] = ttma.Value(1,1);
2505 TTMa[0][1] = ttma.Value(1,2);
2506 TTMa[0][2] = ttma.Value(1,3);
2507 TTMa[1][0] = ttma.Value(2,1);
2508 TTMa[1][1] = ttma.Value(2,2);
2509 TTMa[1][2] = ttma.Value(2,3);
2510 TTMa[2][0] = ttma.Value(3,1);
2511 TTMa[2][1] = ttma.Value(3,2);
2512 TTMa[2][2] = ttma.Value(3,3);
2513 Standard_Integer iseg,nbT,nbS,nbN;
2515 nbT = (*pid)->NbTData();
2516 nbN = (*pid)->NbPINod();
2517 nbS = (*pid)->NbPISeg();
2521 cout << " InsertOnOutLine : NbTData " << nbT << endl;
2522 cout << " InsertOnOutLine : NbPISeg " << nbS << endl;
2523 cout << " InsertOnOutLine : NbPINod " << nbN << endl;
2527 for (iseg = 1; iseg <= nbS; iseg++) {
2529 ((HLRAlgo_Array1OfPISeg*)PISeg1)->ChangeValue(iseg).Indices();
2530 // Standard_Boolean Cutted = Standard_False;
2531 if (Seg1Conex1 != 0 && Seg1Conex2 != 0) {
2534 const Handle(HLRAlgo_PolyInternalNode)* pip1 =
2535 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip1));
2536 Nod1Indices = (*pip1)->Indices();
2537 Nod1RValues = (*pip1)->RValues();
2538 const Handle(HLRAlgo_PolyInternalNode)* pip2 =
2539 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip2));
2540 Nod2Indices = (*pip2)->Indices();
2541 Nod2RValues = (*pip2)->RValues();
2542 if (Nod1Flag & NMskOutL && Nod2Flag & NMskOutL)
2543 IntOutL = Standard_True;
2544 else if ((Nod1Scal >= myTolAngular &&
2545 Nod2Scal <= -myTolAngular) ||
2546 (Nod2Scal >= myTolAngular &&
2547 Nod1Scal <= -myTolAngular)) {
2548 IntOutL = Standard_True;
2549 insP3 = NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1);
2551 UVNode(Nod1RValues,Nod2RValues,coef3,U3,V3);
2552 const gp_Pnt& PT3 = myGSurf->Value(U3,V3);
2556 TTMultiply(X3,Y3,Z3);
2559 if (insP3 && mP3P1) { // P1 ---> P3
2560 if ((Nod1Flag & NMskEdge) == 0 && coef3 < myTolSta) {
2561 insP3 = Standard_False;
2563 Nod1Indices,Nod1RValues,
2564 Nod2Indices,Nod2RValues,
2565 coef3,X3,Y3,Z3,Standard_True,
2566 TData1,PISeg1,PINod1);
2568 Nod1Flag |= NMskOutL;
2571 if (insP3 && !mP3P1) { // P2 ---> P3
2572 if ((Nod2Flag & NMskEdge) == 0 && coef3 > myTolEnd) {
2573 insP3 = Standard_False;
2575 Nod1Indices,Nod1RValues,
2576 Nod2Indices,Nod2RValues,
2577 coef3,X3,Y3,Z3,Standard_False,
2578 TData1,PISeg1,PINod1);
2580 Nod2Flag |= NMskOutL;
2583 if (insP3) { // p1 ip3 p2
2584 ip3 = (*pid)->AddNode(Nod1RValues,Nod2RValues,PINod1,PINod2,
2586 const Handle(HLRAlgo_PolyInternalNode)* pip3 =
2587 (&((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip3));
2588 const Standard_Address Nod3Indices = (*pip3)->Indices();
2589 const Standard_Address Nod3RValues = (*pip3)->RValues();
2590 (*pid)->UpdateLinks(ip1,ip2,ip3,
2591 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2592 UpdateAroundNode(ip3,Nod3Indices,TData1,PISeg1,PINod1);
2594 Nod3Flag |= NMskOutL;
2600 (*pid)->IntOutL(Standard_True);
2602 nbT = (*pid)->NbTData();
2603 nbN = (*pid)->NbPINod();
2604 nbS = (*pid)->NbPISeg();
2608 cout << " InsertOnOutLine : NbTData " << nbT << endl;
2609 cout << " InsertOnOutLine : NbPISeg " << nbS << endl;
2610 cout << " InsertOnOutLine : NbPINod " << nbN << endl;
2618 //=======================================================================
2619 //function : CheckFrBackTriangles
2621 //=======================================================================
2624 HLRBRep_PolyAlgo::CheckFrBackTriangles (HLRAlgo_ListOfBPoint& List,
2625 TColStd_Array1OfTransient& PID)
2627 Standard_Integer f,i,nbN,nbT,nbFace;
2628 Standard_Real X1 =0.,Y1 =0.,X2 =0.,Y2 =0.,X3 =0.,Y3 =0.;
2629 Standard_Real D1,D2,D3;
2630 Standard_Real dd,dX,dY,nX,nY;
2631 Standard_Boolean FrBackInList;
2632 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;
2647 Standard_Address Nod11Indices,Nod12Indices,Nod13Indices;
2648 Standard_Address Nod11RValues,Nod12RValues,Nod13RValues;
2649 Standard_Address Tri1Indices;
2651 Handle(HLRAlgo_PolyInternalData)* pid;
2653 nbFace = myFMap.Extent();
2654 Standard_Boolean Modif = Standard_True;
2655 Standard_Integer iLoop = 0;
2657 while (Modif && iLoop < 4) {
2659 Modif = Standard_False;
2660 FrBackInList = Standard_False;
2661 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2663 for (f = 1; f <= nbFace; f++) {
2664 if (!(*pid).IsNull()) {
2665 nbT = (*pid)->NbTData();
2666 TData = &(*pid)->TData();
2667 PISeg = &(*pid)->PISeg();
2668 PINod = &(*pid)->PINod();
2669 HLRAlgo_TriangleData* tdata =
2670 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
2672 for (i = 1; i <= nbT; i++) {
2673 Tri1Indices = tdata->Indices();
2674 if ((Tri1Flags & FMskSide) == 0 &&
2675 (Tri1Flags & FMskFrBack)) {
2678 cout << " face : " << f << " , triangle " << i << endl;
2680 Modif = Standard_True;
2681 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
2682 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
2683 Nod11Indices = (*pi1p1)->Indices();
2684 Nod11RValues = (*pi1p1)->RValues();
2685 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
2686 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
2687 Nod12Indices = (*pi1p2)->Indices();
2688 Nod12RValues = (*pi1p2)->RValues();
2689 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2690 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
2691 Nod13Indices = (*pi1p3)->Indices();
2692 Nod13RValues = (*pi1p3)->RValues();
2693 D1 = 0.; D2 = 0.; D3 = 0.;
2694 if (((Nod11Flag & NMskEdge) == 0 || iLoop > 1) &&
2695 ((Nod11Flag & NMskOutL) == 0 || iLoop > 1) &&
2696 ((Nod11Flag & NMskVert) == 0)) {
2697 dX = Nod13PntX - Nod12PntX; dY = Nod13PntY - Nod12PntY;
2698 D1 = dX * dX + dY * dY;
2700 nX = - dY / D1; nY = dX / D1;
2701 dX = Nod11PntX - Nod12PntX; dY = Nod11PntY - Nod12PntY;
2702 dd = - (dX * nX + dY * nY);
2703 if (dd < 0) dd -= D1 * 0.01;
2704 else dd += D1 * 0.01;
2705 X1 = nX * dd; Y1 = nY * dd;
2707 if (((Nod12Flag & NMskEdge) == 0 || iLoop > 1) &&
2708 ((Nod12Flag & NMskOutL) == 0 || iLoop > 1) &&
2709 ((Nod12Flag & NMskVert) == 0)) {
2710 dX = Nod11PntX - Nod13PntX; dY = Nod11PntY - Nod13PntY;
2711 D2 = dX * dX + dY * dY;
2713 nX = - dY / D2; nY = dX / D2;
2714 dX = Nod12PntX - Nod13PntX; dY = Nod12PntY - Nod13PntY;
2715 dd = - (dX * nX + dY * nY);
2716 if (dd < 0) dd -= D2 * 0.01;
2717 else dd += D2 * 0.01;
2718 X2 = nX * dd; Y2 = nY * dd;
2720 if (((Nod13Flag & NMskEdge) == 0 || iLoop > 1) &&
2721 ((Nod13Flag & NMskOutL) == 0 || iLoop > 1) &&
2722 ((Nod13Flag & NMskVert) == 0)) {
2723 dX = Nod12PntX - Nod11PntX; dY = Nod12PntY - Nod11PntY;
2724 D3 = dX * dX + dY * dY;
2726 nX = - dY / D3; nY = dX / D3;
2727 dX = Nod13PntX - Nod11PntX; dY = Nod13PntY - Nod11PntY;
2728 dd = - (dX * nX + dY * nY);
2729 if (dd < 0) dd -= D3 * 0.01;
2730 else dd += D3 * 0.01;
2731 X3 = nX * dd; Y3 = nY * dd;
2733 if (D1 > D2 && D1 > D3) {
2734 Nod11PntX += X1; Nod11PntY += Y1;
2735 Nod11Flag |= NMskMove;
2736 UpdateAroundNode(Tri1Node1,Nod11Indices,TData,PISeg,PINod);
2737 FrBackInList = Standard_True;
2740 cout << Tri1Node1 << " modifies : DX,DY ";
2741 cout << X1 << " , " << Y1 << endl;
2745 else if (D2 > D3 && D2 > D1) {
2746 Nod12PntX += X2; Nod12PntY += Y2;
2747 Nod12Flag |= NMskMove;
2748 UpdateAroundNode(Tri1Node2,Nod12Indices,TData,PISeg,PINod);
2749 FrBackInList = Standard_True;
2752 cout << Tri1Node2 << " modifies : DX,DY ";
2753 cout << X2 << " , " << Y2 << endl;
2757 else if (D3 > D1 && D3 > D2) {
2758 Nod13PntX += X3; Nod13PntY += Y3;
2759 Nod13Flag |= NMskMove;
2760 UpdateAroundNode(Tri1Node3,Nod13Indices,TData,PISeg,PINod);
2761 FrBackInList = Standard_True;
2764 cout << Tri1Node3 << " modifies : DX,DY ";
2765 cout << X3 << " , " << Y3 << endl;
2771 cout << "modification error" << endl;
2780 Standard_Address IndexPtr,Coordinates;
2781 HLRAlgo_ListIteratorOfListOfBPoint it;
2783 for (it.Initialize(List); it.More(); it.Next()) {
2784 HLRAlgo_BiPoint& BP = it.Value();
2785 IndexPtr = BP.Indices();
2787 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2788 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2789 TData1 = &pid1->TData();
2790 PISeg1 = &pid1->PISeg();
2791 PINod1 = &pid1->PINod();
2794 if (F1Index == F2Index) {
2800 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2801 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2802 TData2 = &pid2->TData();
2803 PISeg2 = &pid2->PISeg();
2804 PINod2 = &pid2->PINod();
2808 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2809 ChangeValue(F1Pt1Index))->Indices();
2810 if (Nod11Flag & NMskMove) {
2813 cout << F1Pt1Index << " modifies 11" << endl;
2815 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2816 ChangeValue(F1Pt1Index))->RValues();
2817 Coordinates = BP.Coordinates();
2818 PntXTI1 = PntX1 = Nod11PntX;
2819 PntYTI1 = PntY1 = Nod11PntY;
2820 PntZTI1 = PntZ1 = Nod11PntZ;
2821 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2823 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2824 ChangeValue(F2Pt1Index))->Indices();
2825 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2826 ChangeValue(F2Pt1Index))->RValues();
2827 Nod12PntX = Nod11PntX;
2828 Nod12PntY = Nod11PntY;
2829 UpdateAroundNode(F2Pt1Index,Nod12Indices,
2830 TData2,PISeg2,PINod2);
2833 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2834 ChangeValue(F1Pt2Index))->Indices();
2835 if (Nod11Flag & NMskMove) {
2838 cout << F1Pt2Index << " modifies 12" << endl;
2840 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2841 ChangeValue(F1Pt2Index))->RValues();
2842 Coordinates = BP.Coordinates();
2843 PntXTI2 = PntX2 = Nod11PntX;
2844 PntYTI2 = PntY2 = Nod11PntY;
2845 PntZTI2 = PntZ2 = Nod11PntZ;
2846 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2848 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2849 ChangeValue(F2Pt2Index))->Indices();
2850 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2851 ChangeValue(F2Pt2Index))->RValues();
2852 Nod12PntX = Nod11PntX;
2853 Nod12PntY = Nod11PntY;
2854 UpdateAroundNode(F2Pt2Index,Nod12Indices,
2855 TData2,PISeg2,PINod2);
2860 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2861 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2862 PINod2 = &pid2->PINod();
2863 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2864 ChangeValue(F2Pt1Index))->Indices();
2865 if (Nod11Flag & NMskMove) {
2868 cout << F2Pt1Index << " modifies 21" << endl;
2870 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2871 ChangeValue(F2Pt1Index))->RValues();
2872 Coordinates = BP.Coordinates();
2873 PntXTI1 = PntX1 = Nod11PntX;
2874 PntYTI1 = PntY1 = Nod11PntY;
2875 PntZTI1 = PntZ1 = Nod11PntZ;
2876 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2878 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2879 ChangeValue(F1Pt1Index))->Indices();
2880 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2881 ChangeValue(F1Pt1Index))->RValues();
2882 Nod12PntX = Nod11PntX;
2883 Nod12PntY = Nod11PntY;
2884 UpdateAroundNode(F1Pt1Index,Nod12Indices,
2885 TData1,PISeg1,PINod1);
2888 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2889 ChangeValue(F2Pt2Index))->Indices();
2890 if (Nod11Flag & NMskMove) {
2893 cout << F2Pt2Index << " modifies 22" << endl;
2895 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2896 ChangeValue(F2Pt2Index))->RValues();
2897 Coordinates = BP.Coordinates();
2898 PntXTI2 = PntX2 = Nod11PntX;
2899 PntYTI2 = PntY2 = Nod11PntY;
2900 PntZTI2 = PntZ2 = Nod11PntZ;
2901 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2903 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2904 ChangeValue(F1Pt2Index))->Indices();
2905 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2906 ChangeValue(F1Pt2Index))->RValues();
2907 Nod12PntX = Nod11PntX;
2908 Nod12PntY = Nod11PntY;
2909 UpdateAroundNode(F1Pt2Index,Nod12Indices,
2910 TData1,PISeg1,PINod1);
2915 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2917 for (f = 1; f <= nbFace; f++) {
2918 if (!(*pid).IsNull()) {
2919 nbN = (*pid)->NbPINod();
2920 PINod = &(*pid)->PINod();
2921 Handle(HLRAlgo_PolyInternalNode)* NN =
2922 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
2924 for (i = 1; i <= nbN; i++) {
2925 Nod11Indices = (*NN)->Indices();
2926 Nod11Flag &= ~NMskMove;
2936 //=======================================================================
2937 //function : FindEdgeOnTriangle
2939 //=======================================================================
2943 FindEdgeOnTriangle (const Standard_Address Tri1Indices,
2944 const Standard_Integer ip1,
2945 const Standard_Integer ip2,
2946 Standard_Integer& jtrouv,
2947 Standard_Boolean& isDirect) const
2949 Standard_Integer n1 = Tri1Node1;
2950 Standard_Integer n2 = Tri1Node2;
2951 Standard_Integer n3 = Tri1Node3;
2952 if (ip1 == n1 && ip2 == n2) {
2954 isDirect = Standard_True;
2957 else if (ip2 == n1 && ip1 == n2) {
2959 isDirect = Standard_False;
2962 else if (ip1 == n2 && ip2 == n3) {
2964 isDirect = Standard_True;
2967 else if (ip2 == n2 && ip1 == n3) {
2969 isDirect = Standard_False;
2972 else if (ip1 == n3 && ip2 == n1) {
2974 isDirect = Standard_True;
2977 else if (ip2 == n3 && ip1 == n1) {
2979 isDirect = Standard_False;
2984 //=======================================================================
2985 //function : ChangeNode
2987 //=======================================================================
2989 void HLRBRep_PolyAlgo::ChangeNode (const Standard_Integer ip1,
2990 const Standard_Integer ip2,
2991 const Standard_Address Nod1Indices,
2992 const Standard_Address Nod1RValues,
2993 const Standard_Address Nod2Indices,
2994 const Standard_Address Nod2RValues,
2995 const Standard_Real coef1,
2996 const Standard_Real X3,
2997 const Standard_Real Y3,
2998 const Standard_Real Z3,
2999 const Standard_Boolean first,
3000 Standard_Address& TData,
3001 Standard_Address& PISeg,
3002 Standard_Address& PINod) const
3004 Standard_Real coef2 = 1 - coef1;
3009 Nod1PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3010 Nod1PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3011 Nod1Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3012 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3013 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3014 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3015 Standard_Real D = sqrt (x * x + y * y + z * z);
3027 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip1;
3028 cout << " and " << ip2 << endl;
3032 UpdateAroundNode(ip1,Nod1Indices,TData,PISeg,PINod);
3038 Nod2PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3039 Nod2PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3040 Nod2Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3041 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3042 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3043 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3044 Standard_Real D = sqrt (x * x + y * y + z * z);
3057 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip2;
3058 cout << " and " << ip1 << endl;
3062 UpdateAroundNode(ip2,Nod2Indices,TData,PISeg,PINod);
3066 //=======================================================================
3067 //function : UpdateAroundNode
3069 //=======================================================================
3071 void HLRBRep_PolyAlgo::
3072 UpdateAroundNode (const Standard_Integer iNode,
3073 const Standard_Address Nod1Indices,
3074 const Standard_Address TData,
3075 const Standard_Address PISeg,
3076 const Standard_Address PINod) const
3078 Standard_Integer iiii,iTri1,iTri2;
3082 const Standard_Address Seg1Indices =
3083 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3087 const Standard_Address Tri1Indices =
3088 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri1).Indices();
3089 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3090 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
3091 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3092 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
3093 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3094 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
3095 const Standard_Address Nod1Indices = (*PN1)->Indices();
3096 const Standard_Address Nod2Indices = (*PN2)->Indices();
3097 const Standard_Address Nod3Indices = (*PN3)->Indices();
3098 const Standard_Address Nod1RValues = (*PN1)->RValues();
3099 const Standard_Address Nod2RValues = (*PN2)->RValues();
3100 const Standard_Address Nod3RValues = (*PN3)->RValues();
3101 OrientTriangle(iTri1,Tri1Indices,
3102 Nod1Indices,Nod1RValues,
3103 Nod2Indices,Nod2RValues,
3104 Nod3Indices,Nod3RValues);
3107 const Standard_Address Tri2Indices =
3108 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri2).Indices();
3109 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3110 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1));
3111 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3112 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2));
3113 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3114 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3));
3115 const Standard_Address Nod1Indices = (*PN1)->Indices();
3116 const Standard_Address Nod2Indices = (*PN2)->Indices();
3117 const Standard_Address Nod3Indices = (*PN3)->Indices();
3118 const Standard_Address Nod1RValues = (*PN1)->RValues();
3119 const Standard_Address Nod2RValues = (*PN2)->RValues();
3120 const Standard_Address Nod3RValues = (*PN3)->RValues();
3121 OrientTriangle(iTri2,Tri2Indices,
3122 Nod1Indices,Nod1RValues,
3123 Nod2Indices,Nod2RValues,
3124 Nod3Indices,Nod3RValues);
3126 if (Seg1LstSg1 == iNode) iiii = Seg1NxtSg1;
3127 else iiii = Seg1NxtSg2;
3131 //=======================================================================
3132 //function : OrientTriangle
3134 //=======================================================================
3137 HLRBRep_PolyAlgo::OrientTriangle(const Standard_Integer iTri,
3138 const Standard_Address Tri1Indices,
3139 const Standard_Address Nod1Indices,
3140 const Standard_Address Nod1RValues,
3141 const Standard_Address Nod2Indices,
3142 const Standard_Address Nod2RValues,
3143 const Standard_Address Nod3Indices,
3144 const Standard_Address Nod3RValues) const
3146 Standard_Boolean o1 = Nod1Flag & NMskOutL;
3147 Standard_Boolean o2 = Nod2Flag & NMskOutL;
3148 Standard_Boolean o3 = Nod3Flag & NMskOutL;
3149 Tri1Flags &= ~FMskFlat;
3150 Tri1Flags &= ~FMskOnOutL;
3151 if (o1 && o2 && o3) {
3152 Tri1Flags |= FMskSide;
3153 Tri1Flags &= ~FMskBack;
3154 Tri1Flags |= FMskOnOutL;
3157 cout << "HLRBRep_PolyAlgo::OrientTriangle : OnOutL";
3158 cout << " triangle " << iTri << endl;
3163 Standard_Real s1 = Nod1Scal;
3164 Standard_Real s2 = Nod2Scal;
3165 Standard_Real s3 = Nod3Scal;
3166 Standard_Real as1 = s1;
3167 Standard_Real as2 = s2;
3168 Standard_Real as3 = s3;
3169 if (s1 < 0) as1 = -s1;
3170 if (s2 < 0) as2 = -s2;
3171 if (s3 < 0) as3 = -s3;
3172 Standard_Real s = 0;
3173 Standard_Real as = 0;
3174 if (!o1 ) {s = s1; as = as1;}
3175 if (!o2 && as < as2) {s = s2; as = as2;}
3176 if (!o3 && as < as3) {s = s3; as = as3;}
3178 Tri1Flags &= ~FMskSide;
3179 Tri1Flags |= FMskBack;
3182 Tri1Flags &= ~FMskSide;
3183 Tri1Flags &= ~FMskBack;
3185 Standard_Real dx12 = Nod2PntX - Nod1PntX;
3186 Standard_Real dy12 = Nod2PntY - Nod1PntY;
3187 Standard_Real dz12 = Nod2PntZ - Nod1PntZ;
3188 Standard_Real d12 = sqrt(dx12 * dx12 + dy12 * dy12 + dz12 * dz12);
3189 if (d12 <= 1.e-10) {
3192 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3193 cout << " triangle " << iTri << endl;
3196 Tri1Flags |= FMskFlat;
3197 Tri1Flags |= FMskSide;
3198 Tri1Flags &= ~FMskBack;
3201 Standard_Real dx23 = Nod3PntX - Nod2PntX;
3202 Standard_Real dy23 = Nod3PntY - Nod2PntY;
3203 Standard_Real dz23 = Nod3PntZ - Nod2PntZ;
3204 Standard_Real d23 = sqrt(dx23 * dx23 + dy23 * dy23 + dz23 * dz23);
3208 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3209 cout << " triangle " << iTri << endl;
3212 Tri1Flags |= FMskFlat;
3213 Tri1Flags |= FMskSide;
3214 Tri1Flags &= ~FMskBack;
3217 Standard_Real dx31 = Nod1PntX - Nod3PntX;
3218 Standard_Real dy31 = Nod1PntY - Nod3PntY;
3219 Standard_Real dz31 = Nod1PntZ - Nod3PntZ;
3220 Standard_Real d31 = sqrt(dx31 * dx31 + dy31 * dy31 + dz31 * dz31);
3224 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3225 cout << " triangle " << iTri << endl;
3228 Tri1Flags |= FMskFlat;
3229 Tri1Flags |= FMskSide;
3230 Tri1Flags &= ~FMskBack;
3239 Standard_Real dx = dy12 * dz23 - dz12 * dy23;
3240 Standard_Real dy = dz12 * dx23 - dx12 * dz23;
3241 Standard_Real dz = dx12 * dy23 - dy12 * dx23;
3242 Standard_Real d = sqrt(dx * dx + dy * dy + dz * dz);
3246 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3247 cout << " triangle " << iTri << endl;
3250 Tri1Flags |= FMskFlat;
3251 Tri1Flags |= FMskSide;
3252 Tri1Flags &= ~FMskBack;
3256 if (myProj.Perspective()) {
3260 o = ( dz * myProj.Focus()
3268 Tri1Flags |= FMskOrBack;
3272 Tri1Flags &= ~FMskOrBack;
3274 Tri1Flags |= FMskSide;
3275 Tri1Flags &= ~FMskBack;
3282 if ((!(Tri1Flags & FMskBack) && (Tri1Flags & FMskOrBack)) ||
3283 ( (Tri1Flags & FMskBack) && !(Tri1Flags & FMskOrBack)))
3284 Tri1Flags |= FMskFrBack;
3286 Tri1Flags &= ~FMskFrBack;
3289 //=======================================================================
3290 //function : Triangles
3292 //=======================================================================
3295 HLRBRep_PolyAlgo::Triangles(const Standard_Integer ip1,
3296 const Standard_Integer ip2,
3297 const Standard_Address Nod1Indices,
3298 Standard_Address& PISeg,
3299 Standard_Integer& iTri1,
3300 Standard_Integer& iTri2) const
3302 Standard_Address Seg1Indices;
3303 Standard_Integer iiii = Nod1NdSg;
3307 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3308 if (Seg1LstSg1 == ip1) {
3309 if (Seg1LstSg2 == ip2) {
3312 return Standard_True;
3314 else iiii = Seg1NxtSg1;
3317 if (Seg1LstSg1 == ip2) {
3320 return Standard_True;
3322 else iiii = Seg1NxtSg2;
3329 cout << "HLRBRep_PolyAlgo::Triangles : error";
3330 cout << " between " << ip1 << " and " << ip2 << endl;
3333 return Standard_False;
3336 //=======================================================================
3337 //function : NewNode
3339 //=======================================================================
3343 NewNode (const Standard_Address Nod1RValues,
3344 const Standard_Address Nod2RValues,
3345 Standard_Real& coef1,
3346 Standard_Boolean& moveP1) const
3348 Standard_Real TolAng = myTolAngular * 0.5;
3349 if ((Nod1Scal >= TolAng && Nod2Scal <= -TolAng) ||
3350 (Nod2Scal >= TolAng && Nod1Scal <= -TolAng)) {
3351 coef1 = Nod1Scal / ( Nod2Scal - Nod1Scal );
3352 if (coef1 < 0) coef1 = - coef1;
3353 moveP1 = coef1 < 0.5;
3354 return Standard_True;
3356 return Standard_False;
3359 //=======================================================================
3362 //=======================================================================
3365 HLRBRep_PolyAlgo::UVNode (const Standard_Address Nod1RValues,
3366 const Standard_Address Nod2RValues,
3367 const Standard_Real coef1,
3369 Standard_Real& V3) const
3371 Standard_Real coef2 = 1 - coef1;
3372 U3 = Nod1PntU * coef2 + Nod2PntU * coef1;
3373 V3 = Nod1PntV * coef2 + Nod2PntV * coef1;
3376 //=======================================================================
3377 //function : CheckDegeneratedSegment
3379 //=======================================================================
3383 CheckDegeneratedSegment(const Standard_Address Nod1Indices,
3384 const Standard_Address Nod1RValues,
3385 const Standard_Address Nod2Indices,
3386 const Standard_Address Nod2RValues) const
3388 Nod1Flag |= NMskFuck;
3389 Nod2Flag |= NMskFuck;
3390 if ((Nod1Scal >= myTolAngular && Nod2Scal <= -myTolAngular) ||
3391 (Nod2Scal >= myTolAngular && Nod1Scal <= -myTolAngular)) {
3393 Nod1Flag |= NMskOutL;
3395 Nod2Flag |= NMskOutL;
3399 //=======================================================================
3400 //function : UpdateOutLines
3402 //=======================================================================
3405 HLRBRep_PolyAlgo::UpdateOutLines (HLRAlgo_ListOfBPoint& List,
3406 TColStd_Array1OfTransient& PID)
3409 Standard_Integer nbFace = myFMap.Extent();
3410 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
3411 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
3413 Handle(HLRAlgo_PolyInternalData)* pid =
3414 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3416 for (f = 1; f <= nbFace; f++) {
3417 if (!(*pid).IsNull()) {
3418 if ((*pid)->IntOutL()) {
3419 Standard_Address TData = &((*pid)->TData());
3420 Standard_Address PISeg = &((*pid)->PISeg());
3421 Standard_Address PINod = &((*pid)->PINod());
3422 Standard_Integer i,j,it1,it2,tn1,tn2,tn3,pd,pf;
3423 Standard_Address Seg2Indices,Tri1Indices,Tri2Indices;
3424 Standard_Boolean outl;
3425 Standard_Integer nbS = (*pid)->NbPISeg();
3426 HLRAlgo_PolyInternalSegment* psg =
3427 &(((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(1));
3429 for (i = 1; i <= nbS; i++) {
3430 Seg2Indices = psg->Indices();
3433 if (it1 != 0 && it2 != 0 && it1 != it2) { // debile but sure !
3434 Tri1Indices = ((HLRAlgo_Array1OfTData*)TData)->
3435 ChangeValue(it1).Indices();
3436 Tri2Indices = ((HLRAlgo_Array1OfTData*)TData)->
3437 ChangeValue(it2).Indices();
3438 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3439 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3440 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3441 outl = Standard_False;
3442 else if ( Tri1Flags & FMskSide)
3443 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3445 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3453 if (!(Tri1Flags & FMskSide) && (Tri1Flags & FMskOrBack)) {
3458 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3459 Tri1Flags |= EMskOutLin1;
3460 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3461 Tri1Flags |= EMskOutLin2;
3462 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3463 Tri1Flags |= EMskOutLin3;
3466 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3467 cout << " : segment not found" << endl;
3473 if (!(Tri2Flags & FMskSide) && (Tri2Flags & FMskOrBack)) {
3478 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3479 Tri2Flags |= EMskOutLin1;
3480 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3481 Tri2Flags |= EMskOutLin2;
3482 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3483 Tri2Flags |= EMskOutLin3;
3486 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3487 cout << " : segment not found" << endl;
3490 Standard_Address Nod1RValues =
3491 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pd)->RValues();
3492 Standard_Address Nod2RValues =
3493 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pf)->RValues();
3494 XTI1 = X1 = Nod1PntX;
3495 YTI1 = Y1 = Nod1PntY;
3496 ZTI1 = Z1 = Nod1PntZ;
3497 XTI2 = X2 = Nod2PntX;
3498 YTI2 = Y2 = Nod2PntY;
3499 ZTI2 = Z2 = Nod2PntZ;
3500 TIMultiply(XTI1,YTI1,ZTI1);
3501 TIMultiply(XTI2,YTI2,ZTI2);
3502 List.Append(HLRAlgo_BiPoint(XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
3503 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
3504 f,f,pd,pf,f,pd,pf,12));
3515 //=======================================================================
3516 //function : UpdateEdgesBiPoints
3518 //=======================================================================
3520 void HLRBRep_PolyAlgo::
3521 UpdateEdgesBiPoints (HLRAlgo_ListOfBPoint& List,
3522 const TColStd_Array1OfTransient& PID,
3523 const Standard_Boolean closed)
3525 Standard_Integer itri1,itri2,tbid;
3526 Standard_Boolean OK;
3527 HLRAlgo_ListIteratorOfListOfBPoint it;
3529 for (it.Initialize(List); it.More(); it.Next()) {
3530 HLRAlgo_BiPoint& BP = it.Value();
3531 // Standard_Integer i[5];
3532 Standard_Address IndexPtr = BP.Indices();
3533 if (F1Index != 0 && F2Index != 0) {
3534 const Handle(HLRAlgo_PolyInternalData)& pid1 =
3535 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
3536 const Handle(HLRAlgo_PolyInternalData)& pid2 =
3537 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
3538 Standard_Address PISeg1 = &pid1->PISeg();
3539 Standard_Address PISeg2 = &pid2->PISeg();
3540 Standard_Address Nod11Indices =
3541 pid1->PINod().ChangeValue(F1Pt1Index)->Indices();
3542 Standard_Address Nod21Indices =
3543 pid2->PINod().ChangeValue(F2Pt1Index)->Indices();
3544 OK = Triangles(F1Pt1Index,F1Pt2Index,Nod11Indices,PISeg1,itri1,tbid);
3545 OK = Triangles(F2Pt1Index,F2Pt2Index,Nod21Indices,PISeg2,itri2,tbid);
3547 if (itri1 != 0 && itri2 != 0) {
3548 if (F1Index != F2Index || itri1 != itri2) {
3549 Standard_Address TData1 = &pid1->TData();
3550 Standard_Address TData2 = &pid2->TData();
3551 Standard_Address Tri1Indices =
3552 ((HLRAlgo_Array1OfTData*)TData1)->ChangeValue(itri1).Indices();
3553 Standard_Address Tri2Indices =
3554 ((HLRAlgo_Array1OfTData*)TData2)->ChangeValue(itri2).Indices();
3556 if (((Tri1Flags & FMskBack) && (Tri2Flags & FMskBack)) ||
3557 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskSide)) ||
3558 ((Tri1Flags & FMskBack) && (Tri2Flags & FMskSide)) ||
3559 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskBack)))
3560 BP.Hidden(Standard_True);
3562 Standard_Boolean outl;
3563 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3564 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3565 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3566 outl = Standard_False;
3567 else if ( (Tri1Flags & FMskSide))
3568 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3570 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3576 cout << "HLRBRep_PolyAlgo::UpdateEdgesBiPoints : error ";
3577 cout << " between " << F1Index << setw(6);
3578 cout << " and " << F2Index << endl;
3585 //=======================================================================
3586 //function : UpdatePolyData
3588 //=======================================================================
3591 HLRBRep_PolyAlgo::UpdatePolyData (TColStd_Array1OfTransient& PD,
3592 TColStd_Array1OfTransient& PID,
3593 const Standard_Boolean closed)
3595 Standard_Integer f,i;//,n[3];
3596 Handle(TColgp_HArray1OfXYZ) HNodes;
3597 Handle(HLRAlgo_HArray1OfTData) HTData;
3598 Handle(HLRAlgo_HArray1OfPHDat) HPHDat;
3599 Standard_Integer nbFace = myFMap.Extent();
3600 Handle(HLRAlgo_PolyInternalData)* pid =
3601 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3602 Handle(HLRAlgo_PolyData)* pd =
3603 (Handle(HLRAlgo_PolyData)*)&(PD.ChangeValue(1));
3605 for (f = 1; f <= nbFace; f++) {
3606 if (!(*pid).IsNull()) {
3607 Standard_Integer nbN = (*pid)->NbPINod();
3608 Standard_Integer nbT = (*pid)->NbTData();
3609 HNodes = new TColgp_HArray1OfXYZ (1,nbN);
3610 HTData = new HLRAlgo_HArray1OfTData(1,nbT);
3611 TColgp_Array1OfXYZ& Nodes = HNodes->ChangeArray1();
3612 HLRAlgo_Array1OfTData& Trian = HTData->ChangeArray1();
3613 Standard_Address TData = &(*pid)->TData();
3614 Standard_Address PINod = &(*pid)->PINod();
3615 Standard_Integer nbHide = 0;
3616 Handle(HLRAlgo_PolyInternalNode)* ON =
3617 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
3618 gp_XYZ * NN = &(Nodes.ChangeValue(1));
3620 for (i = 1; i <= nbN; i++) {
3621 const Standard_Address Nod1RValues = (*ON)->RValues();
3622 NN->SetCoord(Nod1PntX,Nod1PntY,Nod1PntZ);
3627 HLRAlgo_TriangleData* OT =
3628 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
3629 HLRAlgo_TriangleData* NT = &(Trian.ChangeValue(1));
3630 Standard_Address Tri1Indices,Tri2Indices;
3632 for (i = 1; i <= nbT; i++) {
3633 Tri1Indices = OT->Indices();
3634 Tri2Indices = NT->Indices();
3635 if (!(Tri1Flags & FMskSide)) {
3637 if ((Tri1Flags & FMskFrBack) && DoTrace) {
3638 cout << "HLRBRep_PolyAlgo::ReverseBackTriangle :";
3639 cout << " face " << f << setw(6);
3640 cout << " triangle " << i << endl;
3643 if (Tri1Flags & FMskOrBack) {
3644 Standard_Integer j = Tri1Node1;
3645 Tri1Node1 = Tri1Node3;
3647 Tri1Flags |= FMskBack;
3650 Tri1Flags &= ~FMskBack;
3651 //Tri1Flags |= FMskBack;//OCC349
3653 Tri2Node1 = Tri1Node1;
3654 Tri2Node2 = Tri1Node2;
3655 Tri2Node3 = Tri1Node3;
3656 Tri2Flags = Tri1Flags;
3657 if (!(Tri2Flags & FMskSide) &&
3658 (!(Tri2Flags & FMskBack) || !closed)) {
3659 Tri2Flags |= FMskHiding;
3663 Tri2Flags &= ~FMskHiding;
3667 if (nbHide > 0) HPHDat = new HLRAlgo_HArray1OfPHDat(1,nbHide);
3668 else HPHDat.Nullify();
3669 (*pd)->HNodes(HNodes);
3670 (*pd)->HTData(HTData);
3671 (*pd)->HPHDat(HPHDat);
3672 (*pd)->FaceIndex(f);
3679 //=======================================================================
3680 //function : TMultiply
3682 //=======================================================================
3685 HLRBRep_PolyAlgo::TMultiply (Standard_Real& X,
3688 const Standard_Boolean VPO) const
3690 Standard_Real Xt = TMat[0][0]*X + TMat[0][1]*Y + TMat[0][2]*Z + (VPO ? 0 : TLoc[0]);//OCC349
3691 Standard_Real Yt = TMat[1][0]*X + TMat[1][1]*Y + TMat[1][2]*Z + (VPO ? 0 : TLoc[1]);//OCC349
3692 Z = TMat[2][0]*X + TMat[2][1]*Y + TMat[2][2]*Z + (VPO ? 0 : TLoc[2]);//OCC349
3697 //=======================================================================
3698 //function : TTMultiply
3700 //=======================================================================
3703 HLRBRep_PolyAlgo::TTMultiply (Standard_Real& X,
3706 const Standard_Boolean VPO) const
3708 Standard_Real Xt = TTMa[0][0]*X + TTMa[0][1]*Y + TTMa[0][2]*Z + (VPO ? 0 : TTLo[0]);//OCC349
3709 Standard_Real Yt = TTMa[1][0]*X + TTMa[1][1]*Y + TTMa[1][2]*Z + (VPO ? 0 : TTLo[1]);//OCC349
3710 Z = TTMa[2][0]*X + TTMa[2][1]*Y + TTMa[2][2]*Z + (VPO ? 0 : TTLo[2]);//OCC349
3715 //=======================================================================
3716 //function : TIMultiply
3718 //=======================================================================
3721 HLRBRep_PolyAlgo::TIMultiply (Standard_Real& X,
3724 const Standard_Boolean VPO) const
3726 Standard_Real Xt = TIMa[0][0]*X + TIMa[0][1]*Y + TIMa[0][2]*Z + (VPO ? 0 : TILo[0]);//OCC349
3727 Standard_Real Yt = TIMa[1][0]*X + TIMa[1][1]*Y + TIMa[1][2]*Z + (VPO ? 0 : TILo[1]);//OCC349
3728 Z = TIMa[2][0]*X + TIMa[2][1]*Y + TIMa[2][2]*Z + (VPO ? 0 : TILo[2]);//OCC349
3733 //=======================================================================
3736 //=======================================================================
3738 void HLRBRep_PolyAlgo::Hide (Standard_Address& Coordinates,
3739 HLRAlgo_EdgeStatus& status,
3741 Standard_Boolean& reg1,
3742 Standard_Boolean& regn,
3743 Standard_Boolean& outl,
3744 Standard_Boolean& intl)
3746 Standard_Integer index;
3747 myAlgo->Hide(Coordinates,status,index,reg1,regn,outl,intl);
3748 if (intl) S = myFMap(index);
3749 else S = myEMap(index);
3752 //=======================================================================
3755 //=======================================================================
3757 void HLRBRep_PolyAlgo::Show (Standard_Address& Coordinates,
3759 Standard_Boolean& reg1,
3760 Standard_Boolean& regn,
3761 Standard_Boolean& outl,
3762 Standard_Boolean& intl)
3764 Standard_Integer index;
3765 myAlgo->Show(Coordinates,index,reg1,regn,outl,intl);
3766 if (intl) S = myFMap(index);
3767 else S = myEMap(index);
3770 //=======================================================================
3771 //function : OutLinedShape
3773 //=======================================================================
3776 HLRBRep_PolyAlgo::OutLinedShape (const TopoDS_Shape& S) const
3778 TopoDS_Shape Result;
3782 B.MakeCompound(TopoDS::Compound(Result));
3785 TopTools_MapOfShape Map;
3787 for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next())
3788 Map.Add(ex.Current());
3789 for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next())
3790 Map.Add(ex.Current());
3792 Standard_Integer nbFace = myFMap.Extent();
3794 TopTools_Array1OfShape NewF(1,nbFace);
3795 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
3796 Standard_Integer nbShell = Shell.Upper();
3797 HLRAlgo_ListIteratorOfListOfBPoint it;
3799 for (Standard_Integer iShell = 1; iShell <= nbShell; iShell++) {
3800 HLRAlgo_ListOfBPoint& List =
3801 (*(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell)))->Edges();
3803 for (it.Initialize(List); it.More(); it.Next()) {
3804 HLRAlgo_BiPoint& BP = it.Value();
3806 Standard_Address IndexPtr = BP.Indices();
3807 if (Map.Contains(myFMap(ShapeIndex))) {
3808 Standard_Address Coordinates = BP.Coordinates();
3809 B.Add(Result,BRepLib_MakeEdge
3810 (gp_Pnt(PntXTI1,PntYTI1,PntZTI1),
3811 gp_Pnt(PntXTI2,PntYTI2,PntZTI2)));