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>
15 #include <BRep_Builder.hxx>
17 #include <Precision.hxx>
19 GeomAPI_Vertex::GeomAPI_Vertex()
24 GeomAPI_Vertex::GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape)
26 if (!theShape->isNull() && theShape->isVertex()) {
27 setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
31 GeomAPI_Vertex::GeomAPI_Vertex(double theX, double theY, double theZ)
33 TopoDS_Vertex aVertex;
34 BRep_Builder aBuilder;
35 aBuilder.MakeVertex(aVertex, gp_Pnt(theX, theY, theZ), Precision::Confusion());
36 setImpl(new TopoDS_Shape(aVertex));
39 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Vertex::point()
41 const TopoDS_Shape& aShape = const_cast<GeomAPI_Vertex*>(this)->impl<TopoDS_Shape>();
42 TopoDS_Vertex aVertex = TopoDS::Vertex(aShape);
43 gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
44 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
47 bool GeomAPI_Vertex::isEqual(const std::shared_ptr<GeomAPI_Shape> theVert) const
49 if (!theVert.get() || ! theVert->isVertex())
51 const TopoDS_Shape& aMyShape = const_cast<GeomAPI_Vertex*>(this)->impl<TopoDS_Shape>();
52 const TopoDS_Shape& aInShape = theVert->impl<TopoDS_Shape>();
54 if (aMyShape.ShapeType() != aInShape.ShapeType())
57 TopoDS_Vertex aVertex1 = TopoDS::Vertex(aMyShape);
58 gp_Pnt aPoint1 = BRep_Tool::Pnt(aVertex1);
60 TopoDS_Vertex aVertex2 = TopoDS::Vertex(aInShape);
61 gp_Pnt aPoint2 = BRep_Tool::Pnt(aVertex2);
63 return aPoint1.IsEqual(aPoint2, Precision::Confusion()) == Standard_True;