Salome HOME
Merge branch 'BR_PYTHON_PLUGIN' of newgeom:newgeom.git into Dev_0.6.1
[modules/shaper.git] / src / GeomAPI / GeomAPI_Vertex.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAPI_Vertex.cpp
4 // Created:     24 Jul 2014
5 // Author:      Artem ZHIDKOV
6
7 #include<GeomAPI_Vertex.h>
8 #include<GeomAPI_Pnt.h>
9
10 #include <TopoDS_Shape.hxx>
11 #include <TopoDS_Edge.hxx>
12 #include <TopoDS.hxx>
13 #include <TopoDS_Vertex.hxx>
14 #include <BRep_Tool.hxx>
15 #include <gp_Pnt.hxx>
16 #include <Precision.hxx>
17
18 GeomAPI_Vertex::GeomAPI_Vertex()
19   : GeomAPI_Shape()
20 {
21 }
22
23 GeomAPI_Vertex::GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape)
24 {
25   if (!theShape->isNull() && theShape->isVertex()) {
26     setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
27   }
28 }
29
30 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Vertex::point()
31 {
32   const TopoDS_Shape& aShape = const_cast<GeomAPI_Vertex*>(this)->impl<TopoDS_Shape>();
33   TopoDS_Vertex aVertex = TopoDS::Vertex(aShape);
34   gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
35   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
36 }
37
38 bool GeomAPI_Vertex::isEqual(std::shared_ptr<GeomAPI_Shape> theVert)
39 {
40   const TopoDS_Shape& aMyShape = const_cast<GeomAPI_Vertex*>(this)->impl<TopoDS_Shape>();
41   const TopoDS_Shape& aInShape = theVert->impl<TopoDS_Shape>();
42
43   TopoDS_Vertex aVertex1 = TopoDS::Vertex(aMyShape);
44   gp_Pnt aPoint1 = BRep_Tool::Pnt(aVertex1);
45
46   TopoDS_Vertex aVertex2 = TopoDS::Vertex(aInShape);
47   gp_Pnt aPoint2 = BRep_Tool::Pnt(aVertex2);
48
49   return aPoint1.IsEqual(aPoint2, Precision::Confusion()) == Standard_True;
50 }