Medical Imaging Interaction Toolkit  2018.4.99-f51274ea
Medical Imaging Interaction Toolkit
mitkContour.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 "mitkContour.h"
15 
17  : m_ContourPath(PathType::New()),
18  m_CurrentWindow(nullptr),
19  m_BoundingBox(BoundingBoxType::New()),
20  m_Vertices(BoundingBoxType::PointsContainer::New()),
21  m_Closed(true),
22  m_Selected(false),
23  m_Width(3.0)
24 {
25  Superclass::InitializeTimeGeometry();
26 }
27 
29  : BaseData(other),
30  m_ContourPath(other.m_ContourPath),
31  m_CurrentWindow(other.m_CurrentWindow),
32  m_BoundingBox(other.m_BoundingBox),
33  m_Vertices(other.m_Vertices),
34  m_Closed(other.m_Closed),
35  m_Selected(other.m_Selected),
36  m_Width(other.m_Width)
37 {
38 }
39 
41 {
42 }
43 
45 {
46  BoundingBoxType::PointType p;
47  p.CastFrom(newPoint);
48  m_Vertices->InsertElement(m_Vertices->Size(), p);
50  idx.CastFrom(newPoint);
51  m_ContourPath->AddVertex(idx);
52  m_BoundingBox->SetPoints(m_Vertices);
53  Modified();
54 }
55 
57 {
58  // \todo probably we should do this additionally for each time-step
59  ScalarType mitkBounds[6];
60  if (m_Vertices->Size() == 0)
61  {
62  mitkBounds[0] = 0.0;
63  mitkBounds[1] = 0.0;
64  mitkBounds[2] = 0.0;
65  mitkBounds[3] = 0.0;
66  mitkBounds[4] = 0.0;
67  mitkBounds[5] = 0.0;
68  }
69  else
70  {
71  m_BoundingBox->ComputeBoundingBox();
72  BoundingBoxType::BoundsArrayType tmp = m_BoundingBox->GetBounds();
73  mitkBounds[0] = tmp[0];
74  mitkBounds[1] = tmp[1];
75  mitkBounds[2] = tmp[2];
76  mitkBounds[3] = tmp[3];
77  mitkBounds[4] = tmp[4];
78  mitkBounds[5] = tmp[5];
79  }
80  BaseGeometry *geometry3d = GetGeometry(0);
81  geometry3d->SetBounds(mitkBounds);
83 }
84 
86 {
87 }
88 
90 {
91  return false;
92 }
93 
95 {
96  return true;
97 }
98 
99 void mitk::Contour::SetRequestedRegion(const itk::DataObject *)
100 {
101 }
102 
103 mitk::Contour::PathType::Pointer mitk::Contour::GetContourPath() const
104 {
105  return m_ContourPath;
106 }
107 
108 void mitk::Contour::SetCurrentWindow(vtkRenderWindow *rw)
109 {
110  m_CurrentWindow = rw;
111 }
112 
113 vtkRenderWindow *mitk::Contour::GetCurrentWindow() const
114 {
115  return m_CurrentWindow;
116 }
117 
119 {
120  m_ContourPath = PathType::New();
121  m_ContourPath->Initialize();
122  m_BoundingBox = BoundingBoxType::New();
123  m_Vertices = BoundingBoxType::PointsContainer::New();
125  timeGeometry->Initialize(1);
126  SetTimeGeometry(timeGeometry);
127 }
128 
130 {
131  return m_Vertices->Size();
132 }
133 
135 {
136  return m_Vertices;
137 }
138 
140 {
141  m_Vertices = points;
142  Modified();
143 }
144 
145 void mitk::Contour::PrintSelf(std::ostream &os, itk::Indent indent) const
146 {
147  Superclass::PrintSelf(os, indent);
148 
149  os << indent << "Number of verticies: " << GetNumberOfPoints() << std::endl;
150 
151  mitk::Contour::PointsContainerIterator pointsIt = m_Vertices->Begin(), end = m_Vertices->End();
152 
153  os << indent << "Verticies: " << std::endl;
154 
155  int i = 0;
156  while (pointsIt != end)
157  {
158  os << indent << indent << i << ": " << pointsIt.Value() << std::endl;
159  ++pointsIt;
160  ++i;
161  }
162 }
void SetRequestedRegionToLargestPossibleRegion() override
Definition: mitkContour.cpp:85
BoundingBoxType::PointsContainerIterator PointsContainerIterator
Definition: mitkContour.h:51
Base of all data objects.
Definition: mitkBaseData.h:42
unsigned int GetNumberOfPoints() const
double ScalarType
void SetCurrentWindow(vtkRenderWindow *rw)
virtual void SetTimeGeometry(TimeGeometry *geometry)
Set the TimeGeometry of the data, which will be referenced (not copied!).
itk::PolyLineParametricPath< 3 > PathType
Definition: mitkContour.h:38
void Initialize() override
PathType::ContinuousIndexType ContinuousIndexType
Definition: mitkContour.h:42
void AddVertex(mitk::Point3D newPoint)
Definition: mitkContour.cpp:44
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Definition: mitkContour.cpp:89
Stores vertices for drawing a contour.
Definition: mitkContour.h:31
PointsContainerPointer GetPoints() const
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:66
itk::BoundingBox< unsigned long, 3, ScalarType, itk::VectorContainer< unsigned long, mitk::Point< ScalarType, 3 > > > BoundingBoxType
Definition: mitkContour.h:48
~Contour() override
Definition: mitkContour.cpp:40
BoundingBoxType::PointsContainer::Pointer PointsContainerPointer
Definition: mitkContour.h:50
void SetBounds(const BoundsArrayType &bounds)
Set the bounding box (in index/unit coordinates)
void SetRequestedRegion(const itk::DataObject *data) override
Definition: mitkContour.cpp:99
void SetPoints(PointsContainerPointer points)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
bool VerifyRequestedRegion() override
Definition: mitkContour.cpp:94
PathPointer GetContourPath() const
void Update()
Updates the geometry.
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:143
void UpdateOutputInformation() override
Definition: mitkContour.cpp:56
vtkRenderWindow * GetCurrentWindow() const
BoundingBoxType::PointsContainer PointsContainer
Definition: mitkContour.h:49
BaseGeometry Describes the geometry of a data object.
BoundingBoxType::BoundsArrayType BoundsArrayType