b311480e |
1 | // Created on: 1999-11-02 |
2 | // Created by: Peter KURNEV |
3 | // Copyright (c) 1999-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | #include <TopOpeBRepBuild_Tools.ixx> |
22 | |
23 | #include <gp_Pnt2d.hxx> |
24 | #include <gp_Pnt.hxx> |
25 | #include <gp_Vec.hxx> |
26 | #include <gp_Dir.hxx> |
27 | #include <Adaptor3d_CurveOnSurface.hxx> |
28 | #include <Adaptor2d_HCurve2d.hxx> |
29 | |
30 | #include <BRepTools.hxx> |
31 | #include <BRep_Tool.hxx> |
32 | #include <BRepAdaptor_Surface.hxx> |
33 | #include <BRepAdaptor_Curve.hxx> |
34 | |
35 | #include <GeomAdaptor_Surface.hxx> |
36 | #include <GeomAdaptor_Curve.hxx> |
37 | |
38 | #include <Geom_Curve.hxx> |
39 | #include <Geom_TrimmedCurve.hxx> |
40 | #include <Geom_Surface.hxx> |
41 | #include <Geom2d_Curve.hxx> |
42 | #include <GeomProjLib.hxx> |
43 | |
44 | #include <Geom2dAPI_ProjectPointOnCurve.hxx> |
45 | #include <GeomAPI_ProjectPointOnCurve.hxx> |
46 | |
47 | #include <TopOpeBRepTool_2d.hxx> |
48 | |
49 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> |
50 | #include <TopTools_MapIteratorOfMapOfShape.hxx> |
51 | #include <TopTools_MapOfShape.hxx> |
52 | #include <TopTools_IndexedMapOfShape.hxx> |
53 | #include <TopTools_SequenceOfShape.hxx> |
54 | |
55 | #include <TopoDS_Shape.hxx> |
56 | #include <TopoDS_Face.hxx> |
57 | #include <TopoDS_Edge.hxx> |
58 | #include <TopoDS.hxx> |
59 | |
60 | #include <TopOpeBRepDS_DataStructure.hxx> |
61 | #include <TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx> |
62 | #include <TopOpeBRepDS_ShapeWithState.hxx> |
63 | #include <TopOpeBRepDS_DataMapOfShapeState.hxx> |
64 | #include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeState.hxx> |
65 | |
66 | #include <TopOpeBRepTool_CurveTool.hxx> |
67 | #include <TopOpeBRepTool_TOOL.hxx> |
68 | #include <TopLoc_Location.hxx> |
69 | #include <TopExp.hxx> |
70 | #include <TopExp_Explorer.hxx> |
71 | |
72 | #include <TCollection_AsciiString.hxx> |
73 | #include <BRep_Tool.hxx> |
74 | #include <BRepAdaptor_HSurface.hxx> |
75 | #include <GeomAdaptor_HCurve.hxx> |
76 | #include <ProjLib_ProjectedCurve.hxx> |
77 | #include <GeomAbs_CurveType.hxx> |
78 | #include <Geom2d_Line.hxx> |
79 | #include <Geom2d_Circle.hxx> |
80 | #include <Geom2d_Ellipse.hxx> |
81 | #include <Geom2d_Parabola.hxx> |
82 | #include <Geom2d_Hyperbola.hxx> |
83 | #include <Geom2d_TrimmedCurve.hxx> |
84 | #include <BRepTopAdaptor_FClass2d.hxx> |
85 | #include <TopOpeBRepBuild_CorrectFace2d.hxx> |
86 | #include <Precision.hxx> |
87 | #include <stdio.h> |
88 | |
89 | //define parameter division number as 10*e^(-PI) = 0.43213918 |
90 | const Standard_Real PAR_T = 0.43213918; |
91 | |
92 | //======================================================================= |
93 | //function TopOpeBRepBuild_Tools::DumpMapOfShapeWithState |
94 | //purpose : |
95 | //======================================================================= |
96 | void TopOpeBRepBuild_Tools::DumpMapOfShapeWithState(const Standard_Integer iP, |
97 | const TopOpeBRepDS_IndexedDataMapOfShapeWithState& |
98 | aMapOfShapeWithState) |
99 | { |
100 | static Standard_Integer cnt=0; |
101 | TCollection_AsciiString aFName1 ("/DEBUG/TOPOPE/"), postfix; |
102 | |
103 | Standard_CString ShapeType [9] = {"COMPO", "COMPS", "SOLID", "SHELL", "FACE ", "WIRE ", "EDGE ", "VERTX"}; |
104 | Standard_CString ShapeState[4] = {"IN ", "OUT", "ON ", "UNKNOWN"}; |
105 | |
106 | printf("\n\n********************************\n"); |
107 | printf("* *\n"); |
108 | Standard_Integer i, n=aMapOfShapeWithState.Extent(); |
109 | if (!iP) { |
110 | printf("* Object comparing with TOOL *\n"); |
111 | postfix=TCollection_AsciiString("Obj"); |
112 | } |
113 | |
114 | else { |
115 | printf("* Tool comparing with Object *\n"); |
116 | postfix=TCollection_AsciiString("Tool"); |
117 | } |
118 | |
119 | printf("* *\n"); |
120 | printf("********************************\n"); |
121 | printf("*** aMapOfShapeWithState.Extent()=%d\n", n); |
122 | printf(" C O N T E N T S\n"); |
123 | |
124 | TCollection_AsciiString aFName; |
125 | aFName+=aFName1; |
126 | aFName+=postfix; |
127 | |
128 | for (i=1; i<=n; i++) { |
129 | TCollection_AsciiString aI(i), aName;; |
130 | aName+=aFName; aName+=aI; |
131 | |
132 | const TopoDS_Shape& aShape=aMapOfShapeWithState.FindKey(i); |
133 | const TopOpeBRepDS_ShapeWithState& aShapeWithState= |
134 | aMapOfShapeWithState.FindFromIndex(i); |
135 | |
136 | BRepTools::Write (aShape, aName.ToCString()); |
137 | |
138 | TCollection_AsciiString ann; |
139 | ann+=postfix; ann+=aI; |
140 | |
141 | printf("Key: %-8s , " , ann.ToCString()); |
142 | printf("%s, ", ShapeType[aShape.ShapeType()]); |
143 | if (!iP) |
144 | printf("State comp.with Tool=%s\n", ShapeState[aShapeWithState.State()]); |
145 | |
146 | else |
147 | printf("State comp.with Obj =%s\n", ShapeState[aShapeWithState.State()]); |
148 | |
149 | if (aShapeWithState.IsSplitted()) { |
150 | |
151 | const TopTools_ListOfShape& aListOfShape=aShapeWithState.Part(TopAbs_IN); |
152 | TopTools_ListIteratorOfListOfShape anIt(aListOfShape); |
153 | for (;anIt.More(); anIt.Next()) { |
154 | const TopoDS_Shape& aS=anIt.Value(); |
155 | |
156 | TCollection_AsciiString cn(cnt), prefix("_S_"), sn; |
157 | sn+=aFName; sn+=prefix; sn+=cn; |
158 | BRepTools::Write (aS, sn.ToCString()); |
159 | |
160 | TCollection_AsciiString an;//=postfix+prefix+cn; |
161 | an+=postfix; an+=prefix; an+=cn; |
162 | printf(" -> Splitted Part IN : %s\n", an.ToCString()); |
163 | cnt++; |
164 | } |
165 | |
166 | const TopTools_ListOfShape& aListOfShapeOut=aShapeWithState.Part(TopAbs_OUT); |
167 | anIt.Initialize (aListOfShapeOut); |
168 | for (;anIt.More(); anIt.Next()) { |
169 | const TopoDS_Shape& aS=anIt.Value(); |
170 | |
171 | TCollection_AsciiString cn(cnt), prefix("_S_"), sn;//=aFName+prefix+cn; |
172 | sn+=aFName; sn+=prefix; sn+=cn; |
173 | BRepTools::Write (aS, sn.ToCString()); |
174 | |
175 | TCollection_AsciiString an;//=postfix+prefix+cn; |
176 | an+=postfix; an+=prefix; an+=cn; |
177 | printf(" -> Splitted Part OUT: %-s\n", an.ToCString()); |
178 | cnt++; |
179 | } |
180 | |
181 | const TopTools_ListOfShape& aListOfShapeOn=aShapeWithState.Part(TopAbs_ON); |
182 | anIt.Initialize (aListOfShapeOn); |
183 | for (;anIt.More(); anIt.Next()) { |
184 | const TopoDS_Shape& aS=anIt.Value(); |
185 | |
186 | TCollection_AsciiString cn(cnt), prefix("_S_"), sn;//=aFName+prefix+cn; |
187 | sn+=aFName; sn+=prefix; sn+=cn; |
188 | BRepTools::Write (aS, sn.ToCString()); |
189 | |
190 | TCollection_AsciiString an;//=postfix+prefix+cn; |
191 | an+=postfix; an+=prefix; an+=cn; |
192 | printf(" -> Splitted Part ON : %s\n", an.ToCString()); |
193 | cnt++; |
194 | } |
195 | } |
196 | |
197 | } |
198 | cnt=0; |
199 | } |
200 | |
201 | |
202 | //======================================================================= |
203 | //function TopOpeBRepBuild_Tools::FindState |
204 | //purpose : |
205 | //======================================================================= |
206 | void TopOpeBRepBuild_Tools::FindState (const TopoDS_Shape& aSubsh, |
207 | const TopAbs_State aState, |
208 | const TopAbs_ShapeEnum aSubshEnum, |
209 | const TopTools_IndexedDataMapOfShapeListOfShape& aMapSubshAnc, |
210 | TopTools_MapOfShape& aMapProcessedSubsh, |
211 | TopOpeBRepDS_DataMapOfShapeState& aMapSS) |
212 | { |
213 | Standard_Integer i, nSub; |
214 | const TopTools_ListOfShape& aListOfShapes=aMapSubshAnc.FindFromKey(aSubsh); |
215 | TopTools_ListIteratorOfListOfShape anIt(aListOfShapes); |
216 | for (; anIt.More(); anIt.Next()) { |
217 | const TopoDS_Shape& aS=anIt.Value(); |
218 | TopTools_IndexedMapOfShape aSubshMap; |
219 | TopExp::MapShapes (aS, aSubshEnum, aSubshMap); |
220 | nSub=aSubshMap.Extent(); |
221 | for (i=1; i<=nSub; i++) { |
222 | const TopoDS_Shape& aSS=aSubshMap(i); |
223 | if (! aMapProcessedSubsh.Contains(aSS)) { |
224 | aMapProcessedSubsh.Add(aSS); |
225 | aMapSS.Bind (aSS, aState); |
226 | FindState (aSS, aState, aSubshEnum, aMapSubshAnc, aMapProcessedSubsh, aMapSS); |
227 | } |
228 | } |
229 | } |
230 | } |
231 | |
232 | //======================================================================= |
233 | //function TopOpeBRepBuild_Tools::PropagateState |
234 | //purpose : |
235 | //======================================================================= |
236 | void TopOpeBRepBuild_Tools::PropagateState (const TopOpeBRepDS_DataMapOfShapeState& aSplShapesState, |
237 | const TopTools_IndexedMapOfShape& aShapesToRestMap, |
238 | const TopAbs_ShapeEnum aSubshEnum,// Vertex |
239 | const TopAbs_ShapeEnum aShapeEnum,//Edge |
240 | TopOpeBRepTool_ShapeClassifier& aShapeClassifier, |
241 | TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState, |
242 | const TopTools_MapOfShape& anAvoidSubshMap) |
243 | { |
244 | Standard_Integer j, nSub, nRest; |
245 | TopOpeBRepDS_DataMapOfShapeState aMapSS, aMapSS1; |
246 | |
247 | |
248 | TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeState anItSS (aSplShapesState); |
249 | for (; anItSS.More(); anItSS.Next()) { |
250 | const TopoDS_Shape& aShape= anItSS.Key(); |
251 | TopAbs_State aState = anItSS.Value(); |
252 | TopTools_IndexedMapOfShape aSubshapes; |
253 | TopExp::MapShapes (aShape, aSubshEnum, aSubshapes); |
254 | nSub=aSubshapes.Extent(); |
255 | for (j=1; j<=nSub; j++) |
256 | if (!anAvoidSubshMap.Contains(aSubshapes(j))) // MSV: enforce subshapes avoidance |
257 | aMapSS.Bind (aSubshapes(j), aState); |
258 | } |
259 | |
260 | aMapSS1=aMapSS; |
261 | |
262 | // 1. Build the Map of ShapesAndAncestors for ShapesToRest |
263 | TopTools_IndexedDataMapOfShapeListOfShape aMapSubshAnc; |
264 | nRest=aShapesToRestMap.Extent(); |
265 | for (j=1; j<=nRest; j++) |
266 | TopExp::MapShapesAndAncestors(aShapesToRestMap(j), aSubshEnum, aShapeEnum, aMapSubshAnc); |
267 | |
268 | // 2. Make Map Of all subshapes aMapSS |
269 | TopTools_MapOfShape aProcessedSubshapes; |
270 | anItSS.Initialize (aMapSS1); |
271 | for (; anItSS.More(); anItSS.Next()) { |
272 | const TopoDS_Shape& aSubsh = anItSS.Key(); |
273 | TopAbs_State aState = anItSS.Value(); |
274 | if (aMapSubshAnc.Contains (aSubsh)) { |
275 | aProcessedSubshapes.Add (aSubsh); |
276 | FindState (aSubsh, aState, aSubshEnum, aMapSubshAnc, aProcessedSubshapes, aMapSS); |
277 | } |
278 | } |
279 | |
280 | // 3. Propagate the states on ShapesToRestMap |
281 | TopoDS_Shape aNullShape; |
282 | TopTools_MapOfShape aNonPassedShapes; |
283 | nRest=aShapesToRestMap.Extent(); |
284 | for (j=1; j<=nRest; j++) { |
285 | const TopoDS_Shape& aS=aShapesToRestMap.FindKey(j); |
286 | TopTools_IndexedMapOfShape aSubshMap; |
287 | TopExp::MapShapes (aS, aSubshEnum, aSubshMap); |
288 | const TopoDS_Shape& aSubsh=aSubshMap(1); |
289 | if (aMapSS.IsBound(aSubsh)) { |
290 | TopAbs_State aState=aMapSS.Find(aSubsh); |
291 | |
292 | if (aState==TopAbs_ON) { |
293 | aState=aShapeClassifier.StateShapeReference(aS, aNullShape); |
294 | } |
295 | // Add the Rest Shape to aMapOfShapeWithState |
296 | TopOpeBRepDS_ShapeWithState aShapeWithState; |
297 | aShapeWithState.SetState (aState); |
298 | aShapeWithState.SetIsSplitted (Standard_False); |
299 | aMapOfShapeWithState.Add (aS, aShapeWithState); |
300 | } |
301 | |
302 | else { |
303 | aNonPassedShapes.Add(aS); |
304 | } |
305 | } |
306 | |
307 | // 4. Define the states for aNonPassedShapes |
308 | // (for faces themselves and for theirs Wires, Edges): |
309 | if (aNonPassedShapes.Extent()) { |
310 | // Build the Map of ShapesAndAncestors for aNonPassedShapes |
311 | aMapSubshAnc.Clear(); |
312 | TopTools_MapIteratorOfMapOfShape aMapIt; |
313 | aMapIt.Initialize (aNonPassedShapes); |
314 | for (; aMapIt.More(); aMapIt.Next()) |
315 | TopExp::MapShapesAndAncestors (aMapIt.Key(), aSubshEnum, aShapeEnum, aMapSubshAnc); |
316 | |
317 | aMapSS.Clear(); |
318 | aMapIt.Initialize (aNonPassedShapes); |
319 | for (; aMapIt.More(); aMapIt.Next()) { |
320 | // Face |
321 | const TopoDS_Shape& aNonPassedShape=aMapIt.Key(); |
322 | |
323 | if (!aMapSS.IsBound(aNonPassedShape)) { |
324 | TopAbs_State aState = FindStateThroughVertex (aNonPassedShape, aShapeClassifier, |
325 | aMapOfShapeWithState,anAvoidSubshMap); |
326 | aMapSS.Bind (aNonPassedShape, aState); |
327 | |
328 | // First Subshape |
329 | TopTools_IndexedMapOfShape aTmpMap; |
330 | TopExp::MapShapes (aNonPassedShape, aSubshEnum, aTmpMap); |
331 | TopoDS_Shape aFirstSubsh; |
332 | for (j=1; j <= aTmpMap.Extent() && aFirstSubsh.IsNull(); j++) |
333 | if (!anAvoidSubshMap.Contains(aTmpMap(j))) |
334 | aFirstSubsh = aTmpMap(j); |
335 | if (aFirstSubsh.IsNull()) continue; |
336 | aMapSS.Bind (aFirstSubsh, aState); |
337 | |
338 | // Propagation of aState for subshapes |
339 | TopTools_MapOfShape aMapProcessedSubsh; |
340 | if (aSubshEnum==TopAbs_EDGE) |
341 | FindState1 (aFirstSubsh, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS); |
342 | else // if (aSubshEnum==TopAbs_VERTEX) |
343 | FindState2 (aFirstSubsh, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS); |
344 | } |
345 | } |
346 | |
347 | // Fill aShapeWithState |
348 | TopOpeBRepDS_ShapeWithState aShapeWithState; |
349 | aShapeWithState.SetIsSplitted (Standard_False); |
350 | TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeState anII(aMapSS); |
351 | for (; anII.More(); anII.Next()) { |
352 | aShapeWithState.SetState (anII.Value()); |
353 | if (anII.Key().ShapeType() != TopAbs_VERTEX) |
354 | aMapOfShapeWithState.Add (anII.Key(), aShapeWithState); |
355 | } |
356 | } |
357 | } |
358 | |
359 | //======================================================================= |
360 | //function : TopOpeBRepBuild_Tools::FindState2 |
361 | //purpose : |
362 | //======================================================================= |
363 | void TopOpeBRepBuild_Tools::FindState2 (const TopoDS_Shape& aSubsh, |
364 | const TopAbs_State aState, |
365 | const TopTools_IndexedDataMapOfShapeListOfShape& aMapSubshAnc, |
366 | TopTools_MapOfShape& aMapProcessedSubsh, |
367 | TopOpeBRepDS_DataMapOfShapeState& aMapSS) |
368 | { |
369 | Standard_Integer i, nSub; |
370 | const TopTools_ListOfShape& aListOfShapes=aMapSubshAnc.FindFromKey(aSubsh); |
371 | TopTools_ListIteratorOfListOfShape anIt(aListOfShapes); |
372 | for (; anIt.More(); anIt.Next()) { |
373 | //Shape |
374 | const TopoDS_Shape& aShape=anIt.Value(); |
375 | aMapSS.Bind (aShape, aState); |
376 | |
377 | //Subshape |
378 | TopTools_IndexedMapOfShape aSubshMap; |
379 | TopExp::MapShapes (aShape, TopAbs_VERTEX, aSubshMap); |
380 | nSub=aSubshMap.Extent(); |
381 | for (i=1; i<=nSub; i++) { |
382 | const TopoDS_Shape& aSS=aSubshMap(i); |
383 | if (! aMapProcessedSubsh.Contains(aSS)) { |
384 | aMapProcessedSubsh.Add(aSS); |
385 | aMapSS.Bind (aSS, aState); |
386 | FindState2 (aSS, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS); |
387 | } |
388 | } |
389 | } |
390 | } |
391 | |
392 | //======================================================================= |
393 | //function :TopOpeBRepBuild_Tools::FindState1 |
394 | //purpose : |
395 | //======================================================================= |
396 | void TopOpeBRepBuild_Tools::FindState1 (const TopoDS_Shape& aSubsh, |
397 | const TopAbs_State aState, |
398 | const TopTools_IndexedDataMapOfShapeListOfShape& aMapSubshAnc, |
399 | TopTools_MapOfShape& aMapProcessedSubsh, |
400 | TopOpeBRepDS_DataMapOfShapeState& aMapSS) |
401 | { |
402 | Standard_Integer i, nSub, j, nW; |
403 | const TopTools_ListOfShape& aListOfShapes=aMapSubshAnc.FindFromKey(aSubsh); |
404 | TopTools_ListIteratorOfListOfShape anIt(aListOfShapes); |
405 | for (; anIt.More(); anIt.Next()) { |
406 | //Face |
407 | const TopoDS_Shape& aShape=anIt.Value(); |
408 | aMapSS.Bind (aShape, aState); |
409 | //Wire |
410 | TopTools_IndexedMapOfShape aWireMap; |
411 | TopExp::MapShapes (aShape, TopAbs_WIRE, aWireMap); |
412 | nW=aWireMap.Extent(); |
413 | for (j=1; j<=nW; j++) aMapSS.Bind (aWireMap(j), aState); |
414 | //Edge |
415 | TopTools_IndexedMapOfShape aSubshMap; |
416 | TopExp::MapShapes (aShape, TopAbs_EDGE, aSubshMap); |
417 | nSub=aSubshMap.Extent(); |
418 | for (i=1; i<=nSub; i++) { |
419 | const TopoDS_Shape& aSS=aSubshMap(i); |
420 | if (! aMapProcessedSubsh.Contains(aSS)) { |
421 | aMapProcessedSubsh.Add(aSS); |
422 | aMapSS.Bind (aSS, aState); |
423 | FindState1 (aSS, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS); |
424 | } |
425 | } |
426 | } |
427 | } |
428 | |
429 | //======================================================================= |
430 | //function :TopOpeBRepBuild_Tools::FindStateThroughVertex |
431 | //purpose : |
432 | //======================================================================= |
433 | TopAbs_State TopOpeBRepBuild_Tools::FindStateThroughVertex (const TopoDS_Shape& aShape, |
434 | TopOpeBRepTool_ShapeClassifier& aShapeClassifier, |
435 | TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState, |
436 | const TopTools_MapOfShape& anAvoidSubshMap) |
437 | { |
438 | TopTools_IndexedMapOfShape aSubshMap; |
439 | TopExp::MapShapes (aShape, TopAbs_VERTEX, aSubshMap); |
440 | |
441 | TopoDS_Shape aSubsh; |
442 | Standard_Integer i; |
443 | for (i=1; i <= aSubshMap.Extent() && aSubsh.IsNull(); i++) |
444 | if (!anAvoidSubshMap.Contains (aSubshMap(i)) ) |
445 | aSubsh = aSubshMap(i); |
446 | if (aSubsh.IsNull()) { |
447 | // try an edge |
448 | aSubshMap.Clear(); |
449 | TopExp::MapShapes (aShape, TopAbs_EDGE, aSubshMap); |
450 | for (i=1; i <= aSubshMap.Extent() && aSubsh.IsNull(); i++) |
451 | if (!anAvoidSubshMap.Contains (aSubshMap(i)) ) |
452 | aSubsh = aSubshMap(i); |
453 | if (aSubsh.IsNull()) { |
454 | #ifdef DEB |
455 | cout<<"FindStateThroughVertex: warning: all vertices are avoided"<<endl; |
456 | #endif |
457 | return TopAbs_UNKNOWN; // failure |
458 | } |
459 | } |
460 | |
461 | TopoDS_Shape aNullShape; |
462 | TopAbs_State aState=aShapeClassifier.StateShapeReference(aSubsh, aNullShape); |
463 | TopOpeBRepDS_ShapeWithState aShapeWithState; |
464 | aShapeWithState.SetState (aState); |
465 | aShapeWithState.SetIsSplitted (Standard_False); |
466 | aMapOfShapeWithState.Add(aShape, aShapeWithState); |
467 | SpreadStateToChild (aShape, aState, aMapOfShapeWithState); |
468 | return aState; |
469 | |
470 | } |
471 | |
472 | |
473 | //======================================================================= |
474 | //function :TopOpeBRepBuild_Tools::SpreadStateToChild |
475 | //purpose : |
476 | //======================================================================= |
477 | void TopOpeBRepBuild_Tools::SpreadStateToChild (const TopoDS_Shape& aShape, |
478 | const TopAbs_State aState, |
479 | TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState) |
480 | { |
481 | TopTools_IndexedMapOfShape aChildMap; |
482 | TopExp::MapShapes (aShape, TopAbs_FACE, aChildMap); |
483 | TopExp::MapShapes (aShape, TopAbs_WIRE, aChildMap); |
484 | TopExp::MapShapes (aShape, TopAbs_EDGE, aChildMap); |
485 | |
486 | TopOpeBRepDS_ShapeWithState aShapeWithState; |
487 | aShapeWithState.SetState (aState); |
488 | aShapeWithState.SetIsSplitted (Standard_False); |
489 | |
490 | Standard_Integer i, n=aChildMap.Extent(); |
491 | for (i=1; i<=n; i++) { |
492 | aMapOfShapeWithState.Add(aChildMap(i), aShapeWithState); |
493 | } |
494 | } |
495 | |
496 | //======================================================================= |
497 | //function :TopOpeBRepBuild_Tools::PropagateStateForWires |
498 | //purpose : |
499 | //======================================================================= |
500 | void TopOpeBRepBuild_Tools::PropagateStateForWires(const TopTools_IndexedMapOfShape& aFacesToRestMap, |
501 | TopOpeBRepDS_IndexedDataMapOfShapeWithState& |
502 | aMapOfShapeWithState) |
503 | { |
504 | Standard_Integer i, j, nF, nW, k, nE; |
505 | |
506 | nF=aFacesToRestMap.Extent(); |
507 | for (i=1; i<=nF; i++) { |
508 | const TopoDS_Shape& aF=aFacesToRestMap(i); |
509 | if (aMapOfShapeWithState.Contains (aF)) { |
510 | const TopOpeBRepDS_ShapeWithState& aSWS=aMapOfShapeWithState.FindFromKey(aF); |
511 | TopAbs_State aSt=aSWS.State(); |
512 | |
513 | TopTools_IndexedMapOfShape aWireMap; |
514 | TopExp::MapShapes (aF, TopAbs_WIRE, aWireMap); |
515 | nW=aWireMap.Extent(); |
516 | for (j=1; j<=nW; j++) { |
517 | const TopoDS_Shape& aW=aWireMap(j); |
518 | TopOpeBRepDS_ShapeWithState aWireSWS; |
519 | aWireSWS.SetState(aSt); |
520 | aWireSWS.SetIsSplitted (Standard_False); |
521 | aMapOfShapeWithState.Add(aW, aWireSWS); |
522 | |
523 | TopTools_IndexedMapOfShape aEdgeMap; |
524 | TopExp::MapShapes (aW, TopAbs_EDGE, aEdgeMap); |
525 | nE=aEdgeMap.Extent(); |
526 | for (k=1; k<=nE; k++) { |
527 | const TopoDS_Shape& aE=aEdgeMap(k); |
528 | if (!aMapOfShapeWithState.Contains (aE)) { |
529 | TopOpeBRepDS_ShapeWithState anEdgeSWS; |
530 | anEdgeSWS.SetState(aSt); |
531 | anEdgeSWS.SetIsSplitted (Standard_False); |
532 | aMapOfShapeWithState.Add(aE, anEdgeSWS); |
533 | } |
534 | } |
535 | } |
536 | } |
537 | } |
538 | } |
539 | |
540 | //======================================================================= |
541 | //function :TopOpeBRepBuild_Tools:: GetNormalToFaceOnEdge |
542 | //purpose : |
543 | //======================================================================= |
544 | void TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge (const TopoDS_Face& aFObj, |
545 | const TopoDS_Edge& anEdgeObj, |
546 | gp_Vec& aNormal) |
547 | { |
548 | TopoDS_Edge aEd=anEdgeObj; |
549 | TopoDS_Face aFS=aFObj; |
550 | Standard_Real tolE = 0., f2 = 0., l2 = 0., tolpc = 0., tol = 0., f = 0., l = 0., par = 0.; |
551 | tolE=BRep_Tool::Tolerance(aEd); |
552 | Handle(Geom2d_Curve) C2D=FC2D_CurveOnSurface(aEd,aFS,f2,l2,tolpc, Standard_True); |
553 | tol = Max(tolE,tolpc); |
554 | |
555 | BRepAdaptor_Curve aCA(aEd); |
556 | f=aCA.FirstParameter(); |
557 | l=aCA.LastParameter(); |
558 | par= f*PAR_T + (1 - PAR_T)*l; |
559 | |
560 | gp_Pnt2d aUV1 ; |
561 | C2D -> D0(par, aUV1); |
562 | |
563 | gp_Pnt aP; |
564 | gp_Vec aTg1, aTg2; |
565 | BRepAdaptor_Surface aSA1(aFS); |
566 | aSA1.D1(aUV1.X(), aUV1.Y(), aP, aTg1, aTg2); |
567 | aNormal = aTg1^aTg2; |
568 | } |
569 | |
570 | //======================================================================= |
571 | //function : TopOpeBRepBuild_Tools::GetNormalInNearestPoint |
572 | //purpose : |
573 | //======================================================================= |
574 | void TopOpeBRepBuild_Tools::GetNormalInNearestPoint(const TopoDS_Face& F, |
575 | const TopoDS_Edge& E, |
576 | gp_Vec& aNormal) |
577 | { |
578 | Standard_Real f2 = 0., l2 = 0., tolpc = 0., par = 0.; |
579 | |
580 | gp_Vec2d aTangent; |
581 | |
582 | Handle(Geom2d_Curve) C2D = FC2D_CurveOnSurface(E, F, f2, l2, tolpc, Standard_True); |
583 | |
584 | |
585 | par = f2*PAR_T + (1 - PAR_T)*l2; |
586 | |
587 | gp_Pnt2d aP; |
588 | C2D -> D1(par, aP, aTangent); |
589 | |
590 | Standard_Real Xnorm = -aTangent.Y(); |
591 | Standard_Real Ynorm = aTangent.X(); |
592 | |
593 | Standard_Real step = TopOpeBRepTool_TOOL::minDUV(F); step *= 1e-2; |
594 | |
595 | gp_Vec2d aPV(aP.X(), aP.Y()); |
596 | gp_Dir2d aStepV(Xnorm, Ynorm); |
597 | gp_Vec2d aNorm2d = aPV + gp_Vec2d(step*aStepV); |
598 | |
599 | Standard_Real newU = aNorm2d.X(); |
600 | Standard_Real newV = aNorm2d.Y(); |
601 | gp_Vec aTg1, aTg2; |
602 | gp_Pnt aP1; |
603 | |
604 | BRepAdaptor_Surface BS(F); |
605 | BS.D1(newU, newV, aP1, aTg1, aTg2); |
606 | |
607 | |
608 | gp_Pnt2d aP2d(newU, newV); |
609 | BRepTopAdaptor_FClass2d FC(F, Precision::PConfusion()); |
610 | TopAbs_State aState = FC.Perform(aP2d); |
611 | |
612 | //point out of face: try to go at another direction |
613 | if(aState == TopAbs_OUT) { |
614 | aStepV.Reverse(); |
615 | aNorm2d = aPV + gp_Vec2d(step*aStepV); |
616 | |
617 | newU = aNorm2d.X(); |
618 | newV = aNorm2d.Y(); |
619 | |
620 | BS.D1(newU, newV, aP1, aTg1, aTg2); |
621 | |
622 | //in principle, we must check again |
623 | // aP2d.SetX(newU); aP2d.SetY(newV); |
624 | // BRepClass_FaceClassifier FC(Fex, aP2d, 1e-7); |
625 | // TopAbs_State aState = FC.State(); |
626 | } |
627 | |
628 | aNormal = aTg1^aTg2; |
629 | } |
630 | |
631 | |
632 | //======================================================================= |
633 | //function : TopOpeBRepBuild_Tools::GetTangentToEdgeEdge |
634 | //purpose : |
635 | //======================================================================= |
636 | Standard_Boolean TopOpeBRepBuild_Tools::GetTangentToEdgeEdge (const TopoDS_Face& ,//aFObj, |
637 | const TopoDS_Edge& anEdgeObj, |
638 | const TopoDS_Edge& aOriEObj, |
639 | gp_Vec& aTangent) |
640 | { |
641 | |
642 | if (BRep_Tool::Degenerated(aOriEObj) || |
643 | BRep_Tool::Degenerated(anEdgeObj)) { |
644 | return TopOpeBRepBuild_Tools::GetTangentToEdge (anEdgeObj, aTangent) ; |
645 | } |
646 | |
647 | TopoDS_Edge aEd=anEdgeObj, aEOri = aOriEObj; |
648 | |
649 | Standard_Real f = 0., l = 0., par = 0., parOri = 0.; |
650 | |
651 | BRepAdaptor_Curve aCA(aEd); |
652 | BRepAdaptor_Curve aCAOri(aEOri); |
653 | |
654 | f=aCA.FirstParameter(); |
655 | l=aCA.LastParameter(); |
656 | |
657 | par= f*PAR_T + (1 - PAR_T)*l; |
658 | |
659 | gp_Pnt aP; |
660 | gp_Vec aTgPiece; |
661 | aCA.D1(par, aP, aTgPiece); |
662 | aTangent = aTgPiece; |
663 | |
664 | gp_Pnt aPOri; |
665 | gp_Vec aTgOri; |
666 | ///// |
667 | Handle (Geom_Curve) GCOri=aCAOri.Curve().Curve(); |
668 | Handle (Geom_Curve) aCopyCurve = Handle(Geom_Curve)::DownCast(GCOri -> Copy()); |
669 | |
670 | const TopLoc_Location& aLoc = aEOri.Location(); |
671 | gp_Trsf aTrsf = aLoc.Transformation(); |
672 | aCopyCurve -> Transform(aTrsf); |
673 | |
674 | GeomAPI_ProjectPointOnCurve aPP(aP, aCopyCurve, aCopyCurve->FirstParameter(), aCopyCurve->LastParameter()); |
675 | #ifdef DEB |
676 | // gp_Pnt aNP = aPP.NearestPoint(); |
677 | #endif |
678 | parOri = aPP.LowerDistanceParameter(); |
679 | |
680 | aCopyCurve -> D1(parOri, aPOri, aTgOri);// aPOri must be equal aNP ! |
681 | //printf(" aNP ={%lf, %lf, %lf}\n", aNP.X(), aNP.Y(), aNP.Z()); |
682 | //printf(" aPOri={%lf, %lf, %lf}\n", aPOri.X(), aPOri.Y(), aPOri.Z()); |
683 | if (aEd.Orientation() == TopAbs_REVERSED) |
684 | aTangent.Reverse(); |
685 | |
686 | if(aTgOri*aTgPiece < 0.) { |
687 | aTangent.Reverse(); |
688 | return Standard_True; |
689 | } |
690 | return Standard_False; |
691 | } |
692 | |
693 | |
694 | //======================================================================= |
695 | //function : TopOpeBRepBuild_Tools::GetTangentToEdge |
696 | //purpose : |
697 | //======================================================================= |
698 | Standard_Boolean TopOpeBRepBuild_Tools::GetTangentToEdge (const TopoDS_Edge& anEdgeObj, |
699 | gp_Vec& aTangent) |
700 | { |
701 | TopoDS_Edge aEd=anEdgeObj; |
702 | |
703 | Standard_Real f = 0., l = 0., par = 0.; |
704 | |
705 | BRepAdaptor_Curve aCA(aEd); |
706 | |
707 | f=aCA.FirstParameter(); |
708 | l=aCA.LastParameter(); |
709 | |
710 | par= f*PAR_T + (1 - PAR_T)*l; |
711 | gp_Pnt aP; |
712 | aCA.D1(par, aP, aTangent); |
713 | |
714 | return Standard_True; |
715 | |
716 | } |
717 | |
718 | //======================================================================= |
719 | //function : TopOpeBRepBuild_Tools::GetAdjacentFace |
720 | //purpose : |
721 | //======================================================================= |
722 | Standard_Boolean TopOpeBRepBuild_Tools::GetAdjacentFace (const TopoDS_Shape& aFaceObj, |
723 | const TopoDS_Shape& anEObj, |
724 | const TopTools_IndexedDataMapOfShapeListOfShape& anEdgeFaceMap, |
725 | TopoDS_Shape& anAdjFaceObj) |
726 | { |
727 | const TopTools_ListOfShape& aListOfAdjFaces=anEdgeFaceMap.FindFromKey(anEObj); |
728 | TopTools_ListIteratorOfListOfShape anIt(aListOfAdjFaces); |
729 | TopoDS_Shape anAdjShape; |
730 | for (; anIt.More(); anIt.Next()) { |
731 | if (anIt.Value()!=aFaceObj) { |
732 | anAdjShape=anIt.Value(); |
733 | break; |
734 | } |
735 | } |
736 | |
737 | if (!anAdjShape.IsNull()) { |
738 | anAdjFaceObj=TopoDS::Face(anAdjShape); |
739 | return Standard_True; |
740 | } |
741 | else { |
742 | return Standard_False; |
743 | } |
744 | } |
745 | |
746 | //======================================================================= |
747 | //function : UpdatePCurves |
748 | //purpose : |
749 | //======================================================================= |
750 | void TopOpeBRepBuild_Tools::UpdatePCurves(const TopoDS_Wire& aWire, |
751 | const TopoDS_Face& fromFace, |
752 | const TopoDS_Face& toFace) |
753 | { |
754 | TopExp_Explorer aExp(aWire, TopAbs_EDGE); |
755 | |
756 | for(; aExp.More(); aExp.Next()) { |
757 | TopoDS_Shape aEdge = aExp.Current(); |
758 | UpdateEdgeOnFace(TopoDS::Edge(aEdge), fromFace, toFace); |
759 | } |
760 | } |
761 | |
762 | //======================================================================= |
763 | //function : UpdateEdgeOnFace |
764 | //purpose : |
765 | //======================================================================= |
766 | void TopOpeBRepBuild_Tools::UpdateEdgeOnFace(const TopoDS_Edge& aEdgeToUpdate, |
767 | const TopoDS_Face& fromFace, |
768 | const TopoDS_Face& toFace) |
769 | { |
770 | BRep_Builder BB; |
771 | |
772 | Standard_Real tolE = BRep_Tool::Tolerance(TopoDS::Edge(aEdgeToUpdate)); |
773 | Standard_Real f2 = 0.,l2 = 0.,tolpc = 0.; |
774 | Handle(Geom2d_Curve) C2D; |
775 | |
776 | if(BRep_Tool::Degenerated(aEdgeToUpdate)) { |
777 | //we can not compute PCurve for Degenerated Edge |
778 | //so we take as it was on old face and after (in CorrectFace2D) |
779 | // we will adjust this PCurve |
780 | C2D = FC2D_CurveOnSurface(aEdgeToUpdate, fromFace, |
781 | f2, l2, tolpc, Standard_True); |
782 | Standard_Real tol = Max(tolE, tolpc); |
783 | Handle(Geom2d_Curve) C2Dn = Handle(Geom2d_Curve)::DownCast(C2D -> Copy()); |
784 | Handle(Geom2d_TrimmedCurve) newC2D = new Geom2d_TrimmedCurve(C2Dn, f2, l2); |
785 | BB.UpdateEdge(aEdgeToUpdate ,newC2D, toFace , tol); |
786 | |
787 | } |
788 | else { //not degenerated edge |
789 | |
790 | if(BRep_Tool::IsClosed(aEdgeToUpdate, fromFace)) { |
791 | UpdateEdgeOnPeriodicalFace(aEdgeToUpdate, fromFace, toFace); |
792 | } |
793 | else { |
794 | C2D = FC2D_CurveOnSurface(aEdgeToUpdate, toFace , f2, l2, tolpc, Standard_True); |
795 | Standard_Real tol = Max(tolE,tolpc); |
796 | BB.UpdateEdge(aEdgeToUpdate ,C2D, toFace , tol); |
797 | } |
798 | } |
799 | } |
800 | |
801 | //======================================================================= |
802 | //function : UpdateEdgeOnPeriodicalFace |
803 | //purpose : |
804 | //======================================================================= |
805 | void TopOpeBRepBuild_Tools::UpdateEdgeOnPeriodicalFace(const TopoDS_Edge& aEdgeToUpdate, |
806 | const TopoDS_Face& fromFace, |
807 | const TopoDS_Face& toFace) |
808 | { |
809 | Standard_Boolean DiffOriented = Standard_False; |
810 | BRep_Builder BB; |
811 | TopoDS_Edge newE = aEdgeToUpdate; //newE.Orientation(TopAbs_FORWARD); |
812 | TopoDS_Face fFace = fromFace; //fFace.Orientation(TopAbs_FORWARD); |
813 | TopoDS_Face tFace = toFace; //tFace.Orientation(TopAbs_FORWARD); |
814 | Standard_Real fc = 0., lc = 0.; |
815 | |
816 | Handle(Geom2d_Curve) cc = BRep_Tool::CurveOnSurface(newE, tFace, fc, lc); |
817 | |
818 | if(!cc.IsNull()) { |
819 | //cout << "Pcurves exist" << endl; |
820 | return; |
821 | } |
822 | |
823 | gp_Vec aN1, aN2; |
824 | TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(fromFace), |
825 | TopoDS::Edge(aEdgeToUpdate), aN1); |
826 | |
827 | |
828 | TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(toFace), |
829 | TopoDS::Edge(aEdgeToUpdate), aN2); |
830 | |
831 | if(aN1*aN2 < 0) |
832 | DiffOriented = Standard_True; |
833 | |
834 | Standard_Real tolE = BRep_Tool::Tolerance(newE); |
835 | Standard_Real f2 = 0., l2 = 0., tolpc = 0., tol = 0.; |
836 | |
837 | //first PCurve |
838 | Handle(Geom2d_Curve) C2D = FC2D_CurveOnSurface(newE, |
839 | tFace, f2, |
840 | l2, tolpc, Standard_True); |
841 | |
842 | tol = Max(tolpc, tolE); |
843 | |
844 | BRepAdaptor_Surface aBAS(fFace); |
845 | gp_Vec2d aTrV; |
846 | |
847 | Standard_Real ff = 0., lf = 0., fr = 0., lr = 0.; |
848 | gp_Pnt2d aUVf, aUVr; |
849 | |
850 | Handle(Geom2d_Curve) oldC2DFor = BRep_Tool::CurveOnSurface(newE, //FC2D_CurveOnSurface(newE, |
851 | fFace, ff, |
852 | lf);//, tolpc, Standard_True); |
853 | newE.Reverse(); |
854 | Handle(Geom2d_Curve) oldC2DRev = BRep_Tool::CurveOnSurface(newE, //FC2D_CurveOnSurface(newE, |
855 | fFace, fr, |
856 | lr);//, tolpc, Standard_True); |
857 | |
858 | oldC2DFor -> D0(ff, aUVf); |
859 | oldC2DRev -> D0(fr, aUVr); |
860 | |
861 | if(!DiffOriented) |
862 | aTrV = gp_Vec2d(aUVf, aUVr); |
863 | else |
864 | aTrV = gp_Vec2d(aUVr, aUVf); |
865 | |
866 | gp_Vec2d aux(gp_Pnt2d(0., 0.), gp_Pnt2d(1., 1.)); |
867 | Standard_Real scalar = aux*aTrV; |
868 | Standard_Boolean dir = (scalar >= 0.) ? Standard_True : Standard_False; |
869 | |
870 | //compute right order of pcurves |
871 | gp_Vec2d aYVec(gp_Pnt2d(0., 0.), gp_Pnt2d(0., 1.)); |
872 | gp_Pnt2d aUVfv, aUVlv; |
873 | C2D -> D0(f2, aUVfv); |
874 | C2D -> D0(l2, aUVlv); |
875 | gp_Vec2d C2DVec(aUVfv, aUVlv); |
876 | |
877 | Standard_Boolean firstOrder = Standard_True; |
878 | scalar = aYVec*C2DVec; |
879 | if(fabs(scalar) <= 1e-10) {// compute along X axe |
880 | gp_Vec2d aXVec(gp_Pnt2d(0., 0.), gp_Pnt2d(1., 0.)); |
881 | scalar = aXVec*C2DVec; |
882 | firstOrder = (scalar >= 0.) ? Standard_True : Standard_False; |
883 | } |
884 | else |
885 | firstOrder = (scalar > 0.) ? Standard_False : Standard_True; |
886 | |
887 | Handle(Geom2d_Curve) aTrC = Handle(Geom2d_Curve)::DownCast(C2D->Copy()); |
888 | aTrC -> Translate(aTrV); |
889 | |
890 | if(dir) { |
891 | if(firstOrder) |
892 | BB.UpdateEdge(aEdgeToUpdate, C2D, aTrC, toFace, tol); |
893 | else |
894 | BB.UpdateEdge(aEdgeToUpdate, aTrC, C2D, toFace, tol); |
895 | } |
896 | else { |
897 | if(!firstOrder) |
898 | BB.UpdateEdge(aEdgeToUpdate, C2D, aTrC, toFace, tol); |
899 | else |
900 | BB.UpdateEdge(aEdgeToUpdate, aTrC, C2D, toFace, tol); |
901 | } |
902 | } |
903 | |
904 | //======================================================================= |
905 | //function : TopOpeBRepBuild_Tools::IsDegEdgesTheSame |
906 | //purpose : |
907 | //======================================================================= |
908 | Standard_Boolean TopOpeBRepBuild_Tools::IsDegEdgesTheSame (const TopoDS_Shape& anE1, |
909 | const TopoDS_Shape& anE2) |
910 | { |
911 | TopTools_IndexedMapOfShape aVMap1, aVMap2; |
912 | TopExp::MapShapes(anE1, TopAbs_VERTEX, aVMap1); |
913 | TopExp::MapShapes(anE2, TopAbs_VERTEX, aVMap2); |
914 | |
915 | if (!aVMap1.Extent() || !aVMap2.Extent()) |
916 | return Standard_False; |
917 | |
918 | if (aVMap1(1).IsSame(aVMap2(1))) |
919 | return Standard_True; |
920 | else |
921 | return Standard_False; |
922 | } |
923 | |
924 | //======================================================================= |
925 | //function : NormalizeFace |
926 | //purpose : remove all INTERNAL and EXTERNAL edges from the face |
927 | //======================================================================= |
928 | void TopOpeBRepBuild_Tools::NormalizeFace(const TopoDS_Shape& oldFace, |
929 | TopoDS_Shape& corrFace) |
930 | { |
931 | Standard_Real tolF1; |
932 | |
933 | TopLoc_Location Loc; |
934 | TopoDS_Face aF1 = TopoDS::Face(oldFace), |
935 | aNewFace; |
936 | |
937 | aF1.Orientation(TopAbs_FORWARD); |
938 | |
939 | Handle(Geom_Surface) Surf = BRep_Tool::Surface(aF1, Loc); |
940 | tolF1 = BRep_Tool::Tolerance(aF1); |
941 | BRep_Builder BB; |
942 | BB.MakeFace(aNewFace, Surf, Loc, tolF1); |
943 | |
944 | TopExp_Explorer aFExp(aF1, TopAbs_WIRE); |
945 | for (; aFExp.More(); aFExp.Next()) { |
946 | Standard_Integer NbGoodEdges = 0; |
947 | TopoDS_Shape aWire=aFExp.Current(); |
948 | aWire.Orientation(TopAbs_FORWARD); |
949 | TopoDS_Wire aNewWire; |
950 | |
951 | BB.MakeWire(aNewWire); |
952 | |
953 | TopExp_Explorer aWExp(aWire, TopAbs_EDGE); |
954 | for (; aWExp.More(); aWExp.Next()) { |
955 | TopoDS_Shape anEdge=aWExp.Current(); |
956 | |
957 | if (anEdge.Orientation()==TopAbs_EXTERNAL || |
958 | anEdge.Orientation()==TopAbs_INTERNAL) |
959 | continue; |
960 | |
961 | BB.Add (aNewWire, TopoDS::Edge(anEdge)); |
962 | NbGoodEdges++; |
963 | } |
964 | //keep wire orientation |
965 | aNewWire.Orientation(aFExp.Current().Orientation());//aWire.Orientation()); |
966 | |
967 | if(NbGoodEdges) //we add new wire only if it contains at least one edge |
968 | BB.Add (aNewFace, aNewWire); |
969 | } |
970 | //keep face orientation |
971 | aNewFace.Orientation(oldFace.Orientation()); |
972 | |
973 | corrFace = aNewFace; |
974 | } |
975 | |
976 | |
977 | //======================================================================= |
978 | //function : CorrectFace2d |
979 | //purpose : adjust PCurves of periodical face in 2d |
980 | //======================================================================= |
981 | void TopOpeBRepBuild_Tools::CorrectFace2d (const TopoDS_Shape& oldFace, |
982 | TopoDS_Shape& corrFace, |
983 | const TopTools_IndexedMapOfOrientedShape& aSourceShapes, |
984 | TopTools_IndexedDataMapOfShapeShape& aMapOfCorrect2dEdges) |
985 | { |
986 | TopOpeBRepBuild_CorrectFace2d aCorrectFace2d(TopoDS::Face(oldFace), |
987 | aSourceShapes, |
988 | aMapOfCorrect2dEdges); |
989 | |
990 | |
991 | aCorrectFace2d.Perform(); |
992 | corrFace=oldFace; |
993 | } |