#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()
GEOMAPI_EXPORT
GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape);
+ /// Creation of vertex by the given point.
+ GEOMAPI_EXPORT
+ GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
+
/// Creation of vertex by 3d coordinates.
GEOMAPI_EXPORT
GeomAPI_Vertex(double theX, double theY, double theZ);
#include <GeomAPI_PlanarEdges.h>
#include <GeomAPI_Pnt.h>
+#include <GeomAlgoAPI_ShapeTools.h>
+
#ifdef WIN32
#pragma warning(disable : 4996) // for sprintf
for (std::list<GeomShapePtr>::const_iterator aSubIt = aSubs.begin();
aSubIt != aSubs.end(); ++aSubIt) {
GeomPointPtr aMiddlePoint = (*aSubIt)->middlePoint();
- if (aMiddlePoint && aMiddlePoint->distance(thePoint) < theTolerance)
+ if (!aMiddlePoint)
+ continue;
+
+ double aDistance = aMiddlePoint->distance(thePoint);
+ bool isFound = aDistance < theTolerance;
+ // issue #19019: special workaround for faces, because if the face contains B-spline contour,
+ // the middle point is calculated with respect to its poles, but not a curve itself.
+ // Thus is some operations (like BOP) the curve may have different number of poles
+ // from time to time, as a result, the face parametric boundaries are floating
+ // as well as the middle point.
+ // The workaround is to find a distance from the picking point to the face, if the distance
+ // between the picking point and the middle point on the face is small to some extend.
+ static const double THE_THRESHOLD = 100.;
+ if (!isFound && aDistance < THE_THRESHOLD * theTolerance && (*aSubIt)->isFace()) {
+ GeomVertexPtr aVertex(new GeomAPI_Vertex(thePoint));
+ aDistance = GeomAlgoAPI_ShapeTools::minimalDistance(aVertex, *aSubIt);
+ isFound = aDistance < theTolerance;
+ }
+ if (isFound)
aFoundSubs.push_back(*aSubIt);
}
return aFoundSubs;