} else {
// it may be a folder
- ObjectPtr aFolder = folder(aRefs->Value(a));
+ const ObjectPtr& aFolder = folder(aRefs->Value(a));
if (aFolder.get()) {
// store folder information for the Features group only
if (isFeature || isFolder) {
}
}
-ObjectPtr Model_Objects::folder(TDF_Label theLabel) const
+const ObjectPtr& Model_Objects::folder(TDF_Label theLabel) const
{
if (myFolders.IsBound(theLabel))
return myFolders.Find(theLabel);
- return ObjectPtr();
+ static ObjectPtr anEmptyResult;
+ return anEmptyResult;
}
FeaturePtr Model_Objects::feature(TDF_Label theLabel) const
continue;
}
- aFoundFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(folder(aCurLabel));
- if (aFoundFolder) {
+ const ObjectPtr& aFolderObj = folder(aCurLabel);
+ if (aFolderObj.get()) {
+ aFoundFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aFolderObj);
AttributeReferencePtr aLastFeatAttr =
aFoundFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID());
if (aLastFeatAttr) {
if (aFoundFolder) {
if (isSkippedFeature(theFeature)) {
theIndexInFolder = -1;
- return false;
+ return FolderPtr();
}
// decrease the index of the feature in the folder by the number of skipped features
for (int anIndex = theIndexInFolder - 1; anIndex > 0; anIndex--) {
if (!aFoundFolder) {
// if the current label refers to a folder, feel all necessary data
- aFoundFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(folder(aCurLabel));
- if (aFoundFolder) {
+ const ObjectPtr& aFolderObj = folder(aCurLabel);
+ if (aFolderObj.get()) {
+ aFoundFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aFolderObj);
theIndexInFolder = -1;
AttributeReferencePtr aLastRef =
std::string& theParentName) const;
/// Return object representing a folder or empty pointer
- ObjectPtr folder(TDF_Label theLabel) const;
+ const ObjectPtr& folder(TDF_Label theLabel) const;
private:
TDF_Label myMain; ///< main label of the data storage
ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
{
ObjectPtr anObject;
- foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
- AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
+ ResultToAISMap::const_iterator aMapIter = myResult2AISObjectMap.cbegin();
+ for (; aMapIter != myResult2AISObjectMap.cend(); aMapIter++) {
+ const AISObjectPtr& aAIS = aMapIter.value();
Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
if (anAIS == theIO)
- anObject = anObj;
+ anObject = aMapIter.key();
if (anObject.get())
break;
}