Also, the regression of the issue #359 is corrected[Axis with the same point on both ends]
AttributeSelectionPtr aSelectionAttribute =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
GeomShapePtr aShape = aSelectionAttribute->value();
+ if (!aShape.get()) {
+ ResultPtr aResult = aSelectionAttribute->context();
+ if (aResult.get())
+ aShape = aResult->shape();
+ }
std::string aCurrentAttributeId = theAttribute->id();
// get all feature attributes
AttributePtr anAttribute = *anAttr;
// take into concideration only other attributes
if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) {
- AttributeSelectionPtr aSelectionAttribute =
+ aSelectionAttribute =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
// the shape of the attribute should be not the same
- if (aSelectionAttribute.get() != NULL && aShape->isEqual(aSelectionAttribute->value())) {
- return false;
+ if (aSelectionAttribute.get() != NULL) {
+ GeomShapePtr anAttrShape = aSelectionAttribute->value();
+ if (!anAttrShape.get()) {
+ ResultPtr aResult = aSelectionAttribute->context();
+ if (aResult.get())
+ anAttrShape = aResult->shape();
+ }
+ if (aShape->isEqual(anAttrShape)) {
+ return false;
+ }
}
}
}
}
}
}
- return !featureHasReferences(theAttribute);
-}
-
-bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& theAttribute) const
-{
- std::list<std::pair<std::string, std::list<ObjectPtr> > > allRefs;
- if (theAttribute->owner().get() && theAttribute->owner()->data()->isValid())
- theAttribute->owner()->data()->referencesToObjects(allRefs);
- // collect object referenced by theAttribute
- std::list<ObjectPtr>* anAttrObjs = 0;
- std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRefIter = allRefs.begin();
- for(; aRefIter != allRefs.end(); aRefIter++) {
- if (theAttribute->id() == aRefIter->first)
- anAttrObjs = &(aRefIter->second);
- }
- if (!anAttrObjs || anAttrObjs->empty())
- return false; // theAttribute does not references to anything
- // check with all others
- for(aRefIter = allRefs.begin(); aRefIter != allRefs.end(); aRefIter++) {
- if (theAttribute->id() == aRefIter->first)
- continue; // do not check with myself
- std::list<ObjectPtr>::iterator aReferenced = aRefIter->second.begin();
- for(; aReferenced != aRefIter->second.end(); aReferenced++) {
- std::list<ObjectPtr>::iterator aReferencedByMe = anAttrObjs->begin();
- for(; aReferencedByMe != anAttrObjs->end(); aReferencedByMe++) {
- if (*aReferenced == *aReferencedByMe) // found same objects!
- return true;
- }
- }
- }
- return false;
+ return true;
}
bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const;
-
-protected:
- //! Checks whethe other feature attributes has a reference to the given attribute
- //! \param theAttribute a source attribute to find object
- //! \return a boolean value
- bool featureHasReferences(const AttributePtr& theAttribute) const;
};
/**