From: dbv Date: Thu, 3 Mar 2016 13:17:05 +0000 (+0300) Subject: Fillet selection validator for edges with tangent constraint. X-Git-Tag: V_2.2.0~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e6ab88ed62727ed0f267e133de8965c886d98d78;p=modules%2Fshaper.git Fillet selection validator for edges with tangent constraint. --- diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 431cc0347..1110db427 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -12,6 +12,7 @@ #include "SketchPlugin_ConstraintDistance.h" #include "SketchPlugin_ConstraintFillet.h" #include "SketchPlugin_ConstraintRigid.h" +#include "SketchPlugin_ConstraintTangent.h" #include "SketchPlugin_Line.h" #include "SketchPlugin_Point.h" #include "SketchPlugin_Sketch.h" @@ -457,6 +458,45 @@ bool SketchPlugin_SolverErrorValidator::isNotObligatory(std::string theFeature, return true; } +static bool hasSameTangentFeature(const std::set& theRefsList, const FeaturePtr theFeature) +{ + for(std::set::const_iterator anIt = theRefsList.cbegin(); anIt != theRefsList.cend(); ++anIt) { + std::shared_ptr aAttr = (*anIt); + FeaturePtr aFeature = std::dynamic_pointer_cast(aAttr->owner()); + if (aFeature->getKind() == SketchPlugin_ConstraintTangent::ID()) { + AttributeRefAttrPtr anAttrRefA = std::dynamic_pointer_cast( + aFeature->attribute(SketchPlugin_ConstraintTangent::ENTITY_A())); + AttributeRefAttrPtr anAttrRefB = std::dynamic_pointer_cast( + aFeature->attribute(SketchPlugin_ConstraintTangent::ENTITY_B())); + if(anAttrRefA.get()) { + ResultPtr aResA = std::dynamic_pointer_cast(anAttrRefA->object()); + if(aResA.get()) { + DocumentPtr aDoc = aResA->document(); + if(aDoc.get()) { + FeaturePtr aFeatureA = aDoc->feature(aResA); + if(aFeatureA.get() && aFeatureA == theFeature) { + return true; + } + } + } + } + if(anAttrRefB.get()) { + ResultPtr aResB = std::dynamic_pointer_cast(anAttrRefB->object()); + if(aResB.get()) { + DocumentPtr aDoc = aResB->document(); + if(aDoc.get()) { + FeaturePtr aFeatureB = aDoc->feature(aResB); + if(aFeatureB.get() && aFeatureB == theFeature) { + return true; + } + } + } + } + } + } + return false; +} + bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, std::string& theError) const @@ -582,14 +622,31 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut } if(aCoinsides.size() != 2) { - theError = ("Error: One of the selected points does not have two suitable edges for fillet."); + theError = "Error: One of the selected points does not have two suitable edges for fillet."; return false; } - // Check that lines not collinear + // Check that selected edges don't have tangent constraint. std::set::iterator anIt = aCoinsides.begin(); FeaturePtr aFirstFeature = *anIt++; FeaturePtr aSecondFeature = *anIt; + const std::set& aFirstFeatureRefsList = aFirstFeature->data()->refsToMe(); + if(hasSameTangentFeature(aFirstFeatureRefsList, aSecondFeature)) { + theError = "Error: Edges in selected point has tangent constraint."; + return false; + } + + std::list aFirstResults = aFirstFeature->results(); + for(std::list::iterator aResIt = aFirstResults.begin(); aResIt != aFirstResults.end(); ++aResIt) { + ResultPtr aRes = *aResIt; + const std::set& aResRefsList = aRes->data()->refsToMe(); + if(hasSameTangentFeature(aResRefsList, aSecondFeature)) { + theError = "Error: Edges in selected point has tangent constraint."; + return false; + } + } + + // Check that lines not collinear if(aFirstFeature->getKind() == SketchPlugin_Line::ID() && aSecondFeature->getKind() == SketchPlugin_Line::ID()) { std::string aStartAttr = SketchPlugin_Line::START_ID(); std::string anEndAttr = SketchPlugin_Line::END_ID();