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 <GeomAPI_Vertex.h>
11 #include <BRepBuilderAPI_MakeVertex.hxx>
12 #include <BRep_Tool.hxx>
13 #include <TopoDS_Vertex.hxx>
17 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
18 std::shared_ptr<GeomAPI_Pnt> thePoint)
20 const gp_Pnt& aPnt = thePoint->impl<gp_Pnt>();
21 BRepBuilderAPI_MakeVertex aMaker(aPnt);
22 TopoDS_Vertex aVertex = aMaker.Vertex();
23 std::shared_ptr<GeomAPI_Vertex> aRes(new GeomAPI_Vertex);
24 aRes->setImpl(new TopoDS_Shape(aVertex));
29 std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(std::shared_ptr<GeomAPI_Shape> theVertex)
31 TopoDS_Shape aShape = theVertex->impl<TopoDS_Shape>();
32 if ((!aShape.IsNull()) && (aShape.ShapeType() == TopAbs_VERTEX)) {
33 TopoDS_Vertex aVertex = TopoDS::Vertex(aShape);
34 gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
35 std::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
38 return std::shared_ptr<GeomAPI_Pnt>();