1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
20 #include <boost/shared_ptr.hpp>
22 #include "SMESHGUI_GEOMGenUtils.h"
23 #include "SMESHGUI_Utils.h"
25 #include <GeometryGUI.h>
27 #include <SALOMEDSClient_SObject.hxx>
28 #include <SALOMEDSClient_ChildIterator.hxx>
29 #include <SALOMEDS_SObject.hxx>
31 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
36 GEOM::GEOM_Gen_var GetGEOMGen()
38 static GEOM::GEOM_Gen_var aGEOMGen;
40 if(CORBA::is_nil(aGEOMGen))
41 aGEOMGen = GeometryGUI::GetGeomGen();
45 GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh)
47 SALOMEDS_SObject* aMeshOrSubmesh = _CAST(SObject,theMeshOrSubmesh);
49 CORBA::Object_var Obj = aMeshOrSubmesh->GetObject();
50 if ( !CORBA::is_nil( Obj ) ) {
51 SMESH::SMESH_Mesh_var aMesh =
52 SObjectToInterface<SMESH::SMESH_Mesh>( theMeshOrSubmesh );
53 if ( !aMesh->_is_nil() )
54 return aMesh->GetShapeToMesh();
55 SMESH::SMESH_subMesh_var aSubmesh =
56 SObjectToInterface<SMESH::SMESH_subMesh>( theMeshOrSubmesh );
57 if ( !aSubmesh->_is_nil() )
58 return aSubmesh->GetSubShape();
61 return GEOM::GEOM_Object::_nil();
64 GEOM::GEOM_Object_ptr GetGeom (_PTR(SObject) theSO)
67 return GEOM::GEOM_Object::_nil();
69 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
71 return GEOM::GEOM_Object::_nil();
73 _PTR(ChildIterator) anIter (aStudy->NewChildIterator(theSO));
74 for (; anIter->More(); anIter->Next()) {
75 _PTR(SObject) aSObject = anIter->Value();
76 _PTR(SObject) aRefSOClient;
77 GEOM::GEOM_Object_var aMeshShape;
79 if (aSObject->ReferencedObject(aRefSOClient)) {
80 SALOMEDS_SObject* aRefSO = _CAST(SObject,aRefSOClient);
81 aMeshShape = GEOM::GEOM_Object::_narrow(aRefSO->GetObject());
83 SALOMEDS_SObject* aSO = _CAST(SObject,aSObject);
84 aMeshShape = GEOM::GEOM_Object::_narrow(aSO->GetObject());
87 if (!aMeshShape->_is_nil())
88 return aMeshShape._retn();
90 return GEOM::GEOM_Object::_nil();