void Model_Document::updateHistory(const std::shared_ptr<ModelAPI_Object> theObject)
{
- myObjs->updateHistory(theObject);
+ if (myObjs)
+ myObjs->updateHistory(theObject);
}
void Model_Document::updateHistory(const std::string theGroup)
{
- myObjs->updateHistory(theGroup);
+ if (myObjs)
+ myObjs->updateHistory(theGroup);
}
const std::set<int> Model_Document::subDocuments() const
return TDF_LabelMapHasher::IsEqual(theLab1, theLab2);
}
-// searches in this document feature that contains this label
FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) {
TDF_Label aCurrentLab = theLab;
while(aCurrentLab.Depth() > 3)
return myObjs->feature(aCurrentLab);
}
+ResultPtr Model_Document::resultByLab(const TDF_Label& theLab)
+{
+ TDF_Label aCurrentLab = theLab;
+ while(aCurrentLab.Depth() > 3) {
+ ObjectPtr aResultObj = myObjs->object(aCurrentLab);
+ if (aResultObj.get()) {
+ return std::dynamic_pointer_cast<ModelAPI_Result>(aResultObj); // this may be null if feature
+ }
+ aCurrentLab = aCurrentLab.Father();
+ }
+ return ResultPtr(); // not found
+}
+
+
void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName)
{
std::map<std::string, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theName);
if (!aRefFeat.get()) { // take feature of the result
aRefFeat = feature(std::dynamic_pointer_cast<ModelAPI_Result>(aRefObj));
}
- if (aRefFeat.get() && aRefFeat == theThis) {
- return false; // other references to this, so this later than other
+ if (aRefFeat.get()) {
+ if (aRefFeat == theThis)
+ return false; // other references to this, so other later than this
+ if (std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aRefFeat)) {
+ if (!isLaterByDep(theThis, aRefFeat)) // nested composites: recursion
+ return false;
+ }
}
}
}
std::string aName = theName;
ResultPtr aRes = myObjs->findByName(aName);
theUniqueContext = !(aRes.get() && myNamingNames.find(aName) != myNamingNames.end());
- while(!aRes.get() && aName[0] == '_') { // this may be thecontext with the history index
+ while(!aRes.get() && aName[0] == '_') { // this may be theContext with the history index
aNumInHistory++;
aName = aName.substr(1);
aRes = myObjs->findByName(aName);