Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkContourSet.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 "mitkContourSet.h"
15 
17 {
19  timeGeometry->Initialize(1);
20  SetTimeGeometry(timeGeometry);
21 }
22 
24 {
25 }
26 
27 void mitk::ContourSet::AddContour(unsigned int index, mitk::Contour::Pointer contour)
28 {
29  m_ContourVector.insert(std::make_pair(index, contour));
30 }
31 
32 void mitk::ContourSet::RemoveContour(unsigned long index)
33 {
34  m_ContourVector.erase(index);
35 }
36 
38 {
40  auto contoursIterator = contourVec.begin();
41  auto contoursIteratorEnd = contourVec.end();
42 
43  // initialize container
44  mitk::BoundingBox::PointsContainer::Pointer pointscontainer = mitk::BoundingBox::PointsContainer::New();
45 
46  mitk::BoundingBox::PointIdentifier pointid = 0;
47  mitk::Point3D point;
48 
50  mitk::AffineTransform3D::Pointer inverse = mitk::AffineTransform3D::New();
51  transform->GetInverse(inverse);
52 
53  // calculate a bounding box that includes all contours
54  // \todo probably we should do this additionally for each time-step
55  while (contoursIterator != contoursIteratorEnd)
56  {
57  const TimeGeometry *geometry = (*contoursIterator).second->GetUpdatedTimeGeometry();
58  unsigned char i;
59  for (i = 0; i < 8; ++i)
60  {
61  point = inverse->TransformPoint(geometry->GetCornerPointInWorld(i));
62  if (point[0] * point[0] + point[1] * point[1] + point[2] * point[2] < mitk::large)
63  pointscontainer->InsertElement(pointid++, point);
64  else
65  {
66  itkGenericOutputMacro(<< "Unrealistically distant corner point encountered. Ignored. BoundingObject: "
67  << (*contoursIterator).second);
68  }
69  }
70  ++contoursIterator;
71  }
72 
73  mitk::BoundingBox::Pointer boundingBox = mitk::BoundingBox::New();
74  boundingBox->SetPoints(pointscontainer);
75  boundingBox->ComputeBoundingBox();
76 
77  BaseGeometry *geometry3d = GetGeometry(0);
78  geometry3d->SetIndexToWorldTransform(transform);
79  geometry3d->SetBounds(boundingBox->GetBounds());
80 
82  timeGeometry->Initialize(geometry3d, GetTimeGeometry()->CountTimeSteps());
83  SetTimeGeometry(timeGeometry);
84 }
85 
87 {
88 }
89 
91 {
92  return true;
93 }
94 
96 {
97  return true;
98 }
99 
100 void mitk::ContourSet::SetRequestedRegion(const itk::DataObject *)
101 {
102 }
103 
105 {
106  m_ContourVector = ContourVectorType();
108  timeGeometry->Initialize(1);
109  SetTimeGeometry(timeGeometry);
110 }
111 
113 {
114  return m_ContourVector.size();
115 }
116 
118 {
119  return m_ContourVector;
120 }
Point3D GetCornerPointInWorld(int id) const
Get the position of the corner number id (in world coordinates)
void SetIndexToWorldTransform(mitk::AffineTransform3D *transform)
bool VerifyRequestedRegion() override
virtual void SetTimeGeometry(TimeGeometry *geometry)
Set the TimeGeometry of the data, which will be referenced (not copied!).
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
void UpdateOutputInformation() override
void SetRequestedRegionToLargestPossibleRegion() override
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
void Initialize() override
itk::AffineGeometryFrame< ScalarType, 3 >::TransformType AffineTransform3D
std::map< unsigned long, Contour::Pointer > ContourVectorType
MITKCORE_EXPORT const double large
ContourVectorType GetContours()
void SetBounds(const BoundsArrayType &bounds)
Set the bounding box (in index/unit coordinates)
void SetRequestedRegion(const itk::DataObject *data) override
void AddContour(unsigned int index, mitk::Contour::Pointer contour)
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:138
~ContourSet() override
BaseGeometry Describes the geometry of a data object.
void RemoveContour(unsigned long index)
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
unsigned int GetNumberOfContours()