X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Gen_i.cxx;h=81dcf5a3754c1bd1a6b2b93cde24c5316bee3d4f;hb=aa034dad38ed214bf71255119d299ec6826588f8;hp=32265c51435a7f721af90321bdb6021d7707d6a3;hpb=2653bcf37414d5a96c98ced7bb14b9b792422ca5;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 32265c514..81dcf5a37 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -101,12 +101,17 @@ #include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis_i.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_ParallelMesh.hxx" #include "SMESH_MeshEditor.hxx" #include "SMESH_Mesh_i.hxx" +#include +#include "SMESH_ParallelMesh_i.hxx" #include "SMESH_PreMeshInfo.hxx" #include "SMESH_PythonDump.hxx" #include "SMESH_ControlsDef.hxx" #include +#include +#include // to pass CORBA exception through SMESH_TRY #define SMY_OWN_CATCH catch( SALOME::SALOME_Exception& se ) { throw se; } @@ -571,7 +576,10 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh() SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this ); // create a new mesh object MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode); - meshServant->SetImpl( myGen.CreateMesh( myIsEmbeddedMode )); + SMESH_Mesh* myImpl = dynamic_cast(myGen.CreateMesh( myIsEmbeddedMode )); + if(myImpl == NULL ) + THROW_SALOME_CORBA_EXCEPTION( "Could not cast SequentialMesh as Mesh", SALOME::INTERNAL_ERROR ); + meshServant->SetImpl(myImpl); // activate the CORBA servant of Mesh SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() ); @@ -586,6 +594,42 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh() return SMESH::SMESH_Mesh::_nil(); } +//============================================================================= +/*! + * SMESH_Gen_i::createParallelMesh + * + * Create empty parallel mesh on shape + */ +//============================================================================= +SMESH::SMESH_ParallelMesh_ptr SMESH_Gen_i::createParallelMesh() +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "SMESH_Gen_i::createParallelMesh" ); + + // Get or create the GEOM_Client instance + try { + // create a new mesh object servant, store it in a map in study context + SMESH_ParallelMesh_i* meshServant = new SMESH_ParallelMesh_i( GetPOA(), this ); + // create a new mesh object + MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode); + SMESH_Mesh* myImpl = dynamic_cast(myGen.CreateParallelMesh( myIsEmbeddedMode )); + if(myImpl == NULL ) + THROW_SALOME_CORBA_EXCEPTION( "Could not cast ParallelMesh as Mesh", SALOME::INTERNAL_ERROR ); + meshServant->SetImpl(myImpl); + + // activate the CORBA servant of Mesh + SMESH::SMESH_ParallelMesh_var mesh = SMESH::SMESH_ParallelMesh::_narrow( meshServant->_this() ); + int nextId = RegisterObject( mesh ); + MESSAGE( "Add mesh to map with id = "<< nextId); + + return mesh._retn(); + } + catch (SALOME_Exception& S_ex) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + return SMESH::SMESH_ParallelMesh::_nil(); +} + //============================================================================= /*! * SMESH_Gen_i::GetShapeReader @@ -1198,7 +1242,7 @@ char* SMESH_Gen_i::GetOption(const char* name) SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObject ) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::CreateMesh" ); + MESSAGE( "SMESH_Gen_i::CreateMesh(GEOM_Object_ptr)" ); // create mesh SMESH::SMESH_Mesh_var mesh = this->createMesh(); // set shape @@ -1221,6 +1265,40 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj return mesh._retn(); } +//============================================================================= +/*! + * SMESH_Gen_i::CreateParallelMesh + * + * Create empty parallel mesh on a shape and publish it in the study + */ +//============================================================================= + +SMESH::SMESH_ParallelMesh_ptr SMESH_Gen_i::CreateParallelMesh( GEOM::GEOM_Object_ptr theShapeObject ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "SMESH_Gen_i::CreateParallelMesh" ); + // create mesh + SMESH::SMESH_ParallelMesh_var mesh = this->createParallelMesh(); + // set shape + SMESH_ParallelMesh_i* meshServant = SMESH::DownCast( mesh ); + ASSERT( meshServant ); + meshServant->SetShape( theShapeObject ); + + // publish mesh in the study + if ( CanPublishInStudy( mesh ) ) { + SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder(); + aStudyBuilder->NewCommand(); // There is a transaction + SALOMEDS::SObject_wrap aSO = PublishMesh( mesh.in() ); + aStudyBuilder->CommitCommand(); + if ( !aSO->_is_nil() ) { + // Update Python script + TPythonDump(this) << aSO << " = " << this << ".CreateParallelMesh(" << theShapeObject << ")"; + } + } + + return mesh._retn(); +} + //============================================================================= /*! * SMESH_Gen_i::CreateEmptyMesh @@ -1232,7 +1310,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh() { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::CreateMesh" ); + MESSAGE( "SMESH_Gen_i::CreateEmptyMesh" ); // create mesh SMESH::SMESH_Mesh_var mesh = this->createMesh();