From 39b87ba0fde837abdf683ee307a7409053101302 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Thu, 20 Aug 2015 19:05:50 -0500 Subject: [PATCH] Simple point container to polydata added --- lib/fpa/VTK/ImageMPR.cxx | 1 - lib/fpa/VTK/PointPathToPolyDataFilter.h | 63 ++++++++ lib/fpa/VTK/PointPathToPolyDataFilter.hxx | 149 +++++++++++++++++++ lib/fpa/VTK/UniqueVerticesToPolyDataFilter.h | 2 +- 4 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 lib/fpa/VTK/PointPathToPolyDataFilter.h create mode 100644 lib/fpa/VTK/PointPathToPolyDataFilter.hxx diff --git a/lib/fpa/VTK/ImageMPR.cxx b/lib/fpa/VTK/ImageMPR.cxx index c308453..b565689 100644 --- a/lib/fpa/VTK/ImageMPR.cxx +++ b/lib/fpa/VTK/ImageMPR.cxx @@ -285,7 +285,6 @@ AddPolyData( vtkPolyData* pd, vtkLookupTable* lut, double opacity ) this->m_Renderer->AddActor( this->m_Actors[ i ] ); } - // ------------------------------------------------------------------------- unsigned int fpa::VTK::ImageMPR:: GetNumberOfSeeds( ) const diff --git a/lib/fpa/VTK/PointPathToPolyDataFilter.h b/lib/fpa/VTK/PointPathToPolyDataFilter.h new file mode 100644 index 0000000..1184129 --- /dev/null +++ b/lib/fpa/VTK/PointPathToPolyDataFilter.h @@ -0,0 +1,63 @@ +#ifndef __FPA__VTK__POINTPATHTOPOLYDATAFILTER__H__ +#define __FPA__VTK__POINTPATHTOPOLYDATAFILTER__H__ + +#include + +namespace fpa +{ + namespace VTK + { + /** + */ + template< class C > + class PointPathToPolyDataFilter + : public vtkPolyDataAlgorithm + { + public: + typedef PointPathToPolyDataFilter Self; + + typedef C TContainer; + typedef typename C::value_type TPoint; + + public: + vtkTypeMacro( PointPathToPolyDataFilter, vtkPolyDataAlgorithm ); + + public: + static Self* New( ); + + const C* GetInput( ) const; + void SetInput( const C* c ); + + protected: + PointPathToPolyDataFilter( ); + virtual ~PointPathToPolyDataFilter( ); + + int RequestData( + vtkInformation* information, + vtkInformationVector** input, + vtkInformationVector* output + ); + int RequestInformation( + vtkInformation* information, + vtkInformationVector** input, + vtkInformationVector* output + ); + + private: + // Purposely not implemented + PointPathToPolyDataFilter( const Self& ); + void operator=( const Self& ); + + protected: + const C* m_Container; + }; + + } // ecapseman + +} // ecapseman + +#include + +#endif // __FPA__VTK__POINTPATHTOPOLYDATAFILTER__H__ + +// eof - $RCSfile$ diff --git a/lib/fpa/VTK/PointPathToPolyDataFilter.hxx b/lib/fpa/VTK/PointPathToPolyDataFilter.hxx new file mode 100644 index 0000000..a79c763 --- /dev/null +++ b/lib/fpa/VTK/PointPathToPolyDataFilter.hxx @@ -0,0 +1,149 @@ +#ifndef __FPA__VTK__POINTPATHTOPOLYDATAFILTER__HXX__ +#define __FPA__VTK__POINTPATHTOPOLYDATAFILTER__HXX__ + +#include +#include + +// ------------------------------------------------------------------------- +template< class C > +typename fpa::VTK::PointPathToPolyDataFilter< C >:: +Self* fpa::VTK::PointPathToPolyDataFilter< C >:: +New( ) +{ + return( new Self( ) ); +} + +// ------------------------------------------------------------------------- +template< class C > +const C* fpa::VTK::PointPathToPolyDataFilter< C >:: +GetInput( ) const +{ + return( this->m_Container ); +} + +// ------------------------------------------------------------------------- +template< class C > +void fpa::VTK::PointPathToPolyDataFilter< C >:: +SetInput( const C* c ) +{ + if( this->m_Container != c ) + { + this->m_Container = c; + this->Modified( ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< class C > +fpa::VTK::PointPathToPolyDataFilter< C >:: +PointPathToPolyDataFilter( ) + : vtkPolyDataAlgorithm( ), + m_Container( NULL ) +{ + this->SetNumberOfInputPorts( 0 ); +} + +// ------------------------------------------------------------------------- +template< class C > +fpa::VTK::PointPathToPolyDataFilter< C >:: +~PointPathToPolyDataFilter( ) +{ +} + +// ------------------------------------------------------------------------- +template< class C > +int fpa::VTK::PointPathToPolyDataFilter< C >:: +RequestData( + vtkInformation* information, + vtkInformationVector** input, + vtkInformationVector* output + ) +{ + if( this->m_Container == NULL ) + return( 0 ); + + // Get output + vtkInformation* info = output->GetInformationObject( 0 ); + vtkPolyData* out = vtkPolyData::SafeDownCast( + info->Get( vtkDataObject::DATA_OBJECT( ) ) + ); + + // Prepare points + vtkPoints* points = out->GetPoints( ); + if( points == NULL ) + { + points = vtkPoints::New( ); + out->SetPoints( points ); + points->Delete( ); + + } // fi + points->SetNumberOfPoints( this->m_Container->size( ) ); + + // Prepare cells + vtkSmartPointer< vtkCellArray > cells = + vtkSmartPointer< vtkCellArray >::New( ); + + unsigned int pId = 0; + for( + typename C::const_iterator it = this->m_Container->begin( ); + it != this->m_Container->end( ); + ++it, ++pId + ) + { + TPoint pnt = *it; + if( TPoint::Dimension == 1 ) + points->SetPoint( pId, pnt[ 0 ], 0, 0 ); + else if( TPoint::Dimension == 2 ) + points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], 0 ); + else + points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); + + cells->InsertNextCell( 1 ); + cells->InsertCellPoint( pId ); + + } // rof + out->SetPoints( points ); + out->SetVerts( cells ); + return( 1 ); +} + +// ------------------------------------------------------------------------- +template< class C > +int fpa::VTK::PointPathToPolyDataFilter< C >:: +RequestInformation( + vtkInformation* information, + vtkInformationVector** input, + vtkInformationVector* output + ) +{ + vtkInformation* info = output->GetInformationObject( 0 ); + /* TODO + info->Set( + vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1 + ); + */ + + if( this->m_Container != NULL ) + { + /* TODO + typename C::TScalar len = this->m_RGC->GetTotalLength( ); + typename C::TScalar s0 = this->m_RGC->Gets0( ); + typename C::TPoint p0 = this->m_RGC->Axis( s0 ); + typename C::TPoint p1 = this->m_RGC->Axis( s0 + len ); + + info->Set( + vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX( ), + double( p0[ 0 ] ), double( p1[ 0 ] ), + double( p0[ 1 ] ), double( p1[ 1 ] ), + double( p0[ 2 ] ), double( p1[ 2 ] ) + ); + */ + + } // fi + return( 1 ); +} + +#endif // __FPA__VTK__POINTPATHTOPOLYDATAFILTER__HXX__ + +// eof - $RCSfile$ diff --git a/lib/fpa/VTK/UniqueVerticesToPolyDataFilter.h b/lib/fpa/VTK/UniqueVerticesToPolyDataFilter.h index ed9785f..96d66ca 100644 --- a/lib/fpa/VTK/UniqueVerticesToPolyDataFilter.h +++ b/lib/fpa/VTK/UniqueVerticesToPolyDataFilter.h @@ -17,7 +17,7 @@ namespace fpa typedef UniqueVerticesToPolyDataFilter Self; public: - vtkTypeMacro( UniqueVerticesToPolyDataFilter,vtkPolyDataAlgorithm ); + vtkTypeMacro( UniqueVerticesToPolyDataFilter, vtkPolyDataAlgorithm ); public: static Self* New( ); -- 2.45.1