]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp
Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_PointBuilder.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_PointBuilder.cpp
4 // Created:     02 Jun 2014
5 // Author:      Mikhail PONIKAROV
6
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>
13 #include <TopoDS.hxx>
14 #include <gp_Pnt.hxx>
15
16 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
17     std::shared_ptr<GeomAPI_Pnt> thePoint)
18 {
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));
24   return aRes;
25 }
26
27
28 std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(std::shared_ptr<GeomAPI_Shape> theVertex)
29 {
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()));
35     return aPnt;
36   }
37   return std::shared_ptr<GeomAPI_Pnt>();
38 }