Salome HOME
Speed-up of unit test snowflake: working in sketch with the high number of simple...
authormpv <mpv@opencascade.com>
Tue, 30 Jun 2015 13:13:43 +0000 (16:13 +0300)
committermpv <mpv@opencascade.com>
Tue, 30 Jun 2015 13:13:43 +0000 (16:13 +0300)
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeRefList.h
src/SketchPlugin/SketchPlugin_Sketch.cpp

index b7719ca78f5011e5b4b32980831b452729c773f8..d8b6fc005b78c003477ec1c846ca3592513034b1 100644 (file)
@@ -88,6 +88,26 @@ list<ObjectPtr> Model_AttributeRefList::list()
   return aResult;
 }
 
+bool Model_AttributeRefList::isInList(const ObjectPtr& theObj)
+{
+  std::list<ObjectPtr> aResult;
+  std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+      owner()->document());
+  if (aDoc) {
+    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(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<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
index 1b2c861be2a5a7d04dce3270a491077e1ba52651..778b6956de8edecf26652514a6c217873e6312a8 100644 (file)
@@ -38,6 +38,9 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList
   /// Returns the list of features
   MODEL_EXPORT virtual std::list<ObjectPtr> 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;
 
index 37e9f68de6b1a8a51d85cadfa2d35012da463b04..8b556d595159f22cd120776738ad14bcb80b959d 100644 (file)
@@ -43,6 +43,9 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute
   /// Returns the list of features
   MODELAPI_EXPORT virtual std::list<ObjectPtr> 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;
 
index 1b97f5634a0bd4a3c1db14989ac38030bc4f80cb..4c957c648792db67f8cee6994e6e9c1687c637b6 100644 (file)
@@ -184,11 +184,7 @@ bool SketchPlugin_Sketch::isSub(ObjectPtr theObject) const
       aFeature = document()->feature(aRes);
   }
   if (aFeature) {
-    list<ObjectPtr> aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
-    for(list<ObjectPtr>::iterator aSubIt = aSubs.begin(); aSubIt != aSubs.end(); aSubIt++) {
-      if (*aSubIt == aFeature)
-        return true;
-    }
+    return data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->isInList(aFeature);
   }
   return false;
 }