Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

mitk::Surface Class Reference
[Data Classes]

Class for storing surfaces (vtkPolyData) More...

#include <mitkSurface.h>

Inheritance diagram for mitk::Surface:
Inheritance graph
[legend]
Collaboration diagram for mitk::Surface:
Collaboration graph
[legend]

List of all members.

Public Types

typedef itk::ImageRegion< 5 > RegionType
typedef Surface Self
typedef BaseData Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual void SetVtkPolyData (vtkPolyData *polydata, unsigned int t=0)
virtual vtkPolyData * GetVtkPolyData (unsigned int t=0)
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 void SetRequestedRegionToLargestPossibleRegion ()
 Set the RequestedRegion to the LargestPossibleRegion.
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion ()
 Determine whether the RequestedRegion is outside of the BufferedRegion.
virtual bool VerifyRequestedRegion ()
 Verify that the RequestedRegion is within the LargestPossibleRegion.
virtual void SetRequestedRegion (itk::DataObject *data)
 Set the requested region from this data object to match the requested region of the data object passed in as a parameter.
virtual void SetRequestedRegion (Surface::RegionType *region)
virtual void CopyInformation (const itk::DataObject *data)
 Copy information from the specified data set.
virtual bool IsEmpty (unsigned int t) const
 Check whether object contains data (at a specified time), e.g., a set of points may be empty.
unsigned int GetSizeOfPolyDataSeries () const
virtual void Update ()
virtual void Expand (unsigned int timeSteps=1)
 Expands the TimeSlicedGeometry to a number of TimeSteps.
virtual void Graft (const DataObject *data)
const RegionTypeGetLargestPossibleRegion () const
virtual const RegionTypeGetRequestedRegion () const
void CalculateBoundingBox ()
virtual void PrintSelf (std::ostream &os, itk::Indent indent) const
virtual void ExecuteOperation (Operation *operation)
 overwrite if the Data can be called by an Interactor (StateMachine).

Static Public Member Functions

static Pointer New ()

Protected Types

typedef std::vector
< vtkPolyData * > 
VTKPolyDataSeries

Protected Member Functions

 Surface ()
virtual ~Surface ()
virtual void ClearData ()
 reset to non-initialized state, release memory
virtual void InitializeEmpty ()
 Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least create one empty object and call Superclass::InitializeTimeSlicedGeometry() to ensure an existing valid geometry.

Protected Attributes

VTKPolyDataSeries m_PolyDataSeries
RegionType m_LargestPossibleRegion
RegionType m_RequestedRegion
bool m_CalculateBoundingBox

Detailed Description

Class for storing surfaces (vtkPolyData)

Examples:

mitkMoveSurfaceInteractor.cpp.

Definition at line 32 of file mitkSurface.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::Surface::ConstPointer
typedef itk::SmartPointer<Self> mitk::Surface::Pointer
typedef itk::ImageRegion< 5 > mitk::Surface::RegionType

Definition at line 38 of file mitkSurface.h.

typedef std::vector< vtkPolyData* > mitk::Surface::VTKPolyDataSeries [protected]

Definition at line 96 of file mitkSurface.h.


Constructor & Destructor Documentation

mitk::Surface::Surface (  ) [protected]

Definition at line 29 of file mitkSurface.cpp.

References InitializeEmpty().

                     : 
m_CalculateBoundingBox( false )
{
  this->InitializeEmpty();
}
mitk::Surface::~Surface (  ) [protected, virtual]

Definition at line 35 of file mitkSurface.cpp.

{
  this->ClearData();
}

Member Function Documentation

void mitk::Surface::CalculateBoundingBox (  )

Definition at line 131 of file mitkSurface.cpp.

References mitk::Geometry3D::GetBoundingBox(), mitk::TimeSlicedGeometry::GetGeometry3D(), mitk::TimeSlicedGeometry::GetTimeSteps(), mitk::Geometry3D::SetFloatBounds(), and mitk::TimeSlicedGeometry::UpdateInformation().

