]> Creatis software - cpPlugins.git/commitdiff
..
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 13 Apr 2016 00:07:29 +0000 (19:07 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 13 Apr 2016 00:07:29 +0000 (19:07 -0500)
20 files changed:
cmake/cpPlugins_Functions.cmake
lib/cpPlugins/BoundingBox.cxx [new file with mode: 0644]
lib/cpPlugins/BoundingBox.h [new file with mode: 0644]
lib/cpPlugins/BoundingBox.hxx [new file with mode: 0644]
lib/cpPlugins/Image.hxx
lib/cpPlugins/Mesh.cxx
lib/cpPlugins_Instances/BaseObjects.i
lib/cpPlugins_Instances/BitwiseImageFilters.i [new file with mode: 0644]
lib/cpPlugins_Instances/CMakeLists.txt
lib/cpPlugins_Instances/Mesh.i
plugins/CMakeLists.txt
plugins/cpPluginsGenericFilters/CMakeLists.txt [new file with mode: 0644]
plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx [new file with mode: 0644]
plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h [new file with mode: 0644]
plugins/cpPluginsImageFilters/AndImageFilter.cxx [new file with mode: 0644]
plugins/cpPluginsImageFilters/AndImageFilter.h [new file with mode: 0644]
plugins/cpPluginsImageFilters/OrImageFilter.cxx [new file with mode: 0644]
plugins/cpPluginsImageFilters/OrImageFilter.h [new file with mode: 0644]
plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx
plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx

index d2ec9ca333e5c5cb1c62da9533e4aa1743e2ad8b..68c2b882f437be89d3ef09a7259132b9852ab7f0 100644 (file)
@@ -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 (file)
index 0000000..14f48f4
--- /dev/null
@@ -0,0 +1,97 @@
+#include <cpPlugins/BoundingBox.h>
+#include <limits>
+#include <vtkDataSet.h>
+
+// -------------------------------------------------------------------------
+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 (file)
index 0000000..b29cf2d
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef __CPPLUGINS__BOUNDINGBOX__H__
+#define __CPPLUGINS__BOUNDINGBOX__H__
+
+#include <vector>
+#include <cpPlugins/DataObject.h>
+
+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 <cpPlugins/BoundingBox.hxx>
+
+#endif // __CPPLUGINS__BOUNDINGBOX__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/BoundingBox.hxx b/lib/cpPlugins/BoundingBox.hxx
new file mode 100644 (file)
index 0000000..be95c3a
--- /dev/null
@@ -0,0 +1,131 @@
+#ifndef __CPPLUGINS__BOUNDINGBOX__HXX__
+#define __CPPLUGINS__BOUNDINGBOX__HXX__
+
+#include <cpPlugins/Image.h>
+#include <cpPlugins/Mesh.h>
+#include <itkBoundingBox.h>
+#include <itkPointSet.h>
+
+// -------------------------------------------------------------------------
+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$
index 1378dc8cba97880314e5f3854cbf6157c1be4631..4a02cf93f050e715c05162bee192656df6898eee 100644 (file)
@@ -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 ); \
index 76ba6dd22fc356253c9f2e20e351172fcacf0c2c..216f3b3ac9cf61b4300789d920d2cb3c21d6dfa0 100644 (file)
@@ -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
index b2df0db95bcbc6df48dfbee0cf6628044e825daa..eb122beace6df82943546dd622e449e9995cb238 100644 (file)
@@ -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 (file)
index 0000000..73d17e2
--- /dev/null
@@ -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$
index cfba0f783df3ca135d3a9babd56d8484be733a81..79eef7e0a102aa6c037d052f74339d9e03efc10d 100644 (file)
@@ -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
index ea67b8f348ee1003b8681f566e1740be09853cd2..be7ad5360922ca37086a7e98f601aca0545acde4 100644 (file)
@@ -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 > >
 
index a62392d765b27ce86fe583735ae5e05d6f9d3207..a9950954bbd7ffa36be6d2d10275cfbcd99626c2 100644 (file)
@@ -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 (file)
index 0000000..1d759cc
--- /dev/null
@@ -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 (file)
index 0000000..911040d
--- /dev/null
@@ -0,0 +1,56 @@
+#include <cpPluginsGenericFilters/JoinBoundingBoxes.h>
+#include <cpPlugins/DataObject.h>
+#include <cpPlugins/BoundingBox.h>
+
+// -------------------------------------------------------------------------
+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 (file)
index 0000000..3df5da7
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__
+#define __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__
+
+#include <cpPluginsGenericFilters/cpPluginsGenericFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+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 (file)
index 0000000..e805798
--- /dev/null
@@ -0,0 +1,65 @@
+#include <cpPluginsImageFilters/AndImageFilter.h>
+#include <cpPlugins/Image.h>
+#include <cpPlugins_Instances/BitwiseImageFilters.h>
+
+// -------------------------------------------------------------------------
+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 (file)
index 0000000..7eefcc6
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __CPPLUGINSIMAGEFILTERS__ANDIMAGEFILTER__H__
+#define __CPPLUGINSIMAGEFILTERS__ANDIMAGEFILTER__H__
+
+#include <plugins/cpPluginsImageFilters/cpPluginsImageFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+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 (file)
index 0000000..0d37b7b
--- /dev/null
@@ -0,0 +1,65 @@
+#include <cpPluginsImageFilters/OrImageFilter.h>
+#include <cpPlugins/Image.h>
+#include <cpPlugins_Instances/BitwiseImageFilters.h>
+
+// -------------------------------------------------------------------------
+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 (file)
index 0000000..4ea5f4c
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __CPPLUGINSIMAGEFILTERS__ORIMAGEFILTER__H__
+#define __CPPLUGINSIMAGEFILTERS__ORIMAGEFILTER__H__
+
+#include <plugins/cpPluginsImageFilters/cpPluginsImageFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+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$
index 11bb178f137ff6fd93985d5adebb4a6bff0734a9..6e35acc2233023ba5a8cc7e1981fe7132c07ec0c 100644 (file)
@@ -1,4 +1,5 @@
 #include <cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h>
+#include <cpPlugins/BoundingBox.h>
 #include <cpPlugins/Image.h>
 #include <cpPlugins/Mesh.h>
 
@@ -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 ] );
index 138780452deb3c30b2c55ae742b5077c00d63214..4029c9c9d249895dc36f3d890e59f6066265b5be 100644 (file)
@@ -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( ) );