From 0ea6294d5f1a664fbf05fc2cb05ba74e25bac785 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 17 Oct 2019 19:12:45 +0300 Subject: [PATCH] Fix for the issue #17867 : ExtrusionCut doesn't work Allow to select start point of an arc even due to the 2D->3D conversion produces 3.e-7 error in coordinates. --- src/Model/Model_Data.h | 1 - src/PartSet/PartSet_Tools.cpp | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index f2698eef9..9f26d8de1 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -326,7 +326,6 @@ private: MODEL_EXPORT virtual bool isPrecedingAttribute(const std::string& theAttribute1, const std::string& theAttribute2) const; - friend class Model_Objects; }; /// Generic method to register back reference, used in referencing attributes. diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 376bce7ce..fbb50228f 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -650,6 +650,7 @@ AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj, aFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list::const_iterator anIt = anAttiributes.begin(), aLast = anAttiributes.end(); + double aMinDistance = 1.e-6; // searching for point with minimal distance and < 1.e-6 for (; anIt != aLast && !anAttribute; anIt++) { std::shared_ptr aCurPoint = std::dynamic_pointer_cast(*anIt); @@ -658,9 +659,12 @@ AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj, std::shared_ptr aPnt = convertTo3D(aCurPoint->x(), aCurPoint->y(), theSketch); - if (aPnt && (aPnt->distance(aValue) < Precision::Confusion())) { - anAttribute = aCurPoint; - break; + if (aPnt) { + double aDistance = aPnt->distance(aValue); + if (aDistance < aMinDistance) { + anAttribute = aCurPoint; + aMinDistance = aPnt->distance(aValue); + } } } } -- 2.39.2