{
  //
  // first make sure, that the associated time sliced geometry has
  // the same number of geometry 3d's as vtkPolyDatas are present
  //
  mitk::TimeSlicedGeometry* timeGeometry = GetTimeSlicedGeometry();
  if ( timeGeometry->GetTimeSteps() != m_PolyDataSeries.size() )
  {
    itkExceptionMacro(<<"timeGeometry->GetTimeSteps() != m_PolyDataSeries.size() -- use Initialize(timeSteps) with correct number of timeSteps!");
  }

  //
  // Iterate over the vtkPolyDatas and update the Geometry
  // information of each of the items.
  //
  for ( unsigned int i = 0 ; i < m_PolyDataSeries.size() ; ++i )
  {
    vtkPolyData* polyData = m_PolyDataSeries[ i ];
    vtkFloatingPointType bounds[ ] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
    if ( ( polyData != NULL ) && ( polyData->GetNumberOfPoints() > 0 ) )
    {
      polyData->Update();
      polyData->ComputeBounds();
      polyData->GetBounds( bounds );
    }
    mitk::Geometry3D::Pointer g3d = timeGeometry->GetGeometry3D( i );
    assert( g3d.IsNotNull() );
    g3d->SetFloatBounds( bounds );
  }
  timeGeometry->UpdateInformation();

  mitk::BoundingBox::Pointer bb = const_cast<mitk::BoundingBox*>( timeGeometry->GetBoundingBox() );
  itkDebugMacro( << "boundingbox min: "<< bb->GetMinimum());
  itkDebugMacro( << "boundingbox max: "<< bb->GetMaximum());
  m_CalculateBoundingBox = false;
}
void mitk::Surface::ClearData (  ) [protected, virtual]

reset to non-initialized state, release memory

Reimplemented from mitk::BaseData.

Definition at line 40 of file mitkSurface.cpp.

{
  for ( VTKPolyDataSeries::iterator it = m_PolyDataSeries.begin(); it != m_PolyDataSeries.end(); ++it )
  {
    if ( ( *it ) != NULL )
      ( *it )->Delete();
  }
  m_PolyDataSeries.clear();

  Superclass::ClearData();
}
void mitk::Surface::CopyInformation ( const itk::DataObject *  data ) [virtual]

Copy information from the specified data set.

This method is part of the pipeline execution model. By default, a BaseProcess will copy meta-data from the first input to all of its outputs. See ProcessObject::GenerateOutputInformation(). Each subclass of DataObject is responsible for being able to copy whatever meta-data it needs from another DataObject. The default implementation of this method copies the time sliced geometry and the property list of an object. If a subclass overrides this method, it should always call its superclass' version.

Reimplemented from mitk::BaseData.

Definition at line 227 of file mitkSurface.cpp.

References GetLargestPossibleRegion().

Referenced by mitk::SurfaceSource::GraftNthOutput().

{
  Superclass::CopyInformation( data );

  const mitk::Surface* surfaceData;

  surfaceData = dynamic_cast<const mitk::Surface*>( data );

  if ( surfaceData )
  {
    m_LargestPossibleRegion = surfaceData->GetLargestPossibleRegion();
  }
  else
  {
    // pointer could not be cast back down
    itkExceptionMacro( << "mitk::Surface::CopyInformation(const DataObject *data) cannot cast " << typeid(data).name() << " to " << typeid(surfaceData).name() );
  }
}
void mitk::Surface::ExecuteOperation ( Operation operation ) [virtual]

overwrite if the Data can be called by an Interactor (StateMachine).

Empty by default. Overwrite and implement all the necessary operations here and get the necessary information from the parameter operation.

Reimplemented from mitk::BaseData.

Definition at line 272 of file mitkSurface.cpp.

References mitk::Operation::GetOperationType(), mitk::SurfaceOperation::GetTimeStep(), mitk::SurfaceOperation::GetVtkPolyData(), and mitk::OpSURFACECHANGED.

{
  switch ( operation->GetOperationType() )
  {
  case OpSURFACECHANGED:
  
    mitk::SurfaceOperation* surfOp = dynamic_cast<mitk::SurfaceOperation*>(operation);
    if( ! surfOp ) break;

    unsigned int time = surfOp->GetTimeStep();

    if(m_PolyDataSeries[ time ] != NULL)
    {
      vtkPolyData* updatePoly = surfOp->GetVtkPolyData();
      if( updatePoly ){
        this->SetVtkPolyData( updatePoly, time );
        this->CalculateBoundingBox();
      }
    }
    break;
  }
  this->Modified();
}
void mitk::Surface::Expand ( unsigned int  timeSteps = 1 ) [virtual]

