X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_EdgeBuilder.cpp;h=fdf2fc434a4760f5f8ff3e5d1f9c86ce692818ec;hb=5dfebcc3a72f75f043de9880419b39f073af6819;hp=f1ecb2b34fca5e14775253030ec483e616639460;hpb=7bf19255421b34594c7b0a76d0ce28166d0ce895;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp index f1ecb2b34..fdf2fc434 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp @@ -8,9 +8,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -32,6 +34,38 @@ std::shared_ptr GeomAlgoAPI_EdgeBuilder::line( return aRes; } +std::shared_ptr GeomAlgoAPI_EdgeBuilder::cylinderAxis( + std::shared_ptr theCylindricalFace) +{ + std::shared_ptr aResult; + const TopoDS_Shape& aShape = theCylindricalFace->impl(); + if (aShape.IsNull()) + return aResult; + TopoDS_Face aFace = TopoDS::Face(aShape); + if (aFace.IsNull()) + return aResult; + TopLoc_Location aLoc; + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace, aLoc); + if (aSurf.IsNull()) + return aResult; + Handle(Geom_CylindricalSurface) aCyl = Handle(Geom_CylindricalSurface)::DownCast(aSurf); + if (aCyl.IsNull()) + return aResult; + gp_Ax1 anAxis = aCyl->Axis(); + gp_Pnt aStart(anAxis.Location().Transformed(aLoc.Transformation())); + // edge length is 100, "-" because cylinder of extrusion has negative direction with the cylinder + gp_Pnt anEnd(anAxis.Location().XYZ() - anAxis.Direction().XYZ() * 100.); + anEnd.Transform(aLoc.Transformation()); + + BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd); + std::shared_ptr aRes(new GeomAPI_Edge); + TopoDS_Edge anEdge = anEdgeBuilder.Edge(); + // an axis is an infinite object + anEdge.Infinite(Standard_True); + aRes->setImpl(new TopoDS_Shape(anEdge)); + return aRes; +} + std::shared_ptr GeomAlgoAPI_EdgeBuilder::lineCircle( std::shared_ptr theCenter, std::shared_ptr theNormal, double theRadius)