X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_Object.cxx;h=cfaa700cbaf98718cde07ae36f05dce4cc4fdad2;hp=5e35f14f282dbb52ea49749b4e7da427b00bae41;hb=493747e8ea338a2d88204a5f12ba924d72ecbb5b;hpb=ef8432633e57037dcd8df55503e62b08069c9190 diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 5e35f14f2..cfaa700cb 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -368,11 +368,27 @@ void SMESH_VisualObjDef::buildElemPrs() { 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(*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 ]; @@ -402,44 +418,50 @@ void SMESH_VisualObjDef::buildElemPrs() 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 aConnectivities; // Convertions connectivities from SMDS to VTK + if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE - - if ( const SMDS_VtkVolume* ph = - dynamic_cast (anElem)) - { - aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect); - anIdList->SetNumberOfIds( aNbNodes ); + anIdList->Reset(); + if ( const SMDS_VtkVolume* ph = dynamic_cast(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]); @@ -479,14 +501,16 @@ void SMESH_VisualObjDef::buildElemPrs() 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++ ){ @@ -495,6 +519,7 @@ void SMESH_VisualObjDef::buildElemPrs() } } + aConnectivity->InsertNextCell( anIdList ); aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) ); @@ -570,8 +595,13 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid() { - //MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid); - return myGrid; + if ( !myLocalGrid && !GetMesh()->isCompacted() ) + { + GetMesh()->compactMesh(); + vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); + myGrid->ShallowCopy(theGrid); + } + return myGrid; }