mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-18 17:10:32 +05:00
21680: EDF 2288 SMESH: creation of 0D elements from other elements
1) + SMESH::SMESH_IDSource_ptr Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject, + const char* theGroupName) 2) Keep 10 last auxilary IDSources
This commit is contained in:
parent
e47e273629
commit
957276d339
@ -283,7 +283,7 @@ namespace {
|
|||||||
const SMDS_MeshElement * elem =
|
const SMDS_MeshElement * elem =
|
||||||
(aType == SMDSAbs_Node ? aMesh->FindNode(ind) : aMesh->FindElement(ind));
|
(aType == SMDSAbs_Node ? aMesh->FindNode(ind) : aMesh->FindElement(ind));
|
||||||
if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
|
if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
|
||||||
aMap.insert( elem );
|
aMap.insert( aMap.end(), elem );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -443,6 +443,7 @@ SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview):
|
|||||||
|
|
||||||
SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
|
SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
|
||||||
{
|
{
|
||||||
|
deleteAuxIDSources();
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -461,6 +462,7 @@ void SMESH_MeshEditor_i::initData(bool deleteSearchers)
|
|||||||
TSearchersDeleter::Delete();
|
TSearchersDeleter::Delete();
|
||||||
}
|
}
|
||||||
myEditor.GetError().reset();
|
myEditor.GetError().reset();
|
||||||
|
myEditor.CrearLastCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -624,7 +626,7 @@ SMESH::ComputeError* SMESH_MeshEditor_i::GetLastError()
|
|||||||
//purpose : Wrap a sequence of ids in a SMESH_IDSource
|
//purpose : Wrap a sequence of ids in a SMESH_IDSource
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
struct _IDSource : public POA_SMESH::SMESH_IDSource
|
struct SMESH_MeshEditor_i::_IDSource : public POA_SMESH::SMESH_IDSource
|
||||||
{
|
{
|
||||||
SMESH::long_array _ids;
|
SMESH::long_array _ids;
|
||||||
SMESH::ElementType _type;
|
SMESH::ElementType _type;
|
||||||
@ -647,15 +649,28 @@ struct _IDSource : public POA_SMESH::SMESH_IDSource
|
|||||||
SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids,
|
SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids,
|
||||||
SMESH::ElementType type)
|
SMESH::ElementType type)
|
||||||
{
|
{
|
||||||
_IDSource* anIDSource = new _IDSource;
|
if ( myAuxIDSources.size() > 10 )
|
||||||
anIDSource->_ids = ids;
|
deleteAuxIDSources();
|
||||||
anIDSource->_type = type;
|
|
||||||
anIDSource->_mesh = myMesh_i->_this();
|
_IDSource* idSrc = new _IDSource;
|
||||||
SMESH::SMESH_IDSource_var anIDSourceVar = anIDSource->_this();
|
idSrc->_mesh = myMesh_i->_this();
|
||||||
|
idSrc->_ids = ids;
|
||||||
|
idSrc->_type = type;
|
||||||
|
myAuxIDSources.push_back( idSrc );
|
||||||
|
|
||||||
|
SMESH::SMESH_IDSource_var anIDSourceVar = idSrc->_this();
|
||||||
|
|
||||||
return anIDSourceVar._retn();
|
return anIDSourceVar._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SMESH_MeshEditor_i::deleteAuxIDSources()
|
||||||
|
{
|
||||||
|
std::list< _IDSource* >::iterator idSrcIt = myAuxIDSources.begin();
|
||||||
|
for ( ; idSrcIt != myAuxIDSources.end(); ++idSrcIt )
|
||||||
|
delete *idSrcIt;
|
||||||
|
myAuxIDSources.clear();
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
@ -1031,6 +1046,7 @@ CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolume (const SMESH::long_array & I
|
|||||||
* AddPolyhedralVolumeByFaces
|
* AddPolyhedralVolumeByFaces
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_array & IdsOfFaces)
|
CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_array & IdsOfFaces)
|
||||||
{
|
{
|
||||||
initData();
|
initData();
|
||||||
@ -1059,6 +1075,77 @@ CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_ar
|
|||||||
return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
|
return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
// \brief Create 0D elements on all nodes of the given object except those
|
||||||
|
// nodes on which a 0D element already exists.
|
||||||
|
// \param theObject object on whose nodes 0D elements will be created.
|
||||||
|
// \param theGroupName optional name of a group to add 0D elements created
|
||||||
|
// and/or found on nodes of \a theObject.
|
||||||
|
// \return an object (a new group or a temporary SMESH_IDSource) holding
|
||||||
|
// ids of new and/or found 0D elements.
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
SMESH::SMESH_IDSource_ptr
|
||||||
|
SMESH_MeshEditor_i::Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject,
|
||||||
|
const char* theGroupName)
|
||||||
|
throw (SALOME::SALOME_Exception)
|
||||||
|
{
|
||||||
|
initData();
|
||||||
|
|
||||||
|
SMESH::SMESH_IDSource_var result;
|
||||||
|
TPythonDump pyDump;
|
||||||
|
|
||||||
|
TIDSortedElemSet elements, elems0D;
|
||||||
|
if ( idSourceToSet( theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
|
||||||
|
myEditor.Create0DElementsOnAllNodes( elements, elems0D );
|
||||||
|
|
||||||
|
SMESH::long_array_var newElems = new SMESH::long_array;
|
||||||
|
newElems->length( elems0D.size() );
|
||||||
|
TIDSortedElemSet::iterator eIt = elems0D.begin();
|
||||||
|
for ( size_t i = 0; i < elems0D.size(); ++i, ++eIt )
|
||||||
|
newElems[ i ] = (*eIt)->GetID();
|
||||||
|
|
||||||
|
SMESH::SMESH_GroupBase_var groupToFill;
|
||||||
|
if ( theGroupName && strlen( theGroupName ))
|
||||||
|
{
|
||||||
|
// Get existing group named theGroupName
|
||||||
|
SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
|
||||||
|
for (int i = 0, nbGroups = groups->length(); i < nbGroups; i++ ) {
|
||||||
|
SMESH::SMESH_GroupBase_var group = groups[i];
|
||||||
|
if ( !group->_is_nil() ) {
|
||||||
|
CORBA::String_var name = group->GetName();
|
||||||
|
if ( strcmp( name.in(), theGroupName ) == 0 && group->GetType() == SMESH::ELEM0D ) {
|
||||||
|
groupToFill = group;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( groupToFill->_is_nil() )
|
||||||
|
groupToFill = myMesh_i->CreateGroup( SMESH::ELEM0D, theGroupName );
|
||||||
|
else if ( !SMESH::DownCast< SMESH_Group_i* > ( groupToFill ))
|
||||||
|
groupToFill = myMesh_i->ConvertToStandalone( groupToFill );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( SMESH_Group_i* group_i = SMESH::DownCast< SMESH_Group_i* > ( groupToFill ))
|
||||||
|
{
|
||||||
|
group_i->Add( newElems );
|
||||||
|
result = SMESH::SMESH_IDSource::_narrow( groupToFill );
|
||||||
|
pyDump << groupToFill;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = MakeIDSource( newElems, SMESH::ELEM0D );
|
||||||
|
pyDump << "elem0DIDs";
|
||||||
|
}
|
||||||
|
|
||||||
|
pyDump << " = " << this << ".Create0DElementsOnAllNodes( "
|
||||||
|
<< theObject << ", '" << theGroupName << "' )";
|
||||||
|
|
||||||
|
return result._retn();
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Bind a node to a vertex
|
* \brief Bind a node to a vertex
|
||||||
@ -5244,24 +5331,16 @@ string SMESH_MeshEditor_i::generateGroupName(const string& thePrefix)
|
|||||||
if (CORBA::is_nil(aGroup))
|
if (CORBA::is_nil(aGroup))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
groupNames.insert(aGroup->GetName());
|
CORBA::String_var name = aGroup->GetName();
|
||||||
|
groupNames.insert( name.in() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find new name
|
// Find new name
|
||||||
string name = thePrefix;
|
string name = thePrefix;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
while (!groupNames.insert(name).second) {
|
while (!groupNames.insert(name).second)
|
||||||
if (index == 0) {
|
name = SMESH_Comment( thePrefix ) << "_" << index;
|
||||||
name += "_1";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TCollection_AsciiString nbStr(index+1);
|
|
||||||
name.resize( name.rfind('_')+1 );
|
|
||||||
name += nbStr.ToCString();
|
|
||||||
}
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,19 @@ public:
|
|||||||
const SMESH::long_array & Quantities);
|
const SMESH::long_array & Quantities);
|
||||||
CORBA::Long AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
|
CORBA::Long AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create 0D elements on all nodes of the given object except those
|
||||||
|
* nodes on which a 0D element already exists.
|
||||||
|
* \param theObject object on whose nodes 0D elements will be created.
|
||||||
|
* \param theGroupName optional name of a group to add 0D elements created
|
||||||
|
* and/or found on nodes of \a theObject.
|
||||||
|
* \return an object (a new group or a temporary SMESH_IDSource) holding
|
||||||
|
* ids of new and/or found 0D elements.
|
||||||
|
*/
|
||||||
|
SMESH::SMESH_IDSource_ptr Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject,
|
||||||
|
const char* theGroupName)
|
||||||
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Bind a node to a vertex
|
* \brief Bind a node to a vertex
|
||||||
* \param NodeID - node ID
|
* \param NodeID - node ID
|
||||||
@ -919,6 +932,11 @@ private: //!< fields
|
|||||||
|
|
||||||
SMESH::MeshPreviewStruct_var myPreviewData;
|
SMESH::MeshPreviewStruct_var myPreviewData;
|
||||||
bool myPreviewMode;
|
bool myPreviewMode;
|
||||||
|
|
||||||
|
// temporary IDSources
|
||||||
|
struct _IDSource;
|
||||||
|
std::list< _IDSource* > myAuxIDSources;
|
||||||
|
void deleteAuxIDSources();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user