-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include<GeomAPI_Vertex.h>
#include <gp_Pnt.hxx>
#include <Precision.hxx>
+static TopoDS_Shape* buildVertex(const gp_Pnt& thePoint)
+{
+ TopoDS_Vertex aVertex;
+ BRep_Builder aBuilder;
+ aBuilder.MakeVertex(aVertex, thePoint, Precision::Confusion());
+ return new TopoDS_Shape(aVertex);
+}
+
GeomAPI_Vertex::GeomAPI_Vertex()
: GeomAPI_Shape()
{
}
}
+GeomAPI_Vertex::GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Pnt>& thePoint)
+{
+ setImpl(buildVertex(thePoint->impl<gp_Pnt>()));
+}
+
GeomAPI_Vertex::GeomAPI_Vertex(double theX, double theY, double theZ)
{
- TopoDS_Vertex aVertex;
- BRep_Builder aBuilder;
- aBuilder.MakeVertex(aVertex, gp_Pnt(theX, theY, theZ), Precision::Confusion());
- setImpl(new TopoDS_Shape(aVertex));
+ setImpl(buildVertex(gp_Pnt(theX, theY, theZ)));
}
std::shared_ptr<GeomAPI_Pnt> GeomAPI_Vertex::point()
return aPoint1.IsEqual(aPoint2, Precision::Confusion()) == Standard_True;
}
+
+
+
+bool GeomAPI_Vertex::GeometricComparator::operator()(const GeomVertexPtr& theVertex1,
+ const GeomVertexPtr& theVertex2) const
+{
+ const TopoDS_Vertex& aVertex1 = theVertex1->impl<TopoDS_Vertex>();
+ const TopoDS_Vertex& aVertex2 = theVertex2->impl<TopoDS_Vertex>();
+
+ gp_Pnt aPnt1 = BRep_Tool::Pnt(aVertex1);
+ gp_Pnt aPnt2 = BRep_Tool::Pnt(aVertex2);
+
+ bool isLess = aPnt1.X() + myTolerance < aPnt2.X();
+ if (!isLess && aPnt1.X() <= aPnt2.X() + myTolerance) {
+ isLess = aPnt1.Y() + myTolerance < aPnt2.Y();
+ if (!isLess && aPnt1.Y() <= aPnt2.Y() + myTolerance)
+ isLess = aPnt1.Z() + myTolerance < aPnt2.Z();
+ }
+ return isLess;
+}