X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_EdgeBuilder.cpp;h=360f46bd2b850f90febbc136e831fbff247bde36;hb=f0cec241aae9ca16d86e166f45cb5c4987d2c792;hp=3c177a1787e65cce0425633c6ba3540bf2cf2c2e;hpb=50c26f8bb70e02bfe1f70e0f3545611378433e77;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp index 3c177a178..360f46bd2 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp @@ -36,6 +36,23 @@ std::shared_ptr GeomAlgoAPI_EdgeBuilder::line( aRes->setImpl(new TopoDS_Shape(anEdge)); return aRes; } +std::shared_ptr GeomAlgoAPI_EdgeBuilder::line( + double theDX, double theDY, double theDZ) +{ + + const gp_Pnt& aStart = gp_Pnt(0, 0, 0); + const gp_Pnt& anEnd = gp_Pnt(theDX, theDY, theDZ); + + if (aStart.IsEqual(anEnd, Precision::Confusion())) + return std::shared_ptr(); + if (Abs(aStart.SquareDistance(anEnd)) > 1.e+100) + return std::shared_ptr(); + BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd); + std::shared_ptr aRes(new GeomAPI_Edge); + TopoDS_Edge anEdge = anEdgeBuilder.Edge(); + aRes->setImpl(new TopoDS_Shape(anEdge)); + return aRes; +} std::shared_ptr GeomAlgoAPI_EdgeBuilder::cylinderAxis( std::shared_ptr theCylindricalFace) @@ -130,9 +147,16 @@ std::shared_ptr GeomAlgoAPI_EdgeBuilder::lineCircleArc( std::shared_ptr theCenter, std::shared_ptr theStartPoint, std::shared_ptr theEndPoint, std::shared_ptr theNormal) { + std::shared_ptr aRes; + const gp_Pnt& aCenter = theCenter->impl(); const gp_Dir& aDir = theNormal->impl(); + /// OCCT creates an edge on a circle with empty radius, but visualization + /// is not able to process it + if (theCenter->isEqual(theStartPoint)) + return aRes; + double aRadius = theCenter->distance(theStartPoint); gp_Circ aCircle(gp_Ax2(aCenter, aDir), aRadius); @@ -140,18 +164,13 @@ std::shared_ptr GeomAlgoAPI_EdgeBuilder::lineCircleArc( const gp_Pnt& anEnd = theEndPoint->impl(); BRepBuilderAPI_MakeEdge anEdgeBuilder; - if (aStart.IsEqual(anEnd, Precision::Confusion()) - || gp_Pnt(0, 0, 0).IsEqual(anEnd, Precision::Confusion())) - anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle); - else - anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle, aStart, anEnd); + anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle, aStart, anEnd); - std::shared_ptr aRes(new GeomAPI_Edge); anEdgeBuilder.Build(); - if (anEdgeBuilder.IsDone()) + if (anEdgeBuilder.IsDone()) { + aRes = std::shared_ptr(new GeomAPI_Edge); aRes->setImpl(new TopoDS_Shape(anEdgeBuilder.Edge())); - else - aRes = std::shared_ptr(); + } return aRes; }