X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Vertex.cpp;h=adb04beeed9a1808fa9b35995467761f9f95bc4f;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=b917837a09cfcaa4e9589598625f7a4d4f63765e;hpb=08872b5ca3cca57713f8fdba0e610f7f49cdb298;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Vertex.cpp b/src/GeomAPI/GeomAPI_Vertex.cpp index b917837a0..adb04beee 100644 --- a/src/GeomAPI/GeomAPI_Vertex.cpp +++ b/src/GeomAPI/GeomAPI_Vertex.cpp @@ -1,8 +1,21 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAPI_Vertex.cpp -// Created: 24 Jul 2014 -// Author: Artem ZHIDKOV +// 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include #include @@ -12,9 +25,18 @@ #include #include #include +#include #include #include +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() { @@ -27,6 +49,16 @@ GeomAPI_Vertex::GeomAPI_Vertex(const std::shared_ptr& theShape) } } +GeomAPI_Vertex::GeomAPI_Vertex(const std::shared_ptr& thePoint) +{ + setImpl(buildVertex(thePoint->impl())); +} + +GeomAPI_Vertex::GeomAPI_Vertex(double theX, double theY, double theZ) +{ + setImpl(buildVertex(gp_Pnt(theX, theY, theZ))); +} + std::shared_ptr GeomAPI_Vertex::point() { const TopoDS_Shape& aShape = const_cast(this)->impl(); @@ -53,3 +85,23 @@ bool GeomAPI_Vertex::isEqual(const std::shared_ptr theVert) const 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(); + const TopoDS_Vertex& aVertex2 = theVertex2->impl(); + + 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; +}