{
const TEntityList& aList = anEnts[ aTypes[ i ] ];
TEntityList::const_iterator anIter;
- for ( anIter = aList.begin(); anIter != aList.end(); ++anIter )
- aCellsSize += (*anIter)->NbNodes() + 1;
+ for ( anIter = aList.begin(); anIter != aList.end(); ++anIter ) {
+ 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);
+ }
+ }
+ }
+ }
}
}
-
+
vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] +
nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
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 TEntityList& aList = anEnts[ aType ];
TEntityList::const_iterator anIter;
for ( anIter = aList.begin(); anIter != aList.end(); ++anIter )
{
const SMDS_MeshElement* anElem = *anIter;
-
+
vtkIdType aNbNodes = anElem->NbNodes();
anIdList->SetNumberOfIds( aNbNodes );
-
+
int anId = anElem->GetID();
-
+
mySMDS2VTKElems.insert( TMapOfIds::value_type( anId, iElem ) );
myVTK2SMDSElems.insert( TMapOfIds::value_type( iElem, anId ) );
-
+
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
switch (aType) {
- case SMDSAbs_Volume:{
+ case SMDSAbs_Volume: {
aConnect.clear();
std::vector<int> aConnectivities;
// Convertions connectivities from SMDS to VTK
+
if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
-
- if ( const SMDS_VtkVolume* ph =
- dynamic_cast<const SMDS_VtkVolume*> (anElem))
- {
- aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect);
- anIdList->SetNumberOfIds( aNbNodes );
+ anIdList->Reset();
+ if ( const SMDS_VtkVolume* ph = dynamic_cast<const SMDS_VtkVolume*>(anElem) ) {
+ int nbFaces = ph->NbFaces();
+ 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) {
static int anIds[] = {0,2,1,3};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
-
+
} else if (aNbNodes == 5) {
static int anIds[] = {0,3,2,1,4};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
else {
}
- if ( aConnect.empty() )
- GetConnect(aNodesIter,aConnect);
+ if (!(anElem->IsPoly() && aNbNodes > 3)) {
+ if ( aConnect.empty() )
+ GetConnect(aNodesIter,aConnect);
- if (aConnectivities.size() > 0) {
- for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++)
- SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
- }
- break;
+ if (aConnectivities.size() > 0) {
+ for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++)
+ SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
+ }
+ }
+ break;
}
default:
for( vtkIdType aNodeId = 0; aNodesIter->more(); aNodeId++ ){
}
}
+
aConnectivity->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) );