X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_UnstructuredGrid.cxx;h=bf9df36cffc1c1c80eb5fa3b3fde23e680f301a0;hb=a1920ff31054e2c882bd94d4f3c04abe53980ce0;hp=1f0f799416fe2566e929f07269aa9f914f16352d;hpb=eef0bf5cc772a6bdacf6ae2a4d81fdcb9d3a7fdb;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index 1f0f79941..bf9df36cf 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -125,33 +125,26 @@ SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid() { } -unsigned long SMDS_UnstructuredGrid::GetMTime() +vtkMTimeType SMDS_UnstructuredGrid::GetMTime() { - unsigned long mtime = vtkUnstructuredGrid::GetMTime(); + vtkMTimeType mtime = vtkUnstructuredGrid::GetMTime(); return mtime; } -// OUV_PORTING_VTK6: seems to be useless -/* -void SMDS_UnstructuredGrid::Update() -{ - return vtkUnstructuredGrid::Update(); -} -void SMDS_UnstructuredGrid::UpdateInformation() -{ - return vtkUnstructuredGrid::UpdateInformation(); -} -*/ vtkPoints* SMDS_UnstructuredGrid::GetPoints() { // TODO erreur incomprehensible de la macro vtk GetPoints apparue avec la version paraview de fin aout 2010 return this->Points; } -//#ifdef VTK_HAVE_POLYHEDRON int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts) { - if (type != VTK_POLYHEDRON) + if ( !this->Links ) // don't create Links until they are needed + { + return this->InsertNextCell(type, npts, pts); + } + + if ( type != VTK_POLYHEDRON ) return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts); // --- type = VTK_POLYHEDRON @@ -162,26 +155,25 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p int nbfaces = npts; int i = 0; for (int nf = 0; nf < nbfaces; nf++) + { + int nbnodes = pts[i]; + i++; + for (int k = 0; k < nbnodes; k++) { - int nbnodes = pts[i]; + setOfNodes.insert(pts[i]); i++; - for (int k = 0; k < nbnodes; k++) - { - setOfNodes.insert(pts[i]); - i++; - } } + } set::iterator it = setOfNodes.begin(); for (; it != setOfNodes.end(); ++it) - { - this->Links->ResizeCellList(*it, 1); - this->Links->AddCellReference(cellid, *it); - } + { + this->Links->ResizeCellList(*it, 1); + this->Links->AddCellReference(cellid, *it); + } return cellid; } -//#endif void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh) { @@ -191,20 +183,20 @@ void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh) void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int newNodeSize, std::vector& idCellsOldToNew, int newCellSize) { - //MESSAGE("------------------------- compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1); int alreadyCopied = 0; this->DeleteLinks(); // --- if newNodeSize, create a new compacted vtkPoints - vtkPoints *newPoints = vtkPoints::New(); - newPoints->SetDataType(VTK_DOUBLE); - newPoints->SetNumberOfPoints(newNodeSize); - if (newNodeSize) + if ( newNodeSize ) { // rnv: to fix bug "21125: EDF 1233 SMESH: Degradation of precision in a test case for quadratic conversion" // using double type for storing coordinates of nodes instead float. + vtkPoints *newPoints = vtkPoints::New(); + newPoints->SetDataType(VTK_DOUBLE); + newPoints->SetNumberOfPoints(newNodeSize); + int oldNodeSize = idNodesOldToNew.size(); int i = 0; @@ -220,22 +212,25 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n int endBloc = i; copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc); } - newPoints->Squeeze(); - } - - if (1/*newNodeSize*/) - { this->SetPoints(newPoints); + newPoints->Delete(); } - newPoints->Delete(); - + this->Points->Squeeze(); // --- create new compacted Connectivity, Locations and Types int oldCellSize = this->Types->GetNumberOfTuples(); - if ( oldCellSize == newCellSize ) + if ( !newNodeSize && oldCellSize == newCellSize ) // no holes in elements { + this->Connectivity->Squeeze(); + this->Locations->Squeeze(); + this->Types->Squeeze(); + if ( this->FaceLocations ) + { + this->FaceLocations->Squeeze(); + this->Faces->Squeeze(); + } for ( int i = 0; i < oldCellSize; ++i ) idCellsOldToNew[i] = i; return; @@ -352,11 +347,11 @@ void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints, void *source = this->Points->GetVoidPointer(3 * start); int nbPoints = end - start; if (nbPoints > 0) - { - memcpy(target, source, 3 * sizeof(double) * nbPoints); - for (int j = start; j < end; j++) - idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId - } + { + memcpy(target, source, 3 * sizeof(double) * nbPoints); + for (int j = start; j < end; j++) + idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId + } } void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, @@ -370,24 +365,24 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, int end) { for (int j = start; j < end; j++) + { + newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); + idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId + vtkIdType oldLoc = this->Locations->GetValue(j); + vtkIdType nbpts; + vtkIdType *oldPtsCell = 0; + this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell); + assert(nbpts < NBMAXNODESINCELL); + for (int l = 0; l < nbpts; l++) { - newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); - idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId - vtkIdType oldLoc = this->Locations->GetValue(j); - vtkIdType nbpts; - vtkIdType *oldPtsCell = 0; - this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell); - assert(nbpts < NBMAXNODESINCELL); - for (int l = 0; l < nbpts; l++) - { - int oldval = oldPtsCell[l]; - pointsCell[l] = idNodesOldToNew[oldval]; - } - /*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell); - int newLoc = newConnectivity->GetInsertLocation(nbpts); - newLocations->SetValue(alreadyCopied, newLoc); - alreadyCopied++; + int oldval = oldPtsCell[l]; + pointsCell[l] = idNodesOldToNew[oldval]; } + /*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell); + int newLoc = newConnectivity->GetInsertLocation(nbpts); + newLocations->SetValue(alreadyCopied, newLoc); + alreadyCopied++; + } } int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId)