Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMeshTest.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 <fstream>
18 #include <mitkInteractionConst.h>
19 #include <mitkMesh.h>
20 #include <mitkNumericTypes.h>
21 #include <mitkPointOperation.h>
22 
23 int mitkMeshTest(int /*argc*/, char * /*argv*/ [])
24 {
25  // Create mesh
27  mesh = mitk::Mesh::New();
28 
29  // try to get the itkmesh
30  std::cout << "Create a mesh and try to get the itkMesh";
31  mitk::Mesh::DataType::Pointer itkdata = nullptr;
32  itkdata = mesh->GetMesh();
33  if (itkdata.IsNull())
34  {
35  std::cout << "[FAILED]" << std::endl;
36  return EXIT_FAILURE;
37  }
38 
39  // fresh mesh has to be empty!
40  std::cout << "Is the mesh empty?";
41  if (mesh->GetSize() != 0)
42  {
43  std::cout << "[FAILED]" << std::endl;
44  return EXIT_FAILURE;
45  }
46 
47  // create an operation and add a point.
48  int position = 0;
49  mitk::Point3D point;
50  point.Fill(1);
51  auto doOp = new mitk::PointOperation(mitk::OpINSERT, point, position);
52  mesh->ExecuteOperation(doOp);
53 
54  // now check new condition!
55  if ((mesh->GetSize() != 1) || (!mesh->IndexExists(position)))
56  {
57  std::cout << "[FAILED]" << std::endl;
58  return EXIT_FAILURE;
59  }
60  delete doOp;
61 
62  // get the point and check if it is still the same
63  std::cout << "Create an operation and add a point. Then try to get that point.";
64  mitk::Point3D tempPoint;
65  tempPoint.Fill(0);
66  tempPoint = mesh->GetPoint(position);
67  if (tempPoint != point)
68  {
69  std::cout << "[FAILED]" << std::endl;
70  return EXIT_FAILURE;
71  }
72 
73  // well done!!! Passed!
74  std::cout << "[PASSED]" << std::endl;
75 
76  std::cout << "[TEST DONE]" << std::endl;
77  return EXIT_SUCCESS;
78 }
itk::SmartPointer< Self > Pointer
static Pointer New()
Constants for most interaction classes, due to the generic StateMachines.
Operation that handles all actions on one Point.
int mitkMeshTest(int, char *[])