Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPlanarLine.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 "mitkPlanarLine.h"
18 #include "mitkPlaneGeometry.h"
19 
20 mitk::PlanarLine::PlanarLine() : FEATURE_ID_LENGTH(this->AddFeature("Length", "mm"))
21 {
22  // Line has two control points
24 
25  this->SetNumberOfPolyLines(1);
26 }
27 
29 {
30  this->ClearPolyLines();
31 
32  this->AppendPointToPolyLine(0, this->GetControlPoint(0));
33  this->AppendPointToPolyLine(0, this->GetControlPoint(1));
34 }
35 
36 void mitk::PlanarLine::GenerateHelperPolyLine(double /*mmPerDisplayUnit*/, unsigned int /*displayHeight*/)
37 {
38  // A line does not require a helper object
39 }
40 
42 {
43  // Calculate line length
44  const Point3D &p0 = this->GetWorldControlPoint(0);
45  const Point3D &p1 = this->GetWorldControlPoint(1);
46  double length = p0.EuclideanDistanceTo(p1);
47 
48  this->SetQuantity(FEATURE_ID_LENGTH, length);
49 }
50 
51 void mitk::PlanarLine::PrintSelf(std::ostream &os, itk::Indent indent) const
52 {
53  Superclass::PrintSelf(os, indent);
54 }
55 
56 bool mitk::PlanarLine::Equals(const PlanarFigure &other) const
57 {
58  const mitk::PlanarLine *otherLine = dynamic_cast<const mitk::PlanarLine *>(&other);
59  if (otherLine)
60  {
61  return Superclass::Equals(other);
62  }
63  else
64  {
65  return false;
66  }
67 }
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override
void ResetNumberOfControlPoints(int numberOfControlPoints)
Set the initial number of control points of the planar figure.
virtual bool Equals(const mitk::PlanarFigure &other) const override
Compare two PlanarFigure objects Note: all subclasses have to implement the method on their own...
virtual void EvaluateFeaturesInternal() override
Calculates feature quantities of the planar figure.
virtual void GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight) override
Generates the poly-lines that should be drawn the same size regardless of zoom.
void SetNumberOfPolyLines(unsigned int numberOfPolyLines)
defines the number of PolyLines that will be available
Implementation of PlanarFigure representing a line through two control points.
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
virtual void GeneratePolyLine() override
Generates the poly-line representation of the planar figure.