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 if ( GeometryGUI::GetGeomGen()->_is_nil() )
42 GeometryGUI::InitGeomGen();
43 aGEOMGen = GeometryGUI::GetGeomGen();
48 GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh)
50 SALOMEDS_SObject* aMeshOrSubmesh = _CAST(SObject,theMeshOrSubmesh);
52 CORBA::Object_var Obj = aMeshOrSubmesh->GetObject();
53 if ( !CORBA::is_nil( Obj ) ) {
54 SMESH::SMESH_Mesh_var aMesh =
55 SObjectToInterface<SMESH::SMESH_Mesh>( theMeshOrSubmesh );
56 if ( !aMesh->_is_nil() )
57 return aMesh->GetShapeToMesh();
58 SMESH::SMESH_subMesh_var aSubmesh =
59 SObjectToInterface<SMESH::SMESH_subMesh>( theMeshOrSubmesh );
60 if ( !aSubmesh->_is_nil() )
61 return aSubmesh->GetSubShape();
64 return GEOM::GEOM_Object::_nil();
67 GEOM::GEOM_Object_ptr GetGeom (_PTR(SObject) theSO)
70 return GEOM::GEOM_Object::_nil();
72 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
74 return GEOM::GEOM_Object::_nil();
76 _PTR(ChildIterator) anIter (aStudy->NewChildIterator(theSO));
77 for (; anIter->More(); anIter->Next()) {
78 _PTR(SObject) aSObject = anIter->Value();
79 _PTR(SObject) aRefSOClient;
80 GEOM::GEOM_Object_var aMeshShape;
82 if (aSObject->ReferencedObject(aRefSOClient)) {
83 SALOMEDS_SObject* aRefSO = _CAST(SObject,aRefSOClient);
84 aMeshShape = GEOM::GEOM_Object::_narrow(aRefSO->GetObject());
86 SALOMEDS_SObject* aSO = _CAST(SObject,aSObject);
87 aMeshShape = GEOM::GEOM_Object::_narrow(aSO->GetObject());
90 if (!aMeshShape->_is_nil())
91 return aMeshShape._retn();
93 return GEOM::GEOM_Object::_nil();