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 <BRep_Builder.hxx>
21 #include <BRep_Tool.hxx>
22 #include <BRepLib_MakeEdge.hxx>
24 #include <CSLib_DerivativeStatus.hxx>
25 #include <CSLib_NormalStatus.hxx>
26 #include <Geom_RectangularTrimmedSurface.hxx>
27 #include <Geom_Surface.hxx>
29 #include <HLRAlgo_BiPoint.hxx>
30 #include <HLRAlgo_EdgeStatus.hxx>
31 #include <HLRAlgo_ListIteratorOfListOfBPoint.hxx>
32 #include <HLRAlgo_PolyAlgo.hxx>
33 #include <HLRAlgo_PolyData.hxx>
34 #include <HLRAlgo_PolyInternalData.hxx>
35 #include <HLRAlgo_PolyShellData.hxx>
36 #include <HLRAlgo_Projector.hxx>
37 #include <HLRBRep_PolyAlgo.hxx>
38 #include <Poly_Polygon3D.hxx>
39 #include <Poly_PolygonOnTriangulation.hxx>
40 #include <Poly_Triangulation.hxx>
41 #include <Precision.hxx>
42 #include <Standard_ErrorHandler.hxx>
43 #include <Standard_OutOfRange.hxx>
44 #include <Standard_Stream.hxx>
45 #include <Standard_Type.hxx>
46 #include <TColStd_HArray1OfInteger.hxx>
47 #include <TColStd_HArray1OfTransient.hxx>
49 #include <TopExp_Explorer.hxx>
51 #include <TopoDS_Edge.hxx>
52 #include <TopoDS_Shape.hxx>
53 #include <TopTools_Array1OfShape.hxx>
54 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
55 #include <TopTools_ListIteratorOfListOfShape.hxx>
57 #define EMskOutLin1 ((Standard_Boolean) 1)
58 #define EMskOutLin2 ((Standard_Boolean) 2)
59 #define EMskOutLin3 ((Standard_Boolean) 4)
60 #define EMskGrALin1 ((Standard_Boolean) 8)
61 #define EMskGrALin2 ((Standard_Boolean) 16)
62 #define EMskGrALin3 ((Standard_Boolean) 32)
63 #define FMskBack ((Standard_Boolean) 64)
64 #define FMskSide ((Standard_Boolean) 128)
65 #define FMskHiding ((Standard_Boolean) 256)
66 #define FMskFlat ((Standard_Boolean) 512)
67 #define FMskOnOutL ((Standard_Boolean)1024)
68 #define FMskOrBack ((Standard_Boolean)2048)
69 #define FMskFrBack ((Standard_Boolean)4096)
71 #define NMskVert ((Standard_Boolean) 1)
72 #define NMskOutL ((Standard_Boolean) 2)
73 #define NMskNorm ((Standard_Boolean) 4)
74 #define NMskFuck ((Standard_Boolean) 8)
75 #define NMskEdge ((Standard_Boolean)16)
76 #define NMskMove ((Standard_Boolean)32)
78 #define PntXTI1 ((Standard_Real*)Coordinates)[ 0]
79 #define PntYTI1 ((Standard_Real*)Coordinates)[ 1]
80 #define PntZTI1 ((Standard_Real*)Coordinates)[ 2]
81 #define PntXTI2 ((Standard_Real*)Coordinates)[ 3]
82 #define PntYTI2 ((Standard_Real*)Coordinates)[ 4]
83 #define PntZTI2 ((Standard_Real*)Coordinates)[ 5]
84 #define PntX1 ((Standard_Real*)Coordinates)[ 6]
85 #define PntY1 ((Standard_Real*)Coordinates)[ 7]
86 #define PntZ1 ((Standard_Real*)Coordinates)[ 8]
87 #define PntX2 ((Standard_Real*)Coordinates)[ 9]
88 #define PntY2 ((Standard_Real*)Coordinates)[10]
89 #define PntZ2 ((Standard_Real*)Coordinates)[11]
91 #define Pn2XTI1 ((Standard_Real*)Coordinate2)[ 0]
92 #define Pn2YTI1 ((Standard_Real*)Coordinate2)[ 1]
93 #define Pn2ZTI1 ((Standard_Real*)Coordinate2)[ 2]
94 #define Pn2XTI2 ((Standard_Real*)Coordinate2)[ 3]
95 #define Pn2YTI2 ((Standard_Real*)Coordinate2)[ 4]
96 #define Pn2ZTI2 ((Standard_Real*)Coordinate2)[ 5]
97 #define Pn2X1 ((Standard_Real*)Coordinate2)[ 6]
98 #define Pn2Y1 ((Standard_Real*)Coordinate2)[ 7]
99 #define Pn2Z1 ((Standard_Real*)Coordinate2)[ 8]
100 #define Pn2X2 ((Standard_Real*)Coordinate2)[ 9]
101 #define Pn2Y2 ((Standard_Real*)Coordinate2)[10]
102 #define Pn2Z2 ((Standard_Real*)Coordinate2)[11]
104 #define Tri1Node1 ((Standard_Integer*)Tri1Indices)[0]
105 #define Tri1Node2 ((Standard_Integer*)Tri1Indices)[1]
106 #define Tri1Node3 ((Standard_Integer*)Tri1Indices)[2]
107 #define Tri1Flags ((Standard_Boolean*)Tri1Indices)[3]
109 #define Tri2Node1 ((Standard_Integer*)Tri2Indices)[0]
110 #define Tri2Node2 ((Standard_Integer*)Tri2Indices)[1]
111 #define Tri2Node3 ((Standard_Integer*)Tri2Indices)[2]
112 #define Tri2Flags ((Standard_Boolean*)Tri2Indices)[3]
114 #define Tri3Node1 ((Standard_Integer*)Tri3Indices)[0]
115 #define Tri3Node2 ((Standard_Integer*)Tri3Indices)[1]
116 #define Tri3Node3 ((Standard_Integer*)Tri3Indices)[2]
117 #define Tri3Flags ((Standard_Boolean*)Tri3Indices)[3]
119 #define Seg1LstSg1 ((Standard_Integer*)Seg1Indices)[0]
120 #define Seg1LstSg2 ((Standard_Integer*)Seg1Indices)[1]
121 #define Seg1NxtSg1 ((Standard_Integer*)Seg1Indices)[2]
122 #define Seg1NxtSg2 ((Standard_Integer*)Seg1Indices)[3]
123 #define Seg1Conex1 ((Standard_Integer*)Seg1Indices)[4]
124 #define Seg1Conex2 ((Standard_Integer*)Seg1Indices)[5]
126 #define Seg2LstSg1 ((Standard_Integer*)Seg2Indices)[0]
127 #define Seg2LstSg2 ((Standard_Integer*)Seg2Indices)[1]
128 #define Seg2NxtSg1 ((Standard_Integer*)Seg2Indices)[2]
129 #define Seg2NxtSg2 ((Standard_Integer*)Seg2Indices)[3]
130 #define Seg2Conex1 ((Standard_Integer*)Seg2Indices)[4]
131 #define Seg2Conex2 ((Standard_Integer*)Seg2Indices)[5]
133 #define Nod1NdSg ((Standard_Integer*)Nod1Indices)[0]
134 #define Nod1Flag ((Standard_Boolean*)Nod1Indices)[1]
135 #define Nod1Edg1 ((Standard_Boolean*)Nod1Indices)[2]
136 #define Nod1Edg2 ((Standard_Boolean*)Nod1Indices)[3]
138 #define Nod1PntX ((Standard_Real*)Nod1RValues)[ 0]
139 #define Nod1PntY ((Standard_Real*)Nod1RValues)[ 1]
140 #define Nod1PntZ ((Standard_Real*)Nod1RValues)[ 2]
141 #define Nod1PntU ((Standard_Real*)Nod1RValues)[ 3]
142 #define Nod1PntV ((Standard_Real*)Nod1RValues)[ 4]
143 #define Nod1NrmX ((Standard_Real*)Nod1RValues)[ 5]
144 #define Nod1NrmY ((Standard_Real*)Nod1RValues)[ 6]
145 #define Nod1NrmZ ((Standard_Real*)Nod1RValues)[ 7]
146 #define Nod1PCu1 ((Standard_Real*)Nod1RValues)[ 8]
147 #define Nod1PCu2 ((Standard_Real*)Nod1RValues)[ 9]
148 #define Nod1Scal ((Standard_Real*)Nod1RValues)[10]
150 #define NodANdSg ((Standard_Integer*)NodAIndices)[0]
151 #define NodAFlag ((Standard_Boolean*)NodAIndices)[1]
152 #define NodAEdg1 ((Standard_Boolean*)NodAIndices)[2]
153 #define NodAEdg2 ((Standard_Boolean*)NodAIndices)[3]
155 #define NodAPntX ((Standard_Real*)NodARValues)[ 0]
156 #define NodAPntY ((Standard_Real*)NodARValues)[ 1]
157 #define NodAPntZ ((Standard_Real*)NodARValues)[ 2]
158 #define NodAPntU ((Standard_Real*)NodARValues)[ 3]
159 #define NodAPntV ((Standard_Real*)NodARValues)[ 4]
160 #define NodANrmX ((Standard_Real*)NodARValues)[ 5]
161 #define NodANrmY ((Standard_Real*)NodARValues)[ 6]
162 #define NodANrmZ ((Standard_Real*)NodARValues)[ 7]
163 #define NodAPCu1 ((Standard_Real*)NodARValues)[ 8]
164 #define NodAPCu2 ((Standard_Real*)NodARValues)[ 9]
165 #define NodAScal ((Standard_Real*)NodARValues)[10]
167 #define NodBNdSg ((Standard_Integer*)NodBIndices)[0]
168 #define NodBFlag ((Standard_Boolean*)NodBIndices)[1]
169 #define NodBEdg1 ((Standard_Boolean*)NodBIndices)[2]
170 #define NodBEdg2 ((Standard_Boolean*)NodBIndices)[3]
172 #define NodBPntX ((Standard_Real*)NodBRValues)[ 0]
173 #define NodBPntY ((Standard_Real*)NodBRValues)[ 1]
174 #define NodBPntZ ((Standard_Real*)NodBRValues)[ 2]
175 #define NodBPntU ((Standard_Real*)NodBRValues)[ 3]
176 #define NodBPntV ((Standard_Real*)NodBRValues)[ 4]
177 #define NodBNrmX ((Standard_Real*)NodBRValues)[ 5]
178 #define NodBNrmY ((Standard_Real*)NodBRValues)[ 6]
179 #define NodBNrmZ ((Standard_Real*)NodBRValues)[ 7]
180 #define NodBPCu1 ((Standard_Real*)NodBRValues)[ 8]
181 #define NodBPCu2 ((Standard_Real*)NodBRValues)[ 9]
182 #define NodBScal ((Standard_Real*)NodBRValues)[10]
184 #define Nod2NdSg ((Standard_Integer*)Nod2Indices)[0]
185 #define Nod2Flag ((Standard_Boolean*)Nod2Indices)[1]
186 #define Nod2Edg1 ((Standard_Boolean*)Nod2Indices)[2]
187 #define Nod2Edg2 ((Standard_Boolean*)Nod2Indices)[3]
189 #define Nod2PntX ((Standard_Real*)Nod2RValues)[ 0]
190 #define Nod2PntY ((Standard_Real*)Nod2RValues)[ 1]
191 #define Nod2PntZ ((Standard_Real*)Nod2RValues)[ 2]
192 #define Nod2PntU ((Standard_Real*)Nod2RValues)[ 3]
193 #define Nod2PntV ((Standard_Real*)Nod2RValues)[ 4]
194 #define Nod2NrmX ((Standard_Real*)Nod2RValues)[ 5]
195 #define Nod2NrmY ((Standard_Real*)Nod2RValues)[ 6]
196 #define Nod2NrmZ ((Standard_Real*)Nod2RValues)[ 7]
197 #define Nod2PCu1 ((Standard_Real*)Nod2RValues)[ 8]
198 #define Nod2PCu2 ((Standard_Real*)Nod2RValues)[ 9]
199 #define Nod2Scal ((Standard_Real*)Nod2RValues)[10]
201 #define Nod3NdSg ((Standard_Integer*)Nod3Indices)[0]
202 #define Nod3Flag ((Standard_Boolean*)Nod3Indices)[1]
203 #define Nod3Edg1 ((Standard_Boolean*)Nod3Indices)[2]
204 #define Nod3Edg2 ((Standard_Boolean*)Nod3Indices)[3]
206 #define Nod3PntX ((Standard_Real*)Nod3RValues)[ 0]
207 #define Nod3PntY ((Standard_Real*)Nod3RValues)[ 1]
208 #define Nod3PntZ ((Standard_Real*)Nod3RValues)[ 2]
209 #define Nod3PntU ((Standard_Real*)Nod3RValues)[ 3]
210 #define Nod3PntV ((Standard_Real*)Nod3RValues)[ 4]
211 #define Nod3NrmX ((Standard_Real*)Nod3RValues)[ 5]
212 #define Nod3NrmY ((Standard_Real*)Nod3RValues)[ 6]
213 #define Nod3NrmZ ((Standard_Real*)Nod3RValues)[ 7]
214 #define Nod3PCu1 ((Standard_Real*)Nod3RValues)[ 8]
215 #define Nod3PCu2 ((Standard_Real*)Nod3RValues)[ 9]
216 #define Nod3Scal ((Standard_Real*)Nod3RValues)[10]
218 #define Nod4NdSg ((Standard_Integer*)Nod4Indices)[0]
219 #define Nod4Flag ((Standard_Boolean*)Nod4Indices)[1]
220 #define Nod4Edg1 ((Standard_Boolean*)Nod4Indices)[2]
221 #define Nod4Edg2 ((Standard_Boolean*)Nod4Indices)[3]
223 #define Nod4PntX ((Standard_Real*)Nod4RValues)[ 0]
224 #define Nod4PntY ((Standard_Real*)Nod4RValues)[ 1]
225 #define Nod4PntZ ((Standard_Real*)Nod4RValues)[ 2]
226 #define Nod4PntU ((Standard_Real*)Nod4RValues)[ 3]
227 #define Nod4PntV ((Standard_Real*)Nod4RValues)[ 4]
228 #define Nod4NrmX ((Standard_Real*)Nod4RValues)[ 5]
229 #define Nod4NrmY ((Standard_Real*)Nod4RValues)[ 6]
230 #define Nod4NrmZ ((Standard_Real*)Nod4RValues)[ 7]
231 #define Nod4PCu1 ((Standard_Real*)Nod4RValues)[ 8]
232 #define Nod4PCu2 ((Standard_Real*)Nod4RValues)[ 9]
233 #define Nod4Scal ((Standard_Real*)Nod4RValues)[10]
235 #define Nod11NdSg ((Standard_Integer*)Nod11Indices)[0]
236 #define Nod11Flag ((Standard_Boolean*)Nod11Indices)[1]
237 #define Nod11Edg1 ((Standard_Boolean*)Nod11Indices)[2]
238 #define Nod11Edg2 ((Standard_Boolean*)Nod11Indices)[3]
240 #define Nod11PntX ((Standard_Real*)Nod11RValues)[ 0]
241 #define Nod11PntY ((Standard_Real*)Nod11RValues)[ 1]
242 #define Nod11PntZ ((Standard_Real*)Nod11RValues)[ 2]
243 #define Nod11PntU ((Standard_Real*)Nod11RValues)[ 3]
244 #define Nod11PntV ((Standard_Real*)Nod11RValues)[ 4]
245 #define Nod11NrmX ((Standard_Real*)Nod11RValues)[ 5]
246 #define Nod11NrmY ((Standard_Real*)Nod11RValues)[ 6]
247 #define Nod11NrmZ ((Standard_Real*)Nod11RValues)[ 7]
248 #define Nod11PCu1 ((Standard_Real*)Nod11RValues)[ 8]
249 #define Nod11PCu2 ((Standard_Real*)Nod11RValues)[ 9]
250 #define Nod11Scal ((Standard_Real*)Nod11RValues)[10]
252 #define Nod1ANdSg ((Standard_Integer*)Nod1AIndices)[0]
253 #define Nod1AFlag ((Standard_Boolean*)Nod1AIndices)[1]
254 #define Nod1AEdg1 ((Standard_Boolean*)Nod1AIndices)[2]
255 #define Nod1AEdg2 ((Standard_Boolean*)Nod1AIndices)[3]
257 #define Nod1APntX ((Standard_Real*)Nod1ARValues)[ 0]
258 #define Nod1APntY ((Standard_Real*)Nod1ARValues)[ 1]
259 #define Nod1APntZ ((Standard_Real*)Nod1ARValues)[ 2]
260 #define Nod1APntU ((Standard_Real*)Nod1ARValues)[ 3]
261 #define Nod1APntV ((Standard_Real*)Nod1ARValues)[ 4]
262 #define Nod1ANrmX ((Standard_Real*)Nod1ARValues)[ 5]
263 #define Nod1ANrmY ((Standard_Real*)Nod1ARValues)[ 6]
264 #define Nod1ANrmZ ((Standard_Real*)Nod1ARValues)[ 7]
265 #define Nod1APCu1 ((Standard_Real*)Nod1ARValues)[ 8]
266 #define Nod1APCu2 ((Standard_Real*)Nod1ARValues)[ 9]
267 #define Nod1AScal ((Standard_Real*)Nod1ARValues)[10]
269 #define Nod1BNdSg ((Standard_Integer*)Nod1BIndices)[0]
270 #define Nod1BFlag ((Standard_Boolean*)Nod1BIndices)[1]
271 #define Nod1BEdg1 ((Standard_Boolean*)Nod1BIndices)[2]
272 #define Nod1BEdg2 ((Standard_Boolean*)Nod1BIndices)[3]
274 #define Nod1BPntX ((Standard_Real*)Nod1BRValues)[ 0]
275 #define Nod1BPntY ((Standard_Real*)Nod1BRValues)[ 1]
276 #define Nod1BPntZ ((Standard_Real*)Nod1BRValues)[ 2]
277 #define Nod1BPntU ((Standard_Real*)Nod1BRValues)[ 3]
278 #define Nod1BPntV ((Standard_Real*)Nod1BRValues)[ 4]
279 #define Nod1BNrmX ((Standard_Real*)Nod1BRValues)[ 5]
280 #define Nod1BNrmY ((Standard_Real*)Nod1BRValues)[ 6]
281 #define Nod1BNrmZ ((Standard_Real*)Nod1BRValues)[ 7]
282 #define Nod1BPCu1 ((Standard_Real*)Nod1BRValues)[ 8]
283 #define Nod1BPCu2 ((Standard_Real*)Nod1BRValues)[ 9]
284 #define Nod1BScal ((Standard_Real*)Nod1BRValues)[10]
286 #define Nod12NdSg ((Standard_Integer*)Nod12Indices)[0]
287 #define Nod12Flag ((Standard_Boolean*)Nod12Indices)[1]
288 #define Nod12Edg1 ((Standard_Boolean*)Nod12Indices)[2]
289 #define Nod12Edg2 ((Standard_Boolean*)Nod12Indices)[3]
291 #define Nod12PntX ((Standard_Real*)Nod12RValues)[ 0]
292 #define Nod12PntY ((Standard_Real*)Nod12RValues)[ 1]
293 #define Nod12PntZ ((Standard_Real*)Nod12RValues)[ 2]
294 #define Nod12PntU ((Standard_Real*)Nod12RValues)[ 3]
295 #define Nod12PntV ((Standard_Real*)Nod12RValues)[ 4]
296 #define Nod12NrmX ((Standard_Real*)Nod12RValues)[ 5]
297 #define Nod12NrmY ((Standard_Real*)Nod12RValues)[ 6]
298 #define Nod12NrmZ ((Standard_Real*)Nod12RValues)[ 7]
299 #define Nod12PCu1 ((Standard_Real*)Nod12RValues)[ 8]
300 #define Nod12PCu2 ((Standard_Real*)Nod12RValues)[ 9]
301 #define Nod12Scal ((Standard_Real*)Nod12RValues)[10]
303 #define Nod13NdSg ((Standard_Integer*)Nod13Indices)[0]
304 #define Nod13Flag ((Standard_Boolean*)Nod13Indices)[1]
305 #define Nod13Edg1 ((Standard_Boolean*)Nod13Indices)[2]
306 #define Nod13Edg2 ((Standard_Boolean*)Nod13Indices)[3]
308 #define Nod13PntX ((Standard_Real*)Nod13RValues)[ 0]
309 #define Nod13PntY ((Standard_Real*)Nod13RValues)[ 1]
310 #define Nod13PntZ ((Standard_Real*)Nod13RValues)[ 2]
311 #define Nod13PntU ((Standard_Real*)Nod13RValues)[ 3]
312 #define Nod13PntV ((Standard_Real*)Nod13RValues)[ 4]
313 #define Nod13NrmX ((Standard_Real*)Nod13RValues)[ 5]
314 #define Nod13NrmY ((Standard_Real*)Nod13RValues)[ 6]
315 #define Nod13NrmZ ((Standard_Real*)Nod13RValues)[ 7]
316 #define Nod13PCu1 ((Standard_Real*)Nod13RValues)[ 8]
317 #define Nod13PCu2 ((Standard_Real*)Nod13RValues)[ 9]
318 #define Nod13Scal ((Standard_Real*)Nod13RValues)[10]
320 #define Nod14NdSg ((Standard_Integer*)Nod14Indices)[0]
321 #define Nod14Flag ((Standard_Boolean*)Nod14Indices)[1]
322 #define Nod14Edg1 ((Standard_Boolean*)Nod14Indices)[2]
323 #define Nod14Edg2 ((Standard_Boolean*)Nod14Indices)[3]
325 #define Nod14PntX ((Standard_Real*)Nod14RValues)[ 0]
326 #define Nod14PntY ((Standard_Real*)Nod14RValues)[ 1]
327 #define Nod14PntZ ((Standard_Real*)Nod14RValues)[ 2]
328 #define Nod14PntU ((Standard_Real*)Nod14RValues)[ 3]
329 #define Nod14PntV ((Standard_Real*)Nod14RValues)[ 4]
330 #define Nod14NrmX ((Standard_Real*)Nod14RValues)[ 5]
331 #define Nod14NrmY ((Standard_Real*)Nod14RValues)[ 6]
332 #define Nod14NrmZ ((Standard_Real*)Nod14RValues)[ 7]
333 #define Nod14PCu1 ((Standard_Real*)Nod14RValues)[ 8]
334 #define Nod14PCu2 ((Standard_Real*)Nod14RValues)[ 9]
335 #define Nod14Scal ((Standard_Real*)Nod14RValues)[10]
337 #define Nod21NdSg ((Standard_Integer*)Nod21Indices)[0]
338 #define Nod21Flag ((Standard_Boolean*)Nod21Indices)[1]
339 #define Nod21Edg1 ((Standard_Boolean*)Nod21Indices)[2]
340 #define Nod21Edg2 ((Standard_Boolean*)Nod21Indices)[3]
342 #define Nod21PntX ((Standard_Real*)Nod21RValues)[ 0]
343 #define Nod21PntY ((Standard_Real*)Nod21RValues)[ 1]
344 #define Nod21PntZ ((Standard_Real*)Nod21RValues)[ 2]
345 #define Nod21PntU ((Standard_Real*)Nod21RValues)[ 3]
346 #define Nod21PntV ((Standard_Real*)Nod21RValues)[ 4]
347 #define Nod21NrmX ((Standard_Real*)Nod21RValues)[ 5]
348 #define Nod21NrmY ((Standard_Real*)Nod21RValues)[ 6]
349 #define Nod21NrmZ ((Standard_Real*)Nod21RValues)[ 7]
350 #define Nod21PCu1 ((Standard_Real*)Nod21RValues)[ 8]
351 #define Nod21PCu2 ((Standard_Real*)Nod21RValues)[ 9]
352 #define Nod21Scal ((Standard_Real*)Nod21RValues)[10]
354 #define Nod2ANdSg ((Standard_Integer*)Nod2AIndices)[0]
355 #define Nod2AFlag ((Standard_Boolean*)Nod2AIndices)[1]
356 #define Nod2AEdg1 ((Standard_Boolean*)Nod2AIndices)[2]
357 #define Nod2AEdg2 ((Standard_Boolean*)Nod2AIndices)[3]
359 #define Nod2APntX ((Standard_Real*)Nod2ARValues)[ 0]
360 #define Nod2APntY ((Standard_Real*)Nod2ARValues)[ 1]
361 #define Nod2APntZ ((Standard_Real*)Nod2ARValues)[ 2]
362 #define Nod2APntU ((Standard_Real*)Nod2ARValues)[ 3]
363 #define Nod2APntV ((Standard_Real*)Nod2ARValues)[ 4]
364 #define Nod2ANrmX ((Standard_Real*)Nod2ARValues)[ 5]
365 #define Nod2ANrmY ((Standard_Real*)Nod2ARValues)[ 6]
366 #define Nod2ANrmZ ((Standard_Real*)Nod2ARValues)[ 7]
367 #define Nod2APCu1 ((Standard_Real*)Nod2ARValues)[ 8]
368 #define Nod2APCu2 ((Standard_Real*)Nod2ARValues)[ 9]
369 #define Nod2AScal ((Standard_Real*)Nod2ARValues)[10]
371 #define Nod2BNdSg ((Standard_Integer*)Nod2BIndices)[0]
372 #define Nod2BFlag ((Standard_Boolean*)Nod2BIndices)[1]
373 #define Nod2BEdg1 ((Standard_Boolean*)Nod2BIndices)[2]
374 #define Nod2BEdg2 ((Standard_Boolean*)Nod2BIndices)[3]
376 #define Nod2BPntX ((Standard_Real*)Nod2BRValues)[ 0]
377 #define Nod2BPntY ((Standard_Real*)Nod2BRValues)[ 1]
378 #define Nod2BPntZ ((Standard_Real*)Nod2BRValues)[ 2]
379 #define Nod2BPntU ((Standard_Real*)Nod2BRValues)[ 3]
380 #define Nod2BPntV ((Standard_Real*)Nod2BRValues)[ 4]
381 #define Nod2BNrmX ((Standard_Real*)Nod2BRValues)[ 5]
382 #define Nod2BNrmY ((Standard_Real*)Nod2BRValues)[ 6]
383 #define Nod2BNrmZ ((Standard_Real*)Nod2BRValues)[ 7]
384 #define Nod2BPCu1 ((Standard_Real*)Nod2BRValues)[ 8]
385 #define Nod2BPCu2 ((Standard_Real*)Nod2BRValues)[ 9]
386 #define Nod2BScal ((Standard_Real*)Nod2BRValues)[10]
388 #define Nod22NdSg ((Standard_Integer*)Nod22Indices)[0]
389 #define Nod22Flag ((Standard_Boolean*)Nod22Indices)[1]
390 #define Nod22Edg1 ((Standard_Boolean*)Nod22Indices)[2]
391 #define Nod22Edg2 ((Standard_Boolean*)Nod22Indices)[3]
393 #define Nod22PntX ((Standard_Real*)Nod22RValues)[ 0]
394 #define Nod22PntY ((Standard_Real*)Nod22RValues)[ 1]
395 #define Nod22PntZ ((Standard_Real*)Nod22RValues)[ 2]
396 #define Nod22PntU ((Standard_Real*)Nod22RValues)[ 3]
397 #define Nod22PntV ((Standard_Real*)Nod22RValues)[ 4]
398 #define Nod22NrmX ((Standard_Real*)Nod22RValues)[ 5]
399 #define Nod22NrmY ((Standard_Real*)Nod22RValues)[ 6]
400 #define Nod22NrmZ ((Standard_Real*)Nod22RValues)[ 7]
401 #define Nod22PCu1 ((Standard_Real*)Nod22RValues)[ 8]
402 #define Nod22PCu2 ((Standard_Real*)Nod22RValues)[ 9]
403 #define Nod22Scal ((Standard_Real*)Nod22RValues)[10]
405 #define Nod23NdSg ((Standard_Integer*)Nod23Indices)[0]
406 #define Nod23Flag ((Standard_Boolean*)Nod23Indices)[1]
407 #define Nod23Edg1 ((Standard_Boolean*)Nod23Indices)[2]
408 #define Nod23Edg2 ((Standard_Boolean*)Nod23Indices)[3]
410 #define Nod23PntX ((Standard_Real*)Nod23RValues)[ 0]
411 #define Nod23PntY ((Standard_Real*)Nod23RValues)[ 1]
412 #define Nod23PntZ ((Standard_Real*)Nod23RValues)[ 2]
413 #define Nod23PntU ((Standard_Real*)Nod23RValues)[ 3]
414 #define Nod23PntV ((Standard_Real*)Nod23RValues)[ 4]
415 #define Nod23NrmX ((Standard_Real*)Nod23RValues)[ 5]
416 #define Nod23NrmY ((Standard_Real*)Nod23RValues)[ 6]
417 #define Nod23NrmZ ((Standard_Real*)Nod23RValues)[ 7]
418 #define Nod23PCu1 ((Standard_Real*)Nod23RValues)[ 8]
419 #define Nod23PCu2 ((Standard_Real*)Nod23RValues)[ 9]
420 #define Nod23Scal ((Standard_Real*)Nod23RValues)[10]
422 #define Nod24NdSg ((Standard_Integer*)Nod24Indices)[0]
423 #define Nod24Flag ((Standard_Boolean*)Nod24Indices)[1]
424 #define Nod24Edg1 ((Standard_Boolean*)Nod24Indices)[2]
425 #define Nod24Edg2 ((Standard_Boolean*)Nod24Indices)[3]
427 #define Nod24PntX ((Standard_Real*)Nod24RValues)[ 0]
428 #define Nod24PntY ((Standard_Real*)Nod24RValues)[ 1]
429 #define Nod24PntZ ((Standard_Real*)Nod24RValues)[ 2]
430 #define Nod24PntU ((Standard_Real*)Nod24RValues)[ 3]
431 #define Nod24PntV ((Standard_Real*)Nod24RValues)[ 4]
432 #define Nod24NrmX ((Standard_Real*)Nod24RValues)[ 5]
433 #define Nod24NrmY ((Standard_Real*)Nod24RValues)[ 6]
434 #define Nod24NrmZ ((Standard_Real*)Nod24RValues)[ 7]
435 #define Nod24PCu1 ((Standard_Real*)Nod24RValues)[ 8]
436 #define Nod24PCu2 ((Standard_Real*)Nod24RValues)[ 9]
437 #define Nod24Scal ((Standard_Real*)Nod24RValues)[10]
439 #define ShapeIndex ((Standard_Integer*)IndexPtr)[0]
440 #define F1Index ((Standard_Integer*)IndexPtr)[1]
441 #define F1Pt1Index ((Standard_Integer*)IndexPtr)[2]
442 #define F1Pt2Index ((Standard_Integer*)IndexPtr)[3]
443 #define F2Index ((Standard_Integer*)IndexPtr)[4]
444 #define F2Pt1Index ((Standard_Integer*)IndexPtr)[5]
445 #define F2Pt2Index ((Standard_Integer*)IndexPtr)[6]
446 #define MinSeg ((Standard_Integer*)IndexPtr)[7]
447 #define MaxSeg ((Standard_Integer*)IndexPtr)[8]
448 #define SegFlags ((Standard_Integer*)IndexPtr)[9]
450 static Standard_Integer DoTrace = Standard_False;
451 static Standard_Integer DoError = Standard_False;
453 //=======================================================================
454 //function : HLRBRep_PolyAlgo
456 //=======================================================================
458 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo () :
459 myDebug (Standard_False),
460 myAngle (5 * M_PI / 180.),
465 myAlgo = new HLRAlgo_PolyAlgo();
468 //=======================================================================
469 //function : HLRBRep_PolyAlgo
471 //=======================================================================
473 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const Handle(HLRBRep_PolyAlgo)& A)
475 myDebug = A->Debug();
476 myAngle = A->Angle();
477 myTolAngular = A->TolAngular();
478 myTolSta = A->TolCoef();
479 myTolEnd = 1 - myTolSta;
481 myProj = A->Projector();
483 Standard_Integer n = A->NbShapes();
485 for (Standard_Integer i = 1; i <= n; i++)
489 //=======================================================================
490 //function : HLRBRep_PolyAlgo
492 //=======================================================================
494 HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const TopoDS_Shape& S) :
495 myDebug (Standard_False),
496 myAngle (5 * M_PI / 180.),
502 myAlgo = new HLRAlgo_PolyAlgo();
505 //=======================================================================
508 //=======================================================================
510 TopoDS_Shape & HLRBRep_PolyAlgo::Shape (const Standard_Integer I)
512 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
513 "HLRBRep_PolyAlgo::Shape : unknown Shape");
517 //=======================================================================
520 //=======================================================================
522 void HLRBRep_PolyAlgo::Remove (const Standard_Integer I)
524 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
525 "HLRBRep_PolyAlgo::Remove : unknown Shape");
532 //=======================================================================
535 //=======================================================================
537 Standard_Integer HLRBRep_PolyAlgo::Index (const TopoDS_Shape& S) const
539 Standard_Integer n = myShapes.Length();
541 for (Standard_Integer i = 1; i <= n; i++)
542 if (myShapes(i) == S) return i;
547 //=======================================================================
550 //=======================================================================
552 Handle(HLRAlgo_PolyAlgo) HLRBRep_PolyAlgo::Algo () const
557 //=======================================================================
560 //=======================================================================
562 void HLRBRep_PolyAlgo::Update ()
567 TopoDS_Shape Shape = MakeShape();
569 if (!Shape.IsNull()) {
570 TopExp_Explorer exshell;
571 Standard_Boolean IsoledF,IsoledE;//,closed;
573 TopTools_MapOfShape ShapeMap1,ShapeMap2;
574 TopExp::MapShapes(Shape,TopAbs_EDGE,myEMap);
575 TopExp::MapShapes(Shape,TopAbs_FACE,myFMap);
576 Standard_Integer nbEdge = myEMap.Extent();
577 Standard_Integer nbFace = myFMap.Extent();
578 TColStd_Array1OfInteger ES (0,nbEdge); // index of the Shell
579 TColStd_Array1OfTransient PD (0,nbFace); // HLRAlgo_PolyData
580 TColStd_Array1OfTransient PID(0,nbFace); // PolyInternalData
581 Standard_Integer nbShell = InitShape(Shape,IsoledF,IsoledE);
583 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
584 Standard_Integer iShell = 0;
586 for (exshell.Init(Shape, TopAbs_SHELL);
589 StoreShell(exshell.Current(),iShell,Shell,
590 Standard_False,Standard_False,
591 ES,PD,PID,ShapeMap1,ShapeMap2);
593 StoreShell(Shape,iShell,Shell,IsoledF,Standard_False,
594 ES,PD,PID,ShapeMap1,ShapeMap2);
596 StoreShell(Shape,iShell,Shell,Standard_False,IsoledE,
597 ES,PD,PID,ShapeMap1,ShapeMap2);
603 //=======================================================================
604 //function : MakeShape
606 //=======================================================================
608 TopoDS_Shape HLRBRep_PolyAlgo::MakeShape () const
610 Standard_Integer n = myShapes.Length();
611 Standard_Boolean FirstTime = Standard_True;
615 for (Standard_Integer i = 1; i <= n; i++) {
617 FirstTime = Standard_False;
618 B.MakeCompound(TopoDS::Compound(Shape));
620 B.Add(Shape,myShapes(i));
625 //=======================================================================
626 //function : InitShape
628 //=======================================================================
631 HLRBRep_PolyAlgo::InitShape (const TopoDS_Shape& Shape,
632 Standard_Boolean& IsoledF,
633 Standard_Boolean& IsoledE)
635 TopTools_MapOfShape ShapeMap0;
636 Standard_Integer nbShell = 0;
637 IsoledF = Standard_False;
638 IsoledE = Standard_False;
639 TopExp_Explorer exshell,exface,exedge;
642 for (exshell.Init(Shape, TopAbs_SHELL);
645 Standard_Boolean withTrian = Standard_False;
647 for (exface.Init(exshell.Current(), TopAbs_FACE);
650 const TopoDS_Face& F = TopoDS::Face(exface.Current());
651 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
652 if (ShapeMap0.Add(F))
653 withTrian = Standard_True;
656 if (withTrian) nbShell++;
659 for (exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
660 exface.More() && !IsoledF;
662 const TopoDS_Face& F = TopoDS::Face(exface.Current());
663 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
664 if (ShapeMap0.Add(F))
665 IsoledF = Standard_True;
668 if (IsoledF) nbShell++;
670 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
671 exedge.More() && !IsoledE;
673 IsoledE = Standard_True;
674 if (IsoledE) nbShell++;
676 myAlgo->Init(new TColStd_HArray1OfTransient(1,nbShell));
680 //=======================================================================
681 //function : StoreShell
683 //=======================================================================
685 void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
686 Standard_Integer& iShell,
687 TColStd_Array1OfTransient& Shell,
688 const Standard_Boolean IsoledF,
689 const Standard_Boolean IsoledE,
690 TColStd_Array1OfInteger& ES,
691 TColStd_Array1OfTransient& PD,
692 TColStd_Array1OfTransient& PID,
693 TopTools_MapOfShape& ShapeMap1,
694 TopTools_MapOfShape& ShapeMap2)
697 TopExp_Explorer exface,exedge;
698 Standard_Integer f = 0,i,j;
699 Standard_Integer nbFaceShell = 0;
700 Standard_Boolean reversed;
701 Standard_Boolean closed = Standard_False;
702 const gp_Trsf& T = myProj.Transformation();
703 const gp_Trsf& TI = myProj.InvertedTransformation();
704 const gp_XYZ& tloc = T.TranslationPart();
708 const gp_Mat& tmat = T.VectorialPart();
709 TMat[0][0] = tmat.Value(1,1);
710 TMat[0][1] = tmat.Value(1,2);
711 TMat[0][2] = tmat.Value(1,3);
712 TMat[1][0] = tmat.Value(2,1);
713 TMat[1][1] = tmat.Value(2,2);
714 TMat[1][2] = tmat.Value(2,3);
715 TMat[2][0] = tmat.Value(3,1);
716 TMat[2][1] = tmat.Value(3,2);
717 TMat[2][2] = tmat.Value(3,3);
718 const gp_XYZ& tilo = TI.TranslationPart();
722 const gp_Mat& tima = TI.VectorialPart();
723 TIMa[0][0] = tima.Value(1,1);
724 TIMa[0][1] = tima.Value(1,2);
725 TIMa[0][2] = tima.Value(1,3);
726 TIMa[1][0] = tima.Value(2,1);
727 TIMa[1][1] = tima.Value(2,2);
728 TIMa[1][2] = tima.Value(2,3);
729 TIMa[2][0] = tima.Value(3,1);
730 TIMa[2][1] = tima.Value(3,2);
731 TIMa[2][2] = tima.Value(3,3);
734 closed = Shape.Closed();
736 TopTools_IndexedMapOfShape EM;
737 TopExp::MapShapes(Shape,TopAbs_EDGE,EM);
739 Standard_Integer nbEdge = EM.Extent ();
740 Standard_Integer *flag = new Standard_Integer[nbEdge + 1];
742 for (ie = 1; ie <= nbEdge; ie++)
745 for (exedge.Init(Shape, TopAbs_EDGE);
748 const TopoDS_Edge& E = TopoDS::Edge(exedge.Current());
749 ie = EM.FindIndex(E);
750 TopAbs_Orientation orient = E.Orientation();
751 if (!BRep_Tool::Degenerated(E)) {
752 if (orient == TopAbs_FORWARD ) flag[ie] += 1;
753 else if (orient == TopAbs_REVERSED) flag[ie] -= 1;
756 closed = Standard_True;
758 for (ie = 1; ie <= nbEdge && closed; ie++)
759 closed = (flag[ie] == 0);
764 exface.Init(Shape, TopAbs_FACE);
767 exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
769 for (; exface.More(); exface.Next()) {
770 const TopoDS_Face& F = TopoDS::Face(exface.Current());
771 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
772 if (ShapeMap1.Add(F))
777 if (nbFaceShell > 0 || IsoledE) {
779 Shell(iShell) = new HLRAlgo_PolyShellData(nbFaceShell);
781 if (nbFaceShell > 0) {
782 const Handle(HLRAlgo_PolyShellData)& psd =
783 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
784 Standard_Integer iFace = 0;
785 if (!IsoledF) exface.Init(Shape, TopAbs_FACE);
786 else exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
787 TopTools_MapOfShape ShapeMapBis;
789 for (; exface.More(); exface.Next()) {
790 const TopoDS_Face& F = TopoDS::Face(exface.Current());
791 const Handle(Poly_Triangulation)& Tr = BRep_Tool::Triangulation(F,L);
793 if (ShapeMap2.Add(F)) {
795 f = myFMap.FindIndex(F);
796 reversed = F.Orientation() == TopAbs_REVERSED;
797 gp_Trsf TT = L.Transformation();
799 const gp_XYZ& ttlo = TT.TranslationPart();
803 const gp_Mat& ttma = TT.VectorialPart();
804 TTMa[0][0] = ttma.Value(1,1);
805 TTMa[0][1] = ttma.Value(1,2);
806 TTMa[0][2] = ttma.Value(1,3);
807 TTMa[1][0] = ttma.Value(2,1);
808 TTMa[1][1] = ttma.Value(2,2);
809 TTMa[1][2] = ttma.Value(2,3);
810 TTMa[2][0] = ttma.Value(3,1);
811 TTMa[2][1] = ttma.Value(3,2);
812 TTMa[2][2] = ttma.Value(3,3);
813 Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
814 TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
815 Standard_Integer nbN = Nod.Upper();
816 Standard_Integer nbT = Tri.Upper();
817 PD (f) = new HLRAlgo_PolyData();
818 psd->PolyData().ChangeValue(iFace) = PD(f);
819 PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
820 Handle(HLRAlgo_PolyInternalData)& pid =
821 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(f));
822 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
823 if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface))
824 S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
825 GeomAdaptor_Surface AS(S);
826 pid->Planar(AS.GetType() == GeomAbs_Plane);
827 Standard_Address TData = &pid->TData();
828 Standard_Address PISeg = &pid->PISeg();
829 Standard_Address PINod = &pid->PINod();
830 Poly_Triangle * OT = &(Tri.ChangeValue(1));
831 HLRAlgo_TriangleData* NT =
832 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
834 for (i = 1; i <= nbT; i++) {
835 Standard_Address Tri2Indices = NT->Indices();
836 OT->Get(Tri2Node1,Tri2Node2,Tri2Node3);
840 Tri2Node1 = Tri2Node3;
847 gp_Pnt * ON = &(Nod.ChangeValue(1));
848 Handle(HLRAlgo_PolyInternalNode)* NN =
849 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
851 for (i = 1; i <= nbN; i++) {
852 const Standard_Address Nod1RValues = (*NN)->RValues();
853 const Standard_Address Nod1Indices = (*NN)->Indices();
859 TTMultiply(Nod1PntX,Nod1PntY,Nod1PntZ);
863 pid->UpdateLinks(TData,PISeg,PINod);
864 if (Tr->HasUVNodes()) {
865 myBSurf.Initialize(F,Standard_False);
866 TColgp_Array1OfPnt2d & UVN = Tr->ChangeUVNodes();
867 gp_Pnt2d* OUVN = &(UVN.ChangeValue(1));
868 NN = &(((HLRAlgo_Array1OfPINod*)PINod)->
871 for (i = 1; i <= nbN; i++) {
872 const Standard_Address Nod1Indices = (*NN)->Indices();
873 const Standard_Address Nod1RValues = (*NN)->RValues();
874 Nod1PntU = OUVN->X();
875 Nod1PntV = OUVN->Y();
876 if (Normal(i,Nod1Indices,Nod1RValues,
877 TData,PISeg,PINod,Standard_False))
878 Nod1Flag |= NMskNorm;
880 Nod1Flag &= ~NMskNorm;
889 cout << " HLRBRep_PolyAlgo::StoreShell : Face ";
890 cout << f << " non triangulated" << endl;
893 NT = &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
895 for (i = 1; i <= nbT; i++) {
896 const Standard_Address Tri1Indices = NT->Indices();
897 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
898 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
899 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
900 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
901 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
902 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
903 const Standard_Address Nod1Indices = (*PN1)->Indices();
904 const Standard_Address Nod2Indices = (*PN2)->Indices();
905 const Standard_Address Nod3Indices = (*PN3)->Indices();
906 const Standard_Address Nod1RValues = (*PN1)->RValues();
907 const Standard_Address Nod2RValues = (*PN2)->RValues();
908 const Standard_Address Nod3RValues = (*PN3)->RValues();
909 OrientTriangle(i,Tri1Indices,
910 Nod1Indices,Nod1RValues,
911 Nod2Indices,Nod2RValues,
912 Nod3Indices,Nod3RValues);
919 cout << "HLRBRep_PolyAlgo::StoreShell : Face ";
920 cout << f << " deja stockee" << endl;
924 Standard_Integer nbFace = myFMap.Extent();
925 HLRAlgo_ListOfBPoint& List = psd->Edges();
926 TopTools_IndexedDataMapOfShapeListOfShape EF;
927 TopExp::MapShapesAndAncestors(Shape,TopAbs_EDGE,TopAbs_FACE,EF);
928 Handle(HLRAlgo_PolyInternalData)* pid =
929 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
931 for (f = 1; f <= nbFace; f++) {
932 if (!(*pid).IsNull()) {
934 for (exedge.Init(myFMap(f),TopAbs_EDGE);
937 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
938 if (ShapeMap1.Add(E)) {
939 Standard_Integer e = myEMap.FindIndex(E);
941 Standard_Integer i = EF.FindIndex(E);
943 TopTools_ListOfShape& LS = EF(i);
944 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_True);
947 TopTools_ListOfShape LS;
948 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
955 InsertOnOutLine(PID);
956 CheckFrBackTriangles(List,PID);
957 UpdateOutLines(List,PID);
958 UpdateEdgesBiPoints(List,PID,closed);
959 UpdatePolyData(PD,PID,closed);
960 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
962 for (f = 1; f <= nbFace; f++) {
968 const Handle(HLRAlgo_PolyShellData)& psd =
969 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
970 HLRAlgo_ListOfBPoint& List = psd->Edges();
972 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
975 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
976 if (ShapeMap1.Add(E)) {
977 Standard_Integer e = myEMap.FindIndex(E);
979 TopTools_ListOfShape LS;
980 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
986 //=======================================================================
989 //=======================================================================
991 Standard_Boolean HLRBRep_PolyAlgo::
992 Normal (const Standard_Integer iNode,
993 const Standard_Address Nod1Indices,
994 const Standard_Address Nod1RValues,
995 Standard_Address& TData,
996 Standard_Address& PISeg,
997 Standard_Address& PINod,
998 const Standard_Boolean orient) const
1000 gp_Vec D1U,D1V,D2U,D2V,D2UV;
1003 Standard_Boolean OK;
1004 CSLib_DerivativeStatus Status;
1005 CSLib_NormalStatus NStat;
1006 myBSurf.D1(Nod1PntU,Nod1PntV,P,D1U,D1V);
1007 CSLib::Normal(D1U,D1V,Standard_Real(Precision::Angular()),
1009 if (Status != CSLib_Done) {
1010 myBSurf.D2(Nod1PntU,Nod1PntV,P,D1U,D1V,D2U,D2V,D2UV);
1011 CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,
1012 Precision::Angular(),OK,NStat,Norma);
1014 return Standard_False;
1016 Standard_Real EyeX = 0;
1017 Standard_Real EyeY = 0;
1018 Standard_Real EyeZ = -1;
1019 if (myProj.Perspective()) {
1022 EyeZ = Nod1PntZ - myProj.Focus();
1023 Standard_Real d = sqrt(EyeX * EyeX + EyeY * EyeY + EyeZ * EyeZ);
1030 Nod1NrmX = Norma.X();
1031 Nod1NrmY = Norma.Y();
1032 Nod1NrmZ = Norma.Z();
1033 // TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ);
1034 TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ,myProj.Perspective()); //OCC349
1035 Standard_Real NormX,NormY,NormZ;
1037 if (AverageNormal(iNode,Nod1Indices,TData,PISeg,PINod,
1038 NormX,NormY,NormZ)) {
1039 if (Nod1NrmX * NormX +
1041 Nod1NrmZ * NormZ < 0) {
1042 Nod1NrmX = -Nod1NrmX;
1043 Nod1NrmY = -Nod1NrmY;
1044 Nod1NrmZ = -Nod1NrmZ;
1046 Nod1Scal = (Nod1NrmX * EyeX +
1057 cout << "HLRBRep_PolyAlgo::Normal : AverageNormal error";
1063 if ( Nod1Scal < myTolAngular) {
1065 Nod1Flag |= NMskOutL;
1069 if (-Nod1Scal < myTolAngular) {
1071 Nod1Flag |= NMskOutL;
1074 if (orient) UpdateAroundNode(iNode,Nod1Indices,
1076 return Standard_True;
1079 //=======================================================================
1080 //function : AverageNormal
1082 //=======================================================================
1085 HLRBRep_PolyAlgo::AverageNormal(const Standard_Integer iNode,
1086 const Standard_Address Nod1Indices,
1087 Standard_Address& TData,
1088 Standard_Address& PISeg,
1089 Standard_Address& PINod,
1092 Standard_Real& Z) const
1094 Standard_Boolean OK = Standard_False;
1095 Standard_Integer jNode = 0,kNode,iiii,iTri1,iTri2;
1101 while (iiii != 0 && !OK) {
1102 const Standard_Address Seg2Indices =
1103 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1106 if ( iTri1 != 0) AddNormalOnTriangle
1107 (iTri1,iNode,jNode,TData,PINod,X,Y,Z,OK);
1108 if ( iTri2 != 0) AddNormalOnTriangle
1109 (iTri2,iNode,jNode,TData,PINod,X,Y,Z,OK);
1110 if (Seg2LstSg1 == iNode) iiii = Seg2NxtSg1;
1111 else iiii = Seg2NxtSg2;
1115 const Standard_Address Nod2Indices =
1116 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(jNode)->Indices();
1119 while (iiii != 0 && !OK) {
1120 const Standard_Address Seg2Indices =
1121 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1124 if ( iTri1 != 0) AddNormalOnTriangle
1125 (iTri1,jNode,kNode,TData,PINod,X,Y,Z,OK);
1126 if ( iTri2 != 0) AddNormalOnTriangle
1127 (iTri2,jNode,kNode,TData,PINod,X,Y,Z,OK);
1128 if (Seg2LstSg1 == jNode) iiii = Seg2NxtSg1;
1129 else iiii = Seg2NxtSg2;
1132 Standard_Real d = sqrt (X * X + Y * Y + Z * Z);
1133 if (OK && d < 1.e-10) {
1134 OK = Standard_False;
1137 cout << "HLRAlgo_PolyInternalData:: inverted normals on ";
1138 cout << "node " << iNode << endl;
1145 //=======================================================================
1146 //function : AddNormalOnTriangle
1148 //=======================================================================
1152 AddNormalOnTriangle(const Standard_Integer iTri,
1153 const Standard_Integer iNode,
1154 Standard_Integer& jNode,
1155 Standard_Address& TData,
1156 Standard_Address& PINod,
1160 Standard_Boolean& OK) const
1162 Standard_Real dn,dnx,dny,dnz;
1163 Standard_Real d1,dx1,dy1,dz1;
1164 Standard_Real d2,dx2,dy2,dz2;
1165 Standard_Real d3,dx3,dy3,dz3;
1166 const Standard_Address Tri2Indices =
1167 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri).Indices();
1168 const Standard_Address Nod1RValues =
1169 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1)->RValues();
1170 const Standard_Address Nod2RValues =
1171 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2)->RValues();
1172 const Standard_Address Nod3RValues =
1173 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3)->RValues();
1174 dx1 = Nod2PntX - Nod1PntX;
1175 dy1 = Nod2PntY - Nod1PntY;
1176 dz1 = Nod2PntZ - Nod1PntZ;
1177 d1 = sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
1179 if (Tri2Node1 == iNode) jNode = Tri2Node2;
1180 else if (Tri2Node2 == iNode) jNode = Tri2Node1;
1183 dx2 = Nod3PntX - Nod2PntX;
1184 dy2 = Nod3PntY - Nod2PntY;
1185 dz2 = Nod3PntZ - Nod2PntZ;
1186 d2 = sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
1188 if (Tri2Node2 == iNode) jNode = Tri2Node3;
1189 else if (Tri2Node3 == iNode) jNode = Tri2Node2;
1192 dx3 = Nod1PntX - Nod3PntX;
1193 dy3 = Nod1PntY - Nod3PntY;
1194 dz3 = Nod1PntZ - Nod3PntZ;
1195 d3 = sqrt(dx3 * dx3 + dy3 * dy3 + dz3 * dz3);
1197 if (Tri2Node3 == iNode) jNode = Tri2Node1;
1198 else if (Tri2Node1 == iNode) jNode = Tri2Node3;
1202 dnx = (dy1 * dz2 - dy2 * dz1) * dn;
1203 dny = (dz1 * dx2 - dz2 * dx1) * dn;
1204 dnz = (dx1 * dy2 - dx2 * dy1) * dn;
1205 dn = sqrt(dnx * dnx + dny * dny + dnz * dnz);
1217 //=======================================================================
1218 //function : InitBiPointsWithConnexity
1220 //=======================================================================
1222 void HLRBRep_PolyAlgo::
1223 InitBiPointsWithConnexity (const Standard_Integer e,
1225 HLRAlgo_ListOfBPoint& List,
1226 TColStd_Array1OfTransient& PID,
1227 TopTools_ListOfShape& LS,
1228 const Standard_Boolean connex)
1230 Standard_Integer iPol,nbPol,i1,i1p1,i1p2,i2,i2p1,i2p2;
1231 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
1232 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
1233 Standard_Real U1,U2 = 0.;
1234 Handle(Poly_PolygonOnTriangulation) HPol[2];
1236 myBCurv.Initialize(E);
1238 Standard_Integer nbConnex = LS.Extent();
1239 if (nbConnex == 1) {
1240 TopTools_ListIteratorOfListOfShape itn(LS);
1241 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1242 i1 = myFMap.FindIndex(F1);
1243 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1244 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1245 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1246 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1247 if (!HPol[0].IsNull()) {
1248 myPC.Initialize(E,F1);
1249 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1250 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1251 nbPol = Pol1.Upper();
1252 Standard_Address TData1 = &pid1->TData();
1253 Standard_Address PISeg1 = &pid1->PISeg();
1254 Standard_Address PINod1 = &pid1->PINod();
1255 Standard_Address Nod11Indices,Nod12Indices;
1256 Standard_Address Nod11RValues,Nod12RValues;
1257 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1258 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1259 Nod11Indices = (*pi1p1)->Indices();
1260 Nod11RValues = (*pi1p1)->RValues();
1261 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1262 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1263 Nod12Indices = (*pi1p2)->Indices();
1264 Nod12RValues = (*pi1p2)->RValues();
1265 Nod11Flag |= NMskVert;
1266 Nod12Flag |= NMskVert;
1268 for (iPol = 1; iPol <= nbPol; iPol++) {
1269 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1270 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1271 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1272 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1273 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1275 Nod1APCu1 = par->Value(iPol);
1279 Nod1APCu2 = par->Value(iPol);
1284 Nod12Indices = Nod11Indices;
1285 Nod12RValues = Nod11RValues;
1286 XTI2 = X2 = Nod12PntX;
1287 YTI2 = Y2 = Nod12PntY;
1288 ZTI2 = Z2 = Nod12PntZ;
1289 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1290 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1293 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1294 cout << "Parameter error on Node " << i1p2 << endl;
1297 Nod12Flag |= NMskEdge;
1298 TIMultiply(XTI2,YTI2,ZTI2);
1299 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1300 U2 = U2 - myPC.Period();
1302 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1303 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1304 Nod12Indices,Nod12RValues);
1305 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1306 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1310 for (iPol = 2; iPol <= nbPol; iPol++) {
1312 Nod11Indices = Nod12Indices;
1313 Nod11RValues = Nod12RValues;
1315 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1316 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1317 Nod12Indices = (*pi1p2)->Indices();
1318 Nod12RValues = (*pi1p2)->RValues();
1321 if (Nod11NrmX*Nod12NrmX +
1322 Nod11NrmY*Nod12NrmY +
1323 Nod11NrmZ*Nod12NrmZ < 0) {
1324 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1325 cout << "Too big angle between " << i1p1 << setw(6);
1326 cout << " and " << i1p2 << setw(6);
1327 cout << " in face " << i1 << endl;
1338 XTI2 = X2 = Nod12PntX;
1339 YTI2 = Y2 = Nod12PntY;
1340 ZTI2 = Z2 = Nod12PntZ;
1341 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1342 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1345 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1346 cout << "Parameter error on Node " << i1p2 << endl;
1349 Nod12Flag |= NMskEdge;
1350 TIMultiply(XTI2,YTI2,ZTI2);
1352 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1353 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1355 Nod11Indices,Nod11RValues,
1356 Nod12Indices,Nod12RValues,
1357 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1);
1363 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1364 cout << e << " connex 1 sans PolygonOnTriangulation" << endl;
1368 else if (nbConnex == 2) {
1369 TopTools_ListIteratorOfListOfShape itn(LS);
1370 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1371 i1 = myFMap.FindIndex(F1);
1372 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1373 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1375 const TopoDS_Face& F2 = TopoDS::Face(itn.Value());
1376 i2 = myFMap.FindIndex(F2);
1377 if (i1 == i2) E.Reverse();
1378 const Handle(Poly_Triangulation)& Tr2 = BRep_Tool::Triangulation(F2,L);
1379 HPol[1] = BRep_Tool::PolygonOnTriangulation(E,Tr2,L);
1380 GeomAbs_Shape rg = BRep_Tool::Continuity(E,F1,F2);
1381 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1382 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1383 const Handle(HLRAlgo_PolyInternalData)& pid2 =
1384 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i2));
1385 if (!HPol[0].IsNull() && !HPol[1].IsNull()) {
1386 myPC.Initialize(E,F1);
1387 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1388 const TColStd_Array1OfInteger& Pol2 = HPol[1]->Nodes();
1389 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1390 Standard_Integer nbPol = Pol1.Upper();
1391 Standard_Address TData1 = &pid1->TData();
1392 Standard_Address PISeg1 = &pid1->PISeg();
1393 Standard_Address PINod1 = &pid1->PINod();
1394 Standard_Address TData2 = &pid2->TData();
1395 Standard_Address PISeg2 = &pid2->PISeg();
1396 Standard_Address PINod2 = &pid2->PINod();
1397 Standard_Address Nod11Indices,Nod11RValues;
1398 Standard_Address Nod12Indices,Nod12RValues;
1399 Standard_Address Nod21Indices,Nod21RValues;
1400 Standard_Address Nod22Indices,Nod22RValues;
1401 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1402 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1403 Nod11Indices = (*pi1p1)->Indices();
1404 Nod11RValues = (*pi1p1)->RValues();
1405 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1406 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1407 Nod12Indices = (*pi1p2)->Indices();
1408 Nod12RValues = (*pi1p2)->RValues();
1409 const Handle(HLRAlgo_PolyInternalNode)* pi2p1 =
1410 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(1 )));
1411 Nod21Indices = (*pi2p1)->Indices();
1412 Nod21RValues = (*pi2p1)->RValues();
1413 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1414 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(nbPol)));
1415 Nod22Indices = (*pi2p2)->Indices();
1416 Nod22RValues = (*pi2p2)->RValues();
1417 Nod11Flag |= NMskVert;
1418 Nod12Flag |= NMskVert;
1419 Nod21Flag |= NMskVert;
1420 Nod22Flag |= NMskVert;
1422 for (iPol = 1; iPol <= nbPol; iPol++) {
1423 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1424 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1425 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1426 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1427 const Handle(HLRAlgo_PolyInternalNode)* pi2pA =
1428 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1429 Standard_Address Nod2AIndices = (*pi2pA)->Indices();
1430 Standard_Address Nod2ARValues = (*pi2pA)->RValues();
1431 Standard_Real PCu = par->Value(iPol);
1432 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1440 if (Nod2AEdg1 == 0 || Nod2AEdg1 == (Standard_Boolean) e) {
1451 Nod12Indices = Nod11Indices;
1452 Nod12RValues = Nod11RValues;
1454 Nod22Indices = Nod21Indices;
1455 Nod22RValues = Nod21RValues;
1456 XTI2 = X2 = Nod12PntX;
1457 YTI2 = Y2 = Nod12PntY;
1458 ZTI2 = Z2 = Nod12PntZ;
1459 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1460 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1463 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1464 cout << "Parameter error on Node " << i1p2 << endl;
1467 Nod12Flag |= NMskEdge;
1468 Nod22Flag |= NMskEdge;
1469 TIMultiply(XTI2,YTI2,ZTI2);
1470 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1471 U2 = U2 - myPC.Period();
1473 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1474 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1475 Nod12Indices,Nod12RValues);
1476 CheckDegeneratedSegment(Nod21Indices,Nod21RValues,
1477 Nod22Indices,Nod22RValues);
1478 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1479 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1480 UpdateAroundNode(Pol2(1 ),Nod21Indices,TData2,PISeg2,PINod2);
1481 UpdateAroundNode(Pol2(nbPol),Nod22Indices,TData2,PISeg2,PINod2);
1485 for (iPol = 2; iPol <= nbPol; iPol++) {
1487 Nod11Indices = Nod12Indices;
1488 Nod11RValues = Nod12RValues;
1490 Nod21Indices = Nod22Indices;
1491 Nod21RValues = Nod22RValues;
1493 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1494 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1495 Nod12Indices = (*pi1p2)->Indices();
1496 Nod12RValues = (*pi1p2)->RValues();
1498 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1499 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1500 Nod22Indices = (*pi2p2)->Indices();
1501 Nod22RValues = (*pi2p2)->RValues();
1504 if (Nod11NrmX*Nod12NrmX +
1505 Nod11NrmY*Nod12NrmY +
1506 Nod11NrmZ*Nod12NrmZ < 0) {
1507 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1508 cout << "To big angle between " << i1p1 << setw(6);
1509 cout << " and " << i1p2 << setw(6);
1510 cout << " in face " << i1 << endl;
1512 if (Nod21NrmX*Nod22NrmX +
1513 Nod21NrmY*Nod22NrmY +
1514 Nod21NrmZ*Nod22NrmZ < 0) {
1515 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1516 cout << "To big angle between " << i2p1 << setw(6);
1517 cout << " and " << i2p2 << setw(6);
1518 cout<< " in face " << i2 << endl;
1529 XTI2 = X2 = Nod12PntX;
1530 YTI2 = Y2 = Nod12PntY;
1531 ZTI2 = Z2 = Nod12PntZ;
1532 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1533 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1536 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1537 cout << "Parameter error on Node " << i1p2 << endl;
1540 Nod12Flag |= NMskEdge;
1541 Nod22Flag |= NMskEdge;
1542 TIMultiply(XTI2,YTI2,ZTI2);
1544 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1545 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1547 Nod11Indices,Nod11RValues,
1548 Nod12Indices,Nod12RValues,
1549 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1550 Nod21Indices,Nod21RValues,
1551 Nod22Indices,Nod22RValues,
1552 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2);
1558 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1559 cout << e << " connect 2 without PolygonOnTriangulation" << endl;
1564 else { // no connexity
1565 const Handle(Poly_Polygon3D)& Polyg = BRep_Tool::Polygon3D(E,L);
1566 if (!Polyg.IsNull()) {
1567 const TColgp_Array1OfPnt& Pol = Polyg->Nodes();
1568 gp_Trsf TT = L.Transformation();
1569 const gp_Trsf& T = myProj.Transformation();
1571 const gp_XYZ& ttlo = TT.TranslationPart();
1575 const gp_Mat& ttma = TT.VectorialPart();
1576 TTMa[0][0] = ttma.Value(1,1);
1577 TTMa[0][1] = ttma.Value(1,2);
1578 TTMa[0][2] = ttma.Value(1,3);
1579 TTMa[1][0] = ttma.Value(2,1);
1580 TTMa[1][1] = ttma.Value(2,2);
1581 TTMa[1][2] = ttma.Value(2,3);
1582 TTMa[2][0] = ttma.Value(3,1);
1583 TTMa[2][1] = ttma.Value(3,2);
1584 TTMa[2][2] = ttma.Value(3,3);
1585 Standard_Integer nbPol = Pol.Upper();
1586 const gp_XYZ& P1 = Pol(1).XYZ();
1590 TTMultiply(X2,Y2,Z2);
1594 TIMultiply(XTI2,YTI2,ZTI2);
1596 for (Standard_Integer iPol = 2; iPol <= nbPol; iPol++) {
1603 const gp_XYZ& P2 = Pol(iPol).XYZ();
1607 TTMultiply(X2,Y2,Z2);
1611 TIMultiply(XTI2,YTI2,ZTI2);
1612 List.Prepend(HLRAlgo_BiPoint
1613 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1614 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1620 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1621 cout << e << " Isolated, without Polygone 3D" << endl;
1627 //=======================================================================
1628 //function : Interpolation
1630 //=======================================================================
1634 Interpolation (HLRAlgo_ListOfBPoint& List,
1641 Standard_Real& XTI1,
1642 Standard_Real& YTI1,
1643 Standard_Real& ZTI1,
1644 Standard_Real& XTI2,
1645 Standard_Real& YTI2,
1646 Standard_Real& ZTI2,
1647 const Standard_Integer e,
1650 Standard_Address& Nod11Indices,
1651 Standard_Address& Nod11RValues,
1652 Standard_Address& Nod12Indices,
1653 Standard_Address& Nod12RValues,
1654 const Standard_Integer i1p1,
1655 const Standard_Integer i1p2,
1656 const Standard_Integer i1,
1657 const Handle(HLRAlgo_PolyInternalData)& pid1,
1658 Standard_Address& TData1,
1659 Standard_Address& PISeg1,
1660 Standard_Address& PINod1) const
1662 Standard_Boolean insP3,mP3P1;
1663 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1665 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1666 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1667 MoveOrInsertPoint(List,
1668 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1669 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1671 Nod11Indices,Nod11RValues,
1672 Nod12Indices,Nod12RValues,
1673 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1674 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,0);
1677 //=======================================================================
1678 //function : Interpolation
1680 //=======================================================================
1684 Interpolation (HLRAlgo_ListOfBPoint& List,
1691 Standard_Real& XTI1,
1692 Standard_Real& YTI1,
1693 Standard_Real& ZTI1,
1694 Standard_Real& XTI2,
1695 Standard_Real& YTI2,
1696 Standard_Real& ZTI2,
1697 const Standard_Integer e,
1700 const GeomAbs_Shape rg,
1701 Standard_Address& Nod11Indices,
1702 Standard_Address& Nod11RValues,
1703 Standard_Address& Nod12Indices,
1704 Standard_Address& Nod12RValues,
1705 const Standard_Integer i1p1,
1706 const Standard_Integer i1p2,
1707 const Standard_Integer i1,
1708 const Handle(HLRAlgo_PolyInternalData)& pid1,
1709 Standard_Address& TData1,
1710 Standard_Address& PISeg1,
1711 Standard_Address& PINod1,
1712 Standard_Address& Nod21Indices,
1713 Standard_Address& Nod21RValues,
1714 Standard_Address& Nod22Indices,
1715 Standard_Address& Nod22RValues,
1716 const Standard_Integer i2p1,
1717 const Standard_Integer i2p2,
1718 const Standard_Integer i2,
1719 const Handle(HLRAlgo_PolyInternalData)& pid2,
1720 Standard_Address& TData2,
1721 Standard_Address& PISeg2,
1722 Standard_Address& PINod2) const
1724 Standard_Boolean insP3,mP3P1,insP4,mP4P1;
1725 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1726 Standard_Real X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4;
1727 // gp_Pnt P3,PT3,P4,PT4;
1728 Standard_Boolean flag = 0;
1729 if (rg >= GeomAbs_G1) flag += 1;
1730 if (rg >= GeomAbs_G2) flag += 2;
1731 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1732 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1733 insP4 = Interpolation(U1,U2,Nod21RValues,Nod22RValues,
1734 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,mP4P1);
1735 Standard_Boolean OK = insP3 || insP4;
1737 if (!insP4) // p1 i1p3 p2
1738 MoveOrInsertPoint(List,
1739 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1740 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1742 Nod11Indices,Nod11RValues,
1743 Nod12Indices,Nod12RValues,
1744 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1745 Nod21Indices,Nod21RValues,
1746 Nod22Indices,Nod22RValues,
1747 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1748 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1749 else if (!insP3) // p1 i2p4 p2
1750 MoveOrInsertPoint(List,
1751 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1752 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1754 Nod21Indices,Nod21RValues,
1755 Nod22Indices,Nod22RValues,
1756 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1757 Nod11Indices,Nod11RValues,
1758 Nod12Indices,Nod12RValues,
1759 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1760 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1761 else if (Abs(coef4 - coef3) < myTolSta) // p1 i1p3-i2p4 p2
1762 MoveOrInsertPoint(List,
1763 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1764 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1766 Nod21Indices,Nod21RValues,
1767 Nod22Indices,Nod22RValues,
1768 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1769 Nod11Indices,Nod11RValues,
1770 Nod12Indices,Nod12RValues,
1771 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1772 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1773 else if (coef4 < coef3) // p1 i2p4 i1p3 p2
1774 MoveOrInsertPoint(List,
1775 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1776 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1778 Nod21Indices,Nod21RValues,
1779 Nod22Indices,Nod22RValues,
1780 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1781 Nod11Indices,Nod11RValues,
1782 Nod12Indices,Nod12RValues,
1783 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1784 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,
1785 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1786 else // p1 i1p3 i2p4 p2
1787 MoveOrInsertPoint(List,
1788 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1789 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1791 Nod11Indices,Nod11RValues,
1792 Nod12Indices,Nod12RValues,
1793 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1794 Nod21Indices,Nod21RValues,
1795 Nod22Indices,Nod22RValues,
1796 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1797 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,
1798 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1801 List.Prepend(HLRAlgo_BiPoint
1802 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1803 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1804 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
1807 //=======================================================================
1808 //function : Interpolation
1810 //=======================================================================
1814 Interpolation (const Standard_Real U1,
1815 const Standard_Real U2,
1816 const Standard_Address Nod1RValues,
1817 const Standard_Address Nod2RValues,
1821 Standard_Real& XTI3,
1822 Standard_Real& YTI3,
1823 Standard_Real& ZTI3,
1824 Standard_Real& coef3,
1826 Standard_Boolean& mP3P1) const
1828 if (NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1)) {
1829 U3 = U1 + (U2 - U1) * coef3;
1830 const gp_Pnt& P3 = myBCurv.Value(U3);
1834 TMultiply(X3,Y3,Z3);
1835 return Standard_True;
1837 return Standard_False;
1840 //=======================================================================
1841 //function : MoveOrInsertPoint
1843 //=======================================================================
1847 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1854 Standard_Real& XTI1,
1855 Standard_Real& YTI1,
1856 Standard_Real& ZTI1,
1857 Standard_Real& XTI2,
1858 Standard_Real& YTI2,
1859 Standard_Real& ZTI2,
1860 const Standard_Integer e,
1863 Standard_Address& Nod11Indices,
1864 Standard_Address& Nod11RValues,
1865 Standard_Address& Nod12Indices,
1866 Standard_Address& Nod12RValues,
1867 const Standard_Integer i1p1,
1868 const Standard_Integer i1p2,
1869 const Standard_Integer i1,
1870 const Handle(HLRAlgo_PolyInternalData)& pid1,
1871 Standard_Address& TData1,
1872 Standard_Address& PISeg1,
1873 Standard_Address& PINod1,
1874 const Standard_Real X3,
1875 const Standard_Real Y3,
1876 const Standard_Real Z3,
1877 const Standard_Real XTI3,
1878 const Standard_Real YTI3,
1879 const Standard_Real ZTI3,
1880 const Standard_Real coef3,
1881 const Standard_Real U3,
1882 const Standard_Boolean insP3,
1883 const Standard_Boolean mP3P1,
1884 const Standard_Boolean flag) const
1886 Standard_Address TData2 = 0;
1887 Standard_Address PISeg2 = 0;
1888 Standard_Address PINod2 = 0;
1889 Standard_Boolean ins3 = insP3;
1890 if (ins3 && mP3P1) { // P1 ---> P3
1891 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
1892 ins3 = Standard_False;
1893 ChangeNode(i1p1,i1p2,
1894 Nod11Indices,Nod11RValues,
1895 Nod12Indices,Nod12RValues,
1896 coef3,X3,Y3,Z3,Standard_True,
1897 TData1,PISeg1,PINod1);
1908 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
1909 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
1912 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1913 cout << "Parameter error on Node " << i1p1 << endl;
1917 Nod11Flag |= NMskOutL;
1918 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
1919 Standard_Address Coordinates = List.First().Coordinates();
1928 if (ins3 && !mP3P1) { // P2 ---> P3
1929 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
1930 ins3 = Standard_False;
1931 ChangeNode(i1p1,i1p2,
1932 Nod11Indices,Nod11RValues,
1933 Nod12Indices,Nod12RValues,
1934 coef3,X3,Y3,Z3,Standard_False,
1935 TData1,PISeg1,PINod1);
1946 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
1947 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
1950 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1951 cout << "Parameter error on Node " << i1p2 << endl;
1955 Nod12Flag |= NMskOutL;
1956 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
1959 if (ins3) { // p1 i1p3 p2
1960 Standard_Integer i1p3 = pid1->AddNode
1961 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
1962 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
1963 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
1964 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
1965 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
1969 Nod13Flag |= NMskOutL;
1970 Nod13Flag |= NMskEdge;
1971 pid1->UpdateLinks(i1p1,i1p2,i1p3,
1972 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
1973 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
1974 List.Prepend(HLRAlgo_BiPoint
1975 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
1976 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
1977 i1 ,i1p1,i1p3,flag));
1978 List.Prepend(HLRAlgo_BiPoint
1979 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
1980 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
1981 i1 ,i1p3,i1p2,flag));
1984 List.Prepend(HLRAlgo_BiPoint
1985 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1986 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1987 i1 ,i1p1,i1p2,flag));
1990 //=======================================================================
1991 //function : MoveOrInsertPoint
1993 //=======================================================================
1997 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
2004 Standard_Real& XTI1,
2005 Standard_Real& YTI1,
2006 Standard_Real& ZTI1,
2007 Standard_Real& XTI2,
2008 Standard_Real& YTI2,
2009 Standard_Real& ZTI2,
2010 const Standard_Integer e,
2013 Standard_Address& Nod11Indices,
2014 Standard_Address& Nod11RValues,
2015 Standard_Address& Nod12Indices,
2016 Standard_Address& Nod12RValues,
2017 const Standard_Integer i1p1,
2018 const Standard_Integer i1p2,
2019 const Standard_Integer i1,
2020 const Handle(HLRAlgo_PolyInternalData)& pid1,
2021 Standard_Address& TData1,
2022 Standard_Address& PISeg1,
2023 Standard_Address& PINod1,
2024 Standard_Address& Nod21Indices,
2025 Standard_Address& Nod21RValues,
2026 Standard_Address& Nod22Indices,
2027 Standard_Address& Nod22RValues,
2028 const Standard_Integer i2p1,
2029 const Standard_Integer i2p2,
2030 const Standard_Integer i2,
2031 const Handle(HLRAlgo_PolyInternalData)& pid2,
2032 Standard_Address& TData2,
2033 Standard_Address& PISeg2,
2034 Standard_Address& PINod2,
2035 const Standard_Real X3,
2036 const Standard_Real Y3,
2037 const Standard_Real Z3,
2038 const Standard_Real XTI3,
2039 const Standard_Real YTI3,
2040 const Standard_Real ZTI3,
2041 const Standard_Real coef3,
2042 const Standard_Real U3,
2043 const Standard_Boolean insP3,
2044 const Standard_Boolean mP3P1,
2045 const Standard_Boolean flag) const
2047 Standard_Boolean ins3 = insP3;
2048 if (ins3 && mP3P1) { // P1 ---> P3
2049 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2050 ins3 = Standard_False;
2051 ChangeNode(i1p1,i1p2,
2052 Nod11Indices,Nod11RValues,
2053 Nod12Indices,Nod12RValues,
2054 coef3,X3,Y3,Z3,Standard_True,
2055 TData1,PISeg1,PINod1);
2056 ChangeNode(i2p1,i2p2,
2057 Nod21Indices,Nod21RValues,
2058 Nod22Indices,Nod22RValues,
2059 coef3,X3,Y3,Z3,Standard_True,
2060 TData2,PISeg2,PINod2);
2071 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2072 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2075 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2076 cout << "Parameter error on Node " << i1p1 << endl;
2080 Nod11Flag |= NMskOutL;
2081 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2085 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2086 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2089 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2090 cout << "Parameter error on Node " << i2p1 << endl;
2094 Nod21Flag |= NMskOutL;
2095 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2096 Standard_Address Coordinates = List.First().Coordinates();
2105 if (ins3 && !mP3P1) { // P2 ---> P3
2106 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
2107 ins3 = Standard_False;
2108 ChangeNode(i1p1,i1p2,
2109 Nod11Indices,Nod11RValues,
2110 Nod12Indices,Nod12RValues,
2111 coef3,X3,Y3,Z3,Standard_False,
2112 TData1,PISeg1,PINod1);
2113 ChangeNode(i2p1,i2p2,
2114 Nod21Indices,Nod21RValues,
2115 Nod22Indices,Nod22RValues,
2116 coef3,X3,Y3,Z3,Standard_False,
2117 TData2,PISeg2,PINod2);
2128 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
2129 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
2132 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2133 cout << "Parameter error on Node " << i1p2 << endl;
2137 Nod12Flag |= NMskOutL;
2138 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2142 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U3;
2143 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U3;
2146 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2147 cout << "Parameter error on Node " << i2p2 << endl;
2151 Nod22Flag |= NMskOutL;
2152 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2155 if (ins3) { // p1 i1p3 p2
2156 Standard_Integer i1p3 = pid1->AddNode
2157 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2158 Standard_Integer i2p3 = pid2->AddNode
2159 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2160 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2161 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2162 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2163 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2164 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2165 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2166 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2167 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2171 Nod13Flag |= NMskOutL;
2172 Nod13Flag |= NMskEdge;
2176 Nod23Flag |= NMskOutL;
2177 Nod23Flag |= NMskEdge;
2178 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2179 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2180 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2181 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2182 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2183 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2184 List.Prepend(HLRAlgo_BiPoint
2185 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2186 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2187 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2188 List.Prepend(HLRAlgo_BiPoint
2189 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
2190 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
2191 i1 ,i1p3,i1p2,i2 ,i2p3,i2p2,flag));
2194 List.Prepend(HLRAlgo_BiPoint
2195 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2196 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2197 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2200 //=======================================================================
2201 //function : MoveOrInsertPoint
2203 //=======================================================================
2207 MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
2214 Standard_Real& XTI1,
2215 Standard_Real& YTI1,
2216 Standard_Real& ZTI1,
2217 Standard_Real& XTI2,
2218 Standard_Real& YTI2,
2219 Standard_Real& ZTI2,
2220 const Standard_Integer e,
2223 Standard_Address& Nod11Indices,
2224 Standard_Address& Nod11RValues,
2225 Standard_Address& Nod12Indices,
2226 Standard_Address& Nod12RValues,
2227 const Standard_Integer i1p1,
2228 const Standard_Integer i1p2,
2229 const Standard_Integer i1,
2230 const Handle(HLRAlgo_PolyInternalData)& pid1,
2231 Standard_Address& TData1,
2232 Standard_Address& PISeg1,
2233 Standard_Address& PINod1,
2234 Standard_Address& Nod21Indices,
2235 Standard_Address& Nod21RValues,
2236 Standard_Address& Nod22Indices,
2237 Standard_Address& Nod22RValues,
2238 const Standard_Integer i2p1,
2239 const Standard_Integer i2p2,
2240 const Standard_Integer i2,
2241 const Handle(HLRAlgo_PolyInternalData)& pid2,
2242 Standard_Address& TData2,
2243 Standard_Address& PISeg2,
2244 Standard_Address& PINod2,
2245 const Standard_Real X3,
2246 const Standard_Real Y3,
2247 const Standard_Real Z3,
2248 const Standard_Real XTI3,
2249 const Standard_Real YTI3,
2250 const Standard_Real ZTI3,
2251 const Standard_Real coef3,
2252 const Standard_Real U3,
2253 const Standard_Boolean insP3,
2254 const Standard_Boolean mP3P1,
2255 const Standard_Real X4,
2256 const Standard_Real Y4,
2257 const Standard_Real Z4,
2258 const Standard_Real XTI4,
2259 const Standard_Real YTI4,
2260 const Standard_Real ZTI4,
2261 const Standard_Real coef4,
2262 const Standard_Real U4,
2263 const Standard_Boolean insP4,
2264 const Standard_Boolean mP4P1,
2265 const Standard_Boolean flag) const
2267 Standard_Boolean ins3 = insP3;
2268 Standard_Boolean ins4 = insP4;
2269 if (ins3 && mP3P1) { // P1 ---> P3
2270 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2271 ins3 = Standard_False;
2272 ChangeNode(i1p1,i1p2,
2273 Nod11Indices,Nod11RValues,
2274 Nod12Indices,Nod12RValues,
2275 coef3,X3,Y3,Z3,Standard_True,
2276 TData1,PISeg1,PINod1);
2277 ChangeNode(i2p1,i2p2,
2278 Nod21Indices,Nod21RValues,
2279 Nod22Indices,Nod22RValues,
2280 coef3,X3,Y3,Z3,Standard_True,
2281 TData2,PISeg2,PINod2);
2292 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2293 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2296 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2297 cout << "Parameter error on Node " << i1p1 << endl;
2301 Nod11Flag |= NMskOutL;
2302 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2306 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2307 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2310 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2311 cout << "Parameter error on Node " << i2p1 << endl;
2315 Nod21Flag |= NMskOutL;
2316 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2317 Standard_Address Coordinates = List.First().Coordinates();
2326 if (ins4 && !mP4P1) { // P2 ---> P4
2327 if (!(Nod12Flag & NMskVert) && coef4 > myTolEnd) {
2328 ins4 = Standard_False;
2329 ChangeNode(i2p1,i2p2,
2330 Nod21Indices,Nod21RValues,
2331 Nod22Indices,Nod22RValues,
2332 coef4,X4,Y4,Z4,Standard_False,
2333 TData2,PISeg2,PINod2);
2334 ChangeNode(i1p1,i1p2,
2335 Nod11Indices,Nod11RValues,
2336 Nod12Indices,Nod12RValues,
2337 coef4,X4,Y4,Z4,Standard_False,
2338 TData1,PISeg1,PINod1);
2349 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U4;
2350 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U4;
2353 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2354 cout << "Parameter error on Node " << i1p2 << endl;
2358 Nod12Flag |= NMskOutL;
2359 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2363 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U4;
2364 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U4;
2367 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2368 cout << "Parameter error on Node " << i2p2 << endl;
2372 Nod22Flag |= NMskOutL;
2373 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2377 if (!ins4) // p1 i1p3 p2
2378 MoveOrInsertPoint(List,
2379 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2380 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2382 Nod11Indices,Nod11RValues,
2383 Nod12Indices,Nod12RValues,
2384 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2385 Nod21Indices,Nod21RValues,
2386 Nod22Indices,Nod22RValues,
2387 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2388 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
2389 else if (!ins3) // p1 i2p4 p2
2390 MoveOrInsertPoint(List,
2391 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2392 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2394 Nod21Indices,Nod21RValues,
2395 Nod22Indices,Nod22RValues,
2396 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2397 Nod11Indices,Nod11RValues,
2398 Nod12Indices,Nod12RValues,
2399 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2400 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
2401 else { // p1 i1p3 i2p4 p2
2402 Standard_Integer i1p3 = pid1->AddNode
2403 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2404 Standard_Integer i2p3 = pid2->AddNode
2405 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2406 Standard_Integer i1p4 = pid1->AddNode
2407 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef4,X4,Y4,Z4);
2408 Standard_Integer i2p4 = pid2->AddNode
2409 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef4,X4,Y4,Z4);
2410 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2411 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2412 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2413 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2414 const Handle(HLRAlgo_PolyInternalNode)* pi1p4 =
2415 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p4));
2416 const Standard_Address Nod14Indices = (*pi1p4)->Indices();
2417 const Standard_Address Nod14RValues = (*pi1p4)->RValues();
2418 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2419 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2420 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2421 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2422 const Handle(HLRAlgo_PolyInternalNode)* pi2p4 =
2423 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p4));
2424 const Standard_Address Nod24Indices = (*pi2p4)->Indices();
2425 const Standard_Address Nod24RValues = (*pi2p4)->RValues();
2429 Nod13Flag |= NMskOutL;
2430 Nod13Flag |= NMskEdge;
2434 Nod23Flag |= NMskOutL;
2435 Nod23Flag |= NMskEdge;
2439 Nod14Flag |= NMskOutL;
2440 Nod14Flag |= NMskEdge;
2444 Nod24Flag |= NMskOutL;
2445 Nod24Flag |= NMskEdge;
2446 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2447 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2448 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2449 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2450 pid2->UpdateLinks(i2p3,i2p2,i2p4,
2451 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2452 pid1->UpdateLinks(i1p3,i1p2,i1p4,
2453 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2454 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2455 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2456 UpdateAroundNode(i1p4,Nod14Indices,TData1,PISeg1,PINod1);
2457 UpdateAroundNode(i2p4,Nod24Indices,TData2,PISeg2,PINod2);
2458 List.Prepend(HLRAlgo_BiPoint
2459 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2460 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2461 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2462 List.Prepend(HLRAlgo_BiPoint
2463 (XTI3,YTI3,ZTI3,XTI4,YTI4,ZTI4,
2464 X3 ,Y3 ,Z3 ,X4 ,Y4 ,Z4 , e,
2465 i1 ,i1p3,i1p4,i2 ,i2p3,i2p4,flag));
2466 List.Prepend(HLRAlgo_BiPoint
2467 (XTI4,YTI4,ZTI4,XTI2,YTI2,ZTI2,
2468 X4 ,Y4 ,Z4 ,X2 ,Y2 ,Z2 , e,
2469 i1 ,i1p4,i1p2,i2 ,i2p4,i2p2,flag));
2473 List.Prepend(HLRAlgo_BiPoint
2474 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2475 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2476 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2479 //=======================================================================
2480 //function : InsertOnOutLine
2482 //=======================================================================
2485 HLRBRep_PolyAlgo::InsertOnOutLine (TColStd_Array1OfTransient& PID)
2487 Standard_Address TData2 = 0;
2488 Standard_Address PISeg2 = 0;
2489 Standard_Address PINod2 = 0;
2490 Standard_Address Seg1Indices;
2491 Standard_Address Nod1Indices,Nod1RValues;
2492 Standard_Address Nod2Indices,Nod2RValues;
2493 Handle(HLRAlgo_PolyInternalData)* pid =
2494 (Handle(HLRAlgo_PolyInternalData)*) (&(PID.ChangeValue(1)));
2497 Standard_Boolean insP3,mP3P1,IntOutL;
2498 Standard_Integer f,ip1,ip2,ip3;//, i;
2499 Standard_Real U3,V3,coef3,X3 = 0.,Y3 = 0.,Z3 = 0.;
2501 const gp_Trsf& T = myProj.Transformation();
2503 Standard_Integer nbFace = myFMap.Extent();
2504 for (f = 1; f <= nbFace; f++) {
2506 if (!((*pid).IsNull())) {
2507 IntOutL = Standard_False;
2508 Standard_Address TData1= &((*pid)->TData());
2509 Standard_Address PISeg1= &((*pid)->PISeg());
2510 Standard_Address PINod1= &((*pid)->PINod());
2511 TopoDS_Shape LocalShape = myFMap(f);
2512 const TopoDS_Face& F = TopoDS::Face(LocalShape);
2513 myBSurf.Initialize(F,Standard_False);
2514 myGSurf = BRep_Tool::Surface(F,L);
2515 gp_Trsf TT = L.Transformation();
2517 const gp_XYZ& ttlo = TT.TranslationPart();
2521 const gp_Mat& ttma = TT.VectorialPart();
2522 TTMa[0][0] = ttma.Value(1,1);
2523 TTMa[0][1] = ttma.Value(1,2);
2524 TTMa[0][2] = ttma.Value(1,3);
2525 TTMa[1][0] = ttma.Value(2,1);
2526 TTMa[1][1] = ttma.Value(2,2);
2527 TTMa[1][2] = ttma.Value(2,3);
2528 TTMa[2][0] = ttma.Value(3,1);
2529 TTMa[2][1] = ttma.Value(3,2);
2530 TTMa[2][2] = ttma.Value(3,3);
2534 cout << " InsertOnOutLine : NbTData " << (*pid)->NbTData() << endl;
2535 cout << " InsertOnOutLine : NbPISeg " << (*pid)->NbPISeg() << endl;
2536 cout << " InsertOnOutLine : NbPINod " << (*pid)->NbPINod() << endl;
2540 Standard_Integer iseg,nbS;
2541 nbS = (*pid)->NbPISeg();
2542 for (iseg = 1; iseg <= nbS; iseg++) {
2544 ((HLRAlgo_Array1OfPISeg*)PISeg1)->ChangeValue(iseg).Indices();
2545 // Standard_Boolean Cutted = Standard_False;
2546 if (Seg1Conex1 != 0 && Seg1Conex2 != 0) {
2549 const Handle(HLRAlgo_PolyInternalNode)* pip1 =
2550 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip1));
2551 Nod1Indices = (*pip1)->Indices();
2552 Nod1RValues = (*pip1)->RValues();
2553 const Handle(HLRAlgo_PolyInternalNode)* pip2 =
2554 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip2));
2555 Nod2Indices = (*pip2)->Indices();
2556 Nod2RValues = (*pip2)->RValues();
2557 if (Nod1Flag & NMskOutL && Nod2Flag & NMskOutL)
2558 IntOutL = Standard_True;
2559 else if ((Nod1Scal >= myTolAngular &&
2560 Nod2Scal <= -myTolAngular) ||
2561 (Nod2Scal >= myTolAngular &&
2562 Nod1Scal <= -myTolAngular)) {
2563 IntOutL = Standard_True;
2564 insP3 = NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1);
2566 UVNode(Nod1RValues,Nod2RValues,coef3,U3,V3);
2567 const gp_Pnt& PT3 = myGSurf->Value(U3,V3);
2571 TTMultiply(X3,Y3,Z3);
2574 if (insP3 && mP3P1) { // P1 ---> P3
2575 if ((Nod1Flag & NMskEdge) == 0 && coef3 < myTolSta) {
2576 insP3 = Standard_False;
2578 Nod1Indices,Nod1RValues,
2579 Nod2Indices,Nod2RValues,
2580 coef3,X3,Y3,Z3,Standard_True,
2581 TData1,PISeg1,PINod1);
2583 Nod1Flag |= NMskOutL;
2586 if (insP3 && !mP3P1) { // P2 ---> P3
2587 if ((Nod2Flag & NMskEdge) == 0 && coef3 > myTolEnd) {
2588 insP3 = Standard_False;
2590 Nod1Indices,Nod1RValues,
2591 Nod2Indices,Nod2RValues,
2592 coef3,X3,Y3,Z3,Standard_False,
2593 TData1,PISeg1,PINod1);
2595 Nod2Flag |= NMskOutL;
2598 if (insP3) { // p1 ip3 p2
2599 ip3 = (*pid)->AddNode(Nod1RValues,Nod2RValues,PINod1,PINod2,
2601 const Handle(HLRAlgo_PolyInternalNode)* pip3 =
2602 (&((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip3));
2603 const Standard_Address Nod3Indices = (*pip3)->Indices();
2604 const Standard_Address Nod3RValues = (*pip3)->RValues();
2605 (*pid)->UpdateLinks(ip1,ip2,ip3,
2606 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2607 UpdateAroundNode(ip3,Nod3Indices,TData1,PISeg1,PINod1);
2609 Nod3Flag |= NMskOutL;
2615 (*pid)->IntOutL(Standard_True);
2617 nbS = (*pid)->NbPISeg();
2621 cout << " InsertOnOutLine : NbTData " << (*pid)->NbTData() << endl;
2622 cout << " InsertOnOutLine : NbPISeg " << (*pid)->NbPISeg() << endl;
2623 cout << " InsertOnOutLine : NbPINod " << (*pid)->NbPINod() << endl;
2631 //=======================================================================
2632 //function : CheckFrBackTriangles
2634 //=======================================================================
2637 HLRBRep_PolyAlgo::CheckFrBackTriangles (HLRAlgo_ListOfBPoint& List,
2638 TColStd_Array1OfTransient& PID)
2640 Standard_Integer f,i,nbN,nbT,nbFace;
2641 Standard_Real X1 =0.,Y1 =0.,X2 =0.,Y2 =0.,X3 =0.,Y3 =0.;
2642 Standard_Real D1,D2,D3;
2643 Standard_Real dd,dX,dY,nX,nY;
2644 Standard_Boolean FrBackInList;
2645 Standard_Address TData ,PISeg ,PINod ;
2646 /* Standard_Address IndexPtr = NULL;
2647 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2648 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2649 Standard_Address TData1 = &pid1->TData(),
2650 PISeg1 = &pid1->PISeg(),
2651 PINod1 = &pid1->PINod();
2653 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2654 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2655 Standard_Address TData2 = &pid2->TData(),
2656 PISeg2 = &pid2->PISeg(),
2657 PINod2 = &pid2->PISeg();*/
2658 Standard_Address TData1 = NULL,PISeg1 = NULL,PINod1 = NULL;
2659 Standard_Address TData2 = NULL,PISeg2 = NULL,PINod2 = NULL;
2660 Standard_Address Nod11Indices,Nod12Indices,Nod13Indices;
2661 Standard_Address Nod11RValues,Nod12RValues,Nod13RValues;
2662 Standard_Address Tri1Indices;
2664 Handle(HLRAlgo_PolyInternalData)* pid;
2666 nbFace = myFMap.Extent();
2667 Standard_Boolean Modif = Standard_True;
2668 Standard_Integer iLoop = 0;
2670 while (Modif && iLoop < 4) {
2672 Modif = Standard_False;
2673 FrBackInList = Standard_False;
2674 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2676 for (f = 1; f <= nbFace; f++) {
2677 if (!(*pid).IsNull()) {
2678 nbT = (*pid)->NbTData();
2679 TData = &(*pid)->TData();
2680 PISeg = &(*pid)->PISeg();
2681 PINod = &(*pid)->PINod();
2682 HLRAlgo_TriangleData* tdata =
2683 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
2685 for (i = 1; i <= nbT; i++) {
2686 Tri1Indices = tdata->Indices();
2687 if ((Tri1Flags & FMskSide) == 0 &&
2688 (Tri1Flags & FMskFrBack)) {
2691 cout << " face : " << f << " , triangle " << i << endl;
2693 Modif = Standard_True;
2694 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
2695 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
2696 Nod11Indices = (*pi1p1)->Indices();
2697 Nod11RValues = (*pi1p1)->RValues();
2698 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
2699 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
2700 Nod12Indices = (*pi1p2)->Indices();
2701 Nod12RValues = (*pi1p2)->RValues();
2702 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2703 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
2704 Nod13Indices = (*pi1p3)->Indices();
2705 Nod13RValues = (*pi1p3)->RValues();
2706 D1 = 0.; D2 = 0.; D3 = 0.;
2707 if (((Nod11Flag & NMskEdge) == 0 || iLoop > 1) &&
2708 ((Nod11Flag & NMskOutL) == 0 || iLoop > 1) &&
2709 ((Nod11Flag & NMskVert) == 0)) {
2710 dX = Nod13PntX - Nod12PntX; dY = Nod13PntY - Nod12PntY;
2711 D1 = dX * dX + dY * dY;
2713 nX = - dY / D1; nY = dX / D1;
2714 dX = Nod11PntX - Nod12PntX; dY = Nod11PntY - Nod12PntY;
2715 dd = - (dX * nX + dY * nY);
2716 if (dd < 0) dd -= D1 * 0.01;
2717 else dd += D1 * 0.01;
2718 X1 = nX * dd; Y1 = nY * dd;
2720 if (((Nod12Flag & NMskEdge) == 0 || iLoop > 1) &&
2721 ((Nod12Flag & NMskOutL) == 0 || iLoop > 1) &&
2722 ((Nod12Flag & NMskVert) == 0)) {
2723 dX = Nod11PntX - Nod13PntX; dY = Nod11PntY - Nod13PntY;
2724 D2 = dX * dX + dY * dY;
2726 nX = - dY / D2; nY = dX / D2;
2727 dX = Nod12PntX - Nod13PntX; dY = Nod12PntY - Nod13PntY;
2728 dd = - (dX * nX + dY * nY);
2729 if (dd < 0) dd -= D2 * 0.01;
2730 else dd += D2 * 0.01;
2731 X2 = nX * dd; Y2 = nY * dd;
2733 if (((Nod13Flag & NMskEdge) == 0 || iLoop > 1) &&
2734 ((Nod13Flag & NMskOutL) == 0 || iLoop > 1) &&
2735 ((Nod13Flag & NMskVert) == 0)) {
2736 dX = Nod12PntX - Nod11PntX; dY = Nod12PntY - Nod11PntY;
2737 D3 = dX * dX + dY * dY;
2739 nX = - dY / D3; nY = dX / D3;
2740 dX = Nod13PntX - Nod11PntX; dY = Nod13PntY - Nod11PntY;
2741 dd = - (dX * nX + dY * nY);
2742 if (dd < 0) dd -= D3 * 0.01;
2743 else dd += D3 * 0.01;
2744 X3 = nX * dd; Y3 = nY * dd;
2746 if (D1 > D2 && D1 > D3) {
2747 Nod11PntX += X1; Nod11PntY += Y1;
2748 Nod11Flag |= NMskMove;
2749 UpdateAroundNode(Tri1Node1,Nod11Indices,TData,PISeg,PINod);
2750 FrBackInList = Standard_True;
2753 cout << Tri1Node1 << " modifies : DX,DY ";
2754 cout << X1 << " , " << Y1 << endl;
2758 else if (D2 > D3 && D2 > D1) {
2759 Nod12PntX += X2; Nod12PntY += Y2;
2760 Nod12Flag |= NMskMove;
2761 UpdateAroundNode(Tri1Node2,Nod12Indices,TData,PISeg,PINod);
2762 FrBackInList = Standard_True;
2765 cout << Tri1Node2 << " modifies : DX,DY ";
2766 cout << X2 << " , " << Y2 << endl;
2770 else if (D3 > D1 && D3 > D2) {
2771 Nod13PntX += X3; Nod13PntY += Y3;
2772 Nod13Flag |= NMskMove;
2773 UpdateAroundNode(Tri1Node3,Nod13Indices,TData,PISeg,PINod);
2774 FrBackInList = Standard_True;
2777 cout << Tri1Node3 << " modifies : DX,DY ";
2778 cout << X3 << " , " << Y3 << endl;
2784 cout << "modification error" << endl;
2793 Standard_Address IndexPtr,Coordinates;
2794 HLRAlgo_ListIteratorOfListOfBPoint it;
2796 for (it.Initialize(List); it.More(); it.Next()) {
2797 HLRAlgo_BiPoint& BP = it.Value();
2798 IndexPtr = BP.Indices();
2800 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2801 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2802 TData1 = &pid1->TData();
2803 PISeg1 = &pid1->PISeg();
2804 PINod1 = &pid1->PINod();
2807 if (F1Index == F2Index) {
2813 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2814 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2815 TData2 = &pid2->TData();
2816 PISeg2 = &pid2->PISeg();
2817 PINod2 = &pid2->PINod();
2821 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2822 ChangeValue(F1Pt1Index))->Indices();
2823 if (Nod11Flag & NMskMove) {
2826 cout << F1Pt1Index << " modifies 11" << endl;
2828 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2829 ChangeValue(F1Pt1Index))->RValues();
2830 Coordinates = BP.Coordinates();
2831 PntXTI1 = PntX1 = Nod11PntX;
2832 PntYTI1 = PntY1 = Nod11PntY;
2833 PntZTI1 = PntZ1 = Nod11PntZ;
2834 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2836 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2837 ChangeValue(F2Pt1Index))->Indices();
2838 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2839 ChangeValue(F2Pt1Index))->RValues();
2840 Nod12PntX = Nod11PntX;
2841 Nod12PntY = Nod11PntY;
2842 UpdateAroundNode(F2Pt1Index,Nod12Indices,
2843 TData2,PISeg2,PINod2);
2846 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2847 ChangeValue(F1Pt2Index))->Indices();
2848 if (Nod11Flag & NMskMove) {
2851 cout << F1Pt2Index << " modifies 12" << endl;
2853 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2854 ChangeValue(F1Pt2Index))->RValues();
2855 Coordinates = BP.Coordinates();
2856 PntXTI2 = PntX2 = Nod11PntX;
2857 PntYTI2 = PntY2 = Nod11PntY;
2858 PntZTI2 = PntZ2 = Nod11PntZ;
2859 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2861 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2862 ChangeValue(F2Pt2Index))->Indices();
2863 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2864 ChangeValue(F2Pt2Index))->RValues();
2865 Nod12PntX = Nod11PntX;
2866 Nod12PntY = Nod11PntY;
2867 UpdateAroundNode(F2Pt2Index,Nod12Indices,
2868 TData2,PISeg2,PINod2);
2873 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2874 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2875 PINod2 = &pid2->PINod();
2876 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2877 ChangeValue(F2Pt1Index))->Indices();
2878 if (Nod11Flag & NMskMove) {
2881 cout << F2Pt1Index << " modifies 21" << endl;
2883 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2884 ChangeValue(F2Pt1Index))->RValues();
2885 Coordinates = BP.Coordinates();
2886 PntXTI1 = PntX1 = Nod11PntX;
2887 PntYTI1 = PntY1 = Nod11PntY;
2888 PntZTI1 = PntZ1 = Nod11PntZ;
2889 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2891 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2892 ChangeValue(F1Pt1Index))->Indices();
2893 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2894 ChangeValue(F1Pt1Index))->RValues();
2895 Nod12PntX = Nod11PntX;
2896 Nod12PntY = Nod11PntY;
2897 UpdateAroundNode(F1Pt1Index,Nod12Indices,
2898 TData1,PISeg1,PINod1);
2901 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2902 ChangeValue(F2Pt2Index))->Indices();
2903 if (Nod11Flag & NMskMove) {
2906 cout << F2Pt2Index << " modifies 22" << endl;
2908 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2909 ChangeValue(F2Pt2Index))->RValues();
2910 Coordinates = BP.Coordinates();
2911 PntXTI2 = PntX2 = Nod11PntX;
2912 PntYTI2 = PntY2 = Nod11PntY;
2913 PntZTI2 = PntZ2 = Nod11PntZ;
2914 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2916 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2917 ChangeValue(F1Pt2Index))->Indices();
2918 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2919 ChangeValue(F1Pt2Index))->RValues();
2920 Nod12PntX = Nod11PntX;
2921 Nod12PntY = Nod11PntY;
2922 UpdateAroundNode(F1Pt2Index,Nod12Indices,
2923 TData1,PISeg1,PINod1);
2928 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2930 for (f = 1; f <= nbFace; f++) {
2931 if (!(*pid).IsNull()) {
2932 nbN = (*pid)->NbPINod();
2933 PINod = &(*pid)->PINod();
2934 Handle(HLRAlgo_PolyInternalNode)* NN =
2935 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
2937 for (i = 1; i <= nbN; i++) {
2938 Nod11Indices = (*NN)->Indices();
2939 Nod11Flag &= ~NMskMove;
2949 //=======================================================================
2950 //function : FindEdgeOnTriangle
2952 //=======================================================================
2956 FindEdgeOnTriangle (const Standard_Address Tri1Indices,
2957 const Standard_Integer ip1,
2958 const Standard_Integer ip2,
2959 Standard_Integer& jtrouv,
2960 Standard_Boolean& isDirect) const
2962 Standard_Integer n1 = Tri1Node1;
2963 Standard_Integer n2 = Tri1Node2;
2964 Standard_Integer n3 = Tri1Node3;
2965 if (ip1 == n1 && ip2 == n2) {
2967 isDirect = Standard_True;
2970 else if (ip2 == n1 && ip1 == n2) {
2972 isDirect = Standard_False;
2975 else if (ip1 == n2 && ip2 == n3) {
2977 isDirect = Standard_True;
2980 else if (ip2 == n2 && ip1 == n3) {
2982 isDirect = Standard_False;
2985 else if (ip1 == n3 && ip2 == n1) {
2987 isDirect = Standard_True;
2990 else if (ip2 == n3 && ip1 == n1) {
2992 isDirect = Standard_False;
2997 //=======================================================================
2998 //function : ChangeNode
3000 //=======================================================================
3002 void HLRBRep_PolyAlgo::ChangeNode (const Standard_Integer ip1,
3003 const Standard_Integer ip2,
3004 const Standard_Address Nod1Indices,
3005 const Standard_Address Nod1RValues,
3006 const Standard_Address Nod2Indices,
3007 const Standard_Address Nod2RValues,
3008 const Standard_Real coef1,
3009 const Standard_Real X3,
3010 const Standard_Real Y3,
3011 const Standard_Real Z3,
3012 const Standard_Boolean first,
3013 Standard_Address& TData,
3014 Standard_Address& PISeg,
3015 Standard_Address& PINod) const
3017 Standard_Real coef2 = 1 - coef1;
3022 Nod1PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3023 Nod1PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3024 Nod1Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3025 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3026 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3027 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3028 Standard_Real D = sqrt (x * x + y * y + z * z);
3040 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip1;
3041 cout << " and " << ip2 << endl;
3045 UpdateAroundNode(ip1,Nod1Indices,TData,PISeg,PINod);
3051 Nod2PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3052 Nod2PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3053 Nod2Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3054 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3055 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3056 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3057 Standard_Real D = sqrt (x * x + y * y + z * z);
3070 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip2;
3071 cout << " and " << ip1 << endl;
3075 UpdateAroundNode(ip2,Nod2Indices,TData,PISeg,PINod);
3079 //=======================================================================
3080 //function : UpdateAroundNode
3082 //=======================================================================
3084 void HLRBRep_PolyAlgo::
3085 UpdateAroundNode (const Standard_Integer iNode,
3086 const Standard_Address Nod1Indices,
3087 const Standard_Address TData,
3088 const Standard_Address PISeg,
3089 const Standard_Address PINod) const
3091 Standard_Integer iiii,iTri1,iTri2;
3095 const Standard_Address Seg1Indices =
3096 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3100 const Standard_Address Tri1Indices =
3101 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri1).Indices();
3102 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3103 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
3104 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3105 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
3106 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3107 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
3108 const Standard_Address aNod1Indices = (*PN1)->Indices();
3109 const Standard_Address aNod2Indices = (*PN2)->Indices();
3110 const Standard_Address aNod3Indices = (*PN3)->Indices();
3111 const Standard_Address aNod1RValues = (*PN1)->RValues();
3112 const Standard_Address aNod2RValues = (*PN2)->RValues();
3113 const Standard_Address aNod3RValues = (*PN3)->RValues();
3114 OrientTriangle(iTri1,Tri1Indices,
3115 aNod1Indices,aNod1RValues,
3116 aNod2Indices,aNod2RValues,
3117 aNod3Indices,aNod3RValues);
3120 const Standard_Address Tri2Indices =
3121 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri2).Indices();
3122 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3123 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1));
3124 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3125 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2));
3126 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3127 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3));
3128 const Standard_Address aNod1Indices = (*PN1)->Indices();
3129 const Standard_Address aNod2Indices = (*PN2)->Indices();
3130 const Standard_Address aNod3Indices = (*PN3)->Indices();
3131 const Standard_Address aNod1RValues = (*PN1)->RValues();
3132 const Standard_Address aNod2RValues = (*PN2)->RValues();
3133 const Standard_Address aNod3RValues = (*PN3)->RValues();
3134 OrientTriangle(iTri2,Tri2Indices,
3135 aNod1Indices,aNod1RValues,
3136 aNod2Indices,aNod2RValues,
3137 aNod3Indices,aNod3RValues);
3139 if (Seg1LstSg1 == iNode) iiii = Seg1NxtSg1;
3140 else iiii = Seg1NxtSg2;
3144 //=======================================================================
3145 //function : OrientTriangle
3147 //=======================================================================
3151 HLRBRep_PolyAlgo::OrientTriangle(const Standard_Integer iTri,
3153 HLRBRep_PolyAlgo::OrientTriangle(const Standard_Integer,
3155 const Standard_Address Tri1Indices,
3156 const Standard_Address Nod1Indices,
3157 const Standard_Address Nod1RValues,
3158 const Standard_Address Nod2Indices,
3159 const Standard_Address Nod2RValues,
3160 const Standard_Address Nod3Indices,
3161 const Standard_Address Nod3RValues) const
3163 Standard_Boolean o1 = Nod1Flag & NMskOutL;
3164 Standard_Boolean o2 = Nod2Flag & NMskOutL;
3165 Standard_Boolean o3 = Nod3Flag & NMskOutL;
3166 Tri1Flags &= ~FMskFlat;
3167 Tri1Flags &= ~FMskOnOutL;
3168 if (o1 && o2 && o3) {
3169 Tri1Flags |= FMskSide;
3170 Tri1Flags &= ~FMskBack;
3171 Tri1Flags |= FMskOnOutL;
3174 cout << "HLRBRep_PolyAlgo::OrientTriangle : OnOutL";
3175 cout << " triangle " << iTri << endl;
3180 Standard_Real s1 = Nod1Scal;
3181 Standard_Real s2 = Nod2Scal;
3182 Standard_Real s3 = Nod3Scal;
3183 Standard_Real as1 = s1;
3184 Standard_Real as2 = s2;
3185 Standard_Real as3 = s3;
3186 if (s1 < 0) as1 = -s1;
3187 if (s2 < 0) as2 = -s2;
3188 if (s3 < 0) as3 = -s3;
3189 Standard_Real s = 0;
3190 Standard_Real as = 0;
3191 if (!o1 ) {s = s1; as = as1;}
3192 if (!o2 && as < as2) {s = s2; as = as2;}
3193 if (!o3 && as < as3) {s = s3; as = as3;}
3195 Tri1Flags &= ~FMskSide;
3196 Tri1Flags |= FMskBack;
3199 Tri1Flags &= ~FMskSide;
3200 Tri1Flags &= ~FMskBack;
3202 Standard_Real dx12 = Nod2PntX - Nod1PntX;
3203 Standard_Real dy12 = Nod2PntY - Nod1PntY;
3204 Standard_Real dz12 = Nod2PntZ - Nod1PntZ;
3205 Standard_Real d12 = sqrt(dx12 * dx12 + dy12 * dy12 + dz12 * dz12);
3206 if (d12 <= 1.e-10) {
3209 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3210 cout << " triangle " << iTri << endl;
3213 Tri1Flags |= FMskFlat;
3214 Tri1Flags |= FMskSide;
3215 Tri1Flags &= ~FMskBack;
3218 Standard_Real dx23 = Nod3PntX - Nod2PntX;
3219 Standard_Real dy23 = Nod3PntY - Nod2PntY;
3220 Standard_Real dz23 = Nod3PntZ - Nod2PntZ;
3221 Standard_Real d23 = sqrt(dx23 * dx23 + dy23 * dy23 + dz23 * dz23);
3225 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3226 cout << " triangle " << iTri << endl;
3229 Tri1Flags |= FMskFlat;
3230 Tri1Flags |= FMskSide;
3231 Tri1Flags &= ~FMskBack;
3234 Standard_Real dx31 = Nod1PntX - Nod3PntX;
3235 Standard_Real dy31 = Nod1PntY - Nod3PntY;
3236 Standard_Real dz31 = Nod1PntZ - Nod3PntZ;
3237 Standard_Real d31 = sqrt(dx31 * dx31 + dy31 * dy31 + dz31 * dz31);
3241 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3242 cout << " triangle " << iTri << endl;
3245 Tri1Flags |= FMskFlat;
3246 Tri1Flags |= FMskSide;
3247 Tri1Flags &= ~FMskBack;
3256 Standard_Real dx = dy12 * dz23 - dz12 * dy23;
3257 Standard_Real dy = dz12 * dx23 - dx12 * dz23;
3258 Standard_Real dz = dx12 * dy23 - dy12 * dx23;
3259 Standard_Real d = sqrt(dx * dx + dy * dy + dz * dz);
3263 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3264 cout << " triangle " << iTri << endl;
3267 Tri1Flags |= FMskFlat;
3268 Tri1Flags |= FMskSide;
3269 Tri1Flags &= ~FMskBack;
3273 if (myProj.Perspective()) {
3277 o = ( dz * myProj.Focus()
3285 Tri1Flags |= FMskOrBack;
3289 Tri1Flags &= ~FMskOrBack;
3291 Tri1Flags |= FMskSide;
3292 Tri1Flags &= ~FMskBack;
3299 if ((!(Tri1Flags & FMskBack) && (Tri1Flags & FMskOrBack)) ||
3300 ( (Tri1Flags & FMskBack) && !(Tri1Flags & FMskOrBack)))
3301 Tri1Flags |= FMskFrBack;
3303 Tri1Flags &= ~FMskFrBack;
3306 //=======================================================================
3307 //function : Triangles
3309 //=======================================================================
3312 HLRBRep_PolyAlgo::Triangles(const Standard_Integer ip1,
3313 const Standard_Integer ip2,
3314 const Standard_Address Nod1Indices,
3315 Standard_Address& PISeg,
3316 Standard_Integer& iTri1,
3317 Standard_Integer& iTri2) const
3319 Standard_Address Seg1Indices;
3320 Standard_Integer iiii = Nod1NdSg;
3324 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3325 if (Seg1LstSg1 == ip1) {
3326 if (Seg1LstSg2 == ip2) {
3329 return Standard_True;
3331 else iiii = Seg1NxtSg1;
3334 if (Seg1LstSg1 == ip2) {
3337 return Standard_True;
3339 else iiii = Seg1NxtSg2;
3346 cout << "HLRBRep_PolyAlgo::Triangles : error";
3347 cout << " between " << ip1 << " and " << ip2 << endl;
3350 return Standard_False;
3353 //=======================================================================
3354 //function : NewNode
3356 //=======================================================================
3360 NewNode (const Standard_Address Nod1RValues,
3361 const Standard_Address Nod2RValues,
3362 Standard_Real& coef1,
3363 Standard_Boolean& moveP1) const
3365 Standard_Real TolAng = myTolAngular * 0.5;
3366 if ((Nod1Scal >= TolAng && Nod2Scal <= -TolAng) ||
3367 (Nod2Scal >= TolAng && Nod1Scal <= -TolAng)) {
3368 coef1 = Nod1Scal / ( Nod2Scal - Nod1Scal );
3369 if (coef1 < 0) coef1 = - coef1;
3370 moveP1 = coef1 < 0.5;
3371 return Standard_True;
3373 return Standard_False;
3376 //=======================================================================
3379 //=======================================================================
3382 HLRBRep_PolyAlgo::UVNode (const Standard_Address Nod1RValues,
3383 const Standard_Address Nod2RValues,
3384 const Standard_Real coef1,
3386 Standard_Real& V3) const
3388 Standard_Real coef2 = 1 - coef1;
3389 U3 = Nod1PntU * coef2 + Nod2PntU * coef1;
3390 V3 = Nod1PntV * coef2 + Nod2PntV * coef1;
3393 //=======================================================================
3394 //function : CheckDegeneratedSegment
3396 //=======================================================================
3400 CheckDegeneratedSegment(const Standard_Address Nod1Indices,
3401 const Standard_Address Nod1RValues,
3402 const Standard_Address Nod2Indices,
3403 const Standard_Address Nod2RValues) const
3405 Nod1Flag |= NMskFuck;
3406 Nod2Flag |= NMskFuck;
3407 if ((Nod1Scal >= myTolAngular && Nod2Scal <= -myTolAngular) ||
3408 (Nod2Scal >= myTolAngular && Nod1Scal <= -myTolAngular)) {
3410 Nod1Flag |= NMskOutL;
3412 Nod2Flag |= NMskOutL;
3416 //=======================================================================
3417 //function : UpdateOutLines
3419 //=======================================================================
3422 HLRBRep_PolyAlgo::UpdateOutLines (HLRAlgo_ListOfBPoint& List,
3423 TColStd_Array1OfTransient& PID)
3426 Standard_Integer nbFace = myFMap.Extent();
3427 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
3428 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
3430 Handle(HLRAlgo_PolyInternalData)* pid =
3431 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3433 for (f = 1; f <= nbFace; f++) {
3434 if (!(*pid).IsNull()) {
3435 if ((*pid)->IntOutL()) {
3436 Standard_Address TData = &((*pid)->TData());
3437 Standard_Address PISeg = &((*pid)->PISeg());
3438 Standard_Address PINod = &((*pid)->PINod());
3439 Standard_Integer i,j,it1,it2,tn1,tn2,tn3,pd,pf;
3440 Standard_Address Seg2Indices,Tri1Indices,Tri2Indices;
3441 Standard_Boolean outl;
3442 Standard_Integer nbS = (*pid)->NbPISeg();
3443 HLRAlgo_PolyInternalSegment* psg =
3444 &(((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(1));
3446 for (i = 1; i <= nbS; i++) {
3447 Seg2Indices = psg->Indices();
3450 if (it1 != 0 && it2 != 0 && it1 != it2) { // debile but sure !
3451 Tri1Indices = ((HLRAlgo_Array1OfTData*)TData)->
3452 ChangeValue(it1).Indices();
3453 Tri2Indices = ((HLRAlgo_Array1OfTData*)TData)->
3454 ChangeValue(it2).Indices();
3455 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3456 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3457 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3458 outl = Standard_False;
3459 else if ( Tri1Flags & FMskSide)
3460 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3462 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3470 if (!(Tri1Flags & FMskSide) && (Tri1Flags & FMskOrBack)) {
3475 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3476 Tri1Flags |= EMskOutLin1;
3477 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3478 Tri1Flags |= EMskOutLin2;
3479 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3480 Tri1Flags |= EMskOutLin3;
3483 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3484 cout << " : segment not found" << endl;
3490 if (!(Tri2Flags & FMskSide) && (Tri2Flags & FMskOrBack)) {
3495 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3496 Tri2Flags |= EMskOutLin1;
3497 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3498 Tri2Flags |= EMskOutLin2;
3499 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3500 Tri2Flags |= EMskOutLin3;
3503 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3504 cout << " : segment not found" << endl;
3507 Standard_Address Nod1RValues =
3508 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pd)->RValues();
3509 Standard_Address Nod2RValues =
3510 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pf)->RValues();
3511 XTI1 = X1 = Nod1PntX;
3512 YTI1 = Y1 = Nod1PntY;
3513 ZTI1 = Z1 = Nod1PntZ;
3514 XTI2 = X2 = Nod2PntX;
3515 YTI2 = Y2 = Nod2PntY;
3516 ZTI2 = Z2 = Nod2PntZ;
3517 TIMultiply(XTI1,YTI1,ZTI1);
3518 TIMultiply(XTI2,YTI2,ZTI2);
3519 List.Append(HLRAlgo_BiPoint(XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
3520 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
3521 f,f,pd,pf,f,pd,pf,12));
3532 //=======================================================================
3533 //function : UpdateEdgesBiPoints
3535 //=======================================================================
3537 void HLRBRep_PolyAlgo::
3538 UpdateEdgesBiPoints (HLRAlgo_ListOfBPoint& List,
3539 const TColStd_Array1OfTransient& PID,
3540 const Standard_Boolean closed)
3542 Standard_Integer itri1,itri2,tbid;
3543 HLRAlgo_ListIteratorOfListOfBPoint it;
3545 for (it.Initialize(List); it.More(); it.Next()) {
3546 HLRAlgo_BiPoint& BP = it.Value();
3547 // Standard_Integer i[5];
3548 Standard_Address IndexPtr = BP.Indices();
3549 if (F1Index != 0 && F2Index != 0) {
3550 const Handle(HLRAlgo_PolyInternalData)& pid1 =
3551 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
3552 const Handle(HLRAlgo_PolyInternalData)& pid2 =
3553 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
3554 Standard_Address PISeg1 = &pid1->PISeg();
3555 Standard_Address PISeg2 = &pid2->PISeg();
3556 Standard_Address Nod11Indices =
3557 pid1->PINod().ChangeValue(F1Pt1Index)->Indices();
3558 Standard_Address Nod21Indices =
3559 pid2->PINod().ChangeValue(F2Pt1Index)->Indices();
3560 Triangles(F1Pt1Index,F1Pt2Index,Nod11Indices,PISeg1,itri1,tbid);
3561 Triangles(F2Pt1Index,F2Pt2Index,Nod21Indices,PISeg2,itri2,tbid);
3563 if (itri1 != 0 && itri2 != 0) {
3564 if (F1Index != F2Index || itri1 != itri2) {
3565 Standard_Address TData1 = &pid1->TData();
3566 Standard_Address TData2 = &pid2->TData();
3567 Standard_Address Tri1Indices =
3568 ((HLRAlgo_Array1OfTData*)TData1)->ChangeValue(itri1).Indices();
3569 Standard_Address Tri2Indices =
3570 ((HLRAlgo_Array1OfTData*)TData2)->ChangeValue(itri2).Indices();
3572 if (((Tri1Flags & FMskBack) && (Tri2Flags & FMskBack)) ||
3573 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskSide)) ||
3574 ((Tri1Flags & FMskBack) && (Tri2Flags & FMskSide)) ||
3575 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskBack)))
3576 BP.Hidden(Standard_True);
3578 Standard_Boolean outl;
3579 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3580 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3581 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3582 outl = Standard_False;
3583 else if ( (Tri1Flags & FMskSide))
3584 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3586 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3592 cout << "HLRBRep_PolyAlgo::UpdateEdgesBiPoints : error ";
3593 cout << " between " << F1Index << setw(6);
3594 cout << " and " << F2Index << endl;
3601 //=======================================================================
3602 //function : UpdatePolyData
3604 //=======================================================================
3607 HLRBRep_PolyAlgo::UpdatePolyData (TColStd_Array1OfTransient& PD,
3608 TColStd_Array1OfTransient& PID,
3609 const Standard_Boolean closed)
3611 Standard_Integer f,i;//,n[3];
3612 Handle(TColgp_HArray1OfXYZ) HNodes;
3613 Handle(HLRAlgo_HArray1OfTData) HTData;
3614 Handle(HLRAlgo_HArray1OfPHDat) HPHDat;
3615 Standard_Integer nbFace = myFMap.Extent();
3616 Handle(HLRAlgo_PolyInternalData)* pid =
3617 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3618 Handle(HLRAlgo_PolyData)* pd =
3619 (Handle(HLRAlgo_PolyData)*)&(PD.ChangeValue(1));
3621 for (f = 1; f <= nbFace; f++) {
3622 if (!(*pid).IsNull()) {
3623 Standard_Integer nbN = (*pid)->NbPINod();
3624 Standard_Integer nbT = (*pid)->NbTData();
3625 HNodes = new TColgp_HArray1OfXYZ (1,nbN);
3626 HTData = new HLRAlgo_HArray1OfTData(1,nbT);
3627 TColgp_Array1OfXYZ& Nodes = HNodes->ChangeArray1();
3628 HLRAlgo_Array1OfTData& Trian = HTData->ChangeArray1();
3629 Standard_Address TData = &(*pid)->TData();
3630 Standard_Address PINod = &(*pid)->PINod();
3631 Standard_Integer nbHide = 0;
3632 Handle(HLRAlgo_PolyInternalNode)* ON =
3633 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
3634 gp_XYZ * NN = &(Nodes.ChangeValue(1));
3636 for (i = 1; i <= nbN; i++) {
3637 const Standard_Address Nod1RValues = (*ON)->RValues();
3638 NN->SetCoord(Nod1PntX,Nod1PntY,Nod1PntZ);
3643 HLRAlgo_TriangleData* OT =
3644 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
3645 HLRAlgo_TriangleData* NT = &(Trian.ChangeValue(1));
3646 Standard_Address Tri1Indices,Tri2Indices;
3648 for (i = 1; i <= nbT; i++) {
3649 Tri1Indices = OT->Indices();
3650 Tri2Indices = NT->Indices();
3651 if (!(Tri1Flags & FMskSide)) {
3653 if ((Tri1Flags & FMskFrBack) && DoTrace) {
3654 cout << "HLRBRep_PolyAlgo::ReverseBackTriangle :";
3655 cout << " face " << f << setw(6);
3656 cout << " triangle " << i << endl;
3659 if (Tri1Flags & FMskOrBack) {
3660 Standard_Integer j = Tri1Node1;
3661 Tri1Node1 = Tri1Node3;
3663 Tri1Flags |= FMskBack;
3666 Tri1Flags &= ~FMskBack;
3667 //Tri1Flags |= FMskBack;//OCC349
3669 Tri2Node1 = Tri1Node1;
3670 Tri2Node2 = Tri1Node2;
3671 Tri2Node3 = Tri1Node3;
3672 Tri2Flags = Tri1Flags;
3673 if (!(Tri2Flags & FMskSide) &&
3674 (!(Tri2Flags & FMskBack) || !closed)) {
3675 Tri2Flags |= FMskHiding;
3679 Tri2Flags &= ~FMskHiding;
3683 if (nbHide > 0) HPHDat = new HLRAlgo_HArray1OfPHDat(1,nbHide);
3684 else HPHDat.Nullify();
3685 (*pd)->HNodes(HNodes);
3686 (*pd)->HTData(HTData);
3687 (*pd)->HPHDat(HPHDat);
3688 (*pd)->FaceIndex(f);
3695 //=======================================================================
3696 //function : TMultiply
3698 //=======================================================================
3701 HLRBRep_PolyAlgo::TMultiply (Standard_Real& X,
3704 const Standard_Boolean VPO) const
3706 Standard_Real Xt = TMat[0][0]*X + TMat[0][1]*Y + TMat[0][2]*Z + (VPO ? 0 : TLoc[0]);//OCC349
3707 Standard_Real Yt = TMat[1][0]*X + TMat[1][1]*Y + TMat[1][2]*Z + (VPO ? 0 : TLoc[1]);//OCC349
3708 Z = TMat[2][0]*X + TMat[2][1]*Y + TMat[2][2]*Z + (VPO ? 0 : TLoc[2]);//OCC349
3713 //=======================================================================
3714 //function : TTMultiply
3716 //=======================================================================
3719 HLRBRep_PolyAlgo::TTMultiply (Standard_Real& X,
3722 const Standard_Boolean VPO) const
3724 Standard_Real Xt = TTMa[0][0]*X + TTMa[0][1]*Y + TTMa[0][2]*Z + (VPO ? 0 : TTLo[0]);//OCC349
3725 Standard_Real Yt = TTMa[1][0]*X + TTMa[1][1]*Y + TTMa[1][2]*Z + (VPO ? 0 : TTLo[1]);//OCC349
3726 Z = TTMa[2][0]*X + TTMa[2][1]*Y + TTMa[2][2]*Z + (VPO ? 0 : TTLo[2]);//OCC349
3731 //=======================================================================
3732 //function : TIMultiply
3734 //=======================================================================
3737 HLRBRep_PolyAlgo::TIMultiply (Standard_Real& X,
3740 const Standard_Boolean VPO) const
3742 Standard_Real Xt = TIMa[0][0]*X + TIMa[0][1]*Y + TIMa[0][2]*Z + (VPO ? 0 : TILo[0]);//OCC349
3743 Standard_Real Yt = TIMa[1][0]*X + TIMa[1][1]*Y + TIMa[1][2]*Z + (VPO ? 0 : TILo[1]);//OCC349
3744 Z = TIMa[2][0]*X + TIMa[2][1]*Y + TIMa[2][2]*Z + (VPO ? 0 : TILo[2]);//OCC349
3749 //=======================================================================
3752 //=======================================================================
3754 void HLRBRep_PolyAlgo::Hide (Standard_Address& Coordinates,
3755 HLRAlgo_EdgeStatus& status,
3757 Standard_Boolean& reg1,
3758 Standard_Boolean& regn,
3759 Standard_Boolean& outl,
3760 Standard_Boolean& intl)
3762 Standard_Integer index;
3763 myAlgo->Hide(Coordinates,status,index,reg1,regn,outl,intl);
3764 if (intl) S = myFMap(index);
3765 else S = myEMap(index);
3768 //=======================================================================
3771 //=======================================================================
3773 void HLRBRep_PolyAlgo::Show (Standard_Address& Coordinates,
3775 Standard_Boolean& reg1,
3776 Standard_Boolean& regn,
3777 Standard_Boolean& outl,
3778 Standard_Boolean& intl)
3780 Standard_Integer index;
3781 myAlgo->Show(Coordinates,index,reg1,regn,outl,intl);
3782 if (intl) S = myFMap(index);
3783 else S = myEMap(index);
3786 //=======================================================================
3787 //function : OutLinedShape
3789 //=======================================================================
3792 HLRBRep_PolyAlgo::OutLinedShape (const TopoDS_Shape& S) const
3794 TopoDS_Shape Result;
3798 B.MakeCompound(TopoDS::Compound(Result));
3801 TopTools_MapOfShape Map;
3803 for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next())
3804 Map.Add(ex.Current());
3805 for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next())
3806 Map.Add(ex.Current());
3808 Standard_Integer nbFace = myFMap.Extent();
3810 TopTools_Array1OfShape NewF(1,nbFace);
3811 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
3812 Standard_Integer nbShell = Shell.Upper();
3813 HLRAlgo_ListIteratorOfListOfBPoint it;
3815 for (Standard_Integer iShell = 1; iShell <= nbShell; iShell++) {
3816 HLRAlgo_ListOfBPoint& List =
3817 (*(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell)))->Edges();
3819 for (it.Initialize(List); it.More(); it.Next()) {
3820 HLRAlgo_BiPoint& BP = it.Value();
3822 Standard_Address IndexPtr = BP.Indices();
3823 if (Map.Contains(myFMap(ShapeIndex))) {
3824 Standard_Address Coordinates = BP.Coordinates();
3825 B.Add(Result,BRepLib_MakeEdge
3826 (gp_Pnt(PntXTI1,PntYTI1,PntZTI1),
3827 gp_Pnt(PntXTI2,PntYTI2,PntZTI2)));