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