Commit bfa34cee authored by Philippe Pébay's avatar Philippe Pébay
Browse files

Renamed test and changed it to make it better (2D+binary)

Change-Id: Ic90a55bd00154bef27d21b1e7c73ae827c901e4a
parent c1a43716
create_test_sourcelist(Tests ${vtk-module}CxxTests.cxx
TestBinaryHyperTreeGrid.cxx
TestClipHyperOctree.cxx
TestHyperOctreeContourFilter.cxx
TestHyperOctreeCutter.cxx
......@@ -8,6 +7,7 @@ create_test_sourcelist(Tests ${vtk-module}CxxTests.cxx
TestHyperOctreeToUniformGrid.cxx
TestHyperTreeGrid.cxx
TestHyperTreeGridAxisCut.cxx
TestHyperTreeGridBinary2D.cxx
TestHyperTreeGridGeometry.cxx
EXTRA_INCLUDE vtkTestDriver.h
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestQuadRotationalExtrusionMultiBlock.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.
=========================================================================*/
// .SECTION Thanks
// This test was written by Philippe Pebay, Kitware SAS 2012
#include "vtksys/CommandLineArguments.hxx"
#include "vtksys/Directory.hxx"
#include "vtksys/SystemTools.hxx"
#include "vtksys/Glob.hxx"
#include <vtksys/Process.h>
#include <string>
#include "vtkHyperTreeGrid.h"
#include "vtkHyperTreeGenerator.h"
#include "vtkContourFilter.h"
#include "vtkCutter.h"
#include "vtkDataSetMapper.h"
#include "vtkGeometryFilter.h"
#include "vtkNew.h"
#include "vtkPlane.h"
#include "vtkShrinkFilter.h"
#include "vtkPolyDataWriter.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkUnstructuredGridWriter.h"
#include "vtkXMLUnstructuredGridWriter.h"
#include "vtkUnstructuredGrid.h"
#include "vtkDataSetWriter.h"
int TestBinaryHyperTreeGrid(int argc, char* argv[])
{
vtkNew<vtkHyperTreeGenerator> fractal;
fractal->SetMaximumLevel( 4 );
fractal->DualOn();
fractal->SetDimension( 3 );
fractal->SetAxisBranchFactor( 2 );
vtkHyperTreeGrid* tree = fractal->NewHyperTreeGrid();
vtkNew<vtkCutter> cut;
vtkNew<vtkPlane> plane;
plane->SetOrigin(0.5, 0.5, 0.3333333);
plane->SetNormal(0,0,1);
cut->SetInputData(tree);
cut->SetCutFunction(plane.GetPointer());
vtkPolyDataWriter* writer = vtkPolyDataWriter::New();
writer->SetFileName("./binaryHyperTreeCut.vtk");
writer->SetInputConnection(cut->GetOutputPort());
writer->Write();
writer->Delete();
vtkNew<vtkContourFilter> contour;
contour->SetInputData( tree );
contour->SetNumberOfContours( 2 );
contour->SetValue( 0, 1.5 );
contour->SetValue( 1, 2.5 );
contour->SetInputArrayToProcess(
0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,"Test");
vtkPolyDataWriter* writer2 = vtkPolyDataWriter::New();
writer2->SetFileName("./binaryHyperTreeContour.vtk");
writer2->SetInputConnection(contour->GetOutputPort());
writer2->Write();
writer2->Delete();
vtkNew<vtkShrinkFilter> shrink;
shrink->SetInputData(tree);
shrink->SetShrinkFactor( .8 );
vtkUnstructuredGridWriter* writer3 = vtkUnstructuredGridWriter::New();
writer3->SetFileName("./binaryHyperTreeShrink.vtk");
writer3->SetInputConnection(shrink->GetOutputPort());
writer3->Write();
writer3->Delete();
vtkNew<vtkDataSetMapper> treeMapper;
treeMapper->SetInputConnection( shrink->GetOutputPort() );
vtkNew<vtkActor> treeActor;
treeActor->SetMapper( treeMapper.GetPointer() );
// Create a renderer, add actors to it
vtkNew<vtkRenderer> ren1;
ren1->AddActor( treeActor.GetPointer() );
ren1->SetBackground( 1., 1., 1. );
// Create a renderWindow
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer( ren1.GetPointer() );
renWin->SetSize( 300, 300 );
renWin->SetMultiSamples( 0 );
// Create interactor
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow( renWin.GetPointer() );
// Render and test
renWin->Render();
int retVal = vtkRegressionTestImage( renWin.GetPointer() );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
tree->Delete();
return 0;
}
/*=========================================================================
Copyright (c) Kitware Inc.
All rights reserved.
=========================================================================*/
// .SECTION Thanks
// This test was written by Philippe Pebay, Kitware SAS 2012
#include "vtkHyperTreeGridGeometry.h"
#include "vtkHyperTreeGridSource.h"
#include "vtkCamera.h"
#include "vtkCellData.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
int TestHyperTreeGridBinary2D( int argc, char* argv[] )
{
vtkNew<vtkHyperTreeGridSource> fractal;
fractal->SetMaximumLevel( 3 );
fractal->SetGridSize( 4, 3, 1 );
fractal->SetDimension( 2 );
fractal->SetAxisBranchFactor( 2 );
vtkNew<vtkHyperTreeGridGeometry> geometry;
geometry->SetInputConnection( fractal->GetOutputPort() );
geometry->Update();
vtkPolyData* pd = geometry->GetOutput();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection( geometry->GetOutputPort() );
mapper->SetScalarRange( pd->GetCellData()->GetScalars()->GetRange() );
vtkNew<vtkActor> actor;
actor->SetMapper( mapper.GetPointer() );
// Create camera
double bd[3];
pd->GetBounds( bd );
vtkNew<vtkCamera> camera;
camera->SetClippingRange( 1., 100. );
camera->SetFocalPoint( pd->GetCenter() );
camera->SetPosition( .5 * bd[1], .5 * bd[3], 13 );
// Create a renderer, add actors to it
vtkNew<vtkRenderer> renderer;
renderer->SetActiveCamera( camera.GetPointer() );
renderer->SetBackground( 1., 1., 1. );
renderer->AddActor( actor.GetPointer() );
// Create a renderWindow
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer( renderer.GetPointer() );
renWin->SetSize( 300, 300 );
renWin->SetMultiSamples( 0 );
// Create interactor
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow( renWin.GetPointer() );
// Render and test
renWin->Render();
int retVal = vtkRegressionTestImage( renWin.GetPointer() );
if ( retVal == vtkRegressionTester::DO_INTERACTOR )
{
iren->Start();
}
return !retVal;
}
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