Expands the TimeSlicedGeometry to a number of TimeSteps.

The method expands the TimeSlicedGeometry to the given number of TimeSteps, filling newly created elements with empty geometries. Sub-classes should override this method to handle the elongation of their data vectors, too. Note that a shrinking is neither possible nor intended.

Reimplemented from mitk::BaseData.

Definition at line 259 of file mitkSurface.cpp.

Referenced by mitk::LabeledImageToSurfaceFilter::GenerateOutputInformation().

{  
  // check if the vector is long enough to contain the new element
  // at the given position. If not, expand it with sufficient zero-filled elements.
  if ( timeSteps > m_PolyDataSeries.size() )
  {
    Superclass::Expand( timeSteps );
    vtkPolyData* pdnull = NULL;
    m_PolyDataSeries.resize( timeSteps, pdnull );
    m_CalculateBoundingBox = true;
  }
}
virtual const char* mitk::Surface::GetClassName (  ) const [virtual]
const RegionType& mitk::Surface::GetLargestPossibleRegion (  ) const [inline]

Definition at line 72 of file mitkSurface.h.

Referenced by CopyInformation().

virtual const RegionType& mitk::Surface::GetRequestedRegion (  ) const [inline, virtual]

Get the region object that defines the size and starting index for the region of the image requested (i.e., the region of the image to be operated on by a filter).

Definition at line 83 of file mitkSurface.h.

Referenced by SetRequestedRegion().

    {
      return m_RequestedRegion;
    }
unsigned int mitk::Surface::GetSizeOfPolyDataSeries (  ) const

Definition at line 296 of file mitkSurface.cpp.

{
  return m_PolyDataSeries.size();
}
vtkPolyData * mitk::Surface::GetVtkPolyData ( unsigned int  t = 0 ) [virtual]

Definition at line 98 of file mitkSurface.cpp.

References QuadProgPP::t().

Referenced by mitk::SurfaceInteractor::CanHandleEvent(), mitk::SurfaceDeformationInteractor3D::ExecuteAction(), mitk::SurfaceVtkMapper3D::GenerateData(), mitk::SurfaceIndexToWorldTransformFilter::GenerateData(), mitk::ProbeFilter::GenerateData(), MeshUtil< MeshType, ScalarAccessor >::MeshFromSurface(), CommonFunctionality::SaveSurface(), and testSurfaceBoundingBoxConsistency().

{

  if ( t < m_PolyDataSeries.size() )
  {
    vtkPolyData* polydata = m_PolyDataSeries[ t ];
    if((polydata==NULL) && (GetSource().GetPointer()!=NULL))
    {
      RegionType requestedregion;
      requestedregion.SetIndex(3, t);
      requestedregion.SetSize(3, 1);
      SetRequestedRegion(&requestedregion);
      GetSource()->Update();
    }
    polydata = m_PolyDataSeries[ t ];
    return polydata;
  }
  else
    return NULL;
}
void mitk::Surface::Graft ( const DataObject *  data ) [virtual]

Definition at line 301 of file mitkSurface.cpp.

{
  const Self* surface;
  try 
  {
    surface = dynamic_cast<const Self*>( data );
  }
  catch(...)
  {
    itkExceptionMacro( << "mitk::Surface::Graft cannot cast "
      << typeid(data).name() << " to "
      << typeid(const Self *).name() );
    return;    
  }

  if(!surface)
  {
    // pointer could not be cast back down
    itkExceptionMacro( << "mitk::Surface::Graft cannot cast "
      << typeid(data).name() << " to "
      << typeid(const Self *).name() );
    return;
  }

  this->CopyInformation( data );
  //clear list of PolyData's
  m_PolyDataSeries.clear();
  // do copy
  for (unsigned int i=0; i<surface->GetSizeOfPolyDataSeries(); i++)
    {
      m_PolyDataSeries.push_back(vtkPolyData::New());
      m_PolyDataSeries.back()->DeepCopy( const_cast<mitk::Surface*>(surface)->GetVtkPolyData( i ) );
      //CopyStructure( const_cast<mitk::Surface*>(surface)->GetVtkPolyData( i ) );
    }
}
void mitk::Surface::InitializeEmpty (  ) [protected, virtual]

Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least create one empty object and call Superclass::InitializeTimeSlicedGeometry() to ensure an existing valid geometry.

Reimplemented from mitk::BaseData.

Definition at line 52 of file mitkSurface.cpp.

Referenced by Surface().

{
  vtkPolyData* pdnull = NULL;
  m_PolyDataSeries.resize( 1, pdnull );
  Superclass::InitializeTimeSlicedGeometry(1);

  m_Initialized = true;
}
bool mitk::Surface::IsEmpty ( unsigned int  t ) const [virtual]

Check whether object contains data (at a specified time), e.g., a set of points may be empty.

Warning:
Returns IsInitialized()==false by default for compatibility reasons. Override in sub-classes that support distinction between empty/non-empty state.

Reimplemented from mitk::BaseData.

Definition at line 83 of file mitkSurface.cpp.

{
  if(!IsInitialized())
    return false;
  vtkPolyData* polydata = const_cast<Surface*>(this)->GetVtkPolyData(t);
  return 
    (polydata == NULL) || 
    (
    (polydata->GetNumberOfVerts()  <= 0) &&
    (polydata->GetNumberOfPolys()  <= 0) &&
    (polydata->GetNumberOfStrips() <= 0) &&
    (polydata->GetNumberOfLines()  <= 0)
    );
}
static Pointer mitk::Surface::New (  ) [static]
void mitk::Surface::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const [virtual]

Reimplemented from mitk::BaseData.

Definition at line 337 of file mitkSurface.cpp.

{
  Superclass::PrintSelf(os, indent);

  os << indent << "\nNumber PolyDatas: " << m_PolyDataSeries.size() << "\n";
  unsigned int count = 0;
  for (VTKPolyDataSeries::const_iterator it = m_PolyDataSeries.begin(); it != m_PolyDataSeries.end(); ++it)
  {
    vtkPolyData* pd = *it;
    if(pd != NULL)
    {
      os << "\n";
      os << indent << "PolyData at time step " << count << ". \n";
      os << indent << "Number of cells " << pd->GetNumberOfCells() << ": \n";
      os << indent << "Number of points " << pd->GetNumberOfPoints() << ": \n\n";
      os << indent << "VTKPolyData : \n";
      pd->Print(os);
    }
    else 
      os << indent << "\nEmpty PolyData at time step " << count << ".\n";

    count++;
  }
}
bool mitk::Surface::RequestedRegionIsOutsideOfTheBufferedRegion (  ) [virtual]

Determine whether the RequestedRegion is outside of the BufferedRegion.

This method returns true if the RequestedRegion is outside the BufferedRegion (true if at least one pixel is outside). This is used by the pipeline mechanism to determine whether a filter needs to re-execute in order to satisfy the current request. If the current RequestedRegion is already inside the BufferedRegion from the previous execution (and the current filter is up to date), then a given filter does not need to re-execute

Implements mitk::BaseData.

Definition at line 174 of file mitkSurface.cpp.

References QuadProgPP::t().

{
  RegionType::IndexValueType end = m_RequestedRegion.GetIndex(3)+m_RequestedRegion.GetSize(3);

  if(((RegionType::IndexValueType)m_PolyDataSeries.size())<end)
    return true;

  for( RegionType::IndexValueType t=m_RequestedRegion.GetIndex(3); t<end; ++t )
    if(m_PolyDataSeries[t]==NULL)
      return true;

  return false;
}
void mitk::Surface::SetRequestedRegion ( Surface::RegionType region ) [virtual]

Definition at line 214 of file mitkSurface.cpp.

{
  if(region!=NULL)
  {
    m_RequestedRegion = *region;
  }
  else
  {
    // pointer could not be cast back down
    itkExceptionMacro( << "mitk::Surface::SetRequestedRegion(Surface::RegionType*) cannot cast " << typeid(region).name() << " to " << typeid(Surface*).name() );
  }
}
void mitk::Surface::SetRequestedRegion ( itk::DataObject *  data ) [virtual]

Set the requested region from this data object to match the requested region of the data object passed in as a parameter.

This method is implemented in the concrete subclasses of BaseData.

Implements mitk::BaseData.

Definition at line 197 of file mitkSurface.cpp.

References GetRequestedRegion().

Referenced by mitk::ProbeFilter::GenerateInputRequestedRegion(), and mitk::SurfaceSource::GraftNthOutput().

{
  mitk::Surface *surfaceData;

  surfaceData = dynamic_cast<mitk::Surface*>(data);

  if (surfaceData)
  {
    m_RequestedRegion = surfaceData->GetRequestedRegion();
  }
  else
  {
    // pointer could not be cast back down
    itkExceptionMacro( << "mitk::Surface::SetRequestedRegion(DataObject*) cannot cast " << typeid(data).name() << " to " << typeid(Surface*).name() );
  }
}
void mitk::Surface::SetRequestedRegionToLargestPossibleRegion (  ) [virtual]

Set the RequestedRegion to the LargestPossibleRegion.

This forces a filter to produce all of the output in one execution (i.e. not streaming) on the next call to Update().

Implements mitk::BaseData.

Definition at line 169 of file mitkSurface.cpp.

Referenced by testGeometryDataToSurfaceFilter().

void mitk::Surface::SetVtkPolyData ( vtkPolyData *  polydata,
unsigned int  t = 0 
) [virtual]

Definition at line 61 of file mitkSurface.cpp.

References QuadProgPP::t().

Referenced by mitk::BoundingObjectGroup::BoundingObjectGroup(), mitk::Cone::Cone(), mitk::LabeledImageToSurfaceFilter::CreateSurface(), mitk::ImageToSurfaceFilter::CreateSurface(), mitk::Cuboid::Cuboid(), mitk::Cylinder::Cylinder(), mitk::Ellipsoid::Ellipsoid(), and CommonFunctionality::SaveSurface().

{
  // Adapt the size of the data vector if necessary
  this->Expand( t+1 );

  if(m_PolyDataSeries[ t ] != NULL)
  {
    // we do not need the reference on the object any longer
    m_PolyDataSeries[ t ]->Delete();
  }
  m_PolyDataSeries[ t ] = polydata;
  // call m_VtkPolyData->Register(NULL) to tell 
  // the reference counting that we want to keep a 
  // reference on the object
  if(m_PolyDataSeries[ t ] != NULL)
  {
    m_PolyDataSeries[ t ]->Register( NULL );
  }
  this->Modified();
  m_CalculateBoundingBox = true;
}
void mitk::Surface::Update (  ) [virtual]

Definition at line 246 of file mitkSurface.cpp.

{
  if ( GetSource() == NULL )
  {
    for ( VTKPolyDataSeries::iterator it = m_PolyDataSeries.begin() ; it != m_PolyDataSeries.end() ; ++it )
    {
      if ( ( *it ) != NULL )
        ( *it )->Update();
    }
  }
  Superclass::Update();
}
void mitk::Surface::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().

Note:
Implementations of this methods in derived classes must take care that the geometry is updated by calling GetTimeSlicedGeometry()->UpdateInformation() after calling its source's BaseProcess::UpdateOutputInformation().

Reimplemented from mitk::BaseData.

Reimplemented in mitk::BoundingObjectGroup, and mitk::ExtrudedContour.

Definition at line 119 of file mitkSurface.cpp.

{
  if ( this->GetSource() )
  {
    this->GetSource()->UpdateOutputInformation();
  }
  if ( ( m_CalculateBoundingBox ) && ( m_PolyDataSeries.size() > 0 ) )
    CalculateBoundingBox();
  else
    GetTimeSlicedGeometry()->UpdateInformation();
}
bool mitk::Surface::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.

Implements mitk::BaseData.

Reimplemented in mitk::BoundingObjectGroup.

Definition at line 188 of file mitkSurface.cpp.

{
  if( (m_RequestedRegion.GetIndex(3)>=0) && 
    (m_RequestedRegion.GetIndex(3)+m_RequestedRegion.GetSize(3)<=m_PolyDataSeries.size()) )
    return true;

  return false;
}

Member Data Documentation

Definition at line 112 of file mitkSurface.h.

Definition at line 108 of file mitkSurface.h.

Definition at line 106 of file mitkSurface.h.

Definition at line 110 of file mitkSurface.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines