Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkSurfaceToPointSetFilter.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 
18 
19 // mitk headers
20 #include "mitkPointSet.h"
21 
22 // itk headers
23 #include "itkMatrix.h"
24 #include "itkVector.h"
25 
26 // vtk headers
27 #include <vtkCleanPolyData.h>
28 #include <vtkPolyData.h>
29 
31 {
32  this->SetNumberOfIndexedOutputs(1);
33 }
34 
36 {
37 }
38 
40 {
41  if (m_InputSurface.IsNull())
42  {
43  this->SetNthOutput(0, nullptr);
44  m_ErrorMessage = "Error in SurfaceToPointSetFilter: Input is not set correctly.";
45  return;
46  }
48 
49  vtkPolyData *points = this->m_InputSurface->GetVtkPolyData();
50  vtkCleanPolyData *cleaner = vtkCleanPolyData::New();
51  cleaner->PieceInvariantOff();
52  cleaner->ConvertLinesToPointsOff();
53  cleaner->ConvertPolysToLinesOff();
54  cleaner->ConvertStripsToPolysOff();
55  cleaner->PointMergingOn();
56  cleaner->SetInputData(points);
57  cleaner->Update();
58 
59  vtkPolyData *mergedPoints = cleaner->GetOutput();
60 
61  // generate filter output
62  for (int i = 0; i < mergedPoints->GetNumberOfPoints(); i++)
63  {
64  mitk::Point3D currentPoint;
65  currentPoint[0] = mergedPoints->GetPoint(i)[0];
66  currentPoint[1] = mergedPoints->GetPoint(i)[1];
67  currentPoint[2] = mergedPoints->GetPoint(i)[2];
68  result->InsertPoint(i, currentPoint);
69  }
70  this->SetNthOutput(0, result);
71  //-------------------------
72 
73  cleaner->Delete();
74 }
75 
77 {
78  m_InputSurface = InputSurface;
79  this->Modified();
80 }
81 
83 {
84  return this->m_ErrorMessage;
85 }
virtual void GenerateData() override
method generating the output of this filter. Called in the updated process of the pipeline...
static Pointer New()
void SetInput(mitk::Surface::Pointer m_InputSurface)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.