Fix for the bug 21416: EDF SMESH: Impossible to display a group of polyhedra

This commit is contained in:
rnv 2011-11-07 10:34:28 +00:00
parent 6e9a9249d6
commit b713a5471d

View File

@ -368,9 +368,25 @@ void SMESH_VisualObjDef::buildElemPrs()
{ {
const TEntityList& aList = anEnts[ aTypes[ i ] ]; const TEntityList& aList = anEnts[ aTypes[ i ] ];
TEntityList::const_iterator anIter; TEntityList::const_iterator anIter;
for ( anIter = aList.begin(); anIter != aList.end(); ++anIter ) for ( anIter = aList.begin(); anIter != aList.end(); ++anIter ) {
if((*anIter)->GetEntityType() != SMDSEntity_Polyhedra &&
(*anIter)->GetEntityType() != SMDSEntity_Quad_Polyhedra) {
aCellsSize += (*anIter)->NbNodes() + 1; aCellsSize += (*anIter)->NbNodes() + 1;
} }
// Special case for the VTK_POLYHEDRON:
// itsinput cellArray is of special format.
// [nCellFaces, nFace0Pts, i, j, k, nFace1Pts, i, j, k, ...]
else {
if( const SMDS_VtkVolume* ph = dynamic_cast<const SMDS_VtkVolume*>(*anIter) ) {
int nbFaces = ph->NbFaces();
aCellsSize += (1 + ph->NbFaces());
for( int i = 1; i <= nbFaces; i++ ) {
aCellsSize += ph->NbFaceNodes(i);
}
}
}
}
}
} }
vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] + vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] +
@ -402,8 +418,8 @@ void SMESH_VisualObjDef::buildElemPrs()
for ( int i = 0; i <= 3; i++ ) // iterate through 0d elements, edges, faces and volumes for ( int i = 0; i <= 3; i++ ) // iterate through 0d elements, edges, faces and volumes
{ {
if ( nbEnts[ aTypes[ i ] ] > 0 ) if ( nbEnts[ aTypes[ i ] ] > 0 ) {
{
const SMDSAbs_ElementType& aType = aTypes[ i ]; const SMDSAbs_ElementType& aType = aTypes[ i ];
const TEntityList& aList = anEnts[ aType ]; const TEntityList& aList = anEnts[ aType ];
TEntityList::const_iterator anIter; TEntityList::const_iterator anIter;
@ -425,16 +441,22 @@ void SMESH_VisualObjDef::buildElemPrs()
aConnect.clear(); aConnect.clear();
std::vector<int> aConnectivities; std::vector<int> aConnectivities;
// Convertions connectivities from SMDS to VTK // Convertions connectivities from SMDS to VTK
if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
if ( const SMDS_VtkVolume* ph = if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
dynamic_cast<const SMDS_VtkVolume*> (anElem)) anIdList->Reset();
{ if ( const SMDS_VtkVolume* ph = dynamic_cast<const SMDS_VtkVolume*>(anElem) ) {
aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect); int nbFaces = ph->NbFaces();
anIdList->SetNumberOfIds( aNbNodes ); anIdList->InsertNextId(nbFaces);
for( int i = 1; i <= nbFaces; i++ ) {
anIdList->InsertNextId(ph->NbFaceNodes(i));
for(int j = 1; j <= ph->NbFaceNodes(i); j++) {
const SMDS_MeshNode* n = ph->GetFaceNode(i,j);
if(n) {
anIdList->InsertNextId(mySMDS2VTKNodes[n->GetID()]);
}
}
}
} }
for (int k = 0; k < aNbNodes; k++)
aConnectivities.push_back(k);
} else if (aNbNodes == 4) { } else if (aNbNodes == 4) {
static int anIds[] = {0,2,1,3}; static int anIds[] = {0,2,1,3};
@ -479,6 +501,7 @@ void SMESH_VisualObjDef::buildElemPrs()
else { else {
} }
if (!(anElem->IsPoly() && aNbNodes > 3)) {
if ( aConnect.empty() ) if ( aConnect.empty() )
GetConnect(aNodesIter,aConnect); GetConnect(aNodesIter,aConnect);
@ -486,6 +509,7 @@ void SMESH_VisualObjDef::buildElemPrs()
for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++) for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++)
SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]); SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
} }
}
break; break;
} }
default: default:
@ -495,6 +519,7 @@ void SMESH_VisualObjDef::buildElemPrs()
} }
} }
aConnectivity->InsertNextCell( anIdList ); aConnectivity->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) ); aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) );