00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2009-09-17 13:15:38 +0200 (Do, 17 Sep 2009) $ 00006 Version: $Revision: 19014 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #include "mitkImage.h" 00020 #include "mitkSTLFileReader.h" 00021 #include "mitkTimeSlicedGeometry.h" 00022 #include "mitkSlicedGeometry3D.h" 00023 #include "mitkSurface.h" 00024 #include "mitkTestingMacros.h" 00025 #include <vtkSTLReader.h> 00026 #include <vtkPolyData.h> 00027 #include <vtkSmartPointer.h> 00028 00029 #include <fstream> 00030 int mitkSTLFileReaderTest(int argc, char* argv[]) 00031 { 00032 // always start with this! 00033 MITK_TEST_BEGIN("STLFileReader") 00034 00035 //Read STL-Image from file 00036 mitk::STLFileReader::Pointer reader = mitk::STLFileReader::New(); 00037 00038 if(argc==0) 00039 { 00040 std::cout<<"file not found - test not applied [PASSED]"<<std::endl; 00041 std::cout<<"[TEST DONE]"<<std::endl; 00042 return EXIT_SUCCESS; 00043 } 00044 00045 std::cout << "Testing CanReadFile(): "; 00046 if (!reader->CanReadFile(argv[1], "", "")) 00047 { 00048 //std::cout<<"[FAILED]"<<std::endl; 00049 //return EXIT_FAILURE; 00050 MITK_TEST_OUTPUT(<< mitkTestName << ": "<< mitk::TestManager::GetInstance()->NumberOfPassedTests() << " tests [DONE PASSED] File is not STL!") 00051 return EXIT_SUCCESS; 00052 } 00053 std::cout<<"[PASSED]"<<std::endl; 00054 00055 reader->SetFileName(argv[1]); 00056 reader->Update(); 00057 00058 MITK_TEST_CONDITION_REQUIRED((reader->GetOutput() != NULL),"Reader output not NULL") 00059 00060 mitk::Surface::Pointer surface = reader->GetOutput(); 00061 MITK_TEST_CONDITION_REQUIRED(surface->IsInitialized(),"IsInitialized()") 00062 00063 MITK_TEST_CONDITION_REQUIRED((surface->GetVtkPolyData()!=NULL),"mitk::Surface::SetVtkPolyData()") 00064 00065 MITK_TEST_CONDITION_REQUIRED((surface->GetGeometry()!=NULL),"Availability of geometry") 00066 00067 vtkSmartPointer<vtkSTLReader> myVtkSTLReader = vtkSmartPointer<vtkSTLReader>::New(); 00068 myVtkSTLReader->SetFileName( argv[1] ); 00069 myVtkSTLReader->Update(); 00070 vtkSmartPointer<vtkPolyData> myVtkPolyData = myVtkSTLReader->GetOutput(); 00071 // vtkPolyData from vtkSTLReader directly 00072 int n = myVtkPolyData->GetNumberOfPoints(); 00073 // vtkPolyData from mitkSTLFileReader 00074 int m = surface->GetVtkPolyData()->GetNumberOfPoints(); 00075 MITK_TEST_CONDITION_REQUIRED((n == m),"Number of Points in VtkPolyData") 00076 00077 // always end with this! 00078 MITK_TEST_END() 00079 }