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 "mitkPlanarCircle.h"
00020 #include "mitkGeometry2D.h"
00021
00022 #include "mitkProperties.h"
00023
00024
00025 mitk::PlanarCircle::PlanarCircle()
00026 : FEATURE_ID_RADIUS( this->AddFeature( "Radius", "mm" ) ),
00027 FEATURE_ID_DIAMETER( this->AddFeature( "Diameter", "mm" ) ),
00028 FEATURE_ID_AREA( this->AddFeature( "Area", "mm^2" ) )
00029 {
00030
00031 this->ResetNumberOfControlPoints( 2 );
00032 this->SetProperty( "closed", mitk::BoolProperty::New(true) );
00033
00034 m_PolyLines->InsertElement( 0, VertexContainerType::New());
00035 }
00036
00037
00038 mitk::PlanarCircle::~PlanarCircle()
00039 {
00040 }
00041
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 bool mitk::PlanarCircle::SetControlPoint( unsigned int index, const Point2D &point, bool )
00070 {
00071
00072 if(index == 0)
00073 {
00074 const Point2D ¢erPoint = m_ControlPoints->ElementAt( 0 );
00075 Point2D boundaryPoint = m_ControlPoints->ElementAt( 1 );
00076 vnl_vector<float> vec = (point.GetVnlVector() - centerPoint.GetVnlVector());
00077
00078 boundaryPoint[0] += vec[0];
00079 boundaryPoint[1] += vec[1];
00080 m_ControlPoints->InsertElement( 0, point );
00081 m_ControlPoints->InsertElement( 1, boundaryPoint );
00082 }
00083 else if ( index == 1 )
00084 {
00085 m_ControlPoints->InsertElement( index, point );
00086 return true;
00087 }
00088 return false;
00089 }
00090
00091 void mitk::PlanarCircle::GeneratePolyLine()
00092 {
00093
00094
00095 const Point2D ¢erPoint = m_ControlPoints->ElementAt( 0 );
00096 const Point2D &boundaryPoint = m_ControlPoints->ElementAt( 1 );
00097
00098 double radius = centerPoint.EuclideanDistanceTo( boundaryPoint );
00099
00100
00101 m_PolyLines->ElementAt( 0 )->Reserve( 64 );
00102 for ( int t = 0; t < 64; ++t )
00103 {
00104 double alpha = (double) t * vnl_math::pi / 32.0;
00105
00106 m_PolyLines->ElementAt( 0 )->ElementAt( t )[0] = centerPoint[0] + radius * cos( alpha );
00107 m_PolyLines->ElementAt( 0 )->ElementAt( t )[1] = centerPoint[1] + radius * sin( alpha );
00108 }
00109 }
00110
00111 void mitk::PlanarCircle::GenerateHelperPolyLine(double , unsigned int )
00112 {
00113
00114 }
00115
00116 void mitk::PlanarCircle::EvaluateFeaturesInternal()
00117 {
00118
00119 const Point3D &p0 = this->GetWorldControlPoint( 0 );
00120 const Point3D &p1 = this->GetWorldControlPoint( 1 );
00121
00122 double radius = p0.EuclideanDistanceTo( p1 );
00123 double area = vnl_math::pi * radius * radius;
00124
00125 this->SetQuantity( FEATURE_ID_RADIUS, radius );
00126 this->SetQuantity( FEATURE_ID_DIAMETER, 2*radius );
00127 this->SetQuantity( FEATURE_ID_AREA, area );
00128 }
00129
00130
00131 void mitk::PlanarCircle::PrintSelf( std::ostream& os, itk::Indent indent) const
00132 {
00133 Superclass::PrintSelf( os, indent );
00134 }