From: Leonardo Flórez-Valencia Date: Thu, 6 Oct 2016 22:59:57 +0000 (-0500) Subject: Complex graph representation as branches: 1/3. Windows compil: 2/3 X-Git-Tag: v0.1~95 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8eaa2cf759c39233848cdd5b8346faccbea4c172;p=cpPlugins.git Complex graph representation as branches: 1/3. Windows compil: 2/3 --- diff --git a/lib/Instances/CMakeLists.txt b/lib/Instances/CMakeLists.txt index 6429135..a32d683 100644 --- a/lib/Instances/CMakeLists.txt +++ b/lib/Instances/CMakeLists.txt @@ -28,5 +28,6 @@ TARGET_LINK_LIBRARIES(${_pfx}Meshes ${_pfx}BoundingBoxes) TARGET_LINK_LIBRARIES(${_pfx}ImageIterators ${_pfx}Images) TARGET_LINK_LIBRARIES(${_pfx}ImageFilters ${_pfx}Images ${_pfx}ImageIterators) TARGET_LINK_LIBRARIES(${_pfx}ImageNeighborhoodIterators ${_pfx}Images) +TARGET_LINK_LIBRARIES(${_pfx}Paths ${_pfx}Images) ## eof - $RCSfile$ diff --git a/lib/Instances/cpPlugins_Paths.i b/lib/Instances/cpPlugins_Paths.i new file mode 100644 index 0000000..2b8c8a8 --- /dev/null +++ b/lib/Instances/cpPlugins_Paths.i @@ -0,0 +1,29 @@ +** ====================== +** == Some definitions == +** ====================== + +** ============== +** == Includes == +** ============== + +i cpPlugins_Images.h +t cpExtensions/DataStructures/PolyLineParametricPath +t itkPath +t itkParametricPath +t itkPolyLineParametricPath +t itkVectorContainer + +** ================== +** == Dependencies == +** ================== + +** =============== +** == Instances == +** =============== + +c itk::Path< double, itk::ContinuousIndex< double, #process_dims# >, #process_dims# > +c itk::ParametricPath< #process_dims# > +c itk::PolyLineParametricPath< #process_dims# > +c cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# > + +** eof - $RCSfile$ diff --git a/lib/cpExtensions/DataStructures/PolyLineParametricPath.h b/lib/cpExtensions/DataStructures/PolyLineParametricPath.h index b2e1c77..e8046ea 100644 --- a/lib/cpExtensions/DataStructures/PolyLineParametricPath.h +++ b/lib/cpExtensions/DataStructures/PolyLineParametricPath.h @@ -20,29 +20,48 @@ namespace cpExtensions typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef itk::ImageBase< _VDim > TImageBase; + typedef itk::ImageBase< _VDim > TImageBase; + typedef typename TImageBase::SpacingType TSpacing; + typedef typename TImageBase::PointType TPoint; + typedef typename TImageBase::DirectionType TDirection; + typedef typename Superclass::ContinuousIndexType TContinuousIndex; public: itkNewMacro( Self ); itkTypeMacro( PolyLineParametricPath, itk::PolyLineParametricPath ); + itkGetConstReferenceMacro( Spacing, TSpacing ); + itkGetConstReferenceMacro( Origin, TPoint ); + itkGetConstReferenceMacro( Direction, TDirection ); + itkGetConstReferenceMacro( InverseDirection, TDirection ); + + itkSetMacro( Origin, TPoint ); + public: - TImageBase* GetReferenceImage( ) - { return( this->m_ReferenceImage ); } - const TImageBase* GetReferenceImage( ) const - { return( this->m_ReferenceImage ); } - void SetReferenceImage( const TImageBase* image ) + unsigned long GetSize( ) const; + TContinuousIndex GetVertex( unsigned long i ) const; + TPoint GetPoint( unsigned long i ) const; + + virtual void SetSpacing( const TSpacing& spac ); + virtual void SetSpacing( const double spac[ _VDim ] ); + virtual void SetSpacing( const float spac[ _VDim ] ); + virtual void SetOrigin( const double ori[ _VDim ] ); + virtual void SetOrigin( const float ori[ _VDim ] ); + virtual void SetDirection( const TDirection& dir ); + + template< class _TRefImage > + inline void SetReferenceImage( const _TRefImage* image ) { - this->m_ReferenceImage = TImageBase::New( ); - this->m_ReferenceImage->SetDirection( image->GetDirection( ) ); - this->m_ReferenceImage->SetOrigin( image->GetOrigin( ) ); - this->m_ReferenceImage->SetSpacing( image->GetSpacing( ) ); - this->Modified( ); + this->SetSpacing( image->GetSpacing( ) ); + this->SetOrigin( image->GetOrigin( ) ); + this->SetDirection( image->GetDirection( ) ); } protected: - PolyLineParametricPath( ) { } - virtual ~PolyLineParametricPath( ) { } + PolyLineParametricPath( ); + virtual ~PolyLineParametricPath( ); + + virtual void _ComputeIndexToPhysicalPointMatrices( ); private: // Purposely not implemented @@ -50,14 +69,22 @@ namespace cpExtensions Self& operator=( const Self& other ); protected: - typename TImageBase::Pointer m_ReferenceImage; + TSpacing m_Spacing; + TPoint m_Origin; + TDirection m_Direction; + TDirection m_InverseDirection; + TDirection m_IndexToPhysicalPoint; + TDirection m_PhysicalPointToIndex; }; } // ecapseman } // ecapseman -#endif // __cpExtensions__DataStructures__PolyLineParametricPath__h__ +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION +#endif // __cpExtensions__DataStructures__PolyLineParametricPath__h__ // eof - $RCSfile$ diff --git a/lib/cpExtensions/DataStructures/PolyLineParametricPath.hxx b/lib/cpExtensions/DataStructures/PolyLineParametricPath.hxx new file mode 100644 index 0000000..306ab79 --- /dev/null +++ b/lib/cpExtensions/DataStructures/PolyLineParametricPath.hxx @@ -0,0 +1,176 @@ +#ifndef __cpExtensions__DataStructures__PolyLineParametricPath__hxx__ +#define __cpExtensions__DataStructures__PolyLineParametricPath__hxx__ + +#include +#include + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +unsigned long cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +GetSize( ) const +{ + return( this->GetVertexList( )->Size( ) ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +typename cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +TContinuousIndex +cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +GetVertex( unsigned long i ) const +{ + return( this->GetVertexList( )->GetElement( i ) ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +typename cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +TPoint cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +GetPoint( unsigned long i ) const +{ + typedef typename TPoint::CoordRepType _TCoordRep; + TPoint pnt; + TContinuousIndex idx = this->GetVertex( i ); + for( unsigned int r = 0; r < _VDim; ++r ) + { + _TCoordRep sum = itk::NumericTraits< _TCoordRep >::ZeroValue( ); + for( unsigned int c = 0; c < _VDim; ++c ) + sum += this->m_IndexToPhysicalPoint( r, c ) * idx[ c ]; + pnt[ r ] = sum + this->m_Origin[ r ]; + + } // rof + return( pnt ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +SetSpacing( const TSpacing& spac ) +{ + if( this->m_Spacing != spac ) + { + this->m_Spacing = spac; + this->_ComputeIndexToPhysicalPointMatrices( ); + this->Modified( ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +SetSpacing( const double spac[ _VDim ] ) +{ + this->SetSpacing( TSpacing( spac ) ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +SetSpacing( const float spac[ _VDim ] ) +{ + TSpacing s; + for( unsigned int d = 0; d < _VDim; ++d ) + s[ d ] = spac[ d ]; + this->SetSpacing( s ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +SetOrigin( const double ori[ _VDim ] ) +{ + this->SetOrigin( TPoint( ori ) ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +SetOrigin( const float ori[ _VDim ] ) +{ + this->SetOrigin( TPoint( ori ) ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +SetDirection( const TDirection& dir ) +{ + bool modified = false; + for( unsigned int r = 0; r < _VDim; r++ ) + { + for( unsigned int c = 0; c < _VDim; c++ ) + { + if( + itk::Math::NotExactlyEquals( + this->m_Direction[ r ][ c ], dir[ r ][ c ] + ) + ) + { + this->m_Direction[ r ][ c ] = dir[ r ][ c ]; + modified = true; + } // fi + + } // rof + + } // rof + if( modified ) + { + this->_ComputeIndexToPhysicalPointMatrices( ); + this->m_InverseDirection = this->m_Direction.GetInverse( ); + this->Modified( ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +PolyLineParametricPath( ) + : Superclass( ) +{ + this->m_Spacing.Fill( 1.0 ); + this->m_Origin.Fill( 0.0 ); + this->m_Direction.SetIdentity( ); + this->m_InverseDirection.SetIdentity( ); + this->m_IndexToPhysicalPoint.SetIdentity( ); + this->m_PhysicalPointToIndex.SetIdentity( ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +~PolyLineParametricPath( ) +{ +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >:: +_ComputeIndexToPhysicalPointMatrices( ) +{ + TDirection scale; + scale.Fill( 0.0 ); + for( unsigned int i = 0; i < _VDim; i++ ) + { + if( this->m_Spacing[ i ] == 0.0 ) + itkExceptionMacro( + "A spacing of 0 is not allowed: Spacing is " << this->m_Spacing + ); + scale[ i ][ i ] = this->m_Spacing[ i ]; + + } // rof + + if( vnl_determinant( this->m_Direction.GetVnlMatrix( ) ) == 0.0 ) + itkExceptionMacro( + << "Bad direction, determinant is 0. Direction is " + << this->m_Direction + ); + this->m_IndexToPhysicalPoint = this->m_Direction * scale; + this->m_PhysicalPointToIndex = this->m_IndexToPhysicalPoint.GetInverse( ); + this->Modified( ); +} + +#endif // __cpExtensions__DataStructures__PolyLineParametricPath__hxx__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.cxx b/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.cxx new file mode 100644 index 0000000..c97fac7 --- /dev/null +++ b/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.cxx @@ -0,0 +1,131 @@ +#include + +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +typename +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +Self* +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +New( ) +{ + return( new Self( ) ); +} + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +const typename +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +TPolyLine* +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +GetInput( ) const +{ + return( this->m_PolyLine ); +} + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +void +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +SetInput( const TPolyLine* pl ) +{ + if( this->m_PolyLine != pl ) + { + this->m_PolyLine = pl; + this->Modified( ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +PolyLineParametricPathToPolyData( ) + : vtkPolyDataAlgorithm( ), + m_PolyLine( NULL ) +{ + this->SetNumberOfInputPorts( 0 ); +} + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +~PolyLineParametricPathToPolyData( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +int +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +RequestData( + vtkInformation* information, + vtkInformationVector** input, + vtkInformationVector* output + ) +{ + static const unsigned int dim = _TPolyLine::PathDimension; + + if( this->m_PolyLine == NULL ) + return( 0 ); + + // Get output + vtkInformation* info = output->GetInformationObject( 0 ); + vtkPolyData* out = vtkPolyData::SafeDownCast( + info->Get( vtkDataObject::DATA_OBJECT( ) ) + ); + + // Prepare data + out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) ); + out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) ); + out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) ); + out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) ); + out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) ); + vtkPoints* points = out->GetPoints( ); + vtkCellArray* lines = out->GetLines( ); + + // Get data + for( unsigned long i = 0; i < this->m_PolyLine->GetSize( ); ++i ) + { + typename _TPolyLine::TPoint pnt = this->m_PolyLine->GetPoint( i ); + if( dim == 1 ) points->InsertNextPoint( pnt[ 0 ], 0, 0 ); + else if( dim == 2 ) points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 ); + else points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); + if( i > 0 ) + { + lines->InsertNextCell( 2 ); + lines->InsertCellPoint( i - 1 ); + lines->InsertCellPoint( i ); + + } // fi + + } // rof + return( 1 ); +} + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +int +cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: +RequestInformation( + vtkInformation* information, + vtkInformationVector** input, + vtkInformationVector* output + ) +{ + return( 1 ); +} + +// ------------------------------------------------------------------------- +#include + +template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 1 > >; +template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 2 > >; +template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 3 > >; +template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 4 > >; + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.h b/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.h index cfc481e..8e73108 100644 --- a/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.h +++ b/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.h @@ -1,8 +1,8 @@ -#ifndef __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__H__ -#define __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__H__ +#ifndef __cpExtensions__Visualization__PolyLineParametricPathToPolyData__h__ +#define __cpExtensions__Visualization__PolyLineParametricPathToPolyData__h__ +#include #include -#include namespace cpExtensions { @@ -11,14 +11,12 @@ namespace cpExtensions /** */ template< class _TPolyLine > - class PolyLineParametricPathToPolyData + class cpExtensions_EXPORT PolyLineParametricPathToPolyData : public vtkPolyDataAlgorithm { public: typedef PolyLineParametricPathToPolyData Self; - typedef _TPolyLine TPolyLine; - typedef itk::ImageBase< TPolyLine::PathDimension > TImage; public: vtkTypeMacro( PolyLineParametricPathToPolyData, vtkPolyDataAlgorithm ); @@ -27,9 +25,7 @@ namespace cpExtensions static Self* New( ); const TPolyLine* GetInput( ) const; - const TImage* GetReferenceImage( ) const; void SetInput( const TPolyLine* pl ); - void SetReferenceImage( const TImage* i ); protected: PolyLineParametricPathToPolyData( ); @@ -53,17 +49,12 @@ namespace cpExtensions protected: const TPolyLine* m_PolyLine; - const TImage* m_ReferenceImage; }; } // ecapseman } // ecapseman -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__H__ +#endif // __cpExtensions__Visualization__PolyLineParametricPathToPolyData__h__ // eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx b/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx deleted file mode 100644 index e3d23c7..0000000 --- a/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__HXX__ -#define __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__HXX__ - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -typename -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -Self* -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -New( ) -{ - return( new Self( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -const typename -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -TPolyLine* -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -GetInput( ) const -{ - return( this->m_PolyLine ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -const typename -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -TImage* -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -GetReferenceImage( ) const -{ - return( this->m_ReferenceImage ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -void -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -SetInput( const TPolyLine* pl ) -{ - if( this->m_PolyLine != pl ) - { - this->m_PolyLine = pl; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -void -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -SetReferenceImage( const TImage* i ) -{ - if( this->m_ReferenceImage != i ) - { - this->m_ReferenceImage = i; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -PolyLineParametricPathToPolyData( ) - : vtkPolyDataAlgorithm( ), - m_PolyLine( NULL ), - m_ReferenceImage( NULL ) -{ - this->SetNumberOfInputPorts( 0 ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -~PolyLineParametricPathToPolyData( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -int -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -RequestData( - vtkInformation* information, - vtkInformationVector** input, - vtkInformationVector* output - ) -{ - static const unsigned int dim = _TPolyLine::PathDimension; - - if( this->m_PolyLine == NULL ) - return( 0 ); - - // Get output - vtkInformation* info = output->GetInformationObject( 0 ); - vtkPolyData* out = vtkPolyData::SafeDownCast( - info->Get( vtkDataObject::DATA_OBJECT( ) ) - ); - - // Get input data - auto lst = this->m_PolyLine->GetVertexList( ); - - // Prepare points - vtkPoints* points = out->GetPoints( ); - if( points == NULL ) - { - points = vtkPoints::New( ); - out->SetPoints( points ); - points->Delete( ); - - } // fi - points->SetNumberOfPoints( lst->Size( ) ); - - // Prepare cells - /* TODO - vtkSmartPointer< vtkCellArray > verts = - vtkSmartPointer< vtkCellArray >::New( ); - */ - vtkSmartPointer< vtkCellArray > lines = - vtkSmartPointer< vtkCellArray >::New( ); - - for( unsigned int i = 0; i < lst->Size( ); ++i ) - { - auto idx = lst->GetElement( i ); - if( this->m_ReferenceImage != NULL ) - { - typename TImage::PointType pnt; - this->m_ReferenceImage->TransformContinuousIndexToPhysicalPoint( idx, pnt ); - if( dim == 1 ) - points->SetPoint( i, pnt[ 0 ], 0, 0 ); - else if( dim == 2 ) - points->SetPoint( i, pnt[ 0 ], pnt[ 1 ], 0 ); - else - points->SetPoint( i, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); - } - else - { - if( dim == 1 ) - points->SetPoint( i, idx[ 0 ], 0, 0 ); - else if( dim == 2 ) - points->SetPoint( i, idx[ 0 ], idx[ 1 ], 0 ); - else - points->SetPoint( i, idx[ 0 ], idx[ 1 ], idx[ 2 ] ); - - } // fi - /* TODO - verts->InsertNextCell( 1 ); - verts->InsertCellPoint( i ); - */ - if( i > 0 ) - { - lines->InsertNextCell( 2 ); - lines->InsertCellPoint( i - 1 ); - lines->InsertCellPoint( i ); - - } // fi - - } // rof - out->SetPoints( points ); - // TODO: out->SetVerts( verts ); - out->SetLines( lines ); - return( 1 ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine > -int -cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >:: -RequestInformation( - vtkInformation* information, - vtkInformationVector** input, - vtkInformationVector* output - ) -{ - vtkInformation* info = output->GetInformationObject( 0 ); - /* TODO - info->Set( - vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1 - ); - */ - - if( this->m_PolyLine != NULL && this->m_ReferenceImage != 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 // __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__HXX__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx new file mode 100644 index 0000000..36d11f3 --- /dev/null +++ b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx @@ -0,0 +1,58 @@ +#include +#include + +// ------------------------------------------------------------------------- +void cpPlugins::DataObjects::PolyLineParametricPath:: +SetITK( itk::LightObject* o ) +{ + this->Superclass::SetITK( o ); + auto l1 = dynamic_cast< itk::PolyLineParametricPath< 1 >* >( o ); + auto l2 = dynamic_cast< itk::PolyLineParametricPath< 2 >* >( o ); + auto l3 = dynamic_cast< itk::PolyLineParametricPath< 3 >* >( o ); + auto l4 = dynamic_cast< itk::PolyLineParametricPath< 4 >* >( o ); + if ( l1 != NULL ) this->_ITK_2_VTK( l1 ); + else if( l2 != NULL ) this->_ITK_2_VTK( l2 ); + else if( l3 != NULL ) this->_ITK_2_VTK( l3 ); + else if( l4 != NULL ) this->_ITK_2_VTK( l4 ); + else + { + this->m_VTK = NULL; + this->m_ITKvVTK = NULL; + + } // fi +} + +// ------------------------------------------------------------------------- +void cpPlugins::DataObjects::PolyLineParametricPath:: +SetVTK( vtkObjectBase* o ) +{ + // Do nothing + this->m_ITK = NULL; + this->m_VTK = NULL; + this->m_ITKvVTK = NULL; +} + +// ------------------------------------------------------------------------- +cpPlugins::DataObjects::PolyLineParametricPath:: +PolyLineParametricPath( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::DataObjects::PolyLineParametricPath:: +~PolyLineParametricPath( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TPolyLine > +void cpPlugins::DataObjects::PolyLineParametricPath:: +_ITK_2_VTK( _TPolyLine* pl ) +{ + typedef + cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine > + _TFilter; +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.h b/lib/cpPlugins/DataObjects/PolyLineParametricPath.h new file mode 100644 index 0000000..1a0147b --- /dev/null +++ b/lib/cpPlugins/DataObjects/PolyLineParametricPath.h @@ -0,0 +1,61 @@ +#ifndef __cpPlugins__DataObjects__PolyLineParametricPath__h__ +#define __cpPlugins__DataObjects__PolyLineParametricPath__h__ + +#include +#include +#include + +// ------------------------------------------------------------------------- +class vtkPolyDataAlgorithm; + +// ------------------------------------------------------------------------- +namespace cpPlugins +{ + namespace DataObjects + { + /** + */ + class cpPlugins_EXPORT PolyLineParametricPath + : public cpPlugins::BaseObjects::DataObject + { + public: + typedef PolyLineParametricPath Self; + typedef cpPlugins::BaseObjects::DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + PolyLineParametricPath, cpPlugins::BaseObjects::DataObject + ); + cpPlugins_Id_Macro( PolyLineParametricPath, Object ); + cpPlugins_Compatibility_Macro; + + public: + virtual void SetITK( itk::LightObject* o ) cpPlugins_OVERRIDE; + virtual void SetVTK( vtkObjectBase* o ) cpPlugins_OVERRIDE; + + protected: + PolyLineParametricPath( ); + virtual ~PolyLineParametricPath( ); + + template< class _TPolyLine > + inline void _ITK_2_VTK( _TPolyLine* pl ); + + private: + // Purposely not implemented + PolyLineParametricPath( const Self& ); + Self& operator=( const Self& ); + + protected: + vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK; + }; + + } // ecapseman + +} // ecapseman + +#endif // __cpPlugins__DataObjects__PolyLineParametricPath__h__ + +// eof - $RCSfile$