group object, that contains several mitk::BoundingObjects More...
#include <mitkBoundingObjectGroup.h>
Public Types | |
enum | CSGMode { Union, Intersection, Difference } |
typedef BoundingObjectGroup | Self |
typedef mitk::BoundingObject | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual void | UpdateOutputInformation () |
Update the information for this BaseData (the geometry in particular) so that it can be used as an output of a BaseProcess. | |
virtual bool | IsInside (const mitk::Point3D &p) const |
void | SetBoundingObjects (const std::deque< mitk::BoundingObject::Pointer > boundingObjects) |
std::deque < mitk::BoundingObject::Pointer > | GetBoundingObjects () |
virtual void | SetCSGMode (mitk::BoundingObjectGroup::CSGMode _arg) |
virtual mitk::BoundingObjectGroup::CSGMode | GetCSGMode () |
void | AddBoundingObject (mitk::BoundingObject::Pointer boundingObject) |
void | RemoveBoundingObject (mitk::BoundingObject::Pointer boundingObject) |
unsigned int | GetCount () const |
mitk::Geometry3D * | GetGeometry (int t=0) const |
Return the geometry, which is a TimeSlicedGeometry, of the data as non-const pointer. | |
virtual bool | VerifyRequestedRegion () |
Verify that the RequestedRegion is within the LargestPossibleRegion. | |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
BoundingObjectGroup () | |
virtual | ~BoundingObjectGroup () |
Protected Attributes | |
std::deque < mitk::BoundingObject::Pointer > | m_BoundingObjects |
unsigned int | m_Counter |
CSGMode | m_CSGMode |
group object, that contains several mitk::BoundingObjects
Calculates a bounding box that contains all sub-bounding boxes.
Definition at line 31 of file mitkBoundingObjectGroup.h.
typedef itk::SmartPointer<const Self> mitk::BoundingObjectGroup::ConstPointer |
Reimplemented from mitk::BoundingObject.
Definition at line 42 of file mitkBoundingObjectGroup.h.
typedef itk::SmartPointer<Self> mitk::BoundingObjectGroup::Pointer |
Reimplemented from mitk::BoundingObject.
Definition at line 42 of file mitkBoundingObjectGroup.h.
Reimplemented from mitk::BoundingObject.
Definition at line 42 of file mitkBoundingObjectGroup.h.
Reimplemented from mitk::BoundingObject.
Definition at line 42 of file mitkBoundingObjectGroup.h.
Definition at line 35 of file mitkBoundingObjectGroup.h.
{ Union, Intersection, Difference };
mitk::BoundingObjectGroup::BoundingObjectGroup | ( | ) | [protected] |
Definition at line 25 of file mitkBoundingObjectGroup.cpp.
References GetGeometry(), mitk::BaseData::GetTimeSlicedGeometry(), mitk::TimeSlicedGeometry::Initialize(), mitk::Geometry3D::SetIndexToWorldTransform(), and mitk::Surface::SetVtkPolyData().
:m_BoundingObjects(0), m_Counter(0), m_CSGMode(Union)// m_CSGMode(Difference) //m_CSGMode(Intersection) { GetTimeSlicedGeometry()->Initialize(1); GetGeometry(0)->SetIndexToWorldTransform(GetTimeSlicedGeometry()->GetIndexToWorldTransform()); SetVtkPolyData(NULL); }
mitk::BoundingObjectGroup::~BoundingObjectGroup | ( | ) | [protected, virtual] |
Definition at line 35 of file mitkBoundingObjectGroup.cpp.
{ }
void mitk::BoundingObjectGroup::AddBoundingObject | ( | mitk::BoundingObject::Pointer | boundingObject ) |
Definition at line 110 of file mitkBoundingObjectGroup.cpp.
{ if (boundingObject->GetPositive()) m_BoundingObjects.push_front(boundingObject); else m_BoundingObjects.push_back(boundingObject); ++m_Counter; UpdateOutputInformation(); }
std::deque< mitk::BoundingObject::Pointer > mitk::BoundingObjectGroup::GetBoundingObjects | ( | ) |
Definition at line 212 of file mitkBoundingObjectGroup.cpp.
{ return m_BoundingObjects; }
virtual const char* mitk::BoundingObjectGroup::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::BoundingObject.
unsigned int mitk::BoundingObjectGroup::GetCount | ( | ) | const |
Definition at line 179 of file mitkBoundingObjectGroup.cpp.
{ return m_Counter; }
virtual mitk::BoundingObjectGroup::CSGMode mitk::BoundingObjectGroup::GetCSGMode | ( | ) | [virtual] |
mitk::Geometry3D * mitk::BoundingObjectGroup::GetGeometry | ( | int | t = 0 ) |
const |
Return the geometry, which is a TimeSlicedGeometry, of the data as non-const pointer.
Normally used in GenerateOutputInformation of subclasses of BaseProcess.
Reimplemented from mitk::BaseData.
Definition at line 189 of file mitkBoundingObjectGroup.cpp.
Referenced by BoundingObjectGroup().
{ //if ( m_BoundingObjects == NULL ) return Superclass::GetGeometry(t); //mitk::BoundingObjectGroup::BoundingObjectContainer::ConstIterator boI = m_BoundingObjects->Begin(); //const mitk::BoundingObjectGroup::BoundingObjectContainer::ConstIterator boIEnd = m_BoundingObjects->End(); //mitk::Geometry3D* currentGeometry = NULL; //while ( boI != boIEnd ) //{ // currentGeometry = boI.Value()->GetGeometry( t ); // boI++; //} //return currentGeometry; }
bool mitk::BoundingObjectGroup::IsInside | ( | const mitk::Point3D & | p ) | const [virtual] |
Implements mitk::BoundingObject.
Definition at line 133 of file mitkBoundingObjectGroup.cpp.
{ bool inside = false; // initialize with true for intersection, with false for union bool posInside = false; bool negInside = false; for (unsigned int i = 0; i<m_BoundingObjects.size();i++) { switch(m_CSGMode) { case Intersection: inside = true; // calculate intersection: each point, that is inside each BoundingObject is considered inside the group inside = m_BoundingObjects.at(i)->IsInside(p) && inside; if (!inside) // shortcut, it is enough to find one object that does not contain the point i=m_BoundingObjects.size(); break; case Union: case Difference: posInside = false; negInside = false; // calculate union: each point, that is inside least one BoundingObject is considered inside the group if (m_BoundingObjects.at(i)->GetPositive()) posInside = m_BoundingObjects.at(i)->IsInside(p) || posInside; else negInside = m_BoundingObjects.at(i)->IsInside(p) || negInside; if (posInside && !negInside) inside = true; else inside = false; break; default: inside = false; // calculate union: each point, that is inside least one BoundingObject is considered inside the group inside = m_BoundingObjects.at(i)->IsInside(p) || inside; if (inside) // shortcut, it is enough to find one object that contains the point i=m_BoundingObjects.size(); break; } } return inside; }
static Pointer mitk::BoundingObjectGroup::New | ( | ) | [static] |
Reimplemented from mitk::Surface.
Referenced by QmitkBoundingObjectWidget::GetAllBoundingObjects(), and mitk::BoundingObjectToSegmentationFilter::SetBoundingObject().
void mitk::BoundingObjectGroup::RemoveBoundingObject | ( | mitk::BoundingObject::Pointer | boundingObject ) |
Definition at line 120 of file mitkBoundingObjectGroup.cpp.
{ std::deque<mitk::BoundingObject::Pointer>::iterator it = m_BoundingObjects.begin(); for (unsigned int i=0 ; i<m_BoundingObjects.size();i++) { if (m_BoundingObjects.at(i) == boundingObject) m_BoundingObjects.erase(it); ++it; } --m_Counter; UpdateOutputInformation(); }
void mitk::BoundingObjectGroup::SetBoundingObjects | ( | const std::deque< mitk::BoundingObject::Pointer > | boundingObjects ) |
Definition at line 207 of file mitkBoundingObjectGroup.cpp.
{ m_BoundingObjects = boundingObjects; }
virtual void mitk::BoundingObjectGroup::SetCSGMode | ( | mitk::BoundingObjectGroup::CSGMode | _arg ) | [virtual] |
void mitk::BoundingObjectGroup::UpdateOutputInformation | ( | ) | [virtual] |
Update the information for this BaseData (the geometry in particular) so that it can be used as an output of a BaseProcess.
This method is used in the pipeline mechanism to propagate information and initialize the meta data associated with a BaseData. Any implementation of this method in a derived class is assumed to call its source's BaseProcess::UpdateOutputInformation() which determines modified times, LargestPossibleRegions, and any extra meta data like spacing, origin, etc. Default implementation simply call's it's source's UpdateOutputInformation().
Reimplemented from mitk::Surface.
Definition at line 39 of file mitkBoundingObjectGroup.cpp.
References mitk::Geometry3D::GetCornerPoint(), inverse, mitk::Geometry3D::SetBounds(), and mitk::Geometry3D::SetIndexToWorldTransform().
{ if ( this->GetSource() ) { this->GetSource()->UpdateOutputInformation(); } // calculate global bounding box if(m_BoundingObjects.size() < 1 ) // if there is no BoundingObject, the bounding box is zero { mitk::BoundingBox::BoundsArrayType boundsArray; boundsArray.Fill(0); GetTimeSlicedGeometry()->Initialize(1); GetGeometry()->SetBounds(boundsArray); GetTimeSlicedGeometry()->UpdateInformation(); return; } // initialize container mitk::BoundingBox::PointsContainer::Pointer pointscontainer=mitk::BoundingBox::PointsContainer::New(); mitk::BoundingBox::PointIdentifier pointid=0; mitk::Point3D point; mitk::AffineTransform3D* transform = GetTimeSlicedGeometry()->GetIndexToWorldTransform(); mitk::AffineTransform3D::Pointer inverse = mitk::AffineTransform3D::New(); transform->GetInverse(inverse); // calculate a bounding box that includes all BoundingObjects // \todo probably we should do this additionally for each time-step //while (boundingObjectsIterator != boundingObjectsIteratorEnd) for(unsigned int j = 0; j<m_BoundingObjects.size();j++) { const Geometry3D* geometry = m_BoundingObjects.at(j)->GetUpdatedTimeSlicedGeometry(); unsigned char i; for(i=0; i<8; ++i) { point = inverse->TransformPoint(geometry->GetCornerPoint(i)); if(point[0]*point[0]+point[1]*point[1]+point[2]*point[2] < mitk::large) pointscontainer->InsertElement( pointid++, point); else { itkGenericOutputMacro( << "Unrealistically distant corner point encountered. Ignored. BoundingObject: " << m_BoundingObjects.at(j) ); } } } mitk::BoundingBox::Pointer boundingBox = mitk::BoundingBox::New(); boundingBox->SetPoints(pointscontainer); boundingBox->ComputeBoundingBox(); /* BoundingBox is centered around the center of all sub bounding objects */ //Point3D center = boundingBox->GetCenter(); //Point3D minimum, maximum; //minimum.Fill(0); maximum.Fill(0); //minimum += boundingBox->GetMinimum() - center; //maximum += boundingBox->GetMaximum() - center; //boundingBox->SetMinimum(minimum); //boundingBox->SetMaximum(maximum); Geometry3D* geometry3d = GetGeometry(0); geometry3d->SetIndexToWorldTransform(transform); geometry3d->SetBounds(boundingBox->GetBounds()); /* the objects position is the center of all sub bounding objects */ //geometry3d->SetOrigin(center); GetTimeSlicedGeometry()->InitializeEvenlyTimed(geometry3d, GetTimeSlicedGeometry()->GetTimeSteps()); }
bool mitk::BoundingObjectGroup::VerifyRequestedRegion | ( | ) | [virtual] |
Verify that the RequestedRegion is within the LargestPossibleRegion.
If the RequestedRegion is not within the LargestPossibleRegion, then the filter cannot possibly satisfy the request. This method returns true if the request can be satisfied (even if it will be necessary to process the entire LargestPossibleRegion) and returns false otherwise. This method is used by PropagateRequestedRegion(). PropagateRequestedRegion() throws a InvalidRequestedRegionError exception if the requested region is not within the LargestPossibleRegion.
Reimplemented from mitk::Surface.
Definition at line 184 of file mitkBoundingObjectGroup.cpp.
{ return m_Counter > 0; }
std::deque<mitk::BoundingObject::Pointer> mitk::BoundingObjectGroup::m_BoundingObjects [protected] |
Definition at line 65 of file mitkBoundingObjectGroup.h.
unsigned int mitk::BoundingObjectGroup::m_Counter [protected] |
Definition at line 66 of file mitkBoundingObjectGroup.h.
CSGMode mitk::BoundingObjectGroup::m_CSGMode [protected] |
Definition at line 67 of file mitkBoundingObjectGroup.h.