1 // Copyright (C) 2007-2012 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.hxx>
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>
75 #include <TopoDS_Shape.hxx>
77 #include <TColGeom_HArray2OfSurface.hxx>
79 #include <GeomAdaptor_HSurface.hxx>
80 #include <GeomLib_IsPlanarSurface.hxx>
82 #include <Geom_Surface.hxx>
83 #include <Geom_Plane.hxx>
84 #include <Geom_OffsetSurface.hxx>
85 #include <Geom_SphericalSurface.hxx>
86 #include <Geom_CylindricalSurface.hxx>
87 #include <Geom_SurfaceOfRevolution.hxx>
88 #include <Geom_SurfaceOfLinearExtrusion.hxx>
89 #include <Geom_RectangularTrimmedSurface.hxx>
91 #include <Geom_Curve.hxx>
92 #include <Geom_Line.hxx>
93 #include <Geom_Circle.hxx>
95 #include <Geom2d_Line.hxx>
98 #include <gp_Pnt2d.hxx>
100 #include <Standard_Failure.hxx>
101 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
103 //=======================================================================
104 //function : BlockFix_UnionFaces
106 //=======================================================================
107 BlockFix_UnionFaces::BlockFix_UnionFaces()
108 : myTolerance(Precision::Confusion()),
113 //=======================================================================
114 //function : GetTolerance
116 //=======================================================================
117 Standard_Real& BlockFix_UnionFaces::GetTolerance()
122 //=======================================================================
123 //function : GetOptimumNbFaces
125 //=======================================================================
126 Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces()
128 return myOptimumNbFaces;
131 //=======================================================================
132 //function : AddOrdinaryEdges
134 // adds edges from the shape to the sequence
135 // seams and equal edges are dropped
136 // Returns true if one of original edges dropped
137 //=======================================================================
138 static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges,
139 const TopoDS_Shape aShape,
140 Standard_Integer& anIndex)
143 TopTools_MapOfShape aNewEdges;
144 //add edges without seams
145 for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) {
146 TopoDS_Shape edge = exp.Current();
147 if(aNewEdges.Contains(edge))
148 aNewEdges.Remove(edge);
153 Standard_Boolean isDropped = Standard_False;
154 //merge edges and drop seams
155 for(Standard_Integer i = 1; i <= edges.Length(); i++) {
156 TopoDS_Shape current = edges(i);
157 if(aNewEdges.Contains(current)) {
159 aNewEdges.Remove(current);
164 isDropped = Standard_True;
170 //add edges to the sequemce
171 for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next())
172 edges.Append(anIter.Key());
177 //=======================================================================
178 //function : ClearRts
180 //=======================================================================
181 static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
183 if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
184 Handle(Geom_RectangularTrimmedSurface) rts =
185 Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
186 return rts->BasisSurface();
191 //=======================================================================
194 //=======================================================================
195 TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
197 Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape;
198 TopoDS_Shape aResShape = myContext->Apply(Shape);
200 // processing each solid
201 TopExp_Explorer exps;
202 for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) {
203 TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
205 // creating map of edge faces
206 TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
207 TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
209 // map of processed shapes
210 TopTools_MapOfShape aProcessed;
212 Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
214 Standard_Integer NbModif = 0;
215 Standard_Boolean hasFailed = Standard_False;
216 Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
221 TopTools_MapOfShape mapF;
222 for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
223 if (mapF.Add(exp.Current()))
227 bool doUnion = ((myOptimumNbFaces == 0) ||
228 ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces)));
230 // processing each face
232 for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) {
233 TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
235 if (aProcessed.Contains(aFace))
238 Standard_Integer dummy;
239 TopTools_SequenceOfShape edges;
240 AddOrdinaryEdges(edges,aFace,dummy);
242 TopTools_SequenceOfShape faces;
245 //surface and location to construct result
246 TopLoc_Location aBaseLocation;
247 Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation);
248 aBaseSurface = ClearRts(aBaseSurface);
250 // find adjacent faces to union
252 for (i = 1; i <= edges.Length(); i++) {
253 TopoDS_Edge edge = TopoDS::Edge(edges(i));
254 if (BRep_Tool::Degenerated(edge))
257 const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
258 TopTools_ListIteratorOfListOfShape anIter(aList);
259 for (; anIter.More(); anIter.Next()) {
260 TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD));
261 if (anCheckedFace.IsSame(aFace))
264 if (aProcessed.Contains(anCheckedFace))
267 if (IsSameDomain(aFace,anCheckedFace)) {
269 if (aList.Extent() != 2) {
270 // non mainfold case is not processed
275 TopoDS_Face aMockUpFace;
277 B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.);
278 MovePCurves(aMockUpFace,anCheckedFace);
280 if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) {
281 // sequence edges is modified
285 faces.Append(anCheckedFace);
286 aProcessed.Add(anCheckedFace);
292 // all faces collected in the sequence. Perform union of faces
293 if (faces.Length() > 1) {
297 B.MakeFace(aResult,aBaseSurface,aBaseLocation,0);
298 Standard_Integer nbWires = 0;
301 while (edges.Length()>0) {
303 Standard_Boolean isEdge3d = Standard_False;
305 TopTools_MapOfShape aVertices;
309 TopoDS_Edge anEdge = TopoDS::Edge(edges(1));
312 isEdge3d |= !BRep_Tool::Degenerated(anEdge);
315 TopExp::Vertices(anEdge,V1,V2);
319 Standard_Boolean isNewFound = Standard_False;
321 isNewFound = Standard_False;
322 for(Standard_Integer j = 1; j <= edges.Length(); j++) {
323 anEdge = TopoDS::Edge(edges(j));
324 TopExp::Vertices(anEdge,V1,V2);
325 if(aVertices.Contains(V1) || aVertices.Contains(V2)) {
326 isEdge3d |= !BRep_Tool::Degenerated(anEdge);
332 isNewFound = Standard_True;
335 } while (isNewFound);
337 // sorting any type of edges
338 aWire = TopoDS::Wire(aContext->Apply(aWire));
340 TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD)));
341 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion());
343 Standard_Boolean isDegRemoved = Standard_False;
344 if(!sfw->StatusReorder ( ShapeExtend_FAIL )) {
345 // clear degenerated edges if at least one with 3d curve exist
347 Handle(ShapeExtend_WireData) sewd = sfw->WireData();
348 for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) {
349 TopoDS_Edge E = sewd->Edge(j);
350 if(BRep_Tool::Degenerated(E)) {
352 isDegRemoved = Standard_True;
359 sfw->FixDegenerated();
361 TopoDS_Wire aWireFixed = sfw->Wire();
362 aContext->Replace(aWire,aWireFixed);
363 // add resulting wire
365 B.Add(aResult,aWireFixed);
369 Handle(ShapeExtend_WireData) sbwd = sfw->WireData();
370 Standard_Integer nbEdges = sbwd->NbEdges();
371 // sort degenerated edges and create one edge instead of several ones
372 ShapeAnalysis_WireOrder sawo(Standard_False, 0);
373 ShapeAnalysis_Edge sae;
374 Standard_Integer aLastEdge = nbEdges;
375 for(Standard_Integer j = 1; j <= nbEdges; j++) {
377 //smh protection on NULL pcurve
378 Handle(Geom2d_Curve) c2d;
379 if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) {
383 sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY());
387 // constructind one degenerative edge
388 gp_XY aStart, anEnd, tmp;
389 Standard_Integer nbFirst = sawo.Ordered(1);
390 TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD));
392 TopoDS_Vertex aDummyV;
393 TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV);
394 sawo.XY(nbFirst,aStart,tmp);
395 sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd);
397 gp_XY aVec = anEnd-aStart;
398 Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart));
400 B.UpdateEdge(E,aLine,tmpF,0.);
401 B.Range(E,tmpF,0.,aVec.Modulus());
402 Handle(Geom_Curve) C3d;
403 B.UpdateEdge(E,C3d,0.);
404 B.Degenerated(E,Standard_True);
412 // perform substitution of face
413 aContext->Replace(aContext->Apply(aFace),aResult);
415 ShapeFix_Face sff (aResult);
416 //Intializing by tolerances
417 sff.SetPrecision(myTolerance);
418 sff.SetMinTolerance(tol);
419 sff.SetMaxTolerance(Max(1.,myTolerance*1000.));
421 sff.FixOrientationMode() = 0;
422 //sff.FixWireMode() = 0;
423 sff.SetContext(aContext);
424 // Applying the fixes
426 if(sff.Status(ShapeExtend_FAIL))
427 hasFailed = Standard_True;
429 // breaking down to several faces
430 TopoDS_Shape theResult = aContext->Apply(aResult);
431 for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) {
432 TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD));
433 Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 );
434 grid->SetValue ( 1, 1, aBaseSurface );
435 Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid );
436 ShapeFix_ComposeShell CompShell;
437 CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision
438 CompShell.SetContext( aContext );
440 TopTools_SequenceOfShape parts;
441 ShapeFix_SequenceOfWireSegment wires;
442 for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) {
443 Handle(ShapeExtend_WireData) sbwd =
444 new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() ));
445 ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED );
449 CompShell.DispatchWires ( parts,wires );
450 for (Standard_Integer j=1; j <= parts.Length(); j++ ) {
451 ShapeFix_Face aFixOrient(TopoDS::Face(parts(j)));
452 aFixOrient.SetContext(aContext);
453 aFixOrient.FixOrientation();
456 TopoDS_Shape CompRes;
457 if ( faces.Length() !=1 ) {
460 for ( i=1; i <= parts.Length(); i++ )
461 B.Add ( S, parts(i) );
464 else CompRes = parts(1);
466 aContext->Replace(aCurrent,CompRes);
469 // remove the remaining faces
470 for(i = 2; i <= faces.Length(); i++)
471 aContext->Remove(faces(i));
473 } // end processing each face
475 //TopoDS_Shape aResult = Shape;
476 if (NbModif > 0 && !hasFailed) {
477 TopoDS_Shape aResult = aContext->Apply(aSolid);
480 for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) {
481 TopoDS_Edge E = TopoDS::Edge(exp.Current());
482 sfe.FixVertexTolerance (E);
483 // ptv add fix same parameter
484 sfe.FixSameParameter(E, myTolerance);
487 myContext->Replace(aSolid, aResult);
491 for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
492 TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
493 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
494 sfw->SetContext(myContext);
495 sfw->SetPrecision(myTolerance);
496 sfw->SetMinTolerance(myTolerance);
497 sfw->SetMaxTolerance(Max(1.,myTolerance*1000.));
499 for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) {
500 TopoDS_Wire wire = TopoDS::Wire(iter.Value());
507 } // end processing each solid
509 aResShape = myContext->Apply(Shape);
513 //=======================================================================
514 //function : IsSameDomain
516 //=======================================================================
517 bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder)
519 bool isCylinder = false;
521 if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
522 Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface);
524 theOutCylinder = aGC->Cylinder();
527 else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
528 Handle(Geom_SurfaceOfRevolution) aRS =
529 Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface);
530 Handle(Geom_Curve) aBasis = aRS->BasisCurve();
531 if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) {
532 Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis);
533 gp_Dir aDir = aRS->Direction();
534 gp_Dir aBasisDir = aBasisLine->Position().Direction();
535 if (aBasisDir.IsParallel(aDir, Precision::Confusion())) {
536 // basis line is parallel to the revolution axis: it is a cylinder
537 gp_Pnt aLoc = aRS->Location();
538 Standard_Real aR = aBasisLine->Lin().Distance(aLoc);
539 gp_Ax3 aCylAx (aLoc, aDir);
541 theOutCylinder = gp_Cylinder(aCylAx, aR);
546 else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
547 Handle(Geom_SurfaceOfLinearExtrusion) aLES =
548 Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface);
549 Handle(Geom_Curve) aBasis = aLES->BasisCurve();
550 if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) {
551 Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis);
552 gp_Dir aDir = aLES->Direction();
553 gp_Dir aBasisDir = aBasisCircle->Position().Direction();
554 if (aBasisDir.IsParallel(aDir, Precision::Confusion())) {
555 // basis circle is normal to the extrusion axis: it is a cylinder
556 gp_Pnt aLoc = aBasisCircle->Location();
557 Standard_Real aR = aBasisCircle->Radius();
558 gp_Ax3 aCylAx (aLoc, aDir);
560 theOutCylinder = gp_Cylinder(aCylAx, aR);
571 Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
572 const TopoDS_Face& aCheckedFace) const
574 //checking the same handles
575 TopLoc_Location L1, L2;
576 Handle(Geom_Surface) S1, S2;
578 S1 = BRep_Tool::Surface(aFace,L1);
579 S2 = BRep_Tool::Surface(aCheckedFace,L2);
581 if (S1 == S2 && L1 == L2)
584 // planar and cylindrical cases (IMP 20052)
585 Standard_Real aPrec = Precision::Confusion();
587 S1 = BRep_Tool::Surface(aFace);
588 S2 = BRep_Tool::Surface(aCheckedFace);
593 //Handle(Geom_OffsetSurface) aGOFS1, aGOFS2;
594 //aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1);
595 //aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2);
596 //if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface();
597 //if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface();
599 // case of two elementary surfaces: use OCCT tool
600 // elementary surfaces: ConicalSurface, CylindricalSurface,
601 // Plane, SphericalSurface and ToroidalSurface
602 if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) &&
603 S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface)))
605 Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1);
606 Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2);
608 Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool();
609 Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool();
612 #if OCC_VERSION_LARGE > 0x06010000
616 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
617 IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec);
619 IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec);
621 if (!anIIInt.IsDone() || anIIInt.IsEmpty())
624 return anIIInt.TangentFaces();
626 catch (Standard_Failure) {
631 // case of two planar surfaces:
632 // all kinds of surfaces checked, including b-spline and bezier
633 GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec);
634 if (aPlanarityChecker1.IsPlanar()) {
635 GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec);
636 if (aPlanarityChecker2.IsPlanar()) {
637 gp_Pln aPln1 = aPlanarityChecker1.Plan();
638 gp_Pln aPln2 = aPlanarityChecker2.Plan();
640 if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) &&
641 aPln1.Distance(aPln2) < aPrec) {
647 // case of two cylindrical surfaces, at least one of which is a swept surface
648 // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution
649 if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
650 S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) &&
651 (S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
652 S2->IsKind(STANDARD_TYPE(Geom_SweptSurface))))
654 gp_Cylinder aCyl1, aCyl2;
655 if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) {
656 if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) {
657 gp_Dir aDir1 = aCyl1.Position().Direction();
658 gp_Dir aDir2 = aCyl2.Position().Direction();
659 if (aDir1.IsParallel(aDir2, aPrec)) {
660 gp_Pnt aLoc1 = aCyl1.Location();
661 gp_Pnt aLoc2 = aCyl2.Location();
662 gp_Vec aVec12 (aLoc1, aLoc2);
663 if (aVec12.SquareMagnitude() < aPrec*aPrec ||
664 aVec12.IsParallel(aDir1, aPrec)) {
675 //=======================================================================
676 //function : MovePCurves
678 //=======================================================================
679 void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
680 const TopoDS_Face& aSource) const
683 for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) {
684 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()),
685 aTarget, Precision::Confusion());
687 Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL );
688 sfw->FixEdgeCurves();
693 sfw->FixDegenerated();
695 // remove degenerated edges from not degenerated points
696 ShapeAnalysis_Edge sae;
697 Handle(ShapeExtend_WireData) sewd = sfw->WireData();
698 for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) {
699 TopoDS_Edge E = sewd->Edge(i);
700 if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) {
706 TopoDS_Wire ResWire = sfw->Wire();
707 B.Add(aTarget,ResWire);