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,8 +368,24 @@ 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 ) {
aCellsSize += (*anIter)->NbNodes() + 1; if((*anIter)->GetEntityType() != SMDSEntity_Polyhedra &&
(*anIter)->GetEntityType() != SMDSEntity_Quad_Polyhedra) {
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);
}
}
}
}
} }
} }
@ -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;
@ -421,20 +437,26 @@ void SMESH_VisualObjDef::buildElemPrs()
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
switch (aType) { switch (aType) {
case SMDSAbs_Volume:{ case SMDSAbs_Volume: {
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,14 +501,16 @@ void SMESH_VisualObjDef::buildElemPrs()
else { else {
} }
if ( aConnect.empty() ) if (!(anElem->IsPoly() && aNbNodes > 3)) {
GetConnect(aNodesIter,aConnect); if ( aConnect.empty() )
GetConnect(aNodesIter,aConnect);
if (aConnectivities.size() > 0) { if (aConnectivities.size() > 0) {
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:
for( vtkIdType aNodeId = 0; aNodesIter->more(); aNodeId++ ){ for( vtkIdType aNodeId = 0; aNodesIter->more(); aNodeId++ ){
@ -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 ) );