mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-24 08:20:34 +05:00
0021275: EDF 1681 SMESH: Find the number of nodes of any group
+ long GetNumberOfNodes(); + long_array GetNodeIDs(); + boolean IsNodeInfoAvailable();
This commit is contained in:
parent
a1f18f175a
commit
044576569d
@ -83,6 +83,23 @@ module SMESH
|
||||
*/
|
||||
long_array GetListOfID();
|
||||
|
||||
/*!
|
||||
* Get the number of nodes of cells included to the group
|
||||
* For a nodal group returns the same value as Size() function
|
||||
*/
|
||||
long GetNumberOfNodes();
|
||||
|
||||
/*!
|
||||
* Get IDs of nodes of cells included to the group
|
||||
* For a nodal group returns result of GetListOfID() function
|
||||
*/
|
||||
long_array GetNodeIDs();
|
||||
|
||||
/*!
|
||||
* Return true if GetNumberOfNodes() won't take a long time for computation
|
||||
*/
|
||||
boolean IsNodeInfoAvailable();
|
||||
|
||||
/*!
|
||||
* Sets group color
|
||||
*/
|
||||
@ -107,7 +124,7 @@ module SMESH
|
||||
};
|
||||
|
||||
/*!
|
||||
* SMESH_Group: interface of group object
|
||||
* SMESH_Group: interface of a standalone group object
|
||||
*/
|
||||
interface SMESH_Group : SMESH_GroupBase
|
||||
{
|
||||
@ -141,7 +158,7 @@ module SMESH
|
||||
};
|
||||
|
||||
/*!
|
||||
* SMESH_GroupOnGeom: interface of group object linked to geometry
|
||||
* SMESH_GroupOnGeom: interface of a group object linked to geometry
|
||||
*/
|
||||
interface SMESH_GroupOnGeom : SMESH_GroupBase
|
||||
{
|
||||
@ -149,7 +166,7 @@ module SMESH
|
||||
};
|
||||
|
||||
/*!
|
||||
* SMESH_GroupOnFilter: interface of group object defined by filter
|
||||
* SMESH_GroupOnFilter: interface of a group object defined by filter
|
||||
*/
|
||||
interface SMESH_GroupOnFilter : SMESH_GroupBase
|
||||
{
|
||||
|
@ -55,7 +55,9 @@ SMESH_GroupBase_i::SMESH_GroupBase_i( PortableServer::POA_ptr thePOA,
|
||||
const int theLocalID )
|
||||
: SALOME::GenericObj_i( thePOA ),
|
||||
myMeshServant( theMeshServant ),
|
||||
myLocalID( theLocalID )
|
||||
myLocalID( theLocalID ),
|
||||
myNbNodes(-1),
|
||||
myGroupDSTic(0)
|
||||
{
|
||||
// PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i,
|
||||
// servant activation is performed by SMESH_Mesh_i::createGroup()
|
||||
@ -436,6 +438,88 @@ SMESH::long_array* SMESH_GroupBase_i::GetListOfID()
|
||||
return aRes._retn();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief return nodes of elements pointered by iterator
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void getNodesOfElements(SMDS_ElemIteratorPtr elemIt,
|
||||
set<const SMDS_MeshNode* >& nodes)
|
||||
{
|
||||
while ( elemIt->more() )
|
||||
{
|
||||
const SMDS_MeshElement* e = elemIt->next();
|
||||
nodes.insert( e->begin_nodes(), e->end_nodes() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief return the number of nodes of cells included to the group
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
CORBA::Long SMESH_GroupBase_i::GetNumberOfNodes()
|
||||
{
|
||||
if ( GetType() == SMESH::NODE )
|
||||
return Size();
|
||||
|
||||
if ( SMESHDS_GroupBase* g = GetGroupDS())
|
||||
{
|
||||
if ( myNbNodes < 0 || g->GetTic() != myGroupDSTic )
|
||||
{
|
||||
set<const SMDS_MeshNode* > nodes;
|
||||
getNodesOfElements( g->GetElements(), nodes );
|
||||
myNbNodes = nodes.size();
|
||||
myGroupDSTic = g->GetTic();
|
||||
}
|
||||
}
|
||||
return myNbNodes;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return true if GetNumberOfNodes() won't take a long time for computation
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
CORBA::Boolean SMESH_GroupBase_i::IsNodeInfoAvailable()
|
||||
{
|
||||
if ( GetType() == SMESH::NODE || Size() < 100000 )
|
||||
return true;
|
||||
if ( SMESHDS_GroupBase* g = GetGroupDS())
|
||||
return ( myNbNodes > -1 && g->GetTic() == myGroupDSTic);
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return IDs of nodes of cells included to the group
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMESH::long_array* SMESH_GroupBase_i::GetNodeIDs()
|
||||
{
|
||||
if ( GetType() == SMESH::NODE )
|
||||
return GetListOfID();
|
||||
|
||||
SMESH::long_array_var aRes = new SMESH::long_array();
|
||||
if ( SMESHDS_GroupBase* g = GetGroupDS())
|
||||
{
|
||||
set<const SMDS_MeshNode* > nodes;
|
||||
getNodesOfElements( g->GetElements(), nodes );
|
||||
aRes->length( nodes.size() );
|
||||
set<const SMDS_MeshNode*>::iterator nIt = nodes.begin(), nEnd = nodes.end();
|
||||
for ( int i = 0; nIt != nEnd; ++nIt, ++i )
|
||||
aRes[i] = (*nIt)->GetID();
|
||||
}
|
||||
return aRes._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
|
@ -64,6 +64,9 @@ class SMESH_I_EXPORT SMESH_GroupBase_i:
|
||||
CORBA::Boolean Contains(CORBA::Long elem_id);
|
||||
CORBA::Long GetID(CORBA::Long elem_index);
|
||||
SMESH::long_array* GetListOfID();
|
||||
SMESH::long_array* GetNodeIDs();
|
||||
CORBA::Long GetNumberOfNodes();
|
||||
CORBA::Boolean IsNodeInfoAvailable(); // for gui
|
||||
SMESH::SMESH_Mesh_ptr GetMesh();
|
||||
|
||||
/*!
|
||||
@ -100,6 +103,8 @@ private:
|
||||
|
||||
void changeLocalId(int localId) { myLocalID = localId; }
|
||||
friend class SMESH_Mesh_i;
|
||||
|
||||
int myNbNodes, myGroupDSTic;
|
||||
};
|
||||
|
||||
// ======
|
||||
|
Loading…
Reference in New Issue
Block a user