0007691: Wrong hidden lines computed by HLRBRep_PolyAlgo and HLRBRep_PolyHLRToShape...
[occt.git] / src / HLRBRep / HLRBRep_PolyAlgo.cxx
CommitLineData
7fd59977 1// File: HLRBRep_PolyAlgo.cxx
2// Created: Fri May 5 15:58:19 1995
3// Author: Christophe MARION
4// <cma@ecolox>
5// Modified by cma, Tue Apr 1 11:39:48 1997
6// Modified by cma, Tue Apr 1 11:40:30 1997
7
8#include <Standard_Stream.hxx>
9#include <HLRBRep_PolyAlgo.ixx>
10#include <Standard_ErrorHandler.hxx>
11#include <TColStd_HArray1OfTransient.hxx>
12#include <TColStd_HArray1OfInteger.hxx>
13#include <CSLib.hxx>
14#include <CSLib_DerivativeStatus.hxx>
15#include <CSLib_NormalStatus.hxx>
16#include <Geom_Surface.hxx>
17#include <Geom_RectangularTrimmedSurface.hxx>
18#include <HLRAlgo_ListIteratorOfListOfBPoint.hxx>
19#include <HLRAlgo_PolyShellData.hxx>
20#include <HLRAlgo_PolyData.hxx>
21#include <HLRAlgo_BiPoint.hxx>
22#include <TopoDS.hxx>
23#include <TopExp.hxx>
24#include <TopExp_Explorer.hxx>
25#include <TopTools_Array1OfShape.hxx>
26#include <TopTools_ListIteratorOfListOfShape.hxx>
27#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
28#include <Poly_Triangulation.hxx>
29#include <Poly_Polygon3D.hxx>
30#include <Poly_PolygonOnTriangulation.hxx>
31#include <BRep_Builder.hxx>
32#include <BRep_Tool.hxx>
33#include <BRepLib_MakeEdge.hxx>
34#include <Precision.hxx>
35#include <gp.hxx>
36
37#define EMskOutLin1 ((Standard_Boolean) 1)
38#define EMskOutLin2 ((Standard_Boolean) 2)
39#define EMskOutLin3 ((Standard_Boolean) 4)
40#define EMskGrALin1 ((Standard_Boolean) 8)
41#define EMskGrALin2 ((Standard_Boolean) 16)
42#define EMskGrALin3 ((Standard_Boolean) 32)
43#define FMskBack ((Standard_Boolean) 64)
44#define FMskSide ((Standard_Boolean) 128)
45#define FMskHiding ((Standard_Boolean) 256)
46#define FMskFlat ((Standard_Boolean) 512)
47#define FMskOnOutL ((Standard_Boolean)1024)
48#define FMskOrBack ((Standard_Boolean)2048)
49#define FMskFrBack ((Standard_Boolean)4096)
50
51#define NMskVert ((Standard_Boolean) 1)
52#define NMskOutL ((Standard_Boolean) 2)
53#define NMskNorm ((Standard_Boolean) 4)
54#define NMskFuck ((Standard_Boolean) 8)
55#define NMskEdge ((Standard_Boolean)16)
56#define NMskMove ((Standard_Boolean)32)
57
58#define PntXTI1 ((Standard_Real*)Coordinates)[ 0]
59#define PntYTI1 ((Standard_Real*)Coordinates)[ 1]
60#define PntZTI1 ((Standard_Real*)Coordinates)[ 2]
61#define PntXTI2 ((Standard_Real*)Coordinates)[ 3]
62#define PntYTI2 ((Standard_Real*)Coordinates)[ 4]
63#define PntZTI2 ((Standard_Real*)Coordinates)[ 5]
64#define PntX1 ((Standard_Real*)Coordinates)[ 6]
65#define PntY1 ((Standard_Real*)Coordinates)[ 7]
66#define PntZ1 ((Standard_Real*)Coordinates)[ 8]
67#define PntX2 ((Standard_Real*)Coordinates)[ 9]
68#define PntY2 ((Standard_Real*)Coordinates)[10]
69#define PntZ2 ((Standard_Real*)Coordinates)[11]
70
71#define Pn2XTI1 ((Standard_Real*)Coordinate2)[ 0]
72#define Pn2YTI1 ((Standard_Real*)Coordinate2)[ 1]
73#define Pn2ZTI1 ((Standard_Real*)Coordinate2)[ 2]
74#define Pn2XTI2 ((Standard_Real*)Coordinate2)[ 3]
75#define Pn2YTI2 ((Standard_Real*)Coordinate2)[ 4]
76#define Pn2ZTI2 ((Standard_Real*)Coordinate2)[ 5]
77#define Pn2X1 ((Standard_Real*)Coordinate2)[ 6]
78#define Pn2Y1 ((Standard_Real*)Coordinate2)[ 7]
79#define Pn2Z1 ((Standard_Real*)Coordinate2)[ 8]
80#define Pn2X2 ((Standard_Real*)Coordinate2)[ 9]
81#define Pn2Y2 ((Standard_Real*)Coordinate2)[10]
82#define Pn2Z2 ((Standard_Real*)Coordinate2)[11]
83
84#define Tri1Node1 ((Standard_Integer*)Tri1Indices)[0]
85#define Tri1Node2 ((Standard_Integer*)Tri1Indices)[1]
86#define Tri1Node3 ((Standard_Integer*)Tri1Indices)[2]
87#define Tri1Flags ((Standard_Boolean*)Tri1Indices)[3]
88
89#define Tri2Node1 ((Standard_Integer*)Tri2Indices)[0]
90#define Tri2Node2 ((Standard_Integer*)Tri2Indices)[1]
91#define Tri2Node3 ((Standard_Integer*)Tri2Indices)[2]
92#define Tri2Flags ((Standard_Boolean*)Tri2Indices)[3]
93
94#define Tri3Node1 ((Standard_Integer*)Tri3Indices)[0]
95#define Tri3Node2 ((Standard_Integer*)Tri3Indices)[1]
96#define Tri3Node3 ((Standard_Integer*)Tri3Indices)[2]
97#define Tri3Flags ((Standard_Boolean*)Tri3Indices)[3]
98
99#define Seg1LstSg1 ((Standard_Integer*)Seg1Indices)[0]
100#define Seg1LstSg2 ((Standard_Integer*)Seg1Indices)[1]
101#define Seg1NxtSg1 ((Standard_Integer*)Seg1Indices)[2]
102#define Seg1NxtSg2 ((Standard_Integer*)Seg1Indices)[3]
103#define Seg1Conex1 ((Standard_Integer*)Seg1Indices)[4]
104#define Seg1Conex2 ((Standard_Integer*)Seg1Indices)[5]
105
106#define Seg2LstSg1 ((Standard_Integer*)Seg2Indices)[0]
107#define Seg2LstSg2 ((Standard_Integer*)Seg2Indices)[1]
108#define Seg2NxtSg1 ((Standard_Integer*)Seg2Indices)[2]
109#define Seg2NxtSg2 ((Standard_Integer*)Seg2Indices)[3]
110#define Seg2Conex1 ((Standard_Integer*)Seg2Indices)[4]
111#define Seg2Conex2 ((Standard_Integer*)Seg2Indices)[5]
112
113#define Nod1NdSg ((Standard_Integer*)Nod1Indices)[0]
114#define Nod1Flag ((Standard_Boolean*)Nod1Indices)[1]
115#define Nod1Edg1 ((Standard_Boolean*)Nod1Indices)[2]
116#define Nod1Edg2 ((Standard_Boolean*)Nod1Indices)[3]
117
118#define Nod1PntX ((Standard_Real*)Nod1RValues)[ 0]
119#define Nod1PntY ((Standard_Real*)Nod1RValues)[ 1]
120#define Nod1PntZ ((Standard_Real*)Nod1RValues)[ 2]
121#define Nod1PntU ((Standard_Real*)Nod1RValues)[ 3]
122#define Nod1PntV ((Standard_Real*)Nod1RValues)[ 4]
123#define Nod1NrmX ((Standard_Real*)Nod1RValues)[ 5]
124#define Nod1NrmY ((Standard_Real*)Nod1RValues)[ 6]
125#define Nod1NrmZ ((Standard_Real*)Nod1RValues)[ 7]
126#define Nod1PCu1 ((Standard_Real*)Nod1RValues)[ 8]
127#define Nod1PCu2 ((Standard_Real*)Nod1RValues)[ 9]
128#define Nod1Scal ((Standard_Real*)Nod1RValues)[10]
129
130#define NodANdSg ((Standard_Integer*)NodAIndices)[0]
131#define NodAFlag ((Standard_Boolean*)NodAIndices)[1]
132#define NodAEdg1 ((Standard_Boolean*)NodAIndices)[2]
133#define NodAEdg2 ((Standard_Boolean*)NodAIndices)[3]
134
135#define NodAPntX ((Standard_Real*)NodARValues)[ 0]
136#define NodAPntY ((Standard_Real*)NodARValues)[ 1]
137#define NodAPntZ ((Standard_Real*)NodARValues)[ 2]
138#define NodAPntU ((Standard_Real*)NodARValues)[ 3]
139#define NodAPntV ((Standard_Real*)NodARValues)[ 4]
140#define NodANrmX ((Standard_Real*)NodARValues)[ 5]
141#define NodANrmY ((Standard_Real*)NodARValues)[ 6]
142#define NodANrmZ ((Standard_Real*)NodARValues)[ 7]
143#define NodAPCu1 ((Standard_Real*)NodARValues)[ 8]
144#define NodAPCu2 ((Standard_Real*)NodARValues)[ 9]
145#define NodAScal ((Standard_Real*)NodARValues)[10]
146
147#define NodBNdSg ((Standard_Integer*)NodBIndices)[0]
148#define NodBFlag ((Standard_Boolean*)NodBIndices)[1]
149#define NodBEdg1 ((Standard_Boolean*)NodBIndices)[2]
150#define NodBEdg2 ((Standard_Boolean*)NodBIndices)[3]
151
152#define NodBPntX ((Standard_Real*)NodBRValues)[ 0]
153#define NodBPntY ((Standard_Real*)NodBRValues)[ 1]
154#define NodBPntZ ((Standard_Real*)NodBRValues)[ 2]
155#define NodBPntU ((Standard_Real*)NodBRValues)[ 3]
156#define NodBPntV ((Standard_Real*)NodBRValues)[ 4]
157#define NodBNrmX ((Standard_Real*)NodBRValues)[ 5]
158#define NodBNrmY ((Standard_Real*)NodBRValues)[ 6]
159#define NodBNrmZ ((Standard_Real*)NodBRValues)[ 7]
160#define NodBPCu1 ((Standard_Real*)NodBRValues)[ 8]
161#define NodBPCu2 ((Standard_Real*)NodBRValues)[ 9]
162#define NodBScal ((Standard_Real*)NodBRValues)[10]
163
164#define Nod2NdSg ((Standard_Integer*)Nod2Indices)[0]
165#define Nod2Flag ((Standard_Boolean*)Nod2Indices)[1]
166#define Nod2Edg1 ((Standard_Boolean*)Nod2Indices)[2]
167#define Nod2Edg2 ((Standard_Boolean*)Nod2Indices)[3]
168
169#define Nod2PntX ((Standard_Real*)Nod2RValues)[ 0]
170#define Nod2PntY ((Standard_Real*)Nod2RValues)[ 1]
171#define Nod2PntZ ((Standard_Real*)Nod2RValues)[ 2]
172#define Nod2PntU ((Standard_Real*)Nod2RValues)[ 3]
173#define Nod2PntV ((Standard_Real*)Nod2RValues)[ 4]
174#define Nod2NrmX ((Standard_Real*)Nod2RValues)[ 5]
175#define Nod2NrmY ((Standard_Real*)Nod2RValues)[ 6]
176#define Nod2NrmZ ((Standard_Real*)Nod2RValues)[ 7]
177#define Nod2PCu1 ((Standard_Real*)Nod2RValues)[ 8]
178#define Nod2PCu2 ((Standard_Real*)Nod2RValues)[ 9]
179#define Nod2Scal ((Standard_Real*)Nod2RValues)[10]
180
181#define Nod3NdSg ((Standard_Integer*)Nod3Indices)[0]
182#define Nod3Flag ((Standard_Boolean*)Nod3Indices)[1]
183#define Nod3Edg1 ((Standard_Boolean*)Nod3Indices)[2]
184#define Nod3Edg2 ((Standard_Boolean*)Nod3Indices)[3]
185
186#define Nod3PntX ((Standard_Real*)Nod3RValues)[ 0]
187#define Nod3PntY ((Standard_Real*)Nod3RValues)[ 1]
188#define Nod3PntZ ((Standard_Real*)Nod3RValues)[ 2]
189#define Nod3PntU ((Standard_Real*)Nod3RValues)[ 3]
190#define Nod3PntV ((Standard_Real*)Nod3RValues)[ 4]
191#define Nod3NrmX ((Standard_Real*)Nod3RValues)[ 5]
192#define Nod3NrmY ((Standard_Real*)Nod3RValues)[ 6]
193#define Nod3NrmZ ((Standard_Real*)Nod3RValues)[ 7]
194#define Nod3PCu1 ((Standard_Real*)Nod3RValues)[ 8]
195#define Nod3PCu2 ((Standard_Real*)Nod3RValues)[ 9]
196#define Nod3Scal ((Standard_Real*)Nod3RValues)[10]
197
198#define Nod4NdSg ((Standard_Integer*)Nod4Indices)[0]
199#define Nod4Flag ((Standard_Boolean*)Nod4Indices)[1]
200#define Nod4Edg1 ((Standard_Boolean*)Nod4Indices)[2]
201#define Nod4Edg2 ((Standard_Boolean*)Nod4Indices)[3]
202
203#define Nod4PntX ((Standard_Real*)Nod4RValues)[ 0]
204#define Nod4PntY ((Standard_Real*)Nod4RValues)[ 1]
205#define Nod4PntZ ((Standard_Real*)Nod4RValues)[ 2]
206#define Nod4PntU ((Standard_Real*)Nod4RValues)[ 3]
207#define Nod4PntV ((Standard_Real*)Nod4RValues)[ 4]
208#define Nod4NrmX ((Standard_Real*)Nod4RValues)[ 5]
209#define Nod4NrmY ((Standard_Real*)Nod4RValues)[ 6]
210#define Nod4NrmZ ((Standard_Real*)Nod4RValues)[ 7]
211#define Nod4PCu1 ((Standard_Real*)Nod4RValues)[ 8]
212#define Nod4PCu2 ((Standard_Real*)Nod4RValues)[ 9]
213#define Nod4Scal ((Standard_Real*)Nod4RValues)[10]
214
215#define Nod11NdSg ((Standard_Integer*)Nod11Indices)[0]
216#define Nod11Flag ((Standard_Boolean*)Nod11Indices)[1]
217#define Nod11Edg1 ((Standard_Boolean*)Nod11Indices)[2]
218#define Nod11Edg2 ((Standard_Boolean*)Nod11Indices)[3]
219
220#define Nod11PntX ((Standard_Real*)Nod11RValues)[ 0]
221#define Nod11PntY ((Standard_Real*)Nod11RValues)[ 1]
222#define Nod11PntZ ((Standard_Real*)Nod11RValues)[ 2]
223#define Nod11PntU ((Standard_Real*)Nod11RValues)[ 3]
224#define Nod11PntV ((Standard_Real*)Nod11RValues)[ 4]
225#define Nod11NrmX ((Standard_Real*)Nod11RValues)[ 5]
226#define Nod11NrmY ((Standard_Real*)Nod11RValues)[ 6]
227#define Nod11NrmZ ((Standard_Real*)Nod11RValues)[ 7]
228#define Nod11PCu1 ((Standard_Real*)Nod11RValues)[ 8]
229#define Nod11PCu2 ((Standard_Real*)Nod11RValues)[ 9]
230#define Nod11Scal ((Standard_Real*)Nod11RValues)[10]
231
232#define Nod1ANdSg ((Standard_Integer*)Nod1AIndices)[0]
233#define Nod1AFlag ((Standard_Boolean*)Nod1AIndices)[1]
234#define Nod1AEdg1 ((Standard_Boolean*)Nod1AIndices)[2]
235#define Nod1AEdg2 ((Standard_Boolean*)Nod1AIndices)[3]
236
237#define Nod1APntX ((Standard_Real*)Nod1ARValues)[ 0]
238#define Nod1APntY ((Standard_Real*)Nod1ARValues)[ 1]
239#define Nod1APntZ ((Standard_Real*)Nod1ARValues)[ 2]
240#define Nod1APntU ((Standard_Real*)Nod1ARValues)[ 3]
241#define Nod1APntV ((Standard_Real*)Nod1ARValues)[ 4]
242#define Nod1ANrmX ((Standard_Real*)Nod1ARValues)[ 5]
243#define Nod1ANrmY ((Standard_Real*)Nod1ARValues)[ 6]
244#define Nod1ANrmZ ((Standard_Real*)Nod1ARValues)[ 7]
245#define Nod1APCu1 ((Standard_Real*)Nod1ARValues)[ 8]
246#define Nod1APCu2 ((Standard_Real*)Nod1ARValues)[ 9]
247#define Nod1AScal ((Standard_Real*)Nod1ARValues)[10]
248
249#define Nod1BNdSg ((Standard_Integer*)Nod1BIndices)[0]
250#define Nod1BFlag ((Standard_Boolean*)Nod1BIndices)[1]
251#define Nod1BEdg1 ((Standard_Boolean*)Nod1BIndices)[2]
252#define Nod1BEdg2 ((Standard_Boolean*)Nod1BIndices)[3]
253
254#define Nod1BPntX ((Standard_Real*)Nod1BRValues)[ 0]
255#define Nod1BPntY ((Standard_Real*)Nod1BRValues)[ 1]
256#define Nod1BPntZ ((Standard_Real*)Nod1BRValues)[ 2]
257#define Nod1BPntU ((Standard_Real*)Nod1BRValues)[ 3]
258#define Nod1BPntV ((Standard_Real*)Nod1BRValues)[ 4]
259#define Nod1BNrmX ((Standard_Real*)Nod1BRValues)[ 5]
260#define Nod1BNrmY ((Standard_Real*)Nod1BRValues)[ 6]
261#define Nod1BNrmZ ((Standard_Real*)Nod1BRValues)[ 7]
262#define Nod1BPCu1 ((Standard_Real*)Nod1BRValues)[ 8]
263#define Nod1BPCu2 ((Standard_Real*)Nod1BRValues)[ 9]
264#define Nod1BScal ((Standard_Real*)Nod1BRValues)[10]
265
266#define Nod12NdSg ((Standard_Integer*)Nod12Indices)[0]
267#define Nod12Flag ((Standard_Boolean*)Nod12Indices)[1]
268#define Nod12Edg1 ((Standard_Boolean*)Nod12Indices)[2]
269#define Nod12Edg2 ((Standard_Boolean*)Nod12Indices)[3]
270
271#define Nod12PntX ((Standard_Real*)Nod12RValues)[ 0]
272#define Nod12PntY ((Standard_Real*)Nod12RValues)[ 1]
273#define Nod12PntZ ((Standard_Real*)Nod12RValues)[ 2]
274#define Nod12PntU ((Standard_Real*)Nod12RValues)[ 3]
275#define Nod12PntV ((Standard_Real*)Nod12RValues)[ 4]
276#define Nod12NrmX ((Standard_Real*)Nod12RValues)[ 5]
277#define Nod12NrmY ((Standard_Real*)Nod12RValues)[ 6]
278#define Nod12NrmZ ((Standard_Real*)Nod12RValues)[ 7]
279#define Nod12PCu1 ((Standard_Real*)Nod12RValues)[ 8]
280#define Nod12PCu2 ((Standard_Real*)Nod12RValues)[ 9]
281#define Nod12Scal ((Standard_Real*)Nod12RValues)[10]
282
283#define Nod13NdSg ((Standard_Integer*)Nod13Indices)[0]
284#define Nod13Flag ((Standard_Boolean*)Nod13Indices)[1]
285#define Nod13Edg1 ((Standard_Boolean*)Nod13Indices)[2]
286#define Nod13Edg2 ((Standard_Boolean*)Nod13Indices)[3]
287
288#define Nod13PntX ((Standard_Real*)Nod13RValues)[ 0]
289#define Nod13PntY ((Standard_Real*)Nod13RValues)[ 1]
290#define Nod13PntZ ((Standard_Real*)Nod13RValues)[ 2]
291#define Nod13PntU ((Standard_Real*)Nod13RValues)[ 3]
292#define Nod13PntV ((Standard_Real*)Nod13RValues)[ 4]
293#define Nod13NrmX ((Standard_Real*)Nod13RValues)[ 5]
294#define Nod13NrmY ((Standard_Real*)Nod13RValues)[ 6]
295#define Nod13NrmZ ((Standard_Real*)Nod13RValues)[ 7]
296#define Nod13PCu1 ((Standard_Real*)Nod13RValues)[ 8]
297#define Nod13PCu2 ((Standard_Real*)Nod13RValues)[ 9]
298#define Nod13Scal ((Standard_Real*)Nod13RValues)[10]
299
300#define Nod14NdSg ((Standard_Integer*)Nod14Indices)[0]
301#define Nod14Flag ((Standard_Boolean*)Nod14Indices)[1]
302#define Nod14Edg1 ((Standard_Boolean*)Nod14Indices)[2]
303#define Nod14Edg2 ((Standard_Boolean*)Nod14Indices)[3]
304
305#define Nod14PntX ((Standard_Real*)Nod14RValues)[ 0]
306#define Nod14PntY ((Standard_Real*)Nod14RValues)[ 1]
307#define Nod14PntZ ((Standard_Real*)Nod14RValues)[ 2]
308#define Nod14PntU ((Standard_Real*)Nod14RValues)[ 3]
309#define Nod14PntV ((Standard_Real*)Nod14RValues)[ 4]
310#define Nod14NrmX ((Standard_Real*)Nod14RValues)[ 5]
311#define Nod14NrmY ((Standard_Real*)Nod14RValues)[ 6]
312#define Nod14NrmZ ((Standard_Real*)Nod14RValues)[ 7]
313#define Nod14PCu1 ((Standard_Real*)Nod14RValues)[ 8]
314#define Nod14PCu2 ((Standard_Real*)Nod14RValues)[ 9]
315#define Nod14Scal ((Standard_Real*)Nod14RValues)[10]
316
317#define Nod21NdSg ((Standard_Integer*)Nod21Indices)[0]
318#define Nod21Flag ((Standard_Boolean*)Nod21Indices)[1]
319#define Nod21Edg1 ((Standard_Boolean*)Nod21Indices)[2]
320#define Nod21Edg2 ((Standard_Boolean*)Nod21Indices)[3]
321
322#define Nod21PntX ((Standard_Real*)Nod21RValues)[ 0]
323#define Nod21PntY ((Standard_Real*)Nod21RValues)[ 1]
324#define Nod21PntZ ((Standard_Real*)Nod21RValues)[ 2]
325#define Nod21PntU ((Standard_Real*)Nod21RValues)[ 3]
326#define Nod21PntV ((Standard_Real*)Nod21RValues)[ 4]
327#define Nod21NrmX ((Standard_Real*)Nod21RValues)[ 5]
328#define Nod21NrmY ((Standard_Real*)Nod21RValues)[ 6]
329#define Nod21NrmZ ((Standard_Real*)Nod21RValues)[ 7]
330#define Nod21PCu1 ((Standard_Real*)Nod21RValues)[ 8]
331#define Nod21PCu2 ((Standard_Real*)Nod21RValues)[ 9]
332#define Nod21Scal ((Standard_Real*)Nod21RValues)[10]
333
334#define Nod2ANdSg ((Standard_Integer*)Nod2AIndices)[0]
335#define Nod2AFlag ((Standard_Boolean*)Nod2AIndices)[1]
336#define Nod2AEdg1 ((Standard_Boolean*)Nod2AIndices)[2]
337#define Nod2AEdg2 ((Standard_Boolean*)Nod2AIndices)[3]
338
339#define Nod2APntX ((Standard_Real*)Nod2ARValues)[ 0]
340#define Nod2APntY ((Standard_Real*)Nod2ARValues)[ 1]
341#define Nod2APntZ ((Standard_Real*)Nod2ARValues)[ 2]
342#define Nod2APntU ((Standard_Real*)Nod2ARValues)[ 3]
343#define Nod2APntV ((Standard_Real*)Nod2ARValues)[ 4]
344#define Nod2ANrmX ((Standard_Real*)Nod2ARValues)[ 5]
345#define Nod2ANrmY ((Standard_Real*)Nod2ARValues)[ 6]
346#define Nod2ANrmZ ((Standard_Real*)Nod2ARValues)[ 7]
347#define Nod2APCu1 ((Standard_Real*)Nod2ARValues)[ 8]
348#define Nod2APCu2 ((Standard_Real*)Nod2ARValues)[ 9]
349#define Nod2AScal ((Standard_Real*)Nod2ARValues)[10]
350
351#define Nod2BNdSg ((Standard_Integer*)Nod2BIndices)[0]
352#define Nod2BFlag ((Standard_Boolean*)Nod2BIndices)[1]
353#define Nod2BEdg1 ((Standard_Boolean*)Nod2BIndices)[2]
354#define Nod2BEdg2 ((Standard_Boolean*)Nod2BIndices)[3]
355
356#define Nod2BPntX ((Standard_Real*)Nod2BRValues)[ 0]
357#define Nod2BPntY ((Standard_Real*)Nod2BRValues)[ 1]
358#define Nod2BPntZ ((Standard_Real*)Nod2BRValues)[ 2]
359#define Nod2BPntU ((Standard_Real*)Nod2BRValues)[ 3]
360#define Nod2BPntV ((Standard_Real*)Nod2BRValues)[ 4]
361#define Nod2BNrmX ((Standard_Real*)Nod2BRValues)[ 5]
362#define Nod2BNrmY ((Standard_Real*)Nod2BRValues)[ 6]
363#define Nod2BNrmZ ((Standard_Real*)Nod2BRValues)[ 7]
364#define Nod2BPCu1 ((Standard_Real*)Nod2BRValues)[ 8]
365#define Nod2BPCu2 ((Standard_Real*)Nod2BRValues)[ 9]
366#define Nod2BScal ((Standard_Real*)Nod2BRValues)[10]
367
368#define Nod22NdSg ((Standard_Integer*)Nod22Indices)[0]
369#define Nod22Flag ((Standard_Boolean*)Nod22Indices)[1]
370#define Nod22Edg1 ((Standard_Boolean*)Nod22Indices)[2]
371#define Nod22Edg2 ((Standard_Boolean*)Nod22Indices)[3]
372
373#define Nod22PntX ((Standard_Real*)Nod22RValues)[ 0]
374#define Nod22PntY ((Standard_Real*)Nod22RValues)[ 1]
375#define Nod22PntZ ((Standard_Real*)Nod22RValues)[ 2]
376#define Nod22PntU ((Standard_Real*)Nod22RValues)[ 3]
377#define Nod22PntV ((Standard_Real*)Nod22RValues)[ 4]
378#define Nod22NrmX ((Standard_Real*)Nod22RValues)[ 5]
379#define Nod22NrmY ((Standard_Real*)Nod22RValues)[ 6]
380#define Nod22NrmZ ((Standard_Real*)Nod22RValues)[ 7]
381#define Nod22PCu1 ((Standard_Real*)Nod22RValues)[ 8]
382#define Nod22PCu2 ((Standard_Real*)Nod22RValues)[ 9]
383#define Nod22Scal ((Standard_Real*)Nod22RValues)[10]
384
385#define Nod23NdSg ((Standard_Integer*)Nod23Indices)[0]
386#define Nod23Flag ((Standard_Boolean*)Nod23Indices)[1]
387#define Nod23Edg1 ((Standard_Boolean*)Nod23Indices)[2]
388#define Nod23Edg2 ((Standard_Boolean*)Nod23Indices)[3]
389
390#define Nod23PntX ((Standard_Real*)Nod23RValues)[ 0]
391#define Nod23PntY ((Standard_Real*)Nod23RValues)[ 1]
392#define Nod23PntZ ((Standard_Real*)Nod23RValues)[ 2]
393#define Nod23PntU ((Standard_Real*)Nod23RValues)[ 3]
394#define Nod23PntV ((Standard_Real*)Nod23RValues)[ 4]
395#define Nod23NrmX ((Standard_Real*)Nod23RValues)[ 5]
396#define Nod23NrmY ((Standard_Real*)Nod23RValues)[ 6]
397#define Nod23NrmZ ((Standard_Real*)Nod23RValues)[ 7]
398#define Nod23PCu1 ((Standard_Real*)Nod23RValues)[ 8]
399#define Nod23PCu2 ((Standard_Real*)Nod23RValues)[ 9]
400#define Nod23Scal ((Standard_Real*)Nod23RValues)[10]
401
402#define Nod24NdSg ((Standard_Integer*)Nod24Indices)[0]
403#define Nod24Flag ((Standard_Boolean*)Nod24Indices)[1]
404#define Nod24Edg1 ((Standard_Boolean*)Nod24Indices)[2]
405#define Nod24Edg2 ((Standard_Boolean*)Nod24Indices)[3]
406
407#define Nod24PntX ((Standard_Real*)Nod24RValues)[ 0]
408#define Nod24PntY ((Standard_Real*)Nod24RValues)[ 1]
409#define Nod24PntZ ((Standard_Real*)Nod24RValues)[ 2]
410#define Nod24PntU ((Standard_Real*)Nod24RValues)[ 3]
411#define Nod24PntV ((Standard_Real*)Nod24RValues)[ 4]
412#define Nod24NrmX ((Standard_Real*)Nod24RValues)[ 5]
413#define Nod24NrmY ((Standard_Real*)Nod24RValues)[ 6]
414#define Nod24NrmZ ((Standard_Real*)Nod24RValues)[ 7]
415#define Nod24PCu1 ((Standard_Real*)Nod24RValues)[ 8]
416#define Nod24PCu2 ((Standard_Real*)Nod24RValues)[ 9]
417#define Nod24Scal ((Standard_Real*)Nod24RValues)[10]
418
419#define ShapeIndex ((Standard_Integer*)IndexPtr)[0]
420#define F1Index ((Standard_Integer*)IndexPtr)[1]
421#define F1Pt1Index ((Standard_Integer*)IndexPtr)[2]
422#define F1Pt2Index ((Standard_Integer*)IndexPtr)[3]
423#define F2Index ((Standard_Integer*)IndexPtr)[4]
424#define F2Pt1Index ((Standard_Integer*)IndexPtr)[5]
425#define F2Pt2Index ((Standard_Integer*)IndexPtr)[6]
426#define MinSeg ((Standard_Integer*)IndexPtr)[7]
427#define MaxSeg ((Standard_Integer*)IndexPtr)[8]
428#define SegFlags ((Standard_Integer*)IndexPtr)[9]
429#ifdef DEB
430static Standard_Integer DoTrace = Standard_False;
431static Standard_Integer DoError = Standard_False;
432static Standard_Integer IndexPlusOnePerCentThree [] = { 1 , 2 , 0 };
433#endif
434//=======================================================================
435//function : HLRBRep_PolyAlgo
436//purpose :
437//=======================================================================
438
439HLRBRep_PolyAlgo::HLRBRep_PolyAlgo () :
440myDebug (Standard_False),
441myAngle (5 * PI / 180.),
442myTolSta (0.1),
443myTolEnd (0.9),
444myTolAngular(0.001)
445{
446 myAlgo = new HLRAlgo_PolyAlgo();
447}
448
449//=======================================================================
450//function : HLRBRep_PolyAlgo
451//purpose :
452//=======================================================================
453
454HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const Handle(HLRBRep_PolyAlgo)& A)
455{
456 myDebug = A->Debug();
457 myAngle = A->Angle();
458 myTolAngular = A->TolAngular();
459 myTolSta = A->TolCoef();
460 myTolEnd = 1 - myTolSta;
461 myAlgo = A->Algo();
462 myProj = A->Projector();
463
464 Standard_Integer n = A->NbShapes();
465
466 for (Standard_Integer i = 1; i <= n; i++)
467 Load(A->Shape(i));
468}
469
470//=======================================================================
471//function : HLRBRep_PolyAlgo
472//purpose :
473//=======================================================================
474
475HLRBRep_PolyAlgo::HLRBRep_PolyAlgo (const TopoDS_Shape& S) :
476myDebug (Standard_False),
477myAngle (5 * PI / 180.),
478myTolSta (0.1),
479myTolEnd (0.9),
480myTolAngular(0.001)
481{
482 myShapes.Append(S);
483 myAlgo = new HLRAlgo_PolyAlgo();
484}
485
486//=======================================================================
487//function : Shape
488//purpose :
489//=======================================================================
490
491TopoDS_Shape & HLRBRep_PolyAlgo::Shape (const Standard_Integer I)
492{
493 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
494 "HLRBRep_PolyAlgo::Shape : unknown Shape");
495 return myShapes(I);
496}
497
498//=======================================================================
499//function : Remove
500//purpose :
501//=======================================================================
502
503void HLRBRep_PolyAlgo::Remove (const Standard_Integer I)
504{
505 Standard_OutOfRange_Raise_if (I == 0 || I > myShapes.Length(),
506 "HLRBRep_PolyAlgo::Remove : unknown Shape");
507 myShapes.Remove(I);
508 myAlgo->Clear();
509 myEMap.Clear();
510 myFMap.Clear();
511}
512
513//=======================================================================
514//function : Index
515//purpose :
516//=======================================================================
517
518Standard_Integer HLRBRep_PolyAlgo::Index (const TopoDS_Shape& S) const
519{
520 Standard_Integer n = myShapes.Length();
521
522 for (Standard_Integer i = 1; i <= n; i++)
523 if (myShapes(i) == S) return i;
524
525 return 0;
526}
527
528//=======================================================================
529//function : Algo
530//purpose :
531//=======================================================================
532
533Handle(HLRAlgo_PolyAlgo) HLRBRep_PolyAlgo::Algo () const
534{
535 return myAlgo;
536}
537
538//=======================================================================
539//function : Update
540//purpose :
541//=======================================================================
542
543void HLRBRep_PolyAlgo::Update ()
544{
545 myAlgo->Clear();
546 myEMap.Clear();
547 myFMap.Clear();
548 TopoDS_Shape Shape = MakeShape();
549
550 if (!Shape.IsNull()) {
551 TopExp_Explorer exshell;
552 Standard_Boolean IsoledF,IsoledE;//,closed;
553 TopLoc_Location L;
554 TopTools_MapOfShape ShapeMap1,ShapeMap2;
555 TopExp::MapShapes(Shape,TopAbs_EDGE,myEMap);
556 TopExp::MapShapes(Shape,TopAbs_FACE,myFMap);
557 Standard_Integer nbEdge = myEMap.Extent();
558 Standard_Integer nbFace = myFMap.Extent();
559 TColStd_Array1OfInteger ES (0,nbEdge); // index of the Shell
560 TColStd_Array1OfTransient PD (0,nbFace); // HLRAlgo_PolyData
561 TColStd_Array1OfTransient PID(0,nbFace); // PolyInternalData
562 Standard_Integer nbShell = InitShape(Shape,IsoledF,IsoledE);
563 if (nbShell > 0) {
564 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
565 Standard_Integer iShell = 0;
566
567 for (exshell.Init(Shape, TopAbs_SHELL);
568 exshell.More();
569 exshell.Next())
570 StoreShell(exshell.Current(),iShell,Shell,
571 Standard_False,Standard_False,
572 ES,PD,PID,ShapeMap1,ShapeMap2);
573 if (IsoledF)
574 StoreShell(Shape,iShell,Shell,IsoledF,Standard_False,
575 ES,PD,PID,ShapeMap1,ShapeMap2);
576 if (IsoledE)
577 StoreShell(Shape,iShell,Shell,Standard_False,IsoledE,
578 ES,PD,PID,ShapeMap1,ShapeMap2);
579 myAlgo->Update();
580 }
581 }
582}
583
584//=======================================================================
585//function : MakeShape
586//purpose :
587//=======================================================================
588
589TopoDS_Shape HLRBRep_PolyAlgo::MakeShape () const
590{
591 Standard_Integer n = myShapes.Length();
592 Standard_Boolean FirstTime = Standard_True;
593 BRep_Builder B;
594 TopoDS_Shape Shape;
595
596 for (Standard_Integer i = 1; i <= n; i++) {
597 if (FirstTime) {
598 FirstTime = Standard_False;
599 B.MakeCompound(TopoDS::Compound(Shape));
600 }
601 B.Add(Shape,myShapes(i));
602 }
603 return Shape;
604}
605
606//=======================================================================
607//function : InitShape
608//purpose :
609//=======================================================================
610
611Standard_Integer
612HLRBRep_PolyAlgo::InitShape (const TopoDS_Shape& Shape,
613 Standard_Boolean& IsoledF,
614 Standard_Boolean& IsoledE)
615{
616 TopTools_MapOfShape ShapeMap0;
617 Standard_Integer nbShell = 0;
618 IsoledF = Standard_False;
619 IsoledE = Standard_False;
620 TopExp_Explorer exshell,exface,exedge;
621 TopLoc_Location L;
622
623 for (exshell.Init(Shape, TopAbs_SHELL);
624 exshell.More();
625 exshell.Next()) {
626 Standard_Boolean withTrian = Standard_False;
627
628 for (exface.Init(exshell.Current(), TopAbs_FACE);
629 exface.More();
630 exface.Next()) {
631 const TopoDS_Face& F = TopoDS::Face(exface.Current());
632 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
633 if (ShapeMap0.Add(F))
634 withTrian = Standard_True;
635 }
636 }
637 if (withTrian) nbShell++;
638 }
639
640 for (exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
641 exface.More() && !IsoledF;
642 exface.Next()) {
643 const TopoDS_Face& F = TopoDS::Face(exface.Current());
644 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
645 if (ShapeMap0.Add(F))
646 IsoledF = Standard_True;
647 }
648 }
649 if (IsoledF) nbShell++;
650
651 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
652 exedge.More() && !IsoledE;
653 exedge.Next())
654 IsoledE = Standard_True;
655 if (IsoledE) nbShell++;
656 if (nbShell > 0)
657 myAlgo->Init(new TColStd_HArray1OfTransient(1,nbShell));
658 return nbShell;
659}
660
661//=======================================================================
662//function : StoreShell
663//purpose :
664//=======================================================================
665
666void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
667 Standard_Integer& iShell,
668 TColStd_Array1OfTransient& Shell,
669 const Standard_Boolean IsoledF,
670 const Standard_Boolean IsoledE,
671 TColStd_Array1OfInteger& ES,
672 TColStd_Array1OfTransient& PD,
673 TColStd_Array1OfTransient& PID,
674 TopTools_MapOfShape& ShapeMap1,
675 TopTools_MapOfShape& ShapeMap2)
676{
677 TopLoc_Location L;
678 TopExp_Explorer exface,exedge;
679 Standard_Integer f,i,j;
680 Standard_Integer nbFaceShell = 0;
681 Standard_Boolean reversed;
682 Standard_Boolean closed = Standard_False;
683 const gp_Trsf& T = myProj.Transformation();
684 const gp_Trsf& TI = myProj.InvertedTransformation();
685 const gp_XYZ& tloc = T.TranslationPart();
686 TLoc[0] = tloc.X();
687 TLoc[1] = tloc.Y();
688 TLoc[2] = tloc.Z();
689 const gp_Mat& tmat = T.VectorialPart();
690 TMat[0][0] = tmat.Value(1,1);
691 TMat[0][1] = tmat.Value(1,2);
692 TMat[0][2] = tmat.Value(1,3);
693 TMat[1][0] = tmat.Value(2,1);
694 TMat[1][1] = tmat.Value(2,2);
695 TMat[1][2] = tmat.Value(2,3);
696 TMat[2][0] = tmat.Value(3,1);
697 TMat[2][1] = tmat.Value(3,2);
698 TMat[2][2] = tmat.Value(3,3);
699 const gp_XYZ& tilo = TI.TranslationPart();
700 TILo[0] = tilo.X();
701 TILo[1] = tilo.Y();
702 TILo[2] = tilo.Z();
703 const gp_Mat& tima = TI.VectorialPart();
704 TIMa[0][0] = tima.Value(1,1);
705 TIMa[0][1] = tima.Value(1,2);
706 TIMa[0][2] = tima.Value(1,3);
707 TIMa[1][0] = tima.Value(2,1);
708 TIMa[1][1] = tima.Value(2,2);
709 TIMa[1][2] = tima.Value(2,3);
710 TIMa[2][0] = tima.Value(3,1);
711 TIMa[2][1] = tima.Value(3,2);
712 TIMa[2][2] = tima.Value(3,3);
713 if (!IsoledE) {
714 if (!IsoledF) {
715 closed = Shape.Closed();
716 if (!closed) {
717 TopTools_IndexedMapOfShape EM;
718 TopExp::MapShapes(Shape,TopAbs_EDGE,EM);
719 Standard_Integer ie;
720 Standard_Integer nbEdge = EM.Extent ();
721 Standard_Integer *flag = new Standard_Integer[nbEdge + 1];
722
723 for (ie = 1; ie <= nbEdge; ie++)
724 flag[ie] = 0;
725
726 for (exedge.Init(Shape, TopAbs_EDGE);
727 exedge.More();
728 exedge.Next()) {
729 const TopoDS_Edge& E = TopoDS::Edge(exedge.Current());
730 ie = EM.FindIndex(E);
731 TopAbs_Orientation orient = E.Orientation();
732 if (!BRep_Tool::Degenerated(E)) {
733 if (orient == TopAbs_FORWARD ) flag[ie] += 1;
734 else if (orient == TopAbs_REVERSED) flag[ie] -= 1;
735 }
736 }
737 closed = Standard_True;
738
739 for (ie = 1; ie <= nbEdge && closed; ie++)
740 closed = (flag[ie] == 0);
741 delete [] flag;
742 flag = NULL;
743 }
744
745 exface.Init(Shape, TopAbs_FACE);
746 }
747 else
748 exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
749
750 for (; exface.More(); exface.Next()) {
751 const TopoDS_Face& F = TopoDS::Face(exface.Current());
752 if (!BRep_Tool::Triangulation(F,L).IsNull()) {
753 if (ShapeMap1.Add(F))
754 nbFaceShell++;
755 }
756 }
757 }
758 if (nbFaceShell > 0 || IsoledE) {
759 iShell++;
760 Shell(iShell) = new HLRAlgo_PolyShellData(nbFaceShell);
761 }
762 if (nbFaceShell > 0) {
763 const Handle(HLRAlgo_PolyShellData)& psd =
764 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
765 Standard_Integer iFace = 0;
766 if (!IsoledF) exface.Init(Shape, TopAbs_FACE);
767 else exface.Init(Shape, TopAbs_FACE, TopAbs_SHELL);
768 TopTools_MapOfShape ShapeMapBis;
769
770 for (; exface.More(); exface.Next()) {
771 const TopoDS_Face& F = TopoDS::Face(exface.Current());
772 const Handle(Poly_Triangulation)& Tr = BRep_Tool::Triangulation(F,L);
773 if (!Tr.IsNull()) {
774 if (ShapeMap2.Add(F)) {
775 iFace++;
776 f = myFMap.FindIndex(F);
777 reversed = F.Orientation() == TopAbs_REVERSED;
778 gp_Trsf TT = L.Transformation();
779 TT.PreMultiply(T);
780 const gp_XYZ& ttlo = TT.TranslationPart();
781 TTLo[0] = ttlo.X();
782 TTLo[1] = ttlo.Y();
783 TTLo[2] = ttlo.Z();
784 const gp_Mat& ttma = TT.VectorialPart();
785 TTMa[0][0] = ttma.Value(1,1);
786 TTMa[0][1] = ttma.Value(1,2);
787 TTMa[0][2] = ttma.Value(1,3);
788 TTMa[1][0] = ttma.Value(2,1);
789 TTMa[1][1] = ttma.Value(2,2);
790 TTMa[1][2] = ttma.Value(2,3);
791 TTMa[2][0] = ttma.Value(3,1);
792 TTMa[2][1] = ttma.Value(3,2);
793 TTMa[2][2] = ttma.Value(3,3);
794 Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
795 TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
796 Standard_Integer nbN = Nod.Upper();
797 Standard_Integer nbT = Tri.Upper();
798 PD (f) = new HLRAlgo_PolyData();
799 psd->PolyData().ChangeValue(iFace) = PD(f);
800 PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
801 Handle(HLRAlgo_PolyInternalData)& pid =
802 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(f));
803 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
804 if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface))
805 S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
806 GeomAdaptor_Surface AS(S);
807 pid->Planar(AS.GetType() == GeomAbs_Plane);
808 Standard_Address TData = &pid->TData();
809 Standard_Address PISeg = &pid->PISeg();
810 Standard_Address PINod = &pid->PINod();
811 Poly_Triangle * OT = &(Tri.ChangeValue(1));
812 HLRAlgo_TriangleData* NT =
813 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
814
815 for (i = 1; i <= nbT; i++) {
816 Standard_Address Tri2Indices = NT->Indices();
817 OT->Get(Tri2Node1,Tri2Node2,Tri2Node3);
818 Tri2Flags = 0;
819 if (reversed) {
820 j = Tri2Node1;
821 Tri2Node1 = Tri2Node3;
822 Tri2Node3 = j;
823 }
824 OT++;
825 NT++;
826 }
827
828 gp_Pnt * ON = &(Nod.ChangeValue(1));
829 Handle(HLRAlgo_PolyInternalNode)* NN =
830 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
831
832 for (i = 1; i <= nbN; i++) {
833 const Standard_Address Nod1RValues = (*NN)->RValues();
834 const Standard_Address Nod1Indices = (*NN)->Indices();
835 Nod1NdSg = 0;
836 Nod1Flag = 0;
837 Nod1PntX = ON->X();
838 Nod1PntY = ON->Y();
839 Nod1PntZ = ON->Z();
840 TTMultiply(Nod1PntX,Nod1PntY,Nod1PntZ);
841 ON++;
842 NN++;
843 }
844 pid->UpdateLinks(TData,PISeg,PINod);
845 if (Tr->HasUVNodes()) {
846 myBSurf.Initialize(F,Standard_False);
847 TColgp_Array1OfPnt2d & UVN = Tr->ChangeUVNodes();
848 gp_Pnt2d* OUVN = &(UVN.ChangeValue(1));
849 NN = &(((HLRAlgo_Array1OfPINod*)PINod)->
850 ChangeValue(1));
851
852 for (i = 1; i <= nbN; i++) {
853 const Standard_Address Nod1Indices = (*NN)->Indices();
854 const Standard_Address Nod1RValues = (*NN)->RValues();
855 Nod1PntU = OUVN->X();
856 Nod1PntV = OUVN->Y();
857 if (Normal(i,Nod1Indices,Nod1RValues,
858 TData,PISeg,PINod,Standard_False))
859 Nod1Flag |= NMskNorm;
860 else {
861 Nod1Flag &= ~NMskNorm;
862 Nod1Scal = 0;
863 }
864 OUVN++;
865 NN++;
866 }
867 }
868#ifdef DEB
869 else if (DoError) {
870 cout << " HLRBRep_PolyAlgo::StoreShell : Face ";
871 cout << f << " non triangulated" << endl;
872 }
873#endif
874 NT = &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
875
876 for (i = 1; i <= nbT; i++) {
877 const Standard_Address Tri1Indices = NT->Indices();
878 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
879 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
880 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
881 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
882 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
883 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
884 const Standard_Address Nod1Indices = (*PN1)->Indices();
885 const Standard_Address Nod2Indices = (*PN2)->Indices();
886 const Standard_Address Nod3Indices = (*PN3)->Indices();
887 const Standard_Address Nod1RValues = (*PN1)->RValues();
888 const Standard_Address Nod2RValues = (*PN2)->RValues();
889 const Standard_Address Nod3RValues = (*PN3)->RValues();
890 OrientTriangle(i,Tri1Indices,
891 Nod1Indices,Nod1RValues,
892 Nod2Indices,Nod2RValues,
893 Nod3Indices,Nod3RValues);
894 NT++;
895 }
896 }
897 }
898#ifdef DEB
899 else if (DoError) {
900 cout << "HLRBRep_PolyAlgo::StoreShell : Face ";
901 cout << f << " deja stockee" << endl;
902 }
903#endif
904 }
905 Standard_Integer nbFace = myFMap.Extent();
906 HLRAlgo_ListOfBPoint& List = psd->Edges();
907 TopTools_IndexedDataMapOfShapeListOfShape EF;
908 TopExp::MapShapesAndAncestors(Shape,TopAbs_EDGE,TopAbs_FACE,EF);
909 Handle(HLRAlgo_PolyInternalData)* pid =
910 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
911
912 for (f = 1; f <= nbFace; f++) {
913 if (!(*pid).IsNull()) {
914
915 for (exedge.Init(myFMap(f),TopAbs_EDGE);
916 exedge.More();
917 exedge.Next()) {
918 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
919 if (ShapeMap1.Add(E)) {
920 Standard_Integer e = myEMap.FindIndex(E);
921 ES(e) = iShell;
922 Standard_Integer i = EF.FindIndex(E);
923 if (i > 0) {
924 TopTools_ListOfShape& LS = EF(i);
925 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_True);
926 }
927 else {
928 TopTools_ListOfShape LS;
929 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
930 }
931 }
932 }
933 }
934 pid++;
935 }
936 InsertOnOutLine(PID);
937 CheckFrBackTriangles(List,PID);
938 UpdateOutLines(List,PID);
939 UpdateEdgesBiPoints(List,PID,closed);
940 UpdatePolyData(PD,PID,closed);
941 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
942
943 for (f = 1; f <= nbFace; f++) {
944 (*pid).Nullify();
945 pid++;
946 }
947 }
948 else if (IsoledE) {
949 const Handle(HLRAlgo_PolyShellData)& psd =
950 *(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell));
951 HLRAlgo_ListOfBPoint& List = psd->Edges();
952
953 for (exedge.Init(Shape, TopAbs_EDGE, TopAbs_FACE);
954 exedge.More();
955 exedge.Next()) {
956 TopoDS_Edge E = TopoDS::Edge(exedge.Current());
957 if (ShapeMap1.Add(E)) {
958 Standard_Integer e = myEMap.FindIndex(E);
959 ES(e) = iShell;
960 TopTools_ListOfShape LS;
961 InitBiPointsWithConnexity(e,E,List,PID,LS,Standard_False);
962 }
963 }
964 }
965}
966
967//=======================================================================
968//function : Normal
969//purpose :
970//=======================================================================
971
972Standard_Boolean HLRBRep_PolyAlgo::
973Normal (const Standard_Integer iNode,
974 const Standard_Address Nod1Indices,
975 const Standard_Address Nod1RValues,
976 Standard_Address& TData,
977 Standard_Address& PISeg,
978 Standard_Address& PINod,
979 const Standard_Boolean orient) const
980{
981 gp_Vec D1U,D1V,D2U,D2V,D2UV;
982 gp_Pnt P;
983 gp_Dir Norma;
984 Standard_Boolean OK;
985 CSLib_DerivativeStatus Status;
986 CSLib_NormalStatus NStat;
987 myBSurf.D1(Nod1PntU,Nod1PntV,P,D1U,D1V);
988 CSLib::Normal(D1U,D1V,Standard_Real(Precision::Angular()),
989 Status,Norma);
990 if (Status != CSLib_Done) {
991 myBSurf.D2(Nod1PntU,Nod1PntV,P,D1U,D1V,D2U,D2V,D2UV);
992 CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,
993 Precision::Angular(),OK,NStat,Norma);
994 if (!OK)
995 return Standard_False;
996 }
997 Standard_Real EyeX = 0;
998 Standard_Real EyeY = 0;
999 Standard_Real EyeZ = -1;
1000 if (myProj.Perspective()) {
1001 EyeX = Nod1PntX;
1002 EyeY = Nod1PntY;
1003 EyeZ = Nod1PntZ - myProj.Focus();
1004 Standard_Real d = sqrt(EyeX * EyeX + EyeY * EyeY + EyeZ * EyeZ);
1005 if (d > 0) {
1006 EyeX /= d;
1007 EyeY /= d;
1008 EyeZ /= d;
1009 }
1010 }
1011 Nod1NrmX = Norma.X();
1012 Nod1NrmY = Norma.Y();
1013 Nod1NrmZ = Norma.Z();
1014// TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ);
1015 TMultiply(Nod1NrmX,Nod1NrmY,Nod1NrmZ,myProj.Perspective()); //OCC349
1016 Standard_Real NormX,NormY,NormZ;
1017
1018 if (AverageNormal(iNode,Nod1Indices,TData,PISeg,PINod,
1019 NormX,NormY,NormZ)) {
1020 if (Nod1NrmX * NormX +
1021 Nod1NrmY * NormY +
1022 Nod1NrmZ * NormZ < 0) {
1023 Nod1NrmX = -Nod1NrmX;
1024 Nod1NrmY = -Nod1NrmY;
1025 Nod1NrmZ = -Nod1NrmZ;
1026 }
1027 Nod1Scal = (Nod1NrmX * EyeX +
1028 Nod1NrmY * EyeY +
1029 Nod1NrmZ * EyeZ);
1030 }
1031 else {
1032 Nod1Scal = 0;
1033 Nod1NrmX = 1;
1034 Nod1NrmY = 0;
1035 Nod1NrmZ = 0;
1036#ifdef DEB
1037 if (DoError) {
1038 cout << "HLRBRep_PolyAlgo::Normal : AverageNormal error";
1039 cout << endl;
1040 }
1041#endif
1042 }
1043 if (Nod1Scal > 0) {
1044 if ( Nod1Scal < myTolAngular) {
1045 Nod1Scal = 0;
1046 Nod1Flag |= NMskOutL;
1047 }
1048 }
1049 else {
1050 if (-Nod1Scal < myTolAngular) {
1051 Nod1Scal = 0;
1052 Nod1Flag |= NMskOutL;
1053 }
1054 }
1055 if (orient) UpdateAroundNode(iNode,Nod1Indices,
1056 TData,PISeg,PINod);
1057 return Standard_True;
1058}
1059
1060//=======================================================================
1061//function : AverageNormal
1062//purpose :
1063//=======================================================================
1064
1065Standard_Boolean
1066HLRBRep_PolyAlgo::AverageNormal(const Standard_Integer iNode,
1067 const Standard_Address Nod1Indices,
1068 Standard_Address& TData,
1069 Standard_Address& PISeg,
1070 Standard_Address& PINod,
1071 Standard_Real& X,
1072 Standard_Real& Y,
1073 Standard_Real& Z) const
1074{
1075 Standard_Boolean OK = Standard_False;
1076 Standard_Integer jNode = 0,kNode,iiii,iTri1,iTri2;
1077 X = 0;
1078 Y = 0;
1079 Z = 0;
1080 iiii = Nod1NdSg;
1081
1082 while (iiii != 0 && !OK) {
1083 const Standard_Address Seg2Indices =
1084 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1085 iTri1 = Seg2Conex1;
1086 iTri2 = Seg2Conex2;
1087 if ( iTri1 != 0) AddNormalOnTriangle
1088 (iTri1,iNode,jNode,TData,PINod,X,Y,Z,OK);
1089 if ( iTri2 != 0) AddNormalOnTriangle
1090 (iTri2,iNode,jNode,TData,PINod,X,Y,Z,OK);
1091 if (Seg2LstSg1 == iNode) iiii = Seg2NxtSg1;
1092 else iiii = Seg2NxtSg2;
1093 }
1094
1095 if (jNode != 0) {
1096 const Standard_Address Nod2Indices =
1097 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(jNode)->Indices();
1098 iiii = Nod2NdSg;
1099
1100 while (iiii != 0 && !OK) {
1101 const Standard_Address Seg2Indices =
1102 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
1103 iTri1 = Seg2Conex1;
1104 iTri2 = Seg2Conex2;
1105 if ( iTri1 != 0) AddNormalOnTriangle
1106 (iTri1,jNode,kNode,TData,PINod,X,Y,Z,OK);
1107 if ( iTri2 != 0) AddNormalOnTriangle
1108 (iTri2,jNode,kNode,TData,PINod,X,Y,Z,OK);
1109 if (Seg2LstSg1 == jNode) iiii = Seg2NxtSg1;
1110 else iiii = Seg2NxtSg2;
1111 }
1112 }
1113 Standard_Real d = sqrt (X * X + Y * Y + Z * Z);
1114 if (OK && d < 1.e-10) {
1115 OK = Standard_False;
1116#ifdef DEB
1117 if (DoError) {
1118 cout << "HLRAlgo_PolyInternalData:: inverted normals on ";
1119 cout << "node " << iNode << endl;
1120 }
1121#endif
1122 }
1123 return OK;
1124}
1125
1126//=======================================================================
1127//function : AddNormalOnTriangle
1128//purpose :
1129//=======================================================================
1130
1131void
1132HLRBRep_PolyAlgo::
1133AddNormalOnTriangle(const Standard_Integer iTri,
1134 const Standard_Integer iNode,
1135 Standard_Integer& jNode,
1136 Standard_Address& TData,
1137 Standard_Address& PINod,
1138 Standard_Real& X,
1139 Standard_Real& Y,
1140 Standard_Real& Z,
1141 Standard_Boolean& OK) const
1142{
1143 Standard_Real dn,dnx,dny,dnz;
1144 Standard_Real d1,dx1,dy1,dz1;
1145 Standard_Real d2,dx2,dy2,dz2;
1146 Standard_Real d3,dx3,dy3,dz3;
1147 const Standard_Address Tri2Indices =
1148 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri).Indices();
1149 const Standard_Address Nod1RValues =
1150 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1)->RValues();
1151 const Standard_Address Nod2RValues =
1152 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2)->RValues();
1153 const Standard_Address Nod3RValues =
1154 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3)->RValues();
1155 dx1 = Nod2PntX - Nod1PntX;
1156 dy1 = Nod2PntY - Nod1PntY;
1157 dz1 = Nod2PntZ - Nod1PntZ;
1158 d1 = sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
1159 if (d1 < 1.e-10) {
1160 if (Tri2Node1 == iNode) jNode = Tri2Node2;
1161 else if (Tri2Node2 == iNode) jNode = Tri2Node1;
1162 }
1163 else {
1164 dx2 = Nod3PntX - Nod2PntX;
1165 dy2 = Nod3PntY - Nod2PntY;
1166 dz2 = Nod3PntZ - Nod2PntZ;
1167 d2 = sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
1168 if (d2 < 1.e-10) {
1169 if (Tri2Node2 == iNode) jNode = Tri2Node3;
1170 else if (Tri2Node3 == iNode) jNode = Tri2Node2;
1171 }
1172 else {
1173 dx3 = Nod1PntX - Nod3PntX;
1174 dy3 = Nod1PntY - Nod3PntY;
1175 dz3 = Nod1PntZ - Nod3PntZ;
1176 d3 = sqrt(dx3 * dx3 + dy3 * dy3 + dz3 * dz3);
1177 if (d3 < 1.e-10) {
1178 if (Tri2Node3 == iNode) jNode = Tri2Node1;
1179 else if (Tri2Node1 == iNode) jNode = Tri2Node3;
1180 }
1181 else {
1182 dn = 1 / (d1 * d2);
1183 dnx = (dy1 * dz2 - dy2 * dz1) * dn;
1184 dny = (dz1 * dx2 - dz2 * dx1) * dn;
1185 dnz = (dx1 * dy2 - dx2 * dy1) * dn;
1186 dn = sqrt(dnx * dnx + dny * dny + dnz * dnz);
1187 if (dn > 1.e-10) {
1188 OK = Standard_True;
1189 X += dnx;
1190 Y += dny;
1191 Z += dnz;
1192 }
1193 }
1194 }
1195 }
1196}
1197
1198//=======================================================================
1199//function : InitBiPointsWithConnexity
1200//purpose :
1201//=======================================================================
1202
1203void HLRBRep_PolyAlgo::
1204InitBiPointsWithConnexity (const Standard_Integer e,
1205 TopoDS_Edge& E,
1206 HLRAlgo_ListOfBPoint& List,
1207 TColStd_Array1OfTransient& PID,
1208 TopTools_ListOfShape& LS,
1209 const Standard_Boolean connex)
1210{
1211 Standard_Integer iPol,nbPol,i1,i1p1,i1p2,i2,i2p1,i2p2;
1212 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
1213 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
1214 Standard_Real U1,U2;
1215 Handle(Poly_PolygonOnTriangulation) HPol[2];
1216 TopLoc_Location L;
1217 myBCurv.Initialize(E);
1218 if (connex) {
1219 Standard_Integer nbConnex = LS.Extent();
1220 if (nbConnex == 1) {
1221 TopTools_ListIteratorOfListOfShape itn(LS);
1222 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1223 i1 = myFMap.FindIndex(F1);
1224 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1225 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1226 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1227 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1228 if (!HPol[0].IsNull()) {
1229 myPC.Initialize(E,F1);
1230 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1231 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1232 nbPol = Pol1.Upper();
1233 Standard_Address TData1 = &pid1->TData();
1234 Standard_Address PISeg1 = &pid1->PISeg();
1235 Standard_Address PINod1 = &pid1->PINod();
1236 Standard_Address Nod11Indices,Nod12Indices;
1237 Standard_Address Nod11RValues,Nod12RValues;
1238 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1239 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1240 Nod11Indices = (*pi1p1)->Indices();
1241 Nod11RValues = (*pi1p1)->RValues();
1242 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1243 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1244 Nod12Indices = (*pi1p2)->Indices();
1245 Nod12RValues = (*pi1p2)->RValues();
1246 Nod11Flag |= NMskVert;
1247 Nod12Flag |= NMskVert;
1248
1249 for (iPol = 1; iPol <= nbPol; iPol++) {
1250 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1251 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1252 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1253 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1254 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1255 Nod1AEdg1 = e;
1256 Nod1APCu1 = par->Value(iPol);
1257 }
1258 else {
1259 Nod1AEdg2 = e;
1260 Nod1APCu2 = par->Value(iPol);
1261 }
1262 }
1263
1264 i1p2 = Pol1(1);
1265 Nod12Indices = Nod11Indices;
1266 Nod12RValues = Nod11RValues;
1267 XTI2 = X2 = Nod12PntX;
1268 YTI2 = Y2 = Nod12PntY;
1269 ZTI2 = Z2 = Nod12PntZ;
1270 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1271 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1272#ifdef DEB
1273 else {
1274 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1275 cout << "Parameter error on Node " << i1p2 << endl;
1276 }
1277#endif
1278 Nod12Flag |= NMskEdge;
1279 TIMultiply(XTI2,YTI2,ZTI2);
1280 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1281 U2 = U2 - myPC.Period();
1282
1283 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1284 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1285 Nod12Indices,Nod12RValues);
1286 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1287 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1288 }
1289 else {
1290
1291 for (iPol = 2; iPol <= nbPol; iPol++) {
1292 i1p1 = i1p2;
1293 Nod11Indices = Nod12Indices;
1294 Nod11RValues = Nod12RValues;
1295 i1p2 = Pol1(iPol);
1296 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1297 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1298 Nod12Indices = (*pi1p2)->Indices();
1299 Nod12RValues = (*pi1p2)->RValues();
1300#ifdef DEB
1301 if (DoError) {
1302 if (Nod11NrmX*Nod12NrmX +
1303 Nod11NrmY*Nod12NrmY +
1304 Nod11NrmZ*Nod12NrmZ < 0) {
1305 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1306 cout << "Too big angle between " << i1p1 << setw(6);
1307 cout << " and " << i1p2 << setw(6);
1308 cout << " in face " << i1 << endl;
1309 }
1310 }
1311#endif
1312 X1 = X2;
1313 Y1 = Y2;
1314 Z1 = Z2;
1315 XTI1 = XTI2;
1316 YTI1 = YTI2;
1317 ZTI1 = ZTI2;
1318 U1 = U2;
1319 XTI2 = X2 = Nod12PntX;
1320 YTI2 = Y2 = Nod12PntY;
1321 ZTI2 = Z2 = Nod12PntZ;
1322 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1323 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1324#ifdef DEB
1325 else {
1326 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1327 cout << "Parameter error on Node " << i1p2 << endl;
1328 }
1329#endif
1330 Nod12Flag |= NMskEdge;
1331 TIMultiply(XTI2,YTI2,ZTI2);
1332 Interpolation(List,
1333 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1334 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1335 e,U1,U2,
1336 Nod11Indices,Nod11RValues,
1337 Nod12Indices,Nod12RValues,
1338 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1);
1339 }
1340 }
1341 }
1342#ifdef DEB
1343 else if (DoError) {
1344 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1345 cout << e << " connex 1 sans PolygonOnTriangulation" << endl;
1346 }
1347#endif
1348 }
1349 else if (nbConnex == 2) {
1350 TopTools_ListIteratorOfListOfShape itn(LS);
1351 const TopoDS_Face& F1 = TopoDS::Face(itn.Value());
1352 i1 = myFMap.FindIndex(F1);
1353 const Handle(Poly_Triangulation)& Tr1 = BRep_Tool::Triangulation(F1,L);
1354 HPol[0] = BRep_Tool::PolygonOnTriangulation(E,Tr1,L);
1355 itn.Next();
1356 const TopoDS_Face& F2 = TopoDS::Face(itn.Value());
1357 i2 = myFMap.FindIndex(F2);
1358 if (i1 == i2) E.Reverse();
1359 const Handle(Poly_Triangulation)& Tr2 = BRep_Tool::Triangulation(F2,L);
1360 HPol[1] = BRep_Tool::PolygonOnTriangulation(E,Tr2,L);
1361 GeomAbs_Shape rg = BRep_Tool::Continuity(E,F1,F2);
1362 const Handle(HLRAlgo_PolyInternalData)& pid1 =
1363 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i1));
1364 const Handle(HLRAlgo_PolyInternalData)& pid2 =
1365 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(i2));
1366 if (!HPol[0].IsNull() && !HPol[1].IsNull()) {
1367 myPC.Initialize(E,F1);
1368 const TColStd_Array1OfInteger& Pol1 = HPol[0]->Nodes();
1369 const TColStd_Array1OfInteger& Pol2 = HPol[1]->Nodes();
1370 const Handle(TColStd_HArray1OfReal)& par = HPol[0]->Parameters();
1371 Standard_Integer nbPol = Pol1.Upper();
1372 Standard_Address TData1 = &pid1->TData();
1373 Standard_Address PISeg1 = &pid1->PISeg();
1374 Standard_Address PINod1 = &pid1->PINod();
1375 Standard_Address TData2 = &pid2->TData();
1376 Standard_Address PISeg2 = &pid2->PISeg();
1377 Standard_Address PINod2 = &pid2->PINod();
1378 Standard_Address Nod11Indices,Nod11RValues;
1379 Standard_Address Nod12Indices,Nod12RValues;
1380 Standard_Address Nod21Indices,Nod21RValues;
1381 Standard_Address Nod22Indices,Nod22RValues;
1382 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
1383 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(1 )));
1384 Nod11Indices = (*pi1p1)->Indices();
1385 Nod11RValues = (*pi1p1)->RValues();
1386 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1387 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(nbPol)));
1388 Nod12Indices = (*pi1p2)->Indices();
1389 Nod12RValues = (*pi1p2)->RValues();
1390 const Handle(HLRAlgo_PolyInternalNode)* pi2p1 =
1391 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(1 )));
1392 Nod21Indices = (*pi2p1)->Indices();
1393 Nod21RValues = (*pi2p1)->RValues();
1394 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1395 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(nbPol)));
1396 Nod22Indices = (*pi2p2)->Indices();
1397 Nod22RValues = (*pi2p2)->RValues();
1398 Nod11Flag |= NMskVert;
1399 Nod12Flag |= NMskVert;
1400 Nod21Flag |= NMskVert;
1401 Nod22Flag |= NMskVert;
1402
1403 for (iPol = 1; iPol <= nbPol; iPol++) {
1404 const Handle(HLRAlgo_PolyInternalNode)* pi1pA =
1405 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1406 Standard_Address Nod1AIndices = (*pi1pA)->Indices();
1407 Standard_Address Nod1ARValues = (*pi1pA)->RValues();
1408 const Handle(HLRAlgo_PolyInternalNode)* pi2pA =
1409 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1410 Standard_Address Nod2AIndices = (*pi2pA)->Indices();
1411 Standard_Address Nod2ARValues = (*pi2pA)->RValues();
1412 Standard_Real PCu = par->Value(iPol);
1413 if (Nod1AEdg1 == 0 || Nod1AEdg1 == (Standard_Boolean) e) {
1414 Nod1AEdg1 = e;
1415 Nod1APCu1 = PCu;
1416 }
1417 else {
1418 Nod1AEdg2 = e;
1419 Nod1APCu2 = PCu;
1420 }
1421 if (Nod2AEdg1 == 0 || Nod2AEdg1 == (Standard_Boolean) e) {
1422 Nod2AEdg1 = e;
1423 Nod2APCu1 = PCu;
1424 }
1425 else {
1426 Nod2AEdg2 = e;
1427 Nod2APCu2 = PCu;
1428 }
1429 }
1430
1431 i1p2 = Pol1(1);
1432 Nod12Indices = Nod11Indices;
1433 Nod12RValues = Nod11RValues;
1434 i2p2 = Pol2(1);
1435 Nod22Indices = Nod21Indices;
1436 Nod22RValues = Nod21RValues;
1437 XTI2 = X2 = Nod12PntX;
1438 YTI2 = Y2 = Nod12PntY;
1439 ZTI2 = Z2 = Nod12PntZ;
1440 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1441 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1442#ifdef DEB
1443 else {
1444 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1445 cout << "Parameter error on Node " << i1p2 << endl;
1446 }
1447#endif
1448 Nod12Flag |= NMskEdge;
1449 Nod22Flag |= NMskEdge;
1450 TIMultiply(XTI2,YTI2,ZTI2);
1451 if (Pol1(1) == Pol1(nbPol) && myPC.IsPeriodic())
1452 U2 = U2 - myPC.Period();
1453
1454 if (nbPol == 2 && BRep_Tool::Degenerated(E)) {
1455 CheckDegeneratedSegment(Nod11Indices,Nod11RValues,
1456 Nod12Indices,Nod12RValues);
1457 CheckDegeneratedSegment(Nod21Indices,Nod21RValues,
1458 Nod22Indices,Nod22RValues);
1459 UpdateAroundNode(Pol1(1 ),Nod11Indices,TData1,PISeg1,PINod1);
1460 UpdateAroundNode(Pol1(nbPol),Nod12Indices,TData1,PISeg1,PINod1);
1461 UpdateAroundNode(Pol2(1 ),Nod21Indices,TData2,PISeg2,PINod2);
1462 UpdateAroundNode(Pol2(nbPol),Nod22Indices,TData2,PISeg2,PINod2);
1463 }
1464 else {
1465
1466 for (iPol = 2; iPol <= nbPol; iPol++) {
1467 i1p1 = i1p2;
1468 Nod11Indices = Nod12Indices;
1469 Nod11RValues = Nod12RValues;
1470 i2p1 = i2p2;
1471 Nod21Indices = Nod22Indices;
1472 Nod21RValues = Nod22RValues;
1473 i1p2 = Pol1(iPol);
1474 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
1475 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(Pol1(iPol)));
1476 Nod12Indices = (*pi1p2)->Indices();
1477 Nod12RValues = (*pi1p2)->RValues();
1478 i2p2 = Pol2(iPol);
1479 const Handle(HLRAlgo_PolyInternalNode)* pi2p2 =
1480 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(Pol2(iPol)));
1481 Nod22Indices = (*pi2p2)->Indices();
1482 Nod22RValues = (*pi2p2)->RValues();
1483#ifdef DEB
1484 if (DoError) {
1485 if (Nod11NrmX*Nod12NrmX +
1486 Nod11NrmY*Nod12NrmY +
1487 Nod11NrmZ*Nod12NrmZ < 0) {
1488 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1489 cout << "To big angle between " << i1p1 << setw(6);
1490 cout << " and " << i1p2 << setw(6);
1491 cout << " in face " << i1 << endl;
1492 }
1493 if (Nod21NrmX*Nod22NrmX +
1494 Nod21NrmY*Nod22NrmY +
1495 Nod21NrmZ*Nod22NrmZ < 0) {
1496 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1497 cout << "To big angle between " << i2p1 << setw(6);
1498 cout << " and " << i2p2 << setw(6);
1499 cout<< " in face " << i2 << endl;
1500 }
1501 }
1502#endif
1503 X1 = X2;
1504 Y1 = Y2;
1505 Z1 = Z2;
1506 XTI1 = XTI2;
1507 YTI1 = YTI2;
1508 ZTI1 = ZTI2;
1509 U1 = U2;
1510 XTI2 = X2 = Nod12PntX;
1511 YTI2 = Y2 = Nod12PntY;
1512 ZTI2 = Z2 = Nod12PntZ;
1513 if (Nod12Edg1 == (Standard_Boolean) e) U2 = Nod12PCu1;
1514 else if (Nod12Edg2 == (Standard_Boolean) e) U2 = Nod12PCu2;
1515#ifdef DEB
1516 else {
1517 cout << " HLRBRep_PolyAlgo::InitBiPointsWithConnexity : ";
1518 cout << "Parameter error on Node " << i1p2 << endl;
1519 }
1520#endif
1521 Nod12Flag |= NMskEdge;
1522 Nod22Flag |= NMskEdge;
1523 TIMultiply(XTI2,YTI2,ZTI2);
1524 Interpolation(List,
1525 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1526 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1527 e,U1,U2,rg,
1528 Nod11Indices,Nod11RValues,
1529 Nod12Indices,Nod12RValues,
1530 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1531 Nod21Indices,Nod21RValues,
1532 Nod22Indices,Nod22RValues,
1533 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2);
1534 }
1535 }
1536 }
1537#ifdef DEB
1538 else if (DoError) {
1539 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1540 cout << e << " connect 2 without PolygonOnTriangulation" << endl;
1541 }
1542#endif
1543 }
1544 }
1545 else { // no connexity
1546 const Handle(Poly_Polygon3D)& Polyg = BRep_Tool::Polygon3D(E,L);
1547 if (!Polyg.IsNull()) {
1548 const TColgp_Array1OfPnt& Pol = Polyg->Nodes();
1549 gp_Trsf TT = L.Transformation();
1550 const gp_Trsf& T = myProj.Transformation();
1551 TT.PreMultiply(T);
1552 const gp_XYZ& ttlo = TT.TranslationPart();
1553 TTLo[0] = ttlo.X();
1554 TTLo[1] = ttlo.Y();
1555 TTLo[2] = ttlo.Z();
1556 const gp_Mat& ttma = TT.VectorialPart();
1557 TTMa[0][0] = ttma.Value(1,1);
1558 TTMa[0][1] = ttma.Value(1,2);
1559 TTMa[0][2] = ttma.Value(1,3);
1560 TTMa[1][0] = ttma.Value(2,1);
1561 TTMa[1][1] = ttma.Value(2,2);
1562 TTMa[1][2] = ttma.Value(2,3);
1563 TTMa[2][0] = ttma.Value(3,1);
1564 TTMa[2][1] = ttma.Value(3,2);
1565 TTMa[2][2] = ttma.Value(3,3);
1566 Standard_Integer nbPol = Pol.Upper();
1567 const gp_XYZ& P1 = Pol(1).XYZ();
1568 X2 = P1.X();
1569 Y2 = P1.Y();
1570 Z2 = P1.Z();
1571 TTMultiply(X2,Y2,Z2);
1572 XTI2 = X2;
1573 YTI2 = Y2;
1574 ZTI2 = Z2;
1575 TIMultiply(XTI2,YTI2,ZTI2);
1576
1577 for (Standard_Integer iPol = 2; iPol <= nbPol; iPol++) {
1578 X1 = X2;
1579 Y1 = Y2;
1580 Z1 = Z2;
1581 XTI1 = XTI2;
1582 YTI1 = YTI2;
1583 ZTI1 = ZTI2;
1584 const gp_XYZ& P2 = Pol(iPol).XYZ();
1585 X2 = P2.X();
1586 Y2 = P2.Y();
1587 Z2 = P2.Z();
1588 TTMultiply(X2,Y2,Z2);
1589 XTI2 = X2;
1590 YTI2 = Y2;
1591 ZTI2 = Z2;
1592 TIMultiply(XTI2,YTI2,ZTI2);
1593 List.Prepend(HLRAlgo_BiPoint
1594 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1595 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1596 0));
1597 }
1598 }
1599#ifdef DEB
1600 else if (DoError) {
1601 cout << "HLRBRep_PolyAlgo::InitBiPointsWithConnexity : Edge ";
1602 cout << e << " Isolated, without Polygone 3D" << endl;
1603 }
1604#endif
1605 }
1606}
1607
1608//=======================================================================
1609//function : Interpolation
1610//purpose :
1611//=======================================================================
1612
1613void
1614HLRBRep_PolyAlgo::
1615Interpolation (HLRAlgo_ListOfBPoint& List,
1616 Standard_Real& X1,
1617 Standard_Real& Y1,
1618 Standard_Real& Z1,
1619 Standard_Real& X2,
1620 Standard_Real& Y2,
1621 Standard_Real& Z2,
1622 Standard_Real& XTI1,
1623 Standard_Real& YTI1,
1624 Standard_Real& ZTI1,
1625 Standard_Real& XTI2,
1626 Standard_Real& YTI2,
1627 Standard_Real& ZTI2,
1628 const Standard_Integer e,
1629 Standard_Real& U1,
1630 Standard_Real& U2,
1631 Standard_Address& Nod11Indices,
1632 Standard_Address& Nod11RValues,
1633 Standard_Address& Nod12Indices,
1634 Standard_Address& Nod12RValues,
1635 const Standard_Integer i1p1,
1636 const Standard_Integer i1p2,
1637 const Standard_Integer i1,
1638 const Handle(HLRAlgo_PolyInternalData)& pid1,
1639 Standard_Address& TData1,
1640 Standard_Address& PISeg1,
1641 Standard_Address& PINod1) const
1642{
1643 Standard_Boolean insP3,mP3P1;
1644 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1645// gp_Pnt P3,PT3;
1646 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1647 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1648 MoveOrInsertPoint(List,
1649 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1650 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1651 e,U1,U2,
1652 Nod11Indices,Nod11RValues,
1653 Nod12Indices,Nod12RValues,
1654 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1655 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,0);
1656}
1657
1658//=======================================================================
1659//function : Interpolation
1660//purpose :
1661//=======================================================================
1662
1663void
1664HLRBRep_PolyAlgo::
1665Interpolation (HLRAlgo_ListOfBPoint& List,
1666 Standard_Real& X1,
1667 Standard_Real& Y1,
1668 Standard_Real& Z1,
1669 Standard_Real& X2,
1670 Standard_Real& Y2,
1671 Standard_Real& Z2,
1672 Standard_Real& XTI1,
1673 Standard_Real& YTI1,
1674 Standard_Real& ZTI1,
1675 Standard_Real& XTI2,
1676 Standard_Real& YTI2,
1677 Standard_Real& ZTI2,
1678 const Standard_Integer e,
1679 Standard_Real& U1,
1680 Standard_Real& U2,
1681 const GeomAbs_Shape rg,
1682 Standard_Address& Nod11Indices,
1683 Standard_Address& Nod11RValues,
1684 Standard_Address& Nod12Indices,
1685 Standard_Address& Nod12RValues,
1686 const Standard_Integer i1p1,
1687 const Standard_Integer i1p2,
1688 const Standard_Integer i1,
1689 const Handle(HLRAlgo_PolyInternalData)& pid1,
1690 Standard_Address& TData1,
1691 Standard_Address& PISeg1,
1692 Standard_Address& PINod1,
1693 Standard_Address& Nod21Indices,
1694 Standard_Address& Nod21RValues,
1695 Standard_Address& Nod22Indices,
1696 Standard_Address& Nod22RValues,
1697 const Standard_Integer i2p1,
1698 const Standard_Integer i2p2,
1699 const Standard_Integer i2,
1700 const Handle(HLRAlgo_PolyInternalData)& pid2,
1701 Standard_Address& TData2,
1702 Standard_Address& PISeg2,
1703 Standard_Address& PINod2) const
1704{
1705 Standard_Boolean insP3,mP3P1,insP4,mP4P1;
1706 Standard_Real X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3;
1707 Standard_Real X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4;
1708// gp_Pnt P3,PT3,P4,PT4;
1709 Standard_Boolean flag = 0;
1710 if (rg >= GeomAbs_G1) flag += 1;
1711 if (rg >= GeomAbs_G2) flag += 2;
1712 insP3 = Interpolation(U1,U2,Nod11RValues,Nod12RValues,
1713 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,mP3P1);
1714 insP4 = Interpolation(U1,U2,Nod21RValues,Nod22RValues,
1715 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,mP4P1);
1716 Standard_Boolean OK = insP3 || insP4;
1717 if (OK) {
1718 if (!insP4) // p1 i1p3 p2
1719 MoveOrInsertPoint(List,
1720 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1721 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1722 e,U1,U2,
1723 Nod11Indices,Nod11RValues,
1724 Nod12Indices,Nod12RValues,
1725 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1726 Nod21Indices,Nod21RValues,
1727 Nod22Indices,Nod22RValues,
1728 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1729 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1730 else if (!insP3) // p1 i2p4 p2
1731 MoveOrInsertPoint(List,
1732 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1733 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1734 e,U1,U2,
1735 Nod21Indices,Nod21RValues,
1736 Nod22Indices,Nod22RValues,
1737 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1738 Nod11Indices,Nod11RValues,
1739 Nod12Indices,Nod12RValues,
1740 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1741 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1742 else if (Abs(coef4 - coef3) < myTolSta) // p1 i1p3-i2p4 p2
1743 MoveOrInsertPoint(List,
1744 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1745 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1746 e,U1,U2,
1747 Nod21Indices,Nod21RValues,
1748 Nod22Indices,Nod22RValues,
1749 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1750 Nod11Indices,Nod11RValues,
1751 Nod12Indices,Nod12RValues,
1752 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1753 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1754 else if (coef4 < coef3) // p1 i2p4 i1p3 p2
1755 MoveOrInsertPoint(List,
1756 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1757 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1758 e,U1,U2,
1759 Nod21Indices,Nod21RValues,
1760 Nod22Indices,Nod22RValues,
1761 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1762 Nod11Indices,Nod11RValues,
1763 Nod12Indices,Nod12RValues,
1764 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1765 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,
1766 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
1767 else // p1 i1p3 i2p4 p2
1768 MoveOrInsertPoint(List,
1769 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
1770 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1771 e,U1,U2,
1772 Nod11Indices,Nod11RValues,
1773 Nod12Indices,Nod12RValues,
1774 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
1775 Nod21Indices,Nod21RValues,
1776 Nod22Indices,Nod22RValues,
1777 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
1778 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,
1779 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
1780 }
1781 else // p1 p2
1782 List.Prepend(HLRAlgo_BiPoint
1783 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1784 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1785 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
1786}
1787
1788//=======================================================================
1789//function : Interpolation
1790//purpose :
1791//=======================================================================
1792
1793Standard_Boolean
1794HLRBRep_PolyAlgo::
1795Interpolation (const Standard_Real U1,
1796 const Standard_Real U2,
1797 const Standard_Address Nod1RValues,
1798 const Standard_Address Nod2RValues,
1799 Standard_Real& X3,
1800 Standard_Real& Y3,
1801 Standard_Real& Z3,
1802 Standard_Real& XTI3,
1803 Standard_Real& YTI3,
1804 Standard_Real& ZTI3,
1805 Standard_Real& coef3,
1806 Standard_Real& U3,
1807 Standard_Boolean& mP3P1) const
1808{
1809 if (NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1)) {
1810 U3 = U1 + (U2 - U1) * coef3;
1811 const gp_Pnt& P3 = myBCurv.Value(U3);
1812 XTI3 = X3 = P3.X();
1813 YTI3 = Y3 = P3.Y();
1814 ZTI3 = Z3 = P3.Z();
1815 TMultiply(X3,Y3,Z3);
1816 return Standard_True;
1817 }
1818 return Standard_False;
1819}
1820
1821//=======================================================================
1822//function : MoveOrInsertPoint
1823//purpose :
1824//=======================================================================
1825
1826void
1827HLRBRep_PolyAlgo::
1828MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1829 Standard_Real& X1,
1830 Standard_Real& Y1,
1831 Standard_Real& Z1,
1832 Standard_Real& X2,
1833 Standard_Real& Y2,
1834 Standard_Real& Z2,
1835 Standard_Real& XTI1,
1836 Standard_Real& YTI1,
1837 Standard_Real& ZTI1,
1838 Standard_Real& XTI2,
1839 Standard_Real& YTI2,
1840 Standard_Real& ZTI2,
1841 const Standard_Integer e,
1842 Standard_Real& U1,
1843 Standard_Real& U2,
1844 Standard_Address& Nod11Indices,
1845 Standard_Address& Nod11RValues,
1846 Standard_Address& Nod12Indices,
1847 Standard_Address& Nod12RValues,
1848 const Standard_Integer i1p1,
1849 const Standard_Integer i1p2,
1850 const Standard_Integer i1,
1851 const Handle(HLRAlgo_PolyInternalData)& pid1,
1852 Standard_Address& TData1,
1853 Standard_Address& PISeg1,
1854 Standard_Address& PINod1,
1855 const Standard_Real X3,
1856 const Standard_Real Y3,
1857 const Standard_Real Z3,
1858 const Standard_Real XTI3,
1859 const Standard_Real YTI3,
1860 const Standard_Real ZTI3,
1861 const Standard_Real coef3,
1862 const Standard_Real U3,
1863 const Standard_Boolean insP3,
1864 const Standard_Boolean mP3P1,
1865 const Standard_Boolean flag) const
1866{
1867 Standard_Address TData2 = 0;
1868 Standard_Address PISeg2 = 0;
1869 Standard_Address PINod2 = 0;
1870 Standard_Boolean ins3 = insP3;
1871 if (ins3 && mP3P1) { // P1 ---> P3
1872 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
1873 ins3 = Standard_False;
1874 ChangeNode(i1p1,i1p2,
1875 Nod11Indices,Nod11RValues,
1876 Nod12Indices,Nod12RValues,
1877 coef3,X3,Y3,Z3,Standard_True,
1878 TData1,PISeg1,PINod1);
1879 X1 = X3;
1880 Y1 = Y3;
1881 Z1 = Z3;
1882 XTI1 = XTI3;
1883 YTI1 = YTI3;
1884 ZTI1 = ZTI3;
1885 U1 = U3;
1886 Nod11PntX = X3;
1887 Nod11PntY = Y3;
1888 Nod11PntZ = Z3;
1889 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
1890 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
1891#ifdef DEB
1892 else {
1893 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1894 cout << "Parameter error on Node " << i1p1 << endl;
1895 }
1896#endif
1897 Nod11Scal = 0;
1898 Nod11Flag |= NMskOutL;
1899 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
1900 Standard_Address Coordinates = List.First().Coordinates();
1901 PntX2 = X3;
1902 PntY2 = Y3;
1903 PntZ2 = Z3;
1904 PntXTI2 = XTI3;
1905 PntYTI2 = YTI3;
1906 PntZTI2 = ZTI3;
1907 }
1908 }
1909 if (ins3 && !mP3P1) { // P2 ---> P3
1910 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
1911 ins3 = Standard_False;
1912 ChangeNode(i1p1,i1p2,
1913 Nod11Indices,Nod11RValues,
1914 Nod12Indices,Nod12RValues,
1915 coef3,X3,Y3,Z3,Standard_False,
1916 TData1,PISeg1,PINod1);
1917 X2 = X3;
1918 Y2 = Y3;
1919 Z2 = Z3;
1920 XTI2 = XTI3;
1921 YTI2 = YTI3;
1922 ZTI2 = ZTI3;
1923 U2 = U3;
1924 Nod12PntX = X3;
1925 Nod12PntY = Y3;
1926 Nod12PntZ = Z3;
1927 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
1928 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
1929#ifdef DEB
1930 else {
1931 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
1932 cout << "Parameter error on Node " << i1p2 << endl;
1933 }
1934#endif
1935 Nod12Scal = 0;
1936 Nod12Flag |= NMskOutL;
1937 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
1938 }
1939 }
1940 if (ins3) { // p1 i1p3 p2
1941 Standard_Integer i1p3 = pid1->AddNode
1942 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
1943 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
1944 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
1945 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
1946 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
1947 Nod13Edg1 = e;
1948 Nod13PCu1 = U3;
1949 Nod13Scal = 0;
1950 Nod13Flag |= NMskOutL;
1951 Nod13Flag |= NMskEdge;
1952 pid1->UpdateLinks(i1p1,i1p2,i1p3,
1953 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
1954 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
1955 List.Prepend(HLRAlgo_BiPoint
1956 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
1957 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
1958 i1 ,i1p1,i1p3,flag));
1959 List.Prepend(HLRAlgo_BiPoint
1960 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
1961 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
1962 i1 ,i1p3,i1p2,flag));
1963 }
1964 else // p1 p2
1965 List.Prepend(HLRAlgo_BiPoint
1966 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
1967 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
1968 i1 ,i1p1,i1p2,flag));
1969}
1970
1971//=======================================================================
1972//function : MoveOrInsertPoint
1973//purpose :
1974//=======================================================================
1975
1976void
1977HLRBRep_PolyAlgo::
1978MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
1979 Standard_Real& X1,
1980 Standard_Real& Y1,
1981 Standard_Real& Z1,
1982 Standard_Real& X2,
1983 Standard_Real& Y2,
1984 Standard_Real& Z2,
1985 Standard_Real& XTI1,
1986 Standard_Real& YTI1,
1987 Standard_Real& ZTI1,
1988 Standard_Real& XTI2,
1989 Standard_Real& YTI2,
1990 Standard_Real& ZTI2,
1991 const Standard_Integer e,
1992 Standard_Real& U1,
1993 Standard_Real& U2,
1994 Standard_Address& Nod11Indices,
1995 Standard_Address& Nod11RValues,
1996 Standard_Address& Nod12Indices,
1997 Standard_Address& Nod12RValues,
1998 const Standard_Integer i1p1,
1999 const Standard_Integer i1p2,
2000 const Standard_Integer i1,
2001 const Handle(HLRAlgo_PolyInternalData)& pid1,
2002 Standard_Address& TData1,
2003 Standard_Address& PISeg1,
2004 Standard_Address& PINod1,
2005 Standard_Address& Nod21Indices,
2006 Standard_Address& Nod21RValues,
2007 Standard_Address& Nod22Indices,
2008 Standard_Address& Nod22RValues,
2009 const Standard_Integer i2p1,
2010 const Standard_Integer i2p2,
2011 const Standard_Integer i2,
2012 const Handle(HLRAlgo_PolyInternalData)& pid2,
2013 Standard_Address& TData2,
2014 Standard_Address& PISeg2,
2015 Standard_Address& PINod2,
2016 const Standard_Real X3,
2017 const Standard_Real Y3,
2018 const Standard_Real Z3,
2019 const Standard_Real XTI3,
2020 const Standard_Real YTI3,
2021 const Standard_Real ZTI3,
2022 const Standard_Real coef3,
2023 const Standard_Real U3,
2024 const Standard_Boolean insP3,
2025 const Standard_Boolean mP3P1,
2026 const Standard_Boolean flag) const
2027{
2028 Standard_Boolean ins3 = insP3;
2029 if (ins3 && mP3P1) { // P1 ---> P3
2030 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2031 ins3 = Standard_False;
2032 ChangeNode(i1p1,i1p2,
2033 Nod11Indices,Nod11RValues,
2034 Nod12Indices,Nod12RValues,
2035 coef3,X3,Y3,Z3,Standard_True,
2036 TData1,PISeg1,PINod1);
2037 ChangeNode(i2p1,i2p2,
2038 Nod21Indices,Nod21RValues,
2039 Nod22Indices,Nod22RValues,
2040 coef3,X3,Y3,Z3,Standard_True,
2041 TData2,PISeg2,PINod2);
2042 X1 = X3;
2043 Y1 = Y3;
2044 Z1 = Z3;
2045 XTI1 = XTI3;
2046 YTI1 = YTI3;
2047 ZTI1 = ZTI3;
2048 U1 = U3;
2049 Nod11PntX = X3;
2050 Nod11PntY = Y3;
2051 Nod11PntZ = Z3;
2052 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2053 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2054#ifdef DEB
2055 else {
2056 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2057 cout << "Parameter error on Node " << i1p1 << endl;
2058 }
2059#endif
2060 Nod11Scal = 0;
2061 Nod11Flag |= NMskOutL;
2062 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2063 Nod21PntX = X3;
2064 Nod21PntY = Y3;
2065 Nod21PntZ = Z3;
2066 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2067 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2068#ifdef DEB
2069 else {
2070 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2071 cout << "Parameter error on Node " << i2p1 << endl;
2072 }
2073#endif
2074 Nod21Scal = 0;
2075 Nod21Flag |= NMskOutL;
2076 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2077 Standard_Address Coordinates = List.First().Coordinates();
2078 PntX2 = X3;
2079 PntY2 = Y3;
2080 PntZ2 = Z3;
2081 PntXTI2 = XTI3;
2082 PntYTI2 = YTI3;
2083 PntZTI2 = ZTI3;
2084 }
2085 }
2086 if (ins3 && !mP3P1) { // P2 ---> P3
2087 if (!(Nod12Flag & NMskVert) && coef3 > myTolEnd) {
2088 ins3 = Standard_False;
2089 ChangeNode(i1p1,i1p2,
2090 Nod11Indices,Nod11RValues,
2091 Nod12Indices,Nod12RValues,
2092 coef3,X3,Y3,Z3,Standard_False,
2093 TData1,PISeg1,PINod1);
2094 ChangeNode(i2p1,i2p2,
2095 Nod21Indices,Nod21RValues,
2096 Nod22Indices,Nod22RValues,
2097 coef3,X3,Y3,Z3,Standard_False,
2098 TData2,PISeg2,PINod2);
2099 X2 = X3;
2100 Y2 = Y3;
2101 Z2 = Z3;
2102 XTI2 = XTI3;
2103 YTI2 = YTI3;
2104 ZTI2 = ZTI3;
2105 U2 = U3;
2106 Nod12PntX = X3;
2107 Nod12PntY = Y3;
2108 Nod12PntZ = Z3;
2109 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U3;
2110 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U3;
2111#ifdef DEB
2112 else {
2113 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2114 cout << "Parameter error on Node " << i1p2 << endl;
2115 }
2116#endif
2117 Nod12Scal = 0;
2118 Nod12Flag |= NMskOutL;
2119 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2120 Nod22PntX = X3;
2121 Nod22PntY = Y3;
2122 Nod22PntZ = Z3;
2123 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U3;
2124 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U3;
2125#ifdef DEB
2126 else {
2127 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2128 cout << "Parameter error on Node " << i2p2 << endl;
2129 }
2130#endif
2131 Nod22Scal = 0;
2132 Nod22Flag |= NMskOutL;
2133 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2134 }
2135 }
2136 if (ins3) { // p1 i1p3 p2
2137 Standard_Integer i1p3 = pid1->AddNode
2138 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2139 Standard_Integer i2p3 = pid2->AddNode
2140 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2141 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2142 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2143 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2144 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2145 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2146 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2147 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2148 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2149 Nod13Edg1 = e;
2150 Nod13PCu1 = U3;
2151 Nod13Scal = 0;
2152 Nod13Flag |= NMskOutL;
2153 Nod13Flag |= NMskEdge;
2154 Nod23Edg1 = e;
2155 Nod23PCu1 = U3;
2156 Nod23Scal = 0;
2157 Nod23Flag |= NMskOutL;
2158 Nod23Flag |= NMskEdge;
2159 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2160 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2161 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2162 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2163 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2164 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2165 List.Prepend(HLRAlgo_BiPoint
2166 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2167 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2168 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2169 List.Prepend(HLRAlgo_BiPoint
2170 (XTI3,YTI3,ZTI3,XTI2,YTI2,ZTI2,
2171 X3 ,Y3 ,Z3 ,X2 ,Y2 ,Z2 , e,
2172 i1 ,i1p3,i1p2,i2 ,i2p3,i2p2,flag));
2173 }
2174 else // p1 p2
2175 List.Prepend(HLRAlgo_BiPoint
2176 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2177 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2178 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2179}
2180
2181//=======================================================================
2182//function : MoveOrInsertPoint
2183//purpose :
2184//=======================================================================
2185
2186void
2187HLRBRep_PolyAlgo::
2188MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List,
2189 Standard_Real& X1,
2190 Standard_Real& Y1,
2191 Standard_Real& Z1,
2192 Standard_Real& X2,
2193 Standard_Real& Y2,
2194 Standard_Real& Z2,
2195 Standard_Real& XTI1,
2196 Standard_Real& YTI1,
2197 Standard_Real& ZTI1,
2198 Standard_Real& XTI2,
2199 Standard_Real& YTI2,
2200 Standard_Real& ZTI2,
2201 const Standard_Integer e,
2202 Standard_Real& U1,
2203 Standard_Real& U2,
2204 Standard_Address& Nod11Indices,
2205 Standard_Address& Nod11RValues,
2206 Standard_Address& Nod12Indices,
2207 Standard_Address& Nod12RValues,
2208 const Standard_Integer i1p1,
2209 const Standard_Integer i1p2,
2210 const Standard_Integer i1,
2211 const Handle(HLRAlgo_PolyInternalData)& pid1,
2212 Standard_Address& TData1,
2213 Standard_Address& PISeg1,
2214 Standard_Address& PINod1,
2215 Standard_Address& Nod21Indices,
2216 Standard_Address& Nod21RValues,
2217 Standard_Address& Nod22Indices,
2218 Standard_Address& Nod22RValues,
2219 const Standard_Integer i2p1,
2220 const Standard_Integer i2p2,
2221 const Standard_Integer i2,
2222 const Handle(HLRAlgo_PolyInternalData)& pid2,
2223 Standard_Address& TData2,
2224 Standard_Address& PISeg2,
2225 Standard_Address& PINod2,
2226 const Standard_Real X3,
2227 const Standard_Real Y3,
2228 const Standard_Real Z3,
2229 const Standard_Real XTI3,
2230 const Standard_Real YTI3,
2231 const Standard_Real ZTI3,
2232 const Standard_Real coef3,
2233 const Standard_Real U3,
2234 const Standard_Boolean insP3,
2235 const Standard_Boolean mP3P1,
2236 const Standard_Real X4,
2237 const Standard_Real Y4,
2238 const Standard_Real Z4,
2239 const Standard_Real XTI4,
2240 const Standard_Real YTI4,
2241 const Standard_Real ZTI4,
2242 const Standard_Real coef4,
2243 const Standard_Real U4,
2244 const Standard_Boolean insP4,
2245 const Standard_Boolean mP4P1,
2246 const Standard_Boolean flag) const
2247{
2248 Standard_Boolean ins3 = insP3;
2249 Standard_Boolean ins4 = insP4;
2250 if (ins3 && mP3P1) { // P1 ---> P3
2251 if (!(Nod11Flag & NMskVert) && coef3 < myTolSta) {
2252 ins3 = Standard_False;
2253 ChangeNode(i1p1,i1p2,
2254 Nod11Indices,Nod11RValues,
2255 Nod12Indices,Nod12RValues,
2256 coef3,X3,Y3,Z3,Standard_True,
2257 TData1,PISeg1,PINod1);
2258 ChangeNode(i2p1,i2p2,
2259 Nod21Indices,Nod21RValues,
2260 Nod22Indices,Nod22RValues,
2261 coef3,X3,Y3,Z3,Standard_True,
2262 TData2,PISeg2,PINod2);
2263 X1 = X3;
2264 Y1 = Y3;
2265 Z1 = Z3;
2266 XTI1 = XTI3;
2267 YTI1 = YTI3;
2268 ZTI1 = ZTI3;
2269 U1 = U3;
2270 Nod11PntX = X3;
2271 Nod11PntY = Y3;
2272 Nod11PntZ = Z3;
2273 if (Nod11Edg1 == (Standard_Boolean) e) Nod11PCu1 = U3;
2274 else if (Nod11Edg2 == (Standard_Boolean) e) Nod11PCu2 = U3;
2275#ifdef DEB
2276 else {
2277 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2278 cout << "Parameter error on Node " << i1p1 << endl;
2279 }
2280#endif
2281 Nod11Scal = 0;
2282 Nod11Flag |= NMskOutL;
2283 UpdateAroundNode(i1p1,Nod11Indices,TData1,PISeg1,PINod1);
2284 Nod21PntX = X3;
2285 Nod21PntY = Y3;
2286 Nod21PntZ = Z3;
2287 if (Nod21Edg1 == (Standard_Boolean) e) Nod21PCu1 = U3;
2288 else if (Nod21Edg2 == (Standard_Boolean) e) Nod21PCu2 = U3;
2289#ifdef DEB
2290 else {
2291 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2292 cout << "Parameter error on Node " << i2p1 << endl;
2293 }
2294#endif
2295 Nod21Scal = 0;
2296 Nod21Flag |= NMskOutL;
2297 UpdateAroundNode(i2p1,Nod21Indices,TData2,PISeg2,PINod2);
2298 Standard_Address Coordinates = List.First().Coordinates();
2299 PntX2 = X3;
2300 PntY2 = Y3;
2301 PntZ2 = Z3;
2302 PntXTI2 = XTI3;
2303 PntYTI2 = YTI3;
2304 PntZTI2 = ZTI3;
2305 }
2306 }
2307 if (ins4 && !mP4P1) { // P2 ---> P4
2308 if (!(Nod12Flag & NMskVert) && coef4 > myTolEnd) {
2309 ins4 = Standard_False;
2310 ChangeNode(i2p1,i2p2,
2311 Nod21Indices,Nod21RValues,
2312 Nod22Indices,Nod22RValues,
2313 coef4,X4,Y4,Z4,Standard_False,
2314 TData2,PISeg2,PINod2);
2315 ChangeNode(i1p1,i1p2,
2316 Nod11Indices,Nod11RValues,
2317 Nod12Indices,Nod12RValues,
2318 coef4,X4,Y4,Z4,Standard_False,
2319 TData1,PISeg1,PINod1);
2320 X2 = X4;
2321 Y2 = Y4;
2322 Z2 = Z4;
2323 XTI2 = XTI4;
2324 YTI2 = YTI4;
2325 ZTI2 = ZTI4;
2326 U2 = U4;
2327 Nod12PntX = X4;
2328 Nod12PntY = Y4;
2329 Nod12PntZ = Z4;
2330 if (Nod12Edg1 == (Standard_Boolean) e) Nod12PCu1 = U4;
2331 else if (Nod12Edg2 == (Standard_Boolean) e) Nod12PCu2 = U4;
2332#ifdef DEB
2333 else {
2334 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2335 cout << "Parameter error on Node " << i1p2 << endl;
2336 }
2337#endif
2338 Nod12Scal = 0;
2339 Nod12Flag |= NMskOutL;
2340 UpdateAroundNode(i1p2,Nod12Indices,TData1,PISeg1,PINod1);
2341 Nod22PntX = X4;
2342 Nod22PntY = Y4;
2343 Nod22PntZ = Z4;
2344 if (Nod22Edg1 == (Standard_Boolean) e) Nod22PCu1 = U4;
2345 else if (Nod22Edg2 == (Standard_Boolean) e) Nod22PCu2 = U4;
2346#ifdef DEB
2347 else {
2348 cout << " HLRBRep_PolyAlgo::MoveOrInsertPoint : ";
2349 cout << "Parameter error on Node " << i2p2 << endl;
2350 }
2351#endif
2352 Nod22Scal = 0;
2353 Nod22Flag |= NMskOutL;
2354 UpdateAroundNode(i2p2,Nod22Indices,TData2,PISeg2,PINod2);
2355 }
2356 }
2357 if (ins3 || ins4) {
2358 if (!ins4) // p1 i1p3 p2
2359 MoveOrInsertPoint(List,
2360 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2361 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2362 e,U1,U2,
2363 Nod11Indices,Nod11RValues,
2364 Nod12Indices,Nod12RValues,
2365 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2366 Nod21Indices,Nod21RValues,
2367 Nod22Indices,Nod22RValues,
2368 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2369 X3,Y3,Z3,XTI3,YTI3,ZTI3,coef3,U3,insP3,mP3P1,flag);
2370 else if (!ins3) // p1 i2p4 p2
2371 MoveOrInsertPoint(List,
2372 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
2373 XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2374 e,U1,U2,
2375 Nod21Indices,Nod21RValues,
2376 Nod22Indices,Nod22RValues,
2377 i2p1,i2p2,i2,pid2,TData2,PISeg2,PINod2,
2378 Nod11Indices,Nod11RValues,
2379 Nod12Indices,Nod12RValues,
2380 i1p1,i1p2,i1,pid1,TData1,PISeg1,PINod1,
2381 X4,Y4,Z4,XTI4,YTI4,ZTI4,coef4,U4,insP4,mP4P1,flag);
2382 else { // p1 i1p3 i2p4 p2
2383 Standard_Integer i1p3 = pid1->AddNode
2384 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef3,X3,Y3,Z3);
2385 Standard_Integer i2p3 = pid2->AddNode
2386 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef3,X3,Y3,Z3);
2387 Standard_Integer i1p4 = pid1->AddNode
2388 (Nod11RValues,Nod12RValues,PINod1,PINod2,coef4,X4,Y4,Z4);
2389 Standard_Integer i2p4 = pid2->AddNode
2390 (Nod21RValues,Nod22RValues,PINod2,PINod1,coef4,X4,Y4,Z4);
2391 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2392 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p3));
2393 const Standard_Address Nod13Indices = (*pi1p3)->Indices();
2394 const Standard_Address Nod13RValues = (*pi1p3)->RValues();
2395 const Handle(HLRAlgo_PolyInternalNode)* pi1p4 =
2396 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(i1p4));
2397 const Standard_Address Nod14Indices = (*pi1p4)->Indices();
2398 const Standard_Address Nod14RValues = (*pi1p4)->RValues();
2399 const Handle(HLRAlgo_PolyInternalNode)* pi2p3 =
2400 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p3));
2401 const Standard_Address Nod23Indices = (*pi2p3)->Indices();
2402 const Standard_Address Nod23RValues = (*pi2p3)->RValues();
2403 const Handle(HLRAlgo_PolyInternalNode)* pi2p4 =
2404 &(((HLRAlgo_Array1OfPINod*)PINod2)->ChangeValue(i2p4));
2405 const Standard_Address Nod24Indices = (*pi2p4)->Indices();
2406 const Standard_Address Nod24RValues = (*pi2p4)->RValues();
2407 Nod13Edg1 = e;
2408 Nod13PCu1 = U3;
2409 Nod13Scal = 0;
2410 Nod13Flag |= NMskOutL;
2411 Nod13Flag |= NMskEdge;
2412 Nod23Edg1 = e;
2413 Nod23PCu1 = U3;
2414 Nod23Scal = 0;
2415 Nod23Flag |= NMskOutL;
2416 Nod23Flag |= NMskEdge;
2417 Nod14Edg1 = e;
2418 Nod14PCu1 = U4;
2419 Nod14Scal = 0;
2420 Nod14Flag |= NMskOutL;
2421 Nod14Flag |= NMskEdge;
2422 Nod24Edg1 = e;
2423 Nod24PCu1 = U4;
2424 Nod24Scal = 0;
2425 Nod24Flag |= NMskOutL;
2426 Nod24Flag |= NMskEdge;
2427 pid1->UpdateLinks(i1p1,i1p2,i1p3,
2428 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2429 pid2->UpdateLinks(i2p1,i2p2,i2p3,
2430 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2431 pid2->UpdateLinks(i2p3,i2p2,i2p4,
2432 TData2,TData1,PISeg2,PISeg1,PINod2,PINod1);
2433 pid1->UpdateLinks(i1p3,i1p2,i1p4,
2434 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2435 UpdateAroundNode(i1p3,Nod13Indices,TData1,PISeg1,PINod1);
2436 UpdateAroundNode(i2p3,Nod23Indices,TData2,PISeg2,PINod2);
2437 UpdateAroundNode(i1p4,Nod14Indices,TData1,PISeg1,PINod1);
2438 UpdateAroundNode(i2p4,Nod24Indices,TData2,PISeg2,PINod2);
2439 List.Prepend(HLRAlgo_BiPoint
2440 (XTI1,YTI1,ZTI1,XTI3,YTI3,ZTI3,
2441 X1 ,Y1 ,Z1 ,X3 ,Y3 ,Z3 , e,
2442 i1 ,i1p1,i1p3,i2 ,i2p1,i2p3,flag));
2443 List.Prepend(HLRAlgo_BiPoint
2444 (XTI3,YTI3,ZTI3,XTI4,YTI4,ZTI4,
2445 X3 ,Y3 ,Z3 ,X4 ,Y4 ,Z4 , e,
2446 i1 ,i1p3,i1p4,i2 ,i2p3,i2p4,flag));
2447 List.Prepend(HLRAlgo_BiPoint
2448 (XTI4,YTI4,ZTI4,XTI2,YTI2,ZTI2,
2449 X4 ,Y4 ,Z4 ,X2 ,Y2 ,Z2 , e,
2450 i1 ,i1p4,i1p2,i2 ,i2p4,i2p2,flag));
2451 }
2452 }
2453 else // p1 p2
2454 List.Prepend(HLRAlgo_BiPoint
2455 (XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
2456 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 , e,
2457 i1 ,i1p1,i1p2,i2 ,i2p1,i2p2,flag));
2458}
2459
2460//=======================================================================
2461//function : InsertOnOutLine
2462//purpose :
2463//=======================================================================
2464
2465void
2466HLRBRep_PolyAlgo::InsertOnOutLine (TColStd_Array1OfTransient& PID)
2467{
2468 Standard_Address TData2 = 0;
2469 Standard_Address PISeg2 = 0;
2470 Standard_Address PINod2 = 0;
2471 Standard_Address Seg1Indices;
2472 Standard_Address Nod1Indices,Nod1RValues;
2473 Standard_Address Nod2Indices,Nod2RValues;
2474 Handle(HLRAlgo_PolyInternalData)* pid =
2475 (Handle(HLRAlgo_PolyInternalData)*) (&(PID.ChangeValue(1)));
2476
2477 TopLoc_Location L;
2478 Standard_Boolean insP3,mP3P1,IntOutL;
2479 Standard_Integer f,ip1,ip2,ip3;//, i;
2480 Standard_Real U3,V3,coef3,X3,Y3,Z3;
2481
2482 const gp_Trsf& T = myProj.Transformation();
2483
2484 Standard_Integer nbFace = myFMap.Extent();
2485 for (f = 1; f <= nbFace; f++) {
2486
2487 if (!((*pid).IsNull())) {
2488 IntOutL = Standard_False;
2489 Standard_Address TData1= &((*pid)->TData());
2490 Standard_Address PISeg1= &((*pid)->PISeg());
2491 Standard_Address PINod1= &((*pid)->PINod());
2492 TopoDS_Shape LocalShape = myFMap(f);
2493 const TopoDS_Face& F = TopoDS::Face(LocalShape);
2494 myBSurf.Initialize(F,Standard_False);
2495 myGSurf = BRep_Tool::Surface(F,L);
2496 gp_Trsf TT = L.Transformation();
2497 TT.PreMultiply(T);
2498 const gp_XYZ& ttlo = TT.TranslationPart();
2499 TTLo[0] = ttlo.X();
2500 TTLo[1] = ttlo.Y();
2501 TTLo[2] = ttlo.Z();
2502 const gp_Mat& ttma = TT.VectorialPart();
2503 TTMa[0][0] = ttma.Value(1,1);
2504 TTMa[0][1] = ttma.Value(1,2);
2505 TTMa[0][2] = ttma.Value(1,3);
2506 TTMa[1][0] = ttma.Value(2,1);
2507 TTMa[1][1] = ttma.Value(2,2);
2508 TTMa[1][2] = ttma.Value(2,3);
2509 TTMa[2][0] = ttma.Value(3,1);
2510 TTMa[2][1] = ttma.Value(3,2);
2511 TTMa[2][2] = ttma.Value(3,3);
2512 Standard_Integer iseg,nbT,nbS,nbN;
2513
2514 nbT = (*pid)->NbTData();
2515 nbN = (*pid)->NbPINod();
2516 nbS = (*pid)->NbPISeg();
2517
2518#ifdef DEB
2519 if (DoTrace) {
2520 cout << " InsertOnOutLine : NbTData " << nbT << endl;
2521 cout << " InsertOnOutLine : NbPISeg " << nbS << endl;
2522 cout << " InsertOnOutLine : NbPINod " << nbN << endl;
2523 }
2524#endif
2525
2526 for (iseg = 1; iseg <= nbS; iseg++) {
2527 Seg1Indices =
2528 ((HLRAlgo_Array1OfPISeg*)PISeg1)->ChangeValue(iseg).Indices();
2529// Standard_Boolean Cutted = Standard_False;
2530 if (Seg1Conex1 != 0 && Seg1Conex2 != 0) {
2531 ip1 = Seg1LstSg1;
2532 ip2 = Seg1LstSg2;
2533 const Handle(HLRAlgo_PolyInternalNode)* pip1 =
2534 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip1));
2535 Nod1Indices = (*pip1)->Indices();
2536 Nod1RValues = (*pip1)->RValues();
2537 const Handle(HLRAlgo_PolyInternalNode)* pip2 =
2538 &(((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip2));
2539 Nod2Indices = (*pip2)->Indices();
2540 Nod2RValues = (*pip2)->RValues();
2541 if (Nod1Flag & NMskOutL && Nod2Flag & NMskOutL)
2542 IntOutL = Standard_True;
2543 else if ((Nod1Scal >= myTolAngular &&
2544 Nod2Scal <= -myTolAngular) ||
2545 (Nod2Scal >= myTolAngular &&
2546 Nod1Scal <= -myTolAngular)) {
2547 IntOutL = Standard_True;
2548 insP3 = NewNode(Nod1RValues,Nod2RValues,coef3,mP3P1);
2549 if (insP3) {
2550 UVNode(Nod1RValues,Nod2RValues,coef3,U3,V3);
2551 const gp_Pnt& PT3 = myGSurf->Value(U3,V3);
2552 X3 = PT3.X();
2553 Y3 = PT3.Y();
2554 Z3 = PT3.Z();
2555 TTMultiply(X3,Y3,Z3);
2556 }
2557
2558 if (insP3 && mP3P1) { // P1 ---> P3
2559 if ((Nod1Flag & NMskEdge) == 0 && coef3 < myTolSta) {
2560 insP3 = Standard_False;
2561 ChangeNode(ip1,ip2,
2562 Nod1Indices,Nod1RValues,
2563 Nod2Indices,Nod2RValues,
2564 coef3,X3,Y3,Z3,Standard_True,
2565 TData1,PISeg1,PINod1);
2566 Nod1Scal = 0;
2567 Nod1Flag |= NMskOutL;
2568 }
2569 }
2570 if (insP3 && !mP3P1) { // P2 ---> P3
2571 if ((Nod2Flag & NMskEdge) == 0 && coef3 > myTolEnd) {
2572 insP3 = Standard_False;
2573 ChangeNode(ip1,ip2,
2574 Nod1Indices,Nod1RValues,
2575 Nod2Indices,Nod2RValues,
2576 coef3,X3,Y3,Z3,Standard_False,
2577 TData1,PISeg1,PINod1);
2578 Nod2Scal = 0;
2579 Nod2Flag |= NMskOutL;
2580 }
2581 }
2582 if (insP3) { // p1 ip3 p2
2583 ip3 = (*pid)->AddNode(Nod1RValues,Nod2RValues,PINod1,PINod2,
2584 coef3,X3,Y3,Z3);
2585 const Handle(HLRAlgo_PolyInternalNode)* pip3 =
2586 (&((HLRAlgo_Array1OfPINod*)PINod1)->ChangeValue(ip3));
2587 const Standard_Address Nod3Indices = (*pip3)->Indices();
2588 const Standard_Address Nod3RValues = (*pip3)->RValues();
2589 (*pid)->UpdateLinks(ip1,ip2,ip3,
2590 TData1,TData2,PISeg1,PISeg2,PINod1,PINod2);
2591 UpdateAroundNode(ip3,Nod3Indices,TData1,PISeg1,PINod1);
2592 Nod3Scal = 0;
2593 Nod3Flag |= NMskOutL;
2594 }
2595 }
2596 }
2597 }
2598 if (IntOutL)
2599 (*pid)->IntOutL(Standard_True);
2600
2601 nbT = (*pid)->NbTData();
2602 nbN = (*pid)->NbPINod();
2603 nbS = (*pid)->NbPISeg();
2604
2605#ifdef DEB
2606 if (DoTrace) {
2607 cout << " InsertOnOutLine : NbTData " << nbT << endl;
2608 cout << " InsertOnOutLine : NbPISeg " << nbS << endl;
2609 cout << " InsertOnOutLine : NbPINod " << nbN << endl;
2610 }
2611#endif
2612 }
2613 pid++;
2614 }
2615}
2616
2617//=======================================================================
2618//function : CheckFrBackTriangles
2619//purpose :
2620//=======================================================================
2621
2622void
2623HLRBRep_PolyAlgo::CheckFrBackTriangles (HLRAlgo_ListOfBPoint& List,
2624 TColStd_Array1OfTransient& PID)
2625{
2626 Standard_Integer f,i,nbN,nbT,nbFace;
2627 Standard_Real X1 =0.,Y1 =0.,X2 =0.,Y2 =0.,X3 =0.,Y3 =0.;
2628 Standard_Real D1,D2,D3;
2629 Standard_Real dd,dX,dY,nX,nY;
2630 Standard_Boolean FrBackInList;
2631 Standard_Address TData ,PISeg ,PINod ;
2632#ifndef DEB
2633/* Standard_Address IndexPtr = NULL;
2634 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2635 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2636 Standard_Address TData1 = &pid1->TData(),
2637 PISeg1 = &pid1->PISeg(),
2638 PINod1 = &pid1->PINod();
2639
2640 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2641 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2642 Standard_Address TData2 = &pid2->TData(),
2643 PISeg2 = &pid2->PISeg(),
2644 PINod2 = &pid2->PISeg();*/
2645 Standard_Address TData1 = NULL,PISeg1 = NULL,PINod1 = NULL;
2646 Standard_Address TData2 = NULL,PISeg2 = NULL,PINod2 = NULL;
2647#else
2648 Standard_Address TData1,PISeg1,PINod1;
2649 Standard_Address TData2,PISeg2,PINod2;
2650#endif
2651 Standard_Address Nod11Indices,Nod12Indices,Nod13Indices;
2652 Standard_Address Nod11RValues,Nod12RValues,Nod13RValues;
2653 Standard_Address Tri1Indices;
2654
2655 Handle(HLRAlgo_PolyInternalData)* pid;
2656
2657 nbFace = myFMap.Extent();
2658 Standard_Boolean Modif = Standard_True;
2659 Standard_Integer iLoop = 0;
2660
2661 while (Modif && iLoop < 4) {
2662 iLoop++;
2663 Modif = Standard_False;
2664 FrBackInList = Standard_False;
2665 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2666
2667 for (f = 1; f <= nbFace; f++) {
2668 if (!(*pid).IsNull()) {
2669 nbT = (*pid)->NbTData();
2670 TData = &(*pid)->TData();
2671 PISeg = &(*pid)->PISeg();
2672 PINod = &(*pid)->PINod();
2673 HLRAlgo_TriangleData* tdata =
2674 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
2675
2676 for (i = 1; i <= nbT; i++) {
2677 Tri1Indices = tdata->Indices();
2678 if ((Tri1Flags & FMskSide) == 0 &&
2679 (Tri1Flags & FMskFrBack)) {
2680#ifdef DEB
2681 if (DoTrace)
2682 cout << " face : " << f << " , triangle " << i << endl;
2683#endif
2684 Modif = Standard_True;
2685 const Handle(HLRAlgo_PolyInternalNode)* pi1p1 =
2686 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
2687 Nod11Indices = (*pi1p1)->Indices();
2688 Nod11RValues = (*pi1p1)->RValues();
2689 const Handle(HLRAlgo_PolyInternalNode)* pi1p2 =
2690 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
2691 Nod12Indices = (*pi1p2)->Indices();
2692 Nod12RValues = (*pi1p2)->RValues();
2693 const Handle(HLRAlgo_PolyInternalNode)* pi1p3 =
2694 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
2695 Nod13Indices = (*pi1p3)->Indices();
2696 Nod13RValues = (*pi1p3)->RValues();
2697 D1 = 0.; D2 = 0.; D3 = 0.;
2698 if (((Nod11Flag & NMskEdge) == 0 || iLoop > 1) &&
2699 ((Nod11Flag & NMskOutL) == 0 || iLoop > 1) &&
2700 ((Nod11Flag & NMskVert) == 0)) {
2701 dX = Nod13PntX - Nod12PntX; dY = Nod13PntY - Nod12PntY;
2702 D1 = dX * dX + dY * dY;
2703 D1 = sqrt(D1);
2704 nX = - dY / D1; nY = dX / D1;
2705 dX = Nod11PntX - Nod12PntX; dY = Nod11PntY - Nod12PntY;
2706 dd = - (dX * nX + dY * nY);
2707 if (dd < 0) dd -= D1 * 0.01;
2708 else dd += D1 * 0.01;
2709 X1 = nX * dd; Y1 = nY * dd;
2710 }
2711 if (((Nod12Flag & NMskEdge) == 0 || iLoop > 1) &&
2712 ((Nod12Flag & NMskOutL) == 0 || iLoop > 1) &&
2713 ((Nod12Flag & NMskVert) == 0)) {
2714 dX = Nod11PntX - Nod13PntX; dY = Nod11PntY - Nod13PntY;
2715 D2 = dX * dX + dY * dY;
2716 D2 = sqrt(D2);
2717 nX = - dY / D2; nY = dX / D2;
2718 dX = Nod12PntX - Nod13PntX; dY = Nod12PntY - Nod13PntY;
2719 dd = - (dX * nX + dY * nY);
2720 if (dd < 0) dd -= D2 * 0.01;
2721 else dd += D2 * 0.01;
2722 X2 = nX * dd; Y2 = nY * dd;
2723 }
2724 if (((Nod13Flag & NMskEdge) == 0 || iLoop > 1) &&
2725 ((Nod13Flag & NMskOutL) == 0 || iLoop > 1) &&
2726 ((Nod13Flag & NMskVert) == 0)) {
2727 dX = Nod12PntX - Nod11PntX; dY = Nod12PntY - Nod11PntY;
2728 D3 = dX * dX + dY * dY;
2729 D3 = sqrt(D3);
2730 nX = - dY / D3; nY = dX / D3;
2731 dX = Nod13PntX - Nod11PntX; dY = Nod13PntY - Nod11PntY;
2732 dd = - (dX * nX + dY * nY);
2733 if (dd < 0) dd -= D3 * 0.01;
2734 else dd += D3 * 0.01;
2735 X3 = nX * dd; Y3 = nY * dd;
2736 }
2737 if (D1 > D2 && D1 > D3) {
2738 Nod11PntX += X1; Nod11PntY += Y1;
2739 Nod11Flag |= NMskMove;
2740 UpdateAroundNode(Tri1Node1,Nod11Indices,TData,PISeg,PINod);
2741 FrBackInList = Standard_True;
2742#ifdef DEB
2743 if (DoTrace) {
2744 cout << Tri1Node1 << " modifies : DX,DY ";
2745 cout << X1 << " , " << Y1 << endl;
2746 }
2747#endif
2748 }
2749 else if (D2 > D3 && D2 > D1) {
2750 Nod12PntX += X2; Nod12PntY += Y2;
2751 Nod12Flag |= NMskMove;
2752 UpdateAroundNode(Tri1Node2,Nod12Indices,TData,PISeg,PINod);
2753 FrBackInList = Standard_True;
2754#ifdef DEB
2755 if (DoTrace) {
2756 cout << Tri1Node2 << " modifies : DX,DY ";
2757 cout << X2 << " , " << Y2 << endl;
2758 }
2759#endif
2760 }
2761 else if (D3 > D1 && D3 > D2) {
2762 Nod13PntX += X3; Nod13PntY += Y3;
2763 Nod13Flag |= NMskMove;
2764 UpdateAroundNode(Tri1Node3,Nod13Indices,TData,PISeg,PINod);
2765 FrBackInList = Standard_True;
2766#ifdef DEB
2767 if (DoTrace) {
2768 cout << Tri1Node3 << " modifies : DX,DY ";
2769 cout << X3 << " , " << Y3 << endl;
2770 }
2771#endif
2772 }
2773#ifdef DEB
2774 else if (DoTrace)
2775 cout << "modification error" << endl;
2776#endif
2777 }
2778 tdata++;
2779 }
2780 }
2781 pid++;
2782 }
2783 if (FrBackInList) {
2784 Standard_Address IndexPtr,Coordinates;
2785 HLRAlgo_ListIteratorOfListOfBPoint it;
2786
2787 for (it.Initialize(List); it.More(); it.Next()) {
2788 HLRAlgo_BiPoint& BP = it.Value();
2789 IndexPtr = BP.Indices();
2790 if (F1Index != 0) {
2791 const Handle(HLRAlgo_PolyInternalData)& pid1 =
2792 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
2793 TData1 = &pid1->TData();
2794 PISeg1 = &pid1->PISeg();
2795 PINod1 = &pid1->PINod();
2796 }
2797 if (F2Index != 0) {
2798 if (F1Index == F2Index) {
2799 TData2 = TData1;
2800 PISeg2 = PISeg1;
2801 PINod2 = PINod1;
2802 }
2803 else {
2804 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2805 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2806 TData2 = &pid2->TData();
2807 PISeg2 = &pid2->PISeg();
2808 PINod2 = &pid2->PINod();
2809 }
2810 }
2811 if (F1Index != 0) {
2812 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2813 ChangeValue(F1Pt1Index))->Indices();
2814 if (Nod11Flag & NMskMove) {
2815#ifdef DEB
2816 if (DoTrace)
2817 cout << F1Pt1Index << " modifies 11" << endl;
2818#endif
2819 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2820 ChangeValue(F1Pt1Index))->RValues();
2821 Coordinates = BP.Coordinates();
2822 PntXTI1 = PntX1 = Nod11PntX;
2823 PntYTI1 = PntY1 = Nod11PntY;
2824 PntZTI1 = PntZ1 = Nod11PntZ;
2825 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2826 if (F2Index != 0) {
2827 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2828 ChangeValue(F2Pt1Index))->Indices();
2829 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2830 ChangeValue(F2Pt1Index))->RValues();
2831 Nod12PntX = Nod11PntX;
2832 Nod12PntY = Nod11PntY;
2833 UpdateAroundNode(F2Pt1Index,Nod12Indices,
2834 TData2,PISeg2,PINod2);
2835 }
2836 }
2837 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2838 ChangeValue(F1Pt2Index))->Indices();
2839 if (Nod11Flag & NMskMove) {
2840#ifdef DEB
2841 if (DoTrace)
2842 cout << F1Pt2Index << " modifies 12" << endl;
2843#endif
2844 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2845 ChangeValue(F1Pt2Index))->RValues();
2846 Coordinates = BP.Coordinates();
2847 PntXTI2 = PntX2 = Nod11PntX;
2848 PntYTI2 = PntY2 = Nod11PntY;
2849 PntZTI2 = PntZ2 = Nod11PntZ;
2850 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2851 if (F2Index != 0) {
2852 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2853 ChangeValue(F2Pt2Index))->Indices();
2854 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2855 ChangeValue(F2Pt2Index))->RValues();
2856 Nod12PntX = Nod11PntX;
2857 Nod12PntY = Nod11PntY;
2858 UpdateAroundNode(F2Pt2Index,Nod12Indices,
2859 TData2,PISeg2,PINod2);
2860 }
2861 }
2862 }
2863 if (F2Index != 0) {
2864 const Handle(HLRAlgo_PolyInternalData)& pid2 =
2865 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
2866 PINod2 = &pid2->PINod();
2867 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2868 ChangeValue(F2Pt1Index))->Indices();
2869 if (Nod11Flag & NMskMove) {
2870#ifdef DEB
2871 if (DoTrace)
2872 cout << F2Pt1Index << " modifies 21" << endl;
2873#endif
2874 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2875 ChangeValue(F2Pt1Index))->RValues();
2876 Coordinates = BP.Coordinates();
2877 PntXTI1 = PntX1 = Nod11PntX;
2878 PntYTI1 = PntY1 = Nod11PntY;
2879 PntZTI1 = PntZ1 = Nod11PntZ;
2880 TIMultiply(PntXTI1,PntYTI1,PntZTI1);
2881 if (F1Index != 0) {
2882 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2883 ChangeValue(F1Pt1Index))->Indices();
2884 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2885 ChangeValue(F1Pt1Index))->RValues();
2886 Nod12PntX = Nod11PntX;
2887 Nod12PntY = Nod11PntY;
2888 UpdateAroundNode(F1Pt1Index,Nod12Indices,
2889 TData1,PISeg1,PINod1);
2890 }
2891 }
2892 Nod11Indices = (((HLRAlgo_Array1OfPINod*)PINod2)->
2893 ChangeValue(F2Pt2Index))->Indices();
2894 if (Nod11Flag & NMskMove) {
2895#ifdef DEB
2896 if (DoTrace)
2897 cout << F2Pt2Index << " modifies 22" << endl;
2898#endif
2899 Nod11RValues = (((HLRAlgo_Array1OfPINod*)PINod2)->
2900 ChangeValue(F2Pt2Index))->RValues();
2901 Coordinates = BP.Coordinates();
2902 PntXTI2 = PntX2 = Nod11PntX;
2903 PntYTI2 = PntY2 = Nod11PntY;
2904 PntZTI2 = PntZ2 = Nod11PntZ;
2905 TIMultiply(PntXTI2,PntYTI2,PntZTI2);
2906 if (F1Index != 0) {
2907 Nod12Indices = (((HLRAlgo_Array1OfPINod*)PINod1)->
2908 ChangeValue(F1Pt2Index))->Indices();
2909 Nod12RValues = (((HLRAlgo_Array1OfPINod*)PINod1)->
2910 ChangeValue(F1Pt2Index))->RValues();
2911 Nod12PntX = Nod11PntX;
2912 Nod12PntY = Nod11PntY;
2913 UpdateAroundNode(F1Pt2Index,Nod12Indices,
2914 TData1,PISeg1,PINod1);
2915 }
2916 }
2917 }
2918 }
2919 pid = (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
2920
2921 for (f = 1; f <= nbFace; f++) {
2922 if (!(*pid).IsNull()) {
2923 nbN = (*pid)->NbPINod();
2924 PINod = &(*pid)->PINod();
2925 Handle(HLRAlgo_PolyInternalNode)* NN =
2926 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
2927
2928 for (i = 1; i <= nbN; i++) {
2929 Nod11Indices = (*NN)->Indices();
2930 Nod11Flag &= ~NMskMove;
2931 NN++;
2932 }
2933 }
2934 pid++;
2935 }
2936 }
2937 }
2938}
2939
2940//=======================================================================
2941//function : FindEdgeOnTriangle
2942//purpose :
2943//=======================================================================
2944
2945void
2946HLRBRep_PolyAlgo::
2947FindEdgeOnTriangle (const Standard_Address Tri1Indices,
2948 const Standard_Integer ip1,
2949 const Standard_Integer ip2,
2950 Standard_Integer& jtrouv,
2951 Standard_Boolean& isDirect) const
2952{
2953 Standard_Integer n1 = Tri1Node1;
2954 Standard_Integer n2 = Tri1Node2;
2955 Standard_Integer n3 = Tri1Node3;
2956 if (ip1 == n1 && ip2 == n2) {
2957 jtrouv = 0;
2958 isDirect = Standard_True;
2959 return;
2960 }
2961 else if (ip2 == n1 && ip1 == n2) {
2962 jtrouv = 0;
2963 isDirect = Standard_False;
2964 return;
2965 }
2966 else if (ip1 == n2 && ip2 == n3) {
2967 jtrouv = 1;
2968 isDirect = Standard_True;
2969 return;
2970 }
2971 else if (ip2 == n2 && ip1 == n3) {
2972 jtrouv = 1;
2973 isDirect = Standard_False;
2974 return;
2975 }
2976 else if (ip1 == n3 && ip2 == n1) {
2977 jtrouv = 2;
2978 isDirect = Standard_True;
2979 return;
2980 }
2981 else if (ip2 == n3 && ip1 == n1) {
2982 jtrouv = 2;
2983 isDirect = Standard_False;
2984 return;
2985 }
2986}
2987
2988//=======================================================================
2989//function : ChangeNode
2990//purpose :
2991//=======================================================================
2992
2993void HLRBRep_PolyAlgo::ChangeNode (const Standard_Integer ip1,
2994 const Standard_Integer ip2,
2995 const Standard_Address Nod1Indices,
2996 const Standard_Address Nod1RValues,
2997 const Standard_Address Nod2Indices,
2998 const Standard_Address Nod2RValues,
2999 const Standard_Real coef1,
3000 const Standard_Real X3,
3001 const Standard_Real Y3,
3002 const Standard_Real Z3,
3003 const Standard_Boolean first,
3004 Standard_Address& TData,
3005 Standard_Address& PISeg,
3006 Standard_Address& PINod) const
3007{
3008 Standard_Real coef2 = 1 - coef1;
3009 if (first) {
3010 Nod1PntX = X3;
3011 Nod1PntY = Y3;
3012 Nod1PntZ = Z3;
3013 Nod1PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3014 Nod1PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3015 Nod1Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3016 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3017 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3018 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3019 Standard_Real D = sqrt (x * x + y * y + z * z);
3020 if (D > 0) {
3021 Nod1NrmX = x / D;
3022 Nod1NrmY = y / D;
3023 Nod1NrmZ = z / D;
3024 }
3025 else {
3026 Nod1NrmX = 1;
3027 Nod1NrmY = 0;
3028 Nod1NrmZ = 0;
3029#ifdef DEB
3030 if (DoError) {
3031 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip1;
3032 cout << " and " << ip2 << endl;
3033 }
3034#endif
3035 }
3036 UpdateAroundNode(ip1,Nod1Indices,TData,PISeg,PINod);
3037 }
3038 else {
3039 Nod2PntX = X3;
3040 Nod2PntY = Y3;
3041 Nod2PntZ = Z3;
3042 Nod2PntU = Nod1PntU * coef2 + Nod2PntU * coef1;
3043 Nod2PntV = Nod1PntV * coef2 + Nod2PntV * coef1;
3044 Nod2Scal = Nod1Scal * coef2 + Nod2Scal * coef1;
3045 Standard_Real x = Nod1NrmX * coef2 + Nod2NrmX * coef1;
3046 Standard_Real y = Nod1NrmY * coef2 + Nod2NrmY * coef1;
3047 Standard_Real z = Nod1NrmZ * coef2 + Nod2NrmZ * coef1;
3048 Standard_Real D = sqrt (x * x + y * y + z * z);
3049 if (D > 0) {
3050 D = 1 / D;
3051 Nod2NrmX = x * D;
3052 Nod2NrmY = y * D;
3053 Nod2NrmZ = z * D;
3054 }
3055 else {
3056 Nod2NrmX = 1;
3057 Nod2NrmY = 0;
3058 Nod2NrmZ = 0;
3059#ifdef DEB
3060 if (DoError) {
3061 cout << "HLRBRep_PolyAlgo::ChangeNode between " << ip2;
3062 cout << " and " << ip1 << endl;
3063 }
3064#endif
3065 }
3066 UpdateAroundNode(ip2,Nod2Indices,TData,PISeg,PINod);
3067 }
3068}
3069
3070//=======================================================================
3071//function : UpdateAroundNode
3072//purpose :
3073//=======================================================================
3074
3075void HLRBRep_PolyAlgo::
3076UpdateAroundNode (const Standard_Integer iNode,
3077 const Standard_Address Nod1Indices,
3078 const Standard_Address TData,
3079 const Standard_Address PISeg,
3080 const Standard_Address PINod) const
3081{
3082 Standard_Integer iiii,iTri1,iTri2;
3083 iiii = Nod1NdSg;
3084
3085 while (iiii != 0) {
3086 const Standard_Address Seg1Indices =
3087 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3088 iTri1 = Seg1Conex1;
3089 iTri2 = Seg1Conex2;
3090 if ( iTri1 != 0) {
3091 const Standard_Address Tri1Indices =
3092 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri1).Indices();
3093 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3094 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node1));
3095 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3096 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node2));
3097 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3098 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri1Node3));
3099 const Standard_Address Nod1Indices = (*PN1)->Indices();
3100 const Standard_Address Nod2Indices = (*PN2)->Indices();
3101 const Standard_Address Nod3Indices = (*PN3)->Indices();
3102 const Standard_Address Nod1RValues = (*PN1)->RValues();
3103 const Standard_Address Nod2RValues = (*PN2)->RValues();
3104 const Standard_Address Nod3RValues = (*PN3)->RValues();
3105 OrientTriangle(iTri1,Tri1Indices,
3106 Nod1Indices,Nod1RValues,
3107 Nod2Indices,Nod2RValues,
3108 Nod3Indices,Nod3RValues);
3109 }
3110 if ( iTri2 != 0) {
3111 const Standard_Address Tri2Indices =
3112 ((HLRAlgo_Array1OfTData*)TData)->ChangeValue(iTri2).Indices();
3113 const Handle(HLRAlgo_PolyInternalNode)* PN1 =
3114 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node1));
3115 const Handle(HLRAlgo_PolyInternalNode)* PN2 =
3116 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node2));
3117 const Handle(HLRAlgo_PolyInternalNode)* PN3 =
3118 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(Tri2Node3));
3119 const Standard_Address Nod1Indices = (*PN1)->Indices();
3120 const Standard_Address Nod2Indices = (*PN2)->Indices();
3121 const Standard_Address Nod3Indices = (*PN3)->Indices();
3122 const Standard_Address Nod1RValues = (*PN1)->RValues();
3123 const Standard_Address Nod2RValues = (*PN2)->RValues();
3124 const Standard_Address Nod3RValues = (*PN3)->RValues();
3125 OrientTriangle(iTri2,Tri2Indices,
3126 Nod1Indices,Nod1RValues,
3127 Nod2Indices,Nod2RValues,
3128 Nod3Indices,Nod3RValues);
3129 }
3130 if (Seg1LstSg1 == iNode) iiii = Seg1NxtSg1;
3131 else iiii = Seg1NxtSg2;
3132 }
3133}
3134
3135//=======================================================================
3136//function : OrientTriangle
3137//purpose :
3138//=======================================================================
3139
3140void
3141HLRBRep_PolyAlgo::OrientTriangle(const Standard_Integer iTri,
3142 const Standard_Address Tri1Indices,
3143 const Standard_Address Nod1Indices,
3144 const Standard_Address Nod1RValues,
3145 const Standard_Address Nod2Indices,
3146 const Standard_Address Nod2RValues,
3147 const Standard_Address Nod3Indices,
3148 const Standard_Address Nod3RValues) const
3149{
3150 Standard_Boolean o1 = Nod1Flag & NMskOutL;
3151 Standard_Boolean o2 = Nod2Flag & NMskOutL;
3152 Standard_Boolean o3 = Nod3Flag & NMskOutL;
3153 Tri1Flags &= ~FMskFlat;
3154 Tri1Flags &= ~FMskOnOutL;
3155 if (o1 && o2 && o3) {
3156 Tri1Flags |= FMskSide;
3157 Tri1Flags &= ~FMskBack;
3158 Tri1Flags |= FMskOnOutL;
3159#ifdef DEB
3160 if (DoTrace) {
3161 cout << "HLRBRep_PolyAlgo::OrientTriangle : OnOutL";
3162 cout << " triangle " << iTri << endl;
3163 }
3164#endif
3165 }
3166 else {
3167 Standard_Real s1 = Nod1Scal;
3168 Standard_Real s2 = Nod2Scal;
3169 Standard_Real s3 = Nod3Scal;
3170 Standard_Real as1 = s1;
3171 Standard_Real as2 = s2;
3172 Standard_Real as3 = s3;
3173 if (s1 < 0) as1 = -s1;
3174 if (s2 < 0) as2 = -s2;
3175 if (s3 < 0) as3 = -s3;
3176 Standard_Real s = 0;
3177 Standard_Real as = 0;
3178 if (!o1 ) {s = s1; as = as1;}
3179 if (!o2 && as < as2) {s = s2; as = as2;}
3180 if (!o3 && as < as3) {s = s3; as = as3;}
3181 if (s > 0) {
3182 Tri1Flags &= ~FMskSide;
3183 Tri1Flags |= FMskBack;
3184 }
3185 else {
3186 Tri1Flags &= ~FMskSide;
3187 Tri1Flags &= ~FMskBack;
3188 }
3189 Standard_Real dx12 = Nod2PntX - Nod1PntX;
3190 Standard_Real dy12 = Nod2PntY - Nod1PntY;
3191 Standard_Real dz12 = Nod2PntZ - Nod1PntZ;
3192 Standard_Real d12 = sqrt(dx12 * dx12 + dy12 * dy12 + dz12 * dz12);
3193 if (d12 <= 1.e-10) {
3194#ifdef DEB
3195 if (DoTrace) {
3196 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3197 cout << " triangle " << iTri << endl;
3198 }
3199#endif
3200 Tri1Flags |= FMskFlat;
3201 Tri1Flags |= FMskSide;
3202 Tri1Flags &= ~FMskBack;
3203 }
3204 else {
3205 Standard_Real dx23 = Nod3PntX - Nod2PntX;
3206 Standard_Real dy23 = Nod3PntY - Nod2PntY;
3207 Standard_Real dz23 = Nod3PntZ - Nod2PntZ;
3208 Standard_Real d23 = sqrt(dx23 * dx23 + dy23 * dy23 + dz23 * dz23);
3209 if (d23 < 1.e-10) {
3210#ifdef DEB
3211 if (DoTrace) {
3212 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3213 cout << " triangle " << iTri << endl;
3214 }
3215#endif
3216 Tri1Flags |= FMskFlat;
3217 Tri1Flags |= FMskSide;
3218 Tri1Flags &= ~FMskBack;
3219 }
3220 else {
3221 Standard_Real dx31 = Nod1PntX - Nod3PntX;
3222 Standard_Real dy31 = Nod1PntY - Nod3PntY;
3223 Standard_Real dz31 = Nod1PntZ - Nod3PntZ;
3224 Standard_Real d31 = sqrt(dx31 * dx31 + dy31 * dy31 + dz31 * dz31);
3225 if (d31 < 1.e-10) {
3226#ifdef DEB
3227 if (DoTrace) {
3228 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3229 cout << " triangle " << iTri << endl;
3230 }
3231#endif
3232 Tri1Flags |= FMskFlat;
3233 Tri1Flags |= FMskSide;
3234 Tri1Flags &= ~FMskBack;
3235 }
3236 else {
3237 dx12 /= d12;
3238 dy12 /= d12;
3239 dz12 /= d12;
3240 dx23 /= d23;
3241 dy23 /= d23;
3242 dz23 /= d23;
3243 Standard_Real dx = dy12 * dz23 - dz12 * dy23;
3244 Standard_Real dy = dz12 * dx23 - dx12 * dz23;
3245 Standard_Real dz = dx12 * dy23 - dy12 * dx23;
3246 Standard_Real d = sqrt(dx * dx + dy * dy + dz * dz);
3247 if (d < 1.e-5) {
3248#ifdef DEB
3249 if (DoTrace) {
3250 cout << "HLRBRep_PolyAlgo::OrientTriangle : Flat";
3251 cout << " triangle " << iTri << endl;
3252 }
3253#endif
3254 Tri1Flags |= FMskFlat;
3255 Tri1Flags |= FMskSide;
3256 Tri1Flags &= ~FMskBack;
3257 }
3258 else {
3259 Standard_Real o;
3260 if (myProj.Perspective()) {
3261 dx /= d;
3262 dy /= d;
3263 dz /= d;
3264 o = ( dz * myProj.Focus()
3265 - dx * Nod1PntX
3266 - dy * Nod1PntY
3267 - dz * Nod1PntZ);
3268 }
3269 else
3270 o = dz / d;
3271 if (o < 0) {
3272 Tri1Flags |= FMskOrBack;
3273 o = -o;
3274 }
3275 else
3276 Tri1Flags &= ~FMskOrBack;
3277 if (o < 1.e-10) {
3278 Tri1Flags |= FMskSide;
3279 Tri1Flags &= ~FMskBack;
3280 }
3281 }
3282 }
3283 }
3284 }
3285 }
3286 if ((!(Tri1Flags & FMskBack) && (Tri1Flags & FMskOrBack)) ||
3287 ( (Tri1Flags & FMskBack) && !(Tri1Flags & FMskOrBack)))
3288 Tri1Flags |= FMskFrBack;
3289 else
3290 Tri1Flags &= ~FMskFrBack;
3291}
3292
3293//=======================================================================
3294//function : Triangles
3295//purpose :
3296//=======================================================================
3297
3298Standard_Boolean
3299HLRBRep_PolyAlgo::Triangles(const Standard_Integer ip1,
3300 const Standard_Integer ip2,
3301 const Standard_Address Nod1Indices,
3302 Standard_Address& PISeg,
3303 Standard_Integer& iTri1,
3304 Standard_Integer& iTri2) const
3305{
3306 Standard_Address Seg1Indices;
3307 Standard_Integer iiii = Nod1NdSg;
3308
3309 while (iiii != 0) {
3310 Seg1Indices =
3311 ((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(iiii).Indices();
3312 if (Seg1LstSg1 == ip1) {
3313 if (Seg1LstSg2 == ip2) {
3314 iTri1 = Seg1Conex1;
3315 iTri2 = Seg1Conex2;
3316 return Standard_True;
3317 }
3318 else iiii = Seg1NxtSg1;
3319 }
3320 else {
3321 if (Seg1LstSg1 == ip2) {
3322 iTri1 = Seg1Conex1;
3323 iTri2 = Seg1Conex2;
3324 return Standard_True;
3325 }
3326 else iiii = Seg1NxtSg2;
3327 }
3328 }
3329 iTri1 = 0;
3330 iTri2 = 0;
3331#ifdef DEB
3332 if (DoError) {
3333 cout << "HLRBRep_PolyAlgo::Triangles : error";
3334 cout << " between " << ip1 << " and " << ip2 << endl;
3335 }
3336#endif
3337 return Standard_False;
3338}
3339
3340//=======================================================================
3341//function : NewNode
3342//purpose :
3343//=======================================================================
3344
3345Standard_Boolean
3346HLRBRep_PolyAlgo::
3347NewNode (const Standard_Address Nod1RValues,
3348 const Standard_Address Nod2RValues,
3349 Standard_Real& coef1,
3350 Standard_Boolean& moveP1) const
3351{
3352 Standard_Real TolAng = myTolAngular * 0.5;
3353 if ((Nod1Scal >= TolAng && Nod2Scal <= -TolAng) ||
3354 (Nod2Scal >= TolAng && Nod1Scal <= -TolAng)) {
3355 coef1 = Nod1Scal / ( Nod2Scal - Nod1Scal );
3356 if (coef1 < 0) coef1 = - coef1;
3357 moveP1 = coef1 < 0.5;
3358 return Standard_True;
3359 }
3360 return Standard_False;
3361}
3362
3363//=======================================================================
3364//function : UVNode
3365//purpose :
3366//=======================================================================
3367
3368void
3369HLRBRep_PolyAlgo::UVNode (const Standard_Address Nod1RValues,
3370 const Standard_Address Nod2RValues,
3371 const Standard_Real coef1,
3372 Standard_Real& U3,
3373 Standard_Real& V3) const
3374{
3375 Standard_Real coef2 = 1 - coef1;
3376 U3 = Nod1PntU * coef2 + Nod2PntU * coef1;
3377 V3 = Nod1PntV * coef2 + Nod2PntV * coef1;
3378}
3379
3380//=======================================================================
3381//function : CheckDegeneratedSegment
3382//purpose :
3383//=======================================================================
3384
3385void
3386HLRBRep_PolyAlgo::
3387CheckDegeneratedSegment(const Standard_Address Nod1Indices,
3388 const Standard_Address Nod1RValues,
3389 const Standard_Address Nod2Indices,
3390 const Standard_Address Nod2RValues) const
3391{
3392 Nod1Flag |= NMskFuck;
3393 Nod2Flag |= NMskFuck;
3394 if ((Nod1Scal >= myTolAngular && Nod2Scal <= -myTolAngular) ||
3395 (Nod2Scal >= myTolAngular && Nod1Scal <= -myTolAngular)) {
3396 Nod1Scal = 0.;
3397 Nod1Flag |= NMskOutL;
3398 Nod2Scal = 0.;
3399 Nod2Flag |= NMskOutL;
3400 }
3401}
3402
3403//=======================================================================
3404//function : UpdateOutLines
3405//purpose :
3406//=======================================================================
3407
3408void
3409HLRBRep_PolyAlgo::UpdateOutLines (HLRAlgo_ListOfBPoint& List,
3410 TColStd_Array1OfTransient& PID)
3411{
3412 Standard_Integer f;
3413 Standard_Integer nbFace = myFMap.Extent();
3414 Standard_Real X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ;
3415 Standard_Real XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2;
3416
3417 Handle(HLRAlgo_PolyInternalData)* pid =
3418 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3419
3420 for (f = 1; f <= nbFace; f++) {
3421 if (!(*pid).IsNull()) {
3422 if ((*pid)->IntOutL()) {
3423 Standard_Address TData = &((*pid)->TData());
3424 Standard_Address PISeg = &((*pid)->PISeg());
3425 Standard_Address PINod = &((*pid)->PINod());
3426 Standard_Integer i,j,it1,it2,tn1,tn2,tn3,pd,pf;
3427 Standard_Address Seg2Indices,Tri1Indices,Tri2Indices;
3428 Standard_Boolean outl;
3429 Standard_Integer nbS = (*pid)->NbPISeg();
3430 HLRAlgo_PolyInternalSegment* psg =
3431 &(((HLRAlgo_Array1OfPISeg*)PISeg)->ChangeValue(1));
3432
3433 for (i = 1; i <= nbS; i++) {
3434 Seg2Indices = psg->Indices();
3435 it1 = Seg2Conex1;
3436 it2 = Seg2Conex2;
3437 if (it1 != 0 && it2 != 0 && it1 != it2) { // debile but sure !
3438 Tri1Indices = ((HLRAlgo_Array1OfTData*)TData)->
3439 ChangeValue(it1).Indices();
3440 Tri2Indices = ((HLRAlgo_Array1OfTData*)TData)->
3441 ChangeValue(it2).Indices();
3442 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3443 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3444 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3445 outl = Standard_False;
3446 else if ( Tri1Flags & FMskSide)
3447 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3448 else
3449 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3450
3451 if (outl) {
3452 pd = Seg2LstSg1;
3453 pf = Seg2LstSg2;
3454 tn1 = Tri1Node1;
3455 tn2 = Tri1Node2;
3456 tn3 = Tri1Node3;
3457 if (!(Tri1Flags & FMskSide) && (Tri1Flags & FMskOrBack)) {
3458 j = tn1;
3459 tn1 = tn3;
3460 tn3 = j;
3461 }
3462 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3463 Tri1Flags |= EMskOutLin1;
3464 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3465 Tri1Flags |= EMskOutLin2;
3466 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3467 Tri1Flags |= EMskOutLin3;
3468#ifdef DEB
3469 else if (DoError) {
3470 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3471 cout << " : segment not found" << endl;
3472 }
3473#endif
3474 tn1 = Tri2Node1;
3475 tn2 = Tri2Node2;
3476 tn3 = Tri2Node3;
3477 if (!(Tri2Flags & FMskSide) && (Tri2Flags & FMskOrBack)) {
3478 j = tn1;
3479 tn1 = tn3;
3480 tn3 = j;
3481 }
3482 if ((tn1 == pd && tn2 == pf) || (tn1 == pf && tn2 == pd))
3483 Tri2Flags |= EMskOutLin1;
3484 else if ((tn2 == pd && tn3 == pf) || (tn2 == pf && tn3 == pd))
3485 Tri2Flags |= EMskOutLin2;
3486 else if ((tn3 == pd && tn1 == pf) || (tn3 == pf && tn1 == pd))
3487 Tri2Flags |= EMskOutLin3;
3488#ifdef DEB
3489 else if (DoError) {
3490 cout << "HLRAlgo_PolyInternalData::UpdateOutLines";
3491 cout << " : segment not found" << endl;
3492 }
3493#endif
3494 Standard_Address Nod1RValues =
3495 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pd)->RValues();
3496 Standard_Address Nod2RValues =
3497 ((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(pf)->RValues();
3498 XTI1 = X1 = Nod1PntX;
3499 YTI1 = Y1 = Nod1PntY;
3500 ZTI1 = Z1 = Nod1PntZ;
3501 XTI2 = X2 = Nod2PntX;
3502 YTI2 = Y2 = Nod2PntY;
3503 ZTI2 = Z2 = Nod2PntZ;
3504 TIMultiply(XTI1,YTI1,ZTI1);
3505 TIMultiply(XTI2,YTI2,ZTI2);
3506 List.Append(HLRAlgo_BiPoint(XTI1,YTI1,ZTI1,XTI2,YTI2,ZTI2,
3507 X1 ,Y1 ,Z1 ,X2 ,Y2 ,Z2 ,
3508 f,f,pd,pf,f,pd,pf,12));
3509 }
3510 }
3511 psg++;
3512 }
3513 }
3514 }
3515 pid++;
3516 }
3517}
3518
3519//=======================================================================
3520//function : UpdateEdgesBiPoints
3521//purpose :
3522//=======================================================================
3523
3524void HLRBRep_PolyAlgo::
3525UpdateEdgesBiPoints (HLRAlgo_ListOfBPoint& List,
3526 const TColStd_Array1OfTransient& PID,
3527 const Standard_Boolean closed)
3528{
3529 Standard_Integer itri1,itri2,tbid;
3530 Standard_Boolean OK;
3531 HLRAlgo_ListIteratorOfListOfBPoint it;
3532
3533 for (it.Initialize(List); it.More(); it.Next()) {
3534 HLRAlgo_BiPoint& BP = it.Value();
3535// Standard_Integer i[5];
3536 Standard_Address IndexPtr = BP.Indices();
3537 if (F1Index != 0 && F2Index != 0) {
3538 const Handle(HLRAlgo_PolyInternalData)& pid1 =
3539 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F1Index));
3540 const Handle(HLRAlgo_PolyInternalData)& pid2 =
3541 *(Handle(HLRAlgo_PolyInternalData)*)&(PID(F2Index));
3542 Standard_Address PISeg1 = &pid1->PISeg();
3543 Standard_Address PISeg2 = &pid2->PISeg();
3544 Standard_Address Nod11Indices =
3545 pid1->PINod().ChangeValue(F1Pt1Index)->Indices();
3546 Standard_Address Nod21Indices =
3547 pid2->PINod().ChangeValue(F2Pt1Index)->Indices();
3548 OK = Triangles(F1Pt1Index,F1Pt2Index,Nod11Indices,PISeg1,itri1,tbid);
3549 OK = Triangles(F2Pt1Index,F2Pt2Index,Nod21Indices,PISeg2,itri2,tbid);
3550
3551 if (itri1 != 0 && itri2 != 0) {
3552 if (F1Index != F2Index || itri1 != itri2) {
3553 Standard_Address TData1 = &pid1->TData();
3554 Standard_Address TData2 = &pid2->TData();
3555 Standard_Address Tri1Indices =
3556 ((HLRAlgo_Array1OfTData*)TData1)->ChangeValue(itri1).Indices();
3557 Standard_Address Tri2Indices =
3558 ((HLRAlgo_Array1OfTData*)TData2)->ChangeValue(itri2).Indices();
3559 if (closed) {
3560 if (((Tri1Flags & FMskBack) && (Tri2Flags & FMskBack)) ||
3561 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskSide)) ||
3562 ((Tri1Flags & FMskBack) && (Tri2Flags & FMskSide)) ||
3563 ((Tri1Flags & FMskSide) && (Tri2Flags & FMskBack)))
3564 BP.Hidden(Standard_True);
3565 }
3566 Standard_Boolean outl;
3567 if (!(Tri1Flags & FMskSide) && !(Tri2Flags & FMskSide))
3568 outl = (Tri1Flags & FMskBack) != (Tri2Flags & FMskBack);
3569 else if ( (Tri1Flags & FMskSide) && (Tri2Flags & FMskSide))
3570 outl = Standard_False;
3571 else if ( (Tri1Flags & FMskSide))
3572 outl = !(Tri1Flags & FMskFlat) && !(Tri2Flags & FMskBack);
3573 else
3574 outl = !(Tri2Flags & FMskFlat) && !(Tri1Flags & FMskBack);
3575 BP.OutLine(outl);
3576 }
3577 }
3578#ifdef DEB
3579 else if (DoError) {
3580 cout << "HLRBRep_PolyAlgo::UpdateEdgesBiPoints : error ";
3581 cout << " between " << F1Index << setw(6);
3582 cout << " and " << F2Index << endl;
3583 }
3584#endif
3585 }
3586 }
3587}
3588
3589//=======================================================================
3590//function : UpdatePolyData
3591//purpose :
3592//=======================================================================
3593
3594void
3595HLRBRep_PolyAlgo::UpdatePolyData (TColStd_Array1OfTransient& PD,
3596 TColStd_Array1OfTransient& PID,
3597 const Standard_Boolean closed)
3598{
3599 Standard_Integer f,i;//,n[3];
3600 Handle(TColgp_HArray1OfXYZ) HNodes;
3601 Handle(HLRAlgo_HArray1OfTData) HTData;
3602 Handle(HLRAlgo_HArray1OfPHDat) HPHDat;
3603 Standard_Integer nbFace = myFMap.Extent();
3604 Handle(HLRAlgo_PolyInternalData)* pid =
3605 (Handle(HLRAlgo_PolyInternalData)*)&(PID.ChangeValue(1));
3606 Handle(HLRAlgo_PolyData)* pd =
3607 (Handle(HLRAlgo_PolyData)*)&(PD.ChangeValue(1));
3608
3609 for (f = 1; f <= nbFace; f++) {
3610 if (!(*pid).IsNull()) {
3611 Standard_Integer nbN = (*pid)->NbPINod();
3612 Standard_Integer nbT = (*pid)->NbTData();
3613 HNodes = new TColgp_HArray1OfXYZ (1,nbN);
3614 HTData = new HLRAlgo_HArray1OfTData(1,nbT);
3615 TColgp_Array1OfXYZ& Nodes = HNodes->ChangeArray1();
3616 HLRAlgo_Array1OfTData& Trian = HTData->ChangeArray1();
3617 Standard_Address TData = &(*pid)->TData();
3618 Standard_Address PINod = &(*pid)->PINod();
3619 Standard_Integer nbHide = 0;
3620 Handle(HLRAlgo_PolyInternalNode)* ON =
3621 &(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
3622 gp_XYZ * NN = &(Nodes.ChangeValue(1));
3623
3624 for (i = 1; i <= nbN; i++) {
3625 const Standard_Address Nod1RValues = (*ON)->RValues();
3626 NN->SetCoord(Nod1PntX,Nod1PntY,Nod1PntZ);
3627 ON++;
3628 NN++;
3629 }
3630
3631 HLRAlgo_TriangleData* OT =
3632 &(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
3633 HLRAlgo_TriangleData* NT = &(Trian.ChangeValue(1));
3634 Standard_Address Tri1Indices,Tri2Indices;
3635
3636 for (i = 1; i <= nbT; i++) {
3637 Tri1Indices = OT->Indices();
3638 Tri2Indices = NT->Indices();
3639 if (!(Tri1Flags & FMskSide)) {
3640#ifdef DEB
3641 if ((Tri1Flags & FMskFrBack) && DoTrace) {
3642 cout << "HLRBRep_PolyAlgo::ReverseBackTriangle :";
3643 cout << " face " << f << setw(6);
3644 cout << " triangle " << i << endl;
3645 }
3646#endif
3647 if (Tri1Flags & FMskOrBack) {
3648 Standard_Integer j = Tri1Node1;
3649 Tri1Node1 = Tri1Node3;
3650 Tri1Node3 = j;
3651 Tri1Flags |= FMskBack;
3652 }
3653 else
3fc57801 3654 Tri1Flags &= ~FMskBack;
3655 //Tri1Flags |= FMskBack;//OCC349
7fd59977 3656 }
3657 Tri2Node1 = Tri1Node1;
3658 Tri2Node2 = Tri1Node2;
3659 Tri2Node3 = Tri1Node3;
3660 Tri2Flags = Tri1Flags;
3661 if (!(Tri2Flags & FMskSide) &&
3662 (!(Tri2Flags & FMskBack) || !closed)) {
3663 Tri2Flags |= FMskHiding;
3664 nbHide++;
3665 }
3666 else
3667 Tri2Flags &= ~FMskHiding;
3668 OT++;
3669 NT++;
3670 }
3671 if (nbHide > 0) HPHDat = new HLRAlgo_HArray1OfPHDat(1,nbHide);
3672 else HPHDat.Nullify();
3673 (*pd)->HNodes(HNodes);
3674 (*pd)->HTData(HTData);
3675 (*pd)->HPHDat(HPHDat);
3676 (*pd)->FaceIndex(f);
3677 }
3678 pid++;
3679 pd++;
3680 }
3681}
3682
3683//=======================================================================
3684//function : TMultiply
3685//purpose :
3686//=======================================================================
3687
3688void
3689HLRBRep_PolyAlgo::TMultiply (Standard_Real& X,
3690 Standard_Real& Y,
3691 Standard_Real& Z,
3692 const Standard_Boolean VPO) const
3693{
3694 Standard_Real Xt = TMat[0][0]*X + TMat[0][1]*Y + TMat[0][2]*Z + (VPO ? 0 : TLoc[0]);//OCC349
3695 Standard_Real Yt = TMat[1][0]*X + TMat[1][1]*Y + TMat[1][2]*Z + (VPO ? 0 : TLoc[1]);//OCC349
3696 Z = TMat[2][0]*X + TMat[2][1]*Y + TMat[2][2]*Z + (VPO ? 0 : TLoc[2]);//OCC349
3697 X = Xt;
3698 Y = Yt;
3699}
3700
3701//=======================================================================
3702//function : TTMultiply
3703//purpose :
3704//=======================================================================
3705
3706void
3707HLRBRep_PolyAlgo::TTMultiply (Standard_Real& X,
3708 Standard_Real& Y,
3709 Standard_Real& Z,
3710 const Standard_Boolean VPO) const
3711{
3712 Standard_Real Xt = TTMa[0][0]*X + TTMa[0][1]*Y + TTMa[0][2]*Z + (VPO ? 0 : TTLo[0]);//OCC349
3713 Standard_Real Yt = TTMa[1][0]*X + TTMa[1][1]*Y + TTMa[1][2]*Z + (VPO ? 0 : TTLo[1]);//OCC349
3714 Z = TTMa[2][0]*X + TTMa[2][1]*Y + TTMa[2][2]*Z + (VPO ? 0 : TTLo[2]);//OCC349
3715 X = Xt;
3716 Y = Yt;
3717}
3718
3719//=======================================================================
3720//function : TIMultiply
3721//purpose :
3722//=======================================================================
3723
3724void
3725HLRBRep_PolyAlgo::TIMultiply (Standard_Real& X,
3726 Standard_Real& Y,
3727 Standard_Real& Z,
3728 const Standard_Boolean VPO) const
3729{
3730 Standard_Real Xt = TIMa[0][0]*X + TIMa[0][1]*Y + TIMa[0][2]*Z + (VPO ? 0 : TILo[0]);//OCC349
3731 Standard_Real Yt = TIMa[1][0]*X + TIMa[1][1]*Y + TIMa[1][2]*Z + (VPO ? 0 : TILo[1]);//OCC349
3732 Z = TIMa[2][0]*X + TIMa[2][1]*Y + TIMa[2][2]*Z + (VPO ? 0 : TILo[2]);//OCC349
3733 X = Xt;
3734 Y = Yt;
3735}
3736
3737//=======================================================================
3738//function : Hide
3739//purpose :
3740//=======================================================================
3741
3742void HLRBRep_PolyAlgo::Hide (Standard_Address& Coordinates,
3743 HLRAlgo_EdgeStatus& status,
3744 TopoDS_Shape& S,
3745 Standard_Boolean& reg1,
3746 Standard_Boolean& regn,
3747 Standard_Boolean& outl,
3748 Standard_Boolean& intl)
3749{
3750 Standard_Integer index;
3751 myAlgo->Hide(Coordinates,status,index,reg1,regn,outl,intl);
3752 if (intl) S = myFMap(index);
3753 else S = myEMap(index);
3754}
3755
3756//=======================================================================
3757//function : Show
3758//purpose :
3759//=======================================================================
3760
3761void HLRBRep_PolyAlgo::Show (Standard_Address& Coordinates,
3762 TopoDS_Shape& S,
3763 Standard_Boolean& reg1,
3764 Standard_Boolean& regn,
3765 Standard_Boolean& outl,
3766 Standard_Boolean& intl)
3767{
3768 Standard_Integer index;
3769 myAlgo->Show(Coordinates,index,reg1,regn,outl,intl);
3770 if (intl) S = myFMap(index);
3771 else S = myEMap(index);
3772}
3773
3774//=======================================================================
3775//function : OutLinedShape
3776//purpose :
3777//=======================================================================
3778
3779TopoDS_Shape
3780HLRBRep_PolyAlgo::OutLinedShape (const TopoDS_Shape& S) const
3781{
3782 TopoDS_Shape Result;
3783
3784 if (!S.IsNull()) {
3785 BRep_Builder B;
3786 B.MakeCompound(TopoDS::Compound(Result));
3787 B.Add(Result,S);
3788
3789 TopTools_MapOfShape Map;
3790 TopExp_Explorer ex;
3791 for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next())
3792 Map.Add(ex.Current());
3793 for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next())
3794 Map.Add(ex.Current());
3795
3796 Standard_Integer nbFace = myFMap.Extent();
3797 if (nbFace > 0) {
3798 TopTools_Array1OfShape NewF(1,nbFace);
3799 TColStd_Array1OfTransient& Shell = myAlgo->PolyShell();
3800 Standard_Integer nbShell = Shell.Upper();
3801 HLRAlgo_ListIteratorOfListOfBPoint it;
3802
3803 for (Standard_Integer iShell = 1; iShell <= nbShell; iShell++) {
3804 HLRAlgo_ListOfBPoint& List =
3805 (*(Handle(HLRAlgo_PolyShellData)*)&(Shell(iShell)))->Edges();
3806
3807 for (it.Initialize(List); it.More(); it.Next()) {
3808 HLRAlgo_BiPoint& BP = it.Value();
3809 if (BP.IntLine()) {
3810 Standard_Address IndexPtr = BP.Indices();
3811 if (Map.Contains(myFMap(ShapeIndex))) {
3812 Standard_Address Coordinates = BP.Coordinates();
3813 B.Add(Result,BRepLib_MakeEdge
3814 (gp_Pnt(PntXTI1,PntYTI1,PntZTI1),
3815 gp_Pnt(PntXTI2,PntYTI2,PntZTI2)));
3816 }
3817 }
3818 }
3819 }
3820 }
3821 }
3822 return Result;
3823}
3824