mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-15 10:08:34 +05:00
0021014: EDF 1583 SMESH: Improvement of the Python Dump for the creation of groups
+ SMESH::SMESH_GroupOnFilter_ptr CreateGroupFromFilter()
This commit is contained in:
parent
fa0176f072
commit
bd284fc142
@ -726,26 +726,6 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
|
|||||||
removeSubMesh( theSubMesh, aSubShapeObject.in() );
|
removeSubMesh( theSubMesh, aSubShapeObject.in() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
/*!
|
|
||||||
* ElementTypeString
|
|
||||||
*/
|
|
||||||
//=============================================================================
|
|
||||||
#define CASE2STRING(enum) case SMESH::enum: return "SMESH."#enum;
|
|
||||||
inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType)
|
|
||||||
{
|
|
||||||
switch (theElemType) {
|
|
||||||
CASE2STRING( ALL );
|
|
||||||
CASE2STRING( NODE );
|
|
||||||
CASE2STRING( EDGE );
|
|
||||||
CASE2STRING( FACE );
|
|
||||||
CASE2STRING( VOLUME );
|
|
||||||
CASE2STRING( ELEM0D );
|
|
||||||
default:;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
@ -767,7 +747,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType
|
|||||||
if ( !aSO->_is_nil()) {
|
if ( !aSO->_is_nil()) {
|
||||||
// Update Python script
|
// Update Python script
|
||||||
TPythonDump() << aSO << " = " << _this() << ".CreateGroup( "
|
TPythonDump() << aSO << " = " << _this() << ".CreateGroup( "
|
||||||
<< ElementTypeString(theElemType) << ", '" << theName << "' )";
|
<< theElemType << ", '" << theName << "' )";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return aNewGroup._retn();
|
return aNewGroup._retn();
|
||||||
@ -779,9 +759,10 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType theElemType,
|
SMESH::SMESH_GroupOnGeom_ptr
|
||||||
const char* theName,
|
SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType theElemType,
|
||||||
GEOM::GEOM_Object_ptr theGeomObj)
|
const char* theName,
|
||||||
|
GEOM::GEOM_Object_ptr theGeomObj)
|
||||||
throw(SALOME::SALOME_Exception)
|
throw(SALOME::SALOME_Exception)
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
@ -800,8 +781,7 @@ SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementTy
|
|||||||
if ( !aSO->_is_nil()) {
|
if ( !aSO->_is_nil()) {
|
||||||
// Update Python script
|
// Update Python script
|
||||||
TPythonDump() << aSO << " = " << _this() << ".CreateGroupFromGEOM("
|
TPythonDump() << aSO << " = " << _this() << ".CreateGroupFromGEOM("
|
||||||
<< ElementTypeString(theElemType) << ", '" << theName << "', "
|
<< theElemType << ", '" << theName << "', " << theGeomObj << " )";
|
||||||
<< theGeomObj << " )";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -809,6 +789,53 @@ SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementTy
|
|||||||
return aNewGroup._retn();
|
return aNewGroup._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Creates a group whose contents is defined by filter
|
||||||
|
* \param theElemType - group type
|
||||||
|
* \param theName - group name
|
||||||
|
* \param theFilter - the filter
|
||||||
|
* \retval SMESH::SMESH_GroupOnFilter_ptr - group defined by filter
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
SMESH::SMESH_GroupOnFilter_ptr
|
||||||
|
SMESH_Mesh_i::CreateGroupFromFilter(SMESH::ElementType theElemType,
|
||||||
|
const char* theName,
|
||||||
|
SMESH::Filter_ptr theFilter )
|
||||||
|
throw (SALOME::SALOME_Exception)
|
||||||
|
{
|
||||||
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
|
|
||||||
|
if ( CORBA::is_nil( theFilter ))
|
||||||
|
THROW_SALOME_CORBA_EXCEPTION("NULL filter", SALOME::BAD_PARAM);
|
||||||
|
|
||||||
|
SMESH_PredicatePtr predicate = SMESH_GroupOnFilter_i::GetPredicate( theFilter );
|
||||||
|
if ( !predicate )
|
||||||
|
THROW_SALOME_CORBA_EXCEPTION("Invalid filter", SALOME::BAD_PARAM);
|
||||||
|
|
||||||
|
SMESH::SMESH_GroupOnFilter_var aNewGroup = SMESH::SMESH_GroupOnFilter::_narrow
|
||||||
|
( createGroup( theElemType, theName, TopoDS_Shape(), predicate ));
|
||||||
|
|
||||||
|
TPythonDump pd;
|
||||||
|
if ( !aNewGroup->_is_nil() )
|
||||||
|
aNewGroup->SetFilter( theFilter );
|
||||||
|
|
||||||
|
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
|
||||||
|
{
|
||||||
|
SALOMEDS::SObject_var aSO =
|
||||||
|
_gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(), aNewGroup,
|
||||||
|
GEOM::GEOM_Object::_nil(), theName);
|
||||||
|
if ( !aSO->_is_nil()) {
|
||||||
|
// Update Python script
|
||||||
|
pd << aSO << " = " << _this() << ".CreateGroupFromFilter("
|
||||||
|
<< theElemType << ", '" << theName << "', " << theFilter << " )";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aNewGroup._retn();
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
@ -1905,11 +1932,11 @@ void SMESH_Mesh_i::CheckGeomGroupModif()
|
|||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Create standalone group instead if group on geometry
|
* \brief Create standalone group from a group on geometry or filter
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGroup )
|
SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase_ptr theGroup )
|
||||||
{
|
{
|
||||||
SMESH::SMESH_Group_var aGroup;
|
SMESH::SMESH_Group_var aGroup;
|
||||||
if ( theGroup->_is_nil() )
|
if ( theGroup->_is_nil() )
|
||||||
@ -2070,9 +2097,10 @@ void SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
|
|||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElemType,
|
SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElemType,
|
||||||
const char* theName,
|
const char* theName,
|
||||||
const TopoDS_Shape& theShape )
|
const TopoDS_Shape& theShape,
|
||||||
|
const SMESH_PredicatePtr& thePredicate )
|
||||||
{
|
{
|
||||||
std::string newName;
|
std::string newName;
|
||||||
if ( !theName || strlen( theName ) == 0 )
|
if ( !theName || strlen( theName ) == 0 )
|
||||||
@ -2088,10 +2116,13 @@ SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElem
|
|||||||
}
|
}
|
||||||
int anId;
|
int anId;
|
||||||
SMESH::SMESH_GroupBase_var aGroup;
|
SMESH::SMESH_GroupBase_var aGroup;
|
||||||
if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId, theShape )) {
|
if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId, theShape, thePredicate ))
|
||||||
|
{
|
||||||
SMESH_GroupBase_i* aGroupImpl;
|
SMESH_GroupBase_i* aGroupImpl;
|
||||||
if ( !theShape.IsNull() )
|
if ( !theShape.IsNull() )
|
||||||
aGroupImpl = new SMESH_GroupOnGeom_i( SMESH_Gen_i::GetPOA(), this, anId );
|
aGroupImpl = new SMESH_GroupOnGeom_i( SMESH_Gen_i::GetPOA(), this, anId );
|
||||||
|
else if ( thePredicate )
|
||||||
|
aGroupImpl = new SMESH_GroupOnFilter_i( SMESH_Gen_i::GetPOA(), this, anId );
|
||||||
else
|
else
|
||||||
aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
|
aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
|
||||||
|
|
||||||
|
@ -102,6 +102,11 @@ public:
|
|||||||
GEOM::GEOM_Object_ptr theGeomObj )
|
GEOM::GEOM_Object_ptr theGeomObj )
|
||||||
throw (SALOME::SALOME_Exception);
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
|
SMESH::SMESH_GroupOnFilter_ptr CreateGroupFromFilter(SMESH::ElementType theElemType,
|
||||||
|
const char* theName,
|
||||||
|
SMESH::Filter_ptr theFilter )
|
||||||
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
|
void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
|
||||||
throw (SALOME::SALOME_Exception);
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
@ -148,7 +153,7 @@ public:
|
|||||||
throw (SALOME::SALOME_Exception);
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
|
|
||||||
SMESH::SMESH_Group_ptr ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGeomGroup );
|
SMESH::SMESH_Group_ptr ConvertToStandalone( SMESH::SMESH_GroupBase_ptr theGroupOn );
|
||||||
|
|
||||||
// SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
|
// SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
|
||||||
// throw (SALOME::SALOME_Exception);
|
// throw (SALOME::SALOME_Exception);
|
||||||
@ -366,9 +371,10 @@ public:
|
|||||||
void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
|
void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
|
||||||
GEOM::GEOM_Object_ptr theSubShapeObject );
|
GEOM::GEOM_Object_ptr theSubShapeObject );
|
||||||
|
|
||||||
SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
|
SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
|
||||||
const char* theName,
|
const char* theName,
|
||||||
const TopoDS_Shape& theShape = TopoDS_Shape());
|
const TopoDS_Shape& theShape = TopoDS_Shape(),
|
||||||
|
const SMESH_PredicatePtr& thePred = SMESH_PredicatePtr());
|
||||||
|
|
||||||
void removeGroup( const int theId );
|
void removeGroup( const int theId );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user