1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: BlockFix_UnionFaces.cxx
23 // Created: Tue Dec 7 17:15:42 2004
24 // Author: Pavel DURANDIN
26 #include <BlockFix_UnionFaces.ixx>
28 #include <Basics_OCCTVersion.hxx>
30 #include <ShapeAnalysis_WireOrder.hxx>
31 #include <ShapeAnalysis_Edge.hxx>
33 #include <ShapeBuild_Edge.hxx>
34 #include <ShapeBuild_ReShape.hxx>
36 #include <ShapeExtend_WireData.hxx>
37 #include <ShapeExtend_CompositeSurface.hxx>
39 #include <ShapeFix_Face.hxx>
40 #include <ShapeFix_ComposeShell.hxx>
41 #include <ShapeFix_SequenceOfWireSegment.hxx>
42 #include <ShapeFix_WireSegment.hxx>
43 #include <ShapeFix_Wire.hxx>
44 #include <ShapeFix_Edge.hxx>
46 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
47 #include <IntPatch_ImpImpIntersection.hxx>
49 #include <IntPatch_TheIIIntOfIntersection.hxx>
52 #include <BRep_Tool.hxx>
53 #include <BRep_Builder.hxx>
54 #include <BRepTools.hxx>
55 #include <BRepTopAdaptor_TopolTool.hxx>
58 #include <TopExp_Explorer.hxx>
60 #include <TopTools_SequenceOfShape.hxx>
61 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
62 #include <TopTools_ListOfShape.hxx>
63 #include <TopTools_ListIteratorOfListOfShape.hxx>
64 #include <TopTools_MapOfShape.hxx>
65 #include <TopTools_MapIteratorOfMapOfShape.hxx>
68 #include <TopoDS_Edge.hxx>
69 #include <TopoDS_Wire.hxx>
70 #include <TopoDS_Face.hxx>
71 #include <TopoDS_Solid.hxx>
72 #include <TopoDS_Vertex.hxx>
73 #include <TopoDS_Shell.hxx>
74 #include <TopoDS_Iterator.hxx>
76 #include <TColGeom_HArray2OfSurface.hxx>
78 #include <GeomAdaptor_HSurface.hxx>
79 #include <GeomLib_IsPlanarSurface.hxx>
81 #include <Geom_Surface.hxx>
82 #include <Geom_Plane.hxx>
83 #include <Geom_OffsetSurface.hxx>
84 #include <Geom_SphericalSurface.hxx>
85 #include <Geom_CylindricalSurface.hxx>
86 #include <Geom_SurfaceOfRevolution.hxx>
87 #include <Geom_SurfaceOfLinearExtrusion.hxx>
88 #include <Geom_RectangularTrimmedSurface.hxx>
90 #include <Geom_Curve.hxx>
91 #include <Geom_Line.hxx>
92 #include <Geom_Circle.hxx>
94 #include <Geom2d_Line.hxx>
97 #include <gp_Pnt2d.hxx>
99 #include <Standard_Failure.hxx>
100 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
102 //=======================================================================
103 //function : BlockFix_UnionFaces
105 //=======================================================================
107 BlockFix_UnionFaces::BlockFix_UnionFaces()
108 : myTolerance(Precision::Confusion()),
114 //=======================================================================
115 //function : GetTolerance
117 //=======================================================================
119 Standard_Real& BlockFix_UnionFaces::GetTolerance()
125 //=======================================================================
126 //function : GetOptimumNbFaces
128 //=======================================================================
130 Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces()
132 return myOptimumNbFaces;
136 //=======================================================================
137 //function : AddOrdinaryEdges
139 //=======================================================================
140 // adds edges from the shape to the sequence
141 // seams and equal edges are dropped
142 // Returns true if one of original edges dropped
143 static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges,
144 const TopoDS_Shape aShape,
145 Standard_Integer& anIndex)
148 TopTools_MapOfShape aNewEdges;
149 //add edges without seams
150 for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) {
151 TopoDS_Shape edge = exp.Current();
152 if(aNewEdges.Contains(edge))
153 aNewEdges.Remove(edge);
158 Standard_Boolean isDropped = Standard_False;
159 //merge edges and drop seams
160 for(Standard_Integer i = 1; i <= edges.Length(); i++) {
161 TopoDS_Shape current = edges(i);
162 if(aNewEdges.Contains(current)) {
164 aNewEdges.Remove(current);
169 isDropped = Standard_True;
175 //add edges to the sequemce
176 for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next())
177 edges.Append(anIter.Key());
183 //=======================================================================
184 //function : ClearRts
186 //=======================================================================
187 static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
189 if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
190 Handle(Geom_RectangularTrimmedSurface) rts =
191 Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
192 return rts->BasisSurface();
198 //=======================================================================
201 //=======================================================================
203 TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
205 Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape;
206 TopoDS_Shape aResShape = myContext->Apply(Shape);
208 // processing each solid
209 TopExp_Explorer exps;
210 for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) {
211 TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
213 // creating map of edge faces
214 TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
215 TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
217 // map of processed shapes
218 TopTools_MapOfShape aProcessed;
220 Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
222 Standard_Integer NbModif = 0;
223 Standard_Boolean hasFailed = Standard_False;
224 Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
229 TopTools_MapOfShape mapF;
230 for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
231 if (mapF.Add(exp.Current()))
235 bool doUnion = ((myOptimumNbFaces == 0) ||
236 ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces)));
238 // processing each face
240 for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) {
241 TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
243 if (aProcessed.Contains(aFace))
246 Standard_Integer dummy;
247 TopTools_SequenceOfShape edges;
248 AddOrdinaryEdges(edges,aFace,dummy);
250 TopTools_SequenceOfShape faces;
253 //surface and location to construct result
254 TopLoc_Location aBaseLocation;
255 Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation);
256 aBaseSurface = ClearRts(aBaseSurface);
258 // find adjacent faces to union
260 for (i = 1; i <= edges.Length(); i++) {
261 TopoDS_Edge edge = TopoDS::Edge(edges(i));
262 if (BRep_Tool::Degenerated(edge))
265 const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
266 TopTools_ListIteratorOfListOfShape anIter(aList);
267 for (; anIter.More(); anIter.Next()) {
268 TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD));
269 if (anCheckedFace.IsSame(aFace))
272 if (aProcessed.Contains(anCheckedFace))
275 if (IsSameDomain(aFace,anCheckedFace)) {
277 if (aList.Extent() != 2) {
278 // non mainfold case is not processed
283 TopoDS_Face aMockUpFace;
285 B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.);
286 MovePCurves(aMockUpFace,anCheckedFace);
288 if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) {
289 // sequence edges is modified
293 faces.Append(anCheckedFace);
294 aProcessed.Add(anCheckedFace);
300 // all faces collected in the sequence. Perform union of faces
301 if (faces.Length() > 1) {
305 B.MakeFace(aResult,aBaseSurface,aBaseLocation,0);
306 Standard_Integer nbWires = 0;
309 while (edges.Length()>0) {
311 Standard_Boolean isEdge3d = Standard_False;
313 TopTools_MapOfShape aVertices;
317 TopoDS_Edge anEdge = TopoDS::Edge(edges(1));
320 isEdge3d |= !BRep_Tool::Degenerated(anEdge);
323 TopExp::Vertices(anEdge,V1,V2);
327 Standard_Boolean isNewFound = Standard_False;
329 isNewFound = Standard_False;
330 for(Standard_Integer j = 1; j <= edges.Length(); j++) {
331 anEdge = TopoDS::Edge(edges(j));
332 TopExp::Vertices(anEdge,V1,V2);
333 if(aVertices.Contains(V1) || aVertices.Contains(V2)) {
334 isEdge3d |= !BRep_Tool::Degenerated(anEdge);
340 isNewFound = Standard_True;
343 } while (isNewFound);
345 // sorting any type of edges
346 aWire = TopoDS::Wire(aContext->Apply(aWire));
348 TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD)));
349 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion());
351 Standard_Boolean isDegRemoved = Standard_False;
352 if(!sfw->StatusReorder ( ShapeExtend_FAIL )) {
353 // clear degenerated edges if at least one with 3d curve exist
355 Handle(ShapeExtend_WireData) sewd = sfw->WireData();
356 for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) {
357 TopoDS_Edge E = sewd->Edge(j);
358 if(BRep_Tool::Degenerated(E)) {
360 isDegRemoved = Standard_True;
367 sfw->FixDegenerated();
369 TopoDS_Wire aWireFixed = sfw->Wire();
370 aContext->Replace(aWire,aWireFixed);
371 // add resulting wire
373 B.Add(aResult,aWireFixed);
377 Handle(ShapeExtend_WireData) sbwd = sfw->WireData();
378 Standard_Integer nbEdges = sbwd->NbEdges();
379 // sort degenerated edges and create one edge instead of several ones
380 ShapeAnalysis_WireOrder sawo(Standard_False, 0);
381 ShapeAnalysis_Edge sae;
382 Standard_Integer aLastEdge = nbEdges;
383 for(Standard_Integer j = 1; j <= nbEdges; j++) {
385 //smh protection on NULL pcurve
386 Handle(Geom2d_Curve) c2d;
387 if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) {
391 sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY());
395 // constructind one degenerative edge
396 gp_XY aStart, anEnd, tmp;
397 Standard_Integer nbFirst = sawo.Ordered(1);
398 TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD));
400 TopoDS_Vertex aDummyV;
401 TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV);
402 sawo.XY(nbFirst,aStart,tmp);
403 sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd);
405 gp_XY aVec = anEnd-aStart;
406 Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart));
408 B.UpdateEdge(E,aLine,tmpF,0.);
409 B.Range(E,tmpF,0.,aVec.Modulus());
410 Handle(Geom_Curve) C3d;
411 B.UpdateEdge(E,C3d,0.);
412 B.Degenerated(E,Standard_True);
420 // perform substitution of face
421 aContext->Replace(aContext->Apply(aFace),aResult);
423 ShapeFix_Face sff (aResult);
424 //Intializing by tolerances
425 sff.SetPrecision(myTolerance);
426 sff.SetMinTolerance(tol);
427 sff.SetMaxTolerance(Max(1.,myTolerance*1000.));
429 sff.FixOrientationMode() = 0;
430 //sff.FixWireMode() = 0;
431 sff.SetContext(aContext);
432 // Applying the fixes
434 if(sff.Status(ShapeExtend_FAIL))
435 hasFailed = Standard_True;
437 // breaking down to several faces
438 TopoDS_Shape theResult = aContext->Apply(aResult);
439 for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) {
440 TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD));
441 Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 );
442 grid->SetValue ( 1, 1, aBaseSurface );
443 Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid );
444 ShapeFix_ComposeShell CompShell;
445 CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision
446 CompShell.SetContext( aContext );
448 TopTools_SequenceOfShape parts;
449 ShapeFix_SequenceOfWireSegment wires;
450 for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) {
451 Handle(ShapeExtend_WireData) sbwd =
452 new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() ));
453 ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED );
457 CompShell.DispatchWires ( parts,wires );
458 for (Standard_Integer j=1; j <= parts.Length(); j++ ) {
459 ShapeFix_Face aFixOrient(TopoDS::Face(parts(j)));
460 aFixOrient.SetContext(aContext);
461 aFixOrient.FixOrientation();
464 TopoDS_Shape CompRes;
465 if ( faces.Length() !=1 ) {
468 for ( i=1; i <= parts.Length(); i++ )
469 B.Add ( S, parts(i) );
472 else CompRes = parts(1);
474 aContext->Replace(aCurrent,CompRes);
477 // remove the remaining faces
478 for(i = 2; i <= faces.Length(); i++)
479 aContext->Remove(faces(i));
481 } // end processing each face
483 //TopoDS_Shape aResult = Shape;
484 if (NbModif > 0 && !hasFailed) {
485 TopoDS_Shape aResult = aContext->Apply(aSolid);
488 for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) {
489 TopoDS_Edge E = TopoDS::Edge(exp.Current());
490 sfe.FixVertexTolerance (E);
491 // ptv add fix same parameter
492 sfe.FixSameParameter(E, myTolerance);
495 myContext->Replace(aSolid, aResult);
499 for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
500 TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
501 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
502 sfw->SetContext(myContext);
503 sfw->SetPrecision(myTolerance);
504 sfw->SetMinTolerance(myTolerance);
505 sfw->SetMaxTolerance(Max(1.,myTolerance*1000.));
507 for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) {
508 TopoDS_Wire wire = TopoDS::Wire(iter.Value());
515 } // end processing each solid
517 aResShape = myContext->Apply(Shape);
522 //=======================================================================
523 //function : IsSameDomain
525 //=======================================================================
527 bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder)
529 bool isCylinder = false;
531 if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
532 Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface);
534 theOutCylinder = aGC->Cylinder();
537 else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
538 Handle(Geom_SurfaceOfRevolution) aRS =
539 Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface);
540 Handle(Geom_Curve) aBasis = aRS->BasisCurve();
541 if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) {
542 Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis);
543 gp_Dir aDir = aRS->Direction();
544 gp_Dir aBasisDir = aBasisLine->Position().Direction();
545 if (aBasisDir.IsParallel(aDir, Precision::Confusion())) {
546 // basis line is parallel to the revolution axis: it is a cylinder
547 gp_Pnt aLoc = aRS->Location();
548 Standard_Real aR = aBasisLine->Lin().Distance(aLoc);
549 gp_Ax3 aCylAx (aLoc, aDir);
551 theOutCylinder = gp_Cylinder(aCylAx, aR);
556 else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
557 Handle(Geom_SurfaceOfLinearExtrusion) aLES =
558 Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface);
559 Handle(Geom_Curve) aBasis = aLES->BasisCurve();
560 if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) {
561 Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis);
562 gp_Dir aDir = aLES->Direction();
563 gp_Dir aBasisDir = aBasisCircle->Position().Direction();
564 if (aBasisDir.IsParallel(aDir, Precision::Confusion())) {
565 // basis circle is normal to the extrusion axis: it is a cylinder
566 gp_Pnt aLoc = aBasisCircle->Location();
567 Standard_Real aR = aBasisCircle->Radius();
568 gp_Ax3 aCylAx (aLoc, aDir);
570 theOutCylinder = gp_Cylinder(aCylAx, aR);
581 Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
582 const TopoDS_Face& aCheckedFace) const
584 //checking the same handles
585 TopLoc_Location L1, L2;
586 Handle(Geom_Surface) S1, S2;
588 S1 = BRep_Tool::Surface(aFace,L1);
589 S2 = BRep_Tool::Surface(aCheckedFace,L2);
591 if (S1 == S2 && L1 == L2)
594 // planar and cylindrical cases (IMP 20052)
595 Standard_Real aPrec = Precision::Confusion();
597 S1 = BRep_Tool::Surface(aFace);
598 S2 = BRep_Tool::Surface(aCheckedFace);
603 //Handle(Geom_OffsetSurface) aGOFS1, aGOFS2;
604 //aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1);
605 //aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2);
606 //if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface();
607 //if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface();
609 // case of two elementary surfaces: use OCCT tool
610 // elementary surfaces: ConicalSurface, CylindricalSurface,
611 // Plane, SphericalSurface and ToroidalSurface
612 if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) &&
613 S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface)))
615 Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1);
616 Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2);
618 Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool();
619 Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool();
622 #if OCC_VERSION_LARGE > 0x06010000
626 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
627 IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec);
629 IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec);
631 if (!anIIInt.IsDone() || anIIInt.IsEmpty())
634 return anIIInt.TangentFaces();
636 catch (Standard_Failure) {
641 // case of two planar surfaces:
642 // all kinds of surfaces checked, including b-spline and bezier
643 GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec);
644 if (aPlanarityChecker1.IsPlanar()) {
645 GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec);
646 if (aPlanarityChecker2.IsPlanar()) {
647 gp_Pln aPln1 = aPlanarityChecker1.Plan();
648 gp_Pln aPln2 = aPlanarityChecker2.Plan();
650 if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) &&
651 aPln1.Distance(aPln2) < aPrec) {
657 // case of two cylindrical surfaces, at least one of which is a swept surface
658 // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution
659 if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
660 S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) &&
661 (S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
662 S2->IsKind(STANDARD_TYPE(Geom_SweptSurface))))
664 gp_Cylinder aCyl1, aCyl2;
665 if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) {
666 if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) {
667 gp_Dir aDir1 = aCyl1.Position().Direction();
668 gp_Dir aDir2 = aCyl2.Position().Direction();
669 if (aDir1.IsParallel(aDir2, aPrec)) {
670 gp_Pnt aLoc1 = aCyl1.Location();
671 gp_Pnt aLoc2 = aCyl2.Location();
672 gp_Vec aVec12 (aLoc1, aLoc2);
673 if (aVec12.SquareMagnitude() < aPrec*aPrec ||
674 aVec12.IsParallel(aDir1, aPrec)) {
686 //=======================================================================
687 //function : MovePCurves
689 //=======================================================================
691 void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
692 const TopoDS_Face& aSource) const
695 for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) {
696 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()),
697 aTarget, Precision::Confusion());
699 Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL );
700 sfw->FixEdgeCurves();
705 sfw->FixDegenerated();
707 // remove degenerated edges from not degenerated points
708 ShapeAnalysis_Edge sae;
709 Handle(ShapeExtend_WireData) sewd = sfw->WireData();
710 for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) {
711 TopoDS_Edge E = sewd->Edge(i);
712 if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) {
718 TopoDS_Wire ResWire = sfw->Wire();
719 B.Add(aTarget,ResWire);