From 0d10253e8dc64c0b5b0a1ac97633a9516cdadb08 Mon Sep 17 00:00:00 2001 From: prascle Date: Sat, 4 Dec 2010 15:44:40 +0000 Subject: [PATCH] PR: compactGrid with polyhedrons --- src/SMDS/SMDS_UnstructuredGrid.cxx | 67 +++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index bbe371c8d..259ccdd9b 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -309,26 +309,53 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n this->SetPoints(newPoints); MESSAGE("NumberOfPoints: " << this->GetNumberOfPoints()); } -//#ifdef VTK_HAVE_POLYHEDRON - // TODO compact faces for Polyhedrons - // refaire completement faces et faceLocation - // pour chaque cell, recup oldCellId, oldFacesId, recopie dans newFaces de la faceStream - // en changeant les numeros de noeuds -// vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New(); -// newFaceLocations->Initialize(); -// vtkIdTypeArray *newFaces = vtkIdTypeArray::New(); -// newFaces->Initialize(); -// newFaceLocations->DeepCopy(this->FaceLocations); -// newFaces->DeepCopy(this->Faces); -// this->SetCells(newTypes, newLocations, newConnectivity, newFaceLocations, newFaces); -// newFaceLocations->Delete(); -// newFaces->Delete(); - if (this->FaceLocations) this->FaceLocations->Register(this); - if (this->Faces) this->Faces->Register(this); - this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces); -//#else -// this->SetCells(newTypes, newLocations, newConnectivity); -//#endif + + if (this->FaceLocations) + { + vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New(); + newFaceLocations->Initialize(); + newFaceLocations->Allocate(newTypes->GetSize()); + vtkIdTypeArray *newFaces = vtkIdTypeArray::New(); + newFaces->Initialize(); + newFaces->Allocate(this->Faces->GetSize()); + for (int i = 0; i < oldCellSize; i++) + { + if (newTypes->GetValue(i) == VTK_EMPTY_CELL) + continue; + int newCellId = idCellsOldToNew[i]; + if (newTypes->GetValue(newCellId) == VTK_POLYHEDRON) + { + newFaceLocations->InsertNextValue(newFaces->GetMaxId()+1); + int oldFaceLoc = this->FaceLocations->GetValue(i); + int nCellFaces = this->Faces->GetValue(oldFaceLoc++); + newFaces->InsertNextValue(nCellFaces); + for (int n=0; nFaces->GetValue(oldFaceLoc++); + newFaces->InsertNextValue(nptsInFace); + for (int k=0; kFaces->GetValue(oldFaceLoc++); + newFaces->InsertNextValue(idNodesOldToNew[oldpt]); + } + } + } + else + { + newFaceLocations->InsertNextValue(-1); + } + } + newFaceLocations->Squeeze(); + newFaces->Squeeze(); + newFaceLocations->Register(this); + newFaces->Register(this); + this->SetCells(newTypes, newLocations, newConnectivity, newFaceLocations, newFaces); + newFaceLocations->Delete(); + newFaces->Delete(); + } + else + this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces); + newTypes->Delete(); newLocations->Delete(); newConnectivity->Delete(); -- 2.30.2