Commit 8af35b88 authored by Mathieu Westphal's avatar Mathieu Westphal Committed by Max Zeyen

Adds a new vtk dataType vtkExplicitStructuredGrid and related filters:

* The new class vtkExplicitStructuredGrid
* Two new filter vtkImageDataToExplicitStructuredGrid and vtkUnstructuredGridExplicitStructuredGrid for converting to the new type
* A new filter vtkExplicitStructuredGridToUnstructuredGrid for converting from the new type
* A new filter vtkExplicitStructuredGridCrop , as a first filter specific to the new type
* A few tests for these filters

```
 /* vtkExplicitStructuredGrid is a data object that is a concrete implementation
 * of vtkDataSet. vtkExplicitStructuredGrid represents a geometric structure
 * that is a topologically regular array of hexahedron. The topology is that of
 * a cube that has been subdivided into a regular array of smaller cubes.
 * Each cell can be addressed with i-j-k indices, however neighbor hexahedrons
 * does not necessarily share a face and hexahedron can be blanked (turned-off).
 *
 * Like unstructured grid, vtkExplicitStructuredGrid has explicit point coordinates
 * and cell to point indexing.
 * Unlike unstructured grid, vtkExplicitStructuredGrid does not keep a cell type
 * list as all cells are known to be hexahedra.
 * vtkExplicitStructuredGrid can take advantage of its layout to perform operations
 * based on the i, j, k parameters, similar to structured grid. This makes some
 * operations faster on this class, without loosing the flexibility of the
 * cell -> points mapping.
 * The most common use of this class would be in situations where you have all
 * hexahedra but the points used by the cells are not exactly defined by the
 * i, j, k parameters. One example of this is a structured grid with a half voxel
 * shift occurring in the middle of it such as with a geologic fault.
 *
 * The order and number of points is arbitrary.
 * The order and number of cells must match that specified by the dimensions
 * of the grid minus 1, because in vtk structured datasets the dimensions
 * correspond to the points.
 * The cells order increases in i fastest (from 0 <= i <= dims[0] - 2),
 * then j (0 <= j <= dims[1] - 2), then k ( 0 <= k <= dims[2] - 2) where dims[]
 * are the dimensions of the grid in the i-j-k topological directions.
 * The number of cells is (dims[0] - 1) * (dims[1] - 1) * (dims[2] - 1).
 */

```
parent a4fe0923
......@@ -128,6 +128,7 @@
#define VTK_PARTITIONED_DATA_SET 37
#define VTK_PARTITIONED_DATA_SET_COLLECTION 38
#define VTK_UNIFORM_HYPER_TREE_GRID 39
#define VTK_EXPLICIT_STRUCTURED_GRID 40
/*--------------------------------------------------------------------------*/
/* Define a casting macro for use by the constants below. */
......
......@@ -51,6 +51,7 @@ set(classes
vtkEdgeListIterator
vtkEdgeTable
vtkEmptyCell
vtkExplicitStructuredGrid
vtkExtractStructuredGridHelper
vtkFieldData
vtkGenericAdaptorCell
......
......@@ -23,6 +23,7 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkDataSet.h"
#include "vtkDirectedAcyclicGraph.h"
#include "vtkDirectedGraph.h"
#include "vtkExplicitStructuredGrid.h"
#include "vtkGenericDataSet.h"
#include "vtkGraph.h"
#include "vtkHierarchicalBoxDataSet.h"
......@@ -47,6 +48,7 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkTree.h"
#include "vtkUndirectedGraph.h"
#include "vtkUniformGrid.h"
#include "vtkUniformHyperTreeGrid.h"
#include "vtkUnstructuredGrid.h"
#include "vtkArrayData.h"
......@@ -97,6 +99,8 @@ static const char* vtkDataObjectTypesStrings[] = {
"vtkUnstructuredGridBase",
"vtkPartitionedDataSet",
"vtkPartitionedDataSetCollection",
"vtkUniformHyperTreeGrid",
"vtkExplicitStructuredGrid",
nullptr
};
......@@ -280,6 +284,14 @@ vtkDataObject* vtkDataObjectTypes::NewDataObject(const char* type)
{
return vtkPartitionedDataSetCollection::New();
}
else if(strcmp(type, "vtkUniformHyperTreeGrid") == 0)
{
return vtkUniformHyperTreeGrid::New();
}
else if(strcmp(type, "vtkExplicitStructuredGrid") == 0)
{
return vtkExplicitStructuredGrid::New();
}
vtkGenericWarningMacro("NewDataObject(): You are trying to instantiate DataObjectType \"" << type
<< "\" which does not exist.");
......
This diff is collapsed.
This diff is collapsed.
......@@ -13,6 +13,7 @@ set(classes
vtkDirectedGraphAlgorithm
vtkEnsembleSource
vtkExecutive
vtkExplicitStructuredGridAlgorithm
vtkExtentRCBPartitioner
vtkExtentSplitter
vtkExtentTranslator
......@@ -62,6 +63,7 @@ set(classes
vtkUniformGridPartitioner
vtkUnstructuredGridAlgorithm
vtkUnstructuredGridBaseAlgorithm
# New AMR classes
vtkNonOverlappingAMRAlgorithm
vtkOverlappingAMRAlgorithm
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkExplicitStructuredGridAlgorithm.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 "vtkExplicitStructuredGridAlgorithm.h"
#include "vtkCommand.h"
#include "vtkExplicitStructuredGrid.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkStandardNewMacro(vtkExplicitStructuredGridAlgorithm);
//----------------------------------------------------------------------------
vtkExplicitStructuredGridAlgorithm::vtkExplicitStructuredGridAlgorithm()
{
// by default assume filters have one input and one output
// subclasses that deviate should modify this setting
this->SetNumberOfInputPorts(1);
this->SetNumberOfOutputPorts(1);
}
//----------------------------------------------------------------------------
vtkExplicitStructuredGrid* vtkExplicitStructuredGridAlgorithm::GetOutput()
{
return this->GetOutput(0);
}
//----------------------------------------------------------------------------
vtkExplicitStructuredGrid* vtkExplicitStructuredGridAlgorithm::GetOutput(int port)
{
return vtkExplicitStructuredGrid::SafeDownCast(this->GetOutputDataObject(port));
}
//----------------------------------------------------------------------------
void vtkExplicitStructuredGridAlgorithm::SetOutput(vtkDataObject* d)
{
this->GetExecutive()->SetOutputData(0, d);
}
//----------------------------------------------------------------------------
vtkDataObject* vtkExplicitStructuredGridAlgorithm::GetInput()
{
return this->GetInput(0);
}
//----------------------------------------------------------------------------
vtkDataObject* vtkExplicitStructuredGridAlgorithm::GetInput(int port)
{
return this->GetExecutive()->GetInputData(port, 0);
}
//----------------------------------------------------------------------------
vtkExplicitStructuredGrid* vtkExplicitStructuredGridAlgorithm::GetExplicitStructuredGridInput(
int port)
{
return vtkExplicitStructuredGrid::SafeDownCast(this->GetInput(port));
}
//----------------------------------------------------------------------------
void vtkExplicitStructuredGridAlgorithm::SetInputData(vtkDataObject* input)
{
this->SetInputData(0, input);
}
//----------------------------------------------------------------------------
void vtkExplicitStructuredGridAlgorithm::SetInputData(int index, vtkDataObject* input)
{
this->SetInputDataInternal(index, input);
}
//----------------------------------------------------------------------------
void vtkExplicitStructuredGridAlgorithm::AddInputData(vtkDataObject* input)
{
this->AddInputData(0, input);
}
//----------------------------------------------------------------------------
void vtkExplicitStructuredGridAlgorithm::AddInputData(int index, vtkDataObject* input)
{
this->AddInputDataInternal(index, input);
}
//----------------------------------------------------------------------------
int vtkExplicitStructuredGridAlgorithm::ProcessRequest(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// generate the data
if (request->Has(vtkDemandDrivenPipeline::REQUEST_DATA()))
{
return this->RequestData(request, inputVector, outputVector);
}
if (request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT()))
{
return this->RequestUpdateExtent(request, inputVector, outputVector);
}
// execute information
if (request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()))
{
return this->RequestInformation(request, inputVector, outputVector);
}
if (request->Has(vtkDemandDrivenPipeline::REQUEST_DATA_OBJECT()))
{
vtkInformation* outputInfo = outputVector->GetInformationObject(0);
vtkExplicitStructuredGrid* grid = vtkExplicitStructuredGrid::New();
outputInfo->Set(vtkDataObject::DATA_OBJECT(), grid);
grid->Delete();
return 1;
}
return this->Superclass::ProcessRequest(request, inputVector, outputVector);
}
//----------------------------------------------------------------------------
int vtkExplicitStructuredGridAlgorithm::RequestInformation(vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* vtkNotUsed(outputVector))
{
// do nothing let subclasses handle it
return 1;
}
//----------------------------------------------------------------------------
int vtkExplicitStructuredGridAlgorithm::RequestUpdateExtent(vtkInformation* vtkNotUsed(request),
vtkInformationVector** inputVector,
vtkInformationVector* vtkNotUsed(outputVector))
{
int numInputPorts = this->GetNumberOfInputPorts();
for (int i = 0; i < numInputPorts; i++)
{
int numInputConnections = this->GetNumberOfInputConnections(i);
for (int j = 0; j < numInputConnections; j++)
{
vtkInformation* inputInfo = inputVector[i]->GetInformationObject(j);
inputInfo->Set(vtkStreamingDemandDrivenPipeline::EXACT_EXTENT(), 0);
}
}
return 1;
}
//----------------------------------------------------------------------------
int vtkExplicitStructuredGridAlgorithm::RequestData(vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* vtkNotUsed(outputVector))
{
return 0;
}
//----------------------------------------------------------------------------
int vtkExplicitStructuredGridAlgorithm::FillOutputPortInformation(int vtkNotUsed(port),
vtkInformation* info)
{
// now add our info
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkExplicitStructuredGrid");
return 1;
}
//----------------------------------------------------------------------------
int vtkExplicitStructuredGridAlgorithm::FillInputPortInformation(int vtkNotUsed(port),
vtkInformation* info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkExplicitStructuredGrid");
return 1;
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkExplicitStructuredGridAlgorithm.h
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.
=========================================================================*/
/**
* @class vtkExplicitStructuredGridAlgorithm
* @brief Superclass for algorithms that produce only
* explicit structured grid as output.
*/
#ifndef vtkExplicitStructuredGridAlgorithm_h
#define vtkExplicitStructuredGridAlgorithm_h
#include "vtkAlgorithm.h"
#include "vtkCommonExecutionModelModule.h" // For export macro
class vtkDataSet;
class vtkExplicitStructuredGrid;
class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExplicitStructuredGridAlgorithm : public vtkAlgorithm
{
public:
static vtkExplicitStructuredGridAlgorithm* New();
vtkTypeMacro(vtkExplicitStructuredGridAlgorithm, vtkAlgorithm);
//@{
/**
* Get the output data object for a port on this algorithm.
*/
vtkExplicitStructuredGrid* GetOutput();
vtkExplicitStructuredGrid* GetOutput(int);
virtual void SetOutput(vtkDataObject* d);
//@}
/**
* see vtkAlgorithm for details
*/
virtual int ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
// this method is not recommended for use, but lots of old style filters
// use it
vtkDataObject* GetInput();
vtkDataObject* GetInput(int port);
vtkExplicitStructuredGrid* GetExplicitStructuredGridInput(int port);
//@{
/**
* Assign a data object as input. Note that this method does not
* establish a pipeline connection. Use SetInputConnection() to
* setup a pipeline connection.
*/
void SetInputData(vtkDataObject*);
void SetInputData(int, vtkDataObject*);
//@}
//@{
/**
* Assign a data object as input. Note that this method does not
* establish a pipeline connection. Use AddInputConnection() to
* setup a pipeline connection.
*/
void AddInputData(vtkDataObject*);
void AddInputData(int, vtkDataObject*);
//@}
protected:
vtkExplicitStructuredGridAlgorithm();
~vtkExplicitStructuredGridAlgorithm() override = default;
// convenience method
virtual int RequestInformation(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
/**
* This is called by the superclass.
* This is the method you should override.
*/
virtual int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
/**
* This is called by the superclass.
* This is the method you should override.
*/
virtual int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*);
// see algorithm for more info
virtual int FillOutputPortInformation(int port, vtkInformation* info) override;
virtual int FillInputPortInformation(int port, vtkInformation* info) override;
private:
vtkExplicitStructuredGridAlgorithm(const vtkExplicitStructuredGridAlgorithm&) = delete;
void operator=(const vtkExplicitStructuredGridAlgorithm&) = delete;
};
#endif
......@@ -32,6 +32,8 @@ set(classes
vtkEdgeSubdivisionCriterion
vtkElevationFilter
vtkExecutionTimer
vtkExplicitStructuredGridCrop
vtkExplicitStructuredGridToUnstructuredGrid
vtkFeatureEdges
vtkFieldDataToAttributeDataFilter
vtkFlyingEdges2D
......@@ -43,6 +45,7 @@ set(classes
vtkHedgeHog
vtkHull
vtkIdFilter
vtkImageDataToExplicitStructuredGrid
vtkImageAppend
vtkImplicitPolyDataDistance
vtkMarchingCubes
......@@ -89,6 +92,7 @@ set(classes
vtkTriangleMeshPointNormals
vtkTubeFilter
vtkUnstructuredGridQuadricDecimation
vtkUnstructuredGridToExplicitStructuredGrid
vtkVectorDot
vtkVectorNorm
vtkVoronoi2D
......
......@@ -5,7 +5,8 @@ vtk_module_test_data(
Data/can.ex2
Data/cow.vtp
Data/delaunay3d.vtu
Data/disk_out_ref_surface.vtp)
Data/disk_out_ref_surface.vtp
Data/explicitStructuredGrid.vtu)
add_subdirectory(Cxx)
......
......@@ -24,11 +24,14 @@ vtk_add_test_cxx(vtkFiltersCoreCxxTests tests
TestDelaunay2DFindTriangle.cxx,NO_VALID
TestDelaunay2DMeshes.cxx,NO_VALID
TestDelaunay3D.cxx,NO_VALID
TestExplicitStructuredGridCrop.cxx
TestExplicitStructuredGridToUnstructuredGrid.cxx
TestExecutionTimer.cxx,NO_VALID
TestFeatureEdges.cxx,NO_VALID
TestFlyingEdges.cxx
TestGlyph3D.cxx
TestHedgeHog.cxx,NO_VALID
TestImageDataToExplicitStructuredGrid.cxx
TestImplicitPolyDataDistance.cxx
TestMaskPoints.cxx,NO_VALID
TestNamedComponents.cxx,NO_VALID
......@@ -53,6 +56,7 @@ vtk_add_test_cxx(vtkFiltersCoreCxxTests tests
TestTriangleMeshPointNormals.cxx
TestTubeFilter.cxx
TestUnstructuredGridQuadricDecimation.cxx,NO_VALID
TestUnstructuredGridToExplicitStructuredGrid.cxx
UnitTestMaskPoints.cxx,NO_VALID
UnitTestMergeFilter.cxx,NO_VALID
)
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestExplicitStructuredGridCrop.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.
=========================================================================*/
// Description
// This test read a unstructured grid and crop an explicit grid using
// vtkExplicitGrid
#include "vtkActor.h"
#include "vtkDataSetMapper.h"
#include "vtkExplicitStructuredGridCrop.h"
#include "vtkNew.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestUtilities.h"
#include "vtkTesting.h"
#include "vtkUnstructuredGridToExplicitStructuredGrid.h"
#include "vtkXMLUnstructuredGridReader.h"
int TestExplicitStructuredGridCrop(int argc, char *argv[])
{
vtkNew<vtkXMLUnstructuredGridReader> reader;
char *fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/explicitStructuredGrid.vtu");
reader->SetFileName(fname);
delete [] fname;
reader->Update();
vtkNew<vtkUnstructuredGridToExplicitStructuredGrid> esgConvertor;
esgConvertor->SetInputConnection(reader->GetOutputPort());
esgConvertor->SetWholeExtent(0, 5, 0, 13, 0, 3);
esgConvertor->SetInputArrayToProcess(0, 0, 0, 1, "BLOCK_I");
esgConvertor->SetInputArrayToProcess(1, 0, 0, 1, "BLOCK_J");
esgConvertor->SetInputArrayToProcess(2, 0, 0, 1, "BLOCK_K");
esgConvertor->Update();
vtkNew<vtkExplicitStructuredGridCrop> crop;
crop->SetInputConnection(esgConvertor->GetOutputPort());
crop->SetOutputWholeExtent(0, 5, 0, 6, 0, 3);
crop->Update();
vtkNew<vtkDataSetMapper> mapper;
mapper->SetInputConnection(crop->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> ren;
ren->AddActor(actor);
vtkNew<vtkRenderWindow> renWin;
renWin->SetSize(300, 300);
renWin->AddRenderer(ren);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin);
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestImageDataToExplicitStructuredGrid.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.
=========================================================================*/
// Description
// This test creates an explicit grid and convert it to unstructured grid using
// vtkExplicitStructuredGridToUnstructuredGrid
#include "vtkActor.h"
#include "vtkCellData.h"
#include "vtkDataSetMapper.h"
#include "vtkExplicitStructuredGridToUnstructuredGrid.h"
#include "vtkImageDataToExplicitStructuredGrid.h"
#include "vtkNew.h"
#include "vtkRTAnalyticSource.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTesting.h"
#include "vtkUnstructuredGrid.h"
int TestExplicitStructuredGridToUnstructuredGrid(int argc, char *argv[])
{
// Create the sample dataset
vtkNew<vtkRTAnalyticSource> wavelet;
wavelet->SetWholeExtent(-10, 10,
-10, 10,
-10, 10);
wavelet->SetCenter(0.0, 0.0, 0.0);
wavelet->Update();
vtkNew<vtkImageDataToExplicitStructuredGrid> esgConvertor;
esgConvertor->SetInputConnection(wavelet->GetOutputPort());
vtkNew<vtkExplicitStructuredGridToUnstructuredGrid> ugConvertor;
ugConvertor->SetInputConnection(esgConvertor->GetOutputPort());
ugConvertor->Update();
vtkCellData* cellData = ugConvertor->GetOutput()->GetCellData();
if (!cellData->GetArray("BLOCK_I") || !cellData->GetArray("BLOCK_I") || !cellData->GetArray("BLOCK_I"))
{
std::cout<<"Missing expected arrays"<<std::endl;
return EXIT_FAILURE;
}
vtkNew<vtkDataSetMapper> mapper;
mapper->SetInputConnection(ugConvertor->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> ren;
ren->AddActor(actor);
vtkNew<vtkRenderWindow> renWin;
renWin->SetSize(300, 300);
renWin->AddRenderer(ren);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin);
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestImageDataToExplicitStructuredGrid.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.
=========================================================================*/
// Description
// This test creates a wavelet dataset and creates a explicit grid using
// vtkImageDataToExplicitStructuredGrid
#include "vtkActor.h"
#include "vtkImageDataToExplicitStructuredGrid.h"
#include "vtkNew.h"
#include "vtkDataSetMapper.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRTAnalyticSource.h"
#include "vtkTesting.h"
int TestImageDataToExplicitStructuredGrid(int argc, char *argv[])
{
// Create the sample dataset
vtkNew<vtkRTAnalyticSource> wavelet;
wavelet->SetWholeExtent(-10, 10,
-10, 10,
-10, 10);
wavelet->SetCenter(0.0, 0.0, 0.0);
wavelet->Update();
vtkNew<vtkImageDataToExplicitStructuredGrid> esgConvertor;
esgConvertor->SetInputConnection(wavelet->GetOutputPort());
vtkNew<vtkDataSetMapper> mapper;
mapper->SetInputConnection(esgConvertor->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> ren;
ren->AddActor(actor);
vtkNew<vtkRenderWindow> renWin;
renWin->SetSize(300, 300);
renWin->AddRenderer(ren);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin);
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestUnstructuredGridToExplicitStructuredGrid.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.
=========================================================================*/
// Description
// This test read a unstructured grid and creates a explicit grid using
// vtkUnstructuredGridToExplicitStructuredGrid
#include "vtkActor.h"
#include "vtkDataSetMapper.h"
#include "vtkNew.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestUtilities.h"
#include "vtkTesting.h"
#include "vtkUnstructuredGridToExplicitStructuredGrid.h"
#include "vtkXMLUnstructuredGridReader.h"
int TestUnstructuredGridToExplicitStructuredGrid(int argc, char *argv[])
{
vtkNew<vtkXMLUnstructuredGridReader> reader;
char *fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/explicitStructuredGrid.vtu");
reader->SetFileName(fname);
delete [] fname;
reader->Update();
vtkNew<vtkUnstructuredGridToExplicitStructuredGrid> esgConvertor;
esgConvertor->SetInputConnection(reader->GetOutputPort());
esgConvertor->SetWholeExtent(0, 5, 0, 13, 0, 3);
esgConvertor->SetInputArrayToProcess(0, 0, 0, 1, "BLOCK_I");
esgConvertor->SetInputArrayToProcess(1, 0, 0, 1, "BLOCK_J");
esgConvertor->SetInputArrayToProcess(2, 0, 0, 1, "BLOCK_K");
esgConvertor->Update();
vtkNew<vtkDataSetMapper> mapper;
mapper->SetInputConnection(esgConvertor->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> ren;
ren->AddActor(actor);