Implementation of PlanarFigure representing a polygon with two or more control points. More...
#include <mitkPlanarRectangle.h>


Public Types | |
| typedef PlanarRectangle | Self |
| typedef PlanarFigure | Superclass |
| typedef itk::SmartPointer< Self > | Pointer |
| typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
| virtual const char * | GetClassName () const |
| virtual void | PlaceFigure (const Point2D &point) |
| Place figure in its minimal configuration (a point at least) onto the given 2D geometry. | |
| virtual unsigned int | GetMinimumNumberOfControlPoints () const |
| Polygon has 2 control points per definition. | |
| virtual unsigned int | GetMaximumNumberOfControlPoints () const |
| Polygon maximum number of control points is principally not limited. | |
| virtual bool | SetControlPoint (unsigned int index, const Point2D &point, bool createIfDoesNotExist=false) |
Static Public Member Functions | |
| static Pointer | New () |
Protected Member Functions | |
| PlanarRectangle () | |
| virtual | ~PlanarRectangle () |
| virtual void | GeneratePolyLine () |
| Generates the poly-line representation of the planar figure. | |
| virtual void | GenerateHelperPolyLine (double mmPerDisplayUnit, unsigned int displayHeight) |
| Generates the poly-lines that should be drawn the same size regardless of zoom. | |
| virtual void | EvaluateFeaturesInternal () |
| Calculates feature quantities of the planar figure. | |
| virtual void | PrintSelf (std::ostream &os, itk::Indent indent) const |
Protected Attributes | |
| const unsigned int | FEATURE_ID_CIRCUMFERENCE |
| const unsigned int | FEATURE_ID_AREA |
Implementation of PlanarFigure representing a polygon with two or more control points.
Definition at line 35 of file mitkPlanarRectangle.h.
| typedef itk::SmartPointer<const Self> mitk::PlanarRectangle::ConstPointer |
Reimplemented from mitk::PlanarFigure.
Definition at line 38 of file mitkPlanarRectangle.h.
| typedef itk::SmartPointer<Self> mitk::PlanarRectangle::Pointer |
Reimplemented from mitk::PlanarFigure.
Definition at line 38 of file mitkPlanarRectangle.h.
Reimplemented from mitk::PlanarFigure.
Definition at line 38 of file mitkPlanarRectangle.h.
Reimplemented from mitk::PlanarFigure.
Definition at line 38 of file mitkPlanarRectangle.h.
| mitk::PlanarRectangle::PlanarRectangle | ( | ) | [protected] |
Definition at line 24 of file mitkPlanarRectangle.cpp.
References mitk::PlanarFigure::m_PolyLines, mitk::BoolProperty::New(), mitk::PlanarFigure::ResetNumberOfControlPoints(), and mitk::BaseData::SetProperty().
: FEATURE_ID_CIRCUMFERENCE( this->AddFeature( "Circumference", "mm" ) ), FEATURE_ID_AREA( this->AddFeature( "Area", "mm^2" ) ) { // Rectangle has four control points this->ResetNumberOfControlPoints( 4 ); this->SetProperty( "closed", mitk::BoolProperty::New(true) ); m_PolyLines->InsertElement( 0, VertexContainerType::New()); }
| mitk::PlanarRectangle::~PlanarRectangle | ( | ) | [protected, virtual] |
Definition at line 36 of file mitkPlanarRectangle.cpp.
{
}
| void mitk::PlanarRectangle::EvaluateFeaturesInternal | ( | ) | [protected, virtual] |
Calculates feature quantities of the planar figure.
Implements mitk::PlanarFigure.
Definition at line 142 of file mitkPlanarRectangle.cpp.
References QuadProgPP::abs().
{
// Calculate circumference
double circumference = 0.0;
unsigned int i;
for ( i = 0; i < this->GetNumberOfControlPoints(); ++i )
{
circumference += this->GetWorldControlPoint( i ).EuclideanDistanceTo(
this->GetWorldControlPoint( (i + 1) % this->GetNumberOfControlPoints() ) );
}
this->SetQuantity( FEATURE_ID_CIRCUMFERENCE, circumference );
// Calculate rectangle area (well, done a bit clumsy...)
double area = 0.0;
if ( this->GetGeometry2D() != NULL )
{
for ( i = 0; i < this->GetNumberOfControlPoints(); ++i )
{
Point2D p0 = this->GetControlPoint( i );
Point2D p1 = this->GetControlPoint( (i + 1) % this->GetNumberOfControlPoints() );
area += p0[0] * p1[1] - p1[0] * p0[1];
}
area /= 2.0;
}
this->SetQuantity( FEATURE_ID_AREA, abs(area) );
}
| void mitk::PlanarRectangle::GenerateHelperPolyLine | ( | double | mmPerDisplayUnit, |
| unsigned int | displayHeight | ||
| ) | [protected, virtual] |
Generates the poly-lines that should be drawn the same size regardless of zoom.
Implements mitk::PlanarFigure.
Definition at line 137 of file mitkPlanarRectangle.cpp.
{
// A polygon does not require helper objects
}
| void mitk::PlanarRectangle::GeneratePolyLine | ( | ) | [protected, virtual] |
Generates the poly-line representation of the planar figure.
Implements mitk::PlanarFigure.
Definition at line 127 of file mitkPlanarRectangle.cpp.
{
// TODO: start polygon at specified initalize point...
m_PolyLines->ElementAt( 0 )->Reserve( this->GetNumberOfControlPoints() );
for ( unsigned int i = 0; i < this->GetNumberOfControlPoints(); ++i )
{
m_PolyLines->ElementAt( 0 )->ElementAt( i ) = m_ControlPoints->ElementAt( i );
}
}
| virtual const char* mitk::PlanarRectangle::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::PlanarFigure.
| virtual unsigned int mitk::PlanarRectangle::GetMaximumNumberOfControlPoints | ( | ) | const [inline, virtual] |
Polygon maximum number of control points is principally not limited.
Implements mitk::PlanarFigure.
Definition at line 59 of file mitkPlanarRectangle.h.
{
return 4;
}
| virtual unsigned int mitk::PlanarRectangle::GetMinimumNumberOfControlPoints | ( | ) | const [inline, virtual] |
Polygon has 2 control points per definition.
Implements mitk::PlanarFigure.
Definition at line 52 of file mitkPlanarRectangle.h.
{
return 4;
}
| static Pointer mitk::PlanarRectangle::New | ( | ) | [static] |
| virtual void mitk::PlanarRectangle::PlaceFigure | ( | const Point2D & | point ) | [virtual] |
Place figure in its minimal configuration (a point at least) onto the given 2D geometry.
Must be implemented in sub-classes.
Reimplemented from mitk::PlanarFigure.
| void mitk::PlanarRectangle::PrintSelf | ( | std::ostream & | os, |
| itk::Indent | indent | ||
| ) | const [protected, virtual] |
Reimplemented from mitk::PlanarFigure.
Definition at line 175 of file mitkPlanarRectangle.cpp.
{
Superclass::PrintSelf( os, indent );
os << indent << "Number of control points: " << this->GetNumberOfControlPoints() << std::endl;
os << indent << "Control points:" << std::endl;
mitk::PlanarFigure::VertexContainerType::ConstIterator it;
for ( unsigned int i = 0; i < this->GetNumberOfControlPoints(); ++i )
{
os << indent << indent << i << ": " << m_ControlPoints->ElementAt( i ) << std::endl;
}
}
| bool mitk::PlanarRectangle::SetControlPoint | ( | unsigned int | index, |
| const Point2D & | point, | ||
| bool | createIfDoesNotExist = false |
||
| ) | [virtual] |
Reimplemented from mitk::PlanarFigure.
Definition at line 67 of file mitkPlanarRectangle.cpp.
{
// heres the deal with the rectangle:
// when a point is moved all corresponding corner points are moved with him
// e.g. if the lower right point (index=3) is moved the upper right point (index=1)
// is moved in the same x direction
// and the lower left point (index=2) is moved in the same y direction
// the upper left point (index=0) is left untouched
bool set = false;
if (createIfDoesNotExist)
{
m_ControlPoints->InsertElement( index, point );
set = true;
}
else if ( index < this->GetNumberOfControlPoints() )
{
m_ControlPoints->InsertElement( index, point );
set = true;
}
if(set)
{
// can be made better ...
unsigned int horizontalCorrespondingPointIndex = 1;
unsigned int verticalCorrespondingPointIndex = 3;
if(index == 1)
{
horizontalCorrespondingPointIndex = 0;
verticalCorrespondingPointIndex = 2;
}
else if(index == 2)
{
horizontalCorrespondingPointIndex = 3;
verticalCorrespondingPointIndex = 1;
}
else if(index == 3)
{
horizontalCorrespondingPointIndex = 2;
verticalCorrespondingPointIndex = 0;
}
m_ControlPoints->ElementAt( verticalCorrespondingPointIndex ).SetElement(0, point[0]);
m_ControlPoints->ElementAt( horizontalCorrespondingPointIndex ).SetElement(1, point[1]);
}
return set;
}
const unsigned int mitk::PlanarRectangle::FEATURE_ID_AREA [protected] |
Definition at line 82 of file mitkPlanarRectangle.h.
const unsigned int mitk::PlanarRectangle::FEATURE_ID_CIRCUMFERENCE [protected] |
Definition at line 81 of file mitkPlanarRectangle.h.
1.7.2