Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <fstream>
14 #include <mitkInteractionConst.h>
15 #include <mitkMesh.h>
16 #include <mitkNumericTypes.h>
17 #include <mitkPointOperation.h>
18 
19 int mitkMeshTest(int /*argc*/, char * /*argv*/ [])
20 {
21  // Create mesh
23  mesh = mitk::Mesh::New();
24 
25  // try to get the itkmesh
26  std::cout << "Create a mesh and try to get the itkMesh";
27  mitk::Mesh::DataType::Pointer itkdata = nullptr;
28  itkdata = mesh->GetMesh();
29  if (itkdata.IsNull())
30  {
31  std::cout << "[FAILED]" << std::endl;
32  return EXIT_FAILURE;
33  }
34 
35  // fresh mesh has to be empty!
36  std::cout << "Is the mesh empty?";
37  if (mesh->GetSize() != 0)
38  {
39  std::cout << "[FAILED]" << std::endl;
40  return EXIT_FAILURE;
41  }
42 
43  // create an operation and add a point.
44  int position = 0;
45  mitk::Point3D point;
46  point.Fill(1);
47  auto doOp = new mitk::PointOperation(mitk::OpINSERT, point, position);
48  mesh->ExecuteOperation(doOp);
49 
50  // now check new condition!
51  if ((mesh->GetSize() != 1) || (!mesh->IndexExists(position)))
52  {
53  std::cout << "[FAILED]" << std::endl;
54  return EXIT_FAILURE;
55  }
56  delete doOp;
57 
58  // get the point and check if it is still the same
59  std::cout << "Create an operation and add a point. Then try to get that point.";
60  mitk::Point3D tempPoint;
61  tempPoint.Fill(0);
62  tempPoint = mesh->GetPoint(position);
63  if (tempPoint != point)
64  {
65  std::cout << "[FAILED]" << std::endl;
66  return EXIT_FAILURE;
67  }
68 
69  // well done!!! Passed!
70  std::cout << "[PASSED]" << std::endl;
71 
72  std::cout << "[TEST DONE]" << std::endl;
73  return EXIT_SUCCESS;
74 }
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 *[])