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));
28 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
29 const double theX, const double theY, const double theZ)
31 const gp_Pnt aPnt(theX, theY, theZ);
32 BRepBuilderAPI_MakeVertex aMaker(aPnt);
33 TopoDS_Vertex aVertex = aMaker.Vertex();
34 std::shared_ptr<GeomAPI_Vertex> aRes(new GeomAPI_Vertex);
35 aRes->setImpl(new TopoDS_Shape(aVertex));
39 std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(std::shared_ptr<GeomAPI_Shape> theVertex)
41 TopoDS_Shape aShape = theVertex->impl<TopoDS_Shape>();
42 if ((!aShape.IsNull()) && (aShape.ShapeType() == TopAbs_VERTEX)) {
43 TopoDS_Vertex aVertex = TopoDS::Vertex(aShape);
44 gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
45 std::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
48 return std::shared_ptr<GeomAPI_Pnt>();