From: mpv Date: Tue, 30 Jun 2015 13:13:43 +0000 (+0300) Subject: Speed-up of unit test snowflake: working in sketch with the high number of simple... X-Git-Tag: V_1.3.0~148 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=121bd3159b5213d42221e7396dc779defa5a24a9;p=modules%2Fshaper.git Speed-up of unit test snowflake: working in sketch with the high number of simple (not constrained) objects. --- diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index b7719ca78..d8b6fc005 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -88,6 +88,26 @@ list Model_AttributeRefList::list() return aResult; } +bool Model_AttributeRefList::isInList(const ObjectPtr& theObj) +{ + std::list aResult; + std::shared_ptr aDoc = std::dynamic_pointer_cast( + owner()->document()); + if (aDoc) { + std::shared_ptr aData = std::dynamic_pointer_cast(theObj->data()); + if (aData.get()) { + TDF_Label anObjLab = aData->label().Father(); + const TDF_LabelList& aList = myRef->List(); + for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { + if (aLIter.Value().IsEqual(anObjLab)) { + return true; + } + } + } + } + return false; +} + ObjectPtr Model_AttributeRefList::object(const int theIndex) const { std::shared_ptr aDoc = std::dynamic_pointer_cast( diff --git a/src/Model/Model_AttributeRefList.h b/src/Model/Model_AttributeRefList.h index 1b2c861be..778b6956d 100644 --- a/src/Model/Model_AttributeRefList.h +++ b/src/Model/Model_AttributeRefList.h @@ -38,6 +38,9 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList /// Returns the list of features MODEL_EXPORT virtual std::list list(); + /// Returns true if the object is in list + MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj); + /// Returns the list of features MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const; diff --git a/src/ModelAPI/ModelAPI_AttributeRefList.h b/src/ModelAPI/ModelAPI_AttributeRefList.h index 37e9f68de..8b556d595 100644 --- a/src/ModelAPI/ModelAPI_AttributeRefList.h +++ b/src/ModelAPI/ModelAPI_AttributeRefList.h @@ -43,6 +43,9 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute /// Returns the list of features MODELAPI_EXPORT virtual std::list list() = 0; + /// Returns true if the object is in list + MODELAPI_EXPORT virtual bool isInList(const ObjectPtr& theObj) = 0; + /// Returns the referenced object by the zero-based index MODELAPI_EXPORT virtual ObjectPtr object(const int theIndex) const = 0; diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 1b97f5634..4c957c648 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -184,11 +184,7 @@ bool SketchPlugin_Sketch::isSub(ObjectPtr theObject) const aFeature = document()->feature(aRes); } if (aFeature) { - list aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list(); - for(list::iterator aSubIt = aSubs.begin(); aSubIt != aSubs.end(); aSubIt++) { - if (*aSubIt == aFeature) - return true; - } + return data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->isInList(aFeature); } return false; }