* 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 );
* 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 );
*
*/
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 );
+
};
};
#include "SMESH_Mesh.hxx"
#include "SMESH_Hypothesis.hxx"
#include "SMESH_Group.hxx"
+#include "SMESH_MeshEditor.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_FacePosition.hxx"
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
*/
//=============================================================================
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" );