0021783: EDF 785 SMESH : Bad display of Groups of Volumes

fix iteration on types of elements
This commit is contained in:
eap 2012-08-08 14:59:54 +00:00
parent e050f81084
commit beabd65174

View File

@ -82,14 +82,14 @@ static int MYDEBUGWITHFILES = 0;
// purpose : Get type of VTK cell // purpose : Get type of VTK cell
//================================================================================= //=================================================================================
static inline vtkIdType getCellType( const SMDSAbs_ElementType theType, static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
const bool thePoly, const bool thePoly,
const int theNbNodes ) const int theNbNodes )
{ {
switch( theType ) switch( theType )
{ {
case SMDSAbs_0DElement: return VTK_VERTEX; case SMDSAbs_0DElement: return VTK_VERTEX;
case SMDSAbs_Ball: return VTK_POLY_VERTEX; case SMDSAbs_Ball: return VTK_POLY_VERTEX;
case SMDSAbs_Edge: case SMDSAbs_Edge:
if( theNbNodes == 2 ) return VTK_LINE; if( theNbNodes == 2 ) return VTK_LINE;
@ -345,14 +345,15 @@ void SMESH_VisualObjDef::buildElemPrs()
// Calculate cells size // Calculate cells size
static SMDSAbs_ElementType aTypes[ 5 ] = const int nbTypes = 5;
{ SMDSAbs_Ball, SMDSAbs_0DElement, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume }; static SMDSAbs_ElementType aTypes[ nbTypes ] =
{ SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume, SMDSAbs_Ball, SMDSAbs_0DElement };
// get entity data // get entity data
map<SMDSAbs_ElementType,int> nbEnts; map<SMDSAbs_ElementType,int> nbEnts;
map<SMDSAbs_ElementType,TEntityList> anEnts; map<SMDSAbs_ElementType,TEntityList> anEnts;
for ( int i = 0; i <= 3; i++ ) for ( int i = 0; i < nbTypes; i++ )
nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] ); nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] );
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead, // PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
@ -362,8 +363,12 @@ void SMESH_VisualObjDef::buildElemPrs()
vtkIdType aCellsSize = 2 * nbEnts[ SMDSAbs_0DElement ] + 3 * nbEnts[ SMDSAbs_Edge ]; vtkIdType aCellsSize = 2 * nbEnts[ SMDSAbs_0DElement ] + 3 * nbEnts[ SMDSAbs_Edge ];
aCellsSize += 2 * nbEnts[ SMDSAbs_Ball ]; aCellsSize += 2 * nbEnts[ SMDSAbs_Ball ];
for ( int i = 2; i <= 3; i++ ) // iterate through faces and volumes vtkIdType aNbCells = 0;
for ( int i = 1; i <= 2; i++ ) // iterate through faces and volumes
{ {
aNbCells += nbEnts[ aTypes[ i ]];
if ( nbEnts[ aTypes[ i ] ] ) if ( nbEnts[ aTypes[ i ] ] )
{ {
const TEntityList& aList = anEnts[ aTypes[ i ] ]; const TEntityList& aList = anEnts[ aTypes[ i ] ];
@ -388,11 +393,6 @@ void SMESH_VisualObjDef::buildElemPrs()
} }
} }
} }
vtkIdType aNbCells =
nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Ball ] + nbEnts[ SMDSAbs_Edge ] +
nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize ); MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize );
@ -417,7 +417,7 @@ void SMESH_VisualObjDef::buildElemPrs()
SMDS_Mesh::CheckMemory(); // PAL16631 SMDS_Mesh::CheckMemory(); // PAL16631
for ( int i = 0; i <= 3; i++ ) // iterate through 0d elements, edges, faces and volumes for ( int i = 0; i < nbTypes; i++ ) // iterate through all types of elements
{ {
if ( nbEnts[ aTypes[ i ] ] > 0 ) { if ( nbEnts[ aTypes[ i ] ] > 0 ) {