1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAPI_Vertex.cpp
4 // Created: 24 Jul 2014
5 // Author: Artem ZHIDKOV
7 #include<GeomAPI_Vertex.h>
8 #include<GeomAPI_Pnt.h>
10 #include <TopoDS_Shape.hxx>
11 #include <TopoDS_Edge.hxx>
13 #include <TopoDS_Vertex.hxx>
14 #include <BRep_Tool.hxx>
16 #include <Precision.hxx>
18 GeomAPI_Vertex::GeomAPI_Vertex()
23 GeomAPI_Vertex::GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape)
25 if (!theShape->isNull() && theShape->isVertex()) {
26 setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
30 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Vertex::point()
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()));
38 bool GeomAPI_Vertex::isEqual(std::shared_ptr<GeomAPI_Shape> theVert)
40 const TopoDS_Shape& aMyShape = const_cast<GeomAPI_Vertex*>(this)->impl<TopoDS_Shape>();
41 const TopoDS_Shape& aInShape = theVert->impl<TopoDS_Shape>();
43 if (aMyShape.ShapeType() != aInShape.ShapeType())
46 TopoDS_Vertex aVertex1 = TopoDS::Vertex(aMyShape);
47 gp_Pnt aPoint1 = BRep_Tool::Pnt(aVertex1);
49 TopoDS_Vertex aVertex2 = TopoDS::Vertex(aInShape);
50 gp_Pnt aPoint2 = BRep_Tool::Pnt(aVertex2);
52 return aPoint1.IsEqual(aPoint2, Precision::Confusion()) == Standard_True;