Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "mitkPlanarArrow.h"
00020 #include "mitkGeometry2D.h"
00021
00022
00023 mitk::PlanarArrow::PlanarArrow()
00024 : FEATURE_ID_LENGTH( this->AddFeature( "Length", "mm" ) )
00025 {
00026
00027 this->ResetNumberOfControlPoints( 2 );
00028
00029 m_PolyLines->InsertElement( 0, VertexContainerType::New());
00030
00031
00032 m_HelperPolyLines->InsertElement( 0, VertexContainerType::New());
00033 m_HelperPolyLines->InsertElement( 1, VertexContainerType::New());
00034 m_HelperPolyLines->ElementAt( 0 )->Reserve( 2 );
00035 m_HelperPolyLines->ElementAt( 1 )->Reserve( 2 );
00036 m_HelperPolyLinesToBePainted->InsertElement( 0, false );
00037 m_HelperPolyLinesToBePainted->InsertElement( 1, false );
00038 }
00039
00040
00041 mitk::PlanarArrow::~PlanarArrow()
00042 {
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 void mitk::PlanarArrow::GeneratePolyLine()
00074 {
00075
00076
00077 m_PolyLines->ElementAt( 0 )->Reserve( 2 );
00078 m_PolyLines->ElementAt( 0 )->ElementAt( 0 ) = m_ControlPoints->ElementAt( 0 );
00079 m_PolyLines->ElementAt( 0 )->ElementAt( 1 ) = m_ControlPoints->ElementAt( 1 );
00080 }
00081
00082 void mitk::PlanarArrow::GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight)
00083 {
00084
00085
00086 if ( this->GetNumberOfControlPoints() != 2 )
00087 {
00088 m_HelperPolyLinesToBePainted->SetElement( 0, false );
00089 m_HelperPolyLinesToBePainted->SetElement( 1, false );
00090
00091 return;
00092 }
00093
00094 m_HelperPolyLinesToBePainted->SetElement( 0, true );
00095 m_HelperPolyLinesToBePainted->SetElement( 1, true );
00096
00097
00098 double nonScalingLength = displayHeight * mmPerDisplayUnit * 0.015;
00099
00100
00101 const Point2D& p1 = m_ControlPoints->ElementAt( 0 );
00102 const Point2D& p2 = m_ControlPoints->ElementAt( 1 );
00103 Vector2D n1 = p1 - p2;
00104 n1.Normalize();
00105
00106 double degrees = 100.0;
00107 Vector2D temp;
00108 temp[0] = n1[0] * cos(degrees) - n1[1] * sin(degrees);
00109 temp[1] = n1[0] * sin(degrees) + n1[1] * cos(degrees);
00110 Vector2D temp2;
00111 temp2[0] = n1[0] * cos(-degrees) - n1[1] * sin(-degrees);
00112 temp2[1] = n1[0] * sin(-degrees) + n1[1] * cos(-degrees);
00113
00114 m_HelperPolyLines->ElementAt( 0 )->ElementAt( 0 ) = p1;
00115 m_HelperPolyLines->ElementAt( 0 )->ElementAt( 1 ) = p1 - temp * nonScalingLength;
00116 m_HelperPolyLines->ElementAt( 1 )->ElementAt( 0 ) = p1;
00117 m_HelperPolyLines->ElementAt( 1 )->ElementAt( 1 ) = p1 - temp2 * nonScalingLength;
00118
00119 }
00120
00121
00122 void mitk::PlanarArrow::EvaluateFeaturesInternal()
00123 {
00124
00125 const Point3D &p0 = this->GetWorldControlPoint( 0 );
00126 const Point3D &p1 = this->GetWorldControlPoint( 1 );
00127 double length = p0.EuclideanDistanceTo( p1 );
00128
00129 this->SetQuantity( FEATURE_ID_LENGTH, length );
00130 }
00131
00132
00133 void mitk::PlanarArrow::PrintSelf( std::ostream& os, itk::Indent indent) const
00134 {
00135 Superclass::PrintSelf( os, indent );
00136 }