mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50:34 +05:00
PAL10953. Add GetGeometryByMeshElement()
This commit is contained in:
parent
1e92e82bb3
commit
dd5e16f1de
@ -138,9 +138,8 @@ module SMESH
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
/*!
|
||||
*
|
||||
* Return true if hypotheses are defined well
|
||||
*/
|
||||
|
||||
boolean IsReadyToCompute( in SMESH_Mesh theMesh,
|
||||
in GEOM::GEOM_Object theSubObject )
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
@ -161,10 +160,14 @@ module SMESH
|
||||
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
|
||||
|
@ -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