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