Commit 617852b8 authored by Bill Lorensen's avatar Bill Lorensen
Browse files

ENH: Refactor testing

Change tests from using ExternalData_add_test to vtk_add_test_cxx.
Added baselines for the tests. Ghe OBJImport tests were not being run.
parent 6ec7ca86
ExternalData_add_test(VTKData
NAME vtkIOImportCxx-OBJImport-SolidAndTextured
COMMAND vtkIOImportCxxTests TestOBJImporter
# This is an alternative way to add a named test that uses a common executable
# Use this if it does not require MPI
vtk_add_test_cxx(vtkIOImportCxxTests tests
OBJImport-SolidAndTextured,TestOBJImporter.cxx
DATA{../Data/Input/cube-scene.obj}
DATA{../Data/Input/cube-scene.mtl}
DATA{../Data/Input/noise.png}
)
include(vtkOpenGL)
vtk_module_test_executable(vtkimportobj OBJImporter.cxx)
)
ExternalData_add_test(VTKData
NAME vtkIOImportCxx-OBJImport-MixedOrder1
COMMAND vtkimportobj
"${VTK_TEST_OUTPUT_DIR}"
vtk_add_test_cxx(vtkIOImportCxxTests tests
OBJImport-MixedOrder1,TestOBJImporter.cxx
DATA{../Data/Input/boxes_2.obj}
DATA{../Data/Input/boxes_2.obj.mtl}
DATA{../Data/Input/flare.jpg}
)
)
ExternalData_add_test(VTKData
NAME vtkIOImportCxx-OBJImport-NoMTL
COMMAND vtkimportobj
"${VTK_TEST_OUTPUT_DIR}"
vtk_add_test_cxx(vtkIOImportCxxTests tests
OBJImport-NoMTL,TestOBJImporter.cxx
DATA{../Data/Input/boxes_3_no_mtl.obj}
)
DATA{../Data/Input/boxes_2.obj.mtl}
DATA{../Data/Input/flare.jpg}
)
ExternalData_add_test(VTKData
NAME vtkIOImportCxx-OBJImport-MTLwithoutTextureFile
COMMAND vtkimportobj
"${VTK_TEST_OUTPUT_DIR}"
vtk_add_test_cxx(vtkIOImportCxxTests tests
OBJImport-MTLwithoutTextureFile,TestOBJImporter.cxx
DATA{../Data/Input/boxes_4_mtl_no_texture.obj}
DATA{../Data/Input/boxes_4_mtl_no_texture.obj.mtl}
)
)
# This is an alternative way to add a named test that uses a common executable
# Use this if it does not require MPI
vtk_add_test_cxx(vtkIOImportCxxTests tests
TestOBJImporter-DuplicateMaps,TestOBJImporter.cxx
DATA{../Data/Input/TestOBJImporter.obj}
......@@ -61,4 +53,5 @@ vtk_add_test_cxx(vtkIOImportCxxTests tests
TestVRMLNormals.cxx
)
vtk_test_cxx_executable(vtkIOImportCxxTests tests)
vtk_test_cxx_executable(vtkIOImportCxxTests tests
RENDERING_FACTORY)
#include "vtkVRMLImporter.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkOBJImporter.h"
#include "vtkTestUtilities.h"
#include "vtkNew.h"
#include "vtkJPEGWriter.h"
#include "vtkPNGWriter.h"
#include "vtkImageCanvasSource2D.h"
#include "vtkImageCast.h"
#include "vtkCamera.h"
#include "vtksys/SystemTools.hxx"
#include <sstream>
#include "vtkMapper.h"
#include "vtkXMLPolyDataWriter.h"
#include "vtkTriangleFilter.h"
int main( int argc, char * argv [] )
{
// note that the executable name is stripped out already
// so argc argv will not have it
// Files for testing demonstrate updated functionality for OBJ import:
// polydata + textures + actor properties all get loaded.
if(argc < 3)
{
std::cerr<<"expected vtkimportobj OutputDirectory File1.obj [File2.obj.mtl] [texture1]"<<std::endl;
return -1;
}
std::string filenameOBJ(argv[2]);
std::string filenameMTL,texfile1;
if(argc >= 4)
{
filenameMTL = argv[3];
}
if(argc >= 5)
{
texfile1 = argv[4];
}
std::string texture_path1 = vtksys::SystemTools::GetFilenamePath(texfile1);
vtkNew<vtkOBJImporter> importer;
if(argc > 5)
{
importer->DebugOn();
}
importer->SetFileName(filenameOBJ.data());
importer->SetFileNameMTL(filenameMTL.data());
importer->SetTexturePath(texture_path1.data());
vtkNew<vtkRenderer> ren;
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderWindowInteractor> iren;
renWin->AddRenderer(ren);
iren->SetRenderWindow(renWin);
importer->SetRenderWindow(renWin);
importer->Update();
ren->ResetCamera();
// save out data for actors
for (int i = 0; i < ren->GetActors()->GetNumberOfItems(); i++)
{
std::ostringstream os;
os << argv[1] << "/Model" << i << ".vtp";
vtkActor *act = (vtkActor *)ren->GetActors()->GetItemAsObject(i);
vtkNew<vtkTriangleFilter> trif;
trif->SetInputData((vtkDataObject *)act->GetMapper()->GetInput());
vtkNew<vtkXMLPolyDataWriter> writer;
writer->SetFileName(os.str().c_str());
writer->SetInputConnection(trif->GetOutputPort());
writer->Write();
std::string desc = importer->GetOutputDescription(i);
cerr << "Wrote " << os.str() << " " << desc << "\n";
}
if(ren->GetActors()->GetNumberOfItems() == 0)
{
std::cerr << "failed to get an actor created?!" << std::endl;
return -1;
}
ren->SetBackground(0.4,0.5,0.6);
ren->ResetCamera();
renWin->SetSize(800,600);
//iren->Start();
return 0;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestOBJImporter.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 "vtkNew.h"
#include "vtkOBJImporter.h"
#include "vtkVRMLImporter.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkOBJImporter.h"
#include "vtkTestUtilities.h"
#include "vtkNew.h"
#include "vtkJPEGWriter.h"
#include "vtkPNGWriter.h"
#include "vtkImageCanvasSource2D.h"
#include "vtkImageCast.h"
#include "vtkCamera.h"
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include "vtksys/SystemTools.hxx"
#include <sstream>
......@@ -28,8 +35,8 @@ int TestOBJImporter( int argc, char * argv [] )
// polydata + textures + actor properties all get loaded.
if(argc < 2)
{
std::cerr<<"expected TestName File1.obj [File2.obj.mtl] [texture1] ... "<<std::endl;
return -1;
std::cout <<"expected TestName File1.obj [File2.obj.mtl] [texture1] ... "<<std::endl;
return EXIT_FAILURE;
}
std::string filenameOBJ(argv[1]);
......@@ -48,12 +55,6 @@ int TestOBJImporter( int argc, char * argv [] )
std::string texture_path1 = vtksys::SystemTools::GetFilenamePath(texfile1);
vtkNew<vtkOBJImporter> importer;
if(argc > 4)
{
importer->DebugOn();
}
importer->SetFileName(filenameOBJ.data());
importer->SetFileNameMTL(filenameMTL.data());
importer->SetTexturePath(texture_path1.data());
......@@ -71,23 +72,14 @@ int TestOBJImporter( int argc, char * argv [] )
if( 1 > ren->GetActors()->GetNumberOfItems() )
{
std::cerr << "failed to get an actor created?!" << std::endl;
return -1;
std::cout << "failed to get an actor created?!" << std::endl;
return EXIT_FAILURE;
}
ren->GetActiveCamera()->SetPosition(10,10,-10);
ren->ResetCamera();
int retVal = vtkRegressionTestImage(renWin);
if( retVal == vtkRegressionTester::DO_INTERACTOR )
{
renWin->SetSize(800,600);
iren->Start();
}
renWin->SetSize(800,600);
iren->Start();
// Some tests do not produce images... allow them to pass.
// But if we had an image, it must be within the threshold:
return (
retVal == vtkRegressionTester::PASSED ||
retVal == vtkRegressionTester::NOT_RUN) ?
0 : 1;
return (EXIT_SUCCESS);
}
7189c8dd842a058f1e99c3692b8a971558b8d37991b29efc55de6f3f32aa4d6a0012c3ea985f3bfde6cdf535b0d7cf9748ff523803ae962c8e6f4eb010bc334d
a94f3749d6a923db0ce56a123eb91602d3de5d961d4bae6c6aa0446fa5fc8cefe39942d344fece801cb5aaaaf90714268f0c7acd11e03254cf832876c371279a
bd784e7f27e0c56b7ccd6964caf304be59d8345414a37332f2464fc35ea2eb4b7bb2a16abc52ecdf9bb128a5ffe876d688729ef58efe5402260aef3cbb5453c5
d2c63242023b6b7e30d87bfb6fc348145a09c0f2e0e699ea4952a9ea9f67ef5c73c163a1fa1801ece327d56182e0dc18f7717b49056ba5bb7695182a050ed1d8
0b96967bba88e62a308918927973008cae72c2c9b2fd1c45d7ff8c8b30a0e201d543c3271b7697d8ecd12927dc09043292061eb4bb33a2693d2d90d4ad72cb5f
fb867b8a2c48782a45204662b1854eefb003bfdfb5c6569344154d5d52344a359d8aa84bceac43a4c2c726b4808aba98496844ea75a3494c3e7559a6c5b1c20c
e9b4ce0444e4ff2d6c2ee29632291264c27babca45b25bb36f6bc200ce407f0f5ced1ea562661423ee790559ad5844afb8307826aef7ece1703af00781fc3d5b
61f689cbcca2b0c34d87f00def24c8c7310b57418408d8c9e5b112a2b1fafae7d1f592d2a83abc7bdaeefd76c722c3638f36ae5b5eb97a8f3383510289078862
c6e9845fb09d0d425fc434296bff47927eeff2720d5f6b619dcf08f4c61e496ba7e180b24561bbd0ecdfe85a61e7807e1c9e2708c07f3c1916248b7b4d266977
e29ead591b02c42b7ff62b63eb2edfecbee235b62d9468a2e3b96151a4e3368e97f3bd571683d1058c1f9fb3f35cbafce48d46a30d4a6092c69f24464c10a828
305d424f0a58735fddd0206acb1042fa46edc5e2da510b7a6416066b15ea485625c4da5f5fdd1c6fd9f23476b3145da1ddc476a476fa5abfe84d2f352f9b83d5
Supports Markdown
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