X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_UnstructuredGrid.cxx;h=b3f743a4fec5ea4242f45c266a4dcb2a397f3a03;hp=d3ea0b6209b38f50eb2cf7eec3763b69caecc765;hb=f3e2b7fea2d36b7dbe2df39f3e08e9c4d9b30e6d;hpb=ae29d465091933df101dfac6ae99d3becf4efde7 diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index d3ea0b620..b3f743a4f 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2010-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,6 +24,7 @@ #include "SMDS_MeshVolume.hxx" #include "utilities.h" +#include "chrono.hxx" #include #include @@ -39,7 +40,6 @@ using namespace std; SMDS_CellLinks* SMDS_CellLinks::New() { - MESSAGE("SMDS_CellLinks::New"); return new SMDS_CellLinks(); } @@ -64,7 +64,6 @@ SMDS_CellLinks::~SMDS_CellLinks() SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New() { - MESSAGE("SMDS_UnstructuredGrid::New"); return new SMDS_UnstructuredGrid(); } @@ -84,27 +83,23 @@ SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid() unsigned long SMDS_UnstructuredGrid::GetMTime() { unsigned long mtime = vtkUnstructuredGrid::GetMTime(); - MESSAGE("vtkUnstructuredGrid::GetMTime: " << mtime); return mtime; } // OUV_PORTING_VTK6: seems to be useless /* void SMDS_UnstructuredGrid::Update() { - MESSAGE("SMDS_UnstructuredGrid::Update"); return vtkUnstructuredGrid::Update(); } void SMDS_UnstructuredGrid::UpdateInformation() { - MESSAGE("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 - //MESSAGE("*********************** SMDS_UnstructuredGrid::GetPoints " << this->Points << " " << vtkUnstructuredGrid::GetPoints()); return this->Points; } @@ -115,7 +110,6 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts); // --- type = VTK_POLYHEDRON - //MESSAGE("InsertNextLinkedCell VTK_POLYHEDRON"); int cellid = this->InsertNextCell(type, npts, pts); set setOfNodes; @@ -128,7 +122,6 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p i++; for (int k = 0; k < nbnodes; k++) { - //MESSAGE(" cell " << cellid << " face " << nf << " node " << pts[i]); setOfNodes.insert(pts[i]); i++; } @@ -137,7 +130,6 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p set::iterator it = setOfNodes.begin(); for (; it != setOfNodes.end(); ++it) { - //MESSAGE("reverse link for node " << *it << " cell " << cellid); this->Links->ResizeCellList(*it, 1); this->Links->AddCellReference(cellid, *it); } @@ -154,7 +146,7 @@ void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh) void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int newNodeSize, std::vector& idCellsOldToNew, int newCellSize) { - MESSAGE("------------------------- SMDS_UnstructuredGrid::compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1); + //MESSAGE("------------------------- compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1); int alreadyCopied = 0; // --- if newNodeSize, create a new compacted vtkPoints @@ -164,7 +156,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n newPoints->SetNumberOfPoints(newNodeSize); if (newNodeSize) { - MESSAGE("-------------- compactGrid, newNodeSize " << 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. int oldNodeSize = idNodesOldToNew.size(); @@ -193,7 +184,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n newConnectivity->Initialize(); int oldCellDataSize = this->Connectivity->GetData()->GetSize(); newConnectivity->Allocate(oldCellDataSize); - MESSAGE("oldCellSize="<< oldCellSize << " oldCellDataSize=" << oldCellDataSize); vtkUnsignedCharArray *newTypes = vtkUnsignedCharArray::New(); newTypes->Initialize(); @@ -229,11 +219,9 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n newConnectivity->Squeeze(); if (1/*newNodeSize*/) - { - MESSAGE("------- newNodeSize, setPoints"); - this->SetPoints(newPoints); - MESSAGE("NumberOfPoints: " << this->GetNumberOfPoints()); - } + { + this->SetPoints(newPoints); + } if (vtkDoubleArray* diameters = vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() )) // Balls @@ -249,48 +237,46 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n } 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++) { - 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 (this->Types->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; nTypes->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); - } + int nptsInFace = this->Faces->GetValue(oldFaceLoc++); + newFaces->InsertNextValue(nptsInFace); + for (int k=0; kFaces->GetValue(oldFaceLoc++); + newFaces->InsertNextValue(idNodesOldToNew[oldpt]); + } } - newFaceLocations->Squeeze(); - newFaces->Squeeze(); - newFaceLocations->Register(this); - newFaces->Register(this); - this->SetCells(newTypes, newLocations, newConnectivity, newFaceLocations, newFaces); - newFaceLocations->Delete(); - newFaces->Delete(); + } + else + { + newFaceLocations->InsertNextValue(-1); + } } + newFaceLocations->Squeeze(); + newFaces->Squeeze(); + this->SetCells(newTypes, newLocations, newConnectivity, newFaceLocations, newFaces); + newFaceLocations->Delete(); + newFaces->Delete(); + } else { this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces); @@ -303,10 +289,12 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n this->BuildLinks(); } -void SMDS_UnstructuredGrid::copyNodes(vtkPoints *newPoints, std::vector& idNodesOldToNew, int& alreadyCopied, - int start, int end) +void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints, + std::vector& idNodesOldToNew, + int& alreadyCopied, + int start, + int end) { - MESSAGE("copyNodes " << alreadyCopied << " " << start << " " << end << " size: " << end - start << " total: " << alreadyCopied + end - start); void *target = newPoints->GetVoidPointer(3 * alreadyCopied); void *source = this->Points->GetVoidPointer(3 * start); int nbPoints = end - start; @@ -328,7 +316,6 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, int start, int end) { - MESSAGE("copyBloc " << alreadyCopied << " " << start << " " << end << " size: " << end - start << " total: " << alreadyCopied + end - start); for (int j = start; j < end; j++) { newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); @@ -338,16 +325,13 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, vtkIdType *oldPtsCell = 0; this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell); assert(nbpts < NBMAXNODESINCELL); - //MESSAGE(j << " " << alreadyCopied << " " << (int)this->Types->GetValue(j) << " " << oldLoc << " " << nbpts ); for (int l = 0; l < nbpts; l++) { int oldval = oldPtsCell[l]; pointsCell[l] = idNodesOldToNew[oldval]; - //MESSAGE(" " << oldval << " " << pointsCell[l]); } /*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell); int newLoc = newConnectivity->GetInsertLocation(nbpts); - //MESSAGE(newcnt << " " << newLoc); newLocations->SetValue(alreadyCopied, newLoc); alreadyCopied++; } @@ -355,12 +339,10 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId) { - if((vtkCellId < 0) || (vtkCellId >= _cellIdToDownId.size())) - { - //MESSAGE("SMDS_UnstructuredGrid::CellIdToDownId structure not up to date: vtkCellId=" - // << vtkCellId << " max="<< _cellIdToDownId.size()); - return -1; - } + if ((vtkCellId < 0) || (vtkCellId >= (int)_cellIdToDownId.size())) + { + return -1; + } return _cellIdToDownId[vtkCellId]; } @@ -372,12 +354,12 @@ void SMDS_UnstructuredGrid::setCellIdToDownId(int vtkCellId, int downId) void SMDS_UnstructuredGrid::CleanDownwardConnectivity() { - for (int i = 0; i < _downArray.size(); i++) - { - if (_downArray[i]) - delete _downArray[i]; - _downArray[i] = 0; - } + for (size_t i = 0; i < _downArray.size(); i++) + { + if (_downArray[i]) + delete _downArray[i]; + _downArray[i] = 0; + } _cellIdToDownId.clear(); } @@ -402,6 +384,7 @@ void SMDS_UnstructuredGrid::BuildDownwardConnectivity(bool withEdges) _downArray[VTK_QUADRATIC_EDGE] = new SMDS_DownQuadEdge(this); _downArray[VTK_TRIANGLE] = new SMDS_DownTriangle(this); _downArray[VTK_QUADRATIC_TRIANGLE] = new SMDS_DownQuadTriangle(this); + _downArray[VTK_BIQUADRATIC_TRIANGLE] = new SMDS_DownQuadTriangle(this); _downArray[VTK_QUAD] = new SMDS_DownQuadrangle(this); _downArray[VTK_QUADRATIC_QUAD] = new SMDS_DownQuadQuadrangle(this); _downArray[VTK_BIQUADRATIC_QUAD] = new SMDS_DownQuadQuadrangle(this); @@ -442,6 +425,7 @@ void SMDS_UnstructuredGrid::BuildDownwardConnectivity(bool withEdges) GuessSize[VTK_QUADRATIC_EDGE] = nbQuadEdgeGuess; GuessSize[VTK_TRIANGLE] = nbLinTriaGuess; GuessSize[VTK_QUADRATIC_TRIANGLE] = nbQuadTriaGuess; + GuessSize[VTK_BIQUADRATIC_TRIANGLE] = nbQuadTriaGuess; GuessSize[VTK_QUAD] = nbLinQuadGuess; GuessSize[VTK_QUADRATIC_QUAD] = nbQuadQuadGuess; GuessSize[VTK_BIQUADRATIC_QUAD] = nbQuadQuadGuess; @@ -460,6 +444,7 @@ void SMDS_UnstructuredGrid::BuildDownwardConnectivity(bool withEdges) _downArray[VTK_QUADRATIC_EDGE] ->allocate(nbQuadEdgeGuess); _downArray[VTK_TRIANGLE] ->allocate(nbLinTriaGuess); _downArray[VTK_QUADRATIC_TRIANGLE] ->allocate(nbQuadTriaGuess); + _downArray[VTK_BIQUADRATIC_TRIANGLE] ->allocate(nbQuadTriaGuess); _downArray[VTK_QUAD] ->allocate(nbLinQuadGuess); _downArray[VTK_QUADRATIC_QUAD] ->allocate(nbQuadQuadGuess); _downArray[VTK_BIQUADRATIC_QUAD] ->allocate(nbQuadQuadGuess); @@ -1014,12 +999,13 @@ void SMDS_UnstructuredGrid::BuildLinks() * @param nodeDomains: map(original id --> map(domain --> duplicated node id)) * @return ok if success. */ -SMDS_MeshCell* SMDS_UnstructuredGrid::extrudeVolumeFromFace(int vtkVolId, - int domain1, - int domain2, - std::set& originalNodes, - std::map >& nodeDomains, - std::map >& nodeQuadDomains) +SMDS_MeshCell* +SMDS_UnstructuredGrid::extrudeVolumeFromFace(int vtkVolId, + int domain1, + int domain2, + std::set& originalNodes, + std::map >& nodeDomains, + std::map >& nodeQuadDomains) { //MESSAGE("extrudeVolumeFromFace " << vtkVolId); vector orderedOriginals; @@ -1035,16 +1021,16 @@ SMDS_MeshCell* SMDS_UnstructuredGrid::extrudeVolumeFromFace(int vtkVolId, bool isQuadratic = false; switch (orderedOriginals.size()) { - case 3: - if (dim == 2) - isQuadratic = true; - break; - case 6: - case 8: + case 3: + if (dim == 2) isQuadratic = true; - break; - default: - isQuadratic = false; + break; + case 6: + case 8: + isQuadratic = true; + break; + default: + isQuadratic = false; break; } @@ -1080,8 +1066,11 @@ SMDS_MeshCell* SMDS_UnstructuredGrid::extrudeVolumeFromFace(int vtkVolId, double *coords = this->GetPoint(oldId); SMDS_MeshNode *newNode = _mesh->AddNode(coords[0], coords[1], coords[2]); newId = newNode->getVtkId(); - std::map emptyMap; - nodeQuadDomains[oldId] = emptyMap; + if (! nodeQuadDomains.count(oldId)) + { + std::map emptyMap; + nodeQuadDomains[oldId] = emptyMap; + } nodeQuadDomains[oldId][dom1_2] = newId; } orderedNodes.push_back(newId);