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>(
/// 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;
/// 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;
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;
}