--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Created : mar mai 21 09:12:43 CEST 2002
+# Author : Paul RASCLE, EDF
+# Project : SALOME
+# Copyright : EDF 2002
+# $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
+
+
+@COMMENCE@
+
+EXPORT_PYSCRIPTS = smeshpy.py SMESH_test.py
+
+# Libraries targets
+
+LIB= libSMESHEngine.la
+
+LIB_SRC = SMESH_Gen_i.cxx SMESH_Mesh_i.cxx SMESH_MEDMesh_i.cxx \
+ SMESH_MEDFamily_i.cxx SMESH_MEDSupport_i.cxx \
+ SMESH_subMesh_i.cxx \
+ SMESH_MeshEditor_i.cxx \
+ SMESH_Hypothesis_i.cxx \
+ SMESH_topo.cxx SMESH_HypothesisFactory_i.cxx \
+ SMESH_Algo_i.cxx \
+ SMESH_1D_Algo_i.cxx \
+ SMESH_2D_Algo_i.cxx \
+ SMESH_3D_Algo_i.cxx \
+ SMESH_NumberOfSegments_i.cxx \
+ SMESH_LocalLength_i.cxx \
+ SMESH_MaxElementArea_i.cxx \
+ SMESH_MaxElementVolume_i.cxx \
+ SMESH_Regular_1D_i.cxx \
+ SMESH_Quadrangle_2D_i.cxx \
+ SMESH_MEFISTO_2D_i.cxx \
+ SMESH_Hexa_3D_i.cxx
+
+LIB_SERVER_IDL = SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Mesh.idl \
+ SALOME_Component.idl SALOME_Exception.idl \
+ SMESH_BasicHypothesis.idl
+
+LIB_CLIENT_IDL = SALOMEDS.idl GEOM_Gen.idl GEOM_Shape.idl MED.idl SALOMEDS_Attributes.idl
+
+# Executables targets
+BIN =
+BIN_SRC =
+
+# additionnal information to compil and link file
+CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+
+#IDLCXXFLAGS+= -Wbtp
+
+LDFLAGS+= $(OCC_LIBS) $(HDF5_LIBS) $(MED2_LIBS) -lSMESHimpl -lSalomeContainer -lSalomeNS -lSalomeDS -lRegistry -lSalomeHDFPersist -lOpUtil -lGeometryClient -lSMESHDS -lSMDS -lMEFISTO2D -lMeshDriverMED -lSalomeLifeCycleCORBA
+
+@CONCLUDE@
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_1D_Algo_i.cxx
+// Created : sam mai 18 09:23:13 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_1D_Algo_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_1D_Algo_i::SMESH_1D_Algo_i()
+{
+ MESSAGE("SMESH_1D_Algo_i::SMESH_1D_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_1D_Algo_i::~SMESH_1D_Algo_i()
+{
+ MESSAGE("SMESH_1D_Algo_i::~SMESH_1D_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_1D_Algo_i::SetImpl(::SMESH_1D_Algo* impl)
+{
+ MESSAGE("SMESH_1D_Algo_i::SetImpl");
+ SMESH_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_1D_Algo_i.hxx
+// Created : sam mai 18 09:23:09 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_1D_ALGO_I_HXX_
+#define _SMESH_1D_ALGO_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+
+#include "SMESH_Algo_i.hxx"
+
+#include "SMESH_1D_Algo.hxx"
+
+class SMESH_1D_Algo_i:
+ public POA_SMESH::SMESH_1D_Algo,
+ public SMESH_Algo_i
+{
+public:
+ SMESH_1D_Algo_i();
+
+ virtual ~SMESH_1D_Algo_i();
+
+protected:
+ virtual void SetImpl(::SMESH_1D_Algo* impl);
+
+ ::SMESH_1D_Algo* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_2D_Algo_i.cxx
+// Created : sam mai 18 09:23:51 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_2D_Algo_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_2D_Algo_i::SMESH_2D_Algo_i()
+{
+ MESSAGE("SMESH_2D_Algo_i::SMESH_2D_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_2D_Algo_i::~SMESH_2D_Algo_i()
+{
+ MESSAGE("SMESH_2D_Algo_i::~SMESH_2D_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_2D_Algo_i::SetImpl(::SMESH_2D_Algo* impl)
+{
+ MESSAGE("SMESH_2D_Algo_i::SetImpl");
+ SMESH_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_2D_Algo_i.hxx
+// Created : sam mai 18 09:23:57 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_2D_ALGO_I_HXX_
+#define _SMESH_2D_ALGO_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+
+#include "SMESH_Algo_i.hxx"
+
+#include "SMESH_2D_Algo.hxx"
+
+class SMESH_2D_Algo_i:
+ public POA_SMESH::SMESH_2D_Algo,
+ public SMESH_Algo_i
+{
+public:
+ SMESH_2D_Algo_i();
+
+ virtual ~SMESH_2D_Algo_i();
+
+protected:
+ virtual void SetImpl(::SMESH_2D_Algo* impl);
+
+ ::SMESH_2D_Algo* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_3D_Algo_i.cxx
+// Created : sam mai 18 09:25:00 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_3D_Algo_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_3D_Algo_i::SMESH_3D_Algo_i()
+{
+ MESSAGE("SMESH_3D_Algo_i::SMESH_3D_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_3D_Algo_i::~SMESH_3D_Algo_i()
+{
+ MESSAGE("SMESH_3D_Algo_i::~SMESH_3D_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_3D_Algo_i::SetImpl(::SMESH_3D_Algo* impl)
+{
+ MESSAGE("SMESH_3D_Algo_i::SetImpl");
+ SMESH_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_3D_Algo_i.hxx
+// Created : sam mai 18 09:25:05 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_3D_ALGO_I_HXX_
+#define _SMESH_3D_ALGO_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+
+#include "SMESH_Algo_i.hxx"
+
+class SMESH_3D_Algo;
+
+class SMESH_3D_Algo_i:
+ public POA_SMESH::SMESH_3D_Algo,
+ public SMESH_Algo_i
+{
+public:
+ SMESH_3D_Algo_i();
+
+ virtual ~SMESH_3D_Algo_i();
+
+protected:
+ virtual void SetImpl(::SMESH_3D_Algo* impl);
+
+ ::SMESH_3D_Algo* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Algo_i.cxx
+// Created : sam mai 18 09:21:02 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Algo_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+#include <string>
+#include <vector>
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Algo_i::SMESH_Algo_i()
+{
+ MESSAGE("SMESH_Algo_i::SMESH_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Algo_i::~SMESH_Algo_i()
+{
+ MESSAGE("SMESH_Algo_i::~SMESH_Algo_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::ListOfHypothesisName* SMESH_Algo_i::GetCompatibleHypothesis()
+{
+ MESSAGE("SMESH_Algo_i::GetCompatibleHypothesis");
+ SMESH::ListOfHypothesisName_var listOfHypothesis
+ = new SMESH::ListOfHypothesisName;
+ const vector<string> & hypList = _impl->GetCompatibleHypothesis();
+ int nbHyp = hypList.size();
+ listOfHypothesis->length(nbHyp);
+ for (int i=0; i<nbHyp; i++)
+ {
+ listOfHypothesis[i] = hypList[i].c_str();
+ }
+ return listOfHypothesis._retn();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Algo_i::SetImpl(::SMESH_Algo* impl)
+{
+ MESSAGE("SMESH_Algo_i::SetImpl");
+ //SMESH_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Algo_i.hxx
+// Created : sam mai 18 09:21:09 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_ALGO_I_HXX_
+#define _SMESH_ALGO_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+
+#include "SMESH_Hypothesis_i.hxx"
+
+#include "SMESH_Algo.hxx"
+
+class SMESH_Algo_i:
+ public POA_SMESH::SMESH_Algo,
+ public SMESH_Hypothesis_i
+{
+public:
+ SMESH_Algo_i();
+
+ virtual ~SMESH_Algo_i();
+
+ SMESH::ListOfHypothesisName* GetCompatibleHypothesis();
+
+protected:
+ virtual void SetImpl(::SMESH_Algo* impl);
+
+ ::SMESH_Algo* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Gen_i.cxx
+// Created : lun mai 6 13:41:35 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_CompSolid.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <gp_Pnt.hxx>
+#include <BRep_Tool.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <fstream>
+#include <stdio.h>
+
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_Mesh_i.hxx"
+#include "SMESH_LocalLength_i.hxx"
+#include "SMESH_NumberOfSegments_i.hxx"
+#include "SMESH_MaxElementArea_i.hxx"
+
+#include "SMESHDS_Document.hxx"
+
+#include "Document_Reader.h"
+#include "DriverMED_W_SMESHDS_Mesh.h"
+#include "DriverMED_R_SMESHDS_Mesh.h"
+#include "DriverMED_R_SMESHDS_Document.h"
+#include "DriverUNV_R_SMESHDS_Document.h"
+#include "DriverDAT_R_SMESHDS_Document.h"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+#include "SALOMEDS_Tool.hxx"
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
+
+//#include <TopAbs_ShapeEnum.hxx>
+
+#include "GEOM_Client.hxx"
+
+#include <map>
+
+#define NUM_TMP_FILES 4
+
+// Tags definition
+long Tag_HypothesisRoot = 1;
+long Tag_AlgorithmsRoot = 2;
+
+long Tag_RefOnShape = 1;
+long Tag_RefOnAppliedHypothesis = 2;
+long Tag_RefOnAppliedAlgorithms = 3;
+
+long Tag_SubMeshOnVertex = 4;
+long Tag_SubMeshOnEdge = 5;
+long Tag_SubMeshOnFace = 6;
+long Tag_SubMeshOnSolid = 7;
+long Tag_SubMeshOnCompound = 8;
+
+
+//=============================================================================
+/*!
+ * default constructor: not for use
+ */
+//=============================================================================
+
+SMESH_Gen_i::SMESH_Gen_i()
+{
+ MESSAGE("SMESH_Gen_i default constructor");
+ // ****
+}
+
+//=============================================================================
+/*!
+ * Standard constructor, used with Container.
+ */
+//=============================================================================
+
+SMESH_Gen_i::SMESH_Gen_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName) :
+ Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
+{
+ MESSAGE("activate object");
+ _thisObj = this ;
+ _id = _poa->activate_object(_thisObj);
+
+ _ShapeReader = NULL;
+ _localId = 0; // number of created objects & local id
+
+}
+
+//=============================================================================
+/*!
+ * Standard destructor
+ */
+//=============================================================================
+
+SMESH_Gen_i::~SMESH_Gen_i()
+{
+ MESSAGE("~SMESH_Gen_i");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis(const char* anHyp,
+ CORBA::Long studyId)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("CreateHypothesis");
+
+ // create a new hypothesis object servant
+
+ SMESH_Hypothesis_i* myHypothesis_i = 0;
+ try
+ {
+ myHypothesis_i = _hypothesisFactory_i.Create(anHyp,
+ studyId,
+ &_impl);
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+
+ // activate the CORBA servant of hypothesis
+
+ SMESH::SMESH_Hypothesis_var hypothesis_i
+ = SMESH::SMESH_Hypothesis::_narrow(myHypothesis_i->_this());
+ return SMESH::SMESH_Hypothesis::_duplicate(hypothesis_i);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Init(GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Init");
+ // _narrow() duplicates the reference and checks the type
+ GEOM::GEOM_Gen_var geom = GEOM::GEOM_Gen::_narrow(geomEngine);
+ GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(aShape);
+
+ if (CORBA::is_nil(geom))
+ THROW_SALOME_CORBA_EXCEPTION("bad geom reference", \
+ SALOME::BAD_PARAM);
+ if (CORBA::is_nil(myShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
+ SALOME::BAD_PARAM);
+
+ // Get or create the GEOM_Client instance
+
+ SMESH_Mesh_i* meshServant = 0;
+ try
+ {
+ if (! _ShapeReader) _ShapeReader = new GEOM_Client();
+ ASSERT(_ShapeReader);
+
+ // explore main Shape, get local TopoDS_Shapes of all subShapes
+ // SMESH_topo* myTopo = ExploreMainShape(geom, studyId, myShape);
+
+ // Get studyContext_i, create it if it does'nt exist
+
+ if (_mapStudyContext_i.find(studyId) == _mapStudyContext_i.end())
+ {
+ _mapStudyContext_i[studyId] = new StudyContext_iStruct;
+ }
+ StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
+
+ // create a new mesh object servant, store it in a map in study context
+
+ meshServant = new SMESH_Mesh_i(this,
+ geom,
+ studyId,
+ _localId);
+ myStudyContext->mapMesh_i[_localId] = meshServant;
+ _localId++;
+
+ // create a new mesh object
+
+ TopoDS_Shape myLocShape = _ShapeReader->GetShape(geom,myShape);
+ meshServant->SetImpl(_impl.Init(studyId, myLocShape));
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+
+ // activate the CORBA servant of Mesh
+
+ SMESH::SMESH_Mesh_var mesh
+ = SMESH::SMESH_Mesh::_narrow(meshServant->_this());
+
+ meshServant->SetIor(mesh);
+
+ return SMESH::SMESH_Mesh::_duplicate(mesh);
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_Gen_i::IsReadyToCompute(SMESH::SMESH_Mesh_ptr aMesh,
+ GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_Gen_i::IsReadyToCompute");
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ SMESH::long_array*
+ SMESH_Gen_i::GetSubShapesId(GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ GEOM::GEOM_Shape_ptr mainShape,
+ const SMESH::shape_array& listOfSubShape)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_Gen_i::GetSubShapesId");
+ SMESH::long_array_var shapesId = new SMESH::long_array;
+ set<int> setId;
+
+ GEOM::GEOM_Gen_var geom = GEOM::GEOM_Gen::_narrow(geomEngine);
+ GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(mainShape);
+
+ if (CORBA::is_nil(geom))
+ THROW_SALOME_CORBA_EXCEPTION("bad geom reference", \
+ SALOME::BAD_PARAM);
+ if (CORBA::is_nil(myShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
+ SALOME::BAD_PARAM);
+
+ try
+ {
+ if (! _ShapeReader) _ShapeReader = new GEOM_Client();
+ ASSERT(_ShapeReader);
+ TopoDS_Shape myMainShape = _ShapeReader->GetShape(geom,myShape);
+ TopTools_IndexedMapOfShape myIndexToShape;
+ TopExp::MapShapes(myMainShape,myIndexToShape);
+
+ for (int i=0; i<listOfSubShape.length(); i++)
+ {
+ GEOM::GEOM_Shape_var aShape
+ = GEOM::GEOM_Shape::_narrow(listOfSubShape[i]);
+ if (CORBA::is_nil(aShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
+ SALOME::BAD_PARAM);
+ TopoDS_Shape locShape = _ShapeReader->GetShape(geom,aShape);
+ for (TopExp_Explorer exp(locShape,TopAbs_FACE); exp.More(); exp.Next())
+ {
+ const TopoDS_Face& F = TopoDS::Face(exp.Current());
+ setId.insert(myIndexToShape.FindIndex(F));
+ SCRUTE(myIndexToShape.FindIndex(F));
+ }
+ for (TopExp_Explorer exp(locShape,TopAbs_EDGE); exp.More(); exp.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
+ setId.insert(myIndexToShape.FindIndex(E));
+ SCRUTE(myIndexToShape.FindIndex(E));
+ }
+ for (TopExp_Explorer exp(locShape,TopAbs_VERTEX); exp.More(); exp.Next())
+ {
+ const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current());
+ setId.insert(myIndexToShape.FindIndex(V));
+ SCRUTE(myIndexToShape.FindIndex(V));
+ }
+ }
+ shapesId->length(setId.size());
+ set<int>::iterator iind;
+ int i=0;
+ for (iind = setId.begin(); iind != setId.end(); iind++)
+ {
+ SCRUTE((*iind));
+ shapesId[i] = (*iind);
+ SCRUTE(shapesId[i]);
+ i++;
+ }
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+
+ return shapesId._retn();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_Gen_i::Compute(SMESH::SMESH_Mesh_ptr aMesh,
+ GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_Gen_i::Compute");
+ GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(aShape);
+ if (CORBA::is_nil(myShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
+ SALOME::BAD_PARAM);
+
+ SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow(aMesh);
+ if (CORBA::is_nil(myMesh))
+ THROW_SALOME_CORBA_EXCEPTION("bad Mesh reference", \
+ SALOME::BAD_PARAM);
+
+ bool ret = false;
+ try
+ {
+
+ // get study context from studyId given by CORBA mesh object
+
+ int studyId = myMesh->GetStudyId();
+ ASSERT(_mapStudyContext_i.find(studyId) != _mapStudyContext_i.end());
+ StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
+
+ // get local Mesh_i object with Id and study context
+
+ int meshId = myMesh->GetId();
+ ASSERT(myStudyContext->mapMesh_i.find(meshId) != myStudyContext->mapMesh_i.end());
+ SMESH_Mesh_i* meshServant = myStudyContext->mapMesh_i[meshId];
+ ASSERT(meshServant);
+
+ // get local TopoDS_Shape
+
+ GEOM::GEOM_Gen_var geom = meshServant->GetGeomEngine();
+ TopoDS_Shape myLocShape = _ShapeReader->GetShape(geom,myShape);
+
+ // implementation compute
+
+ ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
+ ret = _impl.Compute(myLocMesh, myLocShape);
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ MESSAGE("catch exception "<< S_ex.what());
+ return false;
+// THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+
+ return ret;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SALOMEDS::TMPFile* SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile)
+{
+ MESSAGE("SMESH_Gen_i::SAVE");
+ SALOMEDS::Study_var Study = theComponent->GetStudy();
+ int studyId;
+
+ // Declare a byte stream
+ SALOMEDS::TMPFile_var aStreamFile;
+
+ // Obtain a temporary dir
+ TCollection_AsciiString tmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+
+ // Create a sequence of files processed
+ SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
+ aFileSeq->length(NUM_TMP_FILES);
+
+ TCollection_AsciiString aStudyName(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+
+ // Set names of temporary files
+ TCollection_AsciiString filename = aStudyName + TCollection_AsciiString("SMESH.hdf");
+ TCollection_AsciiString hypofile = aStudyName + TCollection_AsciiString("SMESH_Hypo.txt");
+ TCollection_AsciiString algofile = aStudyName + TCollection_AsciiString("SMESH_Algo.txt");
+ TCollection_AsciiString meshfile = aStudyName + TCollection_AsciiString("SMESH_Mesh.med");
+ aFileSeq[0] = CORBA::string_dup(filename.ToCString());
+ aFileSeq[1] = CORBA::string_dup(hypofile.ToCString());
+ aFileSeq[2] = CORBA::string_dup(algofile.ToCString());
+ aFileSeq[3] = CORBA::string_dup(meshfile.ToCString());
+ filename = tmpDir + filename;
+ hypofile = tmpDir + hypofile;
+ algofile = tmpDir + algofile;
+ meshfile = tmpDir + meshfile;
+
+ HDFfile * hdf_file;
+ map <int,HDFgroup*> hdf_group, hdf_subgroup;
+ map <int,HDFdataset*> hdf_dataset;
+ FILE* destFile;
+
+ SALOMEDS::ChildIterator_var itBig,it,itSM;
+ SALOMEDS::SObject_var mySObject,myBranch,mySObjectChild;
+ hdf_size size[1];
+ int longueur,cmpt_ds = 0,cmpt_it;
+ char *name_group,name_dataset[30],name_meshgroup[30];
+ bool ok,_found;
+ int cmpt_sm = 0, myTag;
+
+//************* HDF file creation
+ hdf_file = new HDFfile(filename.ToCString());
+ hdf_file->CreateOnDisk();
+//****************************
+
+ itBig = Study->NewChildIterator(theComponent);
+ for (; itBig->More();itBig->Next()) {
+ SALOMEDS::SObject_var gotBranch = itBig->Value();
+
+//************branch 1 : hypothesis
+ if (gotBranch->Tag()==Tag_HypothesisRoot) { //hypothesis = tag 1
+
+ double length,maxElementsArea;
+ int numberOfSegments;
+
+ destFile = fopen( hypofile.ToCString() ,"w");
+ it = Study->NewChildIterator(gotBranch);
+ for (; it->More();it->Next()) {
+ mySObject = it->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( mySObject->FindAttribute(anAttr, "AttributeIOR")) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+
+ SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value()));
+ fprintf(destFile,"%s\n",myHyp->GetName());
+
+ if (strcmp(myHyp->GetName(),"LocalLength")==0) {
+ SMESH::SMESH_LocalLength_var LL = SMESH::SMESH_LocalLength::_narrow( myHyp );
+ length = LL->GetLength();
+ fprintf(destFile,"%f\n",length);
+ }
+ else if (strcmp(myHyp->GetName(),"NumberOfSegments")==0) {
+ SMESH::SMESH_NumberOfSegments_var NOS = SMESH::SMESH_NumberOfSegments::_narrow( myHyp );
+ numberOfSegments = NOS->GetNumberOfSegments();
+ fprintf(destFile,"%d\n",numberOfSegments);
+ }
+ else if (strcmp(myHyp->GetName(),"MaxElementArea")==0) {
+ SMESH::SMESH_MaxElementArea_var MEA = SMESH::SMESH_MaxElementArea::_narrow( myHyp );
+ maxElementsArea = MEA->GetMaxElementArea();
+ fprintf(destFile,"%f\n",maxElementsArea);
+ }
+ }
+ }
+ fclose(destFile);
+
+//writes the file name in the hdf file
+ longueur = hypofile.Length() +1;
+ name_group="Hypothesis";
+ //SCRUTE(name_group);
+
+ size[0]=longueur;
+ hdf_group[1] = new HDFgroup(name_group,hdf_file);
+ hdf_group[1]->CreateOnDisk();
+
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_group,hdf_group[1],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(hypofile.ToCString());
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ hdf_group[1]->CloseOnDisk();
+ MESSAGE("End of Hypothesis Save");
+
+ }
+//************branch 2 : algorithms
+ else if (gotBranch->Tag()==Tag_AlgorithmsRoot) {//algos = tag 2
+
+ destFile = fopen( algofile.ToCString() ,"w");
+ it = Study->NewChildIterator(gotBranch);
+ for (; it->More();it->Next()) {
+ mySObject = it->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if (mySObject->FindAttribute(anAttr, "AttributeIOR")) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(anIOR->Value()));
+ fprintf(destFile,"%s\n",myAlgo->GetName());
+ }
+ }
+
+ fclose(destFile);
+
+//writes the file name in the hdf file
+ longueur = algofile.Length() +1;
+ name_group="Algorithms";
+ //SCRUTE(name_group);
+
+ size[0]=longueur;
+ hdf_group[2] = new HDFgroup(name_group,hdf_file);
+ hdf_group[2]->CreateOnDisk();
+
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_group,hdf_group[2],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(algofile.ToCString());
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ hdf_group[2]->CloseOnDisk();
+ MESSAGE("End of Algos Save");
+
+ }
+//************branch 3 : meshes
+ else if (gotBranch->Tag()>=3) {//meshes = tag > 3
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if (gotBranch->FindAttribute(anAttr, "AttributeIOR")) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+
+ SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value())) ;
+ studyId = myMesh->GetStudyId();
+ SCRUTE(studyId);
+
+ StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
+ int meshId = myMesh->GetId();
+ SMESH_Mesh_i* meshServant = myStudyContext->mapMesh_i[meshId];
+ ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
+ Handle(SMESHDS_Mesh) mySMESHDSMesh = myLocMesh.GetMeshDS();
+
+ SCRUTE(mySMESHDSMesh->NbNodes());
+ if (mySMESHDSMesh->NbNodes()>0) {//checks if the mesh is not empty
+
+ DriverMED_W_SMESHDS_Mesh* myWriter = new DriverMED_W_SMESHDS_Mesh;
+ myWriter->SetFile(meshfile.ToCString());
+
+ myWriter->SetMesh(mySMESHDSMesh);
+ myWriter->SetMeshId(gotBranch->Tag());
+ myWriter->Add();
+ }
+ else meshfile = "No data";
+
+ //********** opening of the HDF group
+ sprintf(name_meshgroup,"Mesh %d",gotBranch->Tag());
+ SCRUTE(name_meshgroup);
+ hdf_group[gotBranch->Tag()] = new HDFgroup(name_meshgroup,hdf_file);
+ hdf_group[gotBranch->Tag()]->CreateOnDisk();
+ //**********
+
+ //********** file where the data are stored
+ longueur = strlen(meshfile.ToCString()) +1;
+ size[0]=longueur;
+ strcpy(name_dataset,"Mesh data");
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_group[gotBranch->Tag()],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(meshfile.ToCString());
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+ //**********
+
+ //********** ref on shape
+ Standard_CString myRefOnObject="" ;
+ SALOMEDS::SObject_var myRef,myShape;
+ _found = gotBranch->FindSubObject(Tag_RefOnShape,myRef);
+ if (_found) {
+ ok = myRef->ReferencedObject(myShape);
+ myRefOnObject = myShape->GetID();
+ SCRUTE(myRefOnObject);
+
+ longueur = strlen(myRefOnObject) +1;
+ if (longueur>1) {
+ size[0]=longueur;
+ strcpy(name_dataset,"Ref on shape");
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_group[gotBranch->Tag()],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ }
+ }
+ //**********
+
+ //********** ref on applied hypothesis
+ _found = gotBranch->FindSubObject(Tag_RefOnAppliedHypothesis,myBranch);
+ if (_found) {
+
+ strcpy(name_meshgroup,"Applied Hypothesis");
+ hdf_subgroup[Tag_RefOnAppliedHypothesis] = new HDFgroup(name_meshgroup,hdf_group[gotBranch->Tag()]);
+ hdf_subgroup[Tag_RefOnAppliedHypothesis]->CreateOnDisk();
+
+ it = Study->NewChildIterator(myBranch);
+ cmpt_it = 0;
+ for (; it->More();it->Next()) {
+ mySObject = it->Value();
+ ok = mySObject->ReferencedObject(myRef);
+ myRefOnObject = myRef->GetID();
+
+ longueur = strlen(myRefOnObject) +1;
+ if (longueur>1) {
+ size[0]=longueur;
+ sprintf(name_dataset,"Hyp %d",cmpt_it);
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedHypothesis],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ }
+ cmpt_ds++;
+ cmpt_it++;
+ }
+ hdf_subgroup[Tag_RefOnAppliedHypothesis]->CloseOnDisk();
+ }
+ //**********
+
+ //********** ref on applied algorithms
+ _found = gotBranch->FindSubObject(Tag_RefOnAppliedAlgorithms,myBranch);
+ if (_found) {
+
+ strcpy(name_meshgroup,"Applied Algorithms");
+ hdf_subgroup[Tag_RefOnAppliedAlgorithms] = new HDFgroup(name_meshgroup,hdf_group[gotBranch->Tag()]);
+ hdf_subgroup[Tag_RefOnAppliedAlgorithms]->CreateOnDisk();
+
+ it = Study->NewChildIterator(myBranch);
+ cmpt_it = 0;
+ for (; it->More();it->Next()) {
+ mySObject = it->Value();
+ ok = mySObject->ReferencedObject(myRef);
+ myRefOnObject = myRef->GetID();
+
+ longueur = strlen(myRefOnObject) +1;
+ if (longueur>1) {
+ size[0]=longueur;
+ sprintf(name_dataset,"Algo %d",cmpt_it);
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedAlgorithms],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ }
+ cmpt_ds++;
+ cmpt_it++;
+ }
+ hdf_subgroup[Tag_RefOnAppliedAlgorithms]->CloseOnDisk();
+ }
+ MESSAGE("end of algo applied");
+ //**********
+
+ //********** submeshes on subshapes
+ int myLevel1Tag;
+ for (int i=Tag_SubMeshOnVertex;i<=Tag_SubMeshOnCompound;i++) {
+ _found = gotBranch->FindSubObject(i,myBranch);
+ if (_found) {
+ if (i==Tag_SubMeshOnVertex)
+ strcpy(name_meshgroup,"SubMeshes On Vertex");
+ else if (i==Tag_SubMeshOnEdge)
+ strcpy(name_meshgroup,"SubMeshes On Edge");
+ else if (i==Tag_SubMeshOnFace)
+ strcpy(name_meshgroup,"SubMeshes On Face");
+ else if (i==Tag_SubMeshOnSolid)
+ strcpy(name_meshgroup,"SubMeshes On Solid");
+ else if (i==Tag_SubMeshOnCompound)
+ strcpy(name_meshgroup,"SubMeshes On Compound");
+
+ cmpt_sm++;
+ myLevel1Tag = 10+cmpt_sm;
+ hdf_subgroup[myLevel1Tag] = new HDFgroup(name_meshgroup,hdf_group[gotBranch->Tag()]);
+ hdf_subgroup[myLevel1Tag]->CreateOnDisk();
+
+ itSM = Study->NewChildIterator(myBranch);
+ for (; itSM->More();itSM->Next()) {//Loop on all submeshes
+ mySObject = itSM->Value();
+ cmpt_sm++;
+ myTag = 10+cmpt_sm;
+ mySObject->FindAttribute(anAttr, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value())) ;
+
+ //sprintf(name_meshgroup,"SubMesh %d",myTag);
+ sprintf(name_meshgroup,"SubMesh %d",mySubMesh->GetId());
+ SCRUTE(name_meshgroup);
+
+ hdf_subgroup[myTag] = new HDFgroup(name_meshgroup,hdf_subgroup[myLevel1Tag]);
+ hdf_subgroup[myTag]->CreateOnDisk();
+
+ //********** ref on shape
+ Standard_CString myRefOnObject="" ;
+ SALOMEDS::SObject_var myRef,myShape;
+ bool _found2;
+ _found2 = mySObject->FindSubObject(Tag_RefOnShape,myRef);
+ if (_found2) {
+ ok = myRef->ReferencedObject(myShape);
+ myRefOnObject = myShape->GetID();
+ SCRUTE(myRefOnObject);
+
+ longueur = strlen(myRefOnObject) +1;
+ if (longueur>1) {
+ size[0]=longueur;
+ strcpy(name_dataset,"Ref on shape");
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[myTag],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+ }
+ }
+ //**********
+
+ //********** ref on applied hypothesis
+ _found2 = mySObject->FindSubObject(Tag_RefOnAppliedHypothesis,myBranch);
+ if (_found2) {
+
+ strcpy(name_meshgroup,"Applied Hypothesis");
+ cmpt_sm++;
+ hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
+ hdf_subgroup[10+cmpt_sm]->CreateOnDisk();
+
+ it = Study->NewChildIterator(myBranch);
+ cmpt_it = 0;
+ for (; it->More();it->Next()) {
+ mySObjectChild = it->Value();
+ ok = mySObjectChild->ReferencedObject(myRef);
+ myRefOnObject = myRef->GetID();
+
+ longueur = strlen(myRefOnObject) +1;
+ if (longueur>1) {
+ size[0]=longueur;
+ sprintf(name_dataset,"Hyp %d",cmpt_it);
+ SCRUTE(cmpt_it);
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ }
+ cmpt_ds++;
+ cmpt_it++;
+ }
+ hdf_subgroup[10+cmpt_sm]->CloseOnDisk();
+ }
+ //**********
+
+ //********** ref on applied algorithms
+ _found2 = mySObject->FindSubObject(Tag_RefOnAppliedAlgorithms,myBranch);
+ SCRUTE(_found2);
+ if (_found2) {
+
+ strcpy(name_meshgroup,"Applied Algorithms");
+ cmpt_sm++;
+ hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
+ hdf_subgroup[10+cmpt_sm]->CreateOnDisk();
+
+ it = Study->NewChildIterator(myBranch);
+ cmpt_it = 0;
+ for (; it->More();it->Next()) {
+ mySObjectChild = it->Value();
+ ok = mySObjectChild->ReferencedObject(myRef);
+ myRefOnObject = myRef->GetID();
+
+ longueur = strlen(myRefOnObject) +1;
+ if (longueur>1) {
+ size[0]=longueur;
+ sprintf(name_dataset,"Algo %d",cmpt_it);
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm],HDF_STRING,size,1);
+ hdf_dataset[cmpt_ds]->CreateOnDisk();
+ hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ }
+ cmpt_ds++;
+ cmpt_it++;
+ }
+ hdf_subgroup[10+cmpt_sm]->CloseOnDisk();
+ }
+ //MESSAGE("end of algo applied");
+ //**********
+
+ hdf_subgroup[myTag]->CloseOnDisk();
+ }
+
+ hdf_subgroup[myLevel1Tag]->CloseOnDisk();
+ }
+
+ }
+ //**********
+
+ //********** closing of the HDF group
+ hdf_group[gotBranch->Tag()]->CloseOnDisk();
+ MESSAGE("End of Mesh Save");
+ //**********
+ }
+ }
+ MESSAGE("End of Meshes Save");
+ }
+
+ hdf_file->CloseOnDisk();
+ delete hdf_file;
+ hdf_file = 0;
+
+ // Convert temporary files to stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.ToCString(), aFileSeq.in(), isMultiFile);
+
+ // Remove temporary files and directory
+ if (isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.ToCString(), aFileSeq.in(), true);
+
+ MESSAGE("End SMESH_Gen_i::Save");
+
+ return aStreamFile._retn();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile)
+{
+ MESSAGE("SMESH_Gen_i::Load\n");
+
+ // Get temporary files location
+ TCollection_AsciiString tmpDir = isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+
+ // Convert the stream into sequence of files to process
+ SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
+ tmpDir.ToCString(),
+ isMultiFile);
+
+ // Set names of temporary files
+ TCollection_AsciiString filename = tmpDir + aFileSeq[0];//"SMESH.hdf";
+ TCollection_AsciiString hypofile = tmpDir + aFileSeq[1];//"SMESH_Hypo.txt";
+ TCollection_AsciiString algofile = tmpDir + aFileSeq[2];//"SMESH_Algo.txt";
+ TCollection_AsciiString meshfile = tmpDir + aFileSeq[3];//"SMESH_Mesh.med";
+
+ SALOMEDS::Study_var Study = theComponent->GetStudy();
+ int studyId = Study->StudyId();
+ SCRUTE(studyId);
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+
+ SALOMEDS::SComponent_var fathergeom = Study->FindComponent("GEOM");
+ SALOMEDS::SComponent_var myGeomSComp = SALOMEDS::SComponent::_narrow( fathergeom );
+ SCRUTE(fathergeom);
+
+ //to get the geom engine !!!
+ //useful to define our new mesh
+ SALOME_NamingService* _NS = SINGLETON_<SALOME_NamingService>::Instance() ;
+ ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
+ _NS->init_orb( _orb ) ;
+ SALOME_LifeCycleCORBA* myEnginesLifeCycle = new SALOME_LifeCycleCORBA(_NS);
+ Engines::Component_var geomEngine =
+ myEnginesLifeCycle->FindOrLoad_Component("FactoryServer","Geometry");
+ GEOM::GEOM_Gen_var myGeomEngine = GEOM::GEOM_Gen::_narrow(geomEngine);
+
+
+ char* aLine;
+ bool ok;
+ char objectId[10],name_dataset[10];
+ int nb_datasets,size,cmpt_ds=0;
+ int cmpt_sm = 0;
+
+ char name[HDF_NAME_MAX_LEN+1];
+ char sgname[HDF_NAME_MAX_LEN+1];
+ char msgname[HDF_NAME_MAX_LEN+1];
+ char name_of_group[HDF_NAME_MAX_LEN+1];
+ char *name_meshgroup;
+ map <int,HDFgroup*> hdf_group, hdf_subgroup;
+ map <int,HDFdataset*> hdf_dataset;
+ FILE *loadedFile;
+
+ //************* HDF file opening
+ HDFfile * hdf_file = new HDFfile(filename.ToCString());
+ try {
+ hdf_file->OpenOnDisk(HDF_RDONLY);
+ }
+ catch (HDFexception) {
+ MESSAGE("Load(): " << filename << " not found!");
+ return false;
+ }
+
+ //****************************
+
+ int nb_group = hdf_file->nInternalObjects();
+ SCRUTE(nb_group);
+ for (int i=0;i<nb_group;i++)
+ {
+ hdf_file->InternalObjectIndentify(i,name);
+ //SCRUTE(name);
+
+//***************
+// Loading of the Hypothesis Branch
+//***************
+ if (strcmp(name,"Hypothesis")==0) {
+
+ double length,maxElementsArea;
+ int numberOfSegments;
+
+ hdf_group[Tag_HypothesisRoot] = new HDFgroup(name,hdf_file);
+ hdf_group[Tag_HypothesisRoot]->OpenOnDisk();
+
+ hdf_group[Tag_HypothesisRoot]->InternalObjectIndentify(0,name_of_group);
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_of_group,hdf_group[Tag_HypothesisRoot]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * name_of_file =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(name_of_file);
+ SCRUTE(name_of_file);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ hdf_group[Tag_HypothesisRoot]->CloseOnDisk();
+ cmpt_ds++;
+ delete[] name_of_file;
+ name_of_file = 0;
+
+ aLine = new char[100];
+ loadedFile = fopen( hypofile.ToCString() ,"r");
+ while (!feof(loadedFile)) {
+ fscanf(loadedFile,"%s",aLine);
+ //SCRUTE(aLine);
+ if (strcmp(aLine,"LocalLength")==0) {
+ SMESH::SMESH_Hypothesis_var myHyp = this->CreateHypothesis(aLine,studyId);
+ SMESH::SMESH_LocalLength_var LL = SMESH::SMESH_LocalLength::_narrow( myHyp );
+ fscanf(loadedFile,"%s",aLine);
+ length = atof(aLine);
+ LL->SetLength(length);
+ string iorString = _orb->object_to_string(LL);
+ sprintf(objectId,"%d",LL->GetId());
+ _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
+ }
+ else if (strcmp(aLine,"NumberOfSegments")==0) {
+ SMESH::SMESH_Hypothesis_var myHyp = this->CreateHypothesis(aLine,studyId);
+ SMESH::SMESH_NumberOfSegments_var NOS = SMESH::SMESH_NumberOfSegments::_narrow( myHyp );
+ fscanf(loadedFile,"%s",aLine);
+ numberOfSegments = atoi(aLine);
+ NOS->SetNumberOfSegments(numberOfSegments);
+ string iorString = _orb->object_to_string(NOS);
+ sprintf(objectId,"%d",NOS->GetId());
+ _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
+ }
+ else if (strcmp(aLine,"MaxElementArea")==0) {
+ SMESH::SMESH_Hypothesis_var myHyp = this->CreateHypothesis(aLine,studyId);
+ SMESH::SMESH_MaxElementArea_var MEA = SMESH::SMESH_MaxElementArea::_narrow( myHyp );
+ fscanf(loadedFile,"%s",aLine);
+ maxElementsArea = atof(aLine);
+ MEA->SetMaxElementArea(maxElementsArea);
+ string iorString = _orb->object_to_string(MEA);
+ sprintf(objectId,"%d",MEA->GetId());
+ _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
+ }
+
+
+ }
+ fclose(loadedFile);
+ delete[] aLine;
+ aLine = 0;
+ MESSAGE("End of Hypos Load");
+
+ }
+//***************
+// Loading of the Algorithms Branch
+//***************
+ else if (strcmp(name,"Algorithms")==0) {
+
+ hdf_group[Tag_AlgorithmsRoot] = new HDFgroup(name,hdf_file);
+ hdf_group[Tag_AlgorithmsRoot]->OpenOnDisk();
+
+ hdf_group[Tag_AlgorithmsRoot]->InternalObjectIndentify(0,name_of_group);
+ hdf_dataset[cmpt_ds] = new HDFdataset(name_of_group,hdf_group[Tag_AlgorithmsRoot]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * name_of_file =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(name_of_file);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ hdf_group[Tag_AlgorithmsRoot]->CloseOnDisk();
+ cmpt_ds++;
+ delete[] name_of_file;
+ name_of_file = 0;
+
+ aLine = new char[100];
+ loadedFile = fopen( algofile.ToCString(),"r");
+ while (!feof(loadedFile)) {
+ fscanf(loadedFile,"%s\n",aLine);
+ //SCRUTE(aLine);
+ if (strcmp(aLine,"")!=0) {
+ SMESH::SMESH_Hypothesis_var myHyp = this->CreateHypothesis(aLine,studyId);
+ SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo::_narrow(myHyp);
+ string iorString = _orb->object_to_string(myAlgo);
+ sprintf(objectId,"%d",myAlgo->GetId());
+ _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
+ }
+ }
+ fclose(loadedFile);
+ delete[] aLine;
+ aLine = 0;
+ MESSAGE("End of Algos Load");
+
+ }
+
+//***************
+// Loading of the Mesh Branch
+//***************
+ else if (string(name).substr(0,4)==string("Mesh")) {
+ MESSAGE("in mesh load");
+
+ Standard_Integer myMeshId = atoi((string(name).substr(5,5)).c_str());
+ SCRUTE(myMeshId);
+
+ hdf_group[myMeshId] = new HDFgroup(name,hdf_file);
+ hdf_group[myMeshId]->OpenOnDisk();
+
+ int nb_meshsubgroup = hdf_group[myMeshId]->nInternalObjects();
+ SCRUTE(nb_meshsubgroup);
+
+ //********** Loading of the file name where the data are stored
+ MESSAGE("Mesh data file");
+ strcpy(name_of_group,"Mesh data");
+ hdf_dataset[cmpt_ds]=new HDFdataset(name_of_group,hdf_group[myMeshId]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * datafilename =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(datafilename);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ //**********
+ //}
+ //else if (strcmp(msgname,"Ref on shape")==0) {
+
+ //********** Loading of the reference on the shape
+ //********** and mesh initialization
+ MESSAGE("Ref on shape");
+ strcpy(name_of_group,"Ref on shape");
+ hdf_dataset[cmpt_ds] = new HDFdataset(name_of_group,hdf_group[myMeshId]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * refFromFile =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ Standard_CString myRefOnShape=""; //look for ref on shape
+
+ bool _found = false;
+ SALOMEDS::SObject_var CSO = Study->FindObjectID(refFromFile);
+ SMESH::SMESH_Mesh_var myNewMesh;
+ GEOM::GEOM_Shape_var aShape;
+
+ if (!CORBA::is_nil(CSO)) {
+ _found = true;
+ CSO->FindAttribute(anAttr, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ char* ShapeIOR = anIOR->Value();
+ aShape = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(ShapeIOR));
+
+ myNewMesh = this->Init(myGeomEngine,studyId,aShape);
+ string iorString = _orb->object_to_string(myNewMesh);
+ sprintf(objectId,"%d",myNewMesh->GetId());
+ _SMESHCorbaObj[string("Mesh_")+string(objectId)] = iorString;
+
+ //**********
+ //********** Loading of mesh data
+ if (strcmp(datafilename,"No data")!=0) {
+
+ med_idt fid;
+ int ret;
+
+ //****************************************************************************
+ //* OUVERTURE DU FICHIER EN LECTURE *
+ //****************************************************************************
+
+ fid = MEDouvrir(datafilename,MED_LECT);
+ if (fid < 0)
+ {
+ printf(">> ERREUR : ouverture du fichier %s \n",datafilename);
+ exit(EXIT_FAILURE);
+ }
+ else {
+
+ StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
+ int meshId = myNewMesh->GetId();
+ SMESH_Mesh_i* meshServant = myStudyContext->mapMesh_i[meshId];
+ ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
+ Handle(SMESHDS_Mesh) mySMESHDSMesh = myLocMesh.GetMeshDS();
+
+ DriverMED_R_SMESHDS_Mesh* myReader = new DriverMED_R_SMESHDS_Mesh;
+
+ myReader->SetMesh(mySMESHDSMesh);
+ myReader->SetMeshId(myMeshId);
+ myReader->SetFileId(fid);
+ myReader->ReadMySelf();
+ //SCRUTE(mySMESHDSMesh->NbNodes());
+ //myNewMesh->ExportUNV("/tmp/test.unv");//only to check out
+
+ //****************************************************************************
+ //* FERMETURE DU FICHIER *
+ //****************************************************************************
+ ret = MEDfermer(fid);
+
+ if (ret != 0)
+ printf(">> ERREUR : erreur a la fermeture du fichier %s\n",datafilename);
+
+ }
+ }
+ }
+ //**********
+ //}
+ //else if (strcmp(msgname,"Applied Hypothesis")==0) {
+ for (int ii=0;ii<nb_meshsubgroup;ii++)
+ {
+ hdf_group[myMeshId]->InternalObjectIndentify(ii,msgname);
+ if (strcmp(msgname,"Mesh data")==0) {
+ //nothing
+ }
+ else if (strcmp(msgname,"Ref on shape")==0) {
+ //nothing
+ }
+ else if (strcmp(msgname,"Applied Hypothesis")==0) {
+ //********** Loading of the applied hypothesis
+ strcpy(name_of_group,"Applied Hypothesis");
+ hdf_subgroup[Tag_RefOnAppliedHypothesis] = new HDFgroup(name_of_group,hdf_group[myMeshId]);
+ hdf_subgroup[Tag_RefOnAppliedHypothesis]->OpenOnDisk();
+
+ nb_datasets = hdf_subgroup[Tag_RefOnAppliedHypothesis]->nInternalObjects();
+ SCRUTE(nb_datasets);
+
+ for (int j=0;j<nb_datasets;j++) {
+ sprintf(name_dataset,"Hyp %d",j);
+ hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedHypothesis]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * refFromFile =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
+ //SCRUTE(refFromFile);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+ if (_found) {
+ SALOMEDS::SObject_var HypSO = Study->FindObjectID(refFromFile);
+ if (!CORBA::is_nil(HypSO)) {
+ HypSO->FindAttribute(anAttr, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ if (!CORBA::is_nil(anIOR)) {
+ char* HypIOR = anIOR->Value();
+ SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(HypIOR));
+ if (!CORBA::is_nil(anHyp)) {
+ myNewMesh->AddHypothesis(aShape,anHyp);
+ MESSAGE("Hypothesis added ...");
+ }
+ }
+ }
+ }
+ }
+
+ hdf_subgroup[Tag_RefOnAppliedHypothesis]->CloseOnDisk();
+ //**********
+ }
+ else if (strcmp(msgname,"Applied Algorithms")==0) {
+
+ //********** Loading of the applied algorithms
+ strcpy(name_of_group,"Applied Algorithms");
+ hdf_subgroup[Tag_RefOnAppliedAlgorithms] = new HDFgroup(name_of_group,hdf_group[myMeshId]);
+ hdf_subgroup[Tag_RefOnAppliedAlgorithms]->OpenOnDisk();
+
+ nb_datasets = hdf_subgroup[Tag_RefOnAppliedAlgorithms]->nInternalObjects();
+ SCRUTE(nb_datasets);
+
+ for (int j=0;j<nb_datasets;j++) {
+ sprintf(name_dataset,"Algo %d",j);
+ hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedAlgorithms]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * refFromFile =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ if (_found) {
+ SALOMEDS::SObject_var AlgoSO = Study->FindObjectID(refFromFile);
+ if (!CORBA::is_nil(AlgoSO)) {
+ AlgoSO->FindAttribute(anAttr, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ if (!CORBA::is_nil(anIOR)) {
+ char* AlgoIOR = anIOR->Value();
+ //SCRUTE(AlgoIOR);
+ SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(AlgoIOR));
+ SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(myHyp);
+ //SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(AlgoIOR));
+ if (!CORBA::is_nil(anAlgo)) {
+ myNewMesh->AddHypothesis(aShape,anAlgo);//essayer avec _SMESHCorbaObj
+ MESSAGE("Algorithms added ...");
+ }
+ }
+ }
+ }
+ }
+
+ hdf_subgroup[Tag_RefOnAppliedAlgorithms]->CloseOnDisk();
+
+ //**********
+ }
+ else if (string(msgname).substr(0,9)==string("SubMeshes")) {
+
+
+ //********** Loading of the submeshes on subshapes
+ int myLevel1Tag, myTag;
+ SCRUTE(msgname);
+ cmpt_sm++;
+ myLevel1Tag = 10+cmpt_sm;
+ hdf_subgroup[myLevel1Tag] = new HDFgroup(name_of_group,hdf_group[myMeshId]);
+ hdf_subgroup[myLevel1Tag] = new HDFgroup(msgname,hdf_group[myMeshId]);
+ hdf_subgroup[myLevel1Tag]->OpenOnDisk();
+
+ int nb_submeshes = hdf_subgroup[myLevel1Tag]->nInternalObjects();
+ SCRUTE(nb_submeshes);
+
+ for (int j=0;j<nb_submeshes;j++) {
+ cmpt_sm++;
+ myTag = 10+cmpt_sm;
+ hdf_subgroup[myLevel1Tag]->InternalObjectIndentify(j,name_meshgroup);
+ SCRUTE(name_meshgroup);
+
+ hdf_subgroup[myTag] = new HDFgroup(name_meshgroup,hdf_subgroup[myLevel1Tag]);
+ hdf_subgroup[myTag]->OpenOnDisk();
+ int subMeshId = atoi((string(name_meshgroup).substr(8,18)).c_str());
+
+ MESSAGE("Ref on shape");
+ //********** ref on shape
+ sprintf(name_dataset,"Ref on shape");
+ hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[myTag]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * refFromFile =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ bool _found3 = false;
+ SALOMEDS::SObject_var GSO = Study->FindObjectID(refFromFile);
+ SMESH::SMESH_subMesh_var aSubMesh;
+ GEOM::GEOM_Shape_var aSubShape;
+
+ if (!CORBA::is_nil(GSO)) {
+ GSO->FindAttribute(anAttr, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ char* SubShapeIOR = anIOR->Value();
+ aSubShape = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(SubShapeIOR));
+
+ if (!CORBA::is_nil(aSubShape)) {
+ aSubMesh = myNewMesh->GetElementsOnShape(aSubShape);
+ string iorString = _orb->object_to_string(aSubMesh);
+ sprintf(objectId,"%d",subMeshId);
+ _SMESHCorbaObj[string("SubMesh_")+string(objectId)] = iorString;
+ _found3 = true;
+ //SCRUTE(aSubMesh->GetNumberOfNodes());
+ //MESSAGE("yes");
+ //SCRUTE(aSubMesh->GetNumberOfElements());
+ }
+ }
+
+ int nb_subgroup = hdf_subgroup[myTag]->nInternalObjects();
+ SCRUTE(nb_subgroup);
+ for (int k=0;k<nb_subgroup;k++)
+ {
+ hdf_subgroup[myTag]->InternalObjectIndentify(k,sgname);
+ if (strcmp(sgname,"Ref on shape")==0) {
+ //nothing
+ }
+ else if (strcmp(sgname,"Applied Hypothesis")==0) {
+ //********** ref on applied hypothesis
+ MESSAGE("Applied Hypothesis");
+ strcpy(name_meshgroup,"Applied Hypothesis");
+ cmpt_sm++;
+ hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
+ hdf_subgroup[10+cmpt_sm]->OpenOnDisk();
+ nb_datasets = hdf_subgroup[10+cmpt_sm]->nInternalObjects();
+ SCRUTE(nb_datasets);
+
+ for (int l=0;l<nb_datasets;l++) {
+ sprintf(name_dataset,"Hyp %d",l);
+ hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * refFromFile =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ if (_found3) {
+ SALOMEDS::SObject_var HypSO = Study->FindObjectID(refFromFile);
+ if (!CORBA::is_nil(HypSO)) {
+ HypSO->FindAttribute(anAttr, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ if (!CORBA::is_nil(anIOR)) {
+ char* HypIOR = anIOR->Value();
+ SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(HypIOR));
+ if (!CORBA::is_nil(anHyp)) {
+ SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
+ aMesh->AddHypothesis(aSubShape,anHyp);//essayer avec _SMESHCorbaObj
+ MESSAGE("Hypothesis added ...");
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (strcmp(sgname,"Applied Algorithms")==0) {
+ //********** ref on applied algorithms
+ MESSAGE("Applied Algorithms");
+ strcpy(name_meshgroup,"Applied Algorithms");
+ cmpt_sm++;
+ hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
+ hdf_subgroup[10+cmpt_sm]->OpenOnDisk();
+ nb_datasets = hdf_subgroup[10+cmpt_sm]->nInternalObjects();
+ SCRUTE(nb_datasets);
+
+ for (int l=0;l<nb_datasets;l++) {
+ sprintf(name_dataset,"Algo %d",l);
+ hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm]);
+ hdf_dataset[cmpt_ds]->OpenOnDisk();
+ size=hdf_dataset[cmpt_ds]->GetSize();
+
+ char * refFromFile =new char[size];
+ hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
+ hdf_dataset[cmpt_ds]->CloseOnDisk();
+ cmpt_ds++;
+
+ if (_found3) {
+ SALOMEDS::SObject_var AlgoSO = Study->FindObjectID(refFromFile);
+ if (!CORBA::is_nil(AlgoSO)) {
+ AlgoSO->FindAttribute(anAttr, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ if (!CORBA::is_nil(anIOR)) {
+ char* AlgoIOR = anIOR->Value();
+ //SCRUTE(AlgoIOR);
+ SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(AlgoIOR));
+ SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(myHyp);
+ //SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(AlgoIOR));
+ if (!CORBA::is_nil(anAlgo)) {
+ SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
+ aMesh->AddHypothesis(aSubShape,anAlgo);//essayer avec _SMESHCorbaObj
+ MESSAGE("Algorithms added ...");
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ hdf_subgroup[myTag]->CloseOnDisk();
+ }
+ hdf_subgroup[myLevel1Tag]->CloseOnDisk();
+ }
+ }
+ hdf_group[myMeshId]->CloseOnDisk();
+
+ MESSAGE("End of Meshes Load");
+ }
+ }
+
+ MESSAGE("End of SMESH_Gen::Load");
+
+ hdf_file->CloseOnDisk();
+ delete hdf_file;
+ hdf_file=0;
+
+ // Remove temporary files created from the stream
+ if (isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.ToCString(), aFileSeq.in(), true);
+
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
+{
+ MESSAGE("Close");
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
+ for (; itBig->More();itBig->Next()) {
+ SALOMEDS::SObject_var gotBranch = itBig->Value();
+
+ // branch 1 : hypothesis
+ if (gotBranch->Tag()==Tag_HypothesisRoot || gotBranch->Tag()==Tag_AlgorithmsRoot) {
+ SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(gotBranch);
+ for (; it->More();it->Next()) {
+ SALOMEDS::SObject_var mySObject = it->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( mySObject->FindAttribute(anAttr, "AttributeIOR")) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ SMESH::SMESH_Hypothesis_var myHyp =
+ SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value()));
+ char objectId[10];
+ sprintf(objectId,"%d",myHyp->GetId());
+// cout<<"********** delete Hyp "<<objectId<<endl;
+ _SMESHCorbaObj.erase(string("Hypo_")+string(objectId));
+ myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value()));
+ }
+ }
+ }
+ // branch 2 : algorithms
+ else if (gotBranch->Tag()>=3) {
+ SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(gotBranch);
+ for (; it->More();it->Next()) {
+ SALOMEDS::SObject_var mySObject = it->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( mySObject->FindAttribute(anAttr, "AttributeIOR")) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ SMESH::SMESH_Mesh_var myMesh =
+ SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
+ if (!myMesh->_is_nil()) {
+ char objectId[10];
+ sprintf(objectId,"%d",myMesh->GetId());
+// cout<<"********** delete Mesh "<<objectId<<endl;
+ _SMESHCorbaObj.erase(string("Mesh_")+string(objectId));
+ CORBA::release(myMesh);
+ }
+ else {
+ SMESH::SMESH_subMesh_var mySubMesh =
+ SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value()));
+ if (!mySubMesh->_is_nil()) {
+ char objectId[10];
+ sprintf(objectId,"%d",mySubMesh->GetId());
+// cout<<"********** delete SubMesh "<<objectId<<endl;
+ _SMESHCorbaObj.erase(string("SubMesh_")+string(objectId));
+ CORBA::release(mySubMesh);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+char* SMESH_Gen_i::ComponentDataType()
+{
+ MESSAGE("SMESH_Gen_i::ComponentDataType");
+ return strdup("SMESH");
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+char* SMESH_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
+ const char* IORString,
+ CORBA::Boolean isMultiFile)
+{
+ MESSAGE("SMESH_Gen_i::IORToLocalPersistentID");
+
+ char objectId[10];
+
+ SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(IORString));
+ if (! CORBA::is_nil(myAlgo))
+ {
+ string prefix = "Hypo_";
+ sprintf(objectId,"%d",myAlgo->GetId());
+ string lpID = prefix + string(objectId);
+ return CORBA::string_dup(lpID.c_str());
+ }
+ else {
+ SMESH::SMESH_Hypothesis_var myHypo = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(IORString));
+ if (! CORBA::is_nil(myHypo))
+ {
+ string prefix = "Hypo_";
+ sprintf(objectId,"%d",myHypo->GetId());
+ string lpID = prefix + string(objectId);
+ return CORBA::string_dup(lpID.c_str());
+ }
+ else {
+ SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(IORString));
+ if (! CORBA::is_nil(myMesh))
+ {
+ string prefix = "Mesh_";
+ sprintf(objectId,"%d",myMesh->GetId());
+ string lpID = prefix + string(objectId);
+ return CORBA::string_dup(lpID.c_str());
+ }
+ else {
+ SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(IORString));
+ if (! CORBA::is_nil(mySubMesh))
+ {
+ string prefix = "SubMesh_";
+ sprintf(objectId,"%d",mySubMesh->GetId());
+ string lpID = prefix + string(objectId);
+ return CORBA::string_dup(lpID.c_str());
+ }
+ else return (strdup("no object"));
+ }
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+char* SMESH_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
+ const char* aLocalPersistentID,
+ CORBA::Boolean isMultiFile)
+{
+ MESSAGE("SMESH_Gen_i::LocalPersistentIDToIOR");
+ SCRUTE(aLocalPersistentID);
+ string clef = string(aLocalPersistentID);
+ SCRUTE(_SMESHCorbaObj[clef].c_str());
+ return CORBA::string_dup(_SMESHCorbaObj[clef].c_str());
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_topo* SMESH_Gen_i::ExploreMainShape(GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ GEOM::GEOM_Shape_ptr aShape)
+{
+ MESSAGE("SMESH_Mesh_i::ExploreMainShape");
+ // _narrow() duplicates the reference and check the type
+ GEOM::GEOM_Gen_var geom = GEOM::GEOM_Gen::_narrow(geomEngine);
+ GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(aShape);
+
+ if (CORBA::is_nil(geom))
+ THROW_SALOME_CORBA_EXCEPTION("bad geom reference", \
+ SALOME::BAD_PARAM);
+ if (CORBA::is_nil(myShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
+ SALOME::BAD_PARAM);
+ MESSAGE("---");
+ SCRUTE(myShape->Name());
+ geom->GetCurrentStudy(studyId);
+ SCRUTE(studyId);
+ TopoDS_Shape mainShape = _ShapeReader->GetShape(geom,myShape);
+ MESSAGE("---");
+
+ // create an SMESH_topo object for the mainShape
+
+ SMESH_topo* myTopo = new SMESH_topo();
+ MESSAGE("---");
+
+ // explore local TopoDS_Shape, store reference of local TopoDS subShapes
+
+ for (TopExp_Explorer exp(mainShape,TopAbs_COMPOUND); exp.More(); exp.Next())
+ {
+ const TopoDS_Compound& E = TopoDS::Compound(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_COMPOUND].Add(E);
+ SCRUTE(i);
+ }
+ for (TopExp_Explorer exp(mainShape,TopAbs_COMPSOLID); exp.More(); exp.Next())
+ {
+ const TopoDS_CompSolid& E = TopoDS::CompSolid(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_COMPSOLID].Add(E);
+ SCRUTE(i);
+ }
+ for (TopExp_Explorer exp(mainShape,TopAbs_SOLID); exp.More(); exp.Next())
+ {
+ const TopoDS_Solid& E = TopoDS::Solid(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_SOLID].Add(E);
+ SCRUTE(i);
+ }
+ for (TopExp_Explorer exp(mainShape,TopAbs_SHELL); exp.More(); exp.Next())
+ {
+ const TopoDS_Shell& E = TopoDS::Shell(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_SHELL].Add(E);
+ SCRUTE(i);
+ }
+ for (TopExp_Explorer exp(mainShape,TopAbs_FACE); exp.More(); exp.Next())
+ {
+ const TopoDS_Face& E = TopoDS::Face(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_FACE].Add(E);
+ SCRUTE(i);
+ }
+ for (TopExp_Explorer exp(mainShape,TopAbs_WIRE); exp.More(); exp.Next())
+ {
+ const TopoDS_Wire& E = TopoDS::Wire(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_WIRE].Add(E);
+ SCRUTE(i);
+ }
+ for (TopExp_Explorer exp(mainShape,TopAbs_EDGE); exp.More(); exp.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_EDGE].Add(E);
+ SCRUTE(i);
+ }
+ for (TopExp_Explorer exp(mainShape,TopAbs_VERTEX); exp.More(); exp.Next())
+ {
+ const TopoDS_Vertex& E = TopoDS::Vertex(exp.Current());
+ int i = myTopo->_myShapes[TopAbs_VERTEX].Add(E);
+ SCRUTE(i);
+ }
+
+ // explore subShapes of distant CORBA object,
+ // associate distant CORBA subShape references
+ // with local reference to local TopoDS subShape
+
+ string filenode = "toposhape.txt";
+ ofstream fic(filenode.c_str());
+
+ for (int shapeType = TopAbs_COMPOUND; shapeType < TopAbs_SHAPE; shapeType++)
+ {
+ fic << "shape type : " << SMESH_shapeTypeNames[shapeType];
+
+ GEOM::GEOM_Gen::ListOfGeomShapes_var subShapes
+ = geom->SubShapeAll(myShape,shapeType);
+ int nbSubShapes = subShapes->length();
+ int nbLocal = myTopo->_myShapes[shapeType].Extent();
+ fic << " - number of elements: " << nbSubShapes << endl;
+ ASSERT(nbSubShapes == nbLocal);
+
+ for (int i=0; i< nbSubShapes; i++)
+ {
+ GEOM::GEOM_Shape_var aSubShape = subShapes[i];
+ string idShape = SMESH_topo::GetShapeLocalId(aSubShape);
+ fic << " " << idShape;
+ SCRUTE(idShape);
+ TopoDS_Shape aLocShape = _ShapeReader->GetShape(geom,aSubShape);
+ for (int j=1; j <= nbLocal; j++)
+ if (aLocShape.IsSame(myTopo->_myShapes[shapeType].FindKey(j)))
+ {
+ MESSAGE(" --- trouve = " << j);
+ myTopo->_mapIndShapes[shapeType][idShape] = j;
+ fic << " --- trouve = " << j;
+ break;
+ }
+ fic << endl;
+ }
+ }
+ fic.close();
+
+ return myTopo;
+}
+
+//=============================================================================
+/*!
+ * C factory, accessible with dlsym, after dlopen
+ */
+//=============================================================================
+
+extern "C"
+{
+ PortableServer::ObjectId * SMESHEngine_factory(
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName)
+ {
+ MESSAGE("PortableServer::ObjectId * SMESHEngine_factory()");
+ SCRUTE(interfaceName);
+ SMESH_Gen_i * mySMESH_Gen
+ = new SMESH_Gen_i(orb, poa, contId, instanceName, interfaceName);
+ return mySMESH_Gen->getId() ;
+ }
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Gen_i.hxx
+// Created : lun mai 6 13:41:30 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_GEN_I_HXX_
+#define _SMESH_GEN_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Gen)
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+#include CORBA_CLIENT_HEADER(GEOM_Gen)
+#include CORBA_CLIENT_HEADER(GEOM_Shape)
+#include CORBA_CLIENT_HEADER(SALOMEDS)
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+
+
+class SMESH_Mesh_i;
+
+#include "SMESH_HypothesisFactory_i.hxx"
+#include "SMESH_Mesh_i.hxx"
+#include "SALOME_Component_i.hxx"
+#include "SALOME_NamingService.hxx"
+
+#include "SMESH_Gen.hxx"
+#include "SMESH_topo.hxx"
+#include "GEOM_Client.hxx"
+
+#include <HDFOI.hxx>
+
+#include <map>
+
+typedef struct studyContext_iStruct
+{
+ map<int,SMESH_Mesh_i*> mapMesh_i;
+} StudyContext_iStruct;
+
+class SMESH_Gen_i:
+ public POA_SMESH::SMESH_Gen,
+ public Engines_Component_i
+{
+public:
+
+ SMESH_Gen_i();
+ SMESH_Gen_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName);
+ virtual ~SMESH_Gen_i();
+
+ SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const char* anHyp,
+ CORBA::Long studyId)
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::SMESH_Mesh_ptr Init(GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Boolean Compute(SMESH::SMESH_Mesh_ptr aMesh,
+ GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Boolean IsReadyToCompute(SMESH::SMESH_Mesh_ptr aMesh,
+ GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::long_array* GetSubShapesId(GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ GEOM::GEOM_Shape_ptr mainShape,
+ const SMESH::shape_array& listOfSubShape)
+ throw (SALOME::SALOME_Exception);
+
+
+ // inherited methods from SALOMEDS::Driver
+
+ SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile);
+ bool Load(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile);
+ void Close(SALOMEDS::SComponent_ptr theComponent);
+ char* ComponentDataType();
+
+ char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
+ const char* IORString,
+ CORBA::Boolean isMultiFile);
+ char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
+ const char* aLocalPersistentID,
+ CORBA::Boolean isMultiFile);
+
+ bool CanPublishInStudy(CORBA::Object_ptr theIOR) { return false; }
+ SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject,
+ CORBA::Object_ptr theObject,
+ const char* theName) throw (SALOME::SALOME_Exception) {
+ SALOMEDS::SObject_var aResultSO;
+ return aResultSO._retn();
+ }
+
+ CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject) {return false;}
+ SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {return false;}
+ CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID) {return false;}
+ SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
+ CORBA::Long theObjectID,
+ SALOMEDS::SObject_ptr theObject) {
+ SALOMEDS::SObject_var aResultSO;
+ return aResultSO._retn();
+ }
+
+ GEOM_Client* _ShapeReader;
+protected:
+ SMESH_topo* ExploreMainShape(GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ GEOM::GEOM_Shape_ptr aShape);
+
+private:
+ SMESH_HypothesisFactory_i _hypothesisFactory_i;
+ ::SMESH_Gen _impl; // no namespace here
+ int _localId; // unique Id of created objects, within SMESH_Gen_i entity
+
+ map<int, StudyContext_iStruct*> _mapStudyContext_i;
+ map <string, string> _SMESHCorbaObj;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Hexa_3D_i.cxx
+// Created : sam mai 18 23:15:45 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Hexa_3D_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hexa_3D_i::SMESH_Hexa_3D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+{
+ MESSAGE("SMESH_Hexa_3D_i::SMESH_Hexa_3D_i");
+ _genImpl = genImpl;
+ ::SMESH_Hexa_3D* impl
+ = new ::SMESH_Hexa_3D(_genImpl->_hypothesisFactory.GetANewId(),
+ studyId,
+ genImpl);
+ SetImpl(impl);
+ _baseImpl = _impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hexa_3D_i::~SMESH_Hexa_3D_i()
+{
+ MESSAGE("SMESH_Hexa_3D_i::~SMESH_Hexa_3D_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Hexa_3D_i::SetImpl(::SMESH_Hexa_3D* impl)
+{
+ MESSAGE("SMESH_Hexa_3D_i::SetImpl");
+ SMESH_3D_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Hexa_3D_i.hxx
+// Created : sam mai 18 23:15:38 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+#ifndef _SMESH_HEXA_3D_I_HXX_
+#define _SMESH_HEXA_3D_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_3D_Algo_i.hxx"
+
+#include "SMESH_Hexa_3D.hxx"
+
+class SMESH_Hexa_3D_i:
+ public POA_SMESH::SMESH_Hexa_3D,
+ public SMESH_3D_Algo_i
+{
+public:
+ SMESH_Hexa_3D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl);
+
+ virtual ~SMESH_Hexa_3D_i();
+
+protected:
+ virtual void SetImpl(::SMESH_Hexa_3D* impl);
+
+ ::SMESH_Hexa_3D* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_HypothesisFactory_i.cxx
+// Created : dim mai 19 22:02:42 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_HypothesisFactory_i.hxx"
+#include "SMESH_Hypothesis_i.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+// Add new hypothesis here (include file)
+//---------------------------------------
+#include "SMESH_LocalLength_i.hxx"
+#include "SMESH_NumberOfSegments_i.hxx"
+#include "SMESH_MaxElementArea_i.hxx"
+#include "SMESH_Regular_1D_i.hxx"
+#include "SMESH_MEFISTO_2D_i.hxx"
+#include "SMESH_Quadrangle_2D_i.hxx"
+#include "SMESH_Hexa_3D_i.hxx"
+
+//---------------------------------------
+
+//=============================================================================
+/*!
+ * Specific Hypothesis Creators are generated with a template which inherits a
+ * generic hypothesis creator. Each creator returns an hypothesis of the type
+ * given in the template.
+ */
+//=============================================================================
+
+template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
+{
+public:
+ virtual SMESH_Hypothesis_i* Create (const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+ {
+ return new T(anHyp, studyId, genImpl);
+ };
+};
+
+//=============================================================================
+/*!
+ * Constructor: instanciate specific hypothesis creators, fill a private map
+ * indexed by hypothesis names. THIS METHOD MUST BE COMPLETED WHEN A NEW
+ * HYPOTHESIS IS ADDED.
+ * Specific hypothesis creator are defined with the above template.
+ * Hypothesis names are related to the corresponding class names:
+ * prefix = SMESH_ ; suffix = _i .
+ */
+//=============================================================================
+
+SMESH_HypothesisFactory_i::SMESH_HypothesisFactory_i()
+{
+// Add new hypothesis here (creators)
+//---------------------------------------
+_creatorMap["LocalLength"] = new HypothesisCreator_i<SMESH_LocalLength_i>;
+_creatorMap["NumberOfSegments"] = new HypothesisCreator_i<SMESH_NumberOfSegments_i>;
+_creatorMap["MaxElementArea"] = new HypothesisCreator_i<SMESH_MaxElementArea_i>;
+_creatorMap["Regular_1D"] = new HypothesisCreator_i<SMESH_Regular_1D_i>;
+_creatorMap["MEFISTO_2D"] = new HypothesisCreator_i<SMESH_MEFISTO_2D_i>;
+_creatorMap["Quadrangle_2D"] = new HypothesisCreator_i<SMESH_Quadrangle_2D_i>;
+_creatorMap["Hexa_3D"] = new HypothesisCreator_i<SMESH_Hexa_3D_i>;
+
+//---------------------------------------
+}
+
+//=============================================================================
+/*!
+ * Destructor: deletes specific hypothesis creators instanciated in the
+ * constructor.
+ */
+//=============================================================================
+
+SMESH_HypothesisFactory_i::~SMESH_HypothesisFactory_i()
+{
+ map<string, GenericHypothesisCreator_i*>::iterator it;
+ for (it = _creatorMap.begin(); it != _creatorMap.end(); it++)
+ {
+ delete (*it).second;
+ }
+ _creatorMap.clear();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis_i* SMESH_HypothesisFactory_i::Create(const char* anHyp,
+ CORBA::Long studyId,
+ ::SMESH_Gen* genImpl)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_HypothesisFactory::Create " << anHyp);
+ if (_creatorMap.find(anHyp) == _creatorMap.end())
+ {
+ MESSAGE("levee exception CORBA");
+ THROW_SALOME_CORBA_EXCEPTION("bad hypothesis type name", \
+ SALOME::BAD_PARAM);
+ }
+ SMESH_Hypothesis_i* myHyp = _creatorMap[anHyp]->Create(anHyp,
+ studyId,
+ genImpl);
+ return myHyp;
+}
+
+
--- /dev/null
+//=============================================================================
+// File : SMESH_HypothesisFactory_i.hxx
+// Created : dim mai 19 22:02:45 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_HYPOTHESISFACTORY_I_HXX_
+#define _SMESH_HYPOTHESISFACTORY_I_HXX_
+
+#include "SMESH_Hypothesis_i.hxx"
+#include <map>
+#include <string>
+
+class GenericHypothesisCreator_i
+{
+public:
+ virtual SMESH_Hypothesis_i* Create(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl) = 0;
+};
+
+class SMESH_HypothesisFactory_i
+{
+public:
+ SMESH_HypothesisFactory_i();
+ virtual ~SMESH_HypothesisFactory_i();
+
+ SMESH_Hypothesis_i* Create(const char* anHyp,
+ CORBA::Long studyId,
+ ::SMESH_Gen* genImpl)
+ throw (SALOME::SALOME_Exception);
+
+private:
+ map<string, GenericHypothesisCreator_i*> _creatorMap;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Hypothesis_i.cxx
+// Created : lun mai 6 13:42:11 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Hypothesis_i.hxx"
+#include "SMESH_Hypothesis.hxx"
+#include "SMESH_Gen.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis_i::SMESH_Hypothesis_i()
+{
+ MESSAGE("SMESH_Hypothesis_i");
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis_i::~SMESH_Hypothesis_i()
+{
+ MESSAGE("~SMESH_Hypothesis_i");
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+char* SMESH_Hypothesis_i::GetName()
+{
+ MESSAGE("GetName");
+ return CORBA::string_dup(_baseImpl->GetName());
+// const char* name = _baseImpl->GetName();
+// SCRUTE(name);
+// return CORBA::string_dup(name);
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long SMESH_Hypothesis_i::GetId()
+{
+ MESSAGE("GetId");
+ return _baseImpl->GetID();
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Hypothesis_i.hxx
+// Created : lun mai 6 13:42:08 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_HYPOTHESIS_I_HXX_
+#define _SMESH_HYPOTHESIS_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+
+class SMESH_Gen;
+class SMESH_Hypothesis;
+
+class SMESH_Hypothesis_i:
+ public POA_SMESH::SMESH_Hypothesis
+{
+public:
+ SMESH_Hypothesis_i();
+ virtual ~SMESH_Hypothesis_i();
+
+ char* GetName();
+ CORBA::Long GetId();
+
+protected:
+ ::SMESH_Hypothesis* _baseImpl;
+ ::SMESH_Gen* _genImpl;
+ int _id;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_LocalLength_i.cxx
+// Created : mar mai 14 13:07:42 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_LocalLength_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ * Constructor:
+ * _name is related to the class name: prefix = SMESH_ ; suffix = _i .
+ */
+//=============================================================================
+
+SMESH_LocalLength_i::SMESH_LocalLength_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+{
+ MESSAGE("SMESH_LocalLength_i::SMESH_LocalLength_i");
+ _impl = new ::SMESH_LocalLength(genImpl->_hypothesisFactory.GetANewId(),
+ studyId,
+ genImpl);
+ _baseImpl = _impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_LocalLength_i::~SMESH_LocalLength_i()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_LocalLength_i::SetLength(CORBA::Double length)
+ throw (SALOME::SALOME_Exception)
+{
+ ASSERT(_impl);
+ try
+ {
+ _impl->SetLength(length);
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), \
+ SALOME::BAD_PARAM);
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Double SMESH_LocalLength_i::GetLength()
+{
+ ASSERT(_impl);
+ return _impl->GetLength();
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_LocalLength_i.hxx
+// Created : mar mai 14 13:07:47 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_LOCALLENGTH_I_HXX_
+#define _SMESH_LOCALLENGTH_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_Hypothesis_i.hxx"
+
+#include "SMESH_LocalLength.hxx"
+
+class SMESH_LocalLength_i:
+ public POA_SMESH::SMESH_LocalLength,
+ public SMESH_Hypothesis_i
+{
+public:
+ SMESH_LocalLength_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl);
+ virtual ~SMESH_LocalLength_i();
+
+ void SetLength(CORBA::Double length)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Double GetLength();
+
+protected:
+ ::SMESH_LocalLength* _impl;
+};
+
+#endif
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MEDFamily_i.cxx
+// Project : SALOME
+// Copyright : EDF 2001
+//=============================================================================
+
+#include "SMESH_MEDFamily_i.hxx"
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+SMESH_MEDFamily_i::SMESH_MEDFamily_i()
+{
+ BEGIN_OF("Default Constructor SMESH_MEDFamily_i");
+ END_OF("Default Constructor SMESH_MEDFamily_i");
+}
+//=============================================================================
+/*!
+ * constructor par recopie
+ */
+//=============================================================================
+SMESH_MEDFamily_i::SMESH_MEDFamily_i(const SMESH_MEDFamily_i & f):
+ SMESH_MEDSupport_i(f._subMesh_i,f._name,f._description,f._entity),
+ _subMesh_i(f._subMesh_i),
+ _identifier(f._identifier),
+ _numberOfAttribute(f._numberOfAttribute),
+ _numberOfGroup(f._numberOfGroup),
+ _attributeValue(f._attributeValue)
+{
+ BEGIN_OF("Copy Constructor SMESH_MEDFamily_i");
+ _attributeDescription=new string[_numberOfAttribute];
+ for (int i=0;i<_numberOfAttribute;i++) {
+ _attributeDescription[i]=f._attributeDescription[i];
+ };
+ _groupName=new string[_numberOfGroup];
+ for (int i=0;i<_numberOfAttribute;i++) {
+ _groupName[i]=f._groupName[i];
+ };
+ END_OF("Copy Constructor SMESH_MEDFamily_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+SMESH_MEDFamily_i::~SMESH_MEDFamily_i()
+{
+}
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+SMESH_MEDFamily_i::SMESH_MEDFamily_i(int identifier, SMESH_subMesh_i* sm,
+ string name, string description, SALOME_MED::medEntityMesh entity):
+ SMESH_MEDSupport_i( sm, name, description, entity ),
+
+ _subMesh_i(sm),
+ _identifier(identifier),
+ _numberOfAttribute(0),
+ _attributeIdentifier((int*)NULL),
+ _attributeValue((int*)NULL),
+ _attributeDescription((string*)NULL),
+ _numberOfGroup(0),
+ _groupName((string*)NULL)
+{
+ BEGIN_OF("Constructor SMESH_MEDFamily_i");
+ END_OF("Constructor SMESH_MEDFamily_i");
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Family's Identifier
+ */
+//=============================================================================
+
+CORBA::Long SMESH_MEDFamily_i::getIdentifier()
+throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ return _identifier;
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for number of attributes
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDFamily_i::getNumberOfAttributes()
+throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ return _numberOfAttribute;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attributes identifiers
+ */
+//=============================================================================
+Engines::long_array* SMESH_MEDFamily_i::getAttributesIdentifiers()
+throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ if (_numberOfAttribute == 0)
+ {
+ MESSAGE("Les familles SMESH n ont pas d attribut");
+ THROW_SALOME_CORBA_EXCEPTION("No attributes"\
+ ,SALOME::BAD_PARAM);
+ };
+
+ Engines::long_array_var myseq= new Engines::long_array;
+ myseq->length(_numberOfAttribute);
+ for (int i=0;i<_numberOfAttribute;i++)
+ {
+ myseq[i]=_attributeIdentifier[i];
+ };
+ return myseq._retn();
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attribute identifier I
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDFamily_i::getAttributeIdentifier(CORBA::Long i)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ MESSAGE("Les familles SMESH n ont pas d attribut");
+ THROW_SALOME_CORBA_EXCEPTION("No attributes"\
+ ,SALOME::BAD_PARAM);
+ if (_numberOfAttribute = 0)
+ {
+ MESSAGE("Les familles SMESH n ont pas d attribut");
+ THROW_SALOME_CORBA_EXCEPTION("No attributes"\
+ ,SALOME::BAD_PARAM);
+ };
+ ASSERT (i <= _numberOfAttribute);
+ return _attributeIdentifier[i];
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attributes values
+ */
+//=============================================================================
+Engines::long_array* SMESH_MEDFamily_i::getAttributesValues()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+
+ if (_numberOfAttribute == 0)
+ {
+ MESSAGE("Les familles SMESH n ont pas d attribut");
+ THROW_SALOME_CORBA_EXCEPTION("No attributes"\
+ ,SALOME::BAD_PARAM);
+ };
+
+ Engines::long_array_var myseq= new Engines::long_array;
+ myseq->length(_numberOfAttribute);
+ for (int i=0;i<_numberOfAttribute;i++)
+ {
+ myseq[i]=_attributeValue[i];
+ };
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attribute value I
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDFamily_i::getAttributeValue(CORBA::Long i)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ if (_numberOfAttribute = 0)
+ {
+ MESSAGE("Les familles SMESH n ont pas d attribut");
+ THROW_SALOME_CORBA_EXCEPTION("No attributes"\
+ ,SALOME::BAD_PARAM);
+ }
+
+ ASSERT (i <= _numberOfAttribute);
+ return _attributeValue[i];
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attributes desriptions
+ */
+//=============================================================================
+Engines::string_array * SMESH_MEDFamily_i::getAttributesDescriptions()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ if (_numberOfAttribute = 0)
+ {
+ MESSAGE("Les familles SMESH n ont pas d attribut");
+ THROW_SALOME_CORBA_EXCEPTION("No attributes"\
+ ,SALOME::BAD_PARAM);
+ }
+ Engines::string_array_var myseq = new Engines::string_array;
+ for (int i=0;i<_numberOfAttribute;i++)
+ {
+ myseq[i]=CORBA::string_dup(_attributeDescription[i].c_str());
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for attribute description i
+ */
+//=============================================================================
+char * SMESH_MEDFamily_i::getAttributeDescription( CORBA::Long i)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
+ SALOME::INTERNAL_ERROR);
+ if (_numberOfAttribute = 0)
+ {
+ MESSAGE("Les familles SMESH n ont pas d attribut");
+ THROW_SALOME_CORBA_EXCEPTION("No attributes"\
+ ,SALOME::BAD_PARAM);
+ }
+ ASSERT (i <= _numberOfAttribute);
+ return CORBA::string_dup(_attributeDescription[i].c_str());
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_MEDFamily_i.hxx
+// Project : SALOME
+// Copyright : EDF 2001
+//=============================================================================
+
+#ifndef SMESH_MED_FAMILY_I_HXX_
+#define SMESH_MED_FAMILY_I_HXX_
+
+#include "SMESH_MEDSupport_i.hxx"
+
+#include<string>
+
+class SMESH_MEDFamily_i:
+ public POA_SALOME_MED::FAMILY,
+ public SMESH_MEDSupport_i
+{
+protected :
+ SMESH_MEDFamily_i();
+ ~SMESH_MEDFamily_i();
+
+ ::SMESH_subMesh_i* _subMesh_i;
+
+ // Values
+ int _identifier;
+ int _numberOfAttribute;
+ int * _attributeIdentifier;
+ int * _attributeValue;
+ string * _attributeDescription;
+ int _numberOfGroup ;
+ string * _groupName ;
+
+
+public :
+
+ // Constructors and associated internal methods
+ SMESH_MEDFamily_i(int identifier, SMESH_subMesh_i* sm,
+ string name, string description, SALOME_MED::medEntityMesh entity );
+ SMESH_MEDFamily_i(const SMESH_MEDFamily_i & f);
+
+ CORBA::Long getIdentifier()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfAttributes()
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getAttributesIdentifiers()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getAttributeIdentifier(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getAttributesValues()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getAttributeValue(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ Engines::string_array* getAttributesDescriptions()
+ throw (SALOME::SALOME_Exception);
+ char* getAttributeDescription( CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+
+};
+#endif /* MED_FAMILY_I_HXX_ */
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MEDMesh_i.cxx
+// Project : SALOME
+// Copyright : EDF 2001
+//=============================================================================
+
+#include "SMESH_MEDMesh_i.hxx"
+#include "SMESH_Mesh_i.hxx"
+
+#include "SMESHDS_Mesh.hxx"
+#include "SMESHDS_SubMesh.hxx"
+
+#include "SMDS_MapIteratorOfExtendedMap.hxx"
+#include "SMDS_MapOfMeshElement.hxx"
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_CompSolid.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_MapOfShape.hxx>
+
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+
+#include "SMESH_MEDSupport_i.hxx"
+#include "SMESH_MEDFamily_i.hxx"
+
+# include "Utils_ORB_INIT.hxx"
+# include "Utils_SINGLETON.hxx"
+extern "C"
+{
+#include <stdio.h>
+}
+
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+// PN Est-ce un const ?
+SMESH_MEDMesh_i::SMESH_MEDMesh_i()
+{
+ BEGIN_OF("Default Constructor SMESH_MEDMesh_i");
+ END_OF("Default Constructor SMESH_MEDMesh_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+SMESH_MEDMesh_i::~SMESH_MEDMesh_i()
+{
+}
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+SMESH_MEDMesh_i::SMESH_MEDMesh_i( ::SMESH_Mesh_i* m_i ) :_meshId(""),
+ _compte(false),
+ _creeFamily(false),
+ _famIdent(0),
+ _indexElts(0),
+ _indexEnts(0)
+{
+ _mesh_i = m_i;
+ _meshDS = _mesh_i->GetImpl().GetMeshDS();
+
+ BEGIN_OF("Constructor SMESH_MEDMesh_i");
+ END_OF("Constructor SMESH_MEDMesh_i");
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Name
+ */
+//=============================================================================
+char * SMESH_MEDMesh_i::getName()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_meshDS == NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+
+ try
+ {
+ // A COMPLETER PAR LE NOM DU MAILLAGE
+ //return CORBA::string_dup(_mesh_i->getName().c_str());
+ return CORBA::string_dup("toto");
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au nom");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for corbaindex cuisine interne
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getCorbaIndex()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Non Implemente");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Space Dimension
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getSpaceDimension()
+ throw (SALOME::SALOME_Exception)
+{
+ // PN : Il semblerait que la dimension soit fixee a 3
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ return 3;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Mesh Dimension
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getMeshDimension()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ // PN : Il semblerait que la dimension soit fixee a 3
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ return 3;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates System
+ */
+//=============================================================================
+char * SMESH_MEDMesh_i::getCoordinateSystem()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ // PN : En dur. Non encore prevu
+ try
+ {
+ string systcoo="CARTESIEN";
+ return CORBA::string_dup(systcoo.c_str());
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au maillage");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates
+ */
+//=============================================================================
+Engines::double_array * SMESH_MEDMesh_i::getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::double_array_var myseq = new Engines::double_array;
+ try
+ {
+ // PN : En dur
+ int spaceDimension=3;
+ int nbNodes=_meshDS->NbNodes();
+ SCRUTE(nbNodes);
+ myseq->length(nbNodes*spaceDimension);
+ int i = 0;
+ SMDS_MeshNodesIterator itNodes(_meshDS);
+ for (;itNodes.More();itNodes.Next())
+ {
+
+ const Handle(SMDS_MeshElement)& elem = itNodes.Value();
+ const Handle(SMDS_MeshNode)& node =_meshDS->GetNode(1,elem);
+
+ if (typeSwitch == SALOME_MED::MED_FULL_INTERLACE)
+ {
+ myseq[i*3]=node->X();
+ myseq[i*3+1]=node->Y();
+ myseq[i*3+2]=node->Z();
+ SCRUTE(myseq[i*3]);
+ SCRUTE(myseq[i*3+1]);
+ SCRUTE(myseq[i*3+2]);
+ }
+ else
+ {
+ ASSERT(typeSwitch == SALOME_MED::MED_NO_INTERLACE);
+ myseq[i]=node->X();
+ myseq[i+nbNodes]=node->Y();
+ myseq[i+(nbNodes*2)]=node->Z();
+ SCRUTE(myseq[i]);
+ SCRUTE(myseq[i+nbNodes]);
+ SCRUTE(myseq[i+(nbNodes*2)]);
+ }
+ i++;
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant aux coordonnees");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates Names
+ */
+//=============================================================================
+Engines::string_array * SMESH_MEDMesh_i::getCoordinatesNames()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ // PN : en dur
+ int spaceDimension=3;
+ myseq->length(spaceDimension);
+ myseq[0]=CORBA::string_dup("x");
+ myseq[1]=CORBA::string_dup("y");
+ myseq[2]=CORBA::string_dup("z");
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant aux noms des coordonnees");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Coordinates Units
+ */
+//=============================================================================
+Engines::string_array * SMESH_MEDMesh_i::getCoordinatesUnits()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ Engines::string_array_var myseq = new Engines::string_array;
+ try
+ {
+ // PN : en dur
+ int spaceDimension=3;
+ myseq->length(spaceDimension);
+ myseq[0]=CORBA::string_dup("m");
+ myseq[1]=CORBA::string_dup("m");
+ myseq[2]=CORBA::string_dup("m");
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant aux unites des coordonnees");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Number of Nodes
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getNumberOfNodes()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _meshDS->NbNodes();
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au nombre de noeuds");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for number of Types
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ if (! _compte)
+ calculeNbElts();
+ int retour = 0;
+ if ( _mapNbTypes.find(entity)!=_mapNbTypes.end())
+ retour=_mapNbTypes[entity];
+ return retour;
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au nombre de Types");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for existing geometry element types
+ * Not implemented for MED_ALL_ENTITIES
+ */
+//=============================================================================
+SALOME_MED::medGeometryElement_array * SMESH_MEDMesh_i::getTypes (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ if (entity ==SALOME_MED::MED_ALL_ENTITIES)
+ THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\
+ SALOME::BAD_PARAM);
+ if (! _compte)
+ calculeNbElts();
+ SALOME_MED::medGeometryElement_array_var myseq =
+ new SALOME_MED::medGeometryElement_array;
+ try
+ {
+ if ( _mapNbTypes.find(entity) ==_mapNbTypes.end())
+ THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh"\
+ ,SALOME::BAD_PARAM);
+ int nbTypes=_mapNbTypes[entity];
+
+ myseq->length(nbTypes);
+
+ if ( _mapIndToVectTypes.find(entity) ==_mapIndToVectTypes.end())
+ THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh"\
+ ,SALOME::INTERNAL_ERROR);
+
+ int index=_mapIndToVectTypes[entity];
+ ASSERT( _TypesId[index].size()!=0);
+ int i=0;
+ vector<SALOME_MED::medGeometryElement>::iterator it;
+ for (it=_TypesId[index].begin();it!=_TypesId[index].end();it++)
+ {
+ myseq[i++]=*it;
+ };
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant aux differents types");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Returns number of elements of type medGeometryElement
+ * Not implemented for MED_ALL_ELEMENTS
+ * implemented for MED_ALL_ENTITIES
+ *
+ * Dans cette implementation, il n est pas prevu de tenir compte du entity
+ * qui ne doit pas pouvoir avoir deux valeurs differentes pour un geomElement
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getNumberOfElements(SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ if (geomElement == SALOME_MED::MED_ALL_ELEMENTS)
+ THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ELEMENTS", \
+ SALOME::BAD_PARAM);
+ if (! _compte)
+ calculeNbElts();
+
+ try
+ {
+ int retour = 0;
+ if ( _mapIndToSeqElts.find(geomElement)!=_mapIndToSeqElts.end())
+ {
+ int index = _mapIndToSeqElts[geomElement];
+ retour=_seq_elemId[index]->length();
+ }
+ return retour;
+ }
+ catch(...)
+ {
+ MESSAGE("Exception en accedant au nombre d élements");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for connectivities
+ */
+//=============================================================================
+Engines::long_array * SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
+ SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ if (mode != SALOME_MED::MED_NODAL)
+ THROW_SALOME_CORBA_EXCEPTION("Not Implemented",\
+ SALOME::BAD_PARAM);
+ if (typeSwitch == SALOME_MED::MED_NO_INTERLACE)
+ THROW_SALOME_CORBA_EXCEPTION("Not Yet Implemented",\
+ SALOME::BAD_PARAM);
+ if (! _compte)
+ calculeNbElts();
+
+ // Faut-il renvoyer un pointeur vide ???
+ if ( _mapIndToSeqElts.find(geomElement)!=_mapIndToSeqElts.end())
+ THROW_SALOME_CORBA_EXCEPTION("No Such Element in the mesh"\
+ ,SALOME::BAD_PARAM);
+
+ int index=_mapIndToSeqElts[geomElement];
+ return _seq_elemId[index]._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for connectivities
+ */
+//=============================================================================
+Engines::long_array* SMESH_MEDMesh_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA: Find an element corresponding to the given connectivity
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getElementNumber(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement type,
+ const Engines::long_array & connectivity
+)
+ throw (SALOME::SALOME_Exception)
+{
+ const char * LOC = "getElementNumber ";
+ MESSAGE(LOC<<"Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return -1;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Ascendant connectivities
+ * not implemented for MED_ALL_ENTITIES and MED_MAILLE
+ */
+//=============================================================================
+Engines::long_array* SMESH_MEDMesh_i::getReverseConnectivity(SALOME_MED::medConnectivity mode)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for connectivities
+ */
+//=============================================================================
+Engines::long_array* SMESH_MEDMesh_i::getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA: Returns number of families within the mesh
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_creeFamily == false)
+ createFamilies();
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ return _families.size();
+}
+//=============================================================================
+/*!
+ * CORBA: Returns number of groups within the mesh
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ MESSAGE(" Pas d implementation des groupes dans SMESH");
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for families within the mesh
+ */
+//=============================================================================
+SALOME_MED::Family_array * SMESH_MEDMesh_i::getFamilies(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_creeFamily == false)
+ createFamilies();
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
+ int nbfam= _families.size();
+ myseq->length(nbfam);
+ int i = 0;
+ vector<SALOME_MED::FAMILY_ptr>::iterator it;
+ for (it=_families.begin();it!=_families.end();it++)
+ {
+ myseq[i++]=*it;
+ };
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for family i within the mesh
+ */
+//=============================================================================
+SALOME_MED::FAMILY_ptr SMESH_MEDMesh_i::getFamily(SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_creeFamily == false)
+ createFamilies();
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+
+ SCRUTE(_families[i]->getName());
+ MESSAGE ( " SMESH_MEDMesh_i::getFamily " << i )
+ return _families[i];
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for groups within the mesh
+ */
+//=============================================================================
+SALOME_MED::Group_array * SMESH_MEDMesh_i::getGroups(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ MESSAGE(" Pas d implementation des groupes dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("No group implementation"\
+ ,SALOME::BAD_PARAM);
+}
+//=============================================================================
+/*!
+ * CORBA: Returns references for group i within the mesh
+ */
+//=============================================================================
+SALOME_MED::GROUP_ptr SMESH_MEDMesh_i::getGroup(SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh_i == 0)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ MESSAGE(" Pas d implementation des groupes dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("No group implementation"\
+ ,SALOME::BAD_PARAM);
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Pas Implemente dans SMESH");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA:
+ */
+//=============================================================================
+SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Non Implemente");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * CORBA: add the Mesh in the StudyManager
+ * PN Pas Implemente
+ */
+//=============================================================================
+void SMESH_MEDMesh_i::addInStudy(SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::MESH_ptr myIor)
+ throw (SALOME::SALOME_Exception)
+{
+ BEGIN_OF("MED_Mesh_i::addInStudy");
+ if ( _meshId != "" )
+ {
+ MESSAGE("Mesh already in Study");
+ THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
+ SALOME::BAD_PARAM);
+ };
+
+ /*
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+
+ // Create SComponent labelled 'MED' if it doesn't already exit
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
+ if ( CORBA::is_nil(medfather) )
+ {
+ MESSAGE("Add Component MED");
+ medfather = myBuilder->NewComponent("MED");
+ //myBuilder->AddAttribute (medfather,SALOMEDS::Name,"MED");
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
+ myBuilder->FindOrCreateAttribute(medfather, "AttributeName"));
+ aName->SetValue("MED");
+
+ myBuilder->DefineComponentInstance(medfather,myIor);
+
+ } ;
+
+ MESSAGE("Add a mesh Object under MED");
+ myBuilder->NewCommand();
+ SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+ string iorStr = orb->object_to_string(myIor);
+ //myBuilder->AddAttribute(newObj,SALOMEDS::IOR,iorStr.c_str());
+ SALOMEDS::AttributeIOR_var aIOR = SALOMEDS::AttributeIOR::_narrow(
+ myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"));
+ aIOR->SetValue(iorStr.c_str());
+
+ //myBuilder->AddAttribute(newObj,SALOMEDS::Name,_mesh_i->getName().c_str());
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
+ myBuilder->FindOrCreateAttribute(newObj, "AttributeName"));
+ aName->SetValue(_mesh_i->getName().c_str());
+
+ _meshId = newObj->GetID();
+ myBuilder->CommitCommand();
+
+ */
+ END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
+}
+//=============================================================================
+/*!
+ * CORBA: write mesh in a med file
+ */
+//=============================================================================
+void SMESH_MEDMesh_i::write(CORBA::Long i, const char* driverMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Non Implemente");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+}
+//=============================================================================
+/*!
+ * CORBA: read mesh in a med file
+ */
+//=============================================================================
+void SMESH_MEDMesh_i::read(CORBA::Long i)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Non Implemente");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+}
+//=============================================================================
+/*!
+ * CORBA : release driver
+ */
+//=============================================================================
+void SMESH_MEDMesh_i::rmDriver(CORBA::Long i)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Non Implemente");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+}
+//=============================================================================
+/*!
+ * CORBA : attach driver
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDMesh_i::addDriver(SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* meshName)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Non Implemente");
+ THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
+ ,SALOME::BAD_PARAM);
+ return 0;
+}
+//=============================================================================
+/*!
+ * Calcule le Nb d'elements par entite geometrique
+ */
+//=============================================================================
+void SMESH_MEDMesh_i::calculeNbElts()
+ throw (SALOME::SALOME_Exception)
+{
+ if (! _compte)
+ {
+ _compte=true;
+
+ _mapNbTypes[SALOME_MED::MED_NODE]=1;
+ // On compte les aretes MED_SEG2 ou MED_SEG3
+ // On range les elements dans les vecteurs correspondants
+
+ _mapIndToSeqElts[SALOME_MED::MED_SEG2]=_indexElts++;
+ _mapIndToSeqElts[SALOME_MED::MED_SEG3]=_indexElts++;
+ _mapIndToVectTypes[SALOME_MED::MED_EDGE]=_indexEnts++;
+
+ int trouveSeg2=0;
+ int trouveSeg3=0;
+ SALOME_MED::medGeometryElement medElement;
+ SMDS_MeshEdgesIterator itEdges(_meshDS);
+ for (;itEdges.More();itEdges.Next())
+ {
+ const Handle(SMDS_MeshElement)& elem = itEdges.Value();
+ int nb_of_nodes = elem->NbNodes();
+
+ switch (nb_of_nodes)
+ {
+ case 2 :
+ {
+ medElement=SALOME_MED::MED_SEG2;
+ if (trouveSeg2==0)
+ {
+ trouveSeg2=1;
+ _TypesId[SALOME_MED::MED_EDGE].push_back(SALOME_MED::MED_SEG2);
+
+ }
+ break;
+ }
+ case 3 :
+ {
+ medElement=SALOME_MED::MED_SEG3;
+ if (trouveSeg3==0)
+ {
+ trouveSeg3=1;
+ _TypesId[SALOME_MED::MED_EDGE].push_back(SALOME_MED::MED_SEG3);
+ }
+ break;
+ }
+ }
+ int index=_mapIndToSeqElts[medElement];
+ SCRUTE(index);
+ // Traitement de l arete
+ int longueur=_seq_elemId[index]->length();
+ _seq_elemId[index]->length(longueur + nb_of_nodes);
+
+ for (int k=0; k<nb_of_nodes; k++)
+ {
+ _seq_elemId[index][longueur+k]=elem->GetConnection(k+1) +1;
+ }
+ }
+
+ _mapNbTypes[SALOME_MED::MED_EDGE]=trouveSeg2 + trouveSeg3;
+
+ // On compte les faces MED_TRIA3, MED_HEXA8, MED_TRIA6
+ // On range les elements dans les vecteurs correspondants
+ int trouveTria3=0;
+ int trouveTria6=0;
+ int trouveQuad4=0;
+
+ _mapIndToSeqElts[SALOME_MED::MED_TRIA3]=_indexElts++;
+ _mapIndToSeqElts[SALOME_MED::MED_TRIA6]=_indexElts++;
+ _mapIndToSeqElts[SALOME_MED::MED_QUAD4]=_indexElts++;
+ _mapIndToVectTypes[SALOME_MED::MED_FACE]=_indexEnts++;
+
+ SMDS_MeshFacesIterator itFaces(_meshDS);
+ for (;itFaces.More();itFaces.Next())
+ {
+
+ const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+ int nb_of_nodes = elem->NbNodes();
+
+ switch (nb_of_nodes)
+ {
+ case 3 :
+ {
+ medElement=SALOME_MED::MED_TRIA3;
+ if (trouveTria3==0)
+ {
+ trouveTria3=1;
+ _TypesId[SALOME_MED::MED_FACE].push_back(SALOME_MED::MED_TRIA3);
+ }
+ break;
+ }
+ case 4 :
+ {
+ medElement=SALOME_MED::MED_QUAD4;
+ if (trouveQuad4==0)
+ {
+ trouveQuad4=1;
+ _TypesId[SALOME_MED::MED_FACE].push_back(SALOME_MED::MED_QUAD4);
+ }
+ break;
+ }
+ case 6 :
+ {
+ medElement=SALOME_MED::MED_TRIA6;
+ if (trouveTria6==0)
+ {
+ trouveTria6=1;
+ _TypesId[SALOME_MED::MED_FACE].push_back(SALOME_MED::MED_TRIA6);
+ }
+ break;
+ }
+ }
+ int index=_mapIndToSeqElts[medElement];
+ SCRUTE(index);
+
+ // Traitement de la face
+ // Attention La numérotation des noeuds Med commence a 1
+
+
+ int longueur = _seq_elemId[index]->length();
+ _seq_elemId[index]->length(longueur+nb_of_nodes);
+
+ for (int k=0; k<nb_of_nodes; k++)
+ {
+ _seq_elemId[index][longueur+k]=elem->GetConnection(k+1) +1;
+ }
+
+ }
+ _mapNbTypes[SALOME_MED::MED_FACE]=trouveTria3 + trouveTria6 + trouveQuad4;
+
+ _mapIndToSeqElts[SALOME_MED::MED_HEXA8]=_indexElts++;
+ _mapIndToVectTypes[SALOME_MED::MED_CELL]=_indexEnts++;
+ int index=_mapIndToSeqElts[medElement];
+
+ int trouveHexa8=0;
+ SMDS_MeshVolumesIterator itVolumes(_meshDS);
+ for (;itVolumes.More();itVolumes.Next())
+ {
+ const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+ int nb_of_nodes = elem->NbNodes();
+ medElement=SALOME_MED::MED_HEXA8;
+ ASSERT(nb_of_nodes=8);
+
+ if (trouveHexa8 == 0)
+ {
+ trouveHexa8=1;
+ _TypesId[SALOME_MED::MED_CELL].push_back(SALOME_MED::MED_HEXA8);
+ };
+ // Traitement de la maille
+ int longueur=_seq_elemId[index]->length();
+ _seq_elemId[index]->length(longueur+nb_of_nodes);
+
+ for (int k=0; k<nb_of_nodes; k++)
+ {
+ _seq_elemId[index][longueur+k]=elem->GetConnection(k+1) +1;
+ }
+
+ }
+
+ _mapNbTypes[SALOME_MED::MED_CELL]=trouveHexa8;
+ _mapNbTypes[SALOME_MED::MED_ALL_ENTITIES]
+ =trouveHexa8 + trouveTria3 + trouveTria6 + trouveQuad4 + trouveSeg2 + trouveSeg3 ;
+ } /* fin du _compte */
+};
+//=============================================================================
+/*!
+ * Creation des familles
+ */
+//=============================================================================
+void SMESH_MEDMesh_i::createFamilies()
+ throw (SALOME::SALOME_Exception)
+{
+ string famDes=("Je ne sais pas");
+ string famName0="Famille_";
+ string famName;
+ char numero[10];
+
+ if ( _creeFamily == false)
+ {
+ _creeFamily = true;
+ SMESH_subMesh_i* subMeshServant;
+
+ map<int, SMESH_subMesh_i*>::iterator it;
+ for (it = _mesh_i->_mapSubMesh_i.begin(); it != _mesh_i->_mapSubMesh_i.end(); it++) {
+ SMESH_subMesh_i* submesh_i = (*it).second;
+ int famIdent = (*it).first;
+
+ ASSERT (famIdent<999999999);
+ sprintf(numero,"%d\n",famIdent);
+ famName=famName0 + numero;
+
+ SMESH_MEDFamily_i * famservant= new SMESH_MEDFamily_i(famIdent, submesh_i,
+ famName, famDes, SALOME_MED::MED_NODE);
+ SALOME_MED::FAMILY_ptr famille =
+ SALOME_MED::FAMILY::_narrow(famservant->POA_SALOME_MED::FAMILY::_this());
+ _families.push_back(famille);
+ }
+ } /* fin du _compte */
+};
+
--- /dev/null
+//=============================================================================
+// File : SMESH_MEDMesh_i.hxx
+// Project : SALOME
+// Copyright : EDF 2001
+//=============================================================================
+
+#ifndef _MED_SMESH_MESH_I_HXX_
+#define _MED_SMESH_MESH_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(MED)
+#include <string>
+#include <vector>
+#include <map>
+
+#include "SMESHDS_Mesh.hxx"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshEdgesIterator.hxx"
+#include "SMDS_MeshNodesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+
+#define MED_NBR_GEOMETRIE_MAILLE 15
+#define MED_NBR_TYPE 5
+
+
+class SMESH_Mesh_i;
+
+class SMESH_MEDMesh_i:
+ public POA_SALOME_MED::MESH,
+ public PortableServer::RefCountServantBase
+{
+public :
+
+private :
+
+protected:
+ // C++ object containing values
+ ::SMESH_Mesh_i* _mesh_i;
+ Handle (SMESHDS_Mesh) _meshDS;
+
+ string _meshId;
+ bool _compte;
+ bool _creeFamily;
+ int _indexElts;
+ int _indexEnts;
+ int _famIdent;
+
+ map <SALOME_MED::medGeometryElement,int> _mapIndToSeqElts;
+ Engines::long_array_var _seq_elemId[MED_NBR_GEOMETRIE_MAILLE];
+
+ map <SALOME_MED::medEntityMesh,int> _mapNbTypes;
+ map <SALOME_MED::medEntityMesh,int> _mapIndToVectTypes;
+ vector<SALOME_MED::medGeometryElement> _TypesId[MED_NBR_GEOMETRIE_MAILLE];
+
+ vector<SALOME_MED::FAMILY_ptr> _families;
+public:
+
+ // Constructors and associated internal methods
+ SMESH_MEDMesh_i();
+ SMESH_MEDMesh_i(SMESH_Mesh_i* m);
+ ~SMESH_MEDMesh_i();
+
+ // IDL Methods
+ char * getName() throw (SALOME::SALOME_Exception);
+ CORBA::Long getSpaceDimension() throw (SALOME::SALOME_Exception);
+ CORBA::Long getMeshDimension() throw (SALOME::SALOME_Exception);
+
+ char * getCoordinateSystem()
+ throw (SALOME::SALOME_Exception);
+ Engines::double_array* getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+ throw (SALOME::SALOME_Exception);
+ Engines::string_array* getCoordinatesNames()
+ throw (SALOME::SALOME_Exception);
+ Engines::string_array* getCoordinatesUnits()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfNodes()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getNumberOfTypes (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::medGeometryElement_array* getTypes(SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getNumberOfElements (SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getConnectivity (SALOME_MED::medModeSwitch typeSwitch,
+ SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getConnectivityIndex(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long getElementNumber(SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement type,
+ const Engines::long_array & connectivity)
+ throw (SALOME::SALOME_Exception);
+
+ Engines::long_array* getReverseConnectivity(SALOME_MED::medConnectivity mode)
+
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
+ throw (SALOME::SALOME_Exception);
+
+ // Family and Group
+ CORBA::Long getNumberOfFamilies (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfGroups (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::Family_array* getFamilies (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FAMILY_ptr getFamily (SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::Group_array* getGroups (SALOME_MED::medEntityMesh entity)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::GROUP_ptr getGroup (SALOME_MED::medEntityMesh entity,
+ CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ //
+ SALOME_MED::FIELD_ptr getVolume (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getArea (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getLength (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getNormal (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getBarycenter (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::FIELD_ptr getNeighbourhood (SALOME_MED::SUPPORT_ptr mySupport)
+ throw (SALOME::SALOME_Exception);
+
+
+ // Others
+ void addInStudy (SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::MESH_ptr myIor)
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* meshName)
+ throw (SALOME::SALOME_Exception);
+ void rmDriver (CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ void read (CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ void write (CORBA::Long i, const char* driverMeshName)
+ throw (SALOME::SALOME_Exception);
+
+ // Cuisine interne
+ CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
+
+ //
+ void calculeNbElts() throw (SALOME::SALOME_Exception);
+ void createFamilies() throw (SALOME::SALOME_Exception);
+};
+
+#endif /* _MED_MESH_I_HXX_ */
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MEDSupport_i.cxx
+// Project : SALOME
+// Copyright : EDF 2002
+//=============================================================================
+
+#include "SMESH_MEDSupport_i.hxx"
+#include "utilities.h"
+#include "Utils_CorbaException.hxx"
+
+#include <TopoDS_Iterator.hxx>
+#include "SMESHDS_Mesh.hxx"
+#include "SMDS_MapIteratorOfExtendedMap.hxx"
+
+#include "SMESH_subMesh.hxx"
+#include "SMESH_Mesh_i.hxx"
+#include "SMESH_subMesh_i.hxx"
+
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+SMESH_MEDSupport_i::SMESH_MEDSupport_i()
+{
+ BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
+ END_OF("Default Constructor SMESH_MEDSupport_i");
+}
+
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i* sm,
+ string name,
+ string description,
+ SALOME_MED::medEntityMesh entity) :
+ _subMesh_i(sm),
+ _name(name),
+ _description(description),
+ _entity(entity),
+ _seqNumber(false),
+ _seqLength(0)
+{
+ BEGIN_OF("Constructor SMESH_MEDSupport_i");
+
+ _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
+
+ int subMeshId = _subMesh_i->GetId();
+
+ MESSAGE ( " subMeshId " << subMeshId )
+ if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) != _subMesh_i->_mesh_i->_mapSubMesh.end()) {
+ ::SMESH_subMesh* subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
+
+ _subMeshDS = subMesh->GetSubMeshDS();
+ }
+
+ if ( _entity == SALOME_MED::MED_NODE)
+ {
+ _numberOfGeometricType = 1 ;
+ _geometricType = new SALOME_MED::medGeometryElement[1] ;
+ _geometricType[0] = SALOME_MED::MED_NONE ;
+ }
+ else
+ {
+ MESSAGE("Pas implemente dans cette version");
+ THROW_SALOME_CORBA_EXCEPTION("Seules les familles de noeuds sont implementees ", \
+ SALOME::BAD_PARAM);
+ }
+
+ END_OF("Constructor SMESH_MEDSupport_i");
+}
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+SMESH_MEDSupport_i::SMESH_MEDSupport_i(const SMESH_MEDSupport_i &s) :
+ _subMesh_i(s._subMesh_i),
+ _name(s._name),
+ _description(s._description),
+ _entity(s._entity),
+ _seqNumber(false),
+ _seqLength(0)
+{
+ BEGIN_OF("Constructor SMESH_MEDSupport_i");
+
+ _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
+
+ int subMeshId = _subMesh_i->GetId();
+ if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) != _subMesh_i->_mesh_i->_mapSubMesh.end()) {
+ ::SMESH_subMesh* subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
+ _subMeshDS = subMesh->GetSubMeshDS();
+ }
+
+ END_OF("Constructor SMESH_MEDSupport_i");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+
+SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
+{
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Corba Index
+ */
+//=============================================================================
+
+CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ MESSAGE("Not implemented for SMESH_i");
+ THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", \
+ SALOME::BAD_PARAM);
+
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Name
+ */
+//=============================================================================
+
+char * SMESH_MEDSupport_i::getName()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ return CORBA::string_dup(_name.c_str());
+
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Description
+ */
+//=============================================================================
+
+char* SMESH_MEDSupport_i::getDescription()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ return CORBA::string_dup(_description.c_str());
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for Mesh
+ */
+//=============================================================================
+
+SALOME_MED::MESH_ptr SMESH_MEDSupport_i::getMesh()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+
+ return _subMesh_i->_mesh_i->GetMEDMesh();
+}
+
+//=============================================================================
+/*!
+ * CORBA: boolean indicating if support concerns all elements
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ if (_seqNumber == false)
+ {
+ if (_entity != SALOME_MED::MED_NONE)
+ {
+ int i = 0;
+ const SMDS_MapOfMeshElement& myNodesMap = _subMeshDS->GetNodes();
+ for (SMDS_MapIteratorOfExtendedMap it(myNodesMap); it.More(); it.Next())
+ {
+ const Handle(SMDS_MeshElement)& elem = myNodesMap.FindID(it.Key()->GetID());
+ const Handle(SMDS_MeshNode)& node = _meshDS->GetNode(1,elem);
+ i ++;
+ }
+ _seqLength=i;
+ _seqNumber=true;
+ }
+ else
+ {
+ MESSAGE("Only Node Families are implemented ");
+ THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ", \
+ SALOME::BAD_PARAM);
+ }
+ }
+ try
+ {
+ if (_seqLength == _meshDS->NbNodes())
+ _isOnAllElements=true;
+ else
+ _isOnAllElements=false;
+ }
+ catch(...)
+ {
+ MESSAGE("unable to acces related Mesh");
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ };
+ return _isOnAllElements;
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for type of support's entity
+ */
+//=============================================================================
+
+SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ return _entity;
+}
+
+//=============================================================================
+/*!
+ * CORBA: Accessor for types of geometry elements
+ */
+//=============================================================================
+
+SALOME_MED::medGeometryElement_array * SMESH_MEDSupport_i::getTypes()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::medGeometryElement_array_var myseq = new SALOME_MED::medGeometryElement_array;
+ try
+ {
+ int mySeqLength = _numberOfGeometricType;
+ myseq->length(mySeqLength);
+ for (int i=0;i<mySeqLength;i++)
+ {
+ myseq[i]=_geometricType[i];
+ }
+ }
+ catch(...)
+ {
+ MESSAGE("Exception lors de la recherche des differents types");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types", \
+ SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+
+//=============================================================================
+/*!
+ * CORBA: Number of different types of geometry elements
+ * existing in the support
+ */
+//=============================================================================
+CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ return _numberOfGeometricType;
+
+}
+
+//=============================================================================
+/*!
+ * CORBA: get Nodes
+ */
+//=============================================================================
+
+Engines::long_array * SMESH_MEDSupport_i::getNumber(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_subMeshDS.IsNull())
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+
+
+ // A changer s'il ne s agit plus seulement de famille de noeuds
+ if (geomElement != SALOME_MED::MED_NONE)
+ THROW_SALOME_CORBA_EXCEPTION("Not implemented", \
+ SALOME::BAD_PARAM);
+
+ Engines::long_array_var myseq= new Engines::long_array;
+
+ int i =0;
+ const SMDS_MapOfMeshElement& myNodesMap = _subMeshDS->GetNodes();
+ for (SMDS_MapIteratorOfExtendedMap it(myNodesMap); it.More(); it.Next())
+ {
+ const Handle(SMDS_MeshElement)& elem = myNodesMap.FindID(it.Key()->GetID());
+ const Handle(SMDS_MeshNode)& node = _meshDS->GetNode(1,elem);
+ myseq->length(i+1);
+ myseq[i]=node->GetID();
+SCRUTE(node->GetID());
+SCRUTE(myseq[i]);
+ i++;
+ };
+
+SCRUTE(myseq->length());
+MESSAGE("yyyyy");
+ return myseq._retn();
+
+}
+//=============================================================================
+/*!
+ * CORBA: Global Nodes Index (optionnaly designed by the user)
+ * CORBA: ??????????????????????????????
+ */
+//=============================================================================
+
+Engines::long_array * SMESH_MEDSupport_i::getNumberIndex()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Not implemented for SMESH_i");
+ THROW_SALOME_CORBA_EXCEPTION("Not Implemented", \
+ SALOME::BAD_PARAM);
+ return 0;
+}
+
+//=============================================================================
+/*!
+ * CORBA: Array containing indexes for elements included in the support
+ */
+//=============================================================================
+
+CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoints(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("Not implemented for SMESH_i");
+ return 0;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_MEDSupport_i.hxx
+// Project : SALOME
+// Copyright : EDF 2001
+//=============================================================================
+
+#ifndef _MED_SMESH_MEDSUPPORT_I_HXX_
+#define _MED_SMESH_MEDSUPPORT_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(MED)
+#include <string>
+
+#include "SMESHDS_Mesh.hxx"
+#include "SMESHDS_SubMesh.hxx"
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+
+#include "SMESH_MEDSupport_i.hxx"
+
+class SMESH_subMesh_i;
+
+class SMESH_MEDSupport_i:
+ public POA_SALOME_MED::SUPPORT,
+ public PortableServer::RefCountServantBase
+{
+
+protected :
+ SMESH_MEDSupport_i();
+ ~SMESH_MEDSupport_i();
+
+
+public :
+
+ Handle_SMESHDS_SubMesh _subMeshDS;
+ ::SMESH_subMesh_i* _subMesh_i;
+
+ Handle_SMESHDS_Mesh _meshDS;
+ string _name;
+ string _description;
+ bool _isOnAllElements;
+ bool _seqNumber;
+ int _seqLength;
+
+ SALOME_MED::medEntityMesh _entity;
+ SALOME_MED::medGeometryElement * _geometricType;
+ int _numberOfGeometricType;
+
+
+public:
+
+ // Constructors and associated internal methods
+ SMESH_MEDSupport_i(SMESH_subMesh_i* sm,
+ string name,
+ string description,
+ SALOME_MED::medEntityMesh entity);
+ SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s);
+
+ // IDL Methods
+ char * getName() throw (SALOME::SALOME_Exception);
+ char * getDescription() throw (SALOME::SALOME_Exception);
+ SALOME_MED::MESH_ptr getMesh() throw (SALOME::SALOME_Exception);
+ CORBA::Boolean isOnAllElements() throw (SALOME::SALOME_Exception);
+ SALOME_MED::medEntityMesh getEntity() throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfElements(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getNumber(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ Engines::long_array* getNumberIndex()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfGaussPoints(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
+ SALOME_MED::medGeometryElement_array* getTypes()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
+ void createSeq() throw (SALOME::SALOME_Exception);
+
+
+};
+
+#endif /* _MED_MEDSUPPORT_I_HXX_ */
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MEFISTO_2D_i.cxx
+// Created : jeu mai 16 13:26:18 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_MEFISTO_2D_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MEFISTO_2D_i::SMESH_MEFISTO_2D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+{
+ MESSAGE("SMESH_MEFISTO_2D_i::SMESH_MEFISTO_2D_i");
+ _genImpl = genImpl;
+ ::SMESH_MEFISTO_2D* impl
+ = new ::SMESH_MEFISTO_2D(_genImpl->_hypothesisFactory.GetANewId(),
+ studyId,
+ genImpl);
+ SetImpl(impl);
+ _baseImpl = _impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MEFISTO_2D_i::~SMESH_MEFISTO_2D_i()
+{
+ MESSAGE("SMESH_MEFISTO_2D_i::~SMESH_MEFISTO_2D_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_MEFISTO_2D_i::SetImpl(::SMESH_MEFISTO_2D* impl)
+{
+ MESSAGE("SMESH_MEFISTO_2D_i::SetImpl");
+ SMESH_2D_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_MEFISTO_2D_i.hxx
+// Created : jeu mai 16 13:26:22 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_MEFISTO_2D_I_HXX_
+#define _SMESH_MEFISTO_2D_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_2D_Algo_i.hxx"
+
+#include "SMESH_MEFISTO_2D.hxx"
+
+class SMESH_MEFISTO_2D_i:
+ public POA_SMESH::SMESH_MEFISTO_2D,
+ public SMESH_2D_Algo_i
+{
+public:
+ SMESH_MEFISTO_2D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl);
+
+ virtual ~SMESH_MEFISTO_2D_i();
+
+protected:
+ virtual void SetImpl(::SMESH_MEFISTO_2D* impl);
+
+ ::SMESH_MEFISTO_2D* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MaxElementArea_i.cxx
+// Created : sam mai 18 23:14:24 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_MaxElementArea_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ * Constructor:
+ * _name is related to the class name: prefix = SMESH_ ; suffix = _i .
+ */
+//=============================================================================
+
+SMESH_MaxElementArea_i::SMESH_MaxElementArea_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+{
+ MESSAGE("SMESH_MaxElementArea_i::SMESH_MaxElementArea_i");
+ _impl = new ::SMESH_MaxElementArea(genImpl->_hypothesisFactory.GetANewId(),
+ studyId,
+ genImpl);
+ _baseImpl = _impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MaxElementArea_i::~SMESH_MaxElementArea_i()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_MaxElementArea_i::SetMaxElementArea(CORBA::Double area)
+ throw (SALOME::SALOME_Exception)
+{
+ ASSERT(_impl);
+ try
+ {
+ _impl->SetMaxArea(area);
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), \
+ SALOME::BAD_PARAM);
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Double SMESH_MaxElementArea_i::GetMaxElementArea()
+{
+ ASSERT(_impl);
+ return _impl->GetMaxArea();
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_MaxElementArea_i.hxx
+// Created : sam mai 18 23:14:29 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_MAXELEMENTAREA_I_HXX_
+#define _SMESH_MAXELEMENTAREA_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_Hypothesis_i.hxx"
+
+#include "SMESH_MaxElementArea.hxx"
+
+class SMESH_MaxElementArea_i:
+ public POA_SMESH::SMESH_MaxElementArea,
+ public SMESH_Hypothesis_i
+{
+public:
+ SMESH_MaxElementArea_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl);
+ virtual ~SMESH_MaxElementArea_i();
+
+ void SetMaxElementArea(CORBA::Double area)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Double GetMaxElementArea();
+
+protected:
+ ::SMESH_MaxElementArea* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MaxElementVolume_i.cxx
+// Created : sam mai 18 23:14:58 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
--- /dev/null
+//=============================================================================
+// File : SMESH_MaxElementVolume_i.hxx
+// Created : sam mai 18 23:14:53 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
--- /dev/null
+using namespace std;
+// File : SMESH_MeshEditor_i.cxx
+// Created : Wed Jun 19 18:43:26 2002
+// Author : Nicolas REJNERI
+
+// Project : SALOME
+// Module : SMESH
+// Copyright : Open CASCADE 2002
+// $Header$
+
+#include "SMESH_MeshEditor_i.hxx"
+
+#include "SMDS_MeshEdgesIterator.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+#include "SMDS_MeshEdge.hxx"
+#include "SMDS_MeshFace.hxx"
+#include "SMDS_MeshVolume.hxx"
+
+#include "utilities.h"
+
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MeshEditor_i::SMESH_MeshEditor_i(const Handle(SMESHDS_Mesh)& theMesh) {
+ _myMeshDS = theMesh;
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array& IDsOfElements) {
+ for (int i = 0 ; i< IDsOfElements.length(); i++) {
+ CORBA::Long index = IDsOfElements[i];
+ _myMeshDS->RemoveElement(index);
+ MESSAGE ( "Element "<< index << " was removed" )
+ }
+ return true;
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array& IDsOfNodes) {
+
+ // Here we try to collect all 1D, 2D and 3D elements which contain at least one
+ // of <IDsOfNodes> in order to remove such elements.
+ // This seems correct since e.g a triangle without 1 vertex looks nonsense.
+ TColStd_MapOfInteger elemsToRemove;
+
+ for (int i = 0 ; i< IDsOfNodes.length(); i++) {
+
+ CORBA::Long ID = IDsOfNodes[i];
+
+ SMDS_MeshEdgesIterator edgeIt(_myMeshDS);
+ for (; edgeIt.More(); edgeIt.Next()) {
+ Handle(SMDS_MeshEdge) anEdge = Handle(SMDS_MeshEdge)::DownCast(edgeIt.Value());
+ for (Standard_Integer i = 0; i < anEdge->NbNodes(); i++) {
+ if (anEdge->GetConnection(i) == ID) {
+ Standard_Integer elemID = anEdge->GetID();
+ if (!elemsToRemove.Contains(elemID)) elemsToRemove.Add(elemID);
+ }
+ }
+ }
+
+ SMDS_MeshFacesIterator faceIt(_myMeshDS);
+ for (; faceIt.More(); faceIt.Next()) {
+ Handle(SMDS_MeshFace) aFace = Handle(SMDS_MeshFace)::DownCast(faceIt.Value());
+ for (Standard_Integer i = 0; i < aFace->NbNodes(); i++) {
+ if (aFace->GetConnection(i) == ID) {
+ Standard_Integer elemID = aFace->GetID();
+ if (!elemsToRemove.Contains(elemID)) elemsToRemove.Add(elemID);
+ }
+ }
+ }
+
+ SMDS_MeshVolumesIterator volIt(_myMeshDS);
+ for (; volIt.More(); volIt.Next()) {
+ Handle(SMDS_MeshVolume) aVol = Handle(SMDS_MeshVolume)::DownCast(volIt.Value());
+ for (Standard_Integer i = 0; i < aVol->NbNodes(); i++) {
+ if (aVol->GetConnection(i) == ID) {
+ Standard_Integer elemID = aVol->GetID();
+ if (!elemsToRemove.Contains(elemID)) elemsToRemove.Add(elemID);
+ }
+ }
+ }
+ }
+
+ // Now remove them!
+ TColStd_MapIteratorOfMapOfInteger it(elemsToRemove);
+ for (; it.More(); it.Next()) {
+ Standard_Integer elemID = it.Key();
+ _myMeshDS->RemoveElement(elemID);
+ MESSAGE("RemoveNodes(): element removed: " << elemID)
+ }
+
+ // It's nodes' turn to die
+ for (int i = 0 ; i< IDsOfNodes.length(); i++) {
+ CORBA::Long index = IDsOfNodes[i];
+ _myMeshDS->RemoveNode(index);
+ MESSAGE ( "Node "<< index << " was removed" )
+ }
+ return true;
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array& IDsOfNodes) {
+ int NbNodes = IDsOfNodes.length();
+ if ( NbNodes == 2 ) {
+ CORBA::Long index1 = IDsOfNodes[0];
+ CORBA::Long index2 = IDsOfNodes[1];
+ int idTri = _myMeshDS->AddEdge(index1,index2);
+ }
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z) {
+ MESSAGE( " AddNode " << x << " , " << y << " , " << z )
+ int idNode = _myMeshDS->AddNode(x,y,z);
+ MESSAGE( " idNode " << idNode )
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array& IDsOfNodes) {
+ int NbNodes = IDsOfNodes.length();
+ if ( NbNodes == 3 ) {
+ CORBA::Long index1 = IDsOfNodes[0];
+ CORBA::Long index2 = IDsOfNodes[1];
+ CORBA::Long index3 = IDsOfNodes[2];
+ int idTri = _myMeshDS->AddFace(index1,index2,index3);
+ } else if ( NbNodes == 4 ) {
+ CORBA::Long index1 = IDsOfNodes[0];
+ CORBA::Long index2 = IDsOfNodes[1];
+ CORBA::Long index3 = IDsOfNodes[2];
+ CORBA::Long index4 = IDsOfNodes[3];
+ int idTri = _myMeshDS->AddFace(index1,index2,index3,index4);
+ }
+ return true;
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::long_array& IDsOfNodes) {
+ int NbNodes = IDsOfNodes.length();
+ if ( NbNodes == 4 ) {
+ CORBA::Long index1 = IDsOfNodes[0];
+ CORBA::Long index2 = IDsOfNodes[1];
+ CORBA::Long index3 = IDsOfNodes[2];
+ CORBA::Long index4 = IDsOfNodes[3];
+ int idTetra = _myMeshDS->AddVolume(index1,index2,index3,index4);
+ } else if ( NbNodes == 5 ) {
+ CORBA::Long index1 = IDsOfNodes[0];
+ CORBA::Long index2 = IDsOfNodes[1];
+ CORBA::Long index3 = IDsOfNodes[2];
+ CORBA::Long index4 = IDsOfNodes[3];
+ CORBA::Long index5 = IDsOfNodes[4];
+ int idPyramid = _myMeshDS->AddVolume(index1,index2,index3,index4,index5);
+ } else if ( NbNodes == 6 ) {
+ CORBA::Long index1 = IDsOfNodes[0];
+ CORBA::Long index2 = IDsOfNodes[1];
+ CORBA::Long index3 = IDsOfNodes[2];
+ CORBA::Long index4 = IDsOfNodes[3];
+ CORBA::Long index5 = IDsOfNodes[4];
+ CORBA::Long index6 = IDsOfNodes[5];
+ int idPrism = _myMeshDS->AddVolume(index1,index2,index3,index4,index5,index6);
+ } else if ( NbNodes == 8 ) {
+ CORBA::Long index1 = IDsOfNodes[0];
+ CORBA::Long index2 = IDsOfNodes[1];
+ CORBA::Long index3 = IDsOfNodes[2];
+ CORBA::Long index4 = IDsOfNodes[3];
+ CORBA::Long index5 = IDsOfNodes[4];
+ CORBA::Long index6 = IDsOfNodes[5];
+ CORBA::Long index7 = IDsOfNodes[6];
+ CORBA::Long index8 = IDsOfNodes[7];
+ int idHexa = _myMeshDS->AddVolume(index1,index2,index3,index4,index5,index6,index7,index8);
+ }
+ return true;
+};
--- /dev/null
+// File : SMESH_MeshEditor_i.hxx
+// Created : Wed Jun 19 18:43:16 2002
+// Author : Nicolas REJNERI
+
+// Project : SALOME
+// Module : SMESH
+// Copyright : Open CASCADE 2002
+// $Header$
+
+#ifndef _SMESH_MESHEDITOR_I_HXX_
+#define _SMESH_MESHEDIOTR_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+#include "SMESHDS_Mesh.hxx"
+
+
+class SMESH_MeshEditor_i:
+ public POA_SMESH::SMESH_MeshEditor
+{
+public:
+ SMESH_MeshEditor_i(const Handle(SMESHDS_Mesh)& theMesh);
+
+ virtual ~SMESH_MeshEditor_i() {};
+
+ // --- CORBA
+ CORBA::Boolean RemoveElements(const SMESH::long_array& IDsOfElements);
+ CORBA::Boolean RemoveNodes(const SMESH::long_array& IDsOfNodes);
+
+ CORBA::Boolean AddNode(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z);
+ CORBA::Boolean AddEdge(const SMESH::long_array& IDsOfNodes);
+ CORBA::Boolean AddFace(const SMESH::long_array& IDsOfNodes);
+ CORBA::Boolean AddVolume(const SMESH::long_array& IDsOfNodes);
+
+private:
+ SMESH::SMESH_subMesh_var _myMesh;
+ Handle (SMESHDS_Mesh) _myMeshDS;
+};
+
+#endif
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Mesh_i.cxx
+// Created : lun mai 6 13:41:55 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Mesh_i.hxx"
+#include "SMESH_subMesh_i.hxx"
+#include "SMESH_MEDMesh_i.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+#include "SALOME_NamingService.hxx"
+#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
+
+#include "TCollection_AsciiString.hxx"
+// #include "SMESHDS_ListOfAsciiString.hxx"
+// #include "SMESHDS_ListIteratorOfListOfAsciiString.hxx"
+#include "TColStd_ListOfInteger.hxx"
+#include "TColStd_ListOfReal.hxx"
+#include "TColStd_ListIteratorOfListOfInteger.hxx"
+#include "TColStd_ListIteratorOfListOfReal.hxx"
+#include "SMESHDS_Command.hxx"
+#include "SMESHDS_CommandType.hxx"
+#include "SMESHDS_ListOfCommand.hxx"
+#include "SMESHDS_ListIteratorOfListOfCommand.hxx"
+#include "Handle_SMESHDS_Command.hxx"
+
+#include "SMESH_MeshEditor_i.hxx"
+#include <string>
+#include <iostream>
+//#include <sstream>
+
+//**** SMESHDS en champ
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Mesh_i::SMESH_Mesh_i()
+{
+ MESSAGE("SMESH_Mesh_i: default constructor, not for use");
+ ASSERT(0);
+};
+
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+
+SMESH_Mesh_i::SMESH_Mesh_i(SMESH_Gen_i* gen_i,
+ GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ int localId)
+{
+ MESSAGE("SMESH_Mesh_i");
+ _gen_i = gen_i;
+ _id = localId;
+ _geom = GEOM::GEOM_Gen::_narrow(geomEngine);
+ _studyId = studyId;
+}
+
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+
+SMESH_Mesh_i::~SMESH_Mesh_i()
+{
+ MESSAGE("~SMESH_Mesh_i");
+ // ****
+};
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+ SMESH::SMESH_Hypothesis_ptr anHyp)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("AddHypothesis");
+ // **** proposer liste de subShape (selection multiple)
+
+ GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
+ if (CORBA::is_nil(mySubShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", \
+ SALOME::BAD_PARAM);
+
+ SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
+ if (CORBA::is_nil(myHyp))
+ THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference", \
+ SALOME::BAD_PARAM);
+ bool ret = false;
+ try
+ {
+ TopoDS_Shape myLocSubShape=
+ _gen_i->_ShapeReader->GetShape(_geom,mySubShape);
+ int hypId = myHyp->GetId();
+ ret = _impl->AddHypothesis(myLocSubShape, hypId);
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), \
+ SALOME::BAD_PARAM);
+ }
+ return ret;
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Boolean
+SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+ SMESH::SMESH_Hypothesis_ptr anHyp)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("RemoveHypothesis");
+ // **** proposer liste de subShape (selection multiple)
+
+ GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
+ if (CORBA::is_nil(mySubShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", \
+ SALOME::BAD_PARAM);
+
+ SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
+ if (CORBA::is_nil(myHyp))
+ THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference", \
+ SALOME::BAD_PARAM);
+
+ bool ret = false;
+ try
+ {
+ TopoDS_Shape myLocSubShape=
+ _gen_i->_ShapeReader->GetShape(_geom,mySubShape);
+ int hypId = myHyp->GetId();
+ ret = _impl->RemoveHypothesis(myLocSubShape, hypId);
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), \
+ SALOME::BAD_PARAM);
+ }
+ return ret;
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::ListOfHypothesis*
+SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Shape_ptr aSubShape)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("GetHypothesisList");
+ // ****
+};
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetElementsOnShape(GEOM::GEOM_Shape_ptr aSubShape)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh_i::GetElementsOnShape");
+ GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
+ if (CORBA::is_nil(mySubShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", \
+ SALOME::BAD_PARAM);
+
+ int subMeshId = 0;
+ try
+ {
+ SMESH_subMesh_i* subMeshServant;
+ TopoDS_Shape myLocSubShape
+ = _gen_i->_ShapeReader->GetShape(_geom,mySubShape);
+
+ //Get or Create the SMESH_subMesh object implementation
+
+ ::SMESH_subMesh * mySubMesh
+ = _impl->GetSubMesh(myLocSubShape);
+ subMeshId = mySubMesh->GetId();
+
+ // create a new subMesh object servant if there is none for the shape
+
+ if (_mapSubMesh.find(subMeshId) != _mapSubMesh.end())
+ {
+ ASSERT(_mapSubMesh_i.find(subMeshId) != _mapSubMesh_i.end());
+ subMeshServant = _mapSubMesh_i[subMeshId];
+ }
+ else
+ {
+ // create and activate the CORBA servant of Mesh
+ subMeshServant = new SMESH_subMesh_i(_gen_i, this, subMeshId);
+ SMESH::SMESH_subMesh_var subMesh
+ = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this());
+ _mapSubMesh[subMeshId] = mySubMesh;
+ _mapSubMesh_i[subMeshId] = subMeshServant;
+ _mapSubMeshIor[subMeshId]
+ = SMESH::SMESH_subMesh::_duplicate(subMesh);
+ }
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+
+ ASSERT(_mapSubMeshIor.find(subMeshId) != _mapSubMeshIor.end());
+ return SMESH::SMESH_subMesh::_duplicate(_mapSubMeshIor[subMeshId]);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::log_array* SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh_i::GetLog");
+
+ SMESH::log_array_var aLog;
+ try
+ {
+ const SMESHDS_ListOfCommand& logDS =_impl->GetLog();
+ aLog = new SMESH::log_array;
+ int indexLog = 0;
+ int lg = logDS.Extent();
+ SCRUTE(lg);
+ aLog->length(lg);
+ SMESHDS_ListIteratorOfListOfCommand its(logDS);
+ while(its.More())
+ {
+ Handle(SMESHDS_Command) com = its.Value();
+ int comType = com->GetType();
+ //SCRUTE(comType);
+ int lgcom = com->GetNumber();
+ //SCRUTE(lgcom);
+ const TColStd_ListOfInteger& intList = com->GetIndexes();
+ int inum = intList.Extent();
+ //SCRUTE(inum);
+ TColStd_ListIteratorOfListOfInteger ii(intList);
+ const TColStd_ListOfReal& coordList = com->GetCoords();
+ int rnum = coordList.Extent();
+ //SCRUTE(rnum);
+ TColStd_ListIteratorOfListOfReal ir(coordList);
+ aLog[indexLog].commandType = comType;
+ aLog[indexLog].number = lgcom;
+ aLog[indexLog].coords.length(rnum);
+ aLog[indexLog].indexes.length(inum);
+ for (int i=0; i<rnum; i++)
+ {
+ aLog[indexLog].coords[i] = ir.Value();
+ //MESSAGE(" "<<i<<" "<<ir.Value());
+ ir.Next();
+ }
+ for (int i=0; i<inum; i++)
+ {
+ aLog[indexLog].indexes[i] = ii.Value();
+ //MESSAGE(" "<<i<<" "<<ii.Value());
+ ii.Next();
+ }
+ indexLog++;
+ its.Next();
+ }
+ if (clearAfterGet) _impl->ClearLog();
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+ return aLog._retn();
+}
+
+// SMESH::string_array* SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
+// throw (SALOME::SALOME_Exception)
+// {
+// MESSAGE("SMESH_Mesh_i::GetLog");
+
+// SMESH::string_array_var aLog;
+// try
+// {
+// const SMESHDS_ListOfCommand& logDS =_impl->GetLog();
+// aLog = new SMESH::string_array;
+// int logSize = 0;
+// int indexLog = 0;
+// int lg = logDS.Extent();
+// SCRUTE(lg);
+// SMESHDS_ListIteratorOfListOfCommand its(logDS);
+// while(its.More())
+// {
+// Handle(SMESHDS_Command) com = its.Value();
+// int comType = com->GetType();
+// SCRUTE(comType);
+// int lgcom = com->GetNumber();
+// SCRUTE(lgcom);
+// logSize += lgcom;
+// aLog->length(logSize);
+// SCRUTE(logSize);
+// const TColStd_ListOfInteger& intList = com->GetIndexes();
+// TColStd_ListIteratorOfListOfInteger ii(intList);
+// const TColStd_ListOfReal& coordList = com->GetCoords();
+// TColStd_ListIteratorOfListOfReal ir(coordList);
+// for (int icom = 1; icom <= lgcom; icom++)
+// {
+// ostringstream S;
+// switch (comType)
+// {
+// case SMESHDS_AddNode:
+// S << "AddNode " << ii.Value(); ii.Next();
+// S << " " << ir.Value(); ir.Next();
+// S << " " << ir.Value(); ir.Next();
+// S << " " << ir.Value(); ir.Next();
+// break;
+// case SMESHDS_AddEdge:
+// S << "AddEdge " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_AddTriangle:
+// S << "AddFace " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_AddQuadrangle:
+// S << "AddFace " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_AddTetrahedron:
+// S << "AddVolume " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_AddPyramid:
+// S << "AddVolume " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_AddPrism:
+// S << "AddVolume " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_AddHexahedron:
+// S << "AddVolume " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// S << " " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_RemoveNode:
+// S << "RemoveNode " << ii.Value(); ii.Next();
+// break;
+// case SMESHDS_RemoveElement:
+// S << "RemoveElement " << ii.Value(); ii.Next();
+// break;
+// default:
+// ASSERT(0);
+// break;
+// }
+// string ch = S.str();
+// SCRUTE(ch);
+// aLog[indexLog++] = CORBA::string_dup(ch.c_str());
+// }
+// its.Next();
+// }
+// if (clearAfterGet) _impl->ClearLog();
+// }
+// catch (SALOME_Exception& S_ex)
+// {
+// THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+// }
+// return aLog._retn();
+// }
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::ClearLog()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh_i::ClearLog");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long SMESH_Mesh_i::GetId()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh_i::GetId");
+ return _id;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long SMESH_Mesh_i::GetStudyId()
+ throw (SALOME::SALOME_Exception)
+{
+ return _studyId;
+}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::SetImpl(::SMESH_Mesh* impl)
+{
+ MESSAGE("SMESH_Mesh_i::SetImpl");
+ _impl = impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+::SMESH_Mesh& SMESH_Mesh_i::GetImpl()
+{
+ MESSAGE("SMESH_Mesh_i::GetImpl()");
+ return *_impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+GEOM::GEOM_Gen_ptr SMESH_Mesh_i::GetGeomEngine()
+{
+ MESSAGE("SMESH_Mesh_i::GetGeomEngine");
+ return GEOM::GEOM_Gen::_duplicate(_geom);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::SetIor(SMESH::SMESH_Mesh_ptr myIor)
+{
+ MESSAGE("SMESH_Mesh_i::SetIor");
+ _myIor = SMESH::SMESH_Mesh::_duplicate(myIor);
+ ASSERT(! CORBA::is_nil(_myIor));
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::SMESH_Mesh_ptr SMESH_Mesh_i::GetIor()
+{
+ MESSAGE("SMESH_Mesh_i::GetIor");
+ ASSERT(! CORBA::is_nil(_myIor));
+ return SMESH::SMESH_Mesh::_duplicate(_myIor);
+}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
+{
+ SMESH_MeshEditor_i* aMeshEditor = new SMESH_MeshEditor_i(_impl->GetMeshDS());
+ SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
+ return aMesh._retn();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::ExportMED( const char* file )
+ throw (SALOME::SALOME_Exception)
+{
+ _impl->ExportMED( file );
+}
+void SMESH_Mesh_i::ExportDAT( const char* file )
+ throw (SALOME::SALOME_Exception)
+{
+ _impl->ExportDAT( file );
+}
+void SMESH_Mesh_i::ExportUNV( const char* file )
+ throw (SALOME::SALOME_Exception)
+{
+ _impl->ExportUNV( file );
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_MEDMesh_i* aMedMesh = new SMESH_MEDMesh_i( this );
+ SALOME_MED::MESH_var aMesh = aMedMesh->_this();
+ return aMesh._retn();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::NbNodes()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbNodes();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::NbEdges()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbEdges();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::NbFaces()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbFaces();
+}
+CORBA::Long SMESH_Mesh_i::NbTriangles()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbTriangles();
+}
+CORBA::Long SMESH_Mesh_i::NbQuadrangles()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbQuadrangles();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::NbVolumes()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbVolumes();
+}
+CORBA::Long SMESH_Mesh_i::NbTetras()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbTetras();
+}
+CORBA::Long SMESH_Mesh_i::NbHexas()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbHexas();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::NbSubMesh()
+ throw (SALOME::SALOME_Exception)
+{
+ return _impl->NbSubMesh();
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Mesh_i.hxx
+// Created : lun mai 6 13:41:50 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_MESH_I_HXX_
+#define _SMESH_MESH_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+#include CORBA_CLIENT_HEADER(GEOM_Gen)
+#include CORBA_CLIENT_HEADER(GEOM_Shape)
+#include CORBA_CLIENT_HEADER(MED)
+
+class SMESH_Gen_i;
+
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_subMesh_i.hxx"
+#include "SMESH_subMesh.hxx"
+#include "SMESH_topo.hxx"
+
+#include <map>
+
+class SMESH_Mesh_i:
+ public POA_SMESH::SMESH_Mesh
+{
+public:
+ SMESH_Mesh_i();
+ SMESH_Mesh_i(SMESH_Gen_i* myGen_i,
+ GEOM::GEOM_Gen_ptr geomEngine,
+ CORBA::Long studyId,
+ int localId);
+
+ virtual ~SMESH_Mesh_i();
+
+ // --- CORBA
+
+ CORBA::Boolean AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+ SMESH::SMESH_Hypothesis_ptr anHyp)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Boolean RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+ SMESH::SMESH_Hypothesis_ptr anHyp)
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Shape_ptr aSubShape)
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::SMESH_subMesh_ptr GetElementsOnShape(GEOM::GEOM_Shape_ptr aSubShape)
+ throw (SALOME::SALOME_Exception);
+
+// SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
+// throw (SALOME::SALOME_Exception);
+
+ SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
+
+ void ClearLog()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long GetId()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long GetStudyId()
+ throw (SALOME::SALOME_Exception);
+
+ // --- C++ interface
+
+ void SetImpl(::SMESH_Mesh* impl);
+
+ ::SMESH_Mesh& GetImpl(); // :: force no namespace here
+ GEOM::GEOM_Gen_ptr GetGeomEngine();
+ void SetIor(SMESH::SMESH_Mesh_ptr myIor);
+ SMESH::SMESH_Mesh_ptr GetIor();
+
+ void ExportMED( const char* file )
+ throw (SALOME::SALOME_Exception);
+ void ExportDAT( const char* file )
+ throw (SALOME::SALOME_Exception);
+ void ExportUNV( const char* file )
+ throw (SALOME::SALOME_Exception);
+
+ SALOME_MED::MESH_ptr GetMEDMesh()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbNodes()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbEdges()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbFaces()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbTriangles()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbQuadrangles()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbVolumes()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbTetras()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbHexas()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long NbSubMesh()
+ throw (SALOME::SALOME_Exception);
+
+
+ map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
+ map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
+
+private:
+
+ ::SMESH_Mesh* _impl; // :: force no namespace here
+ SMESH_Gen_i* _gen_i;
+ // CORBA::ORB_ptr _orb;
+// SMESH_topo* _topo; // all local TopoDS_Shape of subShapes
+ int _id; // id given by creator (unique within the creator instance)
+ GEOM::GEOM_Gen_var _geom;
+ int _studyId;
+ // int _localId; // id attributed to all objects created by Mesh_i
+ map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
+ SMESH::SMESH_Mesh_var _myIor;
+};
+
+#endif
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_NumberOfSegments_i.cxx
+// Created : jeu mai 16 13:09:33 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_NumberOfSegments_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ * Constructor:
+ * _name is related to the class name: prefix = SMESH_ ; suffix = _i .
+ */
+//=============================================================================
+
+SMESH_NumberOfSegments_i::SMESH_NumberOfSegments_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+{
+ MESSAGE("SMESH_NumberOfSegments_i::SMESH_NumberOfSegments_i");
+ _impl= new ::SMESH_NumberOfSegments(genImpl->_hypothesisFactory.GetANewId(),
+ studyId,
+ genImpl);
+ _baseImpl = _impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_NumberOfSegments_i::~SMESH_NumberOfSegments_i()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void
+SMESH_NumberOfSegments_i::SetNumberOfSegments(CORBA::Long segmentsNumber)
+ throw (SALOME::SALOME_Exception)
+{
+ ASSERT(_impl);
+ try
+ {
+ _impl->SetNumberOfSegments(segmentsNumber);
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), \
+ SALOME::BAD_PARAM);
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long SMESH_NumberOfSegments_i::GetNumberOfSegments()
+{
+ ASSERT(_impl);
+ return _impl->GetNumberOfSegments();
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_NumberOfSegments_i.hxx
+// Created : jeu mai 16 13:09:38 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_NUMBEROFSEGMENTS_I_HXX_
+#define _SMESH_NUMBEROFSEGMENTS_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_Hypothesis_i.hxx"
+
+#include "SMESH_NumberOfSegments.hxx"
+
+class SMESH_NumberOfSegments_i:
+ public POA_SMESH::SMESH_NumberOfSegments,
+ public SMESH_Hypothesis_i
+{
+public:
+ SMESH_NumberOfSegments_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl);
+ virtual ~SMESH_NumberOfSegments_i();
+
+ void SetNumberOfSegments(CORBA::Long segmentsNumber)
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long GetNumberOfSegments();
+
+protected:
+ ::SMESH_NumberOfSegments* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Quadrangle_2D_i.cxx
+// Created : jeu mai 16 13:27:25 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Quadrangle_2D_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Quadrangle_2D_i::SMESH_Quadrangle_2D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+{
+ MESSAGE("SMESH_Quadrangle_2D_i::SMESH_Quadrangle_2D_i");
+ _genImpl = genImpl;
+ ::SMESH_Quadrangle_2D* impl
+ = new ::SMESH_Quadrangle_2D(_genImpl->_hypothesisFactory.GetANewId(),
+ studyId,
+ genImpl);
+ SetImpl(impl);
+ _baseImpl = _impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Quadrangle_2D_i::~SMESH_Quadrangle_2D_i()
+{
+ MESSAGE("SMESH_Quadrangle_2D_i::~SMESH_Quadrangle_2D_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Quadrangle_2D_i::SetImpl(::SMESH_Quadrangle_2D* impl)
+{
+ MESSAGE("SMESH_Quadrangle_2D_i::SetImpl");
+ SMESH_2D_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Quadrangle_2D_i.hxx
+// Created : jeu mai 16 13:27:29 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_QUADRANGLE_2D_I_HXX_
+#define _SMESH_QUADRANGLE_2D_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_2D_Algo_i.hxx"
+
+#include "SMESH_Quadrangle_2D.hxx"
+
+class SMESH_Quadrangle_2D_i:
+ public POA_SMESH::SMESH_Quadrangle_2D,
+ public SMESH_2D_Algo_i
+{
+public:
+ SMESH_Quadrangle_2D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl);
+
+ virtual ~SMESH_Quadrangle_2D_i();
+
+protected:
+ virtual void SetImpl(::SMESH_Quadrangle_2D* impl);
+
+ ::SMESH_Quadrangle_2D* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Regular_1D_i.cxx
+// Created : jeu mai 16 13:25:47 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Regular_1D_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_HypothesisFactory.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Regular_1D_i::SMESH_Regular_1D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl)
+{
+ MESSAGE("SMESH_Regular_1D_i::SMESH_Regular_1D_i");
+ _genImpl = genImpl;
+ ::SMESH_Regular_1D* impl
+ = new ::SMESH_Regular_1D(_genImpl->_hypothesisFactory.GetANewId(),
+ studyId,
+ genImpl);
+ SetImpl(impl);
+ _baseImpl = _impl;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Regular_1D_i::~SMESH_Regular_1D_i()
+{
+ MESSAGE("SMESH_Regular_1D_i::~SMESH_Regular_1D_i");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Regular_1D_i::SetImpl(::SMESH_Regular_1D* impl)
+{
+ MESSAGE("SMESH_Regular_1D_i::SetImpl");
+ SMESH_1D_Algo_i::SetImpl(impl);
+ _impl = impl;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Regular_1D_i.hxx
+// Created : jeu mai 16 13:25:50 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_REGULAR_1D_I_HXX_
+#define _SMESH_REGULAR_1D_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_1D_Algo_i.hxx"
+
+#include "SMESH_Regular_1D.hxx"
+
+class SMESH_Regular_1D_i:
+ public POA_SMESH::SMESH_Regular_1D,
+ public SMESH_1D_Algo_i
+{
+public:
+ SMESH_Regular_1D_i(const char* anHyp,
+ int studyId,
+ ::SMESH_Gen* genImpl);
+
+ virtual ~SMESH_Regular_1D_i();
+
+protected:
+ virtual void SetImpl(::SMESH_Regular_1D* impl);
+
+ ::SMESH_Regular_1D* _impl;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_subMesh_i.cxx
+// Created : jeu mai 30 10:01:12 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_subMesh_i.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_Mesh_i.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+#include "OpUtil.hxx"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_subMesh_i::SMESH_subMesh_i()
+{
+ MESSAGE("SMESH_subMesh_i::SMESH_subMesh_i default, not for use");
+ ASSERT(0);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_subMesh_i::SMESH_subMesh_i(SMESH_Gen_i* gen_i,
+ SMESH_Mesh_i* mesh_i,
+ int localId)
+{
+ MESSAGE("SMESH_subMesh_i::SMESH_subMesh_i");
+ _gen_i = gen_i;
+ _mesh_i = mesh_i;
+ _localId = localId;
+ // ****
+}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_subMesh_i::~SMESH_subMesh_i()
+{
+ MESSAGE("SMESH_subMesh_i::~SMESH_subMesh_i");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long SMESH_subMesh_i::GetNumberOfElements()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_subMesh_i::GetNumberOfElements");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long SMESH_subMesh_i::GetNumberOfNodes()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_subMesh_i::GetNumberOfNodes");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_subMesh_i::GetElementsId()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_subMesh_i::GetElementsId");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_subMesh_i::GetNodesId()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_subMesh_i::GetNodesId");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::SMESH_Mesh_ptr SMESH_subMesh_i::GetFather()
+ throw (SALOME::SALOME_Exception)
+{
+ MESSAGE("SMESH_subMesh_i::GetFather");
+ SMESH::SMESH_Mesh_var meshIor = _mesh_i->GetIor();
+ return SMESH::SMESH_Mesh::_duplicate(meshIor);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long SMESH_subMesh_i::GetId()
+{
+ MESSAGE("SMESH_subMesh_i::GetId");
+ return _localId;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+SALOME_MED::FAMILY_ptr SMESH_subMesh_i::GetFamily()
+ throw (SALOME::SALOME_Exception)
+{
+ SALOME_MED::MESH_var MEDMesh = GetFather()->GetMEDMesh();
+
+ SALOME_MED::Family_array_var families =
+ MEDMesh->getFamilies(SALOME_MED::MED_NODE);
+
+ for ( int i = 0; i < families->length(); i++ ) {
+ if ( families[i]->getIdentifier() == ( _localId ) )
+ return families[i];
+ }
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_subMesh_i.hxx
+// Created : jeu mai 30 10:01:17 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_SUBMESH_I_HXX_
+#define _SMESH_SUBMESH_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
+#include CORBA_CLIENT_HEADER(GEOM_Gen)
+#include CORBA_CLIENT_HEADER(GEOM_Shape)
+#include CORBA_CLIENT_HEADER(MED)
+
+class SMESH_Gen_i;
+class SMESH_Mesh_i;
+
+class SMESH_subMesh_i:
+ public POA_SMESH::SMESH_subMesh
+{
+public:
+ SMESH_subMesh_i();
+ SMESH_subMesh_i(SMESH_Gen_i* gen_i,
+ SMESH_Mesh_i* mesh_i,
+ int localId);
+ ~SMESH_subMesh_i();
+
+ CORBA::Long GetNumberOfElements()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long GetNumberOfNodes()
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::long_array* GetElementsId()
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::long_array* GetNodesId()
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::SMESH_Mesh_ptr GetFather()
+ throw (SALOME::SALOME_Exception);
+
+ CORBA::Long GetId();
+
+ SALOME_MED::FAMILY_ptr GetFamily()
+ throw (SALOME::SALOME_Exception);
+
+ SMESH_Mesh_i* _mesh_i; //NRI
+
+protected:
+ SMESH_Gen_i* _gen_i;
+ int _localId;
+};
+
+#endif
--- /dev/null
+# creer des geometries, en selectionner une
+
+import SMESH
+import smeshpy
+import salome
+from salome import sg
+import math
+#import SMESH_BasicHypothesis_idl
+
+import geompy
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+myBuilder = salome.myStudy.NewBuilder()
+from geompy import gg
+
+ShapeTypeCompSolid = 1
+ShapeTypeSolid = 2
+ShapeTypeShell = 3
+ShapeTypeFace = 4
+ShapeTypeWire = 5
+ShapeTypeEdge = 6
+ShapeTypeVertex = 7
+
+# ---- define a box
+
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idb = geompy.addToStudy(box,"box")
+
+# ---- add first face of box in study
+
+subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
+face=subShapeList[0]
+name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
+print name
+idf=geompy.addToStudyInFather(box,face,name)
+
+# ---- add shell from box in study
+
+subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
+shell = subShellList[0]
+name = geompy.SubShapeName( shell._get_Name(), box._get_Name() )
+print name
+ids=geompy.addToStudyInFather(box,shell,name)
+
+# ---- add first edge of face in study
+
+edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
+edge=edgeList[0];
+name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
+print name
+ide=geompy.addToStudyInFather(face,edge,name)
+
+# ---- launch SMESH, init a Mesh with the box
+gen=smeshpy.smeshpy()
+mesh=gen.Init(idb)
+
+# ---- create Hypothesis
+
+print "-------------------------- create Hypothesis"
+print "-------------------------- LocalLength"
+hyp1=gen.CreateHypothesis("LocalLength")
+print hyp1.GetName()
+print hyp1.GetId()
+hypo1 = hyp1._narrow(SMESH.SMESH_LocalLength)
+print hypo1.GetLength()
+hypo1.SetLength(100)
+print hypo1.GetLength()
+
+print "-------------------------- bidon"
+hyp3=gen.CreateHypothesis("bidon")
+
+print "-------------------------- NumberOfSegments"
+hyp3=gen.CreateHypothesis("NumberOfSegments")
+hypo3=hyp3._narrow(SMESH.SMESH_NumberOfSegments)
+hypo3.SetNumberOfSegments(7)
+print hypo3.GetName()
+print hypo3.GetNumberOfSegments()
+print hypo3.GetId()
+
+print "-------------------------- MaxElementArea"
+hyp4=gen.CreateHypothesis("MaxElementArea")
+hypo4=hyp4._narrow(SMESH.SMESH_MaxElementArea)
+hypo4.SetMaxElementArea(5000)
+print hypo4.GetName()
+print hypo4.GetMaxElementArea()
+print hypo4.GetId()
+
+print "-------------------------- Regular_1D"
+alg1=gen.CreateHypothesis("Regular_1D")
+print alg1.GetName()
+print alg1.GetId()
+algo1=alg1._narrow(SMESH.SMESH_Algo)
+listHyp=algo1.GetCompatibleHypothesis()
+for hyp in listHyp:
+ print hyp
+
+algo_1=alg1._narrow(SMESH.SMESH_Regular_1D)
+print algo_1.GetId()
+
+print "-------------------------- MEFISTO_2D"
+alg2=gen.CreateHypothesis("MEFISTO_2D")
+print alg2.GetName()
+print alg2.GetId()
+algo2=alg2._narrow(SMESH.SMESH_Algo)
+listHyp=algo2.GetCompatibleHypothesis()
+for hyp in listHyp:
+ print hyp
+algo_2=alg2._narrow(SMESH.SMESH_MEFISTO_2D)
+print algo_2.GetId()
+
+# ---- add hypothesis to edge
+
+print "-------------------------- add hypothesis to edge"
+edge=salome.IDToObject(ide)
+submesh=mesh.GetElementsOnShape(edge)
+ret=mesh.AddHypothesis(edge,algo_1)
+print ret
+ret=mesh.AddHypothesis(edge,hypo1)
+print ret
+
+# ---- compute edge
+
+##print "-------------------------- compute edge"
+##ret=gen.Compute(mesh,ide)
+##print ret
+##log=mesh.GetLog(1);
+##for a in log:
+## print a
+
+# ---- add hypothesis to box
+
+print "-------------------------- add hypothesis to box"
+box=salome.IDToObject(idb)
+submesh=mesh.GetElementsOnShape(box)
+ret=mesh.AddHypothesis(box,algo_1)
+print ret
+ret=mesh.AddHypothesis(box,hypo1)
+print ret
+ret=mesh.AddHypothesis(box,algo_2)
+print ret
+ret=mesh.AddHypothesis(box,hypo4)
+print ret
+
+# ---- compute face
+
+print "-------------------------- compute face"
+ret=gen.Compute(mesh,idf)
+print ret
+log=mesh.GetLog(1);
+for a in log:
+ print "-------"
+ ii = 0
+ ir = 0
+ comType = a.commandType
+ if comType == 0:
+ for i in range(a.number):
+ ind = a.indexes[ii]
+ ii = ii+1
+ r1 = a.coords[ir]
+ ir = ir+1
+ r2 = a.coords[ir]
+ ir = ir+1
+ r3 = a.coords[ir]
+ ir = ir+1
+ print "AddNode %i - %g %g %g" % (ind, r1, r2, r3)
+ elif comType == 1:
+ for i in range(a.number):
+ ind = a.indexes[ii]
+ ii = ii+1
+ i1 = a.indexes[ii]
+ ii = ii+1
+ i2 = a.indexes[ii]
+ ii = ii+1
+ print "AddEdge %i - %i %i" % (ind, i1, i2)
+ elif comType == 2:
+ for i in range(a.number):
+ ind = a.indexes[ii]
+ ii = ii+1
+ i1 = a.indexes[ii]
+ ii = ii+1
+ i2 = a.indexes[ii]
+ ii = ii+1
+ i3 = a.indexes[ii]
+ ii = ii+1
+ print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
+
+# ---- compute box
+
+##print "-------------------------- compute box"
+##ret=gen.Compute(mesh,idb)
+##print ret
+##log=mesh.GetLog(1);
+##print log
+
+##shell=salome.IDToObject(ids)
+##submesh=mesh.GetElementsOnShape(shell)
+##ret=mesh.AddHypothesis(shell,algo_1)
+##print ret
+##ret=mesh.AddHypothesis(shell,hypo1)
+##print ret
+##ret=gen.Compute(mesh,ids)
+##print ret
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_topo.cxx
+// Created : lun mai 13 15:17:25 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_topo.hxx"
+#include "utilities.h"
+
+SMESH_topo::SMESH_topo()
+{
+ MESSAGE("SMESH_topo()");
+}
+
+SMESH_topo::~SMESH_topo()
+{
+ MESSAGE("~SMESH_topo()");
+}
+
+//=============================================================================
+/*!
+ * Static method, gives a unique local id for a given CORBA reference of
+ * a shape, within the SALOME session (multi studies).
+ * Internal geom id or stringified CORBA reference could be used here.
+ * GEOM Id is more efficient (shorter string).
+ */
+//=============================================================================
+
+string SMESH_topo::GetShapeLocalId(GEOM::GEOM_Shape_ptr aShape)
+{
+ string str = aShape->ShapeId(); //geomId
+ MESSAGE(str);
+ return str;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_topo.hxx
+// Created : lun mai 13 15:17:20 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_TOPO_HXX_
+#define _SMESH_TOPO_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(GEOM_Shape)
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_CompSolid.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <string>
+#include <map>
+
+static const char* const SMESH_shapeTypeNames[9] = { "0=TopAbs_COMPOUND",
+ "1=TopAbs_COMPSOLID",
+ "2=TopAbs_SOLID",
+ "3=TopAbs_SHELL",
+ "4=TopAbs_FACE",
+ "5=TopAbs_WIRE",
+ "6=TopAbs_EDGE",
+ "7=TopAbs_VERTEX",
+ "8=TopAbs_SHAPE" };
+
+class SMESH_topo
+{
+public:
+
+ static string GetShapeLocalId(GEOM::GEOM_Shape_ptr aShape);
+
+ SMESH_topo();
+ virtual ~SMESH_topo();
+
+ map <string, int> _mapIndShapes[9];
+ TopTools_IndexedMapOfShape _myShapes[9];
+
+protected:
+
+
+};
+
+#endif
--- /dev/null
+
+import salome
+import SMESH
+
+from SALOME_utilities import *
+
+#=============================================================================
+
+class smeshpy:
+ _geom = None
+ _smesh = None
+ _studyId = None
+
+ #--------------------------------------------------------------------------
+
+ def __init__(self):
+ try:
+ self._geom = salome.lcc.FindOrLoadComponent("FactoryServer","Geometry")
+ self._smesh = salome.lcc.FindOrLoadComponent("FactoryServer","SMESH")
+ except:
+ MESSAGE( "exception in smeshpy:__init__" )
+ self._studyId = salome.myStudyId
+
+ #--------------------------------------------------------------------------
+
+ def Init(self, shapeId):
+ try:
+ shape = salome.IDToObject(shapeId)
+ aMesh = self._smesh.Init(self._geom, self._studyId, shape)
+ return aMesh
+ except:
+ MESSAGE( "exception in smeshpy:Init" )
+ return None
+
+ #--------------------------------------------------------------------------
+
+ def CreateHypothesis(self, name):
+ try:
+ hyp = self._smesh.CreateHypothesis(name,self._studyId)
+ return hyp
+ except:
+ MESSAGE( "exception in smeshpy:CreateHypothesis" )
+ return None
+
+ #--------------------------------------------------------------------------
+
+ def Compute(self, mesh, shapeId):
+ try:
+ shape = salome.IDToObject(shapeId)
+ ret=self._smesh.Compute(mesh, shape)
+ return ret
+ except:
+ MESSAGE( "exception in smeshpy:Compute" )
+ return 0
+
+#=============================================================================
+## #--------------------------------------------------------------------------
+
+##def SmeshInit(shapeId):
+## import salome
+## import SMESH
+## geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+## smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+## shape = salome.IDToObject(shapeId)
+## studyId = salome.myStudyId
+## MESSAGE( str(studyId) )
+## aMesh = smesh.Init(geom, studyId, shape)
+## return aMesh
+
+## #--------------------------------------------------------------------------
--- /dev/null
+/* This is part of libio/iostream, providing -*- C++ -*- input/output.
+Copyright (C) 2000 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+/* Written by Magnus Fromreide (magfr@lysator.liu.se). */
+
+#ifndef __SSTREAM__
+#define __SSTREAM__
+
+#include <string>
+#include <iostream.h>
+#include <streambuf.h>
+
+namespace std
+{
+ class stringbuf : public streambuf
+ {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit stringbuf(int which=ios::in|ios::out) :
+ streambuf(which), buf(), mode(static_cast<ios::open_mode>(which)),
+ rpos(0), bufsize(1)
+ { }
+
+ explicit stringbuf(const std::string &s, int which=ios::in|ios::out) :
+ streambuf(which), buf(s), mode(static_cast<ios::open_mode>(which)),
+ bufsize(1)
+ {
+ if(mode & ios::in)
+ {
+ setg(&defbuf, &defbuf + bufsize, &defbuf + bufsize);
+ }
+ if(mode & ios::out)
+ {
+ setp(&defbuf, &defbuf + bufsize);
+ }
+ rpos = (mode & ios::ate ? s.size() : 0);
+ }
+
+ std::string str() const
+ {
+ const_cast<stringbuf*>(this)->sync(); // Sigh, really ugly hack
+ return buf;
+ };
+
+ void str(const std::string& s)
+ {
+ buf = s;
+ if(mode & ios::in)
+ {
+ gbump(egptr() - gptr());
+ }
+ if(mode & ios::out)
+ {
+ pbump(pbase() - pptr());
+ }
+ rpos = (mode & ios::ate ? s.size() : 0);
+ }
+
+ protected:
+ inline virtual int sync();
+ inline virtual int overflow(int = EOF);
+ inline virtual int underflow();
+ private:
+ std::string buf;
+ ios::open_mode mode;
+ std::string::size_type rpos;
+ streamsize bufsize;
+ char defbuf;
+ };
+
+ class stringstreambase : virtual public ios {
+ protected:
+ stringbuf __my_sb;
+ public:
+ std::string str() const
+ {
+ return dynamic_cast<stringbuf*>(_strbuf)->str();
+ }
+ void str(const std::string& s)
+ {
+ clear();
+ dynamic_cast<stringbuf*>(_strbuf)->str(s);
+ }
+
+ stringbuf* rdbuf()
+ {
+ return &__my_sb;
+ }
+ protected:
+ stringstreambase(int which) :
+ __my_sb(which)
+ {
+ init (&__my_sb);
+ }
+
+ stringstreambase(const std::string& s, int which) :
+ __my_sb(s, which)
+ {
+ init (&__my_sb);
+ }
+ };
+
+ class istringstream : public stringstreambase, public istream {
+ public:
+ istringstream(int which=ios::in) :
+ stringstreambase(which)
+ { }
+
+ istringstream(const std::string& s, int which=ios::in) :
+ stringstreambase(s, which)
+ { }
+ };
+
+ class ostringstream : public stringstreambase, public ostream {
+ public:
+ ostringstream(int which=ios::out) :
+ stringstreambase(which)
+ { }
+
+ ostringstream(const std::string& s, int which=ios::out) :
+ stringstreambase(s, which)
+ { }
+ };
+
+ class stringstream : public stringstreambase, public iostream {
+ public:
+ stringstream(int which=ios::in|ios::out) :
+ stringstreambase(which)
+ { }
+
+ stringstream(const std::string &s, int which=ios::in|ios::out) :
+ stringstreambase(s, which)
+ { }
+ };
+}
+
+inline int std::stringbuf::sync()
+{
+ if((mode & ios::out) == 0)
+ return EOF;
+
+ streamsize n = pptr() - pbase();
+ if(n)
+ {
+ buf.replace(rpos, std::string::npos, pbase(), n);
+ if(buf.size() - rpos != n)
+ return EOF;
+ rpos += n;
+ pbump(-n);
+ gbump(egptr() - gptr());
+ }
+ return 0;
+}
+
+inline int std::stringbuf::overflow(int ch)
+{
+ if((mode & ios::out) == 0)
+ return EOF;
+
+ streamsize n = pptr() - pbase();
+
+ if(n && sync())
+ return EOF;
+
+ if(ch != EOF)
+ {
+ std::string::size_type oldSize = buf.size();
+
+ buf.replace(rpos, std::string::npos, ch);
+ if(buf.size() - oldSize != 1)
+ return EOF;
+ ++rpos;
+ }
+ return 0;
+}
+
+inline int std::stringbuf::underflow()
+{
+ sync();
+ if((mode & ios::in) == 0)
+ {
+ return EOF;
+ }
+ if(rpos >= buf.size())
+ {
+ return EOF;
+ }
+
+ std::string::size_type n = egptr() - eback();
+ std::string::size_type s;
+
+ s = buf.copy(eback(), n, rpos);
+ pbump(pbase() - pptr());
+ gbump(eback() - gptr());
+ int res = (0377 & buf[rpos]);
+ rpos += s;
+ return res;
+}
+
+#endif /* not __STRSTREAM__ */