From: jfa Date: Mon, 23 May 2022 08:24:16 +0000 (+0300) Subject: [bos #29971] [CEA 29586] doing a fillet X-Git-Tag: V9_9_1b1~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cd3c4a1a639b010e78f742664784ace611935635;hp=95ff1008bc8215fdeafd7d253dc5a6f33e949363;p=modules%2Fshaper.git [bos #29971] [CEA 29586] doing a fillet --- diff --git a/src/SketchPlugin/SketchPlugin_Fillet.cpp b/src/SketchPlugin/SketchPlugin_Fillet.cpp index 8fd28ecb6..25aa311ec 100644 --- a/src/SketchPlugin/SketchPlugin_Fillet.cpp +++ b/src/SketchPlugin/SketchPlugin_Fillet.cpp @@ -31,6 +31,7 @@ #include "SketchPlugin_ConstraintTangent.h" #include "SketchPlugin_ConstraintRadius.h" #include "SketchPlugin_Tools.h" +#include "SketchPlugin_Validators.h" #include #include @@ -53,6 +54,7 @@ #include #include +#include #include @@ -212,37 +214,15 @@ bool SketchPlugin_Fillet::calculateFilletParameters() if (!aFilletPoint2D.get()) return false; - std::set aCoincidentPoints = - SketchPlugin_Tools::findPointsCoincidentToPoint(aFilletPoint2D); - std::set aFilletFeatures; - for (std::set::iterator aCPIt = aCoincidentPoints.begin(); - aCPIt != aCoincidentPoints.end(); ++aCPIt) { - std::shared_ptr anOwner = - std::dynamic_pointer_cast( - ModelAPI_Feature::feature((*aCPIt)->owner())); - if (anOwner && !anOwner->isExternal()) - aFilletFeatures.insert(anOwner); - } - // remove auxilary entities from set of coincident features - if (aFilletFeatures.size() > 2) { - std::set::iterator anIt = aFilletFeatures.begin(); - while (anIt != aFilletFeatures.end()) { - if ((*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) { - std::set::iterator aRemoveIt = anIt++; - aFilletFeatures.erase(aRemoveIt); - } - else - ++anIt; - } - } - if (aFilletFeatures.size() != 2) { - setError("Error: Selected point does not have two suitable edges for fillet."); + Events_InfoMessage anError; + FeaturePtr anEdge1, anEdge2; + if (!SketchPlugin_FilletVertexValidator::isValidVertex + (aPointRefAttr, anError, anEdge1, anEdge2)) { + setError(anError.messageString()); return false; } - - std::set::iterator aFIt = aFilletFeatures.begin(); - myBaseFeatures[0] = *aFIt; - myBaseFeatures[1] = *(++aFIt); + myBaseFeatures[0] = anEdge1; + myBaseFeatures[1] = anEdge2; std::shared_ptr aFilletPnt2d = aFilletPoint2D->pnt(); double aRadius = calculateFilletRadius(myBaseFeatures); diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index bd8408eea..73ec0900a 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -669,6 +669,15 @@ static bool isPointPointCoincidence(const FeaturePtr& theCoincidence) bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, Events_InfoMessage& theError) const +{ + FeaturePtr anEdge1, anEdge2; + return isValidVertex(theAttribute, theError, anEdge1, anEdge2); +} + +bool SketchPlugin_FilletVertexValidator::isValidVertex(const AttributePtr& theAttribute, + Events_InfoMessage& theError, + FeaturePtr& theEdge1, + FeaturePtr& theEdge2) { AttributeRefAttrPtr aPointRefAttr = std::dynamic_pointer_cast(theAttribute); @@ -723,13 +732,13 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut // Get coincides from constraint. std::set aCoinsides; SketchPlugin_Tools::findCoincidences(aConstraintCoincidence, - SketchPlugin_ConstraintCoincidence::ENTITY_A(), - aCoinsides, - true); + SketchPlugin_ConstraintCoincidence::ENTITY_A(), + aCoinsides, + true); SketchPlugin_Tools::findCoincidences(aConstraintCoincidence, - SketchPlugin_ConstraintCoincidence::ENTITY_B(), - aCoinsides, - true); + SketchPlugin_ConstraintCoincidence::ENTITY_B(), + aCoinsides, + true); // Remove points and external lines from set of coincides. std::set aNewSetOfCoincides; @@ -774,6 +783,11 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut return false; } + // output edges + std::set::iterator aFIt = aCoinsides.begin(); + theEdge1 = *aFIt; + theEdge2 = *(++aFIt); + // Check that selected edges don't have tangent constraint. std::set::iterator anIt = aCoinsides.begin(); FeaturePtr aFirstFeature = *anIt++; diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h index 3cb49701f..1516d5554 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.h +++ b/src/SketchPlugin/SketchPlugin_Validators.h @@ -209,6 +209,16 @@ public: virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, Events_InfoMessage& theError) const; + + //! returns true if attribute is a good point for fillet + //! \param theAttribute the checked point attribute + //! \param theError error message + //! \param theEdge1 adjacent edge feature + //! \param theEdge2 adjacent edge feature + static bool isValidVertex(const AttributePtr& theAttribute, + Events_InfoMessage& theError, + FeaturePtr& theEdge1, + FeaturePtr& theEdge2); };