]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Get sub-objects recursively. Miss sub-object if it is in 'selected' list.
authorakl <alexander.kovalev@opencascade.com>
Mon, 23 Jun 2014 14:12:26 +0000 (18:12 +0400)
committerakl <alexander.kovalev@opencascade.com>
Mon, 23 Jun 2014 14:12:26 +0000 (18:12 +0400)
src/GEOM_I/GEOM_Gen_i.cc
src/GEOM_I/GEOM_Gen_i.hh

index 7fa57d213f46171710e44f9f57230d6f28872d81..9742087c284700a3e098883e42f1a1ce43453a60 100755 (executable)
@@ -3238,7 +3238,7 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy,
 
       if ( aSelected.count( anEntry ) > 0 &&
            aParents.count( anEntry ) == 0 ) {
-        getParentDependencies( geomObj, aSelected, aParents, aChildren, anOthers );
+        includeParentDependencies( geomObj, aSelected, aParents, aChildren, anOthers );
       } else if ( aParents.count( anEntry ) == 0 && 
                   aChildren.count( anEntry ) == 0 ) {
         anOthers.insert( geomObj->GetEntry() );
@@ -3252,32 +3252,7 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy,
 
     // filling list of sub-objects
     for ( it = aSelected.begin(); it != aSelected.end(); ++it ) {
-      Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), (*it).c_str(), false);
-      if ( handle_object.IsNull() )
-        continue;
-
-      Handle(GEOM_Function) aShapeFun = handle_object->GetFunction(1);
-      if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() )
-        continue;
-
-      const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences();
-      if ( aListEntries.IsEmpty() )
-        continue;
-
-      TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
-      for ( ; anIt.More(); anIt.Next() ) {
-        TCollection_ExtendedString aSubEntry = anIt.Value();
-        Standard_Integer aStrLen = aSubEntry.LengthOfCString();
-        char* aSubEntryStr = new char[aStrLen+1];
-        aSubEntry.ToUTF8CString( aSubEntryStr );
-        foundIt = aParents.find( aSubEntryStr );
-        if ( foundIt == aParents.end() ) { // add to sub-objects if it is not in parents list
-          aChildren.insert( aSubEntryStr );
-          foundIt = anOthers.find( aSubEntryStr );
-          if ( foundIt != anOthers.end() )
-            anOthers.erase( foundIt );
-        }
-      }
+      includeSubObjects( theStudy, *it, aSelected, aParents, aChildren, anOthers );
     }
 
     // if some selected object is not a main shape,
@@ -3332,11 +3307,15 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy,
   }
 }
 
-void GEOM_Gen_i::getParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
-                                      std::set<std::string>& aSelected,
-                                      std::set<std::string>& aParents,
-                                      std::set<std::string>& aChildren,
-                                      std::set<std::string>& anOthers)
+//==============================================================================
+// function : includeParentDependencies
+// purpose  : 
+//==============================================================================
+void GEOM_Gen_i::includeParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
+                                          std::set<std::string>& aSelected,
+                                          std::set<std::string>& aParents,
+                                          std::set<std::string>& aChildren,
+                                          std::set<std::string>& anOthers)
 {
   std::string anEntry = geomObj->GetEntry();
   if ( aSelected.count( anEntry ) == 0 ) {
@@ -3363,10 +3342,53 @@ void GEOM_Gen_i::getParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
         aParents.count( aDepEntry ) > 0     // skip already processed objects
         )
       continue;
-    getParentDependencies( depList[i], aSelected, aParents, aChildren, anOthers );
+    includeParentDependencies( depList[i], aSelected, aParents, aChildren, anOthers );
   }
 }
 
+//==============================================================================
+// function : includeSubObjects
+// purpose  : 
+//==============================================================================
+void GEOM_Gen_i::includeSubObjects(SALOMEDS::Study_ptr theStudy,
+                                  const std::string& aSelectedEntry,
+                                  std::set<std::string>& aSelected,
+                                  std::set<std::string>& aParents,
+                                  std::set<std::string>& aChildren,
+                                  std::set<std::string>& anOthers)
+{
+  std::set<std::string>::iterator foundIt;
+  Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), aSelectedEntry.c_str(), false);
+  if ( handle_object.IsNull() )
+    return;
+
+  Handle(GEOM_Function) aShapeFun = handle_object->GetFunction(1);
+  if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() )
+    return;
+
+  const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences();
+  if ( aListEntries.IsEmpty() )
+    return;
+
+  TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
+  for ( ; anIt.More(); anIt.Next() ) {
+    TCollection_ExtendedString aSubEntry = anIt.Value();
+    Standard_Integer aStrLen = aSubEntry.LengthOfCString();
+    char* aSubEntryStr = new char[aStrLen+1];
+    aSubEntry.ToUTF8CString( aSubEntryStr );
+    foundIt = aParents.find( aSubEntryStr );
+    if ( foundIt == aParents.end() ) { // add to sub-objects if it is not in parents list
+      foundIt = aSelected.find( aSubEntryStr );
+      if ( foundIt == aSelected.end() ) { // add to sub-objects if it is not in selected list
+           aChildren.insert( aSubEntryStr );
+           foundIt = anOthers.find( aSubEntryStr );
+           if ( foundIt != anOthers.end() )
+             anOthers.erase( foundIt );
+      }
+    }
+    includeSubObjects( theStudy, aSubEntryStr, aSelected, aParents, aChildren, anOthers );
+  }
+}
 //=====================================================================================
 // EXPORTED METHODS
 //=====================================================================================
index 27242fe5bd9c8a1cce1973f12fe0ebb45a43f07f..7d074fa818b12a638cefbdf2ef7f0b5f36fe8a2f 100644 (file)
@@ -391,11 +391,18 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
                              std::map< std::string, std::set<std::string> > &passedEntries,
                               int level = 0 );
 
-  void getParentDependencies(GEOM::GEOM_BaseObject_ptr gbo,
-                            std::set<std::string>& aSelected,
-                            std::set<std::string>& aParents, 
-                            std::set<std::string>& aChildren, 
-                            std::set<std::string>& anOthers);
+  void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo,
+                                std::set<std::string>& aSelected,
+                                std::set<std::string>& aParents, 
+                                std::set<std::string>& aChildren, 
+                                std::set<std::string>& anOthers);
+
+  void includeSubObjects(SALOMEDS::Study_ptr theStudy,
+                        const std::string& aSelectedEntry,
+                        std::set<std::string>& aSelected,
+                        std::set<std::string>& aParents, 
+                        std::set<std::string>& aChildren, 
+                        std::set<std::string>& anOthers);
 
  private: