Salome HOME
Merge of NPAL16812 from 3.x to 4.x
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GEOMGenUtils.cxx
index c9ffc82e620bc008314a4addd506c7d7b7b76fd1..2537452c659e9214694ab256cd31c9c8e78a553b 100644 (file)
@@ -15,7 +15,7 @@
 //  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>
 
@@ -37,8 +37,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 +92,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();
+  }
 }