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