From: Leonardo Florez-Valencia Date: Wed, 13 Apr 2016 00:07:29 +0000 (-0500) Subject: .. X-Git-Tag: v0.1~192 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e0389395c168c78560e79c92bcd021a09c3daf30;p=cpPlugins.git .. --- diff --git a/cmake/cpPlugins_Functions.cmake b/cmake/cpPlugins_Functions.cmake index d2ec9ca..68c2b88 100644 --- a/cmake/cpPlugins_Functions.cmake +++ b/cmake/cpPlugins_Functions.cmake @@ -41,7 +41,13 @@ ADD_CUSTOM_COMMAND( DEPENDS ${cpPlugins_HostCreator_APP} ${headers} COMMAND ${cpPlugins_HostCreator_APP} ${host} ${headers} ) -ADD_LIBRARY(${libname} SHARED ${host} ${sources} ${other_sources}) +SET(qtsources) +FOREACH(qth ${qtheaders}) + QT4_WRAP_CPP(qth_moc ${qth}) + SET(qtsources "${qtsources};${qth_moc}") +ENDFOREACH(qth) + +ADD_LIBRARY(${libname} SHARED ${host} ${sources} ${other_sources} ${qtsources}) SET_TARGET_PROPERTIES( ${libname} PROPERTIES VERSION "${ver}" diff --git a/lib/cpPlugins/BoundingBox.cxx b/lib/cpPlugins/BoundingBox.cxx new file mode 100644 index 0000000..14f48f4 --- /dev/null +++ b/lib/cpPlugins/BoundingBox.cxx @@ -0,0 +1,97 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +void cpPlugins::BoundingBox:: +SetDataObject( DataObject* o ) +{ + auto i = o->GetITK< itk::LightObject >( ); + auto v = o->GetVTK< vtkObjectBase >( ); + if( v != NULL ) this->SetVTK( v ); + else if( i != NULL ) this->SetITK( i ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BoundingBox:: +SetITK( itk::LightObject* o ) +{ + bool r = this->_ITKImage< 1 >( o ); + if( !r ) r = this->_ITKImage< 2 >( o ); + if( !r ) r = this->_ITKImage< 3 >( o ); + if( !r ) r = this->_ITKImage< 4 >( o ); + if( !r ) r = this->_ITKPointSet< float, 2 >( o ); + if( !r ) r = this->_ITKPointSet< double, 2 >( o ); + if( !r ) r = this->_ITKPointSet< float, 3 >( o ); + if( !r ) r = this->_ITKPointSet< double, 3 >( o ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BoundingBox:: +SetVTK( vtkObjectBase* o ) +{ + auto ds = dynamic_cast< vtkDataSet* >( o ); + if( ds != NULL ) + { + double bounds[ 6 ]; + ds->GetBounds( bounds ); + this->m_Points[ 0 ].clear( ); + this->m_Points[ 1 ].clear( ); + this->m_Points[ 0 ].push_back( bounds[ 0 ] ); + this->m_Points[ 1 ].push_back( bounds[ 1 ] ); + this->m_Points[ 0 ].push_back( bounds[ 2 ] ); + this->m_Points[ 1 ].push_back( bounds[ 3 ] ); + this->m_Points[ 0 ].push_back( bounds[ 4 ] ); + this->m_Points[ 1 ].push_back( bounds[ 5 ] ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpPlugins::BoundingBox:: +Copy( Self* other ) +{ + this->m_Points[ 0 ] = other->m_Points[ 0 ]; + this->m_Points[ 1 ] = other->m_Points[ 1 ]; + this->Modified( ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BoundingBox:: +Blend( Self* other ) +{ + if( this->m_Points[ 0 ].size( ) < other->m_Points[ 0 ].size( ) ) + this->m_Points[ 0 ].resize( + other->m_Points[ 0 ].size( ), + std::numeric_limits< double >::max( ) + ); + if( this->m_Points[ 1 ].size( ) < other->m_Points[ 1 ].size( ) ) + this->m_Points[ 1 ].resize( + other->m_Points[ 1 ].size( ), + -std::numeric_limits< double >::max( ) + ); + for( unsigned int d = 0; d < this->m_Points[ 0 ].size( ); ++d ) + if( other->m_Points[ 0 ][ d ] < this->m_Points[ 0 ][ d ] ) + this->m_Points[ 0 ][ d ] = other->m_Points[ 0 ][ d ]; + for( unsigned int d = 0; d < this->m_Points[ 1 ].size( ); ++d ) + if( other->m_Points[ 1 ][ d ] > this->m_Points[ 1 ][ d ] ) + this->m_Points[ 1 ][ d ] = other->m_Points[ 1 ][ d ]; + this->Modified( ); +} + +// ------------------------------------------------------------------------- +cpPlugins::BoundingBox:: +BoundingBox( ) + : Superclass( ) +{ + this->m_Points[ 0 ].push_back( double( 0 ) ); + this->m_Points[ 1 ].push_back( double( 0 ) ); +} + +// ------------------------------------------------------------------------- +cpPlugins::BoundingBox:: +~BoundingBox( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/BoundingBox.h b/lib/cpPlugins/BoundingBox.h new file mode 100644 index 0000000..b29cf2d --- /dev/null +++ b/lib/cpPlugins/BoundingBox.h @@ -0,0 +1,76 @@ +#ifndef __CPPLUGINS__BOUNDINGBOX__H__ +#define __CPPLUGINS__BOUNDINGBOX__H__ + +#include +#include + +namespace cpPlugins +{ + /** + */ + class cpPlugins_EXPORT BoundingBox + : public DataObject + { + public: + typedef BoundingBox Self; + typedef DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( BoundingBox, DataObject ); + cpPlugins_Id_Macro( BoundingBox, Object ); + + public: + void SetDataObject( DataObject* o ); + virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE; + virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE; + + void Copy( Self* other ); + void Blend( Self* other ); + + template< class _TPoint > + inline void SetMinimum( const _TPoint& p ); + + template< class _TPoint > + inline void SetMaximum( const _TPoint& p ); + + template< class _TPoint > + inline _TPoint GetMinimum( ) const; + + template< class _TPoint > + inline _TPoint GetMaximum( ) const; + + protected: + BoundingBox( ); + virtual ~BoundingBox( ); + + template< class _TPoint > + inline void _SetPoint( unsigned int m, const _TPoint& p ); + + template< class _TPoint > + inline _TPoint _GetPoint( unsigned int m ) const; + + template< unsigned int _NDim > + inline bool _ITKImage( itk::LightObject* o ); + + template< class _TScalar, unsigned int _NDim > + inline bool _ITKPointSet( itk::LightObject* o ); + + private: + // Purposely not implemented + BoundingBox( const Self& ); + Self& operator=( const Self& ); + + protected: + std::vector< double > m_Points[ 2 ]; + }; + +} // ecapseman + +#include + +#endif // __CPPLUGINS__BOUNDINGBOX__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/BoundingBox.hxx b/lib/cpPlugins/BoundingBox.hxx new file mode 100644 index 0000000..be95c3a --- /dev/null +++ b/lib/cpPlugins/BoundingBox.hxx @@ -0,0 +1,131 @@ +#ifndef __CPPLUGINS__BOUNDINGBOX__HXX__ +#define __CPPLUGINS__BOUNDINGBOX__HXX__ + +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +template< class _TPoint > +void cpPlugins::BoundingBox:: +SetMinimum( const _TPoint& p ) +{ + this->_SetPoint( 0, p ); +} + +// ------------------------------------------------------------------------- +template< class _TPoint > +void cpPlugins::BoundingBox:: +SetMaximum( const _TPoint& p ) +{ + this->_SetPoint( 1, p ); +} + +// ------------------------------------------------------------------------- +template< class _TPoint > +_TPoint cpPlugins::BoundingBox:: +GetMinimum( ) const +{ + return( this->_GetPoint< _TPoint >( 0 ) ); +} + +// ------------------------------------------------------------------------- +template< class _TPoint > +_TPoint cpPlugins::BoundingBox:: +GetMaximum( ) const +{ + return( this->_GetPoint< _TPoint >( 1 ) ); +} + +// ------------------------------------------------------------------------- +template< class _TPoint > +void cpPlugins::BoundingBox:: +_SetPoint( unsigned int m, const _TPoint& p ) +{ + this->m_Points[ m ].clear( ); + for( unsigned int d = 0; d < _TPoint::PointDimension; ++d ) + this->m_Points[ m ].push_back( double( p[ d ] ) ); + this->Modified( ); +} + +// ------------------------------------------------------------------------- +template< class _TPoint > +_TPoint cpPlugins::BoundingBox:: +_GetPoint( unsigned int m ) const +{ + unsigned int dim = this->m_Points[ m ].size( ); + dim = ( _TPoint::PointDimension < dim )? _TPoint::PointDimension: dim; + _TPoint p; + p.Fill( 0 ); + for( unsigned int d = 0; d < dim; ++d ) + p[ d ] = this->m_Points[ m ][ d ]; + return( p ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _NDim > +bool cpPlugins::BoundingBox:: +_ITKImage( itk::LightObject* o ) +{ + auto image = dynamic_cast< itk::ImageBase< _NDim >* >( o ); + if( image == NULL ) + return( false ); + + auto region = image->GetLargestPossibleRegion( ); + auto i0 = region.GetIndex( ); + auto i1 = i0 + region.GetSize( ); + + typename itk::ImageBase< _NDim >::PointType p0, p1; + image->TransformIndexToPhysicalPoint( i0, p0 ); + image->TransformIndexToPhysicalPoint( i1, p1 ); + this->m_Points[ 0 ].clear( ); + this->m_Points[ 1 ].clear( ); + + for( unsigned int d = 0; d < _NDim; ++d ) + { + this->m_Points[ 0 ].push_back( double( p0[ d ] ) ); + this->m_Points[ 1 ].push_back( double( p1[ d ] ) ); + + } // rof + this->Modified( ); + return( true ); +} + +// ------------------------------------------------------------------------- +template< class _TScalar, unsigned int _NDim > +bool cpPlugins::BoundingBox:: +_ITKPointSet( itk::LightObject* o ) +{ + typedef itk::PointSet< _TScalar, _NDim > _TPointSet; + typedef itk::BoundingBox< typename _TPointSet::PointIdentifier, _NDim, _TScalar, typename _TPointSet::PointsContainer > _TBBox; + + auto ps = dynamic_cast< _TPointSet* >( o ); + if( ps == NULL ) + return( false ); + + this->m_Points[ 0 ].clear( ); + this->m_Points[ 1 ].clear( ); + + typename _TBBox::Pointer bb = _TBBox::New( ); + bb->SetPoints( ps->GetPoints( ) ); + if( bb->ComputeBoundingBox( ) ) + { + auto p0 = bb->GetMinimum( ); + auto p1 = bb->GetMaximum( ); + for( unsigned int d = 0; d < _NDim; ++d ) + { + this->m_Points[ 0 ].push_back( double( p0[ d ] ) ); + this->m_Points[ 1 ].push_back( double( p1[ d ] ) ); + + } // rof + this->Modified( ); + return( true ); + } + else + return( false ); +} + +#endif // __CPPLUGINS__BOUNDINGBOX__HXX__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Image.hxx b/lib/cpPlugins/Image.hxx index 1378dc8..4a02cf9 100644 --- a/lib/cpPlugins/Image.hxx +++ b/lib/cpPlugins/Image.hxx @@ -113,6 +113,16 @@ _ITK_2_VTK_2( itk::LightObject* o ) #define cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, PIXEL, D ) \ this->FUNC( dynamic_cast< itk::Image< VECTOR< PIXEL, D >, D >* >( INPUT ) ) +#define cpPlugin_Image_Demangle_Pixel_AllInts( r, FUNC, INPUT, D ) \ + r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, char, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, short, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, int, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, long, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned char, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned short, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned int, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned long, D ) + #define cpPlugin_Image_Demangle_Pixel_AllScalars( r, FUNC, INPUT, D ) \ r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, char, D ); \ if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, short, D ); \ diff --git a/lib/cpPlugins/Mesh.cxx b/lib/cpPlugins/Mesh.cxx index 76ba6dd..216f3b3 100644 --- a/lib/cpPlugins/Mesh.cxx +++ b/lib/cpPlugins/Mesh.cxx @@ -43,54 +43,50 @@ SetVTK( vtkObjectBase* o ) this->m_VTKObject = mesh; // Copy points - /* TODO - _TMesh::Pointer imesh = _TMesh::New( ); - double point[ 3 ]; - for( long i = 0; i < mesh->GetNumberOfPoints( ); ++i ) - { - mesh->GetPoint( i, point ); - _TMesh::PointType ipoint; - ipoint[ 0 ] = point[ 0 ]; - ipoint[ 1 ] = point[ 1 ]; - ipoint[ 2 ] = point[ 2 ]; - imesh->SetPoint( i, ipoint ); - - } // rof - - // Copy cells - for( long i = 0; i < mesh->GetNumberOfCells( ); ++i ) - { - auto cell = mesh->GetCell( i ); - long nPoints = cell->GetNumberOfPoints( ); - _TCellAutoPointer icell; - if( nPoints == 2 ) - { - icell.TakeOwnership( new _TLine ); - icell->SetPointId( 0, cell->GetPointId( 0 ) ); - icell->SetPointId( 1, cell->GetPointId( 1 ) ); - } - else if( nPoints == 3 ) - { - icell.TakeOwnership( new _TTriangle ); - icell->SetPointId( 0, cell->GetPointId( 0 ) ); - icell->SetPointId( 1, cell->GetPointId( 1 ) ); - icell->SetPointId( 2, cell->GetPointId( 2 ) ); - } - else if( nPoints > 3 ) - { - _TPolygon* polygon = new _TPolygon( ); - for( long j = 0; j < nPoints; ++j ) - polygon->AddPointId( cell->GetPointId( j ) ); - icell.TakeOwnership( polygon ); - - } // fi - imesh->SetCell( imesh->GetNumberOfCells( ), icell ); - - } // rof - - this->m_ITKObject = imesh; - */ - this->m_ITKObject = NULL; // TODO: replace this + _TMesh::Pointer imesh = _TMesh::New( ); + double point[ 3 ]; + for( long i = 0; i < mesh->GetNumberOfPoints( ); ++i ) + { + mesh->GetPoint( i, point ); + _TMesh::PointType ipoint; + ipoint[ 0 ] = point[ 0 ]; + ipoint[ 1 ] = point[ 1 ]; + ipoint[ 2 ] = point[ 2 ]; + imesh->SetPoint( i, ipoint ); + + } // rof + + // Copy cells + for( long i = 0; i < mesh->GetNumberOfCells( ); ++i ) + { + auto cell = mesh->GetCell( i ); + long nPoints = cell->GetNumberOfPoints( ); + _TCellAutoPointer icell; + if( nPoints == 2 ) + { + icell.TakeOwnership( new _TLine ); + icell->SetPointId( 0, cell->GetPointId( 0 ) ); + icell->SetPointId( 1, cell->GetPointId( 1 ) ); + } + else if( nPoints == 3 ) + { + icell.TakeOwnership( new _TTriangle ); + icell->SetPointId( 0, cell->GetPointId( 0 ) ); + icell->SetPointId( 1, cell->GetPointId( 1 ) ); + icell->SetPointId( 2, cell->GetPointId( 2 ) ); + } + else if( nPoints > 3 ) + { + _TPolygon* polygon = new _TPolygon( ); + for( long j = 0; j < nPoints; ++j ) + polygon->AddPointId( cell->GetPointId( j ) ); + icell.TakeOwnership( polygon ); + + } // fi + imesh->SetCell( imesh->GetNumberOfCells( ), icell ); + + } // rof + this->m_ITKObject = imesh; this->Modified( ); } // fi diff --git a/lib/cpPlugins_Instances/BaseObjects.i b/lib/cpPlugins_Instances/BaseObjects.i index b2df0db..eb122be 100644 --- a/lib/cpPlugins_Instances/BaseObjects.i +++ b/lib/cpPlugins_Instances/BaseObjects.i @@ -24,6 +24,10 @@ c itk::Matrix< #floats, #dims, #dims > c itk::SimpleDataObjectDecorator< itk::@{CovariantVector;Point;Vector}< #floats, #dims > > c itk::SimpleDataObjectDecorator< itk::Matrix< #floats, #dims, #dims > > c itk::VectorContainer< unsigned long, itk::Point< #floats, #dims > > -c itk::BoundingBox< unsigned long, #dims, #floats, itk::VectorContainer< unsigned long, itk::Point< #floats, #dims > > > + +d #bb_in=#floats +d #bb_out=#floats + +c itk::BoundingBox< unsigned long, #dims, #bb_in, itk::VectorContainer< unsigned long, itk::Point< #bb_out, #dims > > > * eof - $RCSfile$ diff --git a/lib/cpPlugins_Instances/BitwiseImageFilters.i b/lib/cpPlugins_Instances/BitwiseImageFilters.i new file mode 100644 index 0000000..73d17e2 --- /dev/null +++ b/lib/cpPlugins_Instances/BitwiseImageFilters.i @@ -0,0 +1,14 @@ +f cpPlugins_Instances/ScalarImagesBaseFilters.h + +d #filters=And;Or + +i itk{#filters}ImageFilter.h +t itkBinaryFunctorImageFilter.h + +d #dims=1;2;3;4 +d #int=char;short;int;long +d #scalar=#int;unsigned #int + +c itk::{#filters}ImageFilter< itk::Image< #scalar, #dims >, itk::Image< #scalar, #dims > > + +* eof - $RCSfile$ diff --git a/lib/cpPlugins_Instances/CMakeLists.txt b/lib/cpPlugins_Instances/CMakeLists.txt index cfba0f7..79eef7e 100644 --- a/lib/cpPlugins_Instances/CMakeLists.txt +++ b/lib/cpPlugins_Instances/CMakeLists.txt @@ -23,6 +23,7 @@ cpPlugins_WrapInstances( ) cpPlugins_WrapInstances(ScalarImagesBaseFilters ${arg} ${pfx}ScalarImages) cpPlugins_WrapInstances(ScalarVectorImagesBaseFilters ${arg} ${pfx}ScalarImages ${pfx}VectorImages) +cpPlugins_WrapInstances(BitwiseImageFilters ${arg} ${pfx}ScalarImagesBaseFilters ${pfx}Decorators) cpPlugins_WrapInstances(ThresholdFilters ${arg} ${pfx}ScalarImagesBaseFilters) cpPlugins_WrapInstances(ImageMeshFilters ${arg} ${pfx}ScalarImagesBaseFilters ${pfx}Mesh) cpPlugins_WrapInstances(ResamplingFilters ${arg} ${pfx}ScalarImagesBaseFilters ${pfx}Transforms) @@ -51,6 +52,7 @@ SET( ${pfx}ImagesIO ${pfx}ScalarImagesBaseFilters ${pfx}ScalarVectorImagesBaseFilters + ${pfx}BitwiseImageFilters ${pfx}ThresholdFilters ${pfx}ImageMeshFilters ${pfx}ResamplingFilters diff --git a/lib/cpPlugins_Instances/Mesh.i b/lib/cpPlugins_Instances/Mesh.i index ea67b8f..be7ad53 100644 --- a/lib/cpPlugins_Instances/Mesh.i +++ b/lib/cpPlugins_Instances/Mesh.i @@ -12,12 +12,13 @@ t itkBoundingBox.h t itkMapContainer.h t itkVectorContainer.h t itkLineCell.h +t itkPolygonCell.h t itkTriangleCell.h t itkVertexCell.h c itk::CellInterface< #float, itk::CellTraitsInfo< #dims, float, float, unsigned long, unsigned long, unsigned long, itk::Point< float, #dims >, itk::VectorContainer< unsigned long, itk::Point< float, #dims > >, std::set< unsigned long > > > c itk::VectorContainer< unsigned long, itk::CellInterface< #float, itk::CellTraitsInfo< #dims, float, float, unsigned long, unsigned long, unsigned long, itk::Point< float, #dims >, itk::VectorContainer< unsigned long, itk::Point< float, #dims > >, std::set< unsigned long > > >* > -c @{itk::VertexCell;itk::LineCell;itk::TriangleCell}< itk::CellInterface< #float, itk::CellTraitsInfo< #dims, float, float, unsigned long, unsigned long, unsigned long, itk::Point< float, #dims >, itk::VectorContainer< unsigned long, itk::Point< float, #dims > >, std::set< unsigned long > > > > +c itk::@{VertexCell;LineCell;TriangleCell;PolygonCell}< itk::CellInterface< #float, itk::CellTraitsInfo< #dims, float, float, unsigned long, unsigned long, unsigned long, itk::Point< float, #dims >, itk::VectorContainer< unsigned long, itk::Point< float, #dims > >, std::set< unsigned long > > > > c @{itk::PointSet;itk::Mesh}< #float, #dims > c itk::MeshSource< itk::Mesh< #float, #dims > > diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index a62392d..a995095 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,4 +1,5 @@ SUBDIRS( + cpPluginsGenericFilters cpPluginsIO cpPluginsImageFilters cpPluginsMeshFilters diff --git a/plugins/cpPluginsGenericFilters/CMakeLists.txt b/plugins/cpPluginsGenericFilters/CMakeLists.txt new file mode 100644 index 0000000..1d759cc --- /dev/null +++ b/plugins/cpPluginsGenericFilters/CMakeLists.txt @@ -0,0 +1,27 @@ +SET(lib_NAME cpPluginsGenericFilters) +FILE(GLOB lib_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h") +FILE(GLOB lib_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx") +SET(lib_OTHER_SOURCES "") +SET(lib_QT4_HEADERS "") + +cpPlugins_WrapPlugins( + ${lib_NAME} ${prj_VER} ${prj_sVER} + "${lib_HEADERS}" + "${lib_SOURCES}" + "${lib_OTHER_SOURCES}" + "${lib_QT4_HEADERS}" + cpPlugins ${cpPlugins_LIBRARIES} + ) + +## ======================== +## -- Installation rules -- +## ======================== + +#INSTALL( +# TARGETS ${lib_NAME} +# RUNTIME DESTINATION bin +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib/static +# ) + +## eof - $RCSfile$ diff --git a/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx new file mode 100644 index 0000000..911040d --- /dev/null +++ b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx @@ -0,0 +1,56 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsGenericFilters::JoinBoundingBoxes:: +JoinBoundingBoxes( ) + : Superclass( ) +{ + this->_AddInput( "Input0" ); + this->_AddInput( "Input1", false ); + this->_AddInput( "Input2", false ); + this->_AddInput( "Input3", false ); + this->_AddInput( "Input4", false ); + this->_AddInput( "Input5", false ); + this->_AddOutput< cpPlugins::BoundingBox >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsGenericFilters::JoinBoundingBoxes:: +~JoinBoundingBoxes( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsGenericFilters::JoinBoundingBoxes:: +_GenerateData( ) +{ + typedef cpPlugins::DataObject _TDO; + typedef cpPlugins::BoundingBox _TBB; + _TDO* dobjs[ 5 ]; + + auto do0 = dynamic_cast< _TDO* >( this->GetInputData( "Input0" ) ); + dobjs[ 0 ] = dynamic_cast< _TDO* >( this->GetInputData( "Input1" ) ); + dobjs[ 1 ] = dynamic_cast< _TDO* >( this->GetInputData( "Input2" ) ); + dobjs[ 2 ] = dynamic_cast< _TDO* >( this->GetInputData( "Input3" ) ); + dobjs[ 3 ] = dynamic_cast< _TDO* >( this->GetInputData( "Input4" ) ); + dobjs[ 4 ] = dynamic_cast< _TDO* >( this->GetInputData( "Input5" ) ); + auto out = dynamic_cast< _TBB* >( this->GetOutputData( "Output" ) ); + + out->SetDataObject( do0 ); + for( unsigned int d = 0; d < 5; ++d ) + { + if( dobjs[ d ] != NULL ) + { + typename _TBB::Pointer bb = _TBB::New( ); + bb->SetDataObject( dobjs[ d ] ); + out->Blend( bb ); + + } // fi + + } // rof + return( "" ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h new file mode 100644 index 0000000..3df5da7 --- /dev/null +++ b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h @@ -0,0 +1,41 @@ +#ifndef __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__ +#define __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__ + +#include +#include + +namespace cpPluginsGenericFilters +{ + /** + */ + class cpPluginsGenericFilters_EXPORT JoinBoundingBoxes + : public cpPlugins::ProcessObject + { + public: + typedef JoinBoundingBoxes Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( JoinBoundingBoxes, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( JoinBoundingBoxes, GenericFilters ); + + protected: + JoinBoundingBoxes( ); + virtual ~JoinBoundingBoxes( ); + + virtual std::string _GenerateData( ) ITK_OVERRIDE; + + private: + // Purposely not implemented + JoinBoundingBoxes( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/AndImageFilter.cxx b/plugins/cpPluginsImageFilters/AndImageFilter.cxx new file mode 100644 index 0000000..e805798 --- /dev/null +++ b/plugins/cpPluginsImageFilters/AndImageFilter.cxx @@ -0,0 +1,65 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::AndImageFilter:: +AndImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input0" ); + this->_AddInput( "Input1" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::AndImageFilter:: +~AndImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageFilters::AndImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData( "Input0" )->GetITK< itk::DataObject >( ); + std::string cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 2 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 3 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 1 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 4 ); + return( r ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +std::string cpPluginsImageFilters::AndImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::AndImageFilter< _TImage, _TImage > _TFilter; + if( image0 != NULL ) + { + auto image1 = this->GetInputData( "Input1" )->GetITK< _TImage >( ); + if( image1 != NULL ) + { + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image0 ); + filter->SetInput( 1, image1 ); + filter->Update( ); + + // Connect output + this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + return( "" ); + } + else + return( + "ImageFilters::AndImageFilter: No valid second input image." + ); + } + else + return( + "ImageFilters::AndImageFilter: No valid first input image." + ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/AndImageFilter.h b/plugins/cpPluginsImageFilters/AndImageFilter.h new file mode 100644 index 0000000..7eefcc6 --- /dev/null +++ b/plugins/cpPluginsImageFilters/AndImageFilter.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__ANDIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__ANDIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT AndImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef AndImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( AndImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( AndImageFilter, ImageFilters ); + + protected: + AndImageFilter( ); + virtual ~AndImageFilter( ); + + virtual std::string _GenerateData( ) ITK_OVERRIDE; + + template< class _TImage > + inline std::string _GD0( _TImage* image0 ); + + private: + // Purposely not implemented + AndImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__ANDIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/OrImageFilter.cxx b/plugins/cpPluginsImageFilters/OrImageFilter.cxx new file mode 100644 index 0000000..0d37b7b --- /dev/null +++ b/plugins/cpPluginsImageFilters/OrImageFilter.cxx @@ -0,0 +1,65 @@ +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::OrImageFilter:: +OrImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input0" ); + this->_AddInput( "Input1" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::OrImageFilter:: +~OrImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageFilters::OrImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData( "Input0" )->GetITK< itk::DataObject >( ); + std::string cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 2 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 3 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 1 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 4 ); + return( r ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +std::string cpPluginsImageFilters::OrImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::OrImageFilter< _TImage, _TImage > _TFilter; + if( image0 != NULL ) + { + auto image1 = this->GetInputData( "Input1" )->GetITK< _TImage >( ); + if( image1 != NULL ) + { + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image0 ); + filter->SetInput( 1, image1 ); + filter->Update( ); + + // Connect output + this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + return( "" ); + } + else + return( + "ImageFilters::OrImageFilter: No valid second input image." + ); + } + else + return( + "ImageFilters::OrImageFilter: No valid first input image." + ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/OrImageFilter.h b/plugins/cpPluginsImageFilters/OrImageFilter.h new file mode 100644 index 0000000..4ea5f4c --- /dev/null +++ b/plugins/cpPluginsImageFilters/OrImageFilter.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__ORIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__ORIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT OrImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef OrImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( OrImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( OrImageFilter, ImageFilters ); + + protected: + OrImageFilter( ); + virtual ~OrImageFilter( ); + + virtual std::string _GenerateData( ) ITK_OVERRIDE; + + template< class _TImage > + inline std::string _GD0( _TImage* image0 ); + + private: + // Purposely not implemented + OrImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__ORIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx index 11bb178..6e35acc 100644 --- a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx +++ b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx @@ -1,4 +1,5 @@ #include +#include #include #include @@ -10,6 +11,7 @@ TriangleMeshToBinaryImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); + this->_AddInput( "BoundingBox", false ); this->_AddOutput< cpPlugins::Image >( "Output" ); this->m_Parameters.ConfigureAsUint( "InsideValue" ); @@ -55,16 +57,29 @@ template< class _TMesh, class _TPixel > std::string cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: _GD1( _TMesh* mesh ) { + typedef cpPlugins::BoundingBox _TBB; typedef itk::Image< _TPixel, _TMesh::PointDimension > _TImage; typedef itk::TriangleMeshToBinaryImageFilter< _TMesh, _TImage > _TFilter; + typedef typename _TImage::PointType _TPoint; static const unsigned int PAD = 10; _TFilter* filter = this->_CreateITK< _TFilter >( ); - auto bb = mesh->GetBoundingBox( ); - auto minBB = bb->GetMinimum( ); - auto maxBB = bb->GetMaximum( ); + auto in_bb = dynamic_cast< _TBB* >( this->GetInputData( "BoundingBox" ) ); + _TPoint minBB, maxBB; + if( in_bb == NULL ) + { + auto bb = mesh->GetBoundingBox( ); + minBB = bb->GetMinimum( ); + maxBB = bb->GetMaximum( ); + } + else + { + minBB = in_bb->GetMinimum< _TPoint >( ); + maxBB = in_bb->GetMaximum< _TPoint >( ); + + } // fi double lx = double( maxBB[ 0 ] - minBB[ 0 ] ); double ly = double( maxBB[ 1 ] - minBB[ 1 ] ); diff --git a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx index 1387804..4029c9c 100644 --- a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx +++ b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx @@ -29,18 +29,18 @@ _GenerateData( ) { auto m0 = this->GetInputData( "Input0" )->GetVTK< vtkPolyData >( ); auto m1 = this->GetInputData( "Input1" )->GetVTK< vtkPolyData >( ); - auto m2 = this->GetInputData( "Input2" )->GetVTK< vtkPolyData >( ); - auto m3 = this->GetInputData( "Input3" )->GetVTK< vtkPolyData >( ); - auto m4 = this->GetInputData( "Input4" )->GetVTK< vtkPolyData >( ); - auto m5 = this->GetInputData( "Input5" )->GetVTK< vtkPolyData >( ); + auto m2 = this->GetInputData( "Input2" ); + auto m3 = this->GetInputData( "Input3" ); + auto m4 = this->GetInputData( "Input4" ); + auto m5 = this->GetInputData( "Input5" ); auto filter = this->_CreateVTK< vtkAppendPolyData >( ); filter->AddInputData( m0 ); filter->AddInputData( m1 ); - if( m2 != NULL ) filter->AddInputData( m2 ); - if( m3 != NULL ) filter->AddInputData( m3 ); - if( m4 != NULL ) filter->AddInputData( m4 ); - if( m5 != NULL ) filter->AddInputData( m5 ); + if( m2 != NULL ) filter->AddInputData( m2->GetVTK< vtkPolyData >( ) ); + if( m3 != NULL ) filter->AddInputData( m3->GetVTK< vtkPolyData >( ) ); + if( m4 != NULL ) filter->AddInputData( m4->GetVTK< vtkPolyData >( ) ); + if( m5 != NULL ) filter->AddInputData( m5->GetVTK< vtkPolyData >( ) ); filter->Update( ); this->GetOutputData( "Output" )->SetVTK( filter->GetOutput( ) );