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