From: Leonardo Florez-Valencia Date: Wed, 30 Mar 2016 17:48:35 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~219 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=eccc88f770fd53f8ef8d578127a8788315573c52;p=cpPlugins.git ... --- diff --git a/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt b/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt index d43489e..7cec3ab 100644 --- a/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt +++ b/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt @@ -1,4 +1,5 @@ f cpPlugins_ITKInstances/Base.h +i itkBoundingBox.h i itkPointSet.h i itkMesh.h i itkQuadEdgeMesh.h @@ -7,6 +8,7 @@ i itkPolygonCell.h i itkTriangleCell.h c itk::VectorContainer< unsigned long, itk::Point< #1 , #2 > > c itk::MapContainer< unsigned long , itk::QuadEdgeMeshPoint< #1 , #2 , itk::GeometricalQuadEdge< unsigned long, unsigned long, bool, bool, true > > > +c itk::BoundingBox< unsigned long , #2 , float, itk::VectorContainer< unsigned long , itk::Point< float , #2 > > > c itk::PointSet< #1 , #2 > c #4 < #1 , #2 > c #3 < itk::CellInterface< #1 , itk::CellTraitsInfo< #2 , float , float , unsigned long , unsigned long , unsigned long , itk::Point< float , #2 > , itk::VectorContainer< unsigned long , itk::Point< float , #2 > > , std::set< unsigned long , std::less< unsigned long > , std::allocator< unsigned long > > > > > diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 8cf8c48..d39875a 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,6 +1,8 @@ SUBDIRS( cpPluginsIO cpPluginsImageFilters + cpPluginsMeshFilters + cpPluginsImageMeshFilters cpPluginsVisualization cpPluginsWidgets ) diff --git a/plugins/cpPluginsIO/MeshReader.cxx b/plugins/cpPluginsIO/MeshReader.cxx new file mode 100644 index 0000000..49b76a2 --- /dev/null +++ b/plugins/cpPluginsIO/MeshReader.cxx @@ -0,0 +1,106 @@ +#include +#include + +#include + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsIO::MeshReader:: +MeshReader( ) + : Superclass( ) +{ + this->_AddOutput< cpPlugins::Mesh >( "Output" ); + this->m_Parameters.Clear( ); + this->m_Parameters.ConfigureAsOpenFileName( "FileName" ); + this->m_Parameters.ConfigureAsUint( "Dimension" ); + + std::vector< std::string > valid_types; + valid_types.push_back( "float" ); + valid_types.push_back( "double" ); + this->m_Parameters.ConfigureAsChoices( "ScalarType", valid_types ); + this->m_Parameters.SetSelectedChoice( "ScalarType", "float" ); + + this->m_Parameters.SetUint( "Dimension", 3 ); + this->m_Parameters.SetAcceptedFileExtensions( + "FileName", + "Mesh files (*.obj *.stl *.vtk)" + ); +} + +// ------------------------------------------------------------------------- +cpPluginsIO::MeshReader:: +~MeshReader( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsIO::MeshReader:: +_GenerateData( ) +{ + auto dim = this->m_Parameters.GetUint( "Dimension" ); + if ( dim == 2 ) return( this->_GD0< 2 >( ) ); + else if( dim == 3 ) return( this->_GD0< 3 >( ) ); + else return( "MeshReader: Mesh dimension not supported." ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _Dim > +std::string cpPluginsIO::MeshReader:: +_GD0( ) +{ + auto st = this->m_Parameters.GetSelectedChoice( "ScalarType" ); + if ( st == "float" ) return( this->_GD1< float, _Dim >( ) ); + else if( st == "double" ) return( this->_GD1< double, _Dim >( ) ); + else return( "MeshReader: Mesh type not supported." ); +} + +// ------------------------------------------------------------------------- +template< class _TScalar, unsigned int _Dim > +std::string cpPluginsIO::MeshReader:: +_GD1( ) +{ + auto fname = this->m_Parameters.GetOpenFileName( "FileName" ); + + // Get file extension + std::istringstream fname_str( fname ); + std::string token, ext; + while( std::getline( fname_str, token, '.' ) ) + ext = token; + std::transform( ext.begin( ), ext.end( ), ext.begin( ), tolower ); + + // Real read + if( ext == "stl" ) + { + vtkSTLReader* stlr = this->_CreateVTK< vtkSTLReader >( ); + stlr->SetFileName( fname.c_str( ) ); + stlr->Update( ); + + this->GetOutputData( "Output" )->SetVTK( stlr->GetOutput( ) ); + return( "" ); + } + else if( ext == "obj" ) + { + vtkOBJReader* objr = this->_CreateVTK< vtkOBJReader >( ); + objr->SetFileName( fname.c_str( ) ); + objr->Update( ); + + this->GetOutputData( "Output" )->SetVTK( objr->GetOutput( ) ); + return( "" ); + } + else if( ext == "vtk" ) + { + vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( ); + pdr->SetFileName( fname.c_str( ) ); + pdr->Update( ); + + this->GetOutputData( "Output" )->SetVTK( pdr->GetOutput( ) ); + return( "" ); + } + else + return( "MeshReader: Input file format not recognized." ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/MeshReader.h b/plugins/cpPluginsIO/MeshReader.h new file mode 100644 index 0000000..c32ac9e --- /dev/null +++ b/plugins/cpPluginsIO/MeshReader.h @@ -0,0 +1,47 @@ +#ifndef __CPPLUGINSIO__MESHREADER__H__ +#define __CPPLUGINSIO__MESHREADER__H__ + +#include +#include + +namespace cpPluginsIO +{ + /** + */ + class cpPluginsIO_EXPORT MeshReader + : public cpPlugins::ProcessObject + { + public: + typedef MeshReader Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( MeshReader, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( MeshReader, IO ); + + protected: + MeshReader( ); + virtual ~MeshReader( ); + + virtual std::string _GenerateData( ) ITK_OVERRIDE; + + template< unsigned int _Dim > + inline std::string _GD0( ); + + template< class _TScalar, unsigned int _Dim > + inline std::string _GD1( ); + + private: + // Purposely not implemented + MeshReader( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIO__MESHREADER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/MeshWriter.cxx b/plugins/cpPluginsIO/MeshWriter.cxx new file mode 100644 index 0000000..ad5501a --- /dev/null +++ b/plugins/cpPluginsIO/MeshWriter.cxx @@ -0,0 +1,72 @@ +#include +#include + +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsIO::MeshWriter:: +MeshWriter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->m_Parameters.Clear( ); + this->m_Parameters.ConfigureAsSaveFileName( "FileName" ); + this->m_Parameters.SetAcceptedFileExtensions( + "FileName", + "Mesh files (*.stl *.vtk)" + ); +} + +// ------------------------------------------------------------------------- +cpPluginsIO::MeshWriter:: +~MeshWriter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsIO::MeshWriter:: +_GenerateData( ) +{ + auto mesh = this->GetInputData( "Input" )->GetVTK< vtkPolyData >( ); + if( mesh == NULL ) + return( "MeshWriter: No suitable input." ); + + // Get file extension + auto fname = this->m_Parameters.GetSaveFileName( "FileName" ); + std::istringstream fname_str( fname ); + std::string token, ext; + while( std::getline( fname_str, token, '.' ) ) + ext = token; + std::transform( ext.begin( ), ext.end( ), ext.begin( ), tolower ); + + // Real read + if( ext == "stl" ) + { + vtkSTLWriter* stlw = this->_CreateVTK< vtkSTLWriter >( ); + stlw->SetInputData( mesh ); + stlw->SetFileName( fname.c_str( ) ); + stlw->Update( ); + if( stlw->GetErrorCode( ) != 0 ) + return( "MeshWriter: someting wrong happened." ); + else + return( "" ); + } + else if( ext == "vtk" ) + { + vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( ); + pdw->SetInputData( mesh ); + pdw->SetFileName( fname.c_str( ) ); + pdw->Update( ); + if( pdw->GetErrorCode( ) != 0 ) + return( "MeshWriter: someting wrong happened." ); + else + return( "" ); + } + else + return( "MeshWriter: Input file format not recognized." ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/MeshWriter.h b/plugins/cpPluginsIO/MeshWriter.h new file mode 100644 index 0000000..f4c85bc --- /dev/null +++ b/plugins/cpPluginsIO/MeshWriter.h @@ -0,0 +1,41 @@ +#ifndef __CPPLUGINSIO__MESHWRITER__H__ +#define __CPPLUGINSIO__MESHWRITER__H__ + +#include +#include + +namespace cpPluginsIO +{ + /** + */ + class cpPluginsIO_EXPORT MeshWriter + : public cpPlugins::ProcessObject + { + public: + typedef MeshWriter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( MeshWriter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( MeshWriter, IO ); + + protected: + MeshWriter( ); + virtual ~MeshWriter( ); + + virtual std::string _GenerateData( ) ITK_OVERRIDE; + + private: + // Purposely not implemented + MeshWriter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIO__MESHWRITER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/CMakeLists.txt b/plugins/cpPluginsImageMeshFilters/CMakeLists.txt new file mode 100644 index 0000000..bda2804 --- /dev/null +++ b/plugins/cpPluginsImageMeshFilters/CMakeLists.txt @@ -0,0 +1,74 @@ +SET(lib_NAME cpPluginsImageMeshFilters) +SET(lib_DIR cpPluginsImageMeshFilters) + +## =============== +## = Source code = +## =============== + +FILE(GLOB lib_HEADERS_H "*.h") +FILE(GLOB lib_HEADERS_HPP "*.hpp") +FILE(GLOB lib_HEADERS_HXX "*.hxx") +FILE(GLOB lib_SOURCES_C "*.c") +FILE(GLOB lib_SOURCES_CPP "*.cpp") +FILE(GLOB lib_SOURCES_CXX "*.cxx") + +# =================================== +# = Integrate all source file names = +# =================================== + +SET( + lib_HEADERS + ${lib_HEADERS_H} + ${lib_HEADERS_HPP} + ${lib_HEADERS_HXX} + ) + +SET( + lib_SOURCES + ${lib_SOURCES_C} + ${lib_SOURCES_CPP} + ${lib_SOURCES_CXX} + ) + +SET( + target_LIBRARIES + cpExtensions + cpPlugins + ) + +## ===================== +## = Compilation rules = +## ===================== + +ADD_CUSTOM_COMMAND( + OUTPUT ${lib_NAME}_Host.cxx + DEPENDS cpPlugins_HostCreator ${LIB_HEADERS_H} + COMMAND cpPlugins_HostCreator ${lib_NAME}_Host.cxx ${lib_HEADERS_H} + ) +ADD_LIBRARY(${lib_NAME} SHARED ${lib_NAME}_Host.cxx ${lib_SOURCES}) +SET_TARGET_PROPERTIES( + ${lib_NAME} PROPERTIES + VERSION "${prj_VER}" + SOVERSION "${prj_sVER}" + ) +GENERATE_EXPORT_HEADER( + ${lib_NAME} + BASE_NAME ${lib_NAME} + EXPORT_MACRO_NAME ${lib_NAME}_EXPORT + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h + STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC + ) +TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) + +## ======================== +## -- Installation rules -- +## ======================== + +INSTALL( + TARGETS ${lib_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static + ) + +## eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/MarchingCubes.cxx b/plugins/cpPluginsImageMeshFilters/MarchingCubes.cxx new file mode 100644 index 0000000..ff3c6fc --- /dev/null +++ b/plugins/cpPluginsImageMeshFilters/MarchingCubes.cxx @@ -0,0 +1,65 @@ +#include +#include +#include + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageMeshFilters::MarchingCubes:: +MarchingCubes( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Mesh >( "Output" ); + this->m_Parameters.ConfigureAsRealList( "Thresholds" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageMeshFilters::MarchingCubes:: +~MarchingCubes( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageMeshFilters::MarchingCubes:: +_GenerateData( ) +{ + // Get input + auto image = this->GetInputData( "Input" ); + vtkImageData* vtk_image = image->GetVTK< vtkImageData >( ); + if( vtk_image == NULL ) + return( "MarchingCubes: Input does not have a valid VTK conversion." ); + + std::vector< double > values = + this->m_Parameters.GetRealList( "Thresholds" ); + vtkPolyData* pd = NULL; + if( vtk_image->GetDataDimension( ) == 2 ) + { + vtkMarchingSquares* ms = this->_CreateVTK< vtkMarchingSquares >( ); + ms->SetInputData( vtk_image ); + for( unsigned int i = 0; i < values.size( ); ++i ) + ms->SetValue( i, values[ i ] ); + ms->Update( ); + pd = ms->GetOutput( ); + } + else if( vtk_image->GetDataDimension( ) == 3 ) + { + vtkMarchingCubes* mc = this->_CreateVTK< vtkMarchingCubes >( ); + mc->ComputeNormalsOff( ); + mc->SetInputData( vtk_image ); + for( unsigned int i = 0; i < values.size( ); ++i ) + mc->SetValue( i, values[ i ] ); + mc->Update( ); + pd = mc->GetOutput( ); + } + else + return( "MarchingCubes: Input data does not have a valid dimension." ); + + // Connect output + this->GetOutputData( "Output" )->SetVTK( pd ); + return( "" ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/MarchingCubes.h b/plugins/cpPluginsImageMeshFilters/MarchingCubes.h new file mode 100644 index 0000000..0a1b9ec --- /dev/null +++ b/plugins/cpPluginsImageMeshFilters/MarchingCubes.h @@ -0,0 +1,41 @@ +#ifndef __CPPLUGINSIMAGEMESH__MARCHINGCUBES__H__ +#define __CPPLUGINSIMAGEMESH__MARCHINGCUBES__H__ + +#include +#include + +namespace cpPluginsImageMeshFilters +{ + /** + */ + class cpPluginsImageMeshFilters_EXPORT MarchingCubes + : public cpPlugins::ProcessObject + { + public: + typedef MarchingCubes Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( MarchingCubes, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( MarchingCubes, ImageToMeshFilters ); + + protected: + MarchingCubes( ); + virtual ~MarchingCubes( ); + + virtual std::string _GenerateData( ) override; + + private: + // Purposely not implemented + MarchingCubes( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEMESH__MARCHINGCUBES__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx new file mode 100644 index 0000000..7e223a9 --- /dev/null +++ b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx @@ -0,0 +1,123 @@ +#include +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +TriangleMeshToBinaryImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + + this->m_Parameters.ConfigureAsUint( "InsideValue" ); + this->m_Parameters.ConfigureAsUint( "OutsideValue" ); + this->m_Parameters.ConfigureAsUint( "MinimumSize" ); + + this->m_Parameters.SetUint( "InsideValue", 1 ); + this->m_Parameters.SetUint( "OutsideValue", 0 ); + this->m_Parameters.SetUint( "MinimumSize", 100 ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +~TriangleMeshToBinaryImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +_GenerateData( ) +{ + typedef itk::Mesh< float, 3 > _3F; + typedef itk::Mesh< double, 3 > _3D; + + auto _3f = this->GetInputData( "Input" )->GetITK< _3F >( ); + auto _3d = this->GetInputData( "Input" )->GetITK< _3D >( ); + if ( _3f != NULL ) return( this->_GD0( _3f ) ); + else if( _3d != NULL ) return( this->_GD0( _3d ) ); + else + return( "TriangleMeshToBinaryImageFilter: No valid input itk mesh." ); +} + +// ------------------------------------------------------------------------- +template< class _TMesh > +std::string cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +_GD0( _TMesh* mesh ) +{ + return( this->_GD1< _TMesh, unsigned char >( mesh ) ); +} + +// ------------------------------------------------------------------------- +template< class _TMesh, class _TPixel > +std::string cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +_GD1( _TMesh* mesh ) +{ + typedef itk::Image< _TPixel, _TMesh::PointDimension > _TImage; + typedef itk::TriangleMeshToBinaryImageFilter< _TMesh, _TImage > _TFilter; + + static const unsigned int PAD = 10; + + _TFilter* filter = this->_CreateITK< _TFilter >( ); + + auto bb = mesh->GetBoundingBox( ); + auto minBB = bb->GetMinimum( ); + auto maxBB = bb->GetMaximum( ); + + double lx = double( maxBB[ 0 ] - minBB[ 0 ] ); + double ly = double( maxBB[ 1 ] - minBB[ 1 ] ); + double lz = double( maxBB[ 2 ] - minBB[ 2 ] ); + double lm = ( lx < ly )? lx: ly; + lm = ( lm < lz )? lm: lz; + + // Compute spacing + double mSpac = lm / double( this->m_Parameters.GetUint( "MinimumSize" ) ); + typename _TImage::SpacingType spac; + spac.Fill( mSpac ); + filter->SetSpacing( spac ); + + // Compute size + typename _TImage::SizeType size; + size[ 0 ] = ( unsigned long )( std::ceil( lx / mSpac ) ); + size[ 1 ] = ( unsigned long )( std::ceil( ly / mSpac ) ); + size[ 2 ] = ( unsigned long )( std::ceil( lz / mSpac ) ); + + // ... add some padding pixels + size[ 0 ] += PAD; + size[ 1 ] += PAD; + size[ 2 ] += PAD; + filter->SetSize( size ); + + // Set origin + typename _TImage::PointType origin = minBB; + origin[ 0 ] -= double( PAD >> 1 ) * spac[ 0 ]; + origin[ 1 ] -= double( PAD >> 1 ) * spac[ 1 ]; + origin[ 2 ] -= double( PAD >> 1 ) * spac[ 2 ]; + filter->SetOrigin( origin ); + + // Remaining values + typename _TImage::DirectionType direction; + direction.SetIdentity( ); + filter->SetDirection( direction ); + + typename _TImage::IndexType index; + index.Fill( 0 ); + filter->SetIndex( index ); + + // Execute + filter->SetInput( mesh ); + filter->SetInsideValue( this->m_Parameters.GetUint( "InsideValue" ) ); + filter->SetOutsideValue( this->m_Parameters.GetUint( "OutsideValue" ) ); + filter->Update( ); + + // Connect output + auto out = this->GetOutputData( "Output" ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); + +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h new file mode 100644 index 0000000..7965e2b --- /dev/null +++ b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h @@ -0,0 +1,47 @@ +#ifndef __CPPLUGINSIMAGEMESH__TRIANGLEMESHTOBINARYIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEMESH__TRIANGLEMESHTOBINARYIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageMeshFilters +{ + /** + */ + class cpPluginsImageMeshFilters_EXPORT TriangleMeshToBinaryImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef TriangleMeshToBinaryImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( TriangleMeshToBinaryImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( TriangleMeshToBinaryImageFilter, MeshToImageFilters ); + + protected: + TriangleMeshToBinaryImageFilter( ); + virtual ~TriangleMeshToBinaryImageFilter( ); + + virtual std::string _GenerateData( ) override; + + template< class _TMesh > + inline std::string _GD0( _TMesh* mesh ); + + template< class _TMesh, class _TPixel > + inline std::string _GD1( _TMesh* mesh ); + + private: + // Purposely not implemented + TriangleMeshToBinaryImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEMESH__TRIANGLEMESHTOBINARYIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx new file mode 100644 index 0000000..1387804 --- /dev/null +++ b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx @@ -0,0 +1,50 @@ +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsMeshFilters::AppendMeshesFilter:: +AppendMeshesFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input0" ); + this->_AddInput( "Input1" ); + this->_AddInput( "Input2", false ); + this->_AddInput( "Input3", false ); + this->_AddInput( "Input4", false ); + this->_AddInput( "Input5", false ); + this->_AddOutput< cpPlugins::Mesh >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsMeshFilters::AppendMeshesFilter:: +~AppendMeshesFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsMeshFilters::AppendMeshesFilter:: +_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 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 ); + filter->Update( ); + + this->GetOutputData( "Output" )->SetVTK( filter->GetOutput( ) ); + return( "" ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.h b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.h new file mode 100644 index 0000000..f92ab09 --- /dev/null +++ b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.h @@ -0,0 +1,41 @@ +#ifndef __CPPLUGINSIMAGEMESH__APPENDMESHESFILTER__H__ +#define __CPPLUGINSIMAGEMESH__APPENDMESHESFILTER__H__ + +#include +#include + +namespace cpPluginsMeshFilters +{ + /** + */ + class cpPluginsMeshFilters_EXPORT AppendMeshesFilter + : public cpPlugins::ProcessObject + { + public: + typedef AppendMeshesFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( AppendMeshesFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( AppendMeshesFilter, MeshFilters ); + + protected: + AppendMeshesFilter( ); + virtual ~AppendMeshesFilter( ); + + virtual std::string _GenerateData( ) override; + + private: + // Purposely not implemented + AppendMeshesFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEMESH__APPENDMESHESFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshFilters/CMakeLists.txt b/plugins/cpPluginsMeshFilters/CMakeLists.txt new file mode 100644 index 0000000..25b63c6 --- /dev/null +++ b/plugins/cpPluginsMeshFilters/CMakeLists.txt @@ -0,0 +1,74 @@ +SET(lib_NAME cpPluginsMeshFilters) +SET(lib_DIR cpPluginsMeshFilters) + +## =============== +## = Source code = +## =============== + +FILE(GLOB lib_HEADERS_H "*.h") +FILE(GLOB lib_HEADERS_HPP "*.hpp") +FILE(GLOB lib_HEADERS_HXX "*.hxx") +FILE(GLOB lib_SOURCES_C "*.c") +FILE(GLOB lib_SOURCES_CPP "*.cpp") +FILE(GLOB lib_SOURCES_CXX "*.cxx") + +# =================================== +# = Integrate all source file names = +# =================================== + +SET( + lib_HEADERS + ${lib_HEADERS_H} + ${lib_HEADERS_HPP} + ${lib_HEADERS_HXX} + ) + +SET( + lib_SOURCES + ${lib_SOURCES_C} + ${lib_SOURCES_CPP} + ${lib_SOURCES_CXX} + ) + +SET( + target_LIBRARIES + cpExtensions + cpPlugins + ) + +## ===================== +## = Compilation rules = +## ===================== + +ADD_CUSTOM_COMMAND( + OUTPUT ${lib_NAME}_Host.cxx + DEPENDS cpPlugins_HostCreator ${LIB_HEADERS_H} + COMMAND cpPlugins_HostCreator ${lib_NAME}_Host.cxx ${lib_HEADERS_H} + ) +ADD_LIBRARY(${lib_NAME} SHARED ${lib_NAME}_Host.cxx ${lib_SOURCES}) +SET_TARGET_PROPERTIES( + ${lib_NAME} PROPERTIES + VERSION "${prj_VER}" + SOVERSION "${prj_sVER}" + ) +GENERATE_EXPORT_HEADER( + ${lib_NAME} + BASE_NAME ${lib_NAME} + EXPORT_MACRO_NAME ${lib_NAME}_EXPORT + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h + STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC + ) +TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) + +## ======================== +## -- Installation rules -- +## ======================== + +INSTALL( + TARGETS ${lib_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static + ) + +## eof - $RCSfile$