1 // Created on: 1995-05-05
2 // Created by: Christophe MARION
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by cma, Tue Apr 1 11:39:48 1997
18 // Modified by cma, Tue Apr 1 11:40:30 1997
20 #include <Standard_Stream.hxx>
21 #include <HLRBRep_PolyAlgo.ixx>
22 #include <Standard_ErrorHandler.hxx>
23 #include <TColStd_HArray1OfTransient.hxx>
24 #include <TColStd_HArray1OfInteger.hxx>
26 #include <CSLib_DerivativeStatus.hxx>
27 #include <CSLib_NormalStatus.hxx>
28 #include <Geom_Surface.hxx>
29 #include <Geom_RectangularTrimmedSurface.hxx>
30 #include <HLRAlgo_ListIteratorOfListOfBPoint.hxx>
31 #include <HLRAlgo_PolyShellData.hxx>
32 #include <HLRAlgo_PolyData.hxx>
33 #include <HLRAlgo_BiPoint.hxx>
36 #include <TopExp_Explorer.hxx>
37 #include <TopTools_Array1OfShape.hxx>
38 #include <TopTools_ListIteratorOfListOfShape.hxx>
39 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
40 #include <Poly_Triangulation.hxx>
41 #include <Poly_Polygon3D.hxx>
42 #include <Poly_PolygonOnTriangulation.hxx>
43 #include <BRep_Builder.hxx>
44 #include <BRep_Tool.hxx>
45 #include <BRepLib_MakeEdge.hxx>
46 #include <Precision.hxx>
49 #define EMskOutLin1 ((Standard_Boolean) 1)
50 #define EMskOutLin2 ((Standard_Boolean) 2)
51 #define EMskOutLin3 ((Standard_Boolean) 4)
52 #define EMskGrALin1 ((Standard_Boolean) 8)
53 #define EMskGrALin2 ((Standard_Boolean) 16)
54 #define EMskGrALin3 ((Standard_Boolean) 32)
55 #define FMskBack ((Standard_Boolean) 64)
56 #define FMskSide ((Standard_Boolean) 128)
57 #define FMskHiding ((Standard_Boolean) 256)
58 #define FMskFlat ((Standard_Boolean) 512)
59 #define FMskOnOutL ((Standard_Boolean)1024)
60 #define FMskOrBack ((Standard_Boolean)2048)
61 #define FMskFrBack ((Standard_Boolean)4096)
63 #define NMskVert ((Standard_Boolean) 1)
64 #define NMskOutL ((Standard_Boolean) 2)
65 #define NMskNorm ((Standard_Boolean) 4)
66 #define NMskFuck ((Standard_Boolean) 8)
67 #define NMskEdge ((Standard_Boolean)16)
68 #define NMskMove ((Standard_Boolean)32)
70 #define PntXTI1 ((Standard_Real*)Coordinates)[ 0]
71 #define PntYTI1 ((Standard_Real*)Coordinates)[ 1]
72 #define PntZTI1 ((Standard_Real*)Coordinates)[ 2]
73 #define PntXTI2 ((Standard_Real*)Coordinates)[ 3]
74 #define PntYTI2 ((Standard_Real*)Coordinates)[ 4]
75 #define PntZTI2 ((Standard_Real*)Coordinates)[ 5]
76 #define PntX1 ((Standard_Real*)Coordinates)[ 6]
77 #define PntY1 ((Standard_Real*)Coordinates)[ 7]
78 #define PntZ1 ((Standard_Real*)Coordinates)[ 8]
79 #define PntX2 ((Standard_Real*)Coordinates)[ 9]
80 #define PntY2 ((Standard_Real*)Coordinates)[10]
81 #define PntZ2 ((Standard_Real*)Coordinates)[11]
83 #define Pn2XTI1 ((Standard_Real*)Coordinate2)[ 0]
84 #define Pn2YTI1 ((Standard_Real*)Coordinate2)[ 1]
85 #define Pn2ZTI1 ((Standard_Real*)Coordinate2)[ 2]
86 #define Pn2XTI2 ((Standard_Real*)Coordinate2)[ 3]
87 #define Pn2YTI2 ((Standard_Real*)Coordinate2)[ 4]
88 #define Pn2ZTI2 ((Standard_Real*)Coordinate2)[ 5]
89 #define Pn2X1 ((Standard_Real*)Coordinate2)[ 6]
90 #define Pn2Y1 ((Standard_Real*)Coordinate2)[ 7]
91 #define Pn2Z1 ((Standard_Real*)Coordinate2)[ 8]
92 #define Pn2X2 ((Standard_Real*)Coordinate2)[ 9]
93 #define Pn2Y2 ((Standard_Real*)Coordinate2)[10]
94 #define Pn2Z2 ((Standard_Real*)Coordinate2)[11]
96 #define Tri1Node1 ((Standard_Integer*)Tri1Indices)[0]
97 #define Tri1Node2 ((Standard_Integer*)Tri1Indices)[1]
98 #define Tri1Node3 ((Standard_Integer*)Tri1Indices)[2]
99 #define Tri1Flags ((Standard_Boolean*)Tri1Indices)[3]
101 #define Tri2Node1 ((Standard_Integer*)Tri2Indices)[0]
102 #define Tri2Node2 ((Standard_Integer*)Tri2Indices)[1]
103 #define Tri2Node3 ((Standard_Integer*)Tri2Indices)[2]
104 #define Tri2Flags ((Standard_Boolean*)Tri2Indices)[3]
106 #define Tri3Node1 ((Standard_Integer*)Tri3Indices)[0]
107 #define Tri3Node2 ((Standard_Integer*)Tri3Indices)[1]
108 #define Tri3Node3 ((Standard_Integer*)Tri3Indices)[2]
109 #define Tri3Flags ((Standard_Boolean*)Tri3Indices)[3]
111 #define Seg1LstSg1 ((Standard_Integer*)Seg1Indices)[0]
112 #define Seg1LstSg2 ((Standard_Integer*)Seg1Indices)[1]
113 #define Seg1NxtSg1 ((Standard_Integer*)Seg1Indices)[2]
114 #define Seg1NxtSg2 ((Standard_Integer*)Seg1Indices)[3]
115 #define Seg1Conex1 ((Standard_Integer*)Seg1Indices)[4]
116 #define Seg1Conex2 ((Standard_Integer*)Seg1Indices)[5]
118 #define Seg2LstSg1 ((Standard_Integer*)Seg2Indices)[0]
119 #define Seg2LstSg2 ((Standard_Integer*)Seg2Indices)[1]
120 #define Seg2NxtSg1 ((Standard_Integer*)Seg2Indices)[2]
121 #define Seg2NxtSg2 ((Standard_Integer*)Seg2Indices)[3]
122 #define Seg2Conex1 ((Standard_Integer*)Seg2Indices)[4]
123 #define Seg2Conex2 ((Standard_Integer*)Seg2Indices)[5]
125 #define Nod1NdSg ((Standard_Integer*)Nod1Indices)[0]
126 #define Nod1Flag ((Standard_Boolean*)Nod1Indices)[1]
127 #define Nod1Edg1 ((Standard_Boolean*)Nod1Indices)[2]
128 #define Nod1Edg2 ((Standard_Boolean*)Nod1Indices)[3]
130 #define Nod1PntX ((Standard_Real*)Nod1RValues)[ 0]
131 #define Nod1PntY ((Standard_Real*)Nod1RValues)[ 1]
132 #define Nod1PntZ ((Standard_Real*)Nod1RValues)[ 2]
133 #define Nod1PntU ((Standard_Real*)Nod1RValues)[ 3]
134 #define Nod1PntV ((Standard_Real*)Nod1RValues)[ 4]
135 #define Nod1NrmX ((Standard_Real*)Nod1RValues)[ 5]
136 #define Nod1NrmY ((Standard_Real*)Nod1RValues)[ 6]
137 #define Nod1NrmZ ((Standard_Real*)Nod1RValues)[ 7]
138 #define Nod1PCu1 ((Standard_Real*)Nod1RValues)[ 8]
139 #define Nod1PCu2 ((Standard_Real*)Nod1RValues)[ 9]
140 #define Nod1Scal ((Standard_Real*)Nod1RValues)[10]
142 #define NodANdSg ((Standard_Integer*)NodAIndices)[0]
143 #define NodAFlag ((Standard_Boolean*)NodAIndices)[1]
144 #define NodAEdg1 ((Standard_Boolean*)NodAIndices)[2]
145 #define NodAEdg2 ((Standard_Boolean*)NodAIndices)[3]
147 #define NodAPntX ((Standard_Real*)NodARValues)[ 0]
148 #define NodAPntY ((Standard_Real*)NodARValues)[ 1]
149 #define NodAPntZ ((Standard_Real*)NodARValues)[ 2]
150 #define NodAPntU ((Standard_Real*)NodARValues)[ 3]
151 #define NodAPntV ((Standard_Real*)NodARValues)[ 4]
152 #define NodANrmX ((Standard_Real*)NodARValues)[ 5]
153 #define NodANrmY ((Standard_Real*)NodARValues)[ 6]
154 #define NodANrmZ ((Standard_Real*)NodARValues)[ 7]
155 #define NodAPCu1 ((Standard_Real*)NodARValues)[ 8]
156 #define NodAPCu2 ((Standard_Real*)NodARValues)[ 9]
157 #define NodAScal ((Standard_Real*)NodARValues)[10]
159 #define NodBNdSg ((Standard_Integer*)NodBIndices)[0]
160 #define NodBFlag ((Standard_Boolean*)NodBIndices)[1]
161 #define NodBEdg1 ((Standard_Boolean*)NodBIndices)[2]
162 #define NodBEdg2 ((Standard_Boolean*)NodBIndices)[3]
164 #define NodBPntX ((Standard_Real*)NodBRValues)[ 0]
165 #define NodBPntY ((Standard_Real*)NodBRValues)[ 1]
166 #define NodBPntZ ((Standard_Real*)NodBRValues)[ 2]
167 #define NodBPntU ((Standard_Real*)NodBRValues)[ 3]
168 #define NodBPntV ((Standard_Real*)NodBRValues)[ 4]
169 #define NodBNrmX ((Standard_Real*)NodBRValues)[ 5]
170 #define NodBNrmY ((Standard_Real*)NodBRValues)[ 6]
171 #define NodBNrmZ ((Standard_Real*)NodBRValues)[ 7]
172 #define NodBPCu1 ((Standard_Real*)NodBRValues)[ 8]
173 #define NodBPCu2 ((Standard_Real*)NodBRValues)[ 9]
174 #define NodBScal ((Standard_Real*)NodBRValues)[10]
176 #define Nod2NdSg ((Standard_Integer*)Nod2Indices)[0]
177 #define Nod2Flag ((Standard_Boolean*)Nod2Indices)[1]
178 #define Nod2Edg1 ((Standard_Boolean*)Nod2Indices)[2]
179 #define Nod2Edg2 ((Standard_Boolean*)Nod2Indices)[3]
181 #define Nod2PntX ((Standard_Real*)Nod2RValues)[ 0]
182 #define Nod2PntY ((Standard_Real*)Nod2RValues)[ 1]
183 #define Nod2PntZ ((Standard_Real*)Nod2RValues)[ 2]
184 #define Nod2PntU ((Standard_Real*)Nod2RValues)[ 3]
185 #define Nod2PntV ((Standard_Real*)Nod2RValues)[ 4]
186 #define Nod2NrmX ((Standard_Real*)Nod2RValues)[ 5]
187 #define Nod2NrmY ((Standard_Real*)Nod2RValues)[ 6]
188 #define Nod2NrmZ ((Standard_Real*)Nod2RValues)[ 7]
189 #define Nod2PCu1 ((Standard_Real*)Nod2RValues)[ 8]
190 #define Nod2PCu2 ((Standard_Real*)Nod2RValues)[ 9]
191 #define Nod2Scal ((Standard_Real*)Nod2RValues)[10]
193 #define Nod3NdSg ((Standard_Integer*)Nod3Indices)[0]
194 #define Nod3Flag ((Standard_Boolean*)Nod3Indices)[1]
195 #define Nod3Edg1 ((Standard_Boolean*)Nod3Indices)[2]
196 #define Nod3Edg2 ((Standard_Boolean*)Nod3Indices)[3]
198 #define Nod3PntX ((Standard_Real*)Nod3RValues)[ 0]
199 #define Nod3PntY ((Standard_Real*)Nod3RValues)[ 1]
200 #define Nod3PntZ ((Standard_Real*)Nod3RValues)[ 2]
201 #define Nod3PntU ((Standard_Real*)Nod3RValues)[ 3]
202 #define Nod3PntV ((Standard_Real*)Nod3RValues)[ 4]
203 #define Nod3NrmX ((Standard_Real*)Nod3RValues)[ 5]
204 #define Nod3NrmY ((Standard_Real*)Nod3RValues)[ 6]
205 #define Nod3NrmZ ((Standard_Real*)Nod3RValues)[ 7]
206 #define Nod3PCu1 ((Standard_Real*)Nod3RValues)[ 8]
207 #define Nod3PCu2 ((Standard_Real*)Nod3RValues)[ 9]
208 #define Nod3Scal ((Standard_Real*)Nod3RValues)[10]
210 #define Nod4NdSg ((Standard_Integer*)Nod4Indices)[0]
211 #define Nod4Flag ((Standard_Boolean*)Nod4Indices)[1]
212 #define Nod4Edg1 ((Standard_Boolean*)Nod4Indices)[2]
213 #define Nod4Edg2 ((Standard_Boolean*)Nod4Indices)[3]
215 #define Nod4PntX ((Standard_Real*)Nod4RValues)[ 0]
216 #define Nod4PntY ((Standard_Real*)Nod4RValues)[ 1]
217 #define Nod4PntZ ((Standard_Real*)Nod4RValues)[ 2]
218 #define Nod4PntU ((Standard_Real*)Nod4RValues)[ 3]
219 #define Nod4PntV ((Standard_Real*)Nod4RValues)[ 4]
220 #define Nod4NrmX ((Standard_Real*)Nod4RValues)[ 5]
221 #define Nod4NrmY ((Standard_Real*)Nod4RValues)[ 6]
222 #define Nod4NrmZ ((Standard_Real*)Nod4RValues)[ 7]
223 #define Nod4PCu1 ((Standard_Real*)Nod4RValues)[ 8]
224 #define Nod4PCu2 ((Standard_Real*)Nod4RValues)[ 9]
225 #define Nod4Scal ((Standard_Real*)Nod4RValues)[10]
227 #define Nod11NdSg ((Standard_Integer*)Nod11Indices)[0]
228 #define Nod11Flag ((Standard_Boolean*)Nod11Indices)[1]
229 #define Nod11Edg1 ((Standard_Boolean*)Nod11Indices)[2]
230 #define Nod11Edg2 ((Standard_Boolean*)Nod11Indices)[3]
232 #define Nod11PntX ((Standard_Real*)Nod11RValues)[ 0]
233 #define Nod11PntY ((Standard_Real*)Nod11RValues)[ 1]
234 #define Nod11PntZ ((Standard_Real*)Nod11RValues)[ 2]
235 #define Nod11PntU ((Standard_Real*)Nod11RValues)[ 3]
236 #define Nod11PntV ((Standard_Real*)Nod11RValues)[ 4]
237 #define Nod11NrmX ((Standard_Real*)Nod11RValues)[ 5]
238 #define Nod11NrmY ((Standard_Real*)Nod11RValues)[ 6]
239 #define Nod11NrmZ ((Standard_Real*)Nod11RValues)[ 7]
240 #define Nod11PCu1 ((Standard_Real*)Nod11RValues)[ 8]
241 #define Nod11PCu2 ((Standard_Real*)Nod11RValues)[ 9]
242 #define Nod11Scal ((Standard_Real*)Nod11RValues)[10]
244 #define Nod1ANdSg ((Standard_Integer*)Nod1AIndices)[0]
245 #define Nod1AFlag ((Standard_Boolean*)Nod1AIndices)[1]
246 #define Nod1AEdg1 ((Standard_Boolean*)Nod1AIndices)[2]
247 #define Nod1AEdg2 ((Standard_Boolean*)Nod1AIndices)[3]
249 #define Nod1APntX ((Standard_Real*)Nod1ARValues)[ 0]
250 #define Nod1APntY ((Standard_Real*)Nod1ARValues)[ 1]
251 #define Nod1APntZ ((Standard_Real*)Nod1ARValues)[ 2]
252 #define Nod1APntU ((Standard_Real*)Nod1ARValues)[ 3]
253 #define Nod1APntV ((Standard_Real*)Nod1ARValues)[ 4]
254 #define Nod1ANrmX ((Standard_Real*)Nod1ARValues)[ 5]
255 #define Nod1ANrmY ((Standard_Real*)Nod1ARValues)[ 6]
256 #define Nod1ANrmZ ((Standard_Real*)Nod1ARValues)[ 7]
257 #define Nod1APCu1 ((Standard_Real*)Nod1ARValues)[ 8]
258 #define Nod1APCu2 ((Standard_Real*)Nod1ARValues)[ 9]
259 #define Nod1AScal ((Standard_Real*)Nod1ARValues)[10]
261 #define Nod1BNdSg ((Standard_Integer*)Nod1BIndices)[0]
262 #define Nod1BFlag ((Standard_Boolean*)Nod1BIndices)[1]
263 #define Nod1BEdg1 ((Standard_Boolean*)Nod1BIndices)[2]
264 #define Nod1BEdg2 ((Standard_Boolean*)Nod1BIndices)[3]
266 #define Nod1BPntX ((Standard_Real*)Nod1BRValues)[ 0]
267 #define Nod1BPntY ((Standard_Real*)Nod1BRValues)[ 1]
268 #define Nod1BPntZ ((Standard_Real*)Nod1BRValues)[ 2]
269 #define Nod1BPntU ((Standard_Real*)Nod1BRValues)[ 3]
270 #define Nod1BPntV ((Standard_Real*)Nod1BRValues)[ 4]
271 #define Nod1BNrmX ((Standard_Real*)Nod1BRValues)[ 5]
272 #define Nod1BNrmY ((Standard_Real*)Nod1BRValues)[ 6]
273 #define Nod1BNrmZ ((Standard_Real*)Nod1BRValues)[ 7]
274 #define Nod1BPCu1 ((Standard_Real*)Nod1BRValues)[ 8]
275 #define Nod1BPCu2 ((Standard_Real*)Nod1BRValues)[ 9]
276 #define Nod1BScal ((Standard_Real*)Nod1BRValues)[10]
278 #define Nod12NdSg ((Standard_Integer*)Nod12Indices)[0]
279 #define Nod12Flag ((Standard_Boolean*)Nod12Indices)[1]
280 #define Nod12Edg1 ((Standard_Boolean*)Nod12Indices)[2]
281 #define Nod12Edg2 ((Standard_Boolean*)Nod12Indices)[3]
283 #define Nod12PntX ((Standard_Real*)Nod12RValues)[ 0]
284 #define Nod12PntY ((Standard_Real*)Nod12RValues)[ 1]
285 #define Nod12PntZ ((Standard_Real*)Nod12RValues)[ 2]
286 #define Nod12PntU ((Standard_Real*)Nod12RValues)[ 3]
287 #define Nod12PntV ((Standard_Real*)Nod12RValues)[ 4]
288 #define Nod12NrmX ((Standard_Real*)Nod12RValues)[ 5]
289 #define Nod12NrmY ((Standard_Real*)Nod12RValues)[ 6]
290 #define Nod12NrmZ ((Standard_Real*)Nod12RValues)[ 7]
291 #define Nod12PCu1 ((Standard_Real*)Nod12RValues)[ 8]
292 #define Nod12PCu2 ((Standard_Real*)Nod12RValues)[ 9]
293 #define Nod12Scal ((Standard_Real*)Nod12RValues)[10]
295 #define Nod13NdSg ((Standard_Integer*)Nod13Indices)[0]
296 #define Nod13Flag ((Standard_Boolean*)Nod13Indices)[1]
297 #define Nod13Edg1 ((Standard_Boolean*)Nod13Indices)[2]
298 #define Nod13Edg2 ((Standard_Boolean*)Nod13Indices)[3]
300 #define Nod13PntX ((Standard_Real*)Nod13RValues)[ 0]
301 #define Nod13PntY ((Standard_Real*)Nod13RValues)[ 1]
302 #define Nod13PntZ ((Standard_Real*)Nod13RValues)[ 2]
303 #define Nod13PntU ((Standard_Real*)Nod13RValues)[ 3]
304 #define Nod13PntV ((Standard_Real*)Nod13RValues)[ 4]
305 #define Nod13NrmX ((Standard_Real*)Nod13RValues)[ 5]
306 #define Nod13NrmY ((Standard_Real*)Nod13RValues)[ 6]
307 #define Nod13NrmZ ((Standard_Real*)Nod13RValues)[ 7]
308 #define Nod13PCu1 ((Standard_Real*)Nod13RValues)[ 8]
309 #define Nod13PCu2 ((Standard_Real*)Nod13RValues)[ 9]
310 #define Nod13Scal ((Standard_Real*)Nod13RValues)[10]
312 #define Nod14NdSg ((Standard_Integer*)Nod14Indices)[0]
313 #define Nod14Flag ((Standard_Boolean*)Nod14Indices)[1]
314 #define Nod14Edg1 ((Standard_Boolean*)Nod14Indices)[2]
315 #define Nod14Edg2 ((Standard_Boolean*)Nod14Indices)[3]
317 #define Nod14PntX ((Standard_Real*)Nod14RValues)[ 0]
318 #define Nod14PntY ((Standard_Real*)Nod14RValues)[ 1]
319 #define Nod14PntZ ((Standard_Real*)Nod14RValues)[ 2]
320 #define Nod14PntU ((Standard_Real*)Nod14RValues)[ 3]
321 #define Nod14PntV ((Standard_Real*)Nod14RValues)[ 4]
322 #define Nod14NrmX ((Standard_Real*)Nod14RValues)[ 5]
323 #define Nod14NrmY ((Standard_Real*)Nod14RValues)[ 6]
324 #define Nod14NrmZ ((Standard_Real*)Nod14RValues)[ 7]
325 #define Nod14PCu1 ((Standard_Real*)Nod14RValues)[ 8]
326 #define Nod14PCu2 ((Standard_Real*)Nod14RValues)[ 9]
327 #define Nod14Scal ((Standard_Real*)Nod14RValues)[10]
329 #define Nod21NdSg ((Standard_Integer*)Nod21Indices)[0]
330 #define Nod21Flag ((Standard_Boolean*)Nod21Indices)[1]
331 #define Nod21Edg1 ((Standard_Boolean*)Nod21Indices)[2]
332 #define Nod21Edg2 ((Standard_Boolean*)Nod21Indices)[3]
334 #define Nod21PntX ((Standard_Real*)Nod21RValues)[ 0]
335 #define Nod21PntY ((Standard_Real*)Nod21RValues)[ 1]
336 #define Nod21PntZ ((Standard_Real*)Nod21RValues)[ 2]
337 #define Nod21PntU ((Standard_Real*)Nod21RValues)[ 3]
338 #define Nod21PntV ((Standard_Real*)Nod21RValues)[ 4]
339 #define Nod21NrmX ((Standard_Real*)Nod21RValues)[ 5]
340 #define Nod21NrmY ((Standard_Real*)Nod21RValues)[ 6]
341 #define Nod21NrmZ ((Standard_Real*)Nod21RValues)[ 7]
342 #define Nod21PCu1 ((Standard_Real*)Nod21RValues)[ 8]
343 #define Nod21PCu2 ((Standard_Real*)Nod21RValues)[ 9]
344 #define Nod21Scal ((Standard_Real*)Nod21RValues)[10]
346 #define Nod2ANdSg ((Standard_Integer*)Nod2AIndices)[0]
347 #define Nod2AFlag ((Standard_Boolean*)Nod2AIndices)[1]
348 #define Nod2AEdg1 ((Standard_Boolean*)Nod2AIndices)[2]
349 #define Nod2AEdg2 ((Standard_Boolean*)Nod2AIndices)[3]
351 #define Nod2APntX ((Standard_Real*)Nod2ARValues)[ 0]
352 #define Nod2APntY ((Standard_Real*)Nod2ARValues)[ 1]
353 #define Nod2APntZ ((Standard_Real*)Nod2ARValues)[ 2]
354 #define Nod2APntU ((Standard_Real*)Nod2ARValues)[ 3]
355 #define Nod2APntV ((Standard_Real*)Nod2ARValues)[ 4]
356 #define Nod2ANrmX ((Standard_Real*)Nod2ARValues)[ 5]
357 #define Nod2ANrmY ((Standard_Real*)Nod2ARValues)[ 6]
358 #define Nod2ANrmZ ((Standard_Real*)Nod2ARValues)[ 7]
359 #define Nod2APCu1 ((Standard_Real*)Nod2ARValues)[ 8]
360 #define Nod2APCu2 ((Standard_Real*)Nod2ARValues)[ 9]
361 #define Nod2AScal ((Standard_Real*)Nod2ARValues)[10]
363 #define Nod2BNdSg ((Standard_Integer*)Nod2BIndices)[0]
364 #define Nod2BFlag ((Standard_Boolean*)Nod2BIndices)[1]
365 #define Nod2BEdg1 ((Standard_Boolean*)Nod2BIndices)[2]
366 #define Nod2BEdg2 ((Standard_Boolean*)Nod2BIndices)[3]
368 #define Nod2BPntX ((Standard_Real*)Nod2BRValues)[ 0]
369 #define Nod2BPntY ((Standard_Real*)Nod2BRValues)[ 1]
370 #define Nod2BPntZ ((Standard_Real*)Nod2BRValues)[ 2]
371 #define Nod2BPntU ((Standard_Real*)Nod2BRValues)[ 3]
372 #define Nod2BPntV ((Standard_Real*)Nod2BRValues)[ 4]
373 #define Nod2BNrmX ((Standard_Real*)Nod2BRValues)[ 5]
374 #define Nod2BNrmY ((Standard_Real*)Nod2BRValues)[ 6]
375 #define Nod2BNrmZ ((Standard_Real*)Nod2BRValues)[ 7]
376 #define Nod2BPCu1 ((Standard_Real*)Nod2BRValues)[ 8]
377 #define Nod2BPCu2 ((Standard_Real*)Nod2BRValues)[ 9]
378 #define Nod2BScal ((Standard_Real*)Nod2BRValues)[10]
380 #define Nod22NdSg ((Standard_Integer*)Nod22Indices)[0]
381 #define Nod22Flag ((Standard_Boolean*)Nod22Indices)[1]
382 #define Nod22Edg1 ((Standard_Boolean*)Nod22Indices)[2]
383 #define Nod22Edg2 ((Standard_Boolean*)Nod22Indices)[3]
385 #define Nod22PntX ((Standard_Real*)Nod22RValues)[ 0]
386 #define Nod22PntY ((Standard_Real*)Nod22RValues)[ 1]
387 #define Nod22PntZ ((Standard_Real*)Nod22RValues)[ 2]
388 #define Nod22PntU ((Standard_Real*)Nod22RValues)[ 3]
389 #define Nod22PntV ((Standard_Real*)Nod22RValues)[ 4]
390 #define Nod22NrmX ((Standard_Real*)Nod22RValues)[ 5]
391 #define Nod22NrmY ((Standard_Real*)Nod22RValues)[ 6]
392 #define Nod22NrmZ ((Standard_Real*)Nod22RValues)[ 7]
393 #define Nod22PCu1 ((Standard_Real*)Nod22RValues)[ 8]
394 #define Nod22PCu2 ((Standard_Real*)Nod22RValues)[ 9]
395 #define Nod22Scal ((Standard_Real*)Nod22RValues)[10]
397 #define Nod23NdSg ((Standard_Integer*)Nod23Indices)[0]
398 #define Nod23Flag ((Standard_Boolean*)Nod23Indices)[1]
399 #define Nod23Edg1 ((Standard_Boolean*)Nod23Indices)[2]
400 #define Nod23Edg2 ((Standard_Boolean*)Nod23Indices)[3]
402 #define Nod23PntX ((Standard_Real*)Nod23RValues)[ 0]
403 #define Nod23PntY ((Standard_Real*)Nod23RValues)[ 1]
404 #define Nod23PntZ ((Standard_Real*)Nod23RValues)[ 2]
405 #define Nod23PntU ((Standard_Real*)Nod23RValues)[ 3]
406 #define Nod23PntV ((Standard_Real*)Nod23RValues)[ 4]
407 #define Nod23NrmX ((Standard_Real*)Nod23RValues)[ 5]
408 #define Nod23NrmY ((Standard_Real*)Nod23RValues)[ 6]
409 #define Nod23NrmZ ((Standard_Real*)Nod23RValues)[ 7]
410 #define Nod23PCu1 ((Standard_Real*)Nod23RValues)[ 8]
411 #define Nod23PCu2 ((Standard_Real*)Nod23RValues)[ 9]
412 #define Nod23Scal ((Standard_Real*)Nod23RValues)[10]
414 #define Nod24NdSg ((Standard_Integer*)Nod24Indices)[0]
415 #define Nod24Flag ((Standard_Boolean*)Nod24Indices)[1]
416 #define Nod24Edg1 ((Standard_Boolean*)Nod24Indices)[2]
417 #define Nod24Edg2 ((Standard_Boolean*)Nod24Indices)[3]
419 #define Nod24PntX ((Standard_Real*)Nod24RValues)[ 0]
420 #define Nod24PntY ((Standard_Real*)Nod24RValues)[ 1]
421 #define Nod24PntZ ((Standard_Real*)Nod24RValues)[ 2]
422 #define Nod24PntU ((Standard_Real*)Nod24RValues)[ 3]
423 #define Nod24PntV ((Standard_Real*)Nod24RValues)[ 4]
424 #define Nod24NrmX ((Standard_Real*)Nod24RValues)[ 5]
425 #define Nod24NrmY ((Standard_Real*)Nod24RValues)[ 6]
426 #define Nod24NrmZ ((Standard_Real*)Nod24RValues)[ 7]
427 #define Nod24PCu1 ((Standard_Real*)Nod24RValues)[ 8]
428 #define Nod24PCu2 ((Standard_Real*)Nod24RValues)[ 9]
429 #define Nod24Scal ((Standard_Real*)Nod24RValues)[10]
431 #define ShapeIndex ((Standard_Integer*)IndexPtr)[0]
432 #define F1Index ((Standard_Integer*)IndexPtr)[1]
433 #define F1Pt1Index ((Standard_Integer*)IndexPtr)[2]
434 #define F1Pt2Index ((Standard_Integer*)IndexPtr)[3]
435 #define F2Index ((Standard_Integer*)IndexPtr)[4]
436 #define F2Pt1Index ((Standard_Integer*)IndexPtr)[5]
437 #define F2Pt2Index ((Standard_Integer*)IndexPtr)[6]
438 #define MinSeg ((Standard_Integer*)IndexPtr)[7]
439 #define MaxSeg ((Standard_Integer*)IndexPtr)[8]
440 #define SegFlags ((Standard_Integer*)IndexPtr)[9]
442 static Standard_Integer DoTrace = Standard_False;
443 static Standard_Integer DoError = Standard_False;
445 //=======================================================================
446 //function : HLRBRep_PolyAlgo
448 //=======================================================================
450 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo () :
451 myDebug (Standard_False),
452 myAngle (5 * M_PI / 180.),
457 myAlgo = new HLRAlgo_PolyAlgo();
460 //=======================================================================
461 //function : HLRBRep_PolyAlgo
463 //=======================================================================
465 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const Handle(HLRBRep_PolyAlgo)& A)
467 myDebug = A->Debug();
468 myAngle = A->Angle();
469 myTolAngular = A->TolAngular();
470 myTolSta = A->TolCoef();
471 myTolEnd = 1 - myTolSta;
473 myProj = A->Projector();
475 Standard_Integer n = A->NbShapes();
477 for (Standard_Integer i = 1; i <= n; i++)
481 //=======================================================================
482 //function : HLRBRep_PolyAlgo
484 //=======================================================================
486 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const TopoDS_Shape& S) :
487 myDebug (Standard_False),
488 myAngle (5 * M_PI / 180.),
494 myAlgo = new HLRAlgo_PolyAlgo();
497 //=======================================================================
500 //=======================================================================
502 TopoDS_Shape & HLRBRep_PolyAlgo::Shape (const Standard_Integer I)
504 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
505 "HLRBRep_PolyAlgo::Shape : unknown Shape");
509 //=======================================================================
512 //=======================================================================
514 void HLRBRep_PolyAlgo::Remove (const Standard_Integer I)
516 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
517 "HLRBRep_PolyAlgo::Remove : unknown Shape");
524 //=======================================================================
527 //=======================================================================
529 Standard_Integer HLRBRep_PolyAlgo::Index (const TopoDS_Shape& S) const
531 Standard_Integer n = myShapes.Length();
533 for (Standard_Integer i = 1; i <= n; i++)
534 if (myShapes(i) == S) return i;
539 //=======================================================================
542 //=======================================================================
544 Handle(HLRAlgo_PolyAlgo) HLRBRep_PolyAlgo::Algo () const
549 //=======================================================================
552 //=======================================================================
554 void HLRBRep_PolyAlgo::Update ()
559 TopoDS_Shape Shape = MakeShape();
561 if (!Shape.IsNull()) {
562 TopExp_Explorer exshell;
563 Standard_Boolean IsoledF,IsoledE;//,closed;
565 TopTools_MapOfShape ShapeMap1,ShapeMap2;
566 TopExp::MapShapes(Shape,TopAbs_EDGE,myEMap);
567 TopExp::MapShapes(Shape,TopAbs_FACE,myFMap);
568 Standard_Integer nbEdge = myEMap.Extent();
569 Standard_Integer nbFace = myFMap.Extent();
570 TColStd_Array1OfInteger ES (0,nbEdge); // index of the Shell
571 TColStd_Array1OfTransient PD (0,nbFace); // HLRAlgo_PolyData
572 TColStd_Array1OfTransient PID(0,nbFace); // PolyInternalData
573 Standard_Integer nbShell = InitShape(Shape,IsoledF,IsoledE);
575 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
576 Standard_Integer iShell = 0;
578 for (exshell.Init(Shape, TopAbs_SHELL);
581 StoreShell(exshell.Current(),iShell,Shell,
582 Standard_False,Standard_False,
583 ES,PD,PID,ShapeMap1,ShapeMap2);
585 StoreShell(Shape,iShell,Shell,IsoledF,Standard_False,
586 ES,PD,PID,ShapeMap1,ShapeMap2);
588 StoreShell(Shape,iShell,Shell,Standard_False,IsoledE,
589 ES,PD,PID,ShapeMap1,ShapeMap2);
595 //=======================================================================
596 //function : MakeShape
598 //=======================================================================
600 TopoDS_Shape HLRBRep_PolyAlgo::MakeShape () const
602 Standard_Integer n = myShapes.Length();
603 Standard_Boolean FirstTime = Standard_True;
607 for (Standard_Integer i = 1; i <= n; i++) {
609 FirstTime = Standard_False;
610 B.MakeCompound(TopoDS::Compound(Shape));
612 B.Add(Shape,myShapes(i));
617 //=======================================================================
618 //function : InitShape
620 //=======================================================================
623 HLRBRep_PolyAlgo::InitShape (const TopoDS_Shape& Shape,
624 Standard_Boolean& IsoledF,
625 Standard_Boolean& IsoledE)
627 TopTools_MapOfShape ShapeMap0;
628 Standard_Integer nbShell = 0;
629 IsoledF = Standard_False;
630 IsoledE = Standard_False;
631 TopExp_Explorer exshell,exface,exedge;
634 for (exshell.Init(Shape, TopAbs_SHELL);
637 Standard_Boolean withTrian = Standard_False;
639 for (exface.Init(exshell.Current(), TopAbs_FACE);
642 const TopoDS_Face& F = TopoDS::Face(exface.Current());
643 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
644 if (ShapeMap0.Add(F))
645 withTrian = Standard_True;
648 if (withTrian) nbShell++;
651 for (exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
652 exface.More() && !IsoledF;
654 const TopoDS_Face& F = TopoDS::Face(exface.Current());
655 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
656 if (ShapeMap0.Add(F))
657 IsoledF = Standard_True;
660 if (IsoledF) nbShell++;
662 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
663 exedge.More() && !IsoledE;
665 IsoledE = Standard_True;
666 if (IsoledE) nbShell++;
668 myAlgo->Init(new TColStd_HArray1OfTransient(1,nbShell));
672 //=======================================================================
673 //function : StoreShell
675 //=======================================================================
677 void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
678 Standard_Integer& iShell,
679 TColStd_Array1OfTransient& Shell,
680 const Standard_Boolean IsoledF,
681 const Standard_Boolean IsoledE,
682 TColStd_Array1OfInteger& ES,
683 TColStd_Array1OfTransient& PD,
684 TColStd_Array1OfTransient& PID,
685 TopTools_MapOfShape& ShapeMap1,
686 TopTools_MapOfShape& ShapeMap2)
689 TopExp_Explorer exface,exedge;
690 Standard_Integer f = 0,i,j;
691 Standard_Integer nbFaceShell = 0;
692 Standard_Boolean reversed;
693 Standard_Boolean closed = Standard_False;
694 const gp_Trsf& T = myProj.Transformation();
695 const gp_Trsf& TI = myProj.InvertedTransformation();
696 const gp_XYZ& tloc = T.TranslationPart();
700 const gp_Mat& tmat = T.VectorialPart();
701 TMat[0][0] = tmat.Value(1,1);
702 TMat[0][1] = tmat.Value(1,2);
703 TMat[0][2] = tmat.Value(1,3);
704 TMat[1][0] = tmat.Value(2,1);
705 TMat[1][1] = tmat.Value(2,2);
706 TMat[1][2] = tmat.Value(2,3);
707 TMat[2][0] = tmat.Value(3,1);
708 TMat[2][1] = tmat.Value(3,2);
709 TMat[2][2] = tmat.Value(3,3);
710 const gp_XYZ& tilo = TI.TranslationPart();
714 const gp_Mat& tima = TI.VectorialPart();
715 TIMa[0][0] = tima.Value(1,1);
716 TIMa[0][1] = tima.Value(1,2);
717 TIMa[0][2] = tima.Value(1,3);
718 TIMa[1][0] = tima.Value(2,1);
719 TIMa[1][1] = tima.Value(2,2);
720 TIMa[1][2] = tima.Value(2,3);
721 TIMa[2][0] = tima.Value(3,1);
722 TIMa[2][1] = tima.Value(3,2);
723 TIMa[2][2] = tima.Value(3,3);
726 closed = Shape.Closed();
728 TopTools_IndexedMapOfShape EM;
729 TopExp::MapShapes(Shape,TopAbs_EDGE,EM);
731 Standard_Integer nbEdge = EM.Extent ();
732 Standard_Integer *flag = new Standard_Integer[nbEdge + 1];
734 for (ie = 1; ie <= nbEdge; ie++)
737 for (exedge.Init(Shape, TopAbs_EDGE);
740 const TopoDS_Edge& E = TopoDS::Edge(exedge.Current());
741 ie = EM.FindIndex(E);
742 TopAbs_Orientation orient = E.Orientation();
743 if (!BRep_Tool::Degenerated(E)) {
744 if (orient == TopAbs_FORWARD ) flag[ie] += 1;
745 else if (orient == TopAbs_REVERSED) flag[ie] -= 1;
748 closed = Standard_True;
750 for (ie = 1; ie <= nbEdge && closed; ie++)
751 closed = (flag[ie] == 0);
756 exface.Init(Shape, TopAbs_FACE);
759 exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
761 for (; exface.More(); exface.Next()) {
762 const TopoDS_Face& F = TopoDS::Face(exface.Current());
763 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
764 if (ShapeMap1.Add(F))
769 if (nbFaceShell > 0 || IsoledE) {
771 Shell(iShell) = new HLRAlgo_PolyShellData(nbFaceShell);
773 if (nbFaceShell > 0) {
774 const Handle(HLRAlgo_PolyShellData)& psd =
775 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
776 Standard_Integer iFace = 0;
777 if (!IsoledF) exface.Init(Shape, TopAbs_FACE);
778 else exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
779 TopTools_MapOfShape ShapeMapBis;
781 for (; exface.More(); exface.Next()) {
782 const TopoDS_Face& F = TopoDS::Face(exface.Current());
783 const Handle(Poly_Triangulation)& Tr = BRep_Tool::Triangulation(F,L);
785 if (ShapeMap2.Add(F)) {
787 f = myFMap.FindIndex(F);
788 reversed = F.Orientation() == TopAbs_REVERSED;
789 gp_Trsf TT = L.Transformation();
791 const gp_XYZ& ttlo = TT.TranslationPart();
795 const gp_Mat& ttma = TT.VectorialPart();
796 TTMa[0][0] = ttma.Value(1,1);
797 TTMa[0][1] = ttma.Value(1,2);
798 TTMa[0][2] = ttma.Value(1,3);
799 TTMa[1][0] = ttma.Value(2,1);
800 TTMa[1][1] = ttma.Value(2,2);
801 TTMa[1][2] = ttma.Value(2,3);
802 TTMa[2][0] = ttma.Value(3,1);
803 TTMa[2][1] = ttma.Value(3,2);
804 TTMa[2][2] = ttma.Value(3,3);
805 Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
806 TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
807 Standard_Integer nbN = Nod.Upper();
808 Standard_Integer nbT = Tri.Upper();
809 PD (f) = new HLRAlgo_PolyData();
810 psd->PolyData().ChangeValue(iFace) = PD(f);
811 PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
812 Handle(HLRAlgo_PolyInternalData)& pid =
813 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(f));
814 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
815 if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface))
816 S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
817 GeomAdaptor_Surface AS(S);
818 pid->Planar(AS.GetType() == GeomAbs_Plane);
819 Standard_Address TData = &pid->TData();
820 Standard_Address PISeg = &pid->PISeg();
821 Standard_Address PINod = &pid->PINod();
822 Poly_Triangle * OT = &(Tri.ChangeValue(1));
823 HLRAlgo_TriangleData* NT =
824 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
826 for (i = 1; i <= nbT; i++) {
827 Standard_Address Tri2Indices = NT->Indices();
828 OT->Get(Tri2Node1,Tri2Node2,Tri2Node3);
832 Tri2Node1 = Tri2Node3;
839 gp_Pnt * ON = &(Nod.ChangeValue(1));
840 Handle(HLRAlgo_PolyInternalNode)* NN =
841 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
843 for (i = 1; i <= nbN; i++) {
844 const Standard_Address Nod1RValues = (*NN)->RValues();
845 const Standard_Address Nod1Indices = (*NN)->Indices();
851 TTMultiply(Nod1PntX,Nod1PntY,Nod1PntZ);
855 pid->UpdateLinks(TData,PISeg,PINod);
856 if (Tr->HasUVNodes()) {
857 myBSurf.Initialize(F,Standard_False);
858 TColgp_Array1OfPnt2d & UVN = Tr->ChangeUVNodes();
859 gp_Pnt2d* OUVN = &(UVN.ChangeValue(1));
860 NN = &(((HLRAlgo_Array1OfPINod*)PINod)->
863 for (i = 1; i <= nbN; i++) {
864 const Standard_Address Nod1Indices = (*NN)->Indices();
865 const Standard_Address Nod1RValues = (*NN)->RValues();
866 Nod1PntU = OUVN->X();
867 Nod1PntV = OUVN->Y();
868 if (Normal(i,Nod1Indices,Nod1RValues,
869 TData,PISeg,PINod,Standard_False))
870 Nod1Flag |= NMskNorm;
872 Nod1Flag &= ~NMskNorm;
881 cout << " HLRBRep_PolyAlgo::StoreShell : Face ";
882 cout << f << " non triangulated" << endl;
885 NT = &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
887 for (i = 1; i <= nbT; i++) {
888 const Standard_Address Tri1Indices = NT->Indices();
889 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
890 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
891 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
892 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
893 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
894 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
895 const Standard_Address Nod1Indices = (*PN1)->Indices();
896 const Standard_Address Nod2Indices = (*PN2)->Indices();
897 const Standard_Address Nod3Indices = (*PN3)->Indices();
898 const Standard_Address Nod1RValues = (*PN1)->RValues();
899 const Standard_Address Nod2RValues = (*PN2)->RValues();
900 const Standard_Address Nod3RValues = (*PN3)->RValues();
901 OrientTriangle(i,Tri1Indices,
902 Nod1Indices,Nod1RValues,
903 Nod2Indices,Nod2RValues,
904 Nod3Indices,Nod3RValues);
911 cout << "HLRBRep_PolyAlgo::StoreShell : Face ";
912 cout << f << " deja stockee" << endl;
916 Standard_Integer nbFace = myFMap.Extent();
917 HLRAlgo_ListOfBPoint& List = psd->Edges();
918 TopTools_IndexedDataMapOfShapeListOfShape EF;
919 TopExp::MapShapesAndAncestors(Shape,TopAbs_EDGE,TopAbs_FACE,EF);
920 Handle(HLRAlgo_PolyInternalData)* pid =
921 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
923 for (f = 1; f <= nbFace; f++) {
924 if (!(*pid).IsNull()) {
926 for (exedge.Init(myFMap(f),TopAbs_EDGE);
929 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
930 if (ShapeMap1.Add(E)) {
931 Standard_Integer e = myEMap.FindIndex(E);
933 Standard_Integer i = EF.FindIndex(E);
935 TopTools_ListOfShape& LS = EF(i);
936 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_True);
939 TopTools_ListOfShape LS;
940 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
947 InsertOnOutLine(PID);
948 CheckFrBackTriangles(List,PID);
949 UpdateOutLines(List,PID);
950 UpdateEdgesBiPoints(List,PID,closed);
951 UpdatePolyData(PD,PID,closed);
952 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
954 for (f = 1; f <= nbFace; f++) {
960 const Handle(HLRAlgo_PolyShellData)& psd =
961 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
962 HLRAlgo_ListOfBPoint& List = psd->Edges();
964 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
967 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
968 if (ShapeMap1.Add(E)) {
969 Standard_Integer e = myEMap.FindIndex(E);
971 TopTools_ListOfShape LS;
972 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
978 //=======================================================================
981 //=======================================================================
983 Standard_Boolean HLRBRep_PolyAlgo::
984 Normal (const Standard_Integer iNode,
985 const Standard_Address Nod1Indices,
986 const Standard_Address Nod1RValues,
987 Standard_Address& TData,
988 Standard_Address& PISeg,
989 Standard_Address& PINod,
990 const Standard_Boolean orient) const
992 gp_Vec D1U,D1V,D2U,D2V,D2UV;
996 CSLib_DerivativeStatus Status;
997 CSLib_NormalStatus NStat;
998 myBSurf.D1(Nod1PntU,Nod1PntV,P,D1U,D1V);
999 CSLib::Normal(D1U,D1V,Standard_Real(Precision::Angular()),
1001 if (Status != CSLib_Done) {
1002 myBSurf.D2(Nod1PntU,Nod1PntV,P,D1U,D1V,D2U,D2V,D2UV);
1003 CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,
1004 Precision::Angular(),OK,NStat,Norma);
1006 return Standard_False;
1008 Standard_Real EyeX = 0;
1009 Standard_Real EyeY = 0;
1010 Standard_Real EyeZ = -1;
1011 if (myProj.Perspective()) {
1014 EyeZ = Nod1PntZ - myProj.Focus();
1015 Standard_Real d = sqrt(EyeX * EyeX + EyeY * EyeY + EyeZ * EyeZ);
1022 Nod1NrmX = Norma.X();
1023 Nod1NrmY = Norma.Y();
1024 Nod1NrmZ = Norma.Z();
1025 // TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ);
1026 TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ,myProj.Perspective()); //OCC349
1027 Standard_Real NormX,NormY,NormZ;
1029 if (AverageNormal(iNode,Nod1Indices,TData,PISeg,PINod,
1030 NormX,NormY,NormZ)) {
1031 if (Nod1NrmX * NormX +
1033 Nod1NrmZ * NormZ < 0) {
1034 Nod1NrmX = -Nod1NrmX;
1035 Nod1NrmY = -Nod1NrmY;
1036 Nod1NrmZ = -Nod1NrmZ;
1038 Nod1Scal = (Nod1NrmX * EyeX +
1049 cout << "HLRBRep_PolyAlgo::Normal : AverageNormal error";
1055 if ( Nod1Scal < myTolAngular) {
1057 Nod1Flag |= NMskOutL;
1061 if (-Nod1Scal < myTolAngular) {
1063 Nod1Flag |= NMskOutL;
1066 if (orient) UpdateAroundNode(iNode,Nod1Indices,
1068 return Standard_True;
1071 //=======================================================================
1072 //function : AverageNormal
1074 //=======================================================================
1077 HLRBRep_PolyAlgo::AverageNormal(const Standard_Integer iNode,
1078 const Standard_Address Nod1Indices,
1079 Standard_Address& TData,
1080 Standard_Address& PISeg,
1081 Standard_Address& PINod,
1084 Standard_Real& Z) const
1086 Standard_Boolean OK = Standard_False;
1087 Standard_Integer jNode = 0,kNode,iiii,iTri1,iTri2;
1093 while (iiii != 0 && !OK) {
1094 const Standard_Address Seg2Indices =
1095 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1098 if ( iTri1 != 0) AddNormalOnTriangle
1099 (iTri1,iNode,jNode,TData,PINod,X,Y,Z,OK);
1100 if ( iTri2 != 0) AddNormalOnTriangle
1101 (iTri2,iNode,jNode,TData,PINod,X,Y,Z,OK);
1102 if (Seg2LstSg1 == iNode) iiii = Seg2NxtSg1;
1103 else iiii = Seg2NxtSg2;
1107 const Standard_Address Nod2Indices =
1108 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(jNode)->Indices();
1111 while (iiii != 0 && !OK) {
1112 const Standard_Address Seg2Indices =
1113 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1116 if ( iTri1 != 0) AddNormalOnTriangle
1117 (iTri1,jNode,kNode,TData,PINod,X,Y,Z,OK);
1118 if ( iTri2 != 0) AddNormalOnTriangle
1119 (iTri2,jNode,kNode,TData,PINod,X,Y,Z,OK);
1120 if (Seg2LstSg1 == jNode) iiii = Seg2NxtSg1;
1121 else iiii = Seg2NxtSg2;
1124 Standard_Real d = sqrt (X * X + Y * Y + Z * Z);
1125 if (OK && d < 1.e-10) {
1126 OK = Standard_False;
1129 cout << "HLRAlgo_PolyInternalData:: inverted normals on ";
1130 cout << "node " << iNode << endl;
1137 //=======================================================================
1138 //function : AddNormalOnTriangle
1140 //=======================================================================
1144 AddNormalOnTriangle(const Standard_Integer iTri,
1145 const Standard_Integer iNode,
1146 Standard_Integer& jNode,
1147 Standard_Address& TData,
1148 Standard_Address& PINod,
1152 Standard_Boolean& OK) const
1154 Standard_Real dn,dnx,dny,dnz;
1155 Standard_Real d1,dx1,dy1,dz1;
1156 Standard_Real d2,dx2,dy2,dz2;
1157 Standard_Real d3,dx3,dy3,dz3;
1158 const Standard_Address Tri2Indices =
1159 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri).Indices();
1160 const Standard_Address Nod1RValues =
1161 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1)->RValues();
1162 const Standard_Address Nod2RValues =
1163 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2)->RValues();
1164 const Standard_Address Nod3RValues =
1165 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3)->RValues();
1166 dx1 = Nod2PntX - Nod1PntX;
1167 dy1 = Nod2PntY - Nod1PntY;
1168 dz1 = Nod2PntZ - Nod1PntZ;
1169 d1 = sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
1171 if (Tri2Node1 == iNode) jNode = Tri2Node2;
1172 else if (Tri2Node2 == iNode) jNode = Tri2Node1;
1175 dx2 = Nod3PntX - Nod2PntX;
1176 dy2 = Nod3PntY - Nod2PntY;
1177 dz2 = Nod3PntZ - Nod2PntZ;
1178 d2 = sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
1180 if (Tri2Node2 == iNode) jNode = Tri2Node3;
1181 else if (Tri2Node3 == iNode) jNode = Tri2Node2;
1184 dx3 = Nod1PntX - Nod3PntX;
1185 dy3 = Nod1PntY - Nod3PntY;
1186 dz3 = Nod1PntZ - Nod3PntZ;
1187 d3 = sqrt(dx3 * dx3 + dy3 * dy3 + dz3 * dz3);
1189 if (Tri2Node3 == iNode) jNode = Tri2Node1;
1190 else if (Tri2Node1 == iNode) jNode = Tri2Node3;
1194 dnx = (dy1 * dz2 - dy2 * dz1) * dn;
1195 dny = (dz1 * dx2 - dz2 * dx1) * dn;
1196 dnz = (dx1 * dy2 - dx2 * dy1) * dn;
1197 dn = sqrt(dnx * dnx + dny * dny + dnz * dnz);
1209 //=======================================================================
1210 //function : InitBiPointsWithConnexity
1212 //=======================================================================
1214 void HLRBRep_PolyAlgo::
1215 InitBiPointsWithConnexity (const Standard_Integer e,
1217 HLRAlgo_ListOfBPoint& List,
1218 TColStd_Array1OfTransient& PID,
1219 TopTools_ListOfShape& LS,
1220 const Standard_Boolean connex)
1222 Standard_Integer iPol,nbPol,i1,i1p1,i1p2,i2,i2p1,i2p2;
1223 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
1224 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
1225 Standard_Real U1,U2 = 0.;
1226 Handle(Poly_PolygonOnTriangulation) HPol[2];
1228 myBCurv.Initialize(E);
1230 Standard_Integer nbConnex = LS.Extent();
1231 if (nbConnex == 1) {
1232 TopTools_ListIteratorOfListOfShape itn(LS);
1233 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1234 i1 = myFMap.FindIndex(F1);
1235 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1236 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1237 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1238 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1239 if (!HPol[0].IsNull()) {
1240 myPC.Initialize(E,F1);
1241 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1242 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1243 nbPol = Pol1.Upper();
1244 Standard_Address TData1 = &pid1->TData();
1245 Standard_Address PISeg1 = &pid1->PISeg();
1246 Standard_Address PINod1 = &pid1->PINod();
1247 Standard_Address Nod11Indices,Nod12Indices;
1248 Standard_Address Nod11RValues,Nod12RValues;
1249 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1250 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1251 Nod11Indices = (*pi1p1)->Indices();
1252 Nod11RValues = (*pi1p1)->RValues();
1253 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1254 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1255 Nod12Indices = (*pi1p2)->Indices();
1256 Nod12RValues = (*pi1p2)->RValues();
1257 Nod11Flag |= NMskVert;
1258 Nod12Flag |= NMskVert;
1260 for (iPol = 1; iPol <= nbPol; iPol++) {
1261 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1262 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1263 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1264 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1265 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1267 Nod1APCu1 = par->Value(iPol);
1271 Nod1APCu2 = par->Value(iPol);
1276 Nod12Indices = Nod11Indices;
1277 Nod12RValues = Nod11RValues;
1278 XTI2 = X2 = Nod12PntX;
1279 YTI2 = Y2 = Nod12PntY;
1280 ZTI2 = Z2 = Nod12PntZ;
1281 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1282 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1285 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1286 cout << "Parameter error on Node " << i1p2 << endl;
1289 Nod12Flag |= NMskEdge;
1290 TIMultiply(XTI2,YTI2,ZTI2);
1291 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1292 U2 = U2 - myPC.Period();
1294 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1295 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1296 Nod12Indices,Nod12RValues);
1297 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1298 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1302 for (iPol = 2; iPol <= nbPol; iPol++) {
1304 Nod11Indices = Nod12Indices;
1305 Nod11RValues = Nod12RValues;
1307 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1308 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1309 Nod12Indices = (*pi1p2)->Indices();
1310 Nod12RValues = (*pi1p2)->RValues();
1313 if (Nod11NrmX*Nod12NrmX +
1314 Nod11NrmY*Nod12NrmY +
1315 Nod11NrmZ*Nod12NrmZ < 0) {
1316 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1317 cout << "Too big angle between " << i1p1 << setw(6);
1318 cout << " and " << i1p2 << setw(6);
1319 cout << " in face " << i1 << endl;
1330 XTI2 = X2 = Nod12PntX;
1331 YTI2 = Y2 = Nod12PntY;
1332 ZTI2 = Z2 = Nod12PntZ;
1333 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1334 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1337 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1338 cout << "Parameter error on Node " << i1p2 << endl;
1341 Nod12Flag |= NMskEdge;
1342 TIMultiply(XTI2,YTI2,ZTI2);
1344 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1345 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1347 Nod11Indices,Nod11RValues,
1348 Nod12Indices,Nod12RValues,
1349 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1);
1355 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1356 cout << e << " connex 1 sans PolygonOnTriangulation" << endl;
1360 else if (nbConnex == 2) {
1361 TopTools_ListIteratorOfListOfShape itn(LS);
1362 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1363 i1 = myFMap.FindIndex(F1);
1364 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1365 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1367 const TopoDS_Face& F2 = TopoDS::Face(itn.Value());
1368 i2 = myFMap.FindIndex(F2);
1369 if (i1 == i2) E.Reverse();
1370 const Handle(Poly_Triangulation)& Tr2 = BRep_Tool::Triangulation(F2,L);
1371 HPol[1] = BRep_Tool::PolygonOnTriangulation(E,Tr2,L);
1372 GeomAbs_Shape rg = BRep_Tool::Continuity(E,F1,F2);
1373 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1374 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1375 const Handle(HLRAlgo_PolyInternalData)& pid2 =
1376 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i2));
1377 if (!HPol[0].IsNull() && !HPol[1].IsNull()) {
1378 myPC.Initialize(E,F1);
1379 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1380 const TColStd_Array1OfInteger& Pol2 = HPol[1]->Nodes();
1381 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1382 Standard_Integer nbPol = Pol1.Upper();
1383 Standard_Address TData1 = &pid1->TData();
1384 Standard_Address PISeg1 = &pid1->PISeg();
1385 Standard_Address PINod1 = &pid1->PINod();
1386 Standard_Address TData2 = &pid2->TData();
1387 Standard_Address PISeg2 = &pid2->PISeg();
1388 Standard_Address PINod2 = &pid2->PINod();
1389 Standard_Address Nod11Indices,Nod11RValues;
1390 Standard_Address Nod12Indices,Nod12RValues;
1391 Standard_Address Nod21Indices,Nod21RValues;
1392 Standard_Address Nod22Indices,Nod22RValues;
1393 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1394 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1395 Nod11Indices = (*pi1p1)->Indices();
1396 Nod11RValues = (*pi1p1)->RValues();
1397 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1398 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1399 Nod12Indices = (*pi1p2)->Indices();
1400 Nod12RValues = (*pi1p2)->RValues();
1401 const Handle(HLRAlgo_PolyInternalNode)* pi2p1 =
1402 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(1 )));
1403 Nod21Indices = (*pi2p1)->Indices();
1404 Nod21RValues = (*pi2p1)->RValues();
1405 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1406 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(nbPol)));
1407 Nod22Indices = (*pi2p2)->Indices();
1408 Nod22RValues = (*pi2p2)->RValues();
1409 Nod11Flag |= NMskVert;
1410 Nod12Flag |= NMskVert;
1411 Nod21Flag |= NMskVert;
1412 Nod22Flag |= NMskVert;
1414 for (iPol = 1; iPol <= nbPol; iPol++) {
1415 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1416 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1417 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1418 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1419 const Handle(HLRAlgo_PolyInternalNode)* pi2pA =
1420 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1421 Standard_Address Nod2AIndices = (*pi2pA)->Indices();
1422 Standard_Address Nod2ARValues = (*pi2pA)->RValues();
1423 Standard_Real PCu = par->Value(iPol);
1424 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1432 if (Nod2AEdg1 == 0 || Nod2AEdg1 == (Standard_Boolean) e) {
1443 Nod12Indices = Nod11Indices;
1444 Nod12RValues = Nod11RValues;
1446 Nod22Indices = Nod21Indices;
1447 Nod22RValues = Nod21RValues;
1448 XTI2 = X2 = Nod12PntX;
1449 YTI2 = Y2 = Nod12PntY;
1450 ZTI2 = Z2 = Nod12PntZ;
1451 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1452 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1455 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1456 cout << "Parameter error on Node " << i1p2 << endl;
1459 Nod12Flag |= NMskEdge;
1460 Nod22Flag |= NMskEdge;
1461 TIMultiply(XTI2,YTI2,ZTI2);
1462 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1463 U2 = U2 - myPC.Period();
1465 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1466 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1467 Nod12Indices,Nod12RValues);
1468 CheckDegeneratedSegment(Nod21Indices,Nod21RValues,
1469 Nod22Indices,Nod22RValues);
1470 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1471 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1472 UpdateAroundNode(Pol2(1 ),Nod21Indices,TData2,PISeg2,PINod2);
1473 UpdateAroundNode(Pol2(nbPol),Nod22Indices,TData2,PISeg2,PINod2);
1477 for (iPol = 2; iPol <= nbPol; iPol++) {
1479 Nod11Indices = Nod12Indices;
1480 Nod11RValues = Nod12RValues;
1482 Nod21Indices = Nod22Indices;
1483 Nod21RValues = Nod22RValues;
1485 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1486 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1487 Nod12Indices = (*pi1p2)->Indices();
1488 Nod12RValues = (*pi1p2)->RValues();
1490 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1491 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1492 Nod22Indices = (*pi2p2)->Indices();
1493 Nod22RValues = (*pi2p2)->RValues();
1496 if (Nod11NrmX*Nod12NrmX +
1497 Nod11NrmY*Nod12NrmY +
1498 Nod11NrmZ*Nod12NrmZ < 0) {
1499 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1500 cout << "To big angle between " << i1p1 << setw(6);
1501 cout << " and " << i1p2 << setw(6);
1502 cout << " in face " << i1 << endl;
1504 if (Nod21NrmX*Nod22NrmX +
1505 Nod21NrmY*Nod22NrmY +
1506 Nod21NrmZ*Nod22NrmZ < 0) {
1507 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1508 cout << "To big angle between " << i2p1 << setw(6);
1509 cout << " and " << i2p2 << setw(6);
1510 cout<< " in face " << i2 << endl;
1521 XTI2 = X2 = Nod12PntX;
1522 YTI2 = Y2 = Nod12PntY;
1523 ZTI2 = Z2 = Nod12PntZ;
1524 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1525 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1528 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1529 cout << "Parameter error on Node " << i1p2 << endl;
1532 Nod12Flag |= NMskEdge;
1533 Nod22Flag |= NMskEdge;
1534 TIMultiply(XTI2,YTI2,ZTI2);
1536 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1537 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1539 Nod11Indices,Nod11RValues,
1540 Nod12Indices,Nod12RValues,
1541 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1542 Nod21Indices,Nod21RValues,
1543 Nod22Indices,Nod22RValues,
1544 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2);
1550 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1551 cout << e << " connect 2 without PolygonOnTriangulation" << endl;
1556 else { // no connexity
1557 const Handle(Poly_Polygon3D)& Polyg = BRep_Tool::Polygon3D(E,L);
1558 if (!Polyg.IsNull()) {
1559 const TColgp_Array1OfPnt& Pol = Polyg->Nodes();
1560 gp_Trsf TT = L.Transformation();
1561 const gp_Trsf& T = myProj.Transformation();
1563 const gp_XYZ& ttlo = TT.TranslationPart();
1567 const gp_Mat& ttma = TT.VectorialPart();
1568 TTMa[0][0] = ttma.Value(1,1);
1569 TTMa[0][1] = ttma.Value(1,2);
1570 TTMa[0][2] = ttma.Value(1,3);
1571 TTMa[1][0] = ttma.Value(2,1);
1572 TTMa[1][1] = ttma.Value(2,2);
1573 TTMa[1][2] = ttma.Value(2,3);
1574 TTMa[2][0] = ttma.Value(3,1);
1575 TTMa[2][1] = ttma.Value(3,2);
1576 TTMa[2][2] = ttma.Value(3,3);
1577 Standard_Integer nbPol = Pol.Upper();
1578 const gp_XYZ& P1 = Pol(1).XYZ();
1582 TTMultiply(X2,Y2,Z2);
1586 TIMultiply(XTI2,YTI2,ZTI2);
1588 for (Standard_Integer iPol = 2; iPol <= nbPol; iPol++) {
1595 const gp_XYZ& P2 = Pol(iPol).XYZ();
1599 TTMultiply(X2,Y2,Z2);
1603 TIMultiply(XTI2,YTI2,ZTI2);
1604 List.Prepend(HLRAlgo_BiPoint
1605 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1606 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1612 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1613 cout << e << " Isolated, without Polygone 3D" << endl;
1619 //=======================================================================
1620 //function : Interpolation
1622 //=======================================================================
1626 Interpolation (HLRAlgo_ListOfBPoint& List,
1633 Standard_Real& XTI1,
1634 Standard_Real& YTI1,
1635 Standard_Real& ZTI1,
1636 Standard_Real& XTI2,
1637 Standard_Real& YTI2,
1638 Standard_Real& ZTI2,
1639 const Standard_Integer e,
1642 Standard_Address& Nod11Indices,
1643 Standard_Address& Nod11RValues,
1644 Standard_Address& Nod12Indices,
1645 Standard_Address& Nod12RValues,
1646 const Standard_Integer i1p1,
1647 const Standard_Integer i1p2,
1648 const Standard_Integer i1,
1649 const Handle(HLRAlgo_PolyInternalData)& pid1,
1650 Standard_Address& TData1,
1651 Standard_Address& PISeg1,
1652 Standard_Address& PINod1) const
1654 Standard_Boolean insP3,mP3P1;
1655 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1657 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1658 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1659 MoveOrInsertPoint(List,
1660 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1661 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1663 Nod11Indices,Nod11RValues,
1664 Nod12Indices,Nod12RValues,
1665 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1666 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,0);
1669 //=======================================================================
1670 //function : Interpolation
1672 //=======================================================================
1676 Interpolation (HLRAlgo_ListOfBPoint& List,
1683 Standard_Real& XTI1,
1684 Standard_Real& YTI1,
1685 Standard_Real& ZTI1,
1686 Standard_Real& XTI2,
1687 Standard_Real& YTI2,
1688 Standard_Real& ZTI2,
1689 const Standard_Integer e,
1692 const GeomAbs_Shape rg,
1693 Standard_Address& Nod11Indices,
1694 Standard_Address& Nod11RValues,
1695 Standard_Address& Nod12Indices,
1696 Standard_Address& Nod12RValues,
1697 const Standard_Integer i1p1,
1698 const Standard_Integer i1p2,
1699 const Standard_Integer i1,
1700 const Handle(HLRAlgo_PolyInternalData)& pid1,
1701 Standard_Address& TData1,
1702 Standard_Address& PISeg1,
1703 Standard_Address& PINod1,
1704 Standard_Address& Nod21Indices,
1705 Standard_Address& Nod21RValues,
1706 Standard_Address& Nod22Indices,
1707 Standard_Address& Nod22RValues,
1708 const Standard_Integer i2p1,
1709 const Standard_Integer i2p2,
1710 const Standard_Integer i2,
1711 const Handle(HLRAlgo_PolyInternalData)& pid2,
1712 Standard_Address& TData2,
1713 Standard_Address& PISeg2,
1714 Standard_Address& PINod2) const
1716 Standard_Boolean insP3,mP3P1,insP4,mP4P1;
1717 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1718 Standard_Real X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4;
1719 // gp_Pnt P3,PT3,P4,PT4;
1720 Standard_Boolean flag = 0;
1721 if (rg >= GeomAbs_G1) flag += 1;
1722 if (rg >= GeomAbs_G2) flag += 2;
1723 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1724 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1725 insP4 = Interpolation(U1,U2,Nod21RValues,Nod22RValues,
1726 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,mP4P1);
1727 Standard_Boolean OK = insP3 || insP4;
1729 if (!insP4) // p1 i1p3 p2
1730 MoveOrInsertPoint(List,
1731 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1732 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1734 Nod11Indices,Nod11RValues,
1735 Nod12Indices,Nod12RValues,
1736 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1737 Nod21Indices,Nod21RValues,
1738 Nod22Indices,Nod22RValues,
1739 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1740 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1741 else if (!insP3) // p1 i2p4 p2
1742 MoveOrInsertPoint(List,
1743 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1744 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1746 Nod21Indices,Nod21RValues,
1747 Nod22Indices,Nod22RValues,
1748 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1749 Nod11Indices,Nod11RValues,
1750 Nod12Indices,Nod12RValues,
1751 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1752 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1753 else if (Abs(coef4 - coef3) < myTolSta) // p1 i1p3-i2p4 p2
1754 MoveOrInsertPoint(List,
1755 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1756 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1758 Nod21Indices,Nod21RValues,
1759 Nod22Indices,Nod22RValues,
1760 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1761 Nod11Indices,Nod11RValues,
1762 Nod12Indices,Nod12RValues,
1763 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1764 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1765 else if (coef4 < coef3) // p1 i2p4 i1p3 p2
1766 MoveOrInsertPoint(List,
1767 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1768 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1770 Nod21Indices,Nod21RValues,
1771 Nod22Indices,Nod22RValues,
1772 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1773 Nod11Indices,Nod11RValues,
1774 Nod12Indices,Nod12RValues,
1775 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1776 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,
1777 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1778 else // p1 i1p3 i2p4 p2
1779 MoveOrInsertPoint(List,
1780 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1781 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1783 Nod11Indices,Nod11RValues,
1784 Nod12Indices,Nod12RValues,
1785 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1786 Nod21Indices,Nod21RValues,
1787 Nod22Indices,Nod22RValues,
1788 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1789 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,
1790 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1793 List.Prepend(HLRAlgo_BiPoint
1794 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1795 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1796 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
1799 //=======================================================================
1800 //function : Interpolation
1802 //=======================================================================
1806 Interpolation (const Standard_Real U1,
1807 const Standard_Real U2,
1808 const Standard_Address Nod1RValues,
1809 const Standard_Address Nod2RValues,
1813 Standard_Real& XTI3,
1814 Standard_Real& YTI3,
1815 Standard_Real& ZTI3,
1816 Standard_Real& coef3,
1818 Standard_Boolean& mP3P1) const
1820 if (NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1)) {
1821 U3 = U1 + (U2 - U1) * coef3;
1822 const gp_Pnt& P3 = myBCurv.Value(U3);
1826 TMultiply(X3,Y3,Z3);
1827 return Standard_True;
1829 return Standard_False;
1832 //=======================================================================
1833 //function : MoveOrInsertPoint
1835 //=======================================================================
1839 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1846 Standard_Real& XTI1,
1847 Standard_Real& YTI1,
1848 Standard_Real& ZTI1,
1849 Standard_Real& XTI2,
1850 Standard_Real& YTI2,
1851 Standard_Real& ZTI2,
1852 const Standard_Integer e,
1855 Standard_Address& Nod11Indices,
1856 Standard_Address& Nod11RValues,
1857 Standard_Address& Nod12Indices,
1858 Standard_Address& Nod12RValues,
1859 const Standard_Integer i1p1,
1860 const Standard_Integer i1p2,
1861 const Standard_Integer i1,
1862 const Handle(HLRAlgo_PolyInternalData)& pid1,
1863 Standard_Address& TData1,
1864 Standard_Address& PISeg1,
1865 Standard_Address& PINod1,
1866 const Standard_Real X3,
1867 const Standard_Real Y3,
1868 const Standard_Real Z3,
1869 const Standard_Real XTI3,
1870 const Standard_Real YTI3,
1871 const Standard_Real ZTI3,
1872 const Standard_Real coef3,
1873 const Standard_Real U3,
1874 const Standard_Boolean insP3,
1875 const Standard_Boolean mP3P1,
1876 const Standard_Boolean flag) const
1878 Standard_Address TData2 = 0;
1879 Standard_Address PISeg2 = 0;
1880 Standard_Address PINod2 = 0;
1881 Standard_Boolean ins3 = insP3;
1882 if (ins3 && mP3P1) { // P1 ---> P3
1883 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
1884 ins3 = Standard_False;
1885 ChangeNode(i1p1,i1p2,
1886 Nod11Indices,Nod11RValues,
1887 Nod12Indices,Nod12RValues,
1888 coef3,X3,Y3,Z3,Standard_True,
1889 TData1,PISeg1,PINod1);
1900 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
1901 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
1904 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1905 cout << "Parameter error on Node " << i1p1 << endl;
1909 Nod11Flag |= NMskOutL;
1910 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
1911 Standard_Address Coordinates = List.First().Coordinates();
1920 if (ins3 && !mP3P1) { // P2 ---> P3
1921 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
1922 ins3 = Standard_False;
1923 ChangeNode(i1p1,i1p2,
1924 Nod11Indices,Nod11RValues,
1925 Nod12Indices,Nod12RValues,
1926 coef3,X3,Y3,Z3,Standard_False,
1927 TData1,PISeg1,PINod1);
1938 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
1939 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
1942 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1943 cout << "Parameter error on Node " << i1p2 << endl;
1947 Nod12Flag |= NMskOutL;
1948 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
1951 if (ins3) { // p1 i1p3 p2
1952 Standard_Integer i1p3 = pid1->AddNode
1953 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
1954 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
1955 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
1956 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
1957 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
1961 Nod13Flag |= NMskOutL;
1962 Nod13Flag |= NMskEdge;
1963 pid1->UpdateLinks(i1p1,i1p2,i1p3,
1964 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
1965 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
1966 List.Prepend(HLRAlgo_BiPoint
1967 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
1968 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
1969 i1 ,i1p1,i1p3,flag));
1970 List.Prepend(HLRAlgo_BiPoint
1971 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
1972 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
1973 i1 ,i1p3,i1p2,flag));
1976 List.Prepend(HLRAlgo_BiPoint
1977 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1978 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1979 i1 ,i1p1,i1p2,flag));
1982 //=======================================================================
1983 //function : MoveOrInsertPoint
1985 //=======================================================================
1989 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1996 Standard_Real& XTI1,
1997 Standard_Real& YTI1,
1998 Standard_Real& ZTI1,
1999 Standard_Real& XTI2,
2000 Standard_Real& YTI2,
2001 Standard_Real& ZTI2,
2002 const Standard_Integer e,
2005 Standard_Address& Nod11Indices,
2006 Standard_Address& Nod11RValues,
2007 Standard_Address& Nod12Indices,
2008 Standard_Address& Nod12RValues,
2009 const Standard_Integer i1p1,
2010 const Standard_Integer i1p2,
2011 const Standard_Integer i1,
2012 const Handle(HLRAlgo_PolyInternalData)& pid1,
2013 Standard_Address& TData1,
2014 Standard_Address& PISeg1,
2015 Standard_Address& PINod1,
2016 Standard_Address& Nod21Indices,
2017 Standard_Address& Nod21RValues,
2018 Standard_Address& Nod22Indices,
2019 Standard_Address& Nod22RValues,
2020 const Standard_Integer i2p1,
2021 const Standard_Integer i2p2,
2022 const Standard_Integer i2,
2023 const Handle(HLRAlgo_PolyInternalData)& pid2,
2024 Standard_Address& TData2,
2025 Standard_Address& PISeg2,
2026 Standard_Address& PINod2,
2027 const Standard_Real X3,
2028 const Standard_Real Y3,
2029 const Standard_Real Z3,
2030 const Standard_Real XTI3,
2031 const Standard_Real YTI3,
2032 const Standard_Real ZTI3,
2033 const Standard_Real coef3,
2034 const Standard_Real U3,
2035 const Standard_Boolean insP3,
2036 const Standard_Boolean mP3P1,
2037 const Standard_Boolean flag) const
2039 Standard_Boolean ins3 = insP3;
2040 if (ins3 && mP3P1) { // P1 ---> P3
2041 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2042 ins3 = Standard_False;
2043 ChangeNode(i1p1,i1p2,
2044 Nod11Indices,Nod11RValues,
2045 Nod12Indices,Nod12RValues,
2046 coef3,X3,Y3,Z3,Standard_True,
2047 TData1,PISeg1,PINod1);
2048 ChangeNode(i2p1,i2p2,
2049 Nod21Indices,Nod21RValues,
2050 Nod22Indices,Nod22RValues,
2051 coef3,X3,Y3,Z3,Standard_True,
2052 TData2,PISeg2,PINod2);
2063 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2064 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2067 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2068 cout << "Parameter error on Node " << i1p1 << endl;
2072 Nod11Flag |= NMskOutL;
2073 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2077 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2078 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2081 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2082 cout << "Parameter error on Node " << i2p1 << endl;
2086 Nod21Flag |= NMskOutL;
2087 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2088 Standard_Address Coordinates = List.First().Coordinates();
2097 if (ins3 && !mP3P1) { // P2 ---> P3
2098 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
2099 ins3 = Standard_False;
2100 ChangeNode(i1p1,i1p2,
2101 Nod11Indices,Nod11RValues,
2102 Nod12Indices,Nod12RValues,
2103 coef3,X3,Y3,Z3,Standard_False,
2104 TData1,PISeg1,PINod1);
2105 ChangeNode(i2p1,i2p2,
2106 Nod21Indices,Nod21RValues,
2107 Nod22Indices,Nod22RValues,
2108 coef3,X3,Y3,Z3,Standard_False,
2109 TData2,PISeg2,PINod2);
2120 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
2121 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
2124 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2125 cout << "Parameter error on Node " << i1p2 << endl;
2129 Nod12Flag |= NMskOutL;
2130 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2134 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U3;
2135 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U3;
2138 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2139 cout << "Parameter error on Node " << i2p2 << endl;
2143 Nod22Flag |= NMskOutL;
2144 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2147 if (ins3) { // p1 i1p3 p2
2148 Standard_Integer i1p3 = pid1->AddNode
2149 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2150 Standard_Integer i2p3 = pid2->AddNode
2151 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2152 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2153 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2154 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2155 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2156 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2157 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2158 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2159 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2163 Nod13Flag |= NMskOutL;
2164 Nod13Flag |= NMskEdge;
2168 Nod23Flag |= NMskOutL;
2169 Nod23Flag |= NMskEdge;
2170 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2171 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2172 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2173 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2174 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2175 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2176 List.Prepend(HLRAlgo_BiPoint
2177 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2178 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2179 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2180 List.Prepend(HLRAlgo_BiPoint
2181 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
2182 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
2183 i1 ,i1p3,i1p2,i2 ,i2p3,i2p2,flag));
2186 List.Prepend(HLRAlgo_BiPoint
2187 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2188 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2189 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2192 //=======================================================================
2193 //function : MoveOrInsertPoint
2195 //=======================================================================
2199 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
2206 Standard_Real& XTI1,
2207 Standard_Real& YTI1,
2208 Standard_Real& ZTI1,
2209 Standard_Real& XTI2,
2210 Standard_Real& YTI2,
2211 Standard_Real& ZTI2,
2212 const Standard_Integer e,
2215 Standard_Address& Nod11Indices,
2216 Standard_Address& Nod11RValues,
2217 Standard_Address& Nod12Indices,
2218 Standard_Address& Nod12RValues,
2219 const Standard_Integer i1p1,
2220 const Standard_Integer i1p2,
2221 const Standard_Integer i1,
2222 const Handle(HLRAlgo_PolyInternalData)& pid1,
2223 Standard_Address& TData1,
2224 Standard_Address& PISeg1,
2225 Standard_Address& PINod1,
2226 Standard_Address& Nod21Indices,
2227 Standard_Address& Nod21RValues,
2228 Standard_Address& Nod22Indices,
2229 Standard_Address& Nod22RValues,
2230 const Standard_Integer i2p1,
2231 const Standard_Integer i2p2,
2232 const Standard_Integer i2,
2233 const Handle(HLRAlgo_PolyInternalData)& pid2,
2234 Standard_Address& TData2,
2235 Standard_Address& PISeg2,
2236 Standard_Address& PINod2,
2237 const Standard_Real X3,
2238 const Standard_Real Y3,
2239 const Standard_Real Z3,
2240 const Standard_Real XTI3,
2241 const Standard_Real YTI3,
2242 const Standard_Real ZTI3,
2243 const Standard_Real coef3,
2244 const Standard_Real U3,
2245 const Standard_Boolean insP3,
2246 const Standard_Boolean mP3P1,
2247 const Standard_Real X4,
2248 const Standard_Real Y4,
2249 const Standard_Real Z4,
2250 const Standard_Real XTI4,
2251 const Standard_Real YTI4,
2252 const Standard_Real ZTI4,
2253 const Standard_Real coef4,
2254 const Standard_Real U4,
2255 const Standard_Boolean insP4,
2256 const Standard_Boolean mP4P1,
2257 const Standard_Boolean flag) const
2259 Standard_Boolean ins3 = insP3;
2260 Standard_Boolean ins4 = insP4;
2261 if (ins3 && mP3P1) { // P1 ---> P3
2262 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2263 ins3 = Standard_False;
2264 ChangeNode(i1p1,i1p2,
2265 Nod11Indices,Nod11RValues,
2266 Nod12Indices,Nod12RValues,
2267 coef3,X3,Y3,Z3,Standard_True,
2268 TData1,PISeg1,PINod1);
2269 ChangeNode(i2p1,i2p2,
2270 Nod21Indices,Nod21RValues,
2271 Nod22Indices,Nod22RValues,
2272 coef3,X3,Y3,Z3,Standard_True,
2273 TData2,PISeg2,PINod2);
2284 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2285 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2288 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2289 cout << "Parameter error on Node " << i1p1 << endl;
2293 Nod11Flag |= NMskOutL;
2294 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2298 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2299 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2302 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2303 cout << "Parameter error on Node " << i2p1 << endl;
2307 Nod21Flag |= NMskOutL;
2308 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2309 Standard_Address Coordinates = List.First().Coordinates();
2318 if (ins4 && !mP4P1) { // P2 ---> P4
2319 if (!(Nod12Flag & NMskVert) && coef4 > myTolEnd) {
2320 ins4 = Standard_False;
2321 ChangeNode(i2p1,i2p2,
2322 Nod21Indices,Nod21RValues,
2323 Nod22Indices,Nod22RValues,
2324 coef4,X4,Y4,Z4,Standard_False,
2325 TData2,PISeg2,PINod2);
2326 ChangeNode(i1p1,i1p2,
2327 Nod11Indices,Nod11RValues,
2328 Nod12Indices,Nod12RValues,
2329 coef4,X4,Y4,Z4,Standard_False,
2330 TData1,PISeg1,PINod1);
2341 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U4;
2342 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U4;
2345 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2346 cout << "Parameter error on Node " << i1p2 << endl;
2350 Nod12Flag |= NMskOutL;
2351 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2355 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U4;
2356 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U4;
2359 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2360 cout << "Parameter error on Node " << i2p2 << endl;
2364 Nod22Flag |= NMskOutL;
2365 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2369 if (!ins4) // p1 i1p3 p2
2370 MoveOrInsertPoint(List,
2371 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2372 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2374 Nod11Indices,Nod11RValues,
2375 Nod12Indices,Nod12RValues,
2376 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2377 Nod21Indices,Nod21RValues,
2378 Nod22Indices,Nod22RValues,
2379 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2380 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
2381 else if (!ins3) // p1 i2p4 p2
2382 MoveOrInsertPoint(List,
2383 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2384 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2386 Nod21Indices,Nod21RValues,
2387 Nod22Indices,Nod22RValues,
2388 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2389 Nod11Indices,Nod11RValues,
2390 Nod12Indices,Nod12RValues,
2391 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2392 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
2393 else { // p1 i1p3 i2p4 p2
2394 Standard_Integer i1p3 = pid1->AddNode
2395 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2396 Standard_Integer i2p3 = pid2->AddNode
2397 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2398 Standard_Integer i1p4 = pid1->AddNode
2399 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef4,X4,Y4,Z4);
2400 Standard_Integer i2p4 = pid2->AddNode
2401 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef4,X4,Y4,Z4);
2402 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2403 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2404 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2405 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2406 const Handle(HLRAlgo_PolyInternalNode)* pi1p4 =
2407 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p4));
2408 const Standard_Address Nod14Indices = (*pi1p4)->Indices();
2409 const Standard_Address Nod14RValues = (*pi1p4)->RValues();
2410 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2411 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2412 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2413 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2414 const Handle(HLRAlgo_PolyInternalNode)* pi2p4 =
2415 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p4));
2416 const Standard_Address Nod24Indices = (*pi2p4)->Indices();
2417 const Standard_Address Nod24RValues = (*pi2p4)->RValues();
2421 Nod13Flag |= NMskOutL;
2422 Nod13Flag |= NMskEdge;
2426 Nod23Flag |= NMskOutL;
2427 Nod23Flag |= NMskEdge;
2431 Nod14Flag |= NMskOutL;
2432 Nod14Flag |= NMskEdge;
2436 Nod24Flag |= NMskOutL;
2437 Nod24Flag |= NMskEdge;
2438 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2439 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2440 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2441 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2442 pid2->UpdateLinks(i2p3,i2p2,i2p4,
2443 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2444 pid1->UpdateLinks(i1p3,i1p2,i1p4,
2445 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2446 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2447 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2448 UpdateAroundNode(i1p4,Nod14Indices,TData1,PISeg1,PINod1);
2449 UpdateAroundNode(i2p4,Nod24Indices,TData2,PISeg2,PINod2);
2450 List.Prepend(HLRAlgo_BiPoint
2451 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2452 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2453 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2454 List.Prepend(HLRAlgo_BiPoint
2455 (XTI3,YTI3,ZTI3,XTI4,YTI4,ZTI4,
2456 X3 ,Y3 ,Z3 ,X4 ,Y4 ,Z4 , e,
2457 i1 ,i1p3,i1p4,i2 ,i2p3,i2p4,flag));
2458 List.Prepend(HLRAlgo_BiPoint
2459 (XTI4,YTI4,ZTI4,XTI2,YTI2,ZTI2,
2460 X4 ,Y4 ,Z4 ,X2 ,Y2 ,Z2 , e,
2461 i1 ,i1p4,i1p2,i2 ,i2p4,i2p2,flag));
2465 List.Prepend(HLRAlgo_BiPoint
2466 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2467 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2468 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2471 //=======================================================================
2472 //function : InsertOnOutLine
2474 //=======================================================================
2477 HLRBRep_PolyAlgo::InsertOnOutLine (TColStd_Array1OfTransient& PID)
2479 Standard_Address TData2 = 0;
2480 Standard_Address PISeg2 = 0;
2481 Standard_Address PINod2 = 0;
2482 Standard_Address Seg1Indices;
2483 Standard_Address Nod1Indices,Nod1RValues;
2484 Standard_Address Nod2Indices,Nod2RValues;
2485 Handle(HLRAlgo_PolyInternalData)* pid =
2486 (Handle(HLRAlgo_PolyInternalData)*) (&(PID.ChangeValue(1)));
2489 Standard_Boolean insP3,mP3P1,IntOutL;
2490 Standard_Integer f,ip1,ip2,ip3;//, i;
2491 Standard_Real U3,V3,coef3,X3 = 0.,Y3 = 0.,Z3 = 0.;
2493 const gp_Trsf& T = myProj.Transformation();
2495 Standard_Integer nbFace = myFMap.Extent();
2496 for (f = 1; f <= nbFace; f++) {
2498 if (!((*pid).IsNull())) {
2499 IntOutL = Standard_False;
2500 Standard_Address TData1= &((*pid)->TData());
2501 Standard_Address PISeg1= &((*pid)->PISeg());
2502 Standard_Address PINod1= &((*pid)->PINod());
2503 TopoDS_Shape LocalShape = myFMap(f);
2504 const TopoDS_Face& F = TopoDS::Face(LocalShape);
2505 myBSurf.Initialize(F,Standard_False);
2506 myGSurf = BRep_Tool::Surface(F,L);
2507 gp_Trsf TT = L.Transformation();
2509 const gp_XYZ& ttlo = TT.TranslationPart();
2513 const gp_Mat& ttma = TT.VectorialPart();
2514 TTMa[0][0] = ttma.Value(1,1);
2515 TTMa[0][1] = ttma.Value(1,2);
2516 TTMa[0][2] = ttma.Value(1,3);
2517 TTMa[1][0] = ttma.Value(2,1);
2518 TTMa[1][1] = ttma.Value(2,2);
2519 TTMa[1][2] = ttma.Value(2,3);
2520 TTMa[2][0] = ttma.Value(3,1);
2521 TTMa[2][1] = ttma.Value(3,2);
2522 TTMa[2][2] = ttma.Value(3,3);
2526 cout << " InsertOnOutLine : NbTData " << (*pid)->NbTData() << endl;
2527 cout << " InsertOnOutLine : NbPISeg " << (*pid)->NbPISeg() << endl;
2528 cout << " InsertOnOutLine : NbPINod " << (*pid)->NbPINod() << endl;
2532 Standard_Integer iseg,nbS;
2533 nbS = (*pid)->NbPISeg();
2534 for (iseg = 1; iseg <= nbS; iseg++) {
2536 ((HLRAlgo_Array1OfPISeg*)PISeg1)->ChangeValue(iseg).Indices();
2537 // Standard_Boolean Cutted = Standard_False;
2538 if (Seg1Conex1 != 0 && Seg1Conex2 != 0) {
2541 const Handle(HLRAlgo_PolyInternalNode)* pip1 =
2542 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip1));
2543 Nod1Indices = (*pip1)->Indices();
2544 Nod1RValues = (*pip1)->RValues();
2545 const Handle(HLRAlgo_PolyInternalNode)* pip2 =
2546 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip2));
2547 Nod2Indices = (*pip2)->Indices();
2548 Nod2RValues = (*pip2)->RValues();
2549 if (Nod1Flag & NMskOutL && Nod2Flag & NMskOutL)
2550 IntOutL = Standard_True;
2551 else if ((Nod1Scal >= myTolAngular &&
2552 Nod2Scal <= -myTolAngular) ||
2553 (Nod2Scal >= myTolAngular &&
2554 Nod1Scal <= -myTolAngular)) {
2555 IntOutL = Standard_True;
2556 insP3 = NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1);
2558 UVNode(Nod1RValues,Nod2RValues,coef3,U3,V3);
2559 const gp_Pnt& PT3 = myGSurf->Value(U3,V3);
2563 TTMultiply(X3,Y3,Z3);
2566 if (insP3 && mP3P1) { // P1 ---> P3
2567 if ((Nod1Flag & NMskEdge) == 0 && coef3 < myTolSta) {
2568 insP3 = Standard_False;
2570 Nod1Indices,Nod1RValues,
2571 Nod2Indices,Nod2RValues,
2572 coef3,X3,Y3,Z3,Standard_True,
2573 TData1,PISeg1,PINod1);
2575 Nod1Flag |= NMskOutL;
2578 if (insP3 && !mP3P1) { // P2 ---> P3
2579 if ((Nod2Flag & NMskEdge) == 0 && coef3 > myTolEnd) {
2580 insP3 = Standard_False;
2582 Nod1Indices,Nod1RValues,
2583 Nod2Indices,Nod2RValues,
2584 coef3,X3,Y3,Z3,Standard_False,
2585 TData1,PISeg1,PINod1);
2587 Nod2Flag |= NMskOutL;
2590 if (insP3) { // p1 ip3 p2
2591 ip3 = (*pid)->AddNode(Nod1RValues,Nod2RValues,PINod1,PINod2,
2593 const Handle(HLRAlgo_PolyInternalNode)* pip3 =
2594 (&((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip3));
2595 const Standard_Address Nod3Indices = (*pip3)->Indices();
2596 const Standard_Address Nod3RValues = (*pip3)->RValues();
2597 (*pid)->UpdateLinks(ip1,ip2,ip3,
2598 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2599 UpdateAroundNode(ip3,Nod3Indices,TData1,PISeg1,PINod1);
2601 Nod3Flag |= NMskOutL;
2607 (*pid)->IntOutL(Standard_True);
2609 nbS = (*pid)->NbPISeg();
2613 cout << " InsertOnOutLine : NbTData " << (*pid)->NbTData() << endl;
2614 cout << " InsertOnOutLine : NbPISeg " << (*pid)->NbPISeg() << endl;
2615 cout << " InsertOnOutLine : NbPINod " << (*pid)->NbPINod() << endl;
2623 //=======================================================================
2624 //function : CheckFrBackTriangles
2626 //=======================================================================
2629 HLRBRep_PolyAlgo::CheckFrBackTriangles (HLRAlgo_ListOfBPoint& List,
2630 TColStd_Array1OfTransient& PID)
2632 Standard_Integer f,i,nbN,nbT,nbFace;
2633 Standard_Real X1 =0.,Y1 =0.,X2 =0.,Y2 =0.,X3 =0.,Y3 =0.;
2634 Standard_Real D1,D2,D3;
2635 Standard_Real dd,dX,dY,nX,nY;
2636 Standard_Boolean FrBackInList;
2637 Standard_Address TData ,PISeg ,PINod ;
2638 /* Standard_Address IndexPtr = NULL;
2639 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2640 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2641 Standard_Address TData1 = &pid1->TData(),
2642 PISeg1 = &pid1->PISeg(),
2643 PINod1 = &pid1->PINod();
2645 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2646 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2647 Standard_Address TData2 = &pid2->TData(),
2648 PISeg2 = &pid2->PISeg(),
2649 PINod2 = &pid2->PISeg();*/
2650 Standard_Address TData1 = NULL,PISeg1 = NULL,PINod1 = NULL;
2651 Standard_Address TData2 = NULL,PISeg2 = NULL,PINod2 = NULL;
2652 Standard_Address Nod11Indices,Nod12Indices,Nod13Indices;
2653 Standard_Address Nod11RValues,Nod12RValues,Nod13RValues;
2654 Standard_Address Tri1Indices;
2656 Handle(HLRAlgo_PolyInternalData)* pid;
2658 nbFace = myFMap.Extent();
2659 Standard_Boolean Modif = Standard_True;
2660 Standard_Integer iLoop = 0;
2662 while (Modif && iLoop < 4) {
2664 Modif = Standard_False;
2665 FrBackInList = Standard_False;
2666 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2668 for (f = 1; f <= nbFace; f++) {
2669 if (!(*pid).IsNull()) {
2670 nbT = (*pid)->NbTData();
2671 TData = &(*pid)->TData();
2672 PISeg = &(*pid)->PISeg();
2673 PINod = &(*pid)->PINod();
2674 HLRAlgo_TriangleData* tdata =
2675 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
2677 for (i = 1; i <= nbT; i++) {
2678 Tri1Indices = tdata->Indices();
2679 if ((Tri1Flags & FMskSide) == 0 &&
2680 (Tri1Flags & FMskFrBack)) {
2683 cout << " face : " << f << " , triangle " << i << endl;
2685 Modif = Standard_True;
2686 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
2687 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
2688 Nod11Indices = (*pi1p1)->Indices();
2689 Nod11RValues = (*pi1p1)->RValues();
2690 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
2691 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
2692 Nod12Indices = (*pi1p2)->Indices();
2693 Nod12RValues = (*pi1p2)->RValues();
2694 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2695 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
2696 Nod13Indices = (*pi1p3)->Indices();
2697 Nod13RValues = (*pi1p3)->RValues();
2698 D1 = 0.; D2 = 0.; D3 = 0.;
2699 if (((Nod11Flag & NMskEdge) == 0 || iLoop > 1) &&
2700 ((Nod11Flag & NMskOutL) == 0 || iLoop > 1) &&
2701 ((Nod11Flag & NMskVert) == 0)) {
2702 dX = Nod13PntX - Nod12PntX; dY = Nod13PntY - Nod12PntY;
2703 D1 = dX * dX + dY * dY;
2705 nX = - dY / D1; nY = dX / D1;
2706 dX = Nod11PntX - Nod12PntX; dY = Nod11PntY - Nod12PntY;
2707 dd = - (dX * nX + dY * nY);
2708 if (dd < 0) dd -= D1 * 0.01;
2709 else dd += D1 * 0.01;
2710 X1 = nX * dd; Y1 = nY * dd;
2712 if (((Nod12Flag & NMskEdge) == 0 || iLoop > 1) &&
2713 ((Nod12Flag & NMskOutL) == 0 || iLoop > 1) &&
2714 ((Nod12Flag & NMskVert) == 0)) {
2715 dX = Nod11PntX - Nod13PntX; dY = Nod11PntY - Nod13PntY;
2716 D2 = dX * dX + dY * dY;
2718 nX = - dY / D2; nY = dX / D2;
2719 dX = Nod12PntX - Nod13PntX; dY = Nod12PntY - Nod13PntY;
2720 dd = - (dX * nX + dY * nY);
2721 if (dd < 0) dd -= D2 * 0.01;
2722 else dd += D2 * 0.01;
2723 X2 = nX * dd; Y2 = nY * dd;
2725 if (((Nod13Flag & NMskEdge) == 0 || iLoop > 1) &&
2726 ((Nod13Flag & NMskOutL) == 0 || iLoop > 1) &&
2727 ((Nod13Flag & NMskVert) == 0)) {
2728 dX = Nod12PntX - Nod11PntX; dY = Nod12PntY - Nod11PntY;
2729 D3 = dX * dX + dY * dY;
2731 nX = - dY / D3; nY = dX / D3;
2732 dX = Nod13PntX - Nod11PntX; dY = Nod13PntY - Nod11PntY;
2733 dd = - (dX * nX + dY * nY);
2734 if (dd < 0) dd -= D3 * 0.01;
2735 else dd += D3 * 0.01;
2736 X3 = nX * dd; Y3 = nY * dd;
2738 if (D1 > D2 && D1 > D3) {
2739 Nod11PntX += X1; Nod11PntY += Y1;
2740 Nod11Flag |= NMskMove;
2741 UpdateAroundNode(Tri1Node1,Nod11Indices,TData,PISeg,PINod);
2742 FrBackInList = Standard_True;
2745 cout << Tri1Node1 << " modifies : DX,DY ";
2746 cout << X1 << " , " << Y1 << endl;
2750 else if (D2 > D3 && D2 > D1) {
2751 Nod12PntX += X2; Nod12PntY += Y2;
2752 Nod12Flag |= NMskMove;
2753 UpdateAroundNode(Tri1Node2,Nod12Indices,TData,PISeg,PINod);
2754 FrBackInList = Standard_True;
2757 cout << Tri1Node2 << " modifies : DX,DY ";
2758 cout << X2 << " , " << Y2 << endl;
2762 else if (D3 > D1 && D3 > D2) {
2763 Nod13PntX += X3; Nod13PntY += Y3;
2764 Nod13Flag |= NMskMove;
2765 UpdateAroundNode(Tri1Node3,Nod13Indices,TData,PISeg,PINod);
2766 FrBackInList = Standard_True;
2769 cout << Tri1Node3 << " modifies : DX,DY ";
2770 cout << X3 << " , " << Y3 << endl;
2776 cout << "modification error" << endl;
2785 Standard_Address IndexPtr,Coordinates;
2786 HLRAlgo_ListIteratorOfListOfBPoint it;
2788 for (it.Initialize(List); it.More(); it.Next()) {
2789 HLRAlgo_BiPoint& BP = it.Value();
2790 IndexPtr = BP.Indices();
2792 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2793 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2794 TData1 = &pid1->TData();
2795 PISeg1 = &pid1->PISeg();
2796 PINod1 = &pid1->PINod();
2799 if (F1Index == F2Index) {
2805 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2806 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2807 TData2 = &pid2->TData();
2808 PISeg2 = &pid2->PISeg();
2809 PINod2 = &pid2->PINod();
2813 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2814 ChangeValue(F1Pt1Index))->Indices();
2815 if (Nod11Flag & NMskMove) {
2818 cout << F1Pt1Index << " modifies 11" << endl;
2820 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2821 ChangeValue(F1Pt1Index))->RValues();
2822 Coordinates = BP.Coordinates();
2823 PntXTI1 = PntX1 = Nod11PntX;
2824 PntYTI1 = PntY1 = Nod11PntY;
2825 PntZTI1 = PntZ1 = Nod11PntZ;
2826 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2828 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2829 ChangeValue(F2Pt1Index))->Indices();
2830 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2831 ChangeValue(F2Pt1Index))->RValues();
2832 Nod12PntX = Nod11PntX;
2833 Nod12PntY = Nod11PntY;
2834 UpdateAroundNode(F2Pt1Index,Nod12Indices,
2835 TData2,PISeg2,PINod2);
2838 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2839 ChangeValue(F1Pt2Index))->Indices();
2840 if (Nod11Flag & NMskMove) {
2843 cout << F1Pt2Index << " modifies 12" << endl;
2845 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2846 ChangeValue(F1Pt2Index))->RValues();
2847 Coordinates = BP.Coordinates();
2848 PntXTI2 = PntX2 = Nod11PntX;
2849 PntYTI2 = PntY2 = Nod11PntY;
2850 PntZTI2 = PntZ2 = Nod11PntZ;
2851 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2853 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2854 ChangeValue(F2Pt2Index))->Indices();
2855 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2856 ChangeValue(F2Pt2Index))->RValues();
2857 Nod12PntX = Nod11PntX;
2858 Nod12PntY = Nod11PntY;
2859 UpdateAroundNode(F2Pt2Index,Nod12Indices,
2860 TData2,PISeg2,PINod2);
2865 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2866 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2867 PINod2 = &pid2->PINod();
2868 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2869 ChangeValue(F2Pt1Index))->Indices();
2870 if (Nod11Flag & NMskMove) {
2873 cout << F2Pt1Index << " modifies 21" << endl;
2875 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2876 ChangeValue(F2Pt1Index))->RValues();
2877 Coordinates = BP.Coordinates();
2878 PntXTI1 = PntX1 = Nod11PntX;
2879 PntYTI1 = PntY1 = Nod11PntY;
2880 PntZTI1 = PntZ1 = Nod11PntZ;
2881 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2883 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2884 ChangeValue(F1Pt1Index))->Indices();
2885 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2886 ChangeValue(F1Pt1Index))->RValues();
2887 Nod12PntX = Nod11PntX;
2888 Nod12PntY = Nod11PntY;
2889 UpdateAroundNode(F1Pt1Index,Nod12Indices,
2890 TData1,PISeg1,PINod1);
2893 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2894 ChangeValue(F2Pt2Index))->Indices();
2895 if (Nod11Flag & NMskMove) {
2898 cout << F2Pt2Index << " modifies 22" << endl;
2900 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2901 ChangeValue(F2Pt2Index))->RValues();
2902 Coordinates = BP.Coordinates();
2903 PntXTI2 = PntX2 = Nod11PntX;
2904 PntYTI2 = PntY2 = Nod11PntY;
2905 PntZTI2 = PntZ2 = Nod11PntZ;
2906 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2908 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2909 ChangeValue(F1Pt2Index))->Indices();
2910 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2911 ChangeValue(F1Pt2Index))->RValues();
2912 Nod12PntX = Nod11PntX;
2913 Nod12PntY = Nod11PntY;
2914 UpdateAroundNode(F1Pt2Index,Nod12Indices,
2915 TData1,PISeg1,PINod1);
2920 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2922 for (f = 1; f <= nbFace; f++) {
2923 if (!(*pid).IsNull()) {
2924 nbN = (*pid)->NbPINod();
2925 PINod = &(*pid)->PINod();
2926 Handle(HLRAlgo_PolyInternalNode)* NN =
2927 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
2929 for (i = 1; i <= nbN; i++) {
2930 Nod11Indices = (*NN)->Indices();
2931 Nod11Flag &= ~NMskMove;
2941 //=======================================================================
2942 //function : FindEdgeOnTriangle
2944 //=======================================================================
2948 FindEdgeOnTriangle (const Standard_Address Tri1Indices,
2949 const Standard_Integer ip1,
2950 const Standard_Integer ip2,
2951 Standard_Integer& jtrouv,
2952 Standard_Boolean& isDirect) const
2954 Standard_Integer n1 = Tri1Node1;
2955 Standard_Integer n2 = Tri1Node2;
2956 Standard_Integer n3 = Tri1Node3;
2957 if (ip1 == n1 && ip2 == n2) {
2959 isDirect = Standard_True;
2962 else if (ip2 == n1 && ip1 == n2) {
2964 isDirect = Standard_False;
2967 else if (ip1 == n2 && ip2 == n3) {
2969 isDirect = Standard_True;
2972 else if (ip2 == n2 && ip1 == n3) {
2974 isDirect = Standard_False;
2977 else if (ip1 == n3 && ip2 == n1) {
2979 isDirect = Standard_True;
2982 else if (ip2 == n3 && ip1 == n1) {
2984 isDirect = Standard_False;
2989 //=======================================================================
2990 //function : ChangeNode
2992 //=======================================================================
2994 void HLRBRep_PolyAlgo::ChangeNode (const Standard_Integer ip1,
2995 const Standard_Integer ip2,
2996 const Standard_Address Nod1Indices,
2997 const Standard_Address Nod1RValues,
2998 const Standard_Address Nod2Indices,
2999 const Standard_Address Nod2RValues,
3000 const Standard_Real coef1,
3001 const Standard_Real X3,
3002 const Standard_Real Y3,
3003 const Standard_Real Z3,
3004 const Standard_Boolean first,
3005 Standard_Address& TData,
3006 Standard_Address& PISeg,
3007 Standard_Address& PINod) const
3009 Standard_Real coef2 = 1 - coef1;
3014 Nod1PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3015 Nod1PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3016 Nod1Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3017 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3018 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3019 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3020 Standard_Real D = sqrt (x * x + y * y + z * z);
3032 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip1;
3033 cout << " and " << ip2 << endl;
3037 UpdateAroundNode(ip1,Nod1Indices,TData,PISeg,PINod);
3043 Nod2PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3044 Nod2PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3045 Nod2Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3046 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3047 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3048 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3049 Standard_Real D = sqrt (x * x + y * y + z * z);
3062 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip2;
3063 cout << " and " << ip1 << endl;
3067 UpdateAroundNode(ip2,Nod2Indices,TData,PISeg,PINod);
3071 //=======================================================================
3072 //function : UpdateAroundNode
3074 //=======================================================================
3076 void HLRBRep_PolyAlgo::
3077 UpdateAroundNode (const Standard_Integer iNode,
3078 const Standard_Address Nod1Indices,
3079 const Standard_Address TData,
3080 const Standard_Address PISeg,
3081 const Standard_Address PINod) const
3083 Standard_Integer iiii,iTri1,iTri2;
3087 const Standard_Address Seg1Indices =
3088 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3092 const Standard_Address Tri1Indices =
3093 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri1).Indices();
3094 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3095 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
3096 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3097 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
3098 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3099 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
3100 const Standard_Address Nod1Indices = (*PN1)->Indices();
3101 const Standard_Address Nod2Indices = (*PN2)->Indices();
3102 const Standard_Address Nod3Indices = (*PN3)->Indices();
3103 const Standard_Address Nod1RValues = (*PN1)->RValues();
3104 const Standard_Address Nod2RValues = (*PN2)->RValues();
3105 const Standard_Address Nod3RValues = (*PN3)->RValues();
3106 OrientTriangle(iTri1,Tri1Indices,
3107 Nod1Indices,Nod1RValues,
3108 Nod2Indices,Nod2RValues,
3109 Nod3Indices,Nod3RValues);
3112 const Standard_Address Tri2Indices =
3113 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri2).Indices();
3114 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3115 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1));
3116 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3117 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2));
3118 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3119 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3));
3120 const Standard_Address Nod1Indices = (*PN1)->Indices();
3121 const Standard_Address Nod2Indices = (*PN2)->Indices();
3122 const Standard_Address Nod3Indices = (*PN3)->Indices();
3123 const Standard_Address Nod1RValues = (*PN1)->RValues();
3124 const Standard_Address Nod2RValues = (*PN2)->RValues();
3125 const Standard_Address Nod3RValues = (*PN3)->RValues();
3126 OrientTriangle(iTri2,Tri2Indices,
3127 Nod1Indices,Nod1RValues,
3128 Nod2Indices,Nod2RValues,
3129 Nod3Indices,Nod3RValues);
3131 if (Seg1LstSg1 == iNode) iiii = Seg1NxtSg1;
3132 else iiii = Seg1NxtSg2;
3136 //=======================================================================
3137 //function : OrientTriangle
3139 //=======================================================================
3143 HLRBRep_PolyAlgo::OrientTriangle(const Standard_Integer iTri,
3145 HLRBRep_PolyAlgo::OrientTriangle(const Standard_Integer,
3147 const Standard_Address Tri1Indices,
3148 const Standard_Address Nod1Indices,
3149 const Standard_Address Nod1RValues,
3150 const Standard_Address Nod2Indices,
3151 const Standard_Address Nod2RValues,
3152 const Standard_Address Nod3Indices,
3153 const Standard_Address Nod3RValues) const
3155 Standard_Boolean o1 = Nod1Flag & NMskOutL;
3156 Standard_Boolean o2 = Nod2Flag & NMskOutL;
3157 Standard_Boolean o3 = Nod3Flag & NMskOutL;
3158 Tri1Flags &= ~FMskFlat;
3159 Tri1Flags &= ~FMskOnOutL;
3160 if (o1 && o2 && o3) {
3161 Tri1Flags |= FMskSide;
3162 Tri1Flags &= ~FMskBack;
3163 Tri1Flags |= FMskOnOutL;
3166 cout << "HLRBRep_PolyAlgo::OrientTriangle : OnOutL";
3167 cout << " triangle " << iTri << endl;
3172 Standard_Real s1 = Nod1Scal;
3173 Standard_Real s2 = Nod2Scal;
3174 Standard_Real s3 = Nod3Scal;
3175 Standard_Real as1 = s1;
3176 Standard_Real as2 = s2;
3177 Standard_Real as3 = s3;
3178 if (s1 < 0) as1 = -s1;
3179 if (s2 < 0) as2 = -s2;
3180 if (s3 < 0) as3 = -s3;
3181 Standard_Real s = 0;
3182 Standard_Real as = 0;
3183 if (!o1 ) {s = s1; as = as1;}
3184 if (!o2 && as < as2) {s = s2; as = as2;}
3185 if (!o3 && as < as3) {s = s3; as = as3;}
3187 Tri1Flags &= ~FMskSide;
3188 Tri1Flags |= FMskBack;
3191 Tri1Flags &= ~FMskSide;
3192 Tri1Flags &= ~FMskBack;
3194 Standard_Real dx12 = Nod2PntX - Nod1PntX;
3195 Standard_Real dy12 = Nod2PntY - Nod1PntY;
3196 Standard_Real dz12 = Nod2PntZ - Nod1PntZ;
3197 Standard_Real d12 = sqrt(dx12 * dx12 + dy12 * dy12 + dz12 * dz12);
3198 if (d12 <= 1.e-10) {
3201 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3202 cout << " triangle " << iTri << endl;
3205 Tri1Flags |= FMskFlat;
3206 Tri1Flags |= FMskSide;
3207 Tri1Flags &= ~FMskBack;
3210 Standard_Real dx23 = Nod3PntX - Nod2PntX;
3211 Standard_Real dy23 = Nod3PntY - Nod2PntY;
3212 Standard_Real dz23 = Nod3PntZ - Nod2PntZ;
3213 Standard_Real d23 = sqrt(dx23 * dx23 + dy23 * dy23 + dz23 * dz23);
3217 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3218 cout << " triangle " << iTri << endl;
3221 Tri1Flags |= FMskFlat;
3222 Tri1Flags |= FMskSide;
3223 Tri1Flags &= ~FMskBack;
3226 Standard_Real dx31 = Nod1PntX - Nod3PntX;
3227 Standard_Real dy31 = Nod1PntY - Nod3PntY;
3228 Standard_Real dz31 = Nod1PntZ - Nod3PntZ;
3229 Standard_Real d31 = sqrt(dx31 * dx31 + dy31 * dy31 + dz31 * dz31);
3233 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3234 cout << " triangle " << iTri << endl;
3237 Tri1Flags |= FMskFlat;
3238 Tri1Flags |= FMskSide;
3239 Tri1Flags &= ~FMskBack;
3248 Standard_Real dx = dy12 * dz23 - dz12 * dy23;
3249 Standard_Real dy = dz12 * dx23 - dx12 * dz23;
3250 Standard_Real dz = dx12 * dy23 - dy12 * dx23;
3251 Standard_Real d = sqrt(dx * dx + dy * dy + dz * dz);
3255 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3256 cout << " triangle " << iTri << endl;
3259 Tri1Flags |= FMskFlat;
3260 Tri1Flags |= FMskSide;
3261 Tri1Flags &= ~FMskBack;
3265 if (myProj.Perspective()) {
3269 o = ( dz * myProj.Focus()
3277 Tri1Flags |= FMskOrBack;
3281 Tri1Flags &= ~FMskOrBack;
3283 Tri1Flags |= FMskSide;
3284 Tri1Flags &= ~FMskBack;
3291 if ((!(Tri1Flags & FMskBack) && (Tri1Flags & FMskOrBack)) ||
3292 ( (Tri1Flags & FMskBack) && !(Tri1Flags & FMskOrBack)))
3293 Tri1Flags |= FMskFrBack;
3295 Tri1Flags &= ~FMskFrBack;
3298 //=======================================================================
3299 //function : Triangles
3301 //=======================================================================
3304 HLRBRep_PolyAlgo::Triangles(const Standard_Integer ip1,
3305 const Standard_Integer ip2,
3306 const Standard_Address Nod1Indices,
3307 Standard_Address& PISeg,
3308 Standard_Integer& iTri1,
3309 Standard_Integer& iTri2) const
3311 Standard_Address Seg1Indices;
3312 Standard_Integer iiii = Nod1NdSg;
3316 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3317 if (Seg1LstSg1 == ip1) {
3318 if (Seg1LstSg2 == ip2) {
3321 return Standard_True;
3323 else iiii = Seg1NxtSg1;
3326 if (Seg1LstSg1 == ip2) {
3329 return Standard_True;
3331 else iiii = Seg1NxtSg2;
3338 cout << "HLRBRep_PolyAlgo::Triangles : error";
3339 cout << " between " << ip1 << " and " << ip2 << endl;
3342 return Standard_False;
3345 //=======================================================================
3346 //function : NewNode
3348 //=======================================================================
3352 NewNode (const Standard_Address Nod1RValues,
3353 const Standard_Address Nod2RValues,
3354 Standard_Real& coef1,
3355 Standard_Boolean& moveP1) const
3357 Standard_Real TolAng = myTolAngular * 0.5;
3358 if ((Nod1Scal >= TolAng && Nod2Scal <= -TolAng) ||
3359 (Nod2Scal >= TolAng && Nod1Scal <= -TolAng)) {
3360 coef1 = Nod1Scal / ( Nod2Scal - Nod1Scal );
3361 if (coef1 < 0) coef1 = - coef1;
3362 moveP1 = coef1 < 0.5;
3363 return Standard_True;
3365 return Standard_False;
3368 //=======================================================================
3371 //=======================================================================
3374 HLRBRep_PolyAlgo::UVNode (const Standard_Address Nod1RValues,
3375 const Standard_Address Nod2RValues,
3376 const Standard_Real coef1,
3378 Standard_Real& V3) const
3380 Standard_Real coef2 = 1 - coef1;
3381 U3 = Nod1PntU * coef2 + Nod2PntU * coef1;
3382 V3 = Nod1PntV * coef2 + Nod2PntV * coef1;
3385 //=======================================================================
3386 //function : CheckDegeneratedSegment
3388 //=======================================================================
3392 CheckDegeneratedSegment(const Standard_Address Nod1Indices,
3393 const Standard_Address Nod1RValues,
3394 const Standard_Address Nod2Indices,
3395 const Standard_Address Nod2RValues) const
3397 Nod1Flag |= NMskFuck;
3398 Nod2Flag |= NMskFuck;
3399 if ((Nod1Scal >= myTolAngular && Nod2Scal <= -myTolAngular) ||
3400 (Nod2Scal >= myTolAngular && Nod1Scal <= -myTolAngular)) {
3402 Nod1Flag |= NMskOutL;
3404 Nod2Flag |= NMskOutL;
3408 //=======================================================================
3409 //function : UpdateOutLines
3411 //=======================================================================
3414 HLRBRep_PolyAlgo::UpdateOutLines (HLRAlgo_ListOfBPoint& List,
3415 TColStd_Array1OfTransient& PID)
3418 Standard_Integer nbFace = myFMap.Extent();
3419 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
3420 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
3422 Handle(HLRAlgo_PolyInternalData)* pid =
3423 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3425 for (f = 1; f <= nbFace; f++) {
3426 if (!(*pid).IsNull()) {
3427 if ((*pid)->IntOutL()) {
3428 Standard_Address TData = &((*pid)->TData());
3429 Standard_Address PISeg = &((*pid)->PISeg());
3430 Standard_Address PINod = &((*pid)->PINod());
3431 Standard_Integer i,j,it1,it2,tn1,tn2,tn3,pd,pf;
3432 Standard_Address Seg2Indices,Tri1Indices,Tri2Indices;
3433 Standard_Boolean outl;
3434 Standard_Integer nbS = (*pid)->NbPISeg();
3435 HLRAlgo_PolyInternalSegment* psg =
3436 &(((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(1));
3438 for (i = 1; i <= nbS; i++) {
3439 Seg2Indices = psg->Indices();
3442 if (it1 != 0 && it2 != 0 && it1 != it2) { // debile but sure !
3443 Tri1Indices = ((HLRAlgo_Array1OfTData*)TData)->
3444 ChangeValue(it1).Indices();
3445 Tri2Indices = ((HLRAlgo_Array1OfTData*)TData)->
3446 ChangeValue(it2).Indices();
3447 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3448 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3449 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3450 outl = Standard_False;
3451 else if ( Tri1Flags & FMskSide)
3452 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3454 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3462 if (!(Tri1Flags & FMskSide) && (Tri1Flags & FMskOrBack)) {
3467 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3468 Tri1Flags |= EMskOutLin1;
3469 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3470 Tri1Flags |= EMskOutLin2;
3471 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3472 Tri1Flags |= EMskOutLin3;
3475 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3476 cout << " : segment not found" << endl;
3482 if (!(Tri2Flags & FMskSide) && (Tri2Flags & FMskOrBack)) {
3487 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3488 Tri2Flags |= EMskOutLin1;
3489 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3490 Tri2Flags |= EMskOutLin2;
3491 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3492 Tri2Flags |= EMskOutLin3;
3495 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3496 cout << " : segment not found" << endl;
3499 Standard_Address Nod1RValues =
3500 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pd)->RValues();
3501 Standard_Address Nod2RValues =
3502 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pf)->RValues();
3503 XTI1 = X1 = Nod1PntX;
3504 YTI1 = Y1 = Nod1PntY;
3505 ZTI1 = Z1 = Nod1PntZ;
3506 XTI2 = X2 = Nod2PntX;
3507 YTI2 = Y2 = Nod2PntY;
3508 ZTI2 = Z2 = Nod2PntZ;
3509 TIMultiply(XTI1,YTI1,ZTI1);
3510 TIMultiply(XTI2,YTI2,ZTI2);
3511 List.Append(HLRAlgo_BiPoint(XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
3512 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
3513 f,f,pd,pf,f,pd,pf,12));
3524 //=======================================================================
3525 //function : UpdateEdgesBiPoints
3527 //=======================================================================
3529 void HLRBRep_PolyAlgo::
3530 UpdateEdgesBiPoints (HLRAlgo_ListOfBPoint& List,
3531 const TColStd_Array1OfTransient& PID,
3532 const Standard_Boolean closed)
3534 Standard_Integer itri1,itri2,tbid;
3535 HLRAlgo_ListIteratorOfListOfBPoint it;
3537 for (it.Initialize(List); it.More(); it.Next()) {
3538 HLRAlgo_BiPoint& BP = it.Value();
3539 // Standard_Integer i[5];
3540 Standard_Address IndexPtr = BP.Indices();
3541 if (F1Index != 0 && F2Index != 0) {
3542 const Handle(HLRAlgo_PolyInternalData)& pid1 =
3543 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
3544 const Handle(HLRAlgo_PolyInternalData)& pid2 =
3545 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
3546 Standard_Address PISeg1 = &pid1->PISeg();
3547 Standard_Address PISeg2 = &pid2->PISeg();
3548 Standard_Address Nod11Indices =
3549 pid1->PINod().ChangeValue(F1Pt1Index)->Indices();
3550 Standard_Address Nod21Indices =
3551 pid2->PINod().ChangeValue(F2Pt1Index)->Indices();
3552 Triangles(F1Pt1Index,F1Pt2Index,Nod11Indices,PISeg1,itri1,tbid);
3553 Triangles(F2Pt1Index,F2Pt2Index,Nod21Indices,PISeg2,itri2,tbid);
3555 if (itri1 != 0 && itri2 != 0) {
3556 if (F1Index != F2Index || itri1 != itri2) {
3557 Standard_Address TData1 = &pid1->TData();
3558 Standard_Address TData2 = &pid2->TData();
3559 Standard_Address Tri1Indices =
3560 ((HLRAlgo_Array1OfTData*)TData1)->ChangeValue(itri1).Indices();
3561 Standard_Address Tri2Indices =
3562 ((HLRAlgo_Array1OfTData*)TData2)->ChangeValue(itri2).Indices();
3564 if (((Tri1Flags & FMskBack) && (Tri2Flags & FMskBack)) ||
3565 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskSide)) ||
3566 ((Tri1Flags & FMskBack) && (Tri2Flags & FMskSide)) ||
3567 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskBack)))
3568 BP.Hidden(Standard_True);
3570 Standard_Boolean outl;
3571 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3572 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3573 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3574 outl = Standard_False;
3575 else if ( (Tri1Flags & FMskSide))
3576 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3578 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3584 cout << "HLRBRep_PolyAlgo::UpdateEdgesBiPoints : error ";
3585 cout << " between " << F1Index << setw(6);
3586 cout << " and " << F2Index << endl;
3593 //=======================================================================
3594 //function : UpdatePolyData
3596 //=======================================================================
3599 HLRBRep_PolyAlgo::UpdatePolyData (TColStd_Array1OfTransient& PD,
3600 TColStd_Array1OfTransient& PID,
3601 const Standard_Boolean closed)
3603 Standard_Integer f,i;//,n[3];
3604 Handle(TColgp_HArray1OfXYZ) HNodes;
3605 Handle(HLRAlgo_HArray1OfTData) HTData;
3606 Handle(HLRAlgo_HArray1OfPHDat) HPHDat;
3607 Standard_Integer nbFace = myFMap.Extent();
3608 Handle(HLRAlgo_PolyInternalData)* pid =
3609 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3610 Handle(HLRAlgo_PolyData)* pd =
3611 (Handle(HLRAlgo_PolyData)*)&(PD.ChangeValue(1));
3613 for (f = 1; f <= nbFace; f++) {
3614 if (!(*pid).IsNull()) {
3615 Standard_Integer nbN = (*pid)->NbPINod();
3616 Standard_Integer nbT = (*pid)->NbTData();
3617 HNodes = new TColgp_HArray1OfXYZ (1,nbN);
3618 HTData = new HLRAlgo_HArray1OfTData(1,nbT);
3619 TColgp_Array1OfXYZ& Nodes = HNodes->ChangeArray1();
3620 HLRAlgo_Array1OfTData& Trian = HTData->ChangeArray1();
3621 Standard_Address TData = &(*pid)->TData();
3622 Standard_Address PINod = &(*pid)->PINod();
3623 Standard_Integer nbHide = 0;
3624 Handle(HLRAlgo_PolyInternalNode)* ON =
3625 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
3626 gp_XYZ * NN = &(Nodes.ChangeValue(1));
3628 for (i = 1; i <= nbN; i++) {
3629 const Standard_Address Nod1RValues = (*ON)->RValues();
3630 NN->SetCoord(Nod1PntX,Nod1PntY,Nod1PntZ);
3635 HLRAlgo_TriangleData* OT =
3636 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
3637 HLRAlgo_TriangleData* NT = &(Trian.ChangeValue(1));
3638 Standard_Address Tri1Indices,Tri2Indices;
3640 for (i = 1; i <= nbT; i++) {
3641 Tri1Indices = OT->Indices();
3642 Tri2Indices = NT->Indices();
3643 if (!(Tri1Flags & FMskSide)) {
3645 if ((Tri1Flags & FMskFrBack) && DoTrace) {
3646 cout << "HLRBRep_PolyAlgo::ReverseBackTriangle :";
3647 cout << " face " << f << setw(6);
3648 cout << " triangle " << i << endl;
3651 if (Tri1Flags & FMskOrBack) {
3652 Standard_Integer j = Tri1Node1;
3653 Tri1Node1 = Tri1Node3;
3655 Tri1Flags |= FMskBack;
3658 Tri1Flags &= ~FMskBack;
3659 //Tri1Flags |= FMskBack;//OCC349
3661 Tri2Node1 = Tri1Node1;
3662 Tri2Node2 = Tri1Node2;
3663 Tri2Node3 = Tri1Node3;
3664 Tri2Flags = Tri1Flags;
3665 if (!(Tri2Flags & FMskSide) &&
3666 (!(Tri2Flags & FMskBack) || !closed)) {
3667 Tri2Flags |= FMskHiding;
3671 Tri2Flags &= ~FMskHiding;
3675 if (nbHide > 0) HPHDat = new HLRAlgo_HArray1OfPHDat(1,nbHide);
3676 else HPHDat.Nullify();
3677 (*pd)->HNodes(HNodes);
3678 (*pd)->HTData(HTData);
3679 (*pd)->HPHDat(HPHDat);
3680 (*pd)->FaceIndex(f);
3687 //=======================================================================
3688 //function : TMultiply
3690 //=======================================================================
3693 HLRBRep_PolyAlgo::TMultiply (Standard_Real& X,
3696 const Standard_Boolean VPO) const
3698 Standard_Real Xt = TMat[0][0]*X + TMat[0][1]*Y + TMat[0][2]*Z + (VPO ? 0 : TLoc[0]);//OCC349
3699 Standard_Real Yt = TMat[1][0]*X + TMat[1][1]*Y + TMat[1][2]*Z + (VPO ? 0 : TLoc[1]);//OCC349
3700 Z = TMat[2][0]*X + TMat[2][1]*Y + TMat[2][2]*Z + (VPO ? 0 : TLoc[2]);//OCC349
3705 //=======================================================================
3706 //function : TTMultiply
3708 //=======================================================================
3711 HLRBRep_PolyAlgo::TTMultiply (Standard_Real& X,
3714 const Standard_Boolean VPO) const
3716 Standard_Real Xt = TTMa[0][0]*X + TTMa[0][1]*Y + TTMa[0][2]*Z + (VPO ? 0 : TTLo[0]);//OCC349
3717 Standard_Real Yt = TTMa[1][0]*X + TTMa[1][1]*Y + TTMa[1][2]*Z + (VPO ? 0 : TTLo[1]);//OCC349
3718 Z = TTMa[2][0]*X + TTMa[2][1]*Y + TTMa[2][2]*Z + (VPO ? 0 : TTLo[2]);//OCC349
3723 //=======================================================================
3724 //function : TIMultiply
3726 //=======================================================================
3729 HLRBRep_PolyAlgo::TIMultiply (Standard_Real& X,
3732 const Standard_Boolean VPO) const
3734 Standard_Real Xt = TIMa[0][0]*X + TIMa[0][1]*Y + TIMa[0][2]*Z + (VPO ? 0 : TILo[0]);//OCC349
3735 Standard_Real Yt = TIMa[1][0]*X + TIMa[1][1]*Y + TIMa[1][2]*Z + (VPO ? 0 : TILo[1]);//OCC349
3736 Z = TIMa[2][0]*X + TIMa[2][1]*Y + TIMa[2][2]*Z + (VPO ? 0 : TILo[2]);//OCC349
3741 //=======================================================================
3744 //=======================================================================
3746 void HLRBRep_PolyAlgo::Hide (Standard_Address& Coordinates,
3747 HLRAlgo_EdgeStatus& status,
3749 Standard_Boolean& reg1,
3750 Standard_Boolean& regn,
3751 Standard_Boolean& outl,
3752 Standard_Boolean& intl)
3754 Standard_Integer index;
3755 myAlgo->Hide(Coordinates,status,index,reg1,regn,outl,intl);
3756 if (intl) S = myFMap(index);
3757 else S = myEMap(index);
3760 //=======================================================================
3763 //=======================================================================
3765 void HLRBRep_PolyAlgo::Show (Standard_Address& Coordinates,
3767 Standard_Boolean& reg1,
3768 Standard_Boolean& regn,
3769 Standard_Boolean& outl,
3770 Standard_Boolean& intl)
3772 Standard_Integer index;
3773 myAlgo->Show(Coordinates,index,reg1,regn,outl,intl);
3774 if (intl) S = myFMap(index);
3775 else S = myEMap(index);
3778 //=======================================================================
3779 //function : OutLinedShape
3781 //=======================================================================
3784 HLRBRep_PolyAlgo::OutLinedShape (const TopoDS_Shape& S) const
3786 TopoDS_Shape Result;
3790 B.MakeCompound(TopoDS::Compound(Result));
3793 TopTools_MapOfShape Map;
3795 for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next())
3796 Map.Add(ex.Current());
3797 for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next())
3798 Map.Add(ex.Current());
3800 Standard_Integer nbFace = myFMap.Extent();
3802 TopTools_Array1OfShape NewF(1,nbFace);
3803 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
3804 Standard_Integer nbShell = Shell.Upper();
3805 HLRAlgo_ListIteratorOfListOfBPoint it;
3807 for (Standard_Integer iShell = 1; iShell <= nbShell; iShell++) {
3808 HLRAlgo_ListOfBPoint& List =
3809 (*(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell)))->Edges();
3811 for (it.Initialize(List); it.More(); it.Next()) {
3812 HLRAlgo_BiPoint& BP = it.Value();
3814 Standard_Address IndexPtr = BP.Indices();
3815 if (Map.Contains(myFMap(ShapeIndex))) {
3816 Standard_Address Coordinates = BP.Coordinates();
3817 B.Add(Result,BRepLib_MakeEdge
3818 (gp_Pnt(PntXTI1,PntYTI1,PntZTI1),
3819 gp_Pnt(PntXTI2,PntYTI2,PntZTI2)));