1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_PointBuilder.cpp
4 // Created: 02 Jun 2014
5 // Author: Mikhail PONIKAROV
7 #include <GeomAlgoAPI_PointBuilder.h>
8 #include <GeomAPI_Pnt.h>
9 #include <GeomAPI_Shape.h>
10 #include <BRepBuilderAPI_MakeVertex.hxx>
11 #include <BRep_Tool.hxx>
12 #include <TopoDS_Vertex.hxx>
16 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
17 std::shared_ptr<GeomAPI_Pnt> thePoint)
19 const gp_Pnt& aPnt = thePoint->impl<gp_Pnt>();
20 BRepBuilderAPI_MakeVertex aMaker(aPnt);
21 TopoDS_Vertex aVertex = aMaker.Vertex();
22 std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
23 aRes->setImpl(new TopoDS_Shape(aVertex));
28 std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(std::shared_ptr<GeomAPI_Shape> theVertex)
30 TopoDS_Shape aShape = theVertex->impl<TopoDS_Shape>();
31 if ((!aShape.IsNull()) && (aShape.ShapeType() == TopAbs_VERTEX)) {
32 TopoDS_Vertex aVertex = TopoDS::Vertex(aShape);
33 gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
34 std::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
37 return std::shared_ptr<GeomAPI_Pnt>();