Commit 88877418 authored by Robert Maynard's avatar Robert Maynard
Browse files

vtkmContour now supports multiple iso-contour values

parent e7b39312
......@@ -9,6 +9,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestVTKMExternalFaces.cxx
TestVTKMLevelOfDetail.cxx
TestVTKMMarchingCubes.cxx
TestVTKMMarchingCubes2.cxx
TestVTKMThreshold.cxx
TestVTKMThreshold2.cxx
)
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestCutter.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.
=========================================================================*/
#include "vtkActor.h"
#include "vtkCellData.h"
#include "vtkElevationFilter.h"
#include "vtkImageData.h"
#include "vtkImageMandelbrotSource.h"
#include "vtkmContour.h"
#include "vtkNew.h"
#include "vtkPointData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRTAnalyticSource.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
const int EXTENT = 30;
int TestVTKMMarchingCubes2(int argc, char* argv[])
{
vtkNew<vtkRenderer> ren;
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderWindowInteractor> iren;
renWin->AddRenderer(ren.GetPointer());
iren->SetRenderWindow(renWin.GetPointer());
vtkNew<vtkRTAnalyticSource> imageSource;
imageSource->SetWholeExtent(-EXTENT, EXTENT, -EXTENT, EXTENT, -EXTENT, EXTENT);
vtkNew<vtkElevationFilter> ev;
ev->SetInputConnection(imageSource->GetOutputPort());
ev->SetLowPoint(-EXTENT, -EXTENT, -EXTENT);
ev->SetHighPoint(EXTENT, EXTENT, EXTENT);
vtkNew<vtkmContour> cg;
cg->SetInputConnection(ev->GetOutputPort());
cg->SetInputArrayToProcess(
0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "RTData");
cg->SetValue(0, 200.0);
cg->SetValue(1, 220.0);
cg->ComputeScalarsOn();
cg->ComputeNormalsOn();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(cg->GetOutputPort());
mapper->ScalarVisibilityOn();
mapper->SetScalarModeToUsePointFieldData();
mapper->SelectColorArray("Elevation");
mapper->SetScalarRange(0.0, 1.0);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
ren->AddActor(actor.GetPointer());
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
retVal = vtkRegressionTester::PASSED;
}
if (!cg->GetOutput()->GetPointData()->GetNormals())
{
std::cerr << "Output normals not set.\n";
return EXIT_FAILURE;
}
return (!retVal);
}
......@@ -71,20 +71,18 @@ int vtkmContour::RequestData(vtkInformation* request,
{
return 1;
}
else if(numContours > 1)
{
vtkWarningMacro(<< "VTKm contour algorithm currently only supports a "
<< "single contour value. \n"
<< "Falling back to serial implementation.");
return this->Superclass::RequestData(request, inputVector, outputVector);
}
vtkm::filter::MarchingCubes filter;
// set local variables
filter.SetGenerateNormals(this->GetComputeNormals() != 0);
filter.SetIsoValue(this->GetValue(0));
filter.SetNumberOfIsoValues(numContours);
for(int i = 0; i < numContours; ++i)
{
filter.SetIsoValue(i, this->GetValue(i));
}
// convert the input dataset to a vtkm::cont::DataSet
vtkm::cont::DataSet in = tovtkm::Convert(input);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment