X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Group_i.cxx;h=8aa34cd9aaddc0a1aa12b8734fc0d62c79d07902;hb=493747e8ea338a2d88204a5f12ba924d72ecbb5b;hp=20eb9798a9a4e397bc4d87faf7d19c4701d70b0b;hpb=fa0176f07261b9a4c7b4672287c7c229ac427111;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 20eb9798a..8aa34cd9a 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -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& 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 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 nodes; + getNodesOfElements( g->GetElements(), nodes ); + aRes->length( nodes.size() ); + set::iterator nIt = nodes.begin(), nEnd = nodes.end(); + for ( int i = 0; nIt != nEnd; ++nIt, ++i ) + aRes[i] = (*nIt)->GetID(); + } + return aRes._retn(); +} + //============================================================================= /*! * @@ -498,8 +582,12 @@ void SMESH_GroupBase_i::SetColor(const SALOMEDS::Color& color) if (aGroupDS) { Quantity_Color aQColor( color.R, color.G, color.B, Quantity_TOC_RGB ); - aGroupDS->SetColor(aQColor); - TPythonDump()<<_this()<<".SetColor( SALOMEDS.Color( "<GetColor(); + if ( oldColor != aQColor ) + { + aGroupDS->SetColor(aQColor); + TPythonDump()<<_this()<<".SetColor( SALOMEDS.Color( "<length( 1 ); - types[0] = GetType(); + if ( SMESHDS_GroupBase* ds = GetGroupDS() ) + if ( !ds->IsEmpty() ) + { + types->length( 1 ); + types[0] = GetType(); + } return types._retn(); }