0019923: EDF 765 SMESH : default values of hypothesis

SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char*           theHypType,
                                                             const char*           theLibName,
                                                             SMESH::SMESH_Mesh_ptr theMesh,
-                                                            GEOM::GEOM_Object_ptr theGeom)
+                                                            GEOM::GEOM_Object_ptr theGeom,
+                                                            CORBA::Boolean        byMesh)
This commit is contained in:
eap 2009-01-13 13:08:34 +00:00
parent af446655b4
commit 02b44240c2
2 changed files with 61 additions and 39 deletions

View File

@ -134,6 +134,9 @@ SALOME_NamingService* SMESH_Gen_i::myNS = NULL;
SALOME_LifeCycleCORBA* SMESH_Gen_i::myLCC = NULL; SALOME_LifeCycleCORBA* SMESH_Gen_i::myLCC = NULL;
SMESH_Gen_i* SMESH_Gen_i::mySMESHGen = NULL; SMESH_Gen_i* SMESH_Gen_i::mySMESHGen = NULL;
const int nbElemPerDiagonal = 10;
//============================================================================= //=============================================================================
/*! /*!
* GetServant [ static ] * GetServant [ static ]
@ -458,6 +461,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh()
SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() ); SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
// create a new mesh object // create a new mesh object
meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode )); meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
meshServant->GetImpl().SetNbElementsPerDiagonal( nbElemPerDiagonal );
// activate the CORBA servant of Mesh // activate the CORBA servant of Mesh
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() ); SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() );
@ -641,7 +645,8 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam
//================================================================================ //================================================================================
/*! /*!
* \brief Return hypothesis of given type holding parameter values of the existing mesh * \brief Return a hypothesis holding parameter values corresponding either to the mesh
* existing on the given geometry or to size of the geometry.
* \param theHypType - hypothesis type name * \param theHypType - hypothesis type name
* \param theLibName - plugin library name * \param theLibName - plugin library name
* \param theMesh - The mesh of interest * \param theMesh - The mesh of interest
@ -656,11 +661,12 @@ SMESH::SMESH_Hypothesis_ptr
SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType, SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
const char* theLibName, const char* theLibName,
SMESH::SMESH_Mesh_ptr theMesh, SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theGeom) GEOM::GEOM_Object_ptr theGeom,
CORBA::Boolean byMesh)
throw ( SALOME::SALOME_Exception ) throw ( SALOME::SALOME_Exception )
{ {
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
if ( CORBA::is_nil( theMesh ) ) if ( CORBA::is_nil( theMesh ) && byMesh )
THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM ); THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
if ( CORBA::is_nil( theGeom ) ) if ( CORBA::is_nil( theGeom ) )
THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM );
@ -672,11 +678,11 @@ SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
// get mesh and shape // get mesh and shape
SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh ); SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
TopoDS_Shape shape = GeomObjectToShape( theGeom ); TopoDS_Shape shape = GeomObjectToShape( theGeom );
if ( !meshServant || shape.IsNull() ) if ( !meshServant && byMesh || shape.IsNull() )
return SMESH::SMESH_Hypothesis::_nil(); return SMESH::SMESH_Hypothesis::_nil();
::SMESH_Mesh& mesh = meshServant->GetImpl(); ::SMESH_Mesh* mesh = meshServant ? &meshServant->GetImpl() : (::SMESH_Mesh*)0;
if ( mesh.NbNodes() == 0 ) // empty mesh if ( byMesh && mesh->NbNodes() == 0 ) // empty mesh
return SMESH::SMESH_Hypothesis::_nil(); return SMESH::SMESH_Hypothesis::_nil();
// create a temporary hypothesis to know its dimention // create a temporary hypothesis to know its dimention
@ -686,6 +692,7 @@ SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
return SMESH::SMESH_Hypothesis::_nil(); return SMESH::SMESH_Hypothesis::_nil();
::SMESH_Hypothesis* hyp = hypServant->GetImpl(); ::SMESH_Hypothesis* hyp = hypServant->GetImpl();
if ( byMesh ) {
// look for a hypothesis of theHypType used to mesh the shape // look for a hypothesis of theHypType used to mesh the shape
if ( myGen.GetShapeDim( shape ) == hyp->GetDim() ) if ( myGen.GetShapeDim( shape ) == hyp->GetDim() )
{ {
@ -696,7 +703,7 @@ SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND local! if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND local!
return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] ); return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
// check super shapes // check super shapes
TopTools_ListIteratorOfListOfShape itShape( mesh.GetAncestors( shape )); TopTools_ListIteratorOfListOfShape itShape( mesh->GetAncestors( shape ));
while ( nbLocalHyps == 0 && itShape.More() ) { while ( nbLocalHyps == 0 && itShape.More() ) {
GEOM::GEOM_Object_ptr geomObj = ShapeToGeomObject( itShape.Value() ); GEOM::GEOM_Object_ptr geomObj = ShapeToGeomObject( itShape.Value() );
if ( ! CORBA::is_nil( geomObj )) { if ( ! CORBA::is_nil( geomObj )) {
@ -710,9 +717,23 @@ SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
} }
} }
// let the temporary hypothesis find out some how parameter values // let the temporary hypothesis find out some how parameter values by mesh
if ( hyp->SetParametersByMesh( &mesh, shape )) if ( hyp->SetParametersByMesh( mesh, shape ))
return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp ); return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
}
else {
double diagonal = 0;
if ( mesh )
diagonal = mesh->GetShapeDiagonalSize();
else
diagonal = ::SMESH_Mesh::GetShapeDiagonalSize( shape );
double elemSize = diagonal / nbElemPerDiagonal;
if ( elemSize > 0 ) {
// let the temporary hypothesis initialize it's values
if ( hyp->SetParametersByElementSize( elemSize, mesh ))
return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
}
}
return SMESH::SMESH_Hypothesis::_nil(); return SMESH::SMESH_Hypothesis::_nil();
} }

View File

@ -202,7 +202,8 @@ public:
SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char* theHypType, SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char* theHypType,
const char* theLibName, const char* theLibName,
SMESH::SMESH_Mesh_ptr theMesh, SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theGeom) GEOM::GEOM_Object_ptr theGeom,
CORBA::Boolean byMesh)
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
// Create empty mesh on a shape // Create empty mesh on a shape