Salome HOME
0020145: EDF 666 SMESH: Modifications of GEOM groups are not taken into account
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GEOMGenUtils.cxx
index c9ffc82e620bc008314a4addd506c7d7b7b76fd1..77c0608aeb3f637d71efed5041aabcf45d866c7e 100644 (file)
@@ -1,4 +1,6 @@
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
 //  This library is free software; you can redistribute it and/or
@@ -15,8 +17,8 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 #include <boost/shared_ptr.hpp>
 
 #include "SMESHGUI_GEOMGenUtils.h"
@@ -37,8 +39,11 @@ namespace SMESH {
   {
     static GEOM::GEOM_Gen_var aGEOMGen;
 
-    if(CORBA::is_nil(aGEOMGen))
-        aGEOMGen = GeometryGUI::GetGeomGen();
+    if(CORBA::is_nil(aGEOMGen)) {
+      if ( GeometryGUI::GetGeomGen()->_is_nil() )
+        GeometryGUI::InitGeomGen();
+      aGEOMGen = GeometryGUI::GetGeomGen();
+    }
     return aGEOMGen;
   }
 
@@ -89,4 +94,18 @@ namespace SMESH {
     }
     return GEOM::GEOM_Object::_nil();
   }
+
+  GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape,
+                                     long                  theID)
+  {
+    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+    if (!aStudy || geomGen->_is_nil())
+      return GEOM::GEOM_Object::_nil();
+    GEOM::GEOM_IShapesOperations_var aShapesOp = geomGen->GetIShapesOperations(aStudy->StudyId());
+    if (aShapesOp->_is_nil())
+      return GEOM::GEOM_Object::_nil();
+    GEOM::GEOM_Object_var subShape = aShapesOp->GetSubShape (theMainShape,theID);
+    return subShape._retn();
+  }
 }