From: dbv Date: Fri, 19 Feb 2016 11:33:30 +0000 (+0300) Subject: Removed unused attributes from fillet. X-Git-Tag: V_2.2.0~91 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=77ae7df9bc56751ccd47e4ef084451e0ff19cdbc;p=modules%2Fshaper.git Removed unused attributes from fillet. --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index afbd1407a..b5a802280 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -70,13 +70,6 @@ void SketchPlugin_ConstraintFillet::initAttributes() { data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttrList::typeId()); - AttributePtr aResultEdgesRefList = data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); // Used to store result edges. - AttributePtr aBasePointsRefAttrList = data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefAttrList::typeId()); // Used to store base points. - // Initialize attribute not applicable for user. - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_C()); - aResultEdgesRefList->setIsArgument(false); - aBasePointsRefAttrList->setIsArgument(false); } void SketchPlugin_ConstraintFillet::execute() @@ -96,9 +89,7 @@ void SketchPlugin_ConstraintFillet::execute() aData->attribute(SketchPlugin_Constraint::VALUE()))->value(); // Check the fillet result edges is not initialized yet. - AttributeRefListPtr aResultEdgesRefList = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Constraint::ENTITY_B())); - bool anIsNeedNewObjects = aResultEdgesRefList->size() == 0; + bool anIsNeedNewObjects = myResultEdges.size() == 0; // Wait all constraints being created, then send update events static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -106,6 +97,7 @@ void SketchPlugin_ConstraintFillet::execute() if (isUpdateFlushed) Events_Loop::loop()->setFlushed(anUpdateEvent, false); + std::list::iterator aResultEdgesIt = myResultEdges.begin(); for(int anIndex = 0; anIndex < aPointsRefList->size(); ++anIndex) { std::shared_ptr aFilletPoint2d = std::dynamic_pointer_cast(aPointsRefList->attribute(anIndex)); @@ -182,9 +174,9 @@ void SketchPlugin_ConstraintFillet::execute() aResultArc = sketch()->addFeature(SketchPlugin_Arc::ID()); } else { // Obtain features from the list. - aResultEdgeA = ModelAPI_Feature::feature(aResultEdgesRefList->object(anIndex * 3)); - aResultEdgeB = ModelAPI_Feature::feature(aResultEdgesRefList->object(anIndex * 3 + 1)); - aResultArc = ModelAPI_Feature::feature(aResultEdgesRefList->object(anIndex * 3 + 2)); + aResultEdgeA = *aResultEdgesIt++; + aResultEdgeB = *aResultEdgesIt++; + aResultArc = *aResultEdgesIt++; } // Calculate arc attributes @@ -204,7 +196,7 @@ void SketchPlugin_ConstraintFillet::execute() aStartAttr = SketchPlugin_Arc::START_ID(); aEndAttr = SketchPlugin_Arc::END_ID(); } else { // wrong argument - aResultEdgesRefList->clear(); + myResultEdges.clear(); setError("Error: One of the points has wrong coincide feature"); return; } @@ -291,9 +283,9 @@ void SketchPlugin_ConstraintFillet::execute() if(anIsNeedNewObjects) { // attach new arc to the list - aResultEdgesRefList->append(aResultEdgeA->lastResult()); - aResultEdgesRefList->append(aResultEdgeB->lastResult()); - aResultEdgesRefList->append(aResultArc->lastResult()); + myResultEdges.push_back(aResultEdgeA); + myResultEdges.push_back(aResultEdgeB); + myResultEdges.push_back(aResultArc); myProducedFeatures.push_back(aResultEdgeA); myProducedFeatures.push_back(aResultEdgeB); @@ -442,14 +434,10 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) } // Clear the list of fillet entities. - AttributeRefListPtr aResultEdgesRefList = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Constraint::ENTITY_B())); - aResultEdgesRefList->clear(); + myResultEdges.clear(); // Clear the list of base points. - AttributeRefAttrListPtr aBasePointsRefAttrList = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Constraint::ENTITY_C())); - aBasePointsRefAttrList->clear(); + myBasePoints.clear(); // Clear auxiliary flag on initial objects. std::list::const_iterator aFeatureIt; @@ -606,7 +594,7 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) // Store base point for fillet. aBasePoints.insert(aFilletPointAttr); - aBasePointsRefAttrList->append(aFilletPointAttr); + myBasePoints.push_back(aFilletPointAttr); // Get base lines for fillet. FeaturePtr anOldFeatureA, anOldFeatureB; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.h b/src/SketchPlugin/SketchPlugin_ConstraintFillet.h index 5865c0746..6a1dfa8f0 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.h @@ -58,9 +58,20 @@ class SketchPlugin_ConstraintFillet : public SketchPlugin_ConstraintBase /// \brief Use plugin manager for features creation SketchPlugin_ConstraintFillet(); + /// \return base points list; + SKETCHPLUGIN_EXPORT const std::list basePoints() const {return myBasePoints;}; + + /// \return base edges list; + SKETCHPLUGIN_EXPORT const std::list baseEdges() const {return myBaseEdges;}; + + /// \return result edges list; + SKETCHPLUGIN_EXPORT const std::list resultEdges() const {return myResultEdges;}; + private: - std::list myProducedFeatures; ///< list of constraints provided by the fillet + std::list myBasePoints; ///< list of base points std::list myBaseEdges; ///< list of objects the fillet is based + std::list myResultEdges; ///< list of result edges + std::list myProducedFeatures; ///< list of constraints provided by the fillet bool myListOfPointsChangedInCode; ///< flag to track that list of points changed in code bool myRadiusChangedByUser; ///< flag to track that radius changed by user bool myRadiusChangedInCode; ///< flag to track that radius changed in code diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 4fa4856f6..e3a42ecf1 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -10,6 +10,7 @@ #include "SketchPlugin_Circle.h" #include "SketchPlugin_ConstraintCoincidence.h" #include "SketchPlugin_ConstraintDistance.h" +#include "SketchPlugin_ConstraintFillet.h" #include "SketchPlugin_ConstraintRigid.h" #include "SketchPlugin_Line.h" #include "SketchPlugin_Point.h" @@ -35,6 +36,7 @@ #include #include +#include #include const double tolerance = 1.e-7; @@ -464,17 +466,15 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut return false; } - FeaturePtr aFilletFeature = std::dynamic_pointer_cast(theAttribute->owner()); + std::shared_ptr aFilletFeature = std::dynamic_pointer_cast(theAttribute->owner()); AttributeRefAttrListPtr aPointsRefList = std::dynamic_pointer_cast(theAttribute); if(aPointsRefList->size() == 0) { theError = "Error: List of points is empty."; return false; } - AttributeRefAttrListPtr aBasePointsRefList = std::dynamic_pointer_cast( - aFilletFeature->attribute(SketchPlugin_Constraint::ENTITY_C())); - AttributeRefListPtr aResultEdgesRefList = std::dynamic_pointer_cast( - aFilletFeature->attribute(SketchPlugin_Constraint::ENTITY_B())); + std::list aBasePointsList = aFilletFeature->basePoints(); + std::list aResultEdgesList = aFilletFeature->resultEdges(); std::list> aPointsList = aPointsRefList->list(); for(std::list>::const_iterator aPointsIt = aPointsList.cbegin(); aPointsIt != aPointsList.cend(); aPointsIt++) { @@ -485,16 +485,18 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut // If we alredy have some result then: // - if it is the same point all ok, just skip it // - if it is point on the fillet arc then it is not valid - if(aBasePointsRefList->size() > 0) { - if(aBasePointsRefList->isInList(aPointAttribute)) { + if(!aBasePointsList.empty()) { + if(std::find(aBasePointsList.begin(), aBasePointsList.end(), aPointAttribute) != aBasePointsList.end()) { continue; } // Check that selected point not on the one of the result fillet arc. - for(int anIndex = 0; anIndex < aBasePointsRefList->size(); anIndex++) { - if(aResultEdgesRefList->size() > 0) { + std::list::iterator aResultEdgesIt = aResultEdgesList.begin(); + for(unsigned int anIndex = 0; anIndex < aBasePointsList.size(); anIndex++) { + if(aResultEdgesList.size() > 0) { FeaturePtr aResultArc; - aResultArc = ModelAPI_Feature::feature(aResultEdgesRefList->object(anIndex * 3 + 2)); + std::advance(aResultEdgesIt, 2); + aResultArc = *aResultEdgesIt++; AttributePtr anArcStart = aResultArc->attribute(SketchPlugin_Arc::START_ID()); AttributePtr anArcEnd = aResultArc->attribute(SketchPlugin_Arc::END_ID()); std::shared_ptr anArcStartPnt = std::dynamic_pointer_cast(anArcStart)->pnt();