diff --git a/IO/Geometry/Testing/Cxx/CMakeLists.txt b/IO/Geometry/Testing/Cxx/CMakeLists.txt index 10593e8a5fe5b997c06f10273692675b89062b5c..3de3ddd1c2f7c4ed5839dacb2347ce80aa96e658 100644 --- a/IO/Geometry/Testing/Cxx/CMakeLists.txt +++ b/IO/Geometry/Testing/Cxx/CMakeLists.txt @@ -17,6 +17,11 @@ ExternalData_Expand_Arguments(VTKData _ "DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/system/,REGEX:.*}" ) vtk_add_test_cxx( + TestDataObjectIO.cxx + TestIncrementalOctreePointLocator.cxx + UnstructuredGridCellGradients.cxx + UnstructuredGridFastGradients.cxx + UnstructuredGridGradients.cxx TestOpenFOAMReader.cxx TestProStarReader.cxx TestTecplotReader.cxx diff --git a/IO/Geometry/Testing/Cxx/TestDataObjectIO.cxx b/IO/Geometry/Testing/Cxx/TestDataObjectIO.cxx index 24c29217e8904f783852555cea2dfccdd2837b82..dc1e7a5fb232428f6d9172b0020ee357ff2ae184 100644 --- a/IO/Geometry/Testing/Cxx/TestDataObjectIO.cxx +++ b/IO/Geometry/Testing/Cxx/TestDataObjectIO.cxx @@ -1,126 +1,34 @@ -#include <vtkCellData.h> -#include <vtkCubeSource.h> -#include <vtkDataObjectWriter.h> -#include <vtkDelaunay3D.h> -#include <vtkDirectedGraph.h> -#include <vtkEdgeListIterator.h> -#include <vtkGenericDataObjectReader.h> -#include <vtkGenericDataObjectWriter.h> -#include <vtkGraph.h> -#include <vtkImageData.h> -#include <vtkImageNoiseSource.h> -#include <vtkIntArray.h> -#include <vtkMutableDirectedGraph.h> -#include <vtkPointData.h> -#include <vtkPolyData.h> -#include <vtkRandomGraphSource.h> -#include <vtkRectilinearGrid.h> -#include <vtkSmartPointer.h> -#include <vtkStructuredGrid.h> -#include <vtkTable.h> -#include <vtkTree.h> -#include <vtkUndirectedGraph.h> -#include <vtkUnstructuredGrid.h> -#include <vtkVariant.h> -#include <vtkMultiBlockDataSet.h> -#include <vtkMultiPieceDataSet.h> - -void InitializeData(vtkDirectedGraph* Data) -{ - vtkRandomGraphSource* const source = vtkRandomGraphSource::New(); - source->SetNumberOfVertices(5); - source->SetNumberOfEdges(10); - source->IncludeEdgeWeightsOn(); - source->DirectedOn(); - source->UseEdgeProbabilityOff(); - source->StartWithTreeOff(); - source->AllowSelfLoopsOff(); - source->Update(); - - Data->ShallowCopy(source->GetOutput()); - source->Delete(); -} - -void InitializeData(vtkUndirectedGraph* Data) -{ - vtkRandomGraphSource* const source = vtkRandomGraphSource::New(); - source->SetNumberOfVertices(5); - source->SetNumberOfEdges(10); - source->IncludeEdgeWeightsOn(); - source->DirectedOff(); - source->UseEdgeProbabilityOff(); - source->StartWithTreeOff(); - source->AllowSelfLoopsOff(); - source->Update(); - - Data->ShallowCopy(source->GetOutput()); - source->Delete(); -} - -bool CompareData(vtkGraph* Output, vtkGraph* Input) -{ - bool inputDirected = (vtkDirectedGraph::SafeDownCast(Input) != 0); - bool outputDirected = (vtkDirectedGraph::SafeDownCast(Output) != 0); - if(inputDirected != outputDirected) - return false; - - if(Input->GetNumberOfVertices() != Output->GetNumberOfVertices()) - return false; - - if(Input->GetNumberOfEdges() != Output->GetNumberOfEdges()) - return false; - - if(Input->GetVertexData()->GetNumberOfArrays() != Output->GetVertexData()->GetNumberOfArrays()) - return false; - - if(Input->GetEdgeData()->GetNumberOfArrays() != Output->GetEdgeData()->GetNumberOfArrays()) - return false; - - vtkEdgeListIterator *inputEdges = vtkEdgeListIterator::New(); - vtkEdgeListIterator *outputEdges = vtkEdgeListIterator::New(); - while(inputEdges->HasNext()) - { - vtkEdgeType inputEdge = inputEdges->Next(); - vtkEdgeType outputEdge = outputEdges->Next(); - if(inputEdge.Source != outputEdge.Source) - return false; - - if(inputEdge.Target != outputEdge.Target) - return false; - - if(inputEdge.Id != outputEdge.Id) - return false; - } - inputEdges->Delete(); - outputEdges->Delete(); - - return true; -} - -void InitializeData(vtkImageData* Data) -{ - vtkImageNoiseSource* const source = vtkImageNoiseSource::New(); - source->SetWholeExtent(0, 15, 0, 15, 0, 0); - source->Update(); - - Data->ShallowCopy(source->GetOutput()); - source->Delete(); -} - -bool CompareData(vtkImageData* Output, vtkImageData* Input) -{ - if(memcmp(Input->GetDimensions(), Output->GetDimensions(), 3 * sizeof(int))) - return false; - - const int point_count = Input->GetDimensions()[0] * Input->GetDimensions()[1] * Input->GetDimensions()[2]; - for(int point = 0; point != point_count; ++point) - { - if(memcmp(Input->GetPoint(point), Output->GetPoint(point), 3 * sizeof(double))) - return false; - } - - return true; -} +/*========================================================================= + + Program: Visualization Toolkit + Module: TestDataObjectIO.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 "vtkCellData.h" +#include "vtkCubeSource.h" +#include "vtkDataObjectWriter.h" +#include "vtkDelaunay3D.h" +#include "vtkEdgeListIterator.h" +#include "vtkGenericDataObjectReader.h" +#include "vtkGenericDataObjectWriter.h" +#include "vtkIntArray.h" +#include "vtkPointData.h" +#include "vtkPolyData.h" +#include "vtkRectilinearGrid.h" +#include "vtkSmartPointer.h" +#include "vtkStructuredGrid.h" +#include "vtkTable.h" +#include "vtkUnstructuredGrid.h" +#include "vtkVariant.h" +#include "vtkMultiPieceDataSet.h" void InitializeData(vtkPolyData* Data) { @@ -212,64 +120,6 @@ bool CompareData(vtkTable* Output, vtkTable* Input) return true; } -void InitializeData(vtkTree* Data) -{ - vtkPoints *pts = vtkPoints::New(); - vtkMutableDirectedGraph *g = vtkMutableDirectedGraph::New(); - for (vtkIdType i = 0; i < 5; ++i) - { - g->AddVertex(); - pts->InsertNextPoint(i, 0, 0); - } - g->AddEdge(2, 0); - g->AddEdge(0, 1); - g->AddEdge(0, 3); - g->AddEdge(0, 4); - g->SetPoints(pts); - - if (!Data->CheckedShallowCopy(g)) - { - cerr << "Invalid tree structure." << endl; - } - - g->Delete(); - pts->Delete(); -} - -bool CompareData(vtkTree* Output, vtkTree* Input) -{ - if(Input->GetNumberOfVertices() != Output->GetNumberOfVertices()) - return false; - - if(Input->GetNumberOfEdges() != Output->GetNumberOfEdges()) - return false; - - if(Input->GetVertexData()->GetNumberOfArrays() != Output->GetVertexData()->GetNumberOfArrays()) - return false; - - if(Input->GetEdgeData()->GetNumberOfArrays() != Output->GetEdgeData()->GetNumberOfArrays()) - return false; - - if(Input->GetRoot() != Output->GetRoot()) - return false; - - double inx[3]; - double outx[3]; - for(vtkIdType child = 0; child != Input->GetNumberOfVertices(); ++child) - { - Input->GetPoint(child, inx); - Output->GetPoint(child, outx); - - if (inx[0] != outx[0] || inx[1] != outx[1] || inx[2] != outx[2]) - return false; - - if(Input->GetParent(child) != Output->GetParent(child)) - return false; - } - - return true; -} - void InitializeData(vtkUnstructuredGrid* Data) { vtkCubeSource* const source = vtkCubeSource::New(); @@ -293,46 +143,6 @@ bool CompareData(vtkUnstructuredGrid* Output, vtkUnstructuredGrid* Input) return true; } -void InitializeData(vtkMultiBlockDataSet* data) -{ - vtkPolyData* block0 = vtkPolyData::New(); - InitializeData(block0); - - vtkUnstructuredGrid* block1 = vtkUnstructuredGrid::New(); - InitializeData(block1); - - vtkPolyData* block2 = vtkPolyData::New(); - InitializeData(block2); - - vtkImageData* block3 = vtkImageData::New(); - InitializeData(block3); - - vtkMultiBlockDataSet* child0 = vtkMultiBlockDataSet::New(); - data->SetBlock(0, child0); - child0->Delete(); - - child0->SetBlock(0, block0); - block0->Delete(); - - vtkMultiPieceDataSet* child1 = vtkMultiPieceDataSet::New(); - child0->SetBlock(1, child1); - child1->Delete(); - - child1->SetPiece(0, block1); - block1->Delete(); - child1->SetPiece(1, block2); - block2->Delete(); - - data->SetBlock(1, block3); - block3->Delete(); -} - -bool CompareData(vtkMultiBlockDataSet*, vtkMultiBlockDataSet*) -{ - return true; -} - - template<typename DataT> bool TestDataObjectSerialization() { @@ -372,27 +182,6 @@ int TestDataObjectIO(int /*argc*/, char* /*argv*/[]) { int result = 0; - if(!TestDataObjectSerialization<vtkMultiBlockDataSet>()) - { - cerr << "Error: failure serializing vtkMultiBlockDataSet" << endl; - result = 1; - } - - if(!TestDataObjectSerialization<vtkDirectedGraph>()) - { - cerr << "Error: failure serializing vtkDirectedGraph" << endl; - result = 1; - } - if(!TestDataObjectSerialization<vtkUndirectedGraph>()) - { - cerr << "Error: failure serializing vtkUndirectedGraph" << endl; - result = 1; - } - if(!TestDataObjectSerialization<vtkImageData>()) - { - cerr << "Error: failure serializing vtkImageData" << endl; - result = 1; - } if(!TestDataObjectSerialization<vtkPolyData>()) { cerr << "Error: failure serializing vtkPolyData" << endl; @@ -413,11 +202,6 @@ int TestDataObjectIO(int /*argc*/, char* /*argv*/[]) cerr << "Error: failure serializing vtkTable" << endl; result = 1; } - if(!TestDataObjectSerialization<vtkTree>()) - { - cerr << "Error: failure serializing vtkTree" << endl; - result = 1; - } if(!TestDataObjectSerialization<vtkUnstructuredGrid>()) { cerr << "Error: failure serializaing vtkUnstructuredGrid" << endl; diff --git a/IO/Geometry/Testing/Data/Baseline/UnstructuredGridCellGradients.png.md5 b/IO/Geometry/Testing/Data/Baseline/UnstructuredGridCellGradients.png.md5 new file mode 100644 index 0000000000000000000000000000000000000000..af7d4e84609719a3cc1adc053bafafd6d7627105 --- /dev/null +++ b/IO/Geometry/Testing/Data/Baseline/UnstructuredGridCellGradients.png.md5 @@ -0,0 +1 @@ +29404a4399b34035feb8f3f3cd59009b diff --git a/IO/Geometry/Testing/Data/Baseline/UnstructuredGridFastGradients.png.md5 b/IO/Geometry/Testing/Data/Baseline/UnstructuredGridFastGradients.png.md5 new file mode 100644 index 0000000000000000000000000000000000000000..377b6d424c1b4f2f0d7e97420cd6c75054148aed --- /dev/null +++ b/IO/Geometry/Testing/Data/Baseline/UnstructuredGridFastGradients.png.md5 @@ -0,0 +1 @@ +7e5537d483ad6592169317267034376a diff --git a/IO/Geometry/Testing/Data/Baseline/UnstructuredGridGradients.png.md5 b/IO/Geometry/Testing/Data/Baseline/UnstructuredGridGradients.png.md5 new file mode 100644 index 0000000000000000000000000000000000000000..34fd3e81a6b9c2ea190e299b20f94bf4bf2fa967 --- /dev/null +++ b/IO/Geometry/Testing/Data/Baseline/UnstructuredGridGradients.png.md5 @@ -0,0 +1 @@ +d682ae33081bb64d6d4a4aa66da837fd