Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkSurfaceVtkWriterTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkIOUtil.h"
18 #include "mitkSurface.h"
19 #include "mitkTestingMacros.h"
20 
21 #include <vtkPolyDataReader.h>
22 #include <vtkPolyDataWriter.h>
23 
24 #include <iostream>
25 
34 int mitkSurfaceVtkWriterTest(int /*argc*/, char *argv[])
35 {
36  // always start with this!
37  MITK_TEST_BEGIN("SurfaceVtkWriter")
38 
39  // create contour
40  vtkPolyDataReader *reader = vtkPolyDataReader::New();
41  reader->SetFileName(argv[1]);
42  reader->Update();
43  if (reader->GetOutput())
44  {
46  surface->SetVtkPolyData(reader->GetOutput());
47  surface->Update();
48 
49  MITK_TEST_CONDITION_REQUIRED(surface.IsNotNull(), "Surface creation")
50 
51  try
52  {
53  // test for exception handling
54  mitk::IOUtil::Save(surface, "/usr/bin");
55  MITK_TEST_FAILED_MSG(<< "itk::ExceptionObject expected")
56  }
57  catch (const mitk::Exception &)
58  { /* this is expected */
59  }
60  catch (...)
61  {
62  // this means that a wrong exception (i.e. no itk:Exception) has been thrown
63  MITK_TEST_FAILED_MSG(<< "Wrong exception (i.e. no itk:Exception) caught during write [FAILED]")
64  }
65 
66  // write your own tests here and use the macros from mitkTestingMacros.h !!!
67  // do not write to std::cout and do not return from this function yourself!
68  }
69 
70  // Delete reader correctly
71  reader->Delete();
72 
73  // always end with this!
75 }
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
Definition: mitkIOUtil.cpp:824
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:49
#define MITK_TEST_FAILED_MSG(MSG)
Fail and finish test with message MSG.
int mitkSurfaceVtkWriterTest(int, char *argv[])
and MITK_TEST_END()
static Pointer New()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.