Skip to content
Snippets Groups Projects
Commit 064cb006 authored by Michael Migliore's avatar Michael Migliore
Browse files

Fix and modernize vtkSelectionSource

parent 93d106e0
No related branches found
No related tags found
No related merge requests found
vtk_module_test_data(
Data/cad_cubes.vtp
Data/can.ex2)
add_subdirectory(Cxx)
......
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)
/*=========================================================================
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;
}
......@@ -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)
......
14de9a510f10751dad021d597a38c722391206187a89544b37d7b09e9e0646cad51324c34021298ec865242db9b84074a35b13cc174d92feb377693b0c365874
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment