diff --git a/Filters/Extraction/Testing/CMakeLists.txt b/Filters/Extraction/Testing/CMakeLists.txt index 1823773508372ece37f0fc3d78bd5450960f8998..e50d316a023f6ad6a74e2554535fd5a27f7038fd 100644 --- a/Filters/Extraction/Testing/CMakeLists.txt +++ b/Filters/Extraction/Testing/CMakeLists.txt @@ -1,4 +1,5 @@ vtk_module_test_data( + Data/cad_cubes.vtp Data/can.ex2) add_subdirectory(Cxx) diff --git a/Filters/Extraction/Testing/Cxx/CMakeLists.txt b/Filters/Extraction/Testing/Cxx/CMakeLists.txt index ebfd217b29a2cfd1769292600eadf6d025d38431..b733ebe7580cd9dc60dc07bf9373aac2b03ba85d 100644 --- a/Filters/Extraction/Testing/Cxx/CMakeLists.txt +++ b/Filters/Extraction/Testing/Cxx/CMakeLists.txt @@ -1,3 +1,10 @@ +set(test_64bit) +if(${VTK_USE_64BIT_IDS}) + set(test_64bit + TestExtractValues.cxx,NO_VALID DATA{${_vtk_build_TEST_INPUT_DATA_DIRECTORY}/Data/cad_cubes.vtp} + ) +endif() + vtk_add_test_cxx(vtkFiltersExtractionCxxTests tests TestConvertSelection.cxx,NO_VALID TestExpandMarkedElements.cxx @@ -11,5 +18,6 @@ vtk_add_test_cxx(vtkFiltersExtractionCxxTests tests TestExtractSelectedArraysOverTime.cxx,NO_VALID TestExtractSelection.cxx TestExtractTimeSteps.cxx,NO_VALID + ${test_64bit} ) vtk_test_cxx_executable(vtkFiltersExtractionCxxTests tests) diff --git a/Filters/Extraction/Testing/Cxx/TestExtractValues.cxx b/Filters/Extraction/Testing/Cxx/TestExtractValues.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2f1f5d0f28598966bd97684c91f208e7ff333b75 --- /dev/null +++ b/Filters/Extraction/Testing/Cxx/TestExtractValues.cxx @@ -0,0 +1,53 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: TestExtractValues.cxx + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + 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. + +=========================================================================*/ +// This tests value selection of a vtkPolyData + +#include "vtkExtractSelection.h" +#include "vtkNew.h" +#include "vtkSelectionSource.h" +#include "vtkUnstructuredGrid.h" +#include "vtkXMLPolyDataReader.h" + +int TestExtractValues(int vtkNotUsed(argc), char* argv[]) +{ + vtkNew<vtkXMLPolyDataReader> reader; + reader->SetFileName(argv[1]); + + vtkNew<vtkSelectionSource> selection; + selection->SetArrayName("Solid id"); + selection->SetContentType(vtkSelectionNode::VALUES); + selection->SetFieldType(vtkSelectionNode::CELL); + selection->AddID(-1, 1); + selection->AddID(-1, 2); + + vtkNew<vtkExtractSelection> extract; + extract->SetInputConnection(0, reader->GetOutputPort()); + extract->SetInputConnection(1, selection->GetOutputPort()); + extract->Update(); + + vtkUnstructuredGrid* result = vtkUnstructuredGrid::SafeDownCast(extract->GetOutput()); + vtkIdType nbCells = result->GetNumberOfCells(); + + // We are extracting 2 cubes. Each cube has 6 faces of 4 faces, 12 polylines and 8 vertices. + // We are expecting 2*(6*4+12+8) = 88 cells + if (nbCells == 88) + { + return EXIT_SUCCESS; + } + + cerr << "There is " << nbCells << " cells instead of 88 cells." << endl; + + return EXIT_FAILURE; +} diff --git a/Filters/Sources/vtkSelectionSource.cxx b/Filters/Sources/vtkSelectionSource.cxx index cb31073aca274dae46cc932fcaca5be3d92db563..be06e67d7ad4e99c1e1b9fbcc30b9abf55fd3813 100644 --- a/Filters/Sources/vtkSelectionSource.cxx +++ b/Filters/Sources/vtkSelectionSource.cxx @@ -19,10 +19,10 @@ #include "vtkIdTypeArray.h" #include "vtkInformation.h" #include "vtkInformationVector.h" +#include "vtkNew.h" #include "vtkObjectFactory.h" #include "vtkSelection.h" #include "vtkSelectionNode.h" -#include "vtkSmartPointer.h" #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkStringArray.h" #include "vtkUnsignedIntArray.h" @@ -272,7 +272,7 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) { vtkSelection* outputSel = vtkSelection::GetData(outputVector); - vtkSmartPointer<vtkSelectionNode> output = vtkSmartPointer<vtkSelectionNode>::New(); + vtkNew<vtkSelectionNode> output; outputSel->AddNode(output); vtkInformation* oProperties = output->GetProperties(); @@ -297,15 +297,15 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), // First look for string ids. if (((this->ContentType == vtkSelectionNode::GLOBALIDS) || (this->ContentType == vtkSelectionNode::PEDIGREEIDS) || - (this->ContentType == vtkSelectionNode::INDICES)) && + (this->ContentType == vtkSelectionNode::INDICES) || + (this->ContentType == vtkSelectionNode::VALUES)) && !this->Internal->StringIDs.empty()) { oProperties->Set(vtkSelectionNode::CONTENT_TYPE(), this->ContentType); oProperties->Set(vtkSelectionNode::FIELD_TYPE(), this->FieldType); - vtkStringArray* selectionList = vtkStringArray::New(); + vtkNew<vtkStringArray> selectionList; output->SetSelectionList(selectionList); - selectionList->Delete(); // Number of selected items common to all pieces vtkIdType numCommonElems = 0; @@ -352,15 +352,15 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), // If no string ids, use integer ids. if (((this->ContentType == vtkSelectionNode::GLOBALIDS) || (this->ContentType == vtkSelectionNode::PEDIGREEIDS) || - (this->ContentType == vtkSelectionNode::INDICES)) && + (this->ContentType == vtkSelectionNode::INDICES) || + (this->ContentType == vtkSelectionNode::VALUES)) && this->Internal->StringIDs.empty()) { oProperties->Set(vtkSelectionNode::CONTENT_TYPE(), this->ContentType); oProperties->Set(vtkSelectionNode::FIELD_TYPE(), this->FieldType); - vtkIdTypeArray* selectionList = vtkIdTypeArray::New(); + vtkNew<vtkIdTypeArray> selectionList; output->SetSelectionList(selectionList); - selectionList->Delete(); // Number of selected items common to all pieces vtkIdType numCommonElems = 0; @@ -407,7 +407,7 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), oProperties->Set(vtkSelectionNode::CONTENT_TYPE(), this->ContentType); oProperties->Set(vtkSelectionNode::FIELD_TYPE(), this->FieldType); // Create the selection list - vtkDoubleArray* selectionList = vtkDoubleArray::New(); + vtkNew<vtkDoubleArray> selectionList; selectionList->SetNumberOfComponents(3); selectionList->SetNumberOfValues(static_cast<vtkIdType>(this->Internal->Locations.size())); @@ -418,7 +418,6 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), } output->SetSelectionList(selectionList); - selectionList->Delete(); } if (this->ContentType == vtkSelectionNode::THRESHOLDS) @@ -427,7 +426,7 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), oProperties->Set(vtkSelectionNode::FIELD_TYPE(), this->FieldType); oProperties->Set(vtkSelectionNode::COMPONENT_NUMBER(), this->ArrayComponent); // Create the selection list - vtkDoubleArray* selectionList = vtkDoubleArray::New(); + vtkNew<vtkDoubleArray> selectionList; selectionList->SetNumberOfComponents(2); selectionList->SetNumberOfValues(static_cast<vtkIdType>(this->Internal->Thresholds.size())); @@ -440,7 +439,6 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), } output->SetSelectionList(selectionList); - selectionList->Delete(); } if (this->ContentType == vtkSelectionNode::FRUSTUM) @@ -448,7 +446,7 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), oProperties->Set(vtkSelectionNode::CONTENT_TYPE(), this->ContentType); oProperties->Set(vtkSelectionNode::FIELD_TYPE(), this->FieldType); // Create the selection list - vtkDoubleArray* selectionList = vtkDoubleArray::New(); + vtkNew<vtkDoubleArray> selectionList; selectionList->SetNumberOfComponents(4); selectionList->SetNumberOfTuples(8); for (vtkIdType cc = 0; cc < 32; cc++) @@ -457,14 +455,13 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), } output->SetSelectionList(selectionList); - selectionList->Delete(); } if (this->ContentType == vtkSelectionNode::BLOCKS) { oProperties->Set(vtkSelectionNode::CONTENT_TYPE(), this->ContentType); oProperties->Set(vtkSelectionNode::FIELD_TYPE(), this->FieldType); - vtkUnsignedIntArray* selectionList = vtkUnsignedIntArray::New(); + vtkNew<vtkUnsignedIntArray> selectionList; selectionList->SetNumberOfComponents(1); selectionList->SetNumberOfTuples(static_cast<vtkIdType>(this->Internal->Blocks.size())); vtkSelectionSourceInternals::IDSetType::iterator iter; @@ -474,7 +471,6 @@ int vtkSelectionSource::RequestData(vtkInformation* vtkNotUsed(request), selectionList->SetValue(cc, *iter); } output->SetSelectionList(selectionList); - selectionList->Delete(); } if (this->ContentType == vtkSelectionNode::QUERY) diff --git a/Testing/Data/cad_cubes.vtp.sha512 b/Testing/Data/cad_cubes.vtp.sha512 new file mode 100644 index 0000000000000000000000000000000000000000..8939945ebd7bda3e8ce9f4128d673acd0b8da898 --- /dev/null +++ b/Testing/Data/cad_cubes.vtp.sha512 @@ -0,0 +1 @@ +14de9a510f10751dad021d597a38c722391206187a89544b37d7b09e9e0646cad51324c34021298ec865242db9b84074a35b13cc174d92feb377693b0c365874