Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkContourSetToPointSetFilter.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 #include <mitkInteractionConst.h>
20 #include <mitkPointOperation.h>
21 
23 {
24  OutputType::Pointer output = dynamic_cast<OutputType *>(this->MakeOutput(0).GetPointer());
25  this->SetNumberOfRequiredInputs(1);
26  this->SetNumberOfIndexedOutputs(1);
27  this->SetNthOutput(0, output.GetPointer());
28  m_Frequency = 5;
29 }
30 
32 {
33 }
34 
36 {
37 }
38 
40 {
41  mitk::ContourSet *input = (mitk::ContourSet *)(this->GetInput());
42  mitk::PointSet::Pointer output = this->GetOutput();
43 
45  auto contourIt = contourVec.begin();
46  unsigned int pointId = 0;
47 
48  while (contourIt != contourVec.end())
49  {
50  mitk::Contour *nextContour = (mitk::Contour *)(*contourIt).second;
51 
52  mitk::Contour::InputType idx = nextContour->GetContourPath()->StartOfInput();
54  mitk::Contour::InputType end = nextContour->GetContourPath()->EndOfInput();
55  if (end > 50000)
56  end = 0;
57 
58  while (idx <= end)
59  {
60  point = nextContour->GetContourPath()->Evaluate(idx);
62  p.CastFrom(point);
63  mitk::PointOperation popInsert(mitk::OpINSERT, p, pointId++);
64  mitk::PointOperation popDeactivate(mitk::OpDESELECTPOINT, p, pointId++);
65  output->ExecuteOperation(&popInsert);
66  output->ExecuteOperation(&popDeactivate);
67 
68  idx += m_Frequency;
69  }
70  contourIt++;
71  }
72 }
73 
75 {
76  if (this->GetNumberOfInputs() < 1)
77  {
78  return nullptr;
79  }
80 
81  return static_cast<const mitk::ContourSet *>(this->BaseProcess::GetInput(0));
82 }
83 
85 {
86  // Process object is not const-correct so the const_cast is required here
87  this->BaseProcess::SetNthInput(0, const_cast<mitk::ContourSet *>(input));
88 }
mitk::Point3D PointType
virtual itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
Base of all data objects.
Definition: mitkBaseData.h:39
PathPointer GetContourPath() const
Constants for most interaction classes, due to the generic StateMachines.
Stores vertices for drawing a contour.
Definition: mitkContour.h:35
Operation that handles all actions on one Point.
PathType::OutputType OutputType
Definition: mitkContour.h:46
PathType::InputType InputType
Definition: mitkContour.h:45
std::map< unsigned long, Contour::Pointer > ContourVectorType
ContourVectorType GetContours()
virtual void SetInput(const mitk::ContourSet *contourSet)