mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 17:30:35 +05:00
PAL10953. Add GetGeometryByMeshElement()
This commit is contained in:
parent
1e92e82bb3
commit
dd5e16f1de
@ -133,15 +133,14 @@ module SMESH
|
||||
* First, verify list of hypothesis associated with the subShape,
|
||||
* return NOK if hypothesis are not sufficient
|
||||
*/
|
||||
boolean Compute( in SMESH_Mesh theMesh,
|
||||
boolean Compute( in SMESH_Mesh theMesh,
|
||||
in GEOM::GEOM_Object theSubObject )
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
/*!
|
||||
*
|
||||
* Return true if hypotheses are defined well
|
||||
*/
|
||||
|
||||
boolean IsReadyToCompute( in SMESH_Mesh theMesh,
|
||||
boolean IsReadyToCompute( in SMESH_Mesh theMesh,
|
||||
in GEOM::GEOM_Object theSubObject )
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
@ -149,7 +148,7 @@ module SMESH
|
||||
* Return errors of hypotheses definintion
|
||||
* algo_error_array is empty if everything is OK
|
||||
*/
|
||||
algo_error_array GetAlgoState( in SMESH_Mesh theMesh,
|
||||
algo_error_array GetAlgoState( in SMESH_Mesh theMesh,
|
||||
in GEOM::GEOM_Object theSubObject )
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
@ -157,15 +156,19 @@ module SMESH
|
||||
*
|
||||
*/
|
||||
long_array GetSubShapesId( in GEOM::GEOM_Object theMainObject,
|
||||
in object_array theListOfSubObjects )
|
||||
in object_array theListOfSubObjects )
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
|
||||
/*!
|
||||
*
|
||||
* Return geometrical object the given element is built on.
|
||||
* The returned geometrical object, if not nil, is either found in the
|
||||
* study or is published by this method with the given name
|
||||
*/
|
||||
// long_array GetSubMeshesState( in object_array theListOfSubShape )
|
||||
// raises ( SALOME::SALOME_Exception );
|
||||
|
||||
GEOM::GEOM_Object GetGeometryByMeshElement( in SMESH_Mesh theMesh,
|
||||
in long theElementID,
|
||||
in string theGeomName)
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "SMESH_Mesh.hxx"
|
||||
#include "SMESH_Hypothesis.hxx"
|
||||
#include "SMESH_Group.hxx"
|
||||
#include "SMESH_MeshEditor.hxx"
|
||||
|
||||
#include "SMDS_EdgePosition.hxx"
|
||||
#include "SMDS_FacePosition.hxx"
|
||||
@ -1012,6 +1013,63 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return geometrical object the given element is built on
|
||||
* \param theMesh - the mesh the element is in
|
||||
* \param theElementID - the element ID
|
||||
* \param theGeomName - the name of the result geom object if it is not yet published
|
||||
* \retval GEOM::GEOM_Object_ptr - the found or just published geom object
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
GEOM::GEOM_Object_ptr
|
||||
SMESH_Gen_i::GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
|
||||
CORBA::Long theElementID,
|
||||
const char* theGeomName)
|
||||
throw ( SALOME::SALOME_Exception )
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
if ( CORBA::is_nil( theMesh ) )
|
||||
THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
|
||||
|
||||
GEOM::GEOM_Object_var mainShape = theMesh->GetShapeToMesh();
|
||||
GEOM::GEOM_Gen_var geomGen = GetGeomEngine();
|
||||
|
||||
// get a core mesh DS
|
||||
SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
|
||||
if ( meshServant && !geomGen->_is_nil() && !mainShape->_is_nil() )
|
||||
{
|
||||
::SMESH_Mesh & mesh = meshServant->GetImpl();
|
||||
SMESHDS_Mesh* meshDS = mesh.GetMeshDS();
|
||||
// find the element in mesh
|
||||
if ( const SMDS_MeshElement * elem = meshDS->FindElement( theElementID ) )
|
||||
// find a shape id by the element
|
||||
if ( int shapeID = ::SMESH_MeshEditor( &mesh ).FindShape( elem )) {
|
||||
// get a geom object by the shape id
|
||||
GEOM::GEOM_Object_var geom = ShapeToGeomObject( meshDS->IndexToShape( shapeID ));
|
||||
if ( geom->_is_nil() ) {
|
||||
GEOM::GEOM_IShapesOperations_var op =
|
||||
geomGen->GetIShapesOperations( GetCurrentStudyID() );
|
||||
if ( !op->_is_nil() )
|
||||
geom = op->GetSubShape( mainShape, shapeID );
|
||||
}
|
||||
if ( !geom->_is_nil() ) {
|
||||
// try to find the corresponding SObject
|
||||
GeomObjectToShape( geom ); // geom client remembers the found shape
|
||||
SALOMEDS::SObject_var SObj = ObjectToSObject( myCurrentStudy, geom.in() );
|
||||
if ( SObj->_is_nil() )
|
||||
// publish a new subshape
|
||||
SObj = geomGen->AddInStudy( myCurrentStudy, geom, theGeomName, mainShape );
|
||||
// return only published geometry
|
||||
if ( !SObj->_is_nil() )
|
||||
return geom._retn();
|
||||
}
|
||||
}
|
||||
}
|
||||
return GEOM::GEOM_Object::_nil();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_Gen_i::Save
|
||||
@ -1020,8 +1078,8 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
|
||||
*/
|
||||
//=============================================================================
|
||||
SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
||||
const char* theURL,
|
||||
bool isMultiFile )
|
||||
const char* theURL,
|
||||
bool isMultiFile )
|
||||
{
|
||||
INFOS( "SMESH_Gen_i::Save" );
|
||||
|
||||
|
@ -220,6 +220,11 @@ public:
|
||||
const SMESH::object_array& theListOfSubShape )
|
||||
throw ( SALOME::SALOME_Exception );
|
||||
|
||||
// Return geometrical object the given element is built on
|
||||
GEOM::GEOM_Object_ptr GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
|
||||
CORBA::Long theElementID,
|
||||
const char* theGeomName)
|
||||
throw ( SALOME::SALOME_Exception );
|
||||
|
||||
// ****************************************************
|
||||
// Interface inherited methods (from SALOMEDS::Driver)
|
||||
|
Loading…
Reference in New Issue
Block a user