From: prascle Date: Mon, 29 Nov 2010 12:51:19 +0000 (+0000) Subject: PR: SMDS memory improvement, VTK version from Paraview 3.9 X-Git-Tag: V6_2_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2610ab6124fc401da0f0ca51ca03a69d460588ec;p=modules%2Fgui.git PR: SMDS memory improvement, VTK version from Paraview 3.9 --- diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index 232e9ef83..bae773e73 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -162,7 +162,7 @@ libSVTK_la_LDFLAGS = \ libSVTK_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../ViewerTools/libViewerTools.la \ ../OBJECT/libSalomeObject.la ../Prs/libSalomePrs.la \ ../VTKViewer/libVTKViewer.la ../OpenGLUtils/libOpenGLUtils.la \ - -lSALOMELocalTrace + -lSALOMELocalTrace -lOpUtil # Executable bin_PROGRAMS = SVTK diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index 66d71c866..e513649b5 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -32,8 +32,12 @@ #include #include +#include #include +#include "Utils_SALOME_Exception.hxx" +#include "utilities.h" + using namespace std; @@ -125,7 +129,18 @@ SVTK_Actor for(int ind = 1; ind <= aNbOfParts; ind++){ int aPartId = theMapIndex( ind ); if(vtkCell* aCell = theMapActor->GetElemCell(aPartId)) - myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + { + if (aCell->GetCellType() != VTK_POLYHEDRON) + myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + else + { + vtkPolyhedron *polyhedron = dynamic_cast(aCell); + if (!polyhedron) + throw SALOME_Exception(LOCALIZED ("not a polyhedron")); + vtkIdType *pts = polyhedron->GetFaces(); + myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),pts[0], pts+1); + } + } } UnShrink(); diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index d3d61e2e1..507c39992 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -96,7 +96,7 @@ void MessageOutput( QtMsgType type, const char* msg ) switch ( type ) { case QtDebugMsg: - MESSAGE( "Debug: " << msg ); + //MESSAGE( "Debug: " << msg ); break; case QtWarningMsg: MESSAGE( "Warning: " << msg ); diff --git a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx index d2ee28678..2ce0a7165 100755 --- a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx +++ b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx @@ -37,6 +37,8 @@ #include #include +#include "utilities.h" + using namespace std; #if defined __GNUC__ @@ -66,6 +68,7 @@ void VTKViewer_ExtractUnstructuredGrid::RegisterCell(vtkIdType theCellId){ void VTKViewer_ExtractUnstructuredGrid::RegisterCellsWithType(vtkIdType theCellType){ // if(0 && MYDEBUG) MESSAGE("RegisterCellsWithType - theCellType = "<SetId(i,aPntIds->GetId(i)); } - theConnectivity->InsertNextCell(theIdList); - vtkIdType aCellType = aCell->GetCellType(); + if (aCellType != VTK_POLYHEDRON) + { + theConnectivity->InsertNextCell(theIdList); + if (theFaceLocations) + theFaceLocations->InsertNextValue(-1); + } + else + { + //MESSAGE("InsertCell type VTK_POLYHEDRON " << theStoreMapping); + if (!theFaces) + { + theFaces = vtkIdTypeArray::New(); + theFaces->Allocate(theCellTypesArray->GetSize()); + theFaceLocations = vtkIdTypeArray::New(); + theFaceLocations->Allocate(theCellTypesArray->GetSize()); + // FaceLocations must be padded until the current position + for (vtkIdType i = 0; i <= theCellTypesArray->GetMaxId(); i++) + { + theFaceLocations->InsertNextValue(-1); + } + } + // insert face location + theFaceLocations->InsertNextValue(theFaces->GetMaxId() + 1); + + // insert cell connectivity and faces stream + vtkIdType nfaces; + vtkIdType* face; + vtkIdType realnpts; + theInput->GetFaceStream(theCellId, nfaces, face); + vtkUnstructuredGrid::DecomposeAPolyhedronCell( + nfaces, face, realnpts, theConnectivity, theFaces); + } + theCellTypesArray->InsertNextValue(aCellType); if(theStoreMapping){ theOut2InId.push_back(theCellId); @@ -122,7 +158,7 @@ inline void InsertCell(vtkUnstructuredGrid *theInput, inline void InsertPointCell(vtkCellArray *theConnectivity, vtkUnsignedCharArray* theCellTypesArray, - vtkIdType theCellId, + vtkIdType theCellId, vtkIdList *theIdList, bool theStoreMapping, vtkIdType theOutId, @@ -190,19 +226,23 @@ void VTKViewer_ExtractUnstructuredGrid::Execute() vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); aCellTypesArray->SetNumberOfComponents(1); aCellTypesArray->Allocate(aNbElems*aCellTypesArray->GetNumberOfComponents()); + + vtkIdTypeArray *newFaces = 0; + vtkIdTypeArray *newFaceLocations = 0; + if(!myCellIds.empty() && myCellTypes.empty()){ if(myStoreMapping) myOut2InId.reserve(myCellIds.size()); if(myChangeMode == eAdding){ for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){ if(myCellIds.find(aCellId) != myCellIds.end()){ - InsertCell(anInput,aConnectivity,aCellTypesArray,aCellId,anIdList, + InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList, myStoreMapping,anOutId,myOut2InId,myIn2OutId); } } }else{ for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){ if(myCellIds.find(aCellId) == myCellIds.end()){ - InsertCell(anInput,aConnectivity,aCellTypesArray,aCellId,anIdList, + InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList, myStoreMapping,anOutId,myOut2InId,myIn2OutId); } } @@ -212,7 +252,7 @@ void VTKViewer_ExtractUnstructuredGrid::Execute() for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){ vtkIdType aType = anInput->GetCellType(aCellId); if(myCellTypes.find(aType) != myCellTypes.end()){ - InsertCell(anInput,aConnectivity,aCellTypesArray,aCellId,anIdList, + InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList, myStoreMapping,anOutId,myOut2InId,myIn2OutId); } } @@ -220,7 +260,7 @@ void VTKViewer_ExtractUnstructuredGrid::Execute() for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){ vtkIdType aType = anInput->GetCellType(aCellId); if(myCellTypes.find(aType) == myCellTypes.end()){ - InsertCell(anInput,aConnectivity,aCellTypesArray,aCellId,anIdList, + InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList, myStoreMapping,anOutId,myOut2InId,myIn2OutId); } } @@ -231,7 +271,7 @@ void VTKViewer_ExtractUnstructuredGrid::Execute() vtkIdType aType = anInput->GetCellType(aCellId); if(myCellTypes.find(aType) != myCellTypes.end()){ if(myCellIds.find(aCellId) != myCellIds.end()){ - InsertCell(anInput,aConnectivity,aCellTypesArray,aCellId,anIdList, + InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList, myStoreMapping,anOutId,myOut2InId,myIn2OutId); } } @@ -241,7 +281,7 @@ void VTKViewer_ExtractUnstructuredGrid::Execute() vtkIdType aType = anInput->GetCellType(aCellId); if(myCellTypes.find(aType) == myCellTypes.end()){ if(myCellIds.find(aCellId) == myCellIds.end()){ - InsertCell(anInput,aConnectivity,aCellTypesArray,aCellId,anIdList, + InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList, myStoreMapping,anOutId,myOut2InId,myIn2OutId); } } @@ -256,7 +296,7 @@ void VTKViewer_ExtractUnstructuredGrid::Execute() for(vtkIdType i = 0, *pts, npts; aConnectivity->GetNextCell(npts,pts); i++){ aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); } - anOutput->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + anOutput->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity,newFaceLocations,newFaces); anOutput->SetPoints(anInput->GetPoints()); aCellLocationsArray->Delete(); } @@ -348,7 +388,7 @@ void VTKViewer_ExtractUnstructuredGrid::Execute() for(vtkIdType i = 0, *pts, npts; aConnectivity->GetNextCell(npts,pts); i++){ aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); } - anOutput->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + anOutput->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity,0, 0); anOutput->SetPoints(anInput->GetPoints()); aCellLocationsArray->Delete(); } diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.cxx b/src/VTKViewer/VTKViewer_GeometryFilter.cxx index ae44393d4..0052072e9 100755 --- a/src/VTKViewer/VTKViewer_GeometryFilter.cxx +++ b/src/VTKViewer/VTKViewer_GeometryFilter.cxx @@ -55,6 +55,8 @@ #include #include +#include "utilities.h" + #if defined __GNUC__ #if __GNUC__ == 2 #define __GNUC_2__ @@ -480,6 +482,53 @@ VTKViewer_GeometryFilter } break; } + + case VTK_POLYHEDRON: + { + //MESSAGE("VTK_POLYHEDRON geometry filter"); + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + int idp = 0; + input->GetFaceStream(cellId, nFaces, ptIds); + for (faceId = 0; faceId < nFaces; faceId++) + { + faceIds->Reset(); + numFacePts = ptIds[idp]; + //MESSAGE("numFacePts="<< numFacePts); + int pt0 = ++idp; + for (int i = 0; i < numFacePts; i++) + { + //MESSAGE("ptIds[" << idp + i << "]=" << ptIds[idp + i]); + faceIds->InsertNextId(ptIds[idp + i]); + } + idp += numFacePts; + switch (numFacePts) + { + case 3: + aCellType = VTK_TRIANGLE; + break; + case 4: + aCellType = VTK_QUAD; + break; + default: + aCellType = VTK_POLYGON; + break; + } + // TODO understand and fix display of several polyhedrons + input->GetCellNeighbors(cellId, faceIds, cellIds); + if (cellIds->GetNumberOfIds() <= 0 || myShowInside + || (!allVisible && !cellVis[cellIds->GetId(0)])) + { + for (i = 0; i < numFacePts; i++) + aNewPts[i] = ptIds[pt0 + i]; + newCellId = output->InsertNextCell(aCellType, numFacePts, aNewPts); + if (myStoreMapping) + myVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd, cellId, newCellId); + } + } + break; + } //Quadratic cells case VTK_QUADRATIC_EDGE: case VTK_QUADRATIC_TRIANGLE: