From 55c706d2412ebbaddb5b9a195a53cf5d298ca269 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 30 Nov 2015 18:04:17 +0100 Subject: [PATCH 01/29] Tune FlatTreeView sizing When running ParaView on HiDPI screens, where the IndentWidth may be smaller than the font height, lines in the Pipeline browser may get squashed together. Fix this by defaulting to a preferredHeight for FlatTreeView items which is the maximum between the font height and the IndentWidth, and only adjusting upwards for items with a larger font. --- Qt/Widgets/pqFlatTreeView.cxx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Qt/Widgets/pqFlatTreeView.cxx b/Qt/Widgets/pqFlatTreeView.cxx index b5c196fff7e..2de040f7602 100644 --- a/Qt/Widgets/pqFlatTreeView.cxx +++ b/Qt/Widgets/pqFlatTreeView.cxx @@ -3230,7 +3230,8 @@ void pqFlatTreeView::layoutItem(pqFlatTreeViewItem *item, int &point, } int preferredWidth = 0; - int preferredHeight = 0; + // default to the maximum of the height by the font metrics, and the indent width + int preferredHeight = std::max(fm.height(), this->IndentWidth); for(i = 0; i < item->Cells.size(); i++) { if(item->Cells[i]->Width == 0 || this->FontChanged) @@ -3251,10 +3252,6 @@ void pqFlatTreeView::layoutItem(pqFlatTreeViewItem *item, int &point, else { item->Cells[i]->Width = this->getDataWidth(index, fm); - if(fm.height() > preferredHeight) - { - preferredHeight = fm.height(); - } } } @@ -3267,13 +3264,9 @@ void pqFlatTreeView::layoutItem(pqFlatTreeViewItem *item, int &point, } } - // Save the preferred height for the item. If no font hints were - // found, use the default height. + + // Save the preferred height for the item. item->Height = preferredHeight; - if(item->Height < this->IndentWidth) - { - item->Height = this->IndentWidth; - } // Add padding to the height for the vertical connection. Increment // the starting point for the next item. From a915c5ed8b8e62b6c4d7af9a39fa6e61cd04df74 Mon Sep 17 00:00:00 2001 From: Menno Deij - van Rijswijk Date: Mon, 22 Feb 2016 13:55:24 +0100 Subject: [PATCH 02/29] Added support for reading NFACE_n and NGON_n CGNS files --- .../CGNSReader/vtkCGNSReader.cxx | 206 +++++++++++++++++- .../CGNSReader/vtkCGNSReaderInternal.cxx | 1 + 2 files changed, 199 insertions(+), 8 deletions(-) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx index 57f371ae120..8fbd1a9aafd 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx +++ b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx @@ -1545,6 +1545,12 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, return 1; } + // Set up ugrid - we need to refer to it if we're building an NFACE_n or NGON_n grid + // Create an unstructured grid to contain the points. + vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New(); + ugrid->SetPoints(points); + + bool buildGrid(true); // Iterate over core sections. for (std::vector::iterator iter = coreSec.begin(); iter != coreSec.end(); ++iter) @@ -1563,7 +1569,7 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, double cgioSectionId; cgioSectionId = elemIdList[sec]; - if (elemType != CGNS_ENUMV(MIXED)) + if (elemType != CGNS_ENUMV(MIXED) && elemType != CGNS_ENUMV(NFACE_n) && elemType != CGNS_ENUMV(NGON_n)) // MDvR: test for NFACE_n, NGON_n too { // All cells are of the same type. int numPointsPerCell = 0; @@ -1700,10 +1706,198 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, CGNSRead::CGNS2VTKorder(elementSize, &cellsTypes[start-1], localElements); } } + else if ( elemType == CGNS_ENUMV(NFACE_n)) + { + buildGrid = false; + + // the faces are in NGON_n format, and are in another section - or multiple sections! + std::vector faceElements; + vtkIdType numFaces(0); + cgsize_t fDataSize(0); + for(size_t osec = 0, n = 0; osec < sectionInfoList.size(); ++osec) + { + // the documentation specifies that the faces of NFACE_n are always in NGON_n + // format, so look for another section that has that element type. + if (osec == sec) continue; // skip self + if (sectionInfoList[osec].elemType == NGON_n) + { + fDataSize = sectionInfoList[osec].eDataSize; + // resize to fit the next batch of element connectivity values + faceElements.resize(faceElements.size() + fDataSize); + + numFaces = 1 + sectionInfoList[osec].range[1] - sectionInfoList[osec].range[0]; + + cgsize_t memDim[2]; + + srcStart[0] = 1 ; + srcEnd[0] = fDataSize; + srcStride[0] = 1; + + memStart[0] = 1; + memStart[1] = 1; + memEnd[0] = fDataSize; + memEnd[1] = 1; + memStride[0] = 1; + memStride[1] = 1; + memDim[0] = fDataSize; + memDim[1] = 1; + + if(0 != CGNSRead::get_section_connectivity(this->cgioNum, elemIdList[osec], 1, + srcStart, srcEnd, srcStride, + memStart, memEnd, memStride, + memDim, &faceElements[n])) + { + vtkErrorMacro(<< "FAILED to read NGON_n cells\n"); + return 1; + } + + n += fDataSize; // points to next index + } + } + + vtkNew cellArray; + cgsize_t eDataSize(0); + eDataSize = sectionInfoList[sec].eDataSize; + + cellArray->SetNumberOfValues(eDataSize); + vtkIdType* cellElements = cellArray->GetPointer(0); + cgsize_t memDim[2]; + + srcStart[0] = 1 ; + srcEnd[0] = eDataSize; + srcStride[0] = 1; + + memStart[0] = 1; + memStart[1] = 1; + memEnd[0] = eDataSize; + memEnd[1] = 1; + memStride[0] = 1; + memStride[1] = 1; + memDim[0] = eDataSize; + memDim[1] = 1; + + if (0 != CGNSRead::get_section_connectivity(this->cgioNum, cgioSectionId, 1, + srcStart, srcEnd, srcStride, + memStart, memEnd, memStride, + memDim, cellElements)) + { + vtkErrorMacro(<< "FAILED to read NFACE_n cells\n"); + return 1; + } + + // ok, now we have the face-to-node connectivity array and the cell-to-face connectivity array. + // VTK, however, has no concept of faces, and uses cell-to-node connectivity, so the intermediate faces + // need to be taken out of the description. + + std::vector faceNodeLookupTable(numFaces); + + vtkIdType p(0); + for(vtkIdType nf = 0; nf < numFaces; ++nf) + { + faceNodeLookupTable[nf] = p; + p += 1 + faceElements[p]; + } + + p = 0; + for(vtkIdType nc = 0; nc < numCoreCells; ++nc) + { + int numCellFaces = cellElements[p]; + + vtkNew faces; + faces->InsertNextId(numCellFaces); + + for(vtkIdType nf = 0; nf < numCellFaces; ++nf) + { + vtkIdType faceId = cellElements[p + nf + 1]; + bool mustReverse = faceId > 0; + faceId = abs(faceId); + + // the following is needed because when the NGON_n face data preceeds the + // NFACE_n cell data, the indices are continuous, so a "global-to-local" mapping must be done. + faceId -= sectionInfoList[sec].range[1]; + faceId -= 1; // CGNS uses FORTRAN ID style, starting at 1 + + vtkIdType q = faceNodeLookupTable[faceId]; + vtkIdType numNodes = faceElements[q]; + faces->InsertNextId(numNodes); + if (mustReverse) + { + for(vtkIdType nn = numNodes - 1; nn >= 0; --nn) + { + vtkIdType nodeID = faceElements[q + nn + 1] - 1; // AGAIN subtract 1 from node ID + faces->InsertNextId(nodeID); + } + } + else + { + for (vtkIdType nn = 0; nn < numNodes; ++nn) + { + vtkIdType nodeID = faceElements[q + nn + 1] - 1; // AGAIN subtract 1 from node ID + faces->InsertNextId(nodeID); + } + } + } + ugrid->InsertNextCell(VTK_POLYHEDRON, faces.GetPointer()); + p += 1 + numCellFaces; //p now points to the index of the next cell + } + } + else if (elemType == CGNS_ENUMV(NGON_n)) + { + buildGrid = false; + vtkNew ngonFaceArray; + cgsize_t eDataSize = 0; + eDataSize = sectionInfoList[sec].eDataSize; + + ngonFaceArray->SetNumberOfValues(eDataSize); + vtkIdType* localElements = ngonFaceArray->GetPointer(0); + cgsize_t memDim[2]; + + srcStart[0] = 1 ; + srcEnd[0] = eDataSize; + srcStride[0] = 1; + + memStart[0] = 1; + memStart[1] = 1; + memEnd[0] = eDataSize; + memEnd[1] = 1; + memStride[0] = 1; + memStride[1] = 1; + memDim[0] = eDataSize; + memDim[1] = 1; + + if (0 != CGNSRead::get_section_connectivity(this->cgioNum, cgioSectionId, 1, + srcStart, srcEnd, srcStride, + memStart, memEnd, memStride, + memDim, localElements)) + { + vtkErrorMacro(<< "FAILED to read NGON_n cells\n"); + return 1; + } + + vtkIdType numFaces = 1+ sectionInfoList[sec].range[1] - sectionInfoList[sec].range[0]; + int p(0); + for(vtkIdType nf = 0; nf < numFaces ; ++nf) + { + vtkIdType numNodes = localElements[p]; + vtkNew nodes; + //nodes->InsertNextId(numNodes); + for (vtkIdType nn = 0; nn < numNodes; ++nn) + { + vtkIdType nodeId = localElements[p+nn+1]; + nodeId -= 1; // FORTRAN to C-style indexing + nodes->InsertNextId(nodeId); + } + ugrid->InsertNextCell(VTK_POLYGON, nodes.GetPointer()); + p += 1 + numNodes; + } + } + cgio_release_id(this->cgioNum, cgioSectionId); } + + if (buildGrid) + cells->SetCells(numCoreCells , cellLocations.GetPointer()); - cells->SetCells(numCoreCells , cellLocations.GetPointer()); // bool requiredPatch = (this->LoadBndPatch != 0); // SetUp zone Blocks @@ -1718,12 +1912,8 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, } mzone->GetMetaData((unsigned int) 0)->Set(vtkCompositeDataSet::NAME(), "Internal"); - // Set up ugrid - // Create an unstructured grid to contain the points. - vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New(); - ugrid->SetPoints(points); - - ugrid->SetCells(cellsTypes, cells.GetPointer()); + if(buildGrid) + ugrid->SetCells(cellsTypes, cells.GetPointer()); delete [] cellsTypes; diff --git a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx index 73dc13bf00f..4987afefac5 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx +++ b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReaderInternal.cxx @@ -157,6 +157,7 @@ int get_section_connectivity(const int cgioNum, const double cgioSectionId, char message[81]; cgio_error_message(message); std::cerr << "cgio_read_data :" << message; + return 1; } } else From 90f5fc5b82d6f69d1933a2e504d0bb89f6657992 Mon Sep 17 00:00:00 2001 From: Menno Deij - van Rijswijk Date: Tue, 1 Mar 2016 10:57:58 +0100 Subject: [PATCH 03/29] working on testing --- .../CGNSReader/Testing/Cxx/CMakeLists.txt | 29 +++++++ .../CGNSReader/Testing/Cxx/TestCGNSReader.cxx | 82 ++++++++++++++++++ .../Testing/Cxx/TestReadCGNSSolution.cxx | 83 +++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt create mode 100644 ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx create mode 100644 ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt new file mode 100644 index 00000000000..334317a660c --- /dev/null +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,29 @@ +INCLUDE_DIRECTORIES( + ${ParaView_SOURCE_DIR}/VTK/Common/Testing/Cxx/ + ${ParaView_SOURCE_DIR}/VTK/Testing/Core/ + ${ParaView_SOURCE_DIR}/VTK/Rendering/Testing/Cxx/ + ) + +set(vtk-module VTKExtensions) +set(${vtk-module}_TEST_LABELS PARAVIEW) + +ExternalData_add_test(ParaViewData + NAME TestCGNSReader + COMMAND vtkPVVTKExtensionsCGNSReaderTests TestCGNSReader + DATA{../Data/Example_mixed.cgns} + DATA{../Data/Example_nface_n.cgns} + ) + +ExternalData_add_test(ParaViewData + NAME TestReadCGNSSolution + COMMAND vtkPVVTKExtensionsCGNSReaderTests TestReadCGNSSolution + DATA{../Data/channelBump_solution.cgns} + ) + +vtk_add_test_cxx(${vtk-modules}vtkPVVTKExtensionsCGNSReaderTests tests + NO_VALID NO_OUTPUT + TestCGNSReader.cxx + TestReadCGNSSolution.cxx + ) + +vtk_test_cxx_executable(${vtk-modules}vtkPVVTKExtensionsCGNSReaderTests tests) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx new file mode 100644 index 00000000000..1a616bea76b --- /dev/null +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx @@ -0,0 +1,82 @@ +/*========================================================================= + + Program: ParaView + Module: TestReadCGNSFiles.cxx + + Copyright (c) Menno Deij - van Rijswijk, MARIN, The Netherlands + All rights reserved. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ +#include "vtkCGNSReader.h" +#include "vtkNew.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkUnstructuredGrid.h" +#include "vtkCell.h" +#include "vtkTestUtilities.h" + + +#define TEST_SUCCESS 0 +#define TEST_FAILED 1 + +#define vtk_assert(x)\ + if (! (x) ) { cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; return TEST_FAILED;} + +int TestOutput(vtkMultiBlockDataSet* mb, int nCells, VTKCellType type) +{ + int nBlocks = mb->GetNumberOfBlocks(); + vtk_assert(nBlocks > 0); + for(unsigned int i = 0; i < nBlocks; ++i) + { + vtkMultiBlockDataSet* mb2 = vtkMultiBlockDataSet::SafeDownCast(mb->GetBlock(i)); + for(unsigned int j = 0; j < mb2->GetNumberOfBlocks(); ++j) + { + vtkUnstructuredGrid* ug = vtkUnstructuredGrid::SafeDownCast(mb2->GetBlock(j)); + int nc = ug->GetNumberOfCells(); + vtk_assert(nc == nCells); + for(vtkIdType k = 0; k < ug->GetNumberOfCells(); ++k) + { + vtkCell* cell = ug->GetCell(k); + vtk_assert(cell->GetCellType() == type); + } + } + } + return 0; +} + +int TestCGNSReader(int argc, char* argv[]) +{ + char* mixed = + vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/CGNSReader/Example_mixed.cgns"); + char* nfacen = + vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/CGNSReader/Example_nface_n.cgns"); + + vtkNew mixedReader; + + mixedReader->SetFileName(mixed); + mixedReader->Update(); + + vtkMultiBlockDataSet* mb = mixedReader->GetOutput(); + + if (0 != TestOutput(mb, 7, VTK_HEXAHEDRON)) + return 1; + + vtkNew nfacenReader; + nfacenReader->SetFileName(nfacen); + nfacenReader->Update(); + mb = nfacenReader->GetOutput(); + + if (0 != TestOutput(mb, 7, VTK_POLYHEDRON)) + return 1; + + + delete [] mixed; + delete [] nfacen; + + + cout << __FILE__ << " tests passed." << endl; + return 0; +} diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx new file mode 100644 index 00000000000..f76e15bdaeb --- /dev/null +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx @@ -0,0 +1,83 @@ +/*========================================================================= + + Program: ParaView + Module: TestReadCGNSFiles.cxx + + Copyright (c) Menno Deij - van Rijswijk, MARIN, The Netherlands + All rights reserved. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ +#include "vtkCGNSReader.h" +#include "vtkNew.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkUnstructuredGrid.h" +#include "vtkCell.h" +#include "vtkInformation.h" +#include "vtkTestUtilities.h" +#include "vtkCellData.h" + +#define TEST_SUCCESS 0 +#define TEST_FAILED 1 + +#define vtk_assert(x)\ + if (! (x) ) { cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; return TEST_FAILED;} + +int TestOutput(vtkMultiBlockDataSet* mb, int nCells, VTKCellType type); + +int TestOutputData(vtkMultiBlockDataSet* mb, int nCells, int nArrays) +{ + int nBlocks = mb->GetNumberOfBlocks(); + vtk_assert(nBlocks > 0); + for(unsigned int i = 0; i < nBlocks; ++i) + { + vtkMultiBlockDataSet* mb2 = vtkMultiBlockDataSet::SafeDownCast(mb->GetBlock(i)); + for(unsigned int j = 0; j < mb2->GetNumberOfBlocks(); ++j) + { + vtkUnstructuredGrid* ug = vtkUnstructuredGrid::SafeDownCast(mb2->GetBlock(j)); + vtkCellData* cd = ug->GetCellData(); + int nArr = cd->GetNumberOfArrays(); + if (nArr != nArrays) return 1; + for (int k = 0; k < nArr; ++k) + { + vtkDataArray* arr = cd->GetArray(k); + vtkIdType nTpl = arr->GetNumberOfTuples(); + vtk_assert(nTpl == nCells); + } + } + } + return 0; +} + +int TestReadCGNSSolution(int argc, char* argv[]) +{ + char* solution = + vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/CGNSReader/channelBump_solution.cgns"); + + vtkNew reader; + vtkInformation* inf = reader->GetInformation(); + + reader->SetFileName(solution); + reader->Update(); + + reader->EnableAllCellArrays(); + reader->EnableAllPointArrays(); + + reader->Update(); + + vtkMultiBlockDataSet* mb = reader->GetOutput(); + + if (0 != TestOutput(mb, 19742, VTK_POLYHEDRON)) + return 1; + + if (0 != TestOutputData(mb, 19742, 20)) + return 1; + + delete [] solution; + + cout << __FILE__ << " tests passed." << endl; + return 0; +} From 17909337c85d7a76da787b563405bdaf378c7784 Mon Sep 17 00:00:00 2001 From: Menno Deij - van Rijswijk Date: Wed, 2 Mar 2016 11:51:40 +0100 Subject: [PATCH 04/29] added tests --- .../CGNSReader/Testing/Cxx/CMakeLists.txt | 26 +++++++++---------- .../CGNSReader/Testing/Cxx/TestCGNSReader.cxx | 16 ++++++------ .../Testing/Cxx/TestReadCGNSSolution.cxx | 6 ++--- .../Testing/Data/Example_mixed.cgns.md5 | 1 + .../Testing/Data/Example_nface_n.cgns.md5 | 1 + .../Data/channelBump_solution.cgns.md5 | 1 + 6 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_mixed.cgns.md5 create mode 100644 ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_nface_n.cgns.md5 create mode 100644 ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/channelBump_solution.cgns.md5 diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt index 334317a660c..9dd98fce289 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt @@ -4,26 +4,26 @@ INCLUDE_DIRECTORIES( ${ParaView_SOURCE_DIR}/VTK/Rendering/Testing/Cxx/ ) -set(vtk-module VTKExtensions) +set(vtk-module CGNSReader) set(${vtk-module}_TEST_LABELS PARAVIEW) +paraview_add_test_cxx(${vtk-module}CxxTests tests + NO_VALID NO_OUTPUT NO_DATA + TestCGNSReader.cxx + TestReadCGNSSolution.cxx + ) + ExternalData_add_test(ParaViewData NAME TestCGNSReader - COMMAND vtkPVVTKExtensionsCGNSReaderTests TestCGNSReader - DATA{../Data/Example_mixed.cgns} - DATA{../Data/Example_nface_n.cgns} + COMMAND ${vtk-module}CxxTests TestCGNSReader + -D DATA{../Data/Example_mixed.cgns} + DATA{../Data/Example_nface_n.cgns} ) ExternalData_add_test(ParaViewData NAME TestReadCGNSSolution - COMMAND vtkPVVTKExtensionsCGNSReaderTests TestReadCGNSSolution - DATA{../Data/channelBump_solution.cgns} + COMMAND ${vtk-module}CxxTests TestReadCGNSSolution + -D DATA{../Data/channelBump_solution.cgns} ) -vtk_add_test_cxx(${vtk-modules}vtkPVVTKExtensionsCGNSReaderTests tests - NO_VALID NO_OUTPUT - TestCGNSReader.cxx - TestReadCGNSSolution.cxx - ) - -vtk_test_cxx_executable(${vtk-modules}vtkPVVTKExtensionsCGNSReaderTests tests) +vtk_test_cxx_executable(${vtk-module}CxxTests tests) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx index 1a616bea76b..9b9f4bc5d63 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestCGNSReader.cxx @@ -49,10 +49,14 @@ int TestOutput(vtkMultiBlockDataSet* mb, int nCells, VTKCellType type) int TestCGNSReader(int argc, char* argv[]) { - char* mixed = - vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/CGNSReader/Example_mixed.cgns"); - char* nfacen = - vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/CGNSReader/Example_nface_n.cgns"); + if (argc < 4) return 0; // for some reason two tests are run, one without data data on the cmdline + + const char* mixed = argv[2]; + const char* nfacen = argv[3]; + + + cout << "Opening " << mixed << endl; + cout << "Opening " << nfacen << endl; vtkNew mixedReader; @@ -73,10 +77,6 @@ int TestCGNSReader(int argc, char* argv[]) return 1; - delete [] mixed; - delete [] nfacen; - - cout << __FILE__ << " tests passed." << endl; return 0; } diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx index f76e15bdaeb..23b03dac0c8 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/TestReadCGNSSolution.cxx @@ -54,9 +54,9 @@ int TestOutputData(vtkMultiBlockDataSet* mb, int nCells, int nArrays) int TestReadCGNSSolution(int argc, char* argv[]) { - char* solution = - vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/CGNSReader/channelBump_solution.cgns"); + if (argc < 3) return 0; // for some reason two tests are run, one without data file on cmd line + const char* solution = argv[2]; vtkNew reader; vtkInformation* inf = reader->GetInformation(); @@ -76,8 +76,6 @@ int TestReadCGNSSolution(int argc, char* argv[]) if (0 != TestOutputData(mb, 19742, 20)) return 1; - delete [] solution; - cout << __FILE__ << " tests passed." << endl; return 0; } diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_mixed.cgns.md5 b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_mixed.cgns.md5 new file mode 100644 index 00000000000..9054ef60da1 --- /dev/null +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_mixed.cgns.md5 @@ -0,0 +1 @@ +57faf376c4d77edb017a903fa9909c3c diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_nface_n.cgns.md5 b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_nface_n.cgns.md5 new file mode 100644 index 00000000000..0a8d16b74c4 --- /dev/null +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/Example_nface_n.cgns.md5 @@ -0,0 +1 @@ +83853f5f5a0dfc3e2965dec267da8bb5 diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/channelBump_solution.cgns.md5 b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/channelBump_solution.cgns.md5 new file mode 100644 index 00000000000..e98fef06fa0 --- /dev/null +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Data/channelBump_solution.cgns.md5 @@ -0,0 +1 @@ +bb0dbc74a8d5f97b68d800f3f62859f2 From d50b3027c1366b4ac4c2d537d027851f67842a56 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 18 Feb 2016 09:37:50 -0500 Subject: [PATCH 05/29] vtkProcessModule: store the current directory of the executable Other ParaView client applications may have other paths they would like to derive from this path, so store it and make it available from the vtkProcessModule class. --- .../Core/vtkProcessModule.cxx | 51 +++++++++++-------- .../ClientServerCore/Core/vtkProcessModule.h | 29 ++++++++++- 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/ParaViewCore/ClientServerCore/Core/vtkProcessModule.cxx b/ParaViewCore/ClientServerCore/Core/vtkProcessModule.cxx index db207c1195a..a4c1f0c2f97 100644 --- a/ParaViewCore/ClientServerCore/Core/vtkProcessModule.cxx +++ b/ParaViewCore/ClientServerCore/Core/vtkProcessModule.cxx @@ -270,7 +270,8 @@ bool vtkProcessModule::Initialize(ProcessTypes type, int &argc, char** &argv) // Create the process module. vtkProcessModule::Singleton = vtkSmartPointer::New(); - vtkProcessModule::Singleton->InitializePythonEnvironment(argc, argv); + vtkProcessModule::Singleton->DetermineExecutablePath(argc, argv); + vtkProcessModule::Singleton->InitializePythonEnvironment(); return true; } @@ -547,42 +548,50 @@ void vtkProcessModule::SetOptions(vtkPVOptions* options) } //---------------------------------------------------------------------------- -bool vtkProcessModule::InitializePythonEnvironment(int argc, char** argv) +void vtkProcessModule::DetermineExecutablePath(int argc, char* argv[]) { -#ifdef PARAVIEW_ENABLE_PYTHON assert(argc >= 1); - if (!vtkPythonInterpreter::IsInitialized()) - { - // If someone already initialized Python before ProcessModule was started, - // we don't finalize it when ProcessModule finalizes. This is for the cases - // where ParaView modules are directly imported in python (not pvpython). - vtkProcessModule::FinalizePython = true; - } - - std::string self_dir, programname; if (argc > 0) { std::string errMsg; - if (!vtksys::SystemTools::FindProgramPath(argv[0], programname, errMsg)) + if (!vtksys::SystemTools::FindProgramPath(argv[0], this->ProgramPath, errMsg)) { // if FindProgramPath fails. We really don't have much of an alternative // here. Python module importing is going to fail. - programname = vtksys::SystemTools::CollapseFullPath(argv[0]); + this->ProgramPath = vtksys::SystemTools::CollapseFullPath(argv[0]); } - self_dir = vtksys::SystemTools::GetFilenamePath(programname.c_str()); + this->SelfDir = vtksys::SystemTools::GetFilenamePath(this->ProgramPath); } else { - self_dir = vtksys::SystemTools::GetCurrentWorkingDirectory(/*collapse=*/true); - programname = self_dir + "/unknown_exe"; + this->SelfDir = vtksys::SystemTools::GetCurrentWorkingDirectory(/*collapse=*/true); + this->ProgramPath = this->SelfDir + "/unknown_exe"; + } +} + +//---------------------------------------------------------------------------- +void vtkProcessModule::SetExecutablePath(const std::string& path) +{ + this->ProgramPath = vtksys::SystemTools::CollapseFullPath(path); + this->SelfDir = vtksys::SystemTools::GetFilenamePath(this->ProgramPath); +} + +//---------------------------------------------------------------------------- +bool vtkProcessModule::InitializePythonEnvironment() +{ +#ifdef PARAVIEW_ENABLE_PYTHON + if (!vtkPythonInterpreter::IsInitialized()) + { + // If someone already initialized Python before ProcessModule was started, + // we don't finalize it when ProcessModule finalizes. This is for the cases + // where ParaView modules are directly imported in python (not pvpython). + vtkProcessModule::FinalizePython = true; } - vtkPythonInterpreter::SetProgramName(programname.c_str()); - vtkPythonAppInitPrependPath(self_dir.c_str()); + vtkPythonInterpreter::SetProgramName(this->ProgramPath.c_str()); + vtkPythonAppInitPrependPath(this->SelfDir); #endif - (void)argc; - (void)argv; return true; } diff --git a/ParaViewCore/ClientServerCore/Core/vtkProcessModule.h b/ParaViewCore/ClientServerCore/Core/vtkProcessModule.h index 2f33438e2cf..7bd280b1780 100644 --- a/ParaViewCore/ClientServerCore/Core/vtkProcessModule.h +++ b/ParaViewCore/ClientServerCore/Core/vtkProcessModule.h @@ -23,6 +23,8 @@ #include "vtkObject.h" #include "vtkSmartPointer.h" // needed for vtkSmartPointer. +#include // for std::string + class vtkMultiProcessController; class vtkNetworkAccessManager; class vtkPVOptions; @@ -235,6 +237,24 @@ class VTKPVCLIENTSERVERCORECORE_EXPORT vtkProcessModule : public vtkObject // session id is ever repeated. vtkIdType MaxSessionId; + // Description: + // Sets the executable path of the process so that ParaView can, e.g., set up + // paths for Python properly. + void SetExecutablePath(const std::string& path); + + // Description: + // The full path to the current executable that is running (or empty if unknown). + std::string GetProgramPath() const + { + return this->ProgramPath; + } + // Description: + // The directory containing the current executable (or empty if unknown). + std::string GetSelfDir() const + { + return this->SelfDir; + } + protected: vtkProcessModuleInternals* Internals; @@ -247,10 +267,12 @@ class VTKPVCLIENTSERVERCORECORE_EXPORT vtkProcessModule : public vtkObject vtkProcessModule(const vtkProcessModule&); // Not implemented. void operator=(const vtkProcessModule&); // Not implemented. + void DetermineExecutablePath(int argc, char** argv); + // Helper to initialize Python environment. This doesn't initialize Python // but simply sets up the environment so when Python is initialized, it can - // find ParaView modules. This does nothing is not build with Python support. - bool InitializePythonEnvironment(int argc, char** argv); + // find ParaView modules. This does nothing if not build with Python support. + bool InitializePythonEnvironment(); static ProcessTypes ProcessType; @@ -269,6 +291,9 @@ class VTKPVCLIENTSERVERCORECORE_EXPORT vtkProcessModule : public vtkObject bool MultipleSessionsSupport; vtkIdType EventCallDataSessionId; + + std::string ProgramPath; + std::string SelfDir; //ETX }; From edbab0db02aef3e6b288cfd907d8b799aeee6cce Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Sat, 5 Mar 2016 14:58:40 -0500 Subject: [PATCH 06/29] Cleanup testing code. Signed-off-by: Menno Deij - van Rijswijk --- .../CGNSReader/Testing/Cxx/CMakeLists.txt | 14 +++----------- ParaViewCore/VTKExtensions/CGNSReader/module.cmake | 7 +++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt index 9dd98fce289..15dc3decf2a 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt +++ b/ParaViewCore/VTKExtensions/CGNSReader/Testing/Cxx/CMakeLists.txt @@ -1,20 +1,13 @@ -INCLUDE_DIRECTORIES( - ${ParaView_SOURCE_DIR}/VTK/Common/Testing/Cxx/ - ${ParaView_SOURCE_DIR}/VTK/Testing/Core/ - ${ParaView_SOURCE_DIR}/VTK/Rendering/Testing/Cxx/ - ) - -set(vtk-module CGNSReader) -set(${vtk-module}_TEST_LABELS PARAVIEW) +include(ParaViewTestingMacros) paraview_add_test_cxx(${vtk-module}CxxTests tests NO_VALID NO_OUTPUT NO_DATA TestCGNSReader.cxx TestReadCGNSSolution.cxx ) - + ExternalData_add_test(ParaViewData - NAME TestCGNSReader + NAME TestCGNSReader COMMAND ${vtk-module}CxxTests TestCGNSReader -D DATA{../Data/Example_mixed.cgns} DATA{../Data/Example_nface_n.cgns} @@ -25,5 +18,4 @@ ExternalData_add_test(ParaViewData COMMAND ${vtk-module}CxxTests TestReadCGNSSolution -D DATA{../Data/channelBump_solution.cgns} ) - vtk_test_cxx_executable(${vtk-module}CxxTests tests) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/module.cmake b/ParaViewCore/VTKExtensions/CGNSReader/module.cmake index f41ad777309..0744111f7f7 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/module.cmake +++ b/ParaViewCore/VTKExtensions/CGNSReader/module.cmake @@ -19,6 +19,12 @@ vtk_module(vtkPVVTKExtensionsCGNSReader vtksys vtkParallelCore ${cgns_private_depends} + TEST_DEPENDS + vtkInteractionStyle + vtkTestingCore + vtkTestingRendering + TEST_LABELS + PARAVIEW KIT vtkPVExtensions ) @@ -27,3 +33,4 @@ set_property(GLOBAL PROPERTY vtkPVVTKExtensionsCGNSReader_SERVERMANAGER_XMLS ${CMAKE_CURRENT_LIST_DIR}/resources/CGNSReader.xml ) +unset(cgns_private_depends) From 589f5b1ffa9d501fc203a4f702d4c740112c3b9e Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Sat, 5 Mar 2016 14:59:09 -0500 Subject: [PATCH 07/29] Remove CGNS headers from vtkCGNSReader.h. Signed-off-by: Menno Deij - van Rijswijk --- .../CGNSReader/vtkCGNSReader.cxx | 276 +++++++++++------- .../VTKExtensions/CGNSReader/vtkCGNSReader.h | 45 +-- 2 files changed, 178 insertions(+), 143 deletions(-) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx index 8fbd1a9aafd..3fd00bc293c 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx +++ b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx @@ -15,6 +15,7 @@ // Copyright 2013-2014 Mickael Philit. #include "vtkCGNSReader.h" +#include "vtkCGNSReaderInternal.h" // For parsing information request #include "vtkCallbackCommand.h" #include "vtkCellArray.h" @@ -87,8 +88,49 @@ namespace }; } +// vtkCGNSReader has several method that used types from CGNS +// which resulted in CGNS include being exposed to the users of this class +// causing build complications. This makes that easier. +class vtkCGNSReader::vtkPrivate +{ +public: + static bool IsVarEnabled( + CGNS_ENUMT(GridLocation_t) varcentering, const CGNSRead::char_33 name, + vtkCGNSReader* self); + static int getGridAndSolutionName(int base, + CGNSRead::char_33 GridCoordName, CGNSRead::char_33 SolutionName, + bool& readGridCoordName, bool& readSolutionName, + vtkCGNSReader* self); + static int getCoordsIdAndFillRind(const CGNSRead::char_33 GridCoordName, + const int physicalDim, std::size_t& nCoordsArray, + std::vector& gridChildId, int* rind, + vtkCGNSReader* self); + static int getVarsIdAndFillRind( + const double cgioSolId, + std::size_t& nVarArray, CGNS_ENUMT(GridLocation_t)& varCentering, + std::vector& solChildId, int* rind, + vtkCGNSReader* self); + + static int fillArrayInformation( + const std::vector& solChildId, + const int physicalDim, + std::vector< CGNSRead::CGNSVariable >& cgnsVars, + std::vector< CGNSRead::CGNSVector >& cgnsVectors, + vtkCGNSReader* self); + + static int AllocateVtkArray( + const int physicalDim, const vtkIdType nVals, + const CGNS_ENUMT(GridLocation_t) varCentering, + const std::vector< CGNSRead::CGNSVariable >& cgnsVars, + const std::vector< CGNSRead::CGNSVector >& cgnsVectors, + std::vector& vtkVars, + vtkCGNSReader* self); + + static int AttachReferenceValue(const int base, vtkDataSet* ds, vtkCGNSReader* self); +}; + //---------------------------------------------------------------------------- -vtkCGNSReader::vtkCGNSReader() +vtkCGNSReader::vtkCGNSReader() : Internal(new CGNSRead::vtkCGNSMetaData()) { this->FileName = NULL; @@ -137,6 +179,9 @@ vtkCGNSReader::~vtkCGNSReader() this->BaseSelection->Delete(); this->SelectionObserver->Delete(); this->SetController(NULL); + + delete this->Internal; + this->Internal = NULL; } //---------------------------------------------------------------------------- @@ -171,62 +216,65 @@ void vtkCGNSReader::SetController(vtkMultiProcessController* c) } //------------------------------------------------------------------------------ -bool vtkCGNSReader::IsVarEnabled(CGNS_ENUMT(GridLocation_t) varcentering, - const CGNSRead::char_33 name) +bool vtkCGNSReader::vtkPrivate::IsVarEnabled( + CGNS_ENUMT(GridLocation_t) varcentering, const CGNSRead::char_33 name, + vtkCGNSReader* self) { vtkDataArraySelection *DataSelection = 0; if (varcentering == CGNS_ENUMV(Vertex)) { - DataSelection = this->PointDataArraySelection; + DataSelection = self->PointDataArraySelection; } else { - DataSelection = this->CellDataArraySelection; + DataSelection = self->CellDataArraySelection; } return (DataSelection->ArrayIsEnabled(name) != 0); } //------------------------------------------------------------------------------ -int vtkCGNSReader::getGridAndSolutionName(const int base, - CGNSRead::char_33 GridCoordName, - CGNSRead::char_33 SolutionName, - bool& readGridCoordName, - bool& readSolutionName) +int vtkCGNSReader::vtkPrivate::getGridAndSolutionName( + const int base, + CGNSRead::char_33 GridCoordName, + CGNSRead::char_33 SolutionName, + bool& readGridCoordName, + bool& readSolutionName, + vtkCGNSReader* self) { // // Get Coordinates and FlowSolution node names readGridCoordName = true; readSolutionName = true; - if ((this->Internal.GetBase(base).useGridPointers == true) || - (this->Internal.GetBase(base).useFlowPointers == true)) + if ((self->Internal->GetBase(base).useGridPointers == true) || + (self->Internal->GetBase(base).useFlowPointers == true)) { CGNSRead::char_33 zoneIterName; double ziterId = 0; - std::size_t ptSize = 32*this->Internal.GetBase(base).steps.size() + 1; + std::size_t ptSize = 32*self->Internal->GetBase(base).steps.size() + 1; char *pointers = new char[ptSize]; - if (CGNSRead::getFirstNodeId(this->cgioNum, this->currentId, + if (CGNSRead::getFirstNodeId(self->cgioNum, self->currentId, "ZoneIterativeData_t", &ziterId) == CG_OK) { - cgio_get_name(cgioNum, ziterId, zoneIterName); + cgio_get_name(self->cgioNum, ziterId, zoneIterName); // CGNSRead::char_33 nodeLabel; CGNSRead::char_33 nodeName; std::vector iterChildId; - CGNSRead::getNodeChildrenId(cgioNum, ziterId, iterChildId); + CGNSRead::getNodeChildrenId(self->cgioNum, ziterId, iterChildId); for (std::size_t nn = 0; nn < iterChildId.size(); nn++) { - if (cgio_get_name(cgioNum, iterChildId[nn], nodeName) != CG_OK) + if (cgio_get_name(self->cgioNum, iterChildId[nn], nodeName) != CG_OK) { return 1; } - if (cgio_get_label(cgioNum, iterChildId[nn], nodeLabel) != CG_OK) + if (cgio_get_label(self->cgioNum, iterChildId[nn], nodeLabel) != CG_OK) { return 1; } @@ -234,9 +282,9 @@ int vtkCGNSReader::getGridAndSolutionName(const int base, if (isDataArray && (strcmp(nodeName, "GridCoordinatesPointers") == 0)) { - cgio_read_block_data(this->cgioNum, iterChildId[nn], - (cgsize_t)(this->ActualTimeStep*32 + 1), - (cgsize_t)(this->ActualTimeStep*32 + 32), + cgio_read_block_data(self->cgioNum, iterChildId[nn], + (cgsize_t)(self->ActualTimeStep*32 + 1), + (cgsize_t)(self->ActualTimeStep*32 + 32), ( void * ) GridCoordName); GridCoordName[32] ='\0'; readGridCoordName = false; @@ -244,14 +292,14 @@ int vtkCGNSReader::getGridAndSolutionName(const int base, else if (isDataArray && (strcmp(nodeName, "FlowSolutionPointers") == 0)) { - cgio_read_block_data(this->cgioNum, iterChildId[nn], - (cgsize_t)(this->ActualTimeStep*32 + 1), - (cgsize_t)(this->ActualTimeStep*32 + 32), + cgio_read_block_data(self->cgioNum, iterChildId[nn], + (cgsize_t)(self->ActualTimeStep*32 + 1), + (cgsize_t)(self->ActualTimeStep*32 + 32), (void *) SolutionName); SolutionName[32] ='\0'; readSolutionName = false; } - cgio_release_id(cgioNum, iterChildId[nn]); + cgio_release_id(self->cgioNum, iterChildId[nn]); } } else @@ -271,11 +319,13 @@ int vtkCGNSReader::getGridAndSolutionName(const int base, } //------------------------------------------------------------------------------ -int vtkCGNSReader::getCoordsIdAndFillRind(const CGNSRead::char_33 GridCoordName, +int vtkCGNSReader::vtkPrivate::getCoordsIdAndFillRind( + const CGNSRead::char_33 GridCoordName, const int physicalDim, std::size_t& nCoordsArray, std::vector& gridChildId, - int* rind) + int* rind, + vtkCGNSReader* self) { char nodeLabel[CGIO_MAX_NAME_LENGTH+1]; std::size_t na; @@ -283,17 +333,17 @@ int vtkCGNSReader::getCoordsIdAndFillRind(const CGNSRead::char_33 GridCoordName, nCoordsArray = 0; // Get GridCoordinate node ID for low level access double gridId; - if (cgio_get_node_id(this->cgioNum, this->currentId, + if (cgio_get_node_id(self->cgioNum, self->currentId, GridCoordName, &gridId) != CG_OK) { char message[81]; cgio_error_message(message); - vtkErrorMacro(<< "Error while reading mesh coordinates node :" << message); + vtkErrorWithObjectMacro(self, << "Error while reading mesh coordinates node :" << message); return 1; } // Get the number of Coordinates in GridCoordinates node - CGNSRead::getNodeChildrenId(this->cgioNum, gridId, gridChildId); + CGNSRead::getNodeChildrenId(self->cgioNum, gridId, gridChildId); for (int n = 0; n < 6; n++) { @@ -301,10 +351,10 @@ int vtkCGNSReader::getCoordsIdAndFillRind(const CGNSRead::char_33 GridCoordName, } for (nCoordsArray = 0, na = 0; na < gridChildId.size(); ++na) { - if ( cgio_get_label(cgioNum, gridChildId[na], nodeLabel) != CG_OK) + if ( cgio_get_label(self->cgioNum, gridChildId[na], nodeLabel) != CG_OK) { - vtkErrorMacro(<< "Not enough coordinates in node " - << GridCoordName << "\n"); + vtkErrorWithObjectMacro(self, << "Not enough coordinates in node " + << GridCoordName << "\n"); continue; } @@ -319,29 +369,30 @@ int vtkCGNSReader::getCoordsIdAndFillRind(const CGNSRead::char_33 GridCoordName, else if ( strcmp(nodeLabel, "Rind_t") == 0) { // check for rind - CGNSRead::setUpRind(this->cgioNum, gridChildId[na], rind); + CGNSRead::setUpRind(self->cgioNum, gridChildId[na], rind); } else { - cgio_release_id(cgioNum, gridChildId[na]); + cgio_release_id(self->cgioNum, gridChildId[na]); } } if (nCoordsArray < static_cast(physicalDim)) { - vtkErrorMacro(<< "Not enough coordinates in node " - << GridCoordName << "\n"); + vtkErrorWithObjectMacro(self, << "Not enough coordinates in node " + << GridCoordName << "\n"); return 1; } - cgio_release_id(this->cgioNum, gridId); + cgio_release_id(self->cgioNum, gridId); return 0; } //------------------------------------------------------------------------------ -int vtkCGNSReader::getVarsIdAndFillRind(const double cgioSolId, +int vtkCGNSReader::vtkPrivate::getVarsIdAndFillRind(const double cgioSolId, std::size_t& nVarArray, CGNS_ENUMT(GridLocation_t) & varCentering, std::vector& solChildId, - int* rind) + int* rind, + vtkCGNSReader* self) { char nodeLabel[CGIO_MAX_NAME_LENGTH+1]; std::size_t na; @@ -352,13 +403,13 @@ int vtkCGNSReader::getVarsIdAndFillRind(const double cgioSolId, rind[n] = 0; } - CGNSRead::getNodeChildrenId ( this->cgioNum, cgioSolId, solChildId ); + CGNSRead::getNodeChildrenId ( self->cgioNum, cgioSolId, solChildId ); for (nVarArray = 0, na = 0; na < solChildId.size(); ++na) { - if (cgio_get_label(cgioNum, solChildId[na], nodeLabel) != CG_OK) + if (cgio_get_label(self->cgioNum, solChildId[na], nodeLabel) != CG_OK) { - vtkErrorMacro(<< "Error while reading node label in solution\n"); + vtkErrorWithObjectMacro(self, << "Error while reading node label in solution\n"); continue; } @@ -372,13 +423,13 @@ int vtkCGNSReader::getVarsIdAndFillRind(const double cgioSolId, } else if ( strcmp(nodeLabel, "Rind_t") == 0) { - CGNSRead::setUpRind(this->cgioNum, solChildId[na], rind); + CGNSRead::setUpRind(self->cgioNum, solChildId[na], rind); } else if ( strcmp(nodeLabel, "GridLocation_t") == 0) { CGNSRead::char_33 dataType; - if (cgio_get_data_type(cgioNum, solChildId[na], dataType) != CG_OK) + if (cgio_get_data_type(self->cgioNum, solChildId[na], dataType) != CG_OK) { return 1; } @@ -391,7 +442,7 @@ int vtkCGNSReader::getVarsIdAndFillRind(const double cgioSolId, } std::string location; - CGNSRead::readNodeStringData(this->cgioNum, solChildId[na], location); + CGNSRead::readNodeStringData(self->cgioNum, solChildId[na], location); if (location == "Vertex") { @@ -408,28 +459,30 @@ int vtkCGNSReader::getVarsIdAndFillRind(const double cgioSolId, } else { - cgio_release_id(this->cgioNum, solChildId[na]); + cgio_release_id(self->cgioNum, solChildId[na]); } } return 0; } //------------------------------------------------------------------------------ -int vtkCGNSReader::fillArrayInformation(const std::vector& solChildId, - const int physicalDim, - std::vector< CGNSRead::CGNSVariable >& cgnsVars, - std::vector< CGNSRead::CGNSVector >& cgnsVectors) +int vtkCGNSReader::vtkPrivate::fillArrayInformation( + const std::vector& solChildId, + const int physicalDim, + std::vector< CGNSRead::CGNSVariable >& cgnsVars, + std::vector< CGNSRead::CGNSVector >& cgnsVectors, + vtkCGNSReader* self) { // Read variable names for (std::size_t ff = 0; ff < cgnsVars.size(); ++ff) { - cgio_get_name(cgioNum, solChildId[ff], cgnsVars[ff].name); + cgio_get_name(self->cgioNum, solChildId[ff], cgnsVars[ff].name); cgnsVars[ff].isComponent = false; cgnsVars[ff].xyzIndex = 0; // read node data type CGNSRead::char_33 dataType; - cgio_get_data_type(cgioNum , solChildId[ff], dataType); + cgio_get_data_type(self->cgioNum , solChildId[ff], dataType); if (strcmp(dataType, "R8") == 0) { cgnsVars[ff].dt = CGNS_ENUMV(RealDouble); @@ -458,11 +511,12 @@ int vtkCGNSReader::fillArrayInformation(const std::vector& solChildId, } //------------------------------------------------------------------------------ -int vtkCGNSReader::AllocateVtkArray(const int physicalDim, const vtkIdType nVals, +int vtkCGNSReader::vtkPrivate::AllocateVtkArray(const int physicalDim, const vtkIdType nVals, const CGNS_ENUMT(GridLocation_t) varCentering, const std::vector< CGNSRead::CGNSVariable >& cgnsVars, const std::vector< CGNSRead::CGNSVector >& cgnsVectors, - std::vector& vtkVars) + std::vector& vtkVars, + vtkCGNSReader* self) { for (std::size_t ff = 0; ff < cgnsVars.size(); ff++) { @@ -470,7 +524,7 @@ int vtkCGNSReader::AllocateVtkArray(const int physicalDim, const vtkIdType nVals if (cgnsVars[ff].isComponent == false) { - if (IsVarEnabled(varCentering, cgnsVars[ff].name) == false) + if (vtkPrivate::IsVarEnabled(varCentering, cgnsVars[ff].name, self) == false) { continue; } @@ -505,7 +559,7 @@ int vtkCGNSReader::AllocateVtkArray(const int physicalDim, const vtkIdType nVals { vtkDataArray *arr = 0; - if (IsVarEnabled(varCentering, iter->name) == false) + if (vtkPrivate::IsVarEnabled(varCentering, iter->name, self) == false) { continue; } @@ -546,11 +600,11 @@ int vtkCGNSReader::AllocateVtkArray(const int physicalDim, const vtkIdType nVals } //------------------------------------------------------------------------------ -int vtkCGNSReader::AttachReferenceValue(const int base, vtkDataSet* ds) +int vtkCGNSReader::vtkPrivate::AttachReferenceValue(const int base, vtkDataSet* ds, vtkCGNSReader* self) { // Handle Reference Values (Mach Number, ...) const std::map< std::string, double>& arrState = - this->Internal.GetBase(base).referenceState; + self->Internal->GetBase(base).referenceState; std::map< std::string, double>::const_iterator iteRef = arrState.begin(); for (iteRef = arrState.begin(); iteRef != arrState.end(); iteRef++) { @@ -567,9 +621,11 @@ int vtkCGNSReader::AttachReferenceValue(const int base, vtkDataSet* ds) //------------------------------------------------------------------------------ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, int cellDim, int physicalDim, - cgsize_t *zsize, + void* v_zsize, vtkMultiBlockDataSet *mbase) { + cgsize_t* zsize = reinterpret_cast(v_zsize); + int rind[6]; int n; //int ier; @@ -595,11 +651,11 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, std::vector gridChildId; std::size_t nCoordsArray = 0; - this->getGridAndSolutionName(base, GridCoordName, SolutionName, - readGridCoordName, readSolutionName); + vtkPrivate::getGridAndSolutionName(base, GridCoordName, SolutionName, + readGridCoordName, readSolutionName, this); - this->getCoordsIdAndFillRind(GridCoordName, physicalDim, - nCoordsArray, gridChildId, rind); + vtkPrivate::getCoordsIdAndFillRind(GridCoordName, physicalDim, + nCoordsArray, gridChildId, rind, this); // Rind was parsed (or not) then populate dimensions : // Compute structured grid coordinate range @@ -687,8 +743,8 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, std::vector solChildId; std::size_t nVarArray = 0; - this->getVarsIdAndFillRind(cgioSolId, nVarArray, varCentering, - solChildId, rind); + vtkPrivate::getVarsIdAndFillRind(cgioSolId, nVarArray, varCentering, + solChildId, rind, this); vtkStructuredGrid *sgrid = vtkStructuredGrid::New(); sgrid->SetExtent(extent); @@ -710,7 +766,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, std::vector< CGNSRead::CGNSVariable > cgnsVars(nVarArray); std::vector< CGNSRead::CGNSVector > cgnsVectors; - this->fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors); + vtkPrivate::fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors, this); // Source cgsize_t fieldSrcStart[3] = {1,1,1}; @@ -759,8 +815,8 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, std::vector vtkVars(nVarArray); // Count number of vars and vectors // Assign vars and vectors to a vtkvars array - this->AllocateVtkArray(physicalDim, nVals, varCentering, - cgnsVars, cgnsVectors, vtkVars); + vtkPrivate::AllocateVtkArray(physicalDim, nVals, varCentering, + cgnsVars, cgnsVectors, vtkVars, this); // Load Data for (std::size_t ff = 0; ff < nVarArray; ++ff) @@ -831,7 +887,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, } } // - this->AttachReferenceValue(base, sgrid); + vtkPrivate::AttachReferenceValue(base, sgrid, this); // mbase->SetBlock(zone, sgrid); sgrid->Delete(); @@ -870,7 +926,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, cgio_get_name(this->cgioNum, zoneChildId[nn], SolutionName); - this->getVarsIdAndFillRind(cgioSolId, nVarArray, varCentering, solChildId, rind); + vtkPrivate::getVarsIdAndFillRind(cgioSolId, nVarArray, varCentering, solChildId, rind, this); if (varCentering != CGNS_ENUMV(Vertex)) { @@ -902,7 +958,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, std::vector< CGNSRead::CGNSVariable > cgnsVars(nVarArray); std::vector< CGNSRead::CGNSVector > cgnsVectors; - this->fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors); + vtkPrivate::fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors, this); // Source cgsize_t fieldSrcStart[3] = {1,1,1}; @@ -952,7 +1008,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, // Assign vars and vectors to a vtkvars array std::vector vtkVars(nVarArray); - this->AllocateVtkArray(physicalDim, nVals, varCentering, cgnsVars, cgnsVectors, vtkVars); + vtkPrivate::AllocateVtkArray(physicalDim, nVals, varCentering, cgnsVars, cgnsVectors, vtkVars, this); // Load Data for (std::size_t ff = 0; ff < nVarArray; ++ff) @@ -1024,7 +1080,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, } cgio_release_id(cgioNum, zoneChildId[nn]); } - this->AttachReferenceValue(base, sgrid); + vtkPrivate::AttachReferenceValue(base, sgrid, this); if (nosolutionread == false) { mbase->SetBlock((zone), sgrid); @@ -1062,7 +1118,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, std::size_t nVarArray = 0; std::vector solChildId; - this->getVarsIdAndFillRind(cgioSolId, nVarArray, varCentering, solChildId, rind); + vtkPrivate::getVarsIdAndFillRind(cgioSolId, nVarArray, varCentering, solChildId, rind, this); if ( varCentering != CGNS_ENUMV(Vertex) && varCentering != CGNS_ENUMV(CellCenter)) @@ -1086,7 +1142,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, std::vector< CGNSRead::CGNSVariable > cgnsVars(nVarArray); std::vector< CGNSRead::CGNSVector > cgnsVectors; - this->fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors); + vtkPrivate::fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors, this); // Source cgsize_t fieldSrcStart[3] = {1,1,1}; @@ -1136,7 +1192,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, // Assign vars and vectors to a vtkvars array std::vector vtkVars(nVarArray); - this->AllocateVtkArray(physicalDim, nVals, varCentering, cgnsVars, cgnsVectors, vtkVars); + vtkPrivate::AllocateVtkArray(physicalDim, nVals, varCentering, cgnsVars, cgnsVectors, vtkVars, this); // Load Data for (std::size_t ff = 0; ff < nVarArray; ++ff) @@ -1211,7 +1267,7 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, for (std::size_t sol = 0; sol < StructuredGridList.size(); sol++) { mzone->GetMetaData(static_cast(sol))->Set(vtkCompositeDataSet::NAME(), SolutionNameList[sol]); - this->AttachReferenceValue(base, StructuredGridList[sol]); + vtkPrivate::AttachReferenceValue(base, StructuredGridList[sol], this); mzone->SetBlock((sol), StructuredGridList[sol]); StructuredGridList[sol]->Delete(); } @@ -1242,9 +1298,11 @@ int vtkCGNSReader::GetCurvilinearZone(int base, int zone, //------------------------------------------------------------------------------ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, int cellDim, int physicalDim, - cgsize_t *zsize, + void *v_zsize, vtkMultiBlockDataSet *mbase) { + cgsize_t* zsize = reinterpret_cast(v_zsize); + //======================================================================== // Test at compilation time with static assert ... // In case cgsize_t < vtkIdType one could try to start from the array end @@ -1286,9 +1344,9 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, std::vector gridChildId; std::size_t nCoordsArray = 0; - this->getGridAndSolutionName(base, GridCoordName, SolutionName, readGridCoordName, readSolutionName); + vtkPrivate::getGridAndSolutionName(base, GridCoordName, SolutionName, readGridCoordName, readSolutionName, this); - this->getCoordsIdAndFillRind(GridCoordName, physicalDim, nCoordsArray, gridChildId, rind); + vtkPrivate::getCoordsIdAndFillRind(GridCoordName, physicalDim, nCoordsArray, gridChildId, rind, this); // Rind was parsed or not then populate dimensions : // get grid coordinate range @@ -1945,7 +2003,7 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, std::vector solChildId; std::size_t nVarArray = 0; - this->getVarsIdAndFillRind ( cgioSolId, nVarArray, varCentering, solChildId, rind); + vtkPrivate::getVarsIdAndFillRind ( cgioSolId, nVarArray, varCentering, solChildId, rind, this ); if ((varCentering != CGNS_ENUMV(Vertex)) && (varCentering != CGNS_ENUMV(CellCenter))) @@ -1957,7 +2015,7 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, std::vector< CGNSRead::CGNSVariable > cgnsVars(nVarArray); std::vector< CGNSRead::CGNSVector > cgnsVectors; - this->fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors); + vtkPrivate::fillArrayInformation(solChildId, physicalDim, cgnsVars, cgnsVectors, this); // Source layout cgsize_t fieldSrcStart[3] = {1,1,1}; @@ -2003,7 +2061,7 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, // Count number of vars and vectors // Assign vars and vectors to a vtkvars array std::vector vtkVars(nVarArray); - this->AllocateVtkArray(physicalDim, nVals, varCentering, cgnsVars, cgnsVectors, vtkVars); + vtkPrivate::AllocateVtkArray(physicalDim, nVals, varCentering, cgnsVars, cgnsVectors, vtkVars, this); // Load Data for (std::size_t ff = 0; ff < nVarArray; ++ff) @@ -2074,7 +2132,7 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, } // Handle Reference Values (Mach Number, ...) - this->AttachReferenceValue(base, ugrid); + vtkPrivate::AttachReferenceValue(base, ugrid, this); //-------------------------------------------------- // Read patch boundary Sections @@ -2292,7 +2350,7 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, bnd_id_arr->Delete(); // Handle Ref Values - this->AttachReferenceValue(base, bndugrid); + vtkPrivate::AttachReferenceValue(base, bndugrid, this); // Copy PointData if exists vtkPointData* temp = ugrid->GetPointData(); @@ -2365,11 +2423,11 @@ int vtkCGNSReader::RequestData(vtkInformation *vtkNotUsed(request), numProcessors = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES()); - int numBases = this->Internal.GetNumberOfBaseNodes(); + int numBases = this->Internal->GetNumberOfBaseNodes(); int numZones = 0; for (int bb=0; bb < numBases; bb++) { - numZones += this->Internal.GetBase(bb).nzones; + numZones += this->Internal->GetBase(bb).nzones; } // Divide the files evenly between processors @@ -2393,14 +2451,14 @@ int vtkCGNSReader::RequestData(vtkInformation *vtkNotUsed(request), startRange = startRange - accumulated; endRange = endRange - accumulated; int startInterZone = std::max(startRange, 0); - int endInterZone = std::min(endRange, this->Internal.GetBase(bb).nzones); + int endInterZone = std::min(endRange, this->Internal->GetBase(bb).nzones); if ((endInterZone - startInterZone) > 0) { zoneRange[0] = startInterZone; zoneRange[1] = endInterZone; } - accumulated = this->Internal.GetBase(bb).nzones; + accumulated = this->Internal->GetBase(bb).nzones; baseToZoneRange[bb] = zoneRange; } } @@ -2415,13 +2473,13 @@ int vtkCGNSReader::RequestData(vtkInformation *vtkNotUsed(request), startRange = startRange - accumulated; endRange = endRange - accumulated; int startInterZone = std::max(startRange, 0); - int endInterZone = std::min(endRange, this->Internal.GetBase(bb).nzones); + int endInterZone = std::min(endRange, this->Internal->GetBase(bb).nzones); if ((endInterZone - startInterZone) > 0) { zoneRange[0] = startInterZone; zoneRange[1] = endInterZone; } - accumulated = this->Internal.GetBase(bb).nzones; + accumulated = this->Internal->GetBase(bb).nzones; baseToZoneRange[bb] = zoneRange; } } @@ -2433,7 +2491,7 @@ int vtkCGNSReader::RequestData(vtkInformation *vtkNotUsed(request), this->CreateEachSolutionAsBlock = 0; } - if (!this->Internal.Parse(this->FileName)) + if (!this->Internal->Parse(this->FileName)) { return 0; } @@ -2458,21 +2516,21 @@ int vtkCGNSReader::RequestData(vtkInformation *vtkNotUsed(request), << requestedTimeValue); // Clamp requestedTimeValue to available time range. - if (requestedTimeValue < this->Internal.GetTimes().front()) + if (requestedTimeValue < this->Internal->GetTimes().front()) { - requestedTimeValue = this->Internal.GetTimes().front(); + requestedTimeValue = this->Internal->GetTimes().front(); } - if (requestedTimeValue > this->Internal.GetTimes().back()) + if (requestedTimeValue > this->Internal->GetTimes().back()) { - requestedTimeValue = this->Internal.GetTimes().back() ; + requestedTimeValue = this->Internal->GetTimes().back() ; } std::vector::iterator timeIte = std::find_if( - this->Internal.GetTimes().begin(), this->Internal.GetTimes().end(), + this->Internal->GetTimes().begin(), this->Internal->GetTimes().end(), std::bind2nd(WithinTolerance(), requestedTimeValue)); // - if (timeIte == this->Internal.GetTimes().end()) + if (timeIte == this->Internal->GetTimes().end()) { return 0; } @@ -2511,7 +2569,7 @@ int vtkCGNSReader::RequestData(vtkInformation *vtkNotUsed(request), int cellDim = 0; int physicalDim = 0; - const CGNSRead::BaseInformation & curBaseInfo = this->Internal.GetBase(numBase); + const CGNSRead::BaseInformation & curBaseInfo = this->Internal->GetBase(numBase); // skip unselected base if ( this->BaseSelection->ArrayIsEnabled ( curBaseInfo.name ) == 0 ) @@ -2549,7 +2607,7 @@ int vtkCGNSReader::RequestData(vtkInformation *vtkNotUsed(request), (requestedTimeValue > curBaseInfo.times.back())) { skipBase = true; - requestedTimeValue = this->Internal.GetTimes().front(); + requestedTimeValue = this->Internal->GetTimes().front(); } std::vector::const_iterator iter ; @@ -2782,7 +2840,7 @@ int vtkCGNSReader::RequestInformation(vtkInformation * request, << this->FileName << " for fields and time steps"); // Parse the file... - if (!this->Internal.Parse(this->FileName)) + if (!this->Internal->Parse(this->FileName)) { vtkErrorMacro(<< "Failed to parse cgns file: " << this->FileName); return false; @@ -2794,13 +2852,13 @@ int vtkCGNSReader::RequestInformation(vtkInformation * request, this->Broadcast(this->Controller); } - this->NumberOfBases = this->Internal.GetNumberOfBaseNodes(); + this->NumberOfBases = this->Internal->GetNumberOfBaseNodes(); // Set up time information - if (this->Internal.GetTimes().size() != 0) + if (this->Internal->GetTimes().size() != 0) { - std::vector timeSteps(this->Internal.GetTimes().begin(), - this->Internal.GetTimes().end()); + std::vector timeSteps(this->Internal->GetTimes().begin(), + this->Internal->GetTimes().end()); vtkInformation* outInfo = outputVector->GetInformationObject(0); outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), @@ -2813,9 +2871,9 @@ int vtkCGNSReader::RequestInformation(vtkInformation * request, timeRange, 2); } - for (int base = 0; base < this->Internal.GetNumberOfBaseNodes() ; ++base) + for (int base = 0; base < this->Internal->GetNumberOfBaseNodes() ; ++base) { - const CGNSRead::BaseInformation& curBase = this->Internal.GetBase(base); + const CGNSRead::BaseInformation& curBase = this->Internal->GetBase(base); // Fill base names if ( base == 0 && (!this->BaseSelection->ArrayExists(curBase.name))) { @@ -3139,6 +3197,6 @@ void vtkCGNSReader::Broadcast(vtkMultiProcessController* ctrl) if (ctrl) { int rank = ctrl->GetLocalProcessId(); - this->Internal.Broadcast(ctrl, rank); + this->Internal->Broadcast(ctrl, rank); } } diff --git a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.h b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.h index dbc999c1a90..67d95211fcf 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.h +++ b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.h @@ -35,12 +35,16 @@ #include "vtkMultiBlockDataSetAlgorithm.h" #include "vtkPVVTKExtensionsCGNSReaderModule.h" // for export macro -#include "vtkCGNSReaderInternal.h" // For parsing information request class vtkDataSet; class vtkDataArraySelection; class vtkCallbackCommand; +namespace CGNSRead +{ +class vtkCGNSMetaData; +} + class vtkMultiProcessController; class VTKPVVTKEXTENSIONSCGNSREADER_EXPORT vtkCGNSReader : public vtkMultiBlockDataSetAlgorithm { @@ -136,51 +140,21 @@ class VTKPVVTKEXTENSIONSCGNSREADER_EXPORT vtkCGNSReader : public vtkMultiBlockDa void* clientdata, void* calldata); int GetCurvilinearZone(int base, int zone, - int cell_dim, int phys_dim, cgsize_t *zsize, + int cell_dim, int phys_dim, void *zsize, vtkMultiBlockDataSet *mbase); int GetUnstructuredZone(int base, int zone, - int cell_dim, int phys_dim, cgsize_t *zsize, + int cell_dim, int phys_dim, void *zsize, vtkMultiBlockDataSet *mbase); vtkMultiProcessController* Controller; vtkIdType ProcRank; vtkIdType ProcSize; -#ifndef __WRAP__ - bool IsVarEnabled(CGNS_ENUMT(GridLocation_t) varcentering, - const CGNSRead::char_33 name); - - int getGridAndSolutionName(int base, - CGNSRead::char_33 GridCoordName, CGNSRead::char_33 SolutionName, - bool& readGridCoordName, bool& readSolutionName); - - int getCoordsIdAndFillRind(const CGNSRead::char_33 GridCoordName, - const int physicalDim, std::size_t& nCoordsArray, - std::vector& gridChildId, int* rind); - - int getVarsIdAndFillRind(const double cgioSolId, - std::size_t& nVarArray, CGNS_ENUMT(GridLocation_t)& varCentering, - std::vector& solChildId, int* rind); - - int fillArrayInformation(const std::vector& solChildId, - const int physicalDim, - std::vector< CGNSRead::CGNSVariable >& cgnsVars, - std::vector< CGNSRead::CGNSVector >& cgnsVectors); - - int AllocateVtkArray(const int physicalDim, const vtkIdType nVals, - const CGNS_ENUMT(GridLocation_t) varCentering, - const std::vector< CGNSRead::CGNSVariable >& cgnsVars, - const std::vector< CGNSRead::CGNSVector >& cgnsVectors, - std::vector& vtkVars); - - int AttachReferenceValue(const int base, vtkDataSet* ds); -#endif - private: vtkCGNSReader(const vtkCGNSReader&); // Not implemented. void operator=(const vtkCGNSReader&); // Not implemented. - CGNSRead::vtkCGNSMetaData Internal; // Metadata + CGNSRead::vtkCGNSMetaData *Internal; // Metadata char *FileName; // cgns file name int LoadBndPatch; // option to set section loading for unstructured grid @@ -194,6 +168,9 @@ class VTKPVVTKEXTENSIONSCGNSREADER_EXPORT vtkCGNSReader : public vtkMultiBlockDa // unsigned int NumberOfBases; int ActualTimeStep; + + class vtkPrivate; + friend class vtkPrivate; }; #endif // vtkCGNSReader_h From 0de03c49140632c518424a4947f7aba86951340a Mon Sep 17 00:00:00 2001 From: Menno Deij - van Rijswijk Date: Mon, 7 Mar 2016 11:14:10 +0100 Subject: [PATCH 08/29] Added CGNS_ENUMV(NGON_n). Applied diffs from code review. --- ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx index 3fd00bc293c..0b7296c4a11 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx +++ b/ParaViewCore/VTKExtensions/CGNSReader/vtkCGNSReader.cxx @@ -1777,7 +1777,7 @@ int vtkCGNSReader::GetUnstructuredZone(int base, int zone, // the documentation specifies that the faces of NFACE_n are always in NGON_n // format, so look for another section that has that element type. if (osec == sec) continue; // skip self - if (sectionInfoList[osec].elemType == NGON_n) + if (sectionInfoList[osec].elemType == CGNS_ENUMV(NGON_n)) { fDataSize = sectionInfoList[osec].eDataSize; // resize to fit the next batch of element connectivity values From 27115ba986b78de9426aff3d6c8e3db9f14669cd Mon Sep 17 00:00:00 2001 From: Alberto Valverde Date: Tue, 8 Mar 2016 19:47:15 +0100 Subject: [PATCH 09/29] Removed hard-coded path of VTK_BINARY_DIR --- Wrapping/Python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wrapping/Python/CMakeLists.txt b/Wrapping/Python/CMakeLists.txt index 4c669f78922..571cb4a074c 100644 --- a/Wrapping/Python/CMakeLists.txt +++ b/Wrapping/Python/CMakeLists.txt @@ -45,7 +45,7 @@ set(_vtkpy_modules # bug, the dependency wasn't being setup properly. Hence we directly depend on # the generated file. Once Ninja or Cmake is fixed, we can remove this file # depedency and leave the target dependecy. - ${CMAKE_BINARY_DIR}/VTK/Wrapping/Python/vtk_compile_complete + ${VTK_BINARY_DIR}/Wrapping/Python/vtk_compile_complete vtkpython_pyc ) if (TARGET vtkWebPython) From 0284bf37a4760ed86f35fbebdc2e411163b08508 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Wed, 9 Mar 2016 14:44:50 -0500 Subject: [PATCH 10/29] Use `vtk_module_link_libraries` for modules. This ensures that the linked libraries work as expected when Kits are enabled. --- ParaViewCore/VTKExtensions/CGNSReader/CMakeLists.txt | 3 +-- ParaViewCore/VTKExtensions/CosmoTools/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ParaViewCore/VTKExtensions/CGNSReader/CMakeLists.txt b/ParaViewCore/VTKExtensions/CGNSReader/CMakeLists.txt index 5cf6d8827c5..0fca83eca2c 100644 --- a/ParaViewCore/VTKExtensions/CGNSReader/CMakeLists.txt +++ b/ParaViewCore/VTKExtensions/CGNSReader/CMakeLists.txt @@ -57,5 +57,4 @@ set_source_files_properties( ) vtk_module_library(vtkPVVTKExtensionsCGNSReader ${Module_SRCS}) -target_link_libraries(vtkPVVTKExtensionsCGNSReader - LINK_PRIVATE ${CGNS_LIBRARIES}) +vtk_module_link_libraries(vtkPVVTKExtensionsCGNSReader LINK_PRIVATE ${CGNS_LIBRARIES}) diff --git a/ParaViewCore/VTKExtensions/CosmoTools/CMakeLists.txt b/ParaViewCore/VTKExtensions/CosmoTools/CMakeLists.txt index 50ed9d366e6..b7fbc7776c6 100644 --- a/ParaViewCore/VTKExtensions/CosmoTools/CMakeLists.txt +++ b/ParaViewCore/VTKExtensions/CosmoTools/CMakeLists.txt @@ -50,7 +50,7 @@ set_source_files_properties( vtkGenericIOUtilities PROPERTIES WRAP_EXCLUDE_PYTHON 1) vtk_module_library(vtkPVVTKExtensionsCosmoTools ${Module_SRCS}) -target_link_libraries(vtkPVVTKExtensionsCosmoTools +vtk_module_link_libraries(vtkPVVTKExtensionsCosmoTools LINK_PRIVATE ${CosmoToolsExternalLibs} pthread From 743036cec51232fc847438ce09ed85a9fcf7d822 Mon Sep 17 00:00:00 2001 From: Cory Quammen Date: Fri, 4 Mar 2016 15:39:48 -0500 Subject: [PATCH 11/29] BUG #16020: restore defaults for repeatable vector properties Repeatable vector properties were not being restored when vtkSMProperty::RestoreToXMLDefaults() was called because no defaults for such properties are typically defined in the proxy XML. This patch handles this case by clearing out the vector elements, setting the size to zero. --- .../ServerManager/Core/vtkSMVectorPropertyTemplate.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ParaViewCore/ServerManager/Core/vtkSMVectorPropertyTemplate.h b/ParaViewCore/ServerManager/Core/vtkSMVectorPropertyTemplate.h index 973991f040e..90cc04a32e8 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMVectorPropertyTemplate.h +++ b/ParaViewCore/ServerManager/Core/vtkSMVectorPropertyTemplate.h @@ -318,6 +318,13 @@ class vtkSMVectorPropertyTemplate this->Property->Modified(); this->ClearUncheckedElements(); } + else if (this->Property->GetRepeatable()) + { + this->Values.clear(); + this->Initialized = true; + this->Property->Modified(); + this->ClearUncheckedElements(); + } } //--------------------------------------------------------------------------- From ac4f8240da05b78653b28b658a22e3ab5411704b Mon Sep 17 00:00:00 2001 From: Cory Quammen Date: Wed, 9 Mar 2016 21:49:37 -0500 Subject: [PATCH 12/29] Added another acceptable condition for setting property elements Make setting of vtkSMDoubleVectorProperty elements consistent with setting of vtkSMIntVectorProperties when the property is repeatable. This fixes a bug that made it impossible to change double vector properties to zero elements, e.g., clearing out the Isosurface values in the Contour filter. --- Qt/Core/pqSMAdaptor.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Qt/Core/pqSMAdaptor.cxx b/Qt/Core/pqSMAdaptor.cxx index f2cfb97919e..65e3283063a 100644 --- a/Qt/Core/pqSMAdaptor.cxx +++ b/Qt/Core/pqSMAdaptor.cxx @@ -1269,14 +1269,14 @@ void pqSMAdaptor::setMultipleElementProperty(vtkSMProperty* Property, if(Type == CHECKED) { - if (num > 0) + if (num > 0 || dvp->GetRepeatable()) { dvp->SetElements(dvalues, num); } } else if(Type == UNCHECKED) { - if (num > 0) + if (num > 0 || dvp->GetRepeatable()) { dvp->SetUncheckedElements(dvalues, num); } From e50f93482a0b1870018f489554e902b2991af165 Mon Sep 17 00:00:00 2001 From: Cory Quammen Date: Wed, 9 Mar 2016 22:01:39 -0500 Subject: [PATCH 13/29] When resetting values, reset to default rather than XML default This causes properties with domain defaults to be reset to the domain default. If no domain default is available, it uses the XML default. --- Qt/Components/pqProxyWidget.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Qt/Components/pqProxyWidget.cxx b/Qt/Components/pqProxyWidget.cxx index 8d2584319db..add81941b05 100644 --- a/Qt/Components/pqProxyWidget.cxx +++ b/Qt/Components/pqProxyWidget.cxx @@ -1312,7 +1312,7 @@ bool pqProxyWidget::restoreDefaults() { anyReset = true; } - smproperty->ResetToXMLDefaults(); + smproperty->ResetToDefault(); } } } From fcd0436baf1de0c985d1f54740d713582de70f81 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Sat, 12 Mar 2016 13:18:38 -0500 Subject: [PATCH 14/29] Remove unused header. --- ParaViewCore/VTKExtensions/Rendering/vtkPVGeometryFilter.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/ParaViewCore/VTKExtensions/Rendering/vtkPVGeometryFilter.cxx b/ParaViewCore/VTKExtensions/Rendering/vtkPVGeometryFilter.cxx index ee1ca12fe2c..b916792cdd8 100644 --- a/ParaViewCore/VTKExtensions/Rendering/vtkPVGeometryFilter.cxx +++ b/ParaViewCore/VTKExtensions/Rendering/vtkPVGeometryFilter.cxx @@ -22,7 +22,6 @@ #include "vtkCellData.h" #include "vtkCellTypes.h" #include "vtkCellIterator.h" -#include "vtkCleanArrays.h" #include "vtkCommand.h" #include "vtkCompositeDataPipeline.h" #include "vtkCompositeDataSet.h" From 080622a20041c497d0e5c5a2a3aa20fd6d4d1e8c Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Sat, 12 Mar 2016 13:51:22 -0500 Subject: [PATCH 15/29] vtkCleanArrays now support cleaning composite datasets. vtkCleanArrays now allows removing/filling of partial arrays for composite datasets as well. That way, the filter can now be used to sycn arrays on composite datasets locally or in parallel along with non-composite datasets in parallel. Added a new test "TestCleanArrays" to test this filter. --- .../Default/Testing/Python/CMakeLists.txt | 1 + .../Default/Testing/Python/TestCleanArrays.py | 108 ++++++++ .../Rendering/vtkCleanArrays.cxx | 239 ++++++++++++------ .../VTKExtensions/Rendering/vtkCleanArrays.h | 14 +- 4 files changed, 277 insertions(+), 85 deletions(-) create mode 100644 ParaViewCore/ServerManager/Default/Testing/Python/TestCleanArrays.py diff --git a/ParaViewCore/ServerManager/Default/Testing/Python/CMakeLists.txt b/ParaViewCore/ServerManager/Default/Testing/Python/CMakeLists.txt index 6c8146adf20..b081f8f70f7 100644 --- a/ParaViewCore/ServerManager/Default/Testing/Python/CMakeLists.txt +++ b/ParaViewCore/ServerManager/Default/Testing/Python/CMakeLists.txt @@ -139,6 +139,7 @@ if (PARAVIEW_USE_MPI AND VTK_MPIRUN_EXE AND NOT WIN32) --symmetric) paraview_add_test_pvbatch_mpi( NO_DATA NO_OUTPUT NO_VALID + TestCleanArrays.py TestMPI4PY.py ParallelPythonImport.py ) diff --git a/ParaViewCore/ServerManager/Default/Testing/Python/TestCleanArrays.py b/ParaViewCore/ServerManager/Default/Testing/Python/TestCleanArrays.py new file mode 100644 index 00000000000..62b289de0bf --- /dev/null +++ b/ParaViewCore/ServerManager/Default/Testing/Python/TestCleanArrays.py @@ -0,0 +1,108 @@ +from __future__ import print_function + +import vtk +from vtk.vtkPVVTKExtensionsRendering import vtkCleanArrays +cntrl = vtk.vtkMultiProcessController.GetGlobalController() +rank = cntrl.GetLocalProcessId() +numprocs = cntrl.GetNumberOfProcesses() + +#----------------------------------------------------------------------------- +if rank == 0: + print("Testing on non-composite dataset") + +def get_dataset(pa=None,ca=None): + sphere = vtk.vtkSphereSource() + sphere.Update() + + data = sphere.GetOutputDataObject(0) + data.GetPointData().Initialize() + data.GetCellData().Initialize() + + if pa: + array = vtk.vtkIntArray() + array.SetName(pa) + array.SetNumberOfTuples(data.GetNumberOfPoints()) + data.GetPointData().AddArray(array) + + if ca: + array = vtk.vtkIntArray() + array.SetName(ca) + array.SetNumberOfTuples(data.GetNumberOfCells()) + data.GetCellData().AddArray(array) + return data + + +data = get_dataset("PD-%d" % rank, "CD-%d" % rank) +cleanArrays = vtkCleanArrays() +cleanArrays.SetInputDataObject(data) +cleanArrays.SetController(cntrl) + +# Test removing partial arrays. +cleanArrays.FillPartialArraysOff() +cleanArrays.Update() +result = cleanArrays.GetOutputDataObject(0) + +# Each rank tests the next ranks data. +if numprocs > 1: + assert result.GetPointData().GetArray("PD-%d" % ((rank+1)%numprocs)) is None and \ + result.GetCellData().GetArray("CD-%d" % ((rank+1)%numprocs)) is None + +# Test filling partial arrays. +cleanArrays.FillPartialArraysOn() +cleanArrays.Update() +result = cleanArrays.GetOutputDataObject(0) + +# Each rank tests the next ranks data. +assert result.GetPointData().GetNumberOfArrays() == numprocs and \ + result.GetCellData().GetNumberOfArrays() == numprocs + +assert result.GetPointData().GetArray("PD-%d" % ((rank+1)%numprocs)) is not None and \ + result.GetCellData().GetArray("CD-%d" % ((rank+1)%numprocs)) is not None + + +#----------------------------------------------------------------------------- +if rank == 0: + print("Testing on composite dataset") + + +#----------------------------------------------------------------------------- +# Dataset with identical arrays for non-empty datasets on all ranks. +mb = vtk.vtkMultiBlockDataSet() +mb.SetNumberOfBlocks(numprocs) +mb.SetBlock(rank, get_dataset(pa="pa", ca="ca")) + +cleanArrays.SetInputDataObject(mb) +cleanArrays.FillPartialArraysOff() +cleanArrays.Update() +result = cleanArrays.GetOutputDataObject(0) +assert result.GetBlock(rank).GetPointData().GetNumberOfArrays() == 1 and \ + result.GetBlock(rank).GetCellData().GetNumberOfArrays() == 1 + +cleanArrays.FillPartialArraysOn() +cleanArrays.Update() +result = cleanArrays.GetOutputDataObject(0) +assert result.GetBlock(rank).GetPointData().GetNumberOfArrays() == 1 and \ + result.GetBlock(rank).GetCellData().GetNumberOfArrays() == 1 + +#----------------------------------------------------------------------------- +# Dataset with partial arrays for non-empty datasets on all ranks. +mb = vtk.vtkMultiBlockDataSet() +mb.SetNumberOfBlocks(2*numprocs) +mb.SetBlock(rank, get_dataset(pa="pa-%d" % rank, ca="ca-%d" % rank)) +# Let's add an extra block with new arrays so the test can work even when +# numprocs == 1. +mb.SetBlock(numprocs + rank, get_dataset(pa="pa", ca="ca")) + +cleanArrays.SetInputDataObject(mb) +cleanArrays.FillPartialArraysOff() +cleanArrays.Update() +result = cleanArrays.GetOutputDataObject(0) +assert result.GetBlock(rank).GetPointData().GetNumberOfArrays() == 0 and \ + result.GetBlock(rank).GetCellData().GetNumberOfArrays() == 0 + +cleanArrays.FillPartialArraysOn() +cleanArrays.Update() +result = cleanArrays.GetOutputDataObject(0) +assert result.GetBlock(rank).GetPointData().GetNumberOfArrays() == (numprocs+1) and \ + result.GetBlock(rank).GetCellData().GetNumberOfArrays() == (numprocs+1) +print("%d-Passed!" % rank) diff --git a/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.cxx b/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.cxx index 60b4ad82533..7717febb47f 100644 --- a/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.cxx +++ b/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.cxx @@ -16,19 +16,51 @@ #include "vtkAbstractArray.h" #include "vtkCellData.h" +#include "vtkCompositeDataIterator.h" +#include "vtkCompositeDataSet.h" +#include "vtkDataArray.h" #include "vtkMultiProcessController.h" #include "vtkMultiProcessControllerHelper.h" #include "vtkMultiProcessStream.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" -#include "vtkDataSet.h" -#include "vtkDataArray.h" #include #include #include #include +inline bool vtkSkipAttributeType(int attr) +{ + return (attr == vtkDataObject::POINT_THEN_CELL); +} + +inline void vtkShallowCopy(vtkDataObject* output, vtkDataObject* input) +{ + vtkCompositeDataSet* cdout = vtkCompositeDataSet::SafeDownCast(output); + if (cdout == NULL) + { + output->ShallowCopy(input); + return; + } + + // We can't use vtkCompositeDataSet::ShallowCopy() since that simply passes + // the leaf datasets without actually shallowcopying them. That doesn't work + // in our case since we will be modifying the datasets in the output. + vtkCompositeDataSet* cdin = vtkCompositeDataSet::SafeDownCast(input); + cdout->CopyStructure(cdin); + vtkSmartPointer initer; + initer.TakeReference(cdin->NewIterator()); + for (initer->InitTraversal(); !initer->IsDoneWithTraversal(); initer->GoToNextItem()) + { + vtkDataObject* in = initer->GetCurrentDataObject(); + vtkDataObject* clone = in->NewInstance(); + clone->ShallowCopy(in); + cdout->SetDataSet(initer, clone); + clone->FastDelete(); + } +} + vtkStandardNewMacro(vtkCleanArrays); vtkCxxSetObjectMacro(vtkCleanArrays, Controller, vtkMultiProcessController); //---------------------------------------------------------------------------- @@ -118,10 +150,43 @@ class vtkCleanArrays::vtkArraySet : public std::setValid = 1; } + void Intersection(const vtkArraySet& other) + { + if (this->Valid && other.Valid) + { + vtkCleanArrays::vtkArraySet setC; + std::set_intersection(this->begin(), this->end(), + other.begin(), other.end(), + std::inserter(setC, setC.begin())); + setC.MarkValid(); + this->swap(setC); + } + else if (other.Valid) + { + *this = other; + } + } + void Union(const vtkArraySet& other) + { + if (this->Valid && other.Valid) + { + vtkCleanArrays::vtkArraySet setC; + std::set_union(this->begin(), this->end(), + other.begin(), other.end(), + std::inserter(setC, setC.begin())); + setC.MarkValid(); + this->swap(setC); + } + else if (other.Valid) + { + *this = other; + } + } + // Fill up \c this with arrays from \c dsa - void Initialize(vtkDataSet* ds, vtkFieldData* dsa) + void Initialize(vtkFieldData* dsa) { - this->Valid = (ds->GetNumberOfPoints() > 0)? 1 : 0; + this->Valid = true; int numArrays = dsa->GetNumberOfArrays(); if (dsa->GetNumberOfTuples() == 0) { @@ -140,12 +205,13 @@ class vtkCleanArrays::vtkArraySet : public std::setValid == 0) { return; } + vtkArraySet myself = (*this); int numArrays = dsa->GetNumberOfArrays(); for (int cc=numArrays-1; cc >= 0; cc--) { @@ -154,19 +220,19 @@ class vtkCleanArrays::vtkArraySet : public std::setfind(mda) == this->end()) + if (myself.find(mda) == myself.end()) { //cout << "Removing: " << array->GetName() << endl; dsa->RemoveArray(array->GetName()); } else { - this->erase(mda); + myself.erase(mda); } } } // Now fill any missing arrays. - for (iterator iter = this->begin(); iter != this->end(); ++iter) + for (iterator iter = myself.begin(); iter != myself.end(); ++iter) { vtkAbstractArray* array = iter->NewArray(dsa->GetNumberOfTuples()); if (array) @@ -220,35 +286,17 @@ class vtkCleanArrays::vtkArraySet : public std::setShallowCopy(input); + vtkDataObject* inputDO = vtkDataObject::GetData(inputVector[0], 0); + vtkDataObject* outputDO = vtkDataObject::GetData(outputVector, 0); + vtkShallowCopy(outputDO, inputDO); + vtkCompositeDataSet* outputCD = vtkCompositeDataSet::SafeDownCast(outputDO); vtkMultiProcessController* controller = this->Controller; - if (!controller || controller->GetNumberOfProcesses() <= 1) + if ( (!controller || controller->GetNumberOfProcesses() <= 1) && outputCD == NULL) { - // Nothing to do since not running in parallel. + // Nothing to do since not running in parallel or on composite datasets. return 1; } - vtkCleanArrays::vtkArraySet pdSet; - vtkCleanArrays::vtkArraySet cdSet; - pdSet.Initialize(output, output->GetPointData()); - cdSet.Initialize(output, output->GetCellData()); - - vtkMultiProcessStream pdStream; - vtkMultiProcessStream cdStream; - pdSet.Save(pdStream); - cdSet.Save(cdStream); + // Build the array sets for all attribute types across all blocks (if any). + vtkCleanArrays::vtkArraySet arraySets[vtkDataObject::NUMBER_OF_ATTRIBUTE_TYPES]; + if (outputCD) + { + vtkSmartPointer iter; + iter.TakeReference(outputCD->NewIterator()); + for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) + { + vtkDataObject* dobj = iter->GetCurrentDataObject(); + for (int attr=0; attr < vtkDataObject::NUMBER_OF_ATTRIBUTE_TYPES; attr++) + { + if (vtkSkipAttributeType(attr)) { continue; } + if (dobj->GetNumberOfElements(attr) > 0) + { + vtkCleanArrays::vtkArraySet myset; + myset.Initialize(dobj->GetAttributesAsFieldData(attr)); + if (this->FillPartialArrays) + { + arraySets[attr].Union(myset); + } + else + { + arraySets[attr].Intersection(myset); + } + } + } + } + } + else + { + for (int attr=0; attr < vtkDataObject::NUMBER_OF_ATTRIBUTE_TYPES; attr++) + { + if (vtkSkipAttributeType(attr)) { continue; } + if (outputDO->GetNumberOfElements(attr) > 0) + { + arraySets[attr].Initialize(outputDO->GetAttributesAsFieldData(attr)); + } + } + } - vtkMultiProcessControllerHelper::ReduceToAll( - controller, - pdStream, - this->FillPartialArrays ? ::UnionStreams : ::IntersectStreams, - 1278392); - vtkMultiProcessControllerHelper::ReduceToAll( - controller, - cdStream, - this->FillPartialArrays ? ::UnionStreams : ::IntersectStreams, - 1278393); - pdSet.Load(pdStream); - cdSet.Load(cdStream); + if (controller && controller->GetNumberOfProcesses() > 1) + { + for (int attr=0; attr < vtkDataObject::NUMBER_OF_ATTRIBUTE_TYPES; attr++) + { + if (vtkSkipAttributeType(attr)) { continue; } + vtkMultiProcessStream mstream; + arraySets[attr].Save(mstream); + vtkMultiProcessControllerHelper::ReduceToAll( + controller, + mstream, + this->FillPartialArrays ? ::UnionStreams : ::IntersectStreams, + 1278392 + attr); + arraySets[attr].Load(mstream); + } + } - cdSet.UpdateFieldData(output->GetCellData()); - pdSet.UpdateFieldData(output->GetPointData()); + if (outputCD) + { + vtkSmartPointer iter; + iter.TakeReference(outputCD->NewIterator()); + for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) + { + vtkDataObject* dobj = iter->GetCurrentDataObject(); + for (int attr=0; attr < vtkDataObject::NUMBER_OF_ATTRIBUTE_TYPES; attr++) + { + if (vtkSkipAttributeType(attr)) { continue; } + arraySets[attr].UpdateFieldData(dobj->GetAttributesAsFieldData(attr)); + } + } + } + else + { + for (int attr=0; attr < vtkDataObject::NUMBER_OF_ATTRIBUTE_TYPES; attr++) + { + if (vtkSkipAttributeType(attr)) { continue; } + arraySets[attr].UpdateFieldData(outputDO->GetAttributesAsFieldData(attr)); + } + } return 1; } @@ -335,5 +418,3 @@ void vtkCleanArrays::PrintSelf(ostream& os, vtkIndent indent) os << indent << "FillPartialArrays: " << this->FillPartialArrays << endl; os << indent << "Controller: " << this->Controller << endl; } - - diff --git a/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.h b/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.h index c124139905e..543f8e66652 100644 --- a/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.h +++ b/ParaViewCore/VTKExtensions/Rendering/vtkCleanArrays.h @@ -15,21 +15,23 @@ // .NAME vtkCleanArrays - filter used to remove partial arrays across processes. // .SECTION Description // vtkCleanArrays is a filter used to remove (or fill up) partial arrays in a -// vtkDataSet across processes. Empty dataset on any processes is ignored i.e. -// it does not affect the arrays on any processes. +// vtkDataSet (or a vtkCompositeDataSet) across processes (and blocks). +// Empty dataset on any processes is skipped and doesn't affect the array pruned +// (or filled) in the output. This filter also handles certain non-composite +// data objects such a tables. +// #ifndef vtkCleanArrays_h #define vtkCleanArrays_h -#include "vtkDataSetAlgorithm.h" +#include "vtkPassInputTypeAlgorithm.h" #include "vtkPVVTKExtensionsRenderingModule.h" // needed for export macro class vtkMultiProcessController; - -class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkCleanArrays : public vtkDataSetAlgorithm +class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkCleanArrays : public vtkPassInputTypeAlgorithm { public: static vtkCleanArrays* New(); - vtkTypeMacro(vtkCleanArrays, vtkDataSetAlgorithm); + vtkTypeMacro(vtkCleanArrays, vtkPassInputTypeAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); // Description: From f136c67152a8902879d09ef35669ef9ff39ff7c4 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Mon, 7 Mar 2016 13:44:31 -0500 Subject: [PATCH 16/29] BUG #15167: Show multiple blocks in spreadsheet view. Spreadsheet representation now allows the user to choose multiple blocks from a composite dataset to be shown in the view. Multiple blocks are merged and hence will loose partial arrays, if any. To still support picking the default value as the first non-empty leaf node for Spreadsheet representation, added a mechanism to vtkSMCompositeTreeDomain to select a default mode. --- .../vtkSpreadSheetRepresentation.cxx | 25 ++++++--- .../Rendering/vtkSpreadSheetRepresentation.h | 22 +++++++- .../Core/vtkSMCompositeTreeDomain.cxx | 30 +++++++++- .../Core/vtkSMCompositeTreeDomain.h | 44 +++++++++++++-- .../Resources/views_and_representations.xml | 30 ++++++---- .../vtkBlockDeliveryPreprocessor.cxx | 56 +++++++++++++++---- .../Rendering/vtkBlockDeliveryPreprocessor.h | 11 ++-- 7 files changed, 172 insertions(+), 46 deletions(-) diff --git a/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.cxx b/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.cxx index 4012876008f..1a508f59d42 100644 --- a/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.cxx +++ b/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.cxx @@ -15,6 +15,7 @@ #include "vtkSpreadSheetRepresentation.h" #include "vtkBlockDeliveryPreprocessor.h" +#include "vtkCleanArrays.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" @@ -25,18 +26,16 @@ vtkStandardNewMacro(vtkSpreadSheetRepresentation); vtkSpreadSheetRepresentation::vtkSpreadSheetRepresentation() { this->SetNumberOfInputPorts(3); - this->DataConditioner = vtkBlockDeliveryPreprocessor::New(); this->DataConditioner->SetGenerateOriginalIds(1); + this->CleanArrays->SetInputConnection(this->DataConditioner->GetOutputPort()); - this->ExtractedDataConditioner = vtkBlockDeliveryPreprocessor::New(); this->ExtractedDataConditioner->SetGenerateOriginalIds(0); + this->ExtractedCleanArrays->SetInputConnection(this->ExtractedDataConditioner->GetOutputPort()); } //---------------------------------------------------------------------------- vtkSpreadSheetRepresentation::~vtkSpreadSheetRepresentation() { - this->DataConditioner->Delete(); - this->ExtractedDataConditioner->Delete(); } //---------------------------------------------------------------------------- @@ -54,10 +53,18 @@ int vtkSpreadSheetRepresentation::GetFieldAssociation() } //---------------------------------------------------------------------------- -void vtkSpreadSheetRepresentation::SetCompositeDataSetIndex(int val) +void vtkSpreadSheetRepresentation::AddCompositeDataSetIndex(unsigned int val) { - this->DataConditioner->SetCompositeDataSetIndex(val); - this->ExtractedDataConditioner->SetCompositeDataSetIndex(val); + this->DataConditioner->AddCompositeDataSetIndex(val); + this->ExtractedDataConditioner->AddCompositeDataSetIndex(val); + this->MarkModified(); +} + +//---------------------------------------------------------------------------- +void vtkSpreadSheetRepresentation::RemoveAllCompositeDataSetIndices() +{ + this->DataConditioner->RemoveAllCompositeDataSetIndices(); + this->ExtractedDataConditioner->RemoveAllCompositeDataSetIndices(); this->MarkModified(); } @@ -115,14 +122,14 @@ int vtkSpreadSheetRepresentation::RequestData( vtkAlgorithmOutput* vtkSpreadSheetRepresentation::GetDataProducer() { return this->DataConditioner->GetNumberOfInputConnections(0)==1? - this->DataConditioner->GetOutputPort(0) : NULL; + this->CleanArrays->GetOutputPort(0) : NULL; } //---------------------------------------------------------------------------- vtkAlgorithmOutput* vtkSpreadSheetRepresentation::GetExtractedDataProducer() { return this->ExtractedDataConditioner->GetNumberOfInputConnections(0)==1? - this->ExtractedDataConditioner->GetOutputPort(0) : NULL; + this->ExtractedCleanArrays->GetOutputPort(0) : NULL; } //---------------------------------------------------------------------------- diff --git a/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.h b/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.h index deb52ef0e0e..fc6f337cfe4 100644 --- a/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.h +++ b/ParaViewCore/ClientServerCore/Rendering/vtkSpreadSheetRepresentation.h @@ -29,8 +29,10 @@ #include "vtkPVClientServerCoreRenderingModule.h" //needed for exports #include "vtkPVDataRepresentation.h" +#include "vtkNew.h" // needed for vtkNew. class vtkBlockDeliveryPreprocessor; +class vtkCleanArrays; class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkSpreadSheetRepresentation : public vtkPVDataRepresentation { public: @@ -55,7 +57,18 @@ class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkSpreadSheetRepresentation : publi // Forwarded to vtkBlockDeliveryPreprocessor. void SetFieldAssociation(int val); int GetFieldAssociation(); - void SetCompositeDataSetIndex(int val); + + + // Description: + // Select the block indices to extract. + // Each node in the multi-block tree is identified by an \c index. The index can + // be obtained by performing a preorder traversal of the tree (including empty + // nodes). eg. A(B (D, E), C(F, G)). + // Inorder traversal yields: A, B, D, E, C, F, G + // Index of A is 0, while index of C is 4. + void AddCompositeDataSetIndex(unsigned int index); + void RemoveAllCompositeDataSetIndices(); + //BTX protected: @@ -71,8 +84,11 @@ class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkSpreadSheetRepresentation : publi virtual int RequestData( vtkInformation*, vtkInformationVector**, vtkInformationVector*); - vtkBlockDeliveryPreprocessor* DataConditioner; - vtkBlockDeliveryPreprocessor* ExtractedDataConditioner; + vtkNew CleanArrays; + vtkNew DataConditioner; + + vtkNew ExtractedCleanArrays; + vtkNew ExtractedDataConditioner; private: vtkSpreadSheetRepresentation(const vtkSpreadSheetRepresentation&); // Not implemented diff --git a/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.cxx b/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.cxx index 5f612b867e9..29c3d45beb2 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.cxx +++ b/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.cxx @@ -31,6 +31,7 @@ vtkSMCompositeTreeDomain::vtkSMCompositeTreeDomain() this->Information = 0; this->LastInformation = 0; this->Mode = ALL; + this->DefaultMode = DEFAULT; this->Source = 0; this->SourcePort = 0; } @@ -157,6 +158,18 @@ int vtkSMCompositeTreeDomain::ReadXMLAttributes( return 0; } } + if (const char* default_mode = element->GetAttribute("default_mode")) + { + if (strcmp(default_mode, "nonempty-leaf") == 0) + { + this->DefaultMode = NONEMPTY_LEAF; + } + else + { + vtkErrorMacro("Unrecognized 'default_mode': " << mode); + return 0; + } + } return 1; } @@ -167,9 +180,9 @@ int vtkSMCompositeTreeDomain::SetDefaultValues( vtkSMIntVectorProperty* ivp = vtkSMIntVectorProperty::SafeDownCast(property); vtkSMPropertyHelper helper(property); helper.SetUseUnchecked(use_unchecked_values); - if (ivp && this->Information && helper.GetNumberOfElements() == 1) + if (ivp && this->Information) { - if (this->Mode == LEAVES) + if (this->Mode == LEAVES || this->DefaultMode == NONEMPTY_LEAF) { // change the property default to be the first non-empty leaf. vtkPVDataInformation* info = this->Information; @@ -213,6 +226,19 @@ void vtkSMCompositeTreeDomain::PrintSelf(ostream& os, vtkIndent indent) os << "UNKNOWN"; } os << endl; + os << indent << "DefaultMode: "; + switch (this->DefaultMode) + { + case DEFAULT: + os << "DEFAULT"; + break; + case NONEMPTY_LEAF: + os << "NONEMPTY_LEAF"; + break; + default: + os << "UNKNOWN"; + } + os << endl; os << indent << "SourcePort: " << this->SourcePort << endl; } diff --git a/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.h b/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.h index 67290328086..4eeb9b4312c 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.h +++ b/ParaViewCore/ServerManager/Core/vtkSMCompositeTreeDomain.h @@ -23,7 +23,29 @@ // flat index for a tree is obtained by performing a pre-order traversal of the // tree eg. A ( B ( D, E), C (F, G)) becomes: [A,B,D,E,C,F,G], so flat-index of A is // 0, while flat-index of C is 4. - +// +// vtkSMCompositeTreeDomain can be used in multiple modes. +// \li ALL : This mode is used if the property can accept any type of node index. +// To select this mode in XML, use the `mode="all"`. +// \li LEAVES: This mode is used if the property can only accept leaf nodes i.e. +// indices for non-composite datasets. This is specified in XML +// using `mode="leaves"`. +// \li NON_LEAVES: This mode is used if the property can only accept non-leaf +// node indices, specified using `mode="non-leaves"` in XML +// configuration. +// +// vtkSMCompositeTreeDomain also provides ability to set default value on the +// property. If mode is LEAVES, then the default value selected is the first +// non-null leaf node. If mode is ALL, the same behaviour for default value is +// possible by using `default_mode="nonempty-leaf"` in XML. +// e.g. +// \code{.xml} +// +// +// +// +// +// \endcode #ifndef vtkSMCompositeTreeDomain_h #define vtkSMCompositeTreeDomain_h @@ -76,7 +98,6 @@ class VTKPVSERVERMANAGERCORE_EXPORT vtkSMCompositeTreeDomain : public vtkSMDomai vtkGetMacro(Mode, int); vtkSetMacro(Mode, int); - //BTX enum { ALL=0, @@ -84,8 +105,22 @@ class VTKPVSERVERMANAGERCORE_EXPORT vtkSMCompositeTreeDomain : public vtkSMDomai NON_LEAVES=2, NONE=3 }; - //ETX - + + + enum DefaultModes + { + DEFAULT=0, + NONEMPTY_LEAF=1 + }; + + // Description: + // DefaultMode controls how the default value for the property is set by + // SetDefaultValues(). DEFAULT implies the default value is picked based on + // the default strategy for the selected Mode. NONEMPTY_LEAF indicates that + // the first non-empty leaf node is set as the default value, if possible. + vtkGetMacro(DefaultMode, int); + vtkSetMacro(DefaultMode, int); + // Description: // A vtkSMProperty is often defined with a default value in the // XML itself. However, many times, the default value must be determined @@ -118,6 +153,7 @@ class VTKPVSERVERMANAGERCORE_EXPORT vtkSMCompositeTreeDomain : public vtkSMDomai vtkWeakPointer Source; int Mode; + int DefaultMode; int SourcePort; private: vtkSMCompositeTreeDomain(const vtkSMCompositeTreeDomain&); // Not implemented diff --git a/ParaViewCore/ServerManager/SMApplication/Resources/views_and_representations.xml b/ParaViewCore/ServerManager/SMApplication/Resources/views_and_representations.xml index b4e35d5c0a6..4b284431966 100644 --- a/ParaViewCore/ServerManager/SMApplication/Resources/views_and_representations.xml +++ b/ParaViewCore/ServerManager/SMApplication/Resources/views_and_representations.xml @@ -7140,21 +7140,29 @@ - - In case of Composite datasets, set the flat index of the - dataset to pass. The flat index must point to a non-empty, - non-composite dataset for anything to be passed through. If the input - is not a composite dataset, then this index is ignored. - + number_of_elements_per_command="1" + panel_visibility="default" + repeat_command="1"> + - + + + + + + In case of composite datasets, set the list of flat indices to + show in the spreadsheet view. If the input is not a composite dataset + the value is ignored. If nothing is selected for composite dataset, it + is same as selecting the root node i.e. all blocks in the dataset. + Note, then multiple blocks are being shown in the spreadsheet view, + partial arrays, if any are skipped. + + +class vtkBlockDeliveryPreprocessor::CompositeDataSetIndicesType : + public std::set +{ +}; + vtkStandardNewMacro(vtkBlockDeliveryPreprocessor); //---------------------------------------------------------------------------- vtkBlockDeliveryPreprocessor::vtkBlockDeliveryPreprocessor() { - this->CompositeDataSetIndex = 0; this->FieldAssociation = vtkDataObject::FIELD_ASSOCIATION_POINTS; this->FlattenTable = 0; this->GenerateOriginalIds = true; this->GenerateCellConnectivity = false; + this->CompositeDataSetIndices = new CompositeDataSetIndicesType(); } //---------------------------------------------------------------------------- vtkBlockDeliveryPreprocessor::~vtkBlockDeliveryPreprocessor() { + delete this->CompositeDataSetIndices; +} + +//---------------------------------------------------------------------------- +void vtkBlockDeliveryPreprocessor::AddCompositeDataSetIndex(unsigned int index) +{ + if (this->CompositeDataSetIndices->find(index) == this->CompositeDataSetIndices->end()) + { + this->CompositeDataSetIndices->insert(index); + this->Modified(); + } +} + +//---------------------------------------------------------------------------- +void vtkBlockDeliveryPreprocessor::RemoveAllCompositeDataSetIndices() +{ + if (this->CompositeDataSetIndices->size() > 0) + { + this->CompositeDataSetIndices->clear(); + this->Modified(); + } } //---------------------------------------------------------------------------- @@ -93,8 +122,6 @@ int vtkBlockDeliveryPreprocessor::RequestData(vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { - //cout << "vtkBlockDeliveryPreprocessor::CompositeDataSetIndex: " - // << this->CompositeDataSetIndex << endl; vtkDataObject* inputDO = vtkDataObject::GetData(inputVector[0], 0); vtkDataObject* outputDO = vtkDataObject::GetData(outputVector, 0); @@ -124,27 +151,32 @@ int vtkBlockDeliveryPreprocessor::RequestData(vtkInformation*, split->Update(); } - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast( - outputDO); + vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast(outputDO); if (!output) { outputDO->ShallowCopy(filter->GetOutputDataObject(0)); return 1; } - if (this->CompositeDataSetIndex != 0) + if (this->CompositeDataSetIndices->size() == 0 || + (this->CompositeDataSetIndices->size() == 1 && + (*this->CompositeDataSetIndices->begin()) == 0)) + { + output->ShallowCopy(filter->GetOutputDataObject(0)); + } + else { - vtkSmartPointer eb = vtkSmartPointer::New(); + vtkNew eb; eb->SetInputConnection(filter->GetOutputPort()); - eb->AddIndex(this->CompositeDataSetIndex); + for (CompositeDataSetIndicesType::iterator iter = this->CompositeDataSetIndices->begin(); + iter != this->CompositeDataSetIndices->end(); ++iter) + { + eb->AddIndex(*iter); + } eb->PruneOutputOff(); eb->Update(); output->ShallowCopy(eb->GetOutput()); } - else - { - output->ShallowCopy(filter->GetOutputDataObject(0)); - } // Add meta-data about composite-index/hierarchical index to help // vtkSelectionStreamer. diff --git a/ParaViewCore/VTKExtensions/Rendering/vtkBlockDeliveryPreprocessor.h b/ParaViewCore/VTKExtensions/Rendering/vtkBlockDeliveryPreprocessor.h index 77fcc9f112c..58b8fcc46df 100644 --- a/ParaViewCore/VTKExtensions/Rendering/vtkBlockDeliveryPreprocessor.h +++ b/ParaViewCore/VTKExtensions/Rendering/vtkBlockDeliveryPreprocessor.h @@ -34,10 +34,9 @@ class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkBlockDeliveryPreprocessor : public v // Description: // In case of Composite datasets, set the flat index of the subtree to pass. - // Default is 0 which results in passing the entire composite tree. - vtkSetMacro(CompositeDataSetIndex, unsigned int); - vtkGetMacro(CompositeDataSetIndex, unsigned int); - void SetCompositeDataSetIndex() { this->SetCompositeDataSetIndex(0); } + // Default or empty results in passing the entire composite tree. + void AddCompositeDataSetIndex(unsigned int index); + void RemoveAllCompositeDataSetIndices(); // Description: // Allow user to enable/disable cell connectivity generation in the datamodel @@ -89,13 +88,15 @@ class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkBlockDeliveryPreprocessor : public v vtkInformationVector*); int FieldAssociation; - unsigned int CompositeDataSetIndex; int FlattenTable; bool GenerateOriginalIds; bool GenerateCellConnectivity; private: vtkBlockDeliveryPreprocessor(const vtkBlockDeliveryPreprocessor&); // Not implemented void operator=(const vtkBlockDeliveryPreprocessor&); // Not implemented + + class CompositeDataSetIndicesType; + CompositeDataSetIndicesType *CompositeDataSetIndices; //ETX }; From 5f60463ef808c07ff479df9a6a688015521a06f7 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Wed, 9 Mar 2016 14:27:34 -0500 Subject: [PATCH 17/29] Adding test for testing spreadsheet with multiblock --- .../ParaView/Testing/XML/CMakeLists.txt | 7 ++ .../ParaView/Testing/XML/SpreadSheet3.xml | 71 +++++++++++++++++++ Testing/Data/Baseline/SpreadSheet3.png.md5 | 1 + 3 files changed, 79 insertions(+) create mode 100644 Applications/ParaView/Testing/XML/SpreadSheet3.xml create mode 100644 Testing/Data/Baseline/SpreadSheet3.png.md5 diff --git a/Applications/ParaView/Testing/XML/CMakeLists.txt b/Applications/ParaView/Testing/XML/CMakeLists.txt index 5162fb35017..c3a4b28ab98 100644 --- a/Applications/ParaView/Testing/XML/CMakeLists.txt +++ b/Applications/ParaView/Testing/XML/CMakeLists.txt @@ -285,6 +285,7 @@ list(APPEND TESTS_WITH_BASELINES ${CMAKE_CURRENT_SOURCE_DIR}/SolidColorSource.xml ${CMAKE_CURRENT_SOURCE_DIR}/SpreadSheet1.xml ${CMAKE_CURRENT_SOURCE_DIR}/SpreadSheet2.xml + ${CMAKE_CURRENT_SOURCE_DIR}/SpreadSheet3.xml ${CMAKE_CURRENT_SOURCE_DIR}/SPTimeseries.xml ${CMAKE_CURRENT_SOURCE_DIR}/SpyPlotHistoryReader.xml ${CMAKE_CURRENT_SOURCE_DIR}/SelectionLinkBasic.xml @@ -580,6 +581,12 @@ IF (PARAVIEW_USE_MPI) SET (SpreadSheet1_DISABLE_CS TRUE) SET (SpreadSheet1_DISABLE_CRS TRUE) + # Disabled since the 1 column in spreadsheet view ends up being "Process ID" + # which messes up the sorting in this test. Need to extend the testing framework + # or fix spreadsheet view for these to work properly. + SET (SpreadSheet3_DISABLE_CS TRUE) + SET (SpreadSheet3_DISABLE_CRS TRUE) + # The hierchical fractal source is a temporary testing source and it does not # create the dataset correctly in parallel. Since it's a testing source, I am # just going to disable the test in parallel. We can fix the source when diff --git a/Applications/ParaView/Testing/XML/SpreadSheet3.xml b/Applications/ParaView/Testing/XML/SpreadSheet3.xml new file mode 100644 index 00000000000..17e42b89f34 --- /dev/null +++ b/Applications/ParaView/Testing/XML/SpreadSheet3.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Testing/Data/Baseline/SpreadSheet3.png.md5 b/Testing/Data/Baseline/SpreadSheet3.png.md5 new file mode 100644 index 00000000000..c79763d491c --- /dev/null +++ b/Testing/Data/Baseline/SpreadSheet3.png.md5 @@ -0,0 +1 @@ +044dca08db93e83b1f09bf4c4a440b8d From 03e7e5588faf60af8e8c927ca2262dcb45a70153 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Sun, 13 Mar 2016 16:36:22 -0400 Subject: [PATCH 18/29] Update VTK. Brings in fix for the EnsightGold reader failing to stat() large files on windows. --- VTK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VTK b/VTK index 6c456e0f06c..c5ddf083399 160000 --- a/VTK +++ b/VTK @@ -1 +1 @@ -Subproject commit 6c456e0f06c3babe5fa5ed276f75fccdd2679f8c +Subproject commit c5ddf08339926c734f032bc0058002a5e36e4d5e From 7d13f756367b732e33822bc8b75e0e0efc26d332 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Mon, 14 Mar 2016 11:32:00 -0400 Subject: [PATCH 19/29] Update VTK to master on 2016/03/14. --- VTK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VTK b/VTK index adf0fff8eee..7a8d5dab0e7 160000 --- a/VTK +++ b/VTK @@ -1 +1 @@ -Subproject commit adf0fff8eee76b646b7c1aa2172ea4c0f647b261 +Subproject commit 7a8d5dab0e7face692e54a5acc2cd35522ad225c From 7a35f416868c321b9981b8aab647c21f67e19a14 Mon Sep 17 00:00:00 2001 From: Yumin Yuan Date: Thu, 10 Mar 2016 15:56:18 -0500 Subject: [PATCH 20/29] Update vtk_add_python_wrapping calls to use new signatures --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e16f575765..66ea9effb4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -747,7 +747,9 @@ if (PARAVIEW_ENABLE_PYTHON AND PARAVIEW_ENABLE_CATALYST) list(APPEND VTK_PYTHON_MODULES ${vtk-module}) set(vtkPVPythonCatalyst_HEADERS vtkCPPythonScriptPipeline) - vtk_add_python_wrapping(${vtk-module}) + vtk_add_python_wrapping(${vtk-module} pv_wrapping_sources) + vtk_add_python_wrapping_library(${vtk-module} pv_wrapping_sources ${vtk-module}) + if (BUILD_TESTING) set (_test_module_name "${vtk-module}-Test-Cxx") add_subdirectory( From 85c8699fc8219bd5b92ec0277ffb1c49022718a7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 10 Mar 2016 13:43:03 -0500 Subject: [PATCH 21/29] Python: import the API module, not the Python library When building with Kits, the libraries listed here don't exist. --- Wrapping/Python/paraview/vtk/__init__.py | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Wrapping/Python/paraview/vtk/__init__.py b/Wrapping/Python/paraview/vtk/__init__.py index 28b304a19e7..b5fbb8a8e0c 100644 --- a/Wrapping/Python/paraview/vtk/__init__.py +++ b/Wrapping/Python/paraview/vtk/__init__.py @@ -1,38 +1,38 @@ import paraview try: - from vtkCommonComputationalGeometryPython import * + from vtkCommonComputationalGeometry import * except ImportError: - paraview.print_error("Error: Could not import vtkCommonComputationalGeometryPython") -from vtkCommonCorePython import * -from vtkCommonDataModelPython import * -from vtkCommonExecutionModelPython import * + paraview.print_error("Error: Could not import vtkCommonComputationalGeometry") +from vtkCommonCore import * +from vtkCommonDataModel import * +from vtkCommonExecutionModel import * try: - from vtkCommonMathPython import * + from vtkCommonMath import * except ImportError: - paraview.print_error("Error: Could not import vtkCommonMathPython") + paraview.print_error("Error: Could not import vtkCommonMath") try: - from vtkCommonMiscPython import * + from vtkCommonMisc import * except ImportError: - paraview.print_error("Error: Could not import vtkCommonMiscPython") + paraview.print_error("Error: Could not import vtkCommonMisc") try: - from vtkCommonSystemPython import * + from vtkCommonSystem import * except ImportError: - paraview.print_error("Error: Could not import vtkCommonSystemPython") + paraview.print_error("Error: Could not import vtkCommonSystem") try: - from vtkCommonTransformsPython import * + from vtkCommonTransforms import * except ImportError: - paraview.print_error("Error: Could not import vtkCommonTransformsPython") -from vtkFiltersProgrammablePython import * -from vtkParallelCorePython import * + paraview.print_error("Error: Could not import vtkCommonTransforms") +from vtkFiltersProgrammable import * +from vtkParallelCore import * try: - from vtkRenderingCorePython import vtkCamera + from vtkRenderingCore import vtkCamera except ImportError: - paraview.print_error("Error: Could not import vtkRenderingCorePython") + paraview.print_error("Error: Could not import vtkRenderingCore") try: - from vtkFiltersCorePython import * + from vtkFiltersCore import * except ImportError: - paraview.print_error("Error: Could not import vtkFiltersCorePython") + paraview.print_error("Error: Could not import vtkFiltersCore") # -------------------------------------- From f60c8e791d0605a2cee90b091c04604d70637d48 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 14 Mar 2016 13:16:05 -0400 Subject: [PATCH 22/29] eigen: add a space between strings GCC6 is detecting this as a literal constructor (operator ""X) instead of doing literal string concatenation. A space removes the ambiguity. --- .../eigen-3.0.3/eigen-eigen-3.0.3/Eigen/src/Core/util/Macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/SciberQuestToolKit/eigen-3.0.3/eigen-eigen-3.0.3/Eigen/src/Core/util/Macros.h b/Plugins/SciberQuestToolKit/eigen-3.0.3/eigen-eigen-3.0.3/Eigen/src/Core/util/Macros.h index 2a647cfda5e..93951db1497 100644 --- a/Plugins/SciberQuestToolKit/eigen-3.0.3/eigen-eigen-3.0.3/Eigen/src/Core/util/Macros.h +++ b/Plugins/SciberQuestToolKit/eigen-3.0.3/eigen-eigen-3.0.3/Eigen/src/Core/util/Macros.h @@ -249,7 +249,7 @@ #define EIGEN_UNUSED_VARIABLE(var) (void)var; #if (defined __GNUC__) -#define EIGEN_ASM_COMMENT(X) asm("#"X) +#define EIGEN_ASM_COMMENT(X) asm("#" X) #else #define EIGEN_ASM_COMMENT(X) #endif From 4c467378e1563b96a48b9ade813283d7ff806dca Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Mon, 14 Mar 2016 22:54:02 -0400 Subject: [PATCH 23/29] Cleanup ParaView's python package generation. Avoiding configure time file copying and adding dependencies on source *.py to have them copied and compiled. --- Wrapping/Python/CMakeLists.txt | 154 ++++++++++++------ Wrapping/Python/{paraview => }/cpexport.py.in | 0 Wrapping/Python/paraview/compile_all_pv.py.in | 4 - 3 files changed, 100 insertions(+), 58 deletions(-) rename Wrapping/Python/{paraview => }/cpexport.py.in (100%) delete mode 100644 Wrapping/Python/paraview/compile_all_pv.py.in diff --git a/Wrapping/Python/CMakeLists.txt b/Wrapping/Python/CMakeLists.txt index 4c669f78922..2f001059045 100644 --- a/Wrapping/Python/CMakeLists.txt +++ b/Wrapping/Python/CMakeLists.txt @@ -35,7 +35,6 @@ if (NOT PARAVIEW_ENABLE_PYTHON) return() endif() -set(PV_PYTHON_MODULE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/paraview") set(PV_PYTHON_MODULE_BINARY_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/site-packages/paraview") @@ -51,81 +50,128 @@ set(_vtkpy_modules if (TARGET vtkWebPython) list(APPEND _vtkpy_modules vtkWebPython) endif() + +#------------------------------------------------------------------------------ +# List ParaView *.py files. +set(PV_PYTHON_SOURCE_FILES + paraview/annotation.py + paraview/benchmark.py + paraview/calculator.py + paraview/cinemaIO/cinema_store.py + paraview/cinemaIO/explorers.py + paraview/cinemaIO/__init__.py + paraview/cinemaIO/OexrHelper.py + paraview/cinemaIO/pv_explorers.py + paraview/cinemaIO/pv_introspect.py + paraview/cinemaIO/raster_wrangler.py + paraview/collaboration.py + paraview/coprocessing.py + paraview/cpstate.py + paraview/data_exploration.py + paraview/demos/demo1.py + paraview/demos/show_grid_as_background.py + paraview/extract_selection.py + paraview/__init__.py + paraview/lookuptable.py + paraview/numeric.py + paraview/pvfilters.py + paraview/pvvtkextensions.py + paraview/python_view.py + paraview/servermanager.py + paraview/simple.py + paraview/smstate.py + paraview/smtesting.py + paraview/smtrace.py + paraview/spatiotemporalparallelism.py + paraview/util.py + paraview/variant.py + paraview/vtk/__init__.py + ) + +# This is odd; we shouldnt' need to configure cpexport.py, we can simply fill in +# the version number when cpexport.py is used by the ParaView client. +# Leaving this unchanged for now since don't want to make too many unrelated changes +# here. +configure_file(cpexport.py.in cpexport.py @ONLY) + +#------------------------------------------------------------------------------ add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/vtk_py_copy_completed" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pv_copy_and_compile_py_files_complete" + + # Empty '$pydir/paraview' to remove old files. + COMMAND ${CMAKE_COMMAND} ARGS -E echo "emptying '.../site-packages/paraview'" + COMMAND ${CMAKE_COMMAND} ARGS -E remove_directory "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview" + + COMMAND ${CMAKE_COMMAND} ARGS -E echo "emptying '.../site-packages/vtk'" + COMMAND ${CMAKE_COMMAND} ARGS -E remove_directory "${VTK_BUILD_PYTHON_MODULE_DIR}/vtk" + + COMMAND ${CMAKE_COMMAND} ARGS -E echo "copying paraview/*.py to '.../site-paraview/paraview'" + COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory + "${CMAKE_CURRENT_SOURCE_DIR}/paraview" + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview" + + COMMAND ${CMAKE_COMMAND} ARGS -E copy + "${CMAKE_CURRENT_BINARY_DIR}/cpexport.py" + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview/cpexport.py" + # Copy into $pydir/paraview/vtk. # This is what scripts get when they do "import paraview.vtk". - COMMAND ${CMAKE_COMMAND} ARGS -E echo "copying to ${PV_PYTHON_MODULE_BINARY_DIR}" + COMMAND ${CMAKE_COMMAND} ARGS -E echo "copying VTKs py files to '.../site-packages/paraview/vtk'" COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${VTK_BINARY_DIR}/Wrapping/Python/vtk" - "${PV_PYTHON_MODULE_BINARY_DIR}/vtk" + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview/vtk" + # Overlay that with paraview's customizations. - COMMAND ${CMAKE_COMMAND} ARGS -E echo "overlaying onto ${PV_PYTHON_MODULE_BINARY_DIR}" - COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory - "${CMAKE_CURRENT_SOURCE_DIR}/paraview/vtk" - "${PV_PYTHON_MODULE_BINARY_DIR}/vtk" + COMMAND ${CMAKE_COMMAND} ARGS -E echo "copy minimized __init__.py to '.../site-packages/paraview/vtk'" + COMMAND ${CMAKE_COMMAND} ARGS -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/paraview/vtk/__init__.py" + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview/vtk/__init__.py" # Also copy into $pydir/vtk. - # Scripts that want all of vtk can now "import vtk". - COMMAND ${CMAKE_COMMAND} ARGS -E echo "copying to ${VTK_BUILD_PYTHON_MODULE_DIR}/vtk" + # ParaView (pvpython/pvbatch) scripts that want all of vtk can now "import vtk". + COMMAND ${CMAKE_COMMAND} ARGS -E echo "also copying VTKs py to .../site-packages/vtk" COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${VTK_BINARY_DIR}/Wrapping/Python/vtk" "${VTK_BUILD_PYTHON_MODULE_DIR}/vtk" + # Duplicate a few files from vtk (backwards compatibility) + COMMAND ${CMAKE_COMMAND} -E copy + "${VTK_SOURCE_DIR}/Wrapping/Python/vtk/util/numpy_support.py" + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview/numpy_support.py" + + COMMAND ${CMAKE_COMMAND} -E copy + "${VTK_SOURCE_DIR}/Wrapping/Python/vtk/util/vtkConstants.py" + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview/vtkConstants.py" + + # Now compile the python module files. + COMMAND ${PYTHON_EXECUTABLE} -m compileall -q + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview" + "${VTK_BUILD_PYTHON_MODULE_DIR}/vtk" + + # Copy ColorMaps.xml (obsolete: we should remove this soonish) + COMMAND ${CMAKE_COMMAND} ARGS -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/ColorMaps.xml" + "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview/ColorMaps.xml" + # Touch the OUTPUT file, otherwise this command will always be dirty. - COMMAND ${CMAKE_COMMAND} ARGS -E touch "${CMAKE_CURRENT_BINARY_DIR}/vtk_py_copy_completed" + COMMAND ${CMAKE_COMMAND} ARGS -E touch "${CMAKE_CURRENT_BINARY_DIR}/pv_copy_and_compile_py_files_complete" DEPENDS ${_vtkpy_modules} + "${CMAKE_CURRENT_BINARY_DIR}/cpexport.py" "${VTK_BINARY_DIR}/Wrapping/Python/vtk/__init__.py" + "${VTK_SOURCE_DIR}/Wrapping/Python/vtk/util/numpy_support.py" + "${VTK_SOURCE_DIR}/Wrapping/Python/vtk/util/vtkConstants.py" + "${CMAKE_CURRENT_SOURCE_DIR}/ColorMaps.xml" + ${PV_PYTHON_SOURCE_FILES} ) -add_custom_target(copy_vtk_py_files ALL - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/vtk_py_copy_completed" -) - -# Copy ParaView specific python files -file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/paraview - DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/site-packages - USE_SOURCE_PERMISSIONS - FILES_MATCHING - PATTERN *.py) - -# Copy obsolete ColorMaps.xml for now. -file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/ColorMaps.xml - DESTINATION ${PV_PYTHON_MODULE_BINARY_DIR} - USE_SOURCE_PERMISSIONS) - -# Add a couple of vtk python files to "paraview" module. -file (COPY "${ParaView_SOURCE_DIR}/VTK/Wrapping/Python/vtk/util/numpy_support.py" - "${ParaView_SOURCE_DIR}/VTK/Wrapping/Python/vtk/util/vtkConstants.py" - DESTINATION ${PV_PYTHON_MODULE_BINARY_DIR} - USE_SOURCE_PERMISSIONS) - -# Byte compile the paraview Python files. -configure_file(${PV_PYTHON_MODULE_SOURCE_DIR}/compile_all_pv.py.in - ${PV_PYTHON_MODULE_BINARY_DIR}/compile_all_pv.py - @ONLY IMMEDIATE) - -configure_file(${PV_PYTHON_MODULE_SOURCE_DIR}/cpexport.py.in - ${PV_PYTHON_MODULE_BINARY_DIR}/cpexport.py - @ONLY IMMEDIATE) - - - -add_custom_command( - WORKING_DIRECTORY ${PV_PYTHON_MODULE_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} - ARGS compile_all_pv.py - DEPENDS ${PV_PYTHON_SOURCE_FILES} ${PV_PYTHON_MODULE_BINARY_DIR}/compile_all_pv.py copy_vtk_py_files - ${PV_PYTHON_OUTPUT_FILES} - OUTPUT "${PV_PYTHON_MODULE_BINARY_DIR}/pv_compile_complete" - ) - add_custom_target(paraview_pyc ALL - DEPENDS copy_vtk_py_files "${PV_PYTHON_MODULE_BINARY_DIR}/pv_compile_complete") + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pv_copy_and_compile_py_files_complete") # Install the paraview module files. +# XXX(uda): why are we installing all packages in site-packages? We should only install +# ones we created here i.e. paraview and vtk. install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/site-packages DESTINATION ${VTK_INSTALL_LIBRARY_DIR} COMPONENT Runtime diff --git a/Wrapping/Python/paraview/cpexport.py.in b/Wrapping/Python/cpexport.py.in similarity index 100% rename from Wrapping/Python/paraview/cpexport.py.in rename to Wrapping/Python/cpexport.py.in diff --git a/Wrapping/Python/paraview/compile_all_pv.py.in b/Wrapping/Python/paraview/compile_all_pv.py.in deleted file mode 100644 index 613d84d5833..00000000000 --- a/Wrapping/Python/paraview/compile_all_pv.py.in +++ /dev/null @@ -1,4 +0,0 @@ -import compileall -compileall.compile_dir('@PV_PYTHON_MODULE_BINARY_DIR@') -file = open('@PV_PYTHON_MODULE_BINARY_DIR@/pv_compile_complete', 'w') -file.write('Done') From d179bffca477d449cb16c5844808611f99cff36e Mon Sep 17 00:00:00 2001 From: Max Smolens Date: Mon, 14 Mar 2016 15:14:52 -0400 Subject: [PATCH 24/29] Python: import the API module, not the Python library When building with Kits, the libraries listed here don't exist. --- .../Python/TestPythonParaViewWebMPI.py | 20 ++++++++-------- .../Python/TestPythonParaViewWebiPythonMPI.py | 20 ++++++++-------- .../Core/vtkPythonAnnotationFilter.cxx | 2 +- .../Core/vtkPythonExtractSelection.cxx | 2 +- .../vtkAnnotateAttributeDataFilter.cxx | 2 +- .../Default/vtkAnnotateGlobalDataFilter.cxx | 2 +- .../Default/vtkPythonCalculator.cxx | 2 +- .../Rendering/vtkPythonView.cxx | 2 +- .../Testing/Python/PointGaussianProperties.py | 2 +- .../DataProber/server/pv_web_data_prober.py | 2 +- .../FileViewer/server/pv_web_file_loader.py | 2 +- .../TestApp/server/pv_web_test_app.py | 2 +- Web/Python/paraview/web/helper.py | 4 ++-- Web/Python/paraview/web/ipython.py | 22 ++++++++--------- Web/Python/paraview/web/protocols.py | 12 +++++----- Web/Python/paraview/web/wamp.py | 2 +- Web/Python/paraview/web/webgl.py | 2 +- Wrapping/Python/paraview/coprocessing.py | 2 +- Wrapping/Python/paraview/pvvtkextensions.py | 6 ++--- Wrapping/Python/paraview/python_view.py | 20 ++++++++-------- Wrapping/Python/paraview/servermanager.py | 24 +++++++++---------- Wrapping/Python/paraview/smtesting.py | 2 +- Wrapping/Python/paraview/util.py | 2 +- 23 files changed, 79 insertions(+), 79 deletions(-) diff --git a/Applications/ParaView/Testing/Python/TestPythonParaViewWebMPI.py b/Applications/ParaView/Testing/Python/TestPythonParaViewWebMPI.py index e87744bb3cc..df40445e667 100644 --- a/Applications/ParaView/Testing/Python/TestPythonParaViewWebMPI.py +++ b/Applications/ParaView/Testing/Python/TestPythonParaViewWebMPI.py @@ -14,16 +14,16 @@ from paraview.web import wamp as pv_wamp from paraview.web import ipython as pv_ipython -from vtkCommonCorePython import * -from vtkCommonDataModelPython import * -from vtkCommonExecutionModelPython import * -from vtkFiltersSourcesPython import * -from vtkParallelCorePython import * -from vtkParaViewWebCorePython import * -from vtkPVClientServerCoreCorePython import * -from vtkPVServerManagerApplicationPython import * -from vtkPVServerManagerCorePython import * -from vtkPVVTKExtensionsCorePython import * +from vtk.vtkCommonCore import * +from vtk.vtkCommonDataModel import * +from vtk.vtkCommonExecutionModel import * +from vtk.vtkFiltersSources import * +from vtk.vtkParallelCore import * +from vtk.vtkParaViewWebCore import * +from vtk.vtkPVClientServerCoreCore import * +from vtk.vtkPVServerManagerApplication import * +from vtk.vtkPVServerManagerCore import * +from vtkPVVTKExtensionsCore import * #------------------------------------------------------------------------------ # InLine protocol diff --git a/Applications/ParaView/Testing/Python/TestPythonParaViewWebiPythonMPI.py b/Applications/ParaView/Testing/Python/TestPythonParaViewWebiPythonMPI.py index 3a5afa2e814..f3430cce6e2 100644 --- a/Applications/ParaView/Testing/Python/TestPythonParaViewWebiPythonMPI.py +++ b/Applications/ParaView/Testing/Python/TestPythonParaViewWebiPythonMPI.py @@ -14,16 +14,16 @@ from paraview.web import wamp as pv_wamp from paraview.web import ipython as pv_ipython -from vtkCommonCorePython import * -from vtkCommonDataModelPython import * -from vtkCommonExecutionModelPython import * -from vtkFiltersSourcesPython import * -from vtkParallelCorePython import * -from vtkParaViewWebCorePython import * -from vtkPVClientServerCoreCorePython import * -from vtkPVServerManagerApplicationPython import * -from vtkPVServerManagerCorePython import * -from vtkPVVTKExtensionsCorePython import * +from vtk.vtkCommonCore import * +from vtk.vtkCommonDataModel import * +from vtk.vtkCommonExecutionModel import * +from vtk.vtkFiltersSources import * +from vtk.vtkParallelCore import * +from vtk.vtkParaViewWebCore import * +from vtk.vtkPVClientServerCoreCore import * +from vtk.vtkPVServerManagerApplication import * +from vtk.vtkPVServerManagerCore import * +from vtk.vtkPVVTKExtensionsCore import * from vtk import * #------------------------------------------------------------------------------ diff --git a/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx b/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx index f7866bf145b..f33ace4fefc 100644 --- a/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx +++ b/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx @@ -165,7 +165,7 @@ void vtkPythonAnnotationFilter::EvaluateExpression() stream << "def vtkPythonAnnotationFilter_EvaluateExpression():" << endl << " from paraview import annotation as pv_ann" << endl - << " from vtkPVClientServerCoreCorePython import vtkPythonAnnotationFilter" << endl + << " from vtk.vtkPVClientServerCoreCore import vtkPythonAnnotationFilter" << endl << " me = vtkPythonAnnotationFilter('" << vtkGetReferenceAsString(this) << " ')" << endl << " pv_ann.execute(me)" << endl << " del me" << endl diff --git a/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx b/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx index 27b03cf9b26..e257cff99e2 100644 --- a/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx +++ b/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx @@ -154,7 +154,7 @@ int vtkPythonExtractSelection::RequestData( stream << "def vtkPythonExtractSelection_RequestData():" << endl << " from paraview import extract_selection as pv_es" << endl - << " from vtkPVClientServerCoreCorePython import vtkPythonExtractSelection" << endl + << " from vtk.vtkPVClientServerCoreCore import vtkPythonExtractSelection" << endl << " me = vtkPythonExtractSelection('" << aplus << " ')" << endl << " pv_es.execute(me)" << endl << " del me" << endl diff --git a/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx b/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx index 8de5b5843b4..527f49d2dcd 100644 --- a/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx +++ b/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx @@ -68,7 +68,7 @@ void vtkAnnotateAttributeDataFilter::EvaluateExpression() stream << "def vtkAnnotateAttributeDataFilter_EvaluateExpression():" << endl << " from paraview import annotation as pv_ann" << endl - << " from vtkPVClientServerCoreDefaultPython import vtkAnnotateAttributeDataFilter" << endl + << " from vtk.vtkPVClientServerCoreDefault import vtkAnnotateAttributeDataFilter" << endl << " me = vtkAnnotateAttributeDataFilter('" << vtkGetReferenceAsString(this) << " ')" << endl << " pv_ann.execute_on_attribute_data(me," << (evaluate_locally? "True" : "False") << ")" << endl diff --git a/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx b/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx index a24ca00ed80..7aabdf5587e 100644 --- a/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx +++ b/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx @@ -61,7 +61,7 @@ void vtkAnnotateGlobalDataFilter::EvaluateExpression() stream << "def vtkAnnotateGlobalDataFilter_EvaluateExpression():" << endl << " from paraview import annotation as pv_ann" << endl - << " from vtkPVClientServerCoreDefaultPython import vtkAnnotateGlobalDataFilter" << endl + << " from vtk.vtkPVClientServerCoreDefault import vtkAnnotateGlobalDataFilter" << endl << " me = vtkAnnotateGlobalDataFilter('" << vtkGetReferenceAsString(this) << " ')" << endl << " pv_ann.execute_on_global_data(me)" << endl << " del me" << endl diff --git a/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx b/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx index 7215ad80f16..f99b235436c 100644 --- a/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx +++ b/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx @@ -137,7 +137,7 @@ void vtkPythonCalculator::Exec(const char* expression) python_stream << "import paraview\n" << "from paraview import calculator\n" - << "from vtkPVClientServerCoreDefaultPython import vtkPythonCalculator\n" + << "from vtk.vtkPVClientServerCoreDefault import vtkPythonCalculator\n" << "calculator.execute(vtkPythonCalculator('" << aplus << "'), '" << orgscript.c_str() << "')\n"; diff --git a/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx b/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx index c31341b5e31..3d3333dc30a 100644 --- a/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx +++ b/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx @@ -150,7 +150,7 @@ void vtkPythonView::Update() // Import necessary items from ParaView std::ostringstream importStream; importStream << "import paraview" << endl - << "from vtkPVClientServerCoreRenderingPython import vtkPythonView" << endl + << "from vtk.vtkPVClientServerCoreRendering import vtkPythonView" << endl << "pythonView = vtkPythonView('" << addressOfThis << " ')" << endl; this->RunSimpleStringWithCustomLocals(importStream.str().c_str()); diff --git a/ParaViewCore/ServerManager/Default/Testing/Python/PointGaussianProperties.py b/ParaViewCore/ServerManager/Default/Testing/Python/PointGaussianProperties.py index f6d98579fe7..f787a0f4ee1 100644 --- a/ParaViewCore/ServerManager/Default/Testing/Python/PointGaussianProperties.py +++ b/ParaViewCore/ServerManager/Default/Testing/Python/PointGaussianProperties.py @@ -1,7 +1,7 @@ import os, sys from paraview import simple -from vtkPVServerManagerRenderingPython import * +from vtk.vtkPVServerManagerRendering import * from vtk import * from paraview import smtesting diff --git a/Web/Applications/DataProber/server/pv_web_data_prober.py b/Web/Applications/DataProber/server/pv_web_data_prober.py index a6182ae0aab..712283fa5ec 100644 --- a/Web/Applications/DataProber/server/pv_web_data_prober.py +++ b/Web/Applications/DataProber/server/pv_web_data_prober.py @@ -43,7 +43,7 @@ from paraview.web import protocols as pv_protocols from vtk.web import server -from vtkWebCorePython import * +from vtk.vtkWebCore import * # import annotations from autobahn.wamp import register as exportRpc diff --git a/Web/Applications/FileViewer/server/pv_web_file_loader.py b/Web/Applications/FileViewer/server/pv_web_file_loader.py index 0c4c1bdabe0..a405b286dff 100644 --- a/Web/Applications/FileViewer/server/pv_web_file_loader.py +++ b/Web/Applications/FileViewer/server/pv_web_file_loader.py @@ -54,7 +54,7 @@ from paraview.web import protocols as pv_protocols from vtk.web import server -from vtkWebCorePython import * +from vtk.vtkWebCore import * # import annotations from autobahn.wamp import register as exportRpc diff --git a/Web/Applications/TestApp/server/pv_web_test_app.py b/Web/Applications/TestApp/server/pv_web_test_app.py index f37b280ec47..4da038a2e61 100644 --- a/Web/Applications/TestApp/server/pv_web_test_app.py +++ b/Web/Applications/TestApp/server/pv_web_test_app.py @@ -37,7 +37,7 @@ from paraview.web import protocols as pv_protocols from vtk.web import server -from vtkWebCorePython import * +from vtk.vtkWebCore import * try: import argparse diff --git a/Web/Python/paraview/web/helper.py b/Web/Python/paraview/web/helper.py index c91f3461672..6dd4f1fd12f 100644 --- a/Web/Python/paraview/web/helper.py +++ b/Web/Python/paraview/web/helper.py @@ -13,11 +13,11 @@ from paraview import simple, servermanager from paraview.servermanager import ProxyProperty, InputProperty -from vtkPVServerManagerCorePython import * +from vtk.vtkPVServerManagerCore import * # Needed for: # vtkSMPVRepresentationProxy -from vtkPVServerManagerRenderingPython import * +from vtk.vtkPVServerManagerRendering import * # ============================================================================= # Pipeline management diff --git a/Web/Python/paraview/web/ipython.py b/Web/Python/paraview/web/ipython.py index 538ed7d52ca..5a5060be885 100644 --- a/Web/Python/paraview/web/ipython.py +++ b/Web/Python/paraview/web/ipython.py @@ -78,17 +78,17 @@ def ComputeNextTimeStep(): from mpi4py import MPI from vtk.web import server from paraview.vtk import * -from vtkCommonCorePython import * -from vtkCommonDataModelPython import * -from vtkCommonExecutionModelPython import * -from vtkFiltersSourcesPython import * -from vtkParallelCorePython import * -from vtkParaViewWebCorePython import * -from vtkPVClientServerCoreCorePython import * -from vtkPVServerManagerApplicationPython import * -from vtkPVServerManagerCorePython import * -from vtkPVVTKExtensionsCorePython import * -from vtkWebCorePython import * +from vtk.vtkCommonCore import * +from vtk.vtkCommonDataModel import * +from vtk.vtkCommonExecutionModel import * +from vtk.vtkFiltersSources import * +from vtk.vtkParallelCore import * +from vtk.vtkParaViewWebCore import * +from vtk.vtkPVClientServerCoreCore import * +from vtk.vtkPVServerManagerApplication import * +from vtk.vtkPVServerManagerCore import * +from vtk.vtkPVVTKExtensionsCore import * +from vtk.vtkWebCore import * from paraview.web import wamp as pv_wamp diff --git a/Web/Python/paraview/web/protocols.py b/Web/Python/paraview/web/protocols.py index 0026f58c83f..dd4095b1ed6 100644 --- a/Web/Python/paraview/web/protocols.py +++ b/Web/Python/paraview/web/protocols.py @@ -21,7 +21,7 @@ from vtk.web import protocols as vtk_protocols from decorators import * -from vtkWebCorePython import vtkWebInteractionEvent +from vtk.vtkWebCore import vtkWebInteractionEvent from vtk import vtkImageData from vtk import vtkUnsignedCharArray @@ -31,15 +31,15 @@ # vtkSMPVRepresentationProxy # vtkSMTransferFunctionProxy # vtkSMTransferFunctionManager -from vtkPVServerManagerRenderingPython import * +from vtk.vtkPVServerManagerRendering import * # Needed for: # vtkSMProxyManager -from vtkPVServerManagerCorePython import * +from vtk.vtkPVServerManagerCore import * # Needed for: # vtkDataObject -from vtkCommonDataModelPython import * +from vtk.vtkCommonDataModel import * # ============================================================================= # @@ -2575,8 +2575,8 @@ def listServerDirectory(self, relativeDir='.'): # Handle Data Selection # # ============================================================================= -from vtkPVClientServerCoreRenderingPython import * -from vtkCommonCorePython import * +from vtk.vtkPVClientServerCoreRendering import * +from vtk.vtkCommonCore import * class ParaViewWebSelectionHandler(ParaViewWebProtocol): diff --git a/Web/Python/paraview/web/wamp.py b/Web/Python/paraview/web/wamp.py index 2211d8eb7db..833b9b67ad9 100644 --- a/Web/Python/paraview/web/wamp.py +++ b/Web/Python/paraview/web/wamp.py @@ -3,7 +3,7 @@ """ from vtk.web import wamp -from vtkParaViewWebCorePython import vtkPVWebApplication +from vtk.vtkParaViewWebCore import vtkPVWebApplication from paraview.web import protocols as pv_protocols diff --git a/Web/Python/paraview/web/webgl.py b/Web/Python/paraview/web/webgl.py index 8b654e043ef..5b34bbd090c 100644 --- a/Web/Python/paraview/web/webgl.py +++ b/Web/Python/paraview/web/webgl.py @@ -10,7 +10,7 @@ from paraview import simple from paraview.web import helper -from vtkParaViewWebCorePython import vtkPVWebApplication +from vtk.vtkParaViewWebCore import vtkPVWebApplication import exceptions import base64 diff --git a/Wrapping/Python/paraview/coprocessing.py b/Wrapping/Python/paraview/coprocessing.py index 0c045241df1..fbff27e3823 100644 --- a/Wrapping/Python/paraview/coprocessing.py +++ b/Wrapping/Python/paraview/coprocessing.py @@ -6,7 +6,7 @@ """ from paraview import simple, servermanager -from vtkPVVTKExtensionsCorePython import * +from vtk.vtkPVVTKExtensionsCore import * import math # ----------------------------------------------------------------------------- diff --git a/Wrapping/Python/paraview/pvvtkextensions.py b/Wrapping/Python/paraview/pvvtkextensions.py index 4279815824c..9cb4b69814e 100644 --- a/Wrapping/Python/paraview/pvvtkextensions.py +++ b/Wrapping/Python/paraview/pvvtkextensions.py @@ -1,4 +1,4 @@ from paraview import vtk -from vtkPVVTKExtensionsCorePython import * -from vtkPVVTKExtensionsDefaultPython import * -from vtkPVVTKExtensionsRenderingPython import * +from vtk.vtkPVVTKExtensionsCore import * +from vtk.vtkPVVTKExtensionsDefault import * +from vtk.vtkPVVTKExtensionsRendering import * diff --git a/Wrapping/Python/paraview/python_view.py b/Wrapping/Python/paraview/python_view.py index da2de6f9004..b1bae702711 100644 --- a/Wrapping/Python/paraview/python_view.py +++ b/Wrapping/Python/paraview/python_view.py @@ -19,23 +19,23 @@ import paraview import vtk -from vtkPVServerImplementationCorePython import * -from vtkPVClientServerCoreCorePython import * -from vtkPVServerManagerCorePython import * +from vtk.vtkPVServerImplementationCore import * +from vtk.vtkPVClientServerCoreCore import * +from vtk.vtkPVServerManagerCore import * try: - from vtkPVServerManagerDefaultPython import * + from vtk.vtkPVServerManagerDefault import * except: - paraview.print_error("Error: Cannot import vtkPVServerManagerDefaultPython") + paraview.print_error("Error: Cannot import vtkPVServerManagerDefault") try: - from vtkPVServerManagerRenderingPython import * + from vtk.vtkPVServerManagerRendering import * except: - paraview.print_error("Error: Cannot import vtkPVServerManagerRenderingPython") + paraview.print_error("Error: Cannot import vtkPVServerManagerRendering") try: - from vtkPVServerManagerApplicationPython import * + from vtk.vtkPVServerManagerApplication import * except: - paraview.print_error("Error: Cannot import vtkPVServerManagerApplicationPython") -from vtkPVCommonPython import * + paraview.print_error("Error: Cannot import vtkPVServerManagerApplication") +from vtk.vtkPVCommon import * def numpy_to_image(numpy_array): diff --git a/Wrapping/Python/paraview/servermanager.py b/Wrapping/Python/paraview/servermanager.py index 85a720d3241..df3c6f4018e 100644 --- a/Wrapping/Python/paraview/servermanager.py +++ b/Wrapping/Python/paraview/servermanager.py @@ -47,27 +47,27 @@ #============================================================================== import paraview, re, os, os.path, new, sys, atexit, vtk -from vtkPVServerImplementationCorePython import * -from vtkPVClientServerCoreCorePython import * -from vtkPVServerManagerCorePython import * +from vtk.vtkPVServerImplementationCore import * +from vtk.vtkPVClientServerCoreCore import * +from vtk.vtkPVServerManagerCore import * try: - from vtkPVServerManagerDefaultPython import * + from vtk.vtkPVServerManagerDefault import * except: - paraview.print_error("Error: Cannot import vtkPVServerManagerDefaultPython") + paraview.print_error("Error: Cannot import vtkPVServerManagerDefault") try: - from vtkPVServerManagerRenderingPython import * + from vtk.vtkPVServerManagerRendering import * except: - paraview.print_error("Error: Cannot import vtkPVServerManagerRenderingPython") + paraview.print_error("Error: Cannot import vtkPVServerManagerRendering") try: - from vtkPVServerManagerApplicationPython import * + from vtk.vtkPVServerManagerApplication import * except: - paraview.print_error("Error: Cannot import vtkPVServerManagerApplicationPython") + paraview.print_error("Error: Cannot import vtkPVServerManagerApplication") try: - from vtkPVAnimationPython import * + from vtk.vtkPVAnimation import * except: - paraview.print_error("Error: Cannot import vtkPVAnimationPython") -from vtkPVCommonPython import * + paraview.print_error("Error: Cannot import vtkPVAnimation") +from vtk.vtkPVCommon import * def _wrap_property(proxy, smproperty): """ Internal function. diff --git a/Wrapping/Python/paraview/smtesting.py b/Wrapping/Python/paraview/smtesting.py index 6b0d7664f8f..826abc24589 100644 --- a/Wrapping/Python/paraview/smtesting.py +++ b/Wrapping/Python/paraview/smtesting.py @@ -4,7 +4,7 @@ import re import sys import exceptions -from vtkPVServerManagerDefaultPython import * +from vtk.vtkPVServerManagerDefault import * # we get different behavior based on how we import servermanager # so we want to import servermanager the same way in this module diff --git a/Wrapping/Python/paraview/util.py b/Wrapping/Python/paraview/util.py index dbb4004d55d..9807a546477 100644 --- a/Wrapping/Python/paraview/util.py +++ b/Wrapping/Python/paraview/util.py @@ -1,5 +1,5 @@ from paraview import vtk -from vtkPVVTKExtensionsDefaultPython import * +from vtk.vtkPVVTKExtensionsDefault import * def SetOutputWholeExtent(algorithm, extent): """ From aadfe8621881215a74397357dbe72e6278e8ae5f Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Mon, 14 Mar 2016 23:06:05 -0400 Subject: [PATCH 25/29] Prefer `vtk` package from `paraview`. Using paraview.vtk instead of vtk avoid importing all of VTK's Python wrapped modules which is huge benefit when dealing with slow file systems, often encountered in ParaView use-cases. --- .../Core/vtkPythonAnnotationFilter.cxx | 2 +- .../Core/vtkPythonExtractSelection.cxx | 2 +- .../vtkAnnotateAttributeDataFilter.cxx | 2 +- .../Default/vtkAnnotateGlobalDataFilter.cxx | 2 +- .../Default/vtkPythonCalculator.cxx | 2 +- .../Rendering/vtkPythonView.cxx | 2 +- Wrapping/Python/CMakeLists.txt | 19 ++++++++++--------- Wrapping/Python/paraview/servermanager.py | 6 +++++- 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx b/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx index f33ace4fefc..becc62a3af1 100644 --- a/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx +++ b/ParaViewCore/ClientServerCore/Core/vtkPythonAnnotationFilter.cxx @@ -165,7 +165,7 @@ void vtkPythonAnnotationFilter::EvaluateExpression() stream << "def vtkPythonAnnotationFilter_EvaluateExpression():" << endl << " from paraview import annotation as pv_ann" << endl - << " from vtk.vtkPVClientServerCoreCore import vtkPythonAnnotationFilter" << endl + << " from paraview.vtk.vtkPVClientServerCoreCore import vtkPythonAnnotationFilter" << endl << " me = vtkPythonAnnotationFilter('" << vtkGetReferenceAsString(this) << " ')" << endl << " pv_ann.execute(me)" << endl << " del me" << endl diff --git a/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx b/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx index e257cff99e2..8346aedf635 100644 --- a/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx +++ b/ParaViewCore/ClientServerCore/Core/vtkPythonExtractSelection.cxx @@ -154,7 +154,7 @@ int vtkPythonExtractSelection::RequestData( stream << "def vtkPythonExtractSelection_RequestData():" << endl << " from paraview import extract_selection as pv_es" << endl - << " from vtk.vtkPVClientServerCoreCore import vtkPythonExtractSelection" << endl + << " from paraview.vtk.vtkPVClientServerCoreCore import vtkPythonExtractSelection" << endl << " me = vtkPythonExtractSelection('" << aplus << " ')" << endl << " pv_es.execute(me)" << endl << " del me" << endl diff --git a/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx b/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx index 527f49d2dcd..fdea73e29fa 100644 --- a/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx +++ b/ParaViewCore/ClientServerCore/Default/vtkAnnotateAttributeDataFilter.cxx @@ -68,7 +68,7 @@ void vtkAnnotateAttributeDataFilter::EvaluateExpression() stream << "def vtkAnnotateAttributeDataFilter_EvaluateExpression():" << endl << " from paraview import annotation as pv_ann" << endl - << " from vtk.vtkPVClientServerCoreDefault import vtkAnnotateAttributeDataFilter" << endl + << " from paraview.vtk.vtkPVClientServerCoreDefault import vtkAnnotateAttributeDataFilter" << endl << " me = vtkAnnotateAttributeDataFilter('" << vtkGetReferenceAsString(this) << " ')" << endl << " pv_ann.execute_on_attribute_data(me," << (evaluate_locally? "True" : "False") << ")" << endl diff --git a/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx b/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx index 7aabdf5587e..127f3311a32 100644 --- a/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx +++ b/ParaViewCore/ClientServerCore/Default/vtkAnnotateGlobalDataFilter.cxx @@ -61,7 +61,7 @@ void vtkAnnotateGlobalDataFilter::EvaluateExpression() stream << "def vtkAnnotateGlobalDataFilter_EvaluateExpression():" << endl << " from paraview import annotation as pv_ann" << endl - << " from vtk.vtkPVClientServerCoreDefault import vtkAnnotateGlobalDataFilter" << endl + << " from paraview.vtk.vtkPVClientServerCoreDefault import vtkAnnotateGlobalDataFilter" << endl << " me = vtkAnnotateGlobalDataFilter('" << vtkGetReferenceAsString(this) << " ')" << endl << " pv_ann.execute_on_global_data(me)" << endl << " del me" << endl diff --git a/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx b/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx index f99b235436c..37a3c412e77 100644 --- a/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx +++ b/ParaViewCore/ClientServerCore/Default/vtkPythonCalculator.cxx @@ -137,7 +137,7 @@ void vtkPythonCalculator::Exec(const char* expression) python_stream << "import paraview\n" << "from paraview import calculator\n" - << "from vtk.vtkPVClientServerCoreDefault import vtkPythonCalculator\n" + << "from paraview.vtk.vtkPVClientServerCoreDefault import vtkPythonCalculator\n" << "calculator.execute(vtkPythonCalculator('" << aplus << "'), '" << orgscript.c_str() << "')\n"; diff --git a/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx b/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx index 3d3333dc30a..fc371b0ac8a 100644 --- a/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx +++ b/ParaViewCore/ClientServerCore/Rendering/vtkPythonView.cxx @@ -150,7 +150,7 @@ void vtkPythonView::Update() // Import necessary items from ParaView std::ostringstream importStream; importStream << "import paraview" << endl - << "from vtk.vtkPVClientServerCoreRendering import vtkPythonView" << endl + << "from paraview.vtk.vtkPVClientServerCoreRendering import vtkPythonView" << endl << "pythonView = vtkPythonView('" << addressOfThis << " ')" << endl; this->RunSimpleStringWithCustomLocals(importStream.str().c_str()); diff --git a/Wrapping/Python/CMakeLists.txt b/Wrapping/Python/CMakeLists.txt index 2f001059045..0af7a719ff9 100644 --- a/Wrapping/Python/CMakeLists.txt +++ b/Wrapping/Python/CMakeLists.txt @@ -35,9 +35,6 @@ if (NOT PARAVIEW_ENABLE_PYTHON) return() endif() -set(PV_PYTHON_MODULE_BINARY_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/site-packages/paraview") - - # Copy generated module files from VTK into place in the build tree set(_vtkpy_modules # Ninja BUG 760: In past this depended on vtkpython_pyc. However, due to Ninja @@ -98,12 +95,16 @@ configure_file(cpexport.py.in cpexport.py @ONLY) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pv_copy_and_compile_py_files_complete" - # Empty '$pydir/paraview' to remove old files. - COMMAND ${CMAKE_COMMAND} ARGS -E echo "emptying '.../site-packages/paraview'" - COMMAND ${CMAKE_COMMAND} ARGS -E remove_directory "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview" - - COMMAND ${CMAKE_COMMAND} ARGS -E echo "emptying '.../site-packages/vtk'" - COMMAND ${CMAKE_COMMAND} ARGS -E remove_directory "${VTK_BUILD_PYTHON_MODULE_DIR}/vtk" + # We will presently skip removing old py files since the code to put together + # *.py files for the `paraview` package is scattered around e.g. under the Web module. + # The responsibility to put together the `paraview` Python package should really be in one place + # (which is here). Let's do that in near future. Until then, let's leave these "empty dir" lines + # commented out. + # # Empty '$pydir/paraview' to remove old files. + # COMMAND ${CMAKE_COMMAND} ARGS -E echo "emptying '.../site-packages/paraview'" + # COMMAND ${CMAKE_COMMAND} ARGS -E remove_directory "${VTK_BUILD_PYTHON_MODULE_DIR}/paraview" + # COMMAND ${CMAKE_COMMAND} ARGS -E echo "emptying '.../site-packages/vtk'" + # COMMAND ${CMAKE_COMMAND} ARGS -E remove_directory "${VTK_BUILD_PYTHON_MODULE_DIR}/vtk" COMMAND ${CMAKE_COMMAND} ARGS -E echo "copying paraview/*.py to '.../site-paraview/paraview'" COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory diff --git a/Wrapping/Python/paraview/servermanager.py b/Wrapping/Python/paraview/servermanager.py index df3c6f4018e..16dc941b1ff 100644 --- a/Wrapping/Python/paraview/servermanager.py +++ b/Wrapping/Python/paraview/servermanager.py @@ -45,7 +45,11 @@ # PURPOSE. See the above copyright notice for more information. # #============================================================================== -import paraview, re, os, os.path, new, sys, atexit, vtk +import paraview, re, os, os.path, new, sys, atexit + +# prefer `vtk` from `paraview` since it doesn't import all +# vtk modules. +from paraview import vtk from vtk.vtkPVServerImplementationCore import * from vtk.vtkPVClientServerCoreCore import * From 30de5e14b11deed0f90f906996b9d1ee94b09037 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Mon, 14 Mar 2016 23:11:13 -0400 Subject: [PATCH 26/29] Fix incorrect imports. --- Plugins/SurfaceLIC/Testing/Python/SurfaceLICTestDriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/SurfaceLIC/Testing/Python/SurfaceLICTestDriver.py b/Plugins/SurfaceLIC/Testing/Python/SurfaceLICTestDriver.py index b347cc4c679..09ead0056a8 100644 --- a/Plugins/SurfaceLIC/Testing/Python/SurfaceLICTestDriver.py +++ b/Plugins/SurfaceLIC/Testing/Python/SurfaceLICTestDriver.py @@ -22,7 +22,7 @@ del mapper else: em = rw.GetExtensionManager() - painter = vtk.vtkRenderingLIC.vtkSurfaceLICPainter() + painter = vtk.vtkSurfaceLICPainter() ok = painter.IsSupported(rw) print print 'SurfaceLIC %s Supported by:\n %s\n %s\n %s\n'%( From 10f61cf1aef3733e9b8070c10cf6286e805ebdb1 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Tue, 15 Mar 2016 11:19:11 -0400 Subject: [PATCH 27/29] Making PythonSelection test more robust. This circumvents rendering issues with rendering selection wireframe on certain systems. --- .../ServerManager/Default/Testing/Python/PythonSelection.py | 4 +++- Testing/Data/Baseline/PythonSelection.png.md5 | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ParaViewCore/ServerManager/Default/Testing/Python/PythonSelection.py b/ParaViewCore/ServerManager/Default/Testing/Python/PythonSelection.py index 588dad03a3d..422a2658683 100644 --- a/ParaViewCore/ServerManager/Default/Testing/Python/PythonSelection.py +++ b/ParaViewCore/ServerManager/Default/Testing/Python/PythonSelection.py @@ -7,9 +7,11 @@ c =Cone(Resolution=10) GroupDatasets(Input=[s,c]) GenerateIds() +sel = SelectCells("Ids > 4") + +e = ExtractSelection(Selection=sel) r = Show() r.ColorArrayName = None -SelectCells("Ids > 2") RenderView1 = Render() if not smtesting.DoRegressionTesting(RenderView1.SMProxy): diff --git a/Testing/Data/Baseline/PythonSelection.png.md5 b/Testing/Data/Baseline/PythonSelection.png.md5 index 5877e11bc2f..9b002ad0d95 100644 --- a/Testing/Data/Baseline/PythonSelection.png.md5 +++ b/Testing/Data/Baseline/PythonSelection.png.md5 @@ -1 +1 @@ -15c9ff9710e00383b97994ce56e253ab +34842470e6b232c8c6f1c0ac15cad303 From fd0e9d4a152f579ba28073132187146e5a535d73 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Tue, 15 Mar 2016 15:21:27 -0400 Subject: [PATCH 28/29] Update VTK to bring kits+static+python fixes. --- VTK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VTK b/VTK index 7a8d5dab0e7..34e28445eae 160000 --- a/VTK +++ b/VTK @@ -1 +1 @@ -Subproject commit 7a8d5dab0e7face692e54a5acc2cd35522ad225c +Subproject commit 34e28445eae7c5807a0a2c5fe707ad5ef33d5f33 From efb2fb72d20d1aa3c2c537ea4c8db3afbd58cda7 Mon Sep 17 00:00:00 2001 From: Alberto Valverde Date: Tue, 8 Mar 2016 19:47:15 +0100 Subject: [PATCH 29/29] Removed hard-coded path of VTK_BINARY_DIR --- Wrapping/Python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wrapping/Python/CMakeLists.txt b/Wrapping/Python/CMakeLists.txt index 0af7a719ff9..b721ed5e565 100644 --- a/Wrapping/Python/CMakeLists.txt +++ b/Wrapping/Python/CMakeLists.txt @@ -41,7 +41,7 @@ set(_vtkpy_modules # bug, the dependency wasn't being setup properly. Hence we directly depend on # the generated file. Once Ninja or Cmake is fixed, we can remove this file # depedency and leave the target dependecy. - ${CMAKE_BINARY_DIR}/VTK/Wrapping/Python/vtk_compile_complete + ${VTK_BINARY_DIR}/Wrapping/Python/vtk_compile_complete vtkpython_pyc ) if (TARGET vtkWebPython)