Salome HOME
Issue #351 constraint is not applied on preselected segments
[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 <GeomAPI_Vertex.h>
11 #include <BRepBuilderAPI_MakeVertex.hxx>
12 #include <BRep_Tool.hxx>
13 #include <TopoDS_Vertex.hxx>
14 #include <TopoDS.hxx>
15 #include <gp_Pnt.hxx>
16
17 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
18     std::shared_ptr<GeomAPI_Pnt> thePoint)
19 {
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));
25   return aRes;
26 }
27
28
29 std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(std::shared_ptr<GeomAPI_Shape> theVertex)
30 {
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()));
36     return aPnt;
37   }
38   return std::shared_ptr<GeomAPI_Pnt>();
39 }