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