]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 11 Nov 2016 15:53:14 +0000 (10:53 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 11 Nov 2016 15:53:14 +0000 (10:53 -0500)
lib/cpPlugins/DataObjects/BoundingBox.cxx [new file with mode: 0644]
lib/cpPlugins/DataObjects/BoundingBox.h [new file with mode: 0644]
plugins/CMakeLists.txt
plugins/Extensions/Simple3DCurve.cxx [new file with mode: 0644]
plugins/Extensions/Simple3DCurve.d [new file with mode: 0644]
plugins/Extensions/Simple3DCurve.h [new file with mode: 0644]
plugins/GenericFilters/PolyLineParametricPathToSimple3DCurve.cxx
plugins/ImageSliceFilters/CPRImageFilter.cxx

diff --git a/lib/cpPlugins/DataObjects/BoundingBox.cxx b/lib/cpPlugins/DataObjects/BoundingBox.cxx
new file mode 100644 (file)
index 0000000..4a81b0b
--- /dev/null
@@ -0,0 +1,93 @@
+#include <cpPlugins/DataObjects/BoundingBox.h>
+#include <limits>
+#include <vtkDataSet.h>
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjects::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 );
+  this->_UpdateVTK( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjects::BoundingBox::
+Copy( Self* other )
+{
+  this->m_Points[ 0 ] = other->m_Points[ 0 ];
+  this->m_Points[ 1 ] = other->m_Points[ 1 ];
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjects::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( );
+  this->_UpdateVTK( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObjects::BoundingBox::
+BoundingBox( )
+  : Superclass( )
+{
+  this->m_Points[ 0 ].push_back( double( 0 ) );
+  this->m_Points[ 1 ].push_back( double( 0 ) );
+  this->m_Outline = vtkSmartPointer< vtkOutlineSource >::New( );
+  this->_UpdateVTK( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObjects::BoundingBox::
+~BoundingBox( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjects::BoundingBox::
+_UpdateVTK( )
+{
+  auto dobj = this->GetVTK< vtkDataSet >( );
+  if( dobj == NULL )
+    return;
+
+  // Get bounds
+  double bounds[ 6 ];
+  dobj->GetBounds( bounds );
+
+  this->m_Points[ 0 ].clear( );
+  this->m_Points[ 1 ].clear( );
+  this->m_Points[ 0 ].push_back( bounds[ 0 ] );
+  this->m_Points[ 0 ].push_back( bounds[ 2 ] );
+  this->m_Points[ 0 ].push_back( bounds[ 4 ] );
+  this->m_Points[ 1 ].push_back( bounds[ 1 ] );
+  this->m_Points[ 1 ].push_back( bounds[ 3 ] );
+  this->m_Points[ 1 ].push_back( bounds[ 5 ] );
+
+  // Update vtk objects
+  this->m_Outline->SetBounds( bounds );
+  this->m_Outline->Update( );
+  this->m_VTK = this->m_Outline->GetOutput( );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/DataObjects/BoundingBox.h b/lib/cpPlugins/DataObjects/BoundingBox.h
new file mode 100644 (file)
index 0000000..9ee33cc
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef __cpPlugins__DataObjects__BoundingBox__h__
+#define __cpPlugins__DataObjects__BoundingBox__h__
+
+#include <vector>
+#include <cpPlugins/BaseObjects/DataObject.h>
+#include <vtkOutlineSource.h>
+#include <vtkSmartPointer.h>
+
+namespace cpPlugins
+{
+  namespace DataObjects
+  {
+    /**
+     */
+    class cpPlugins_EXPORT BoundingBox
+      : public cpPlugins::BaseObjects::DataObject
+    {
+    public:
+      typedef BoundingBox                        Self;
+      typedef cpPlugins::BaseObjects::DataObject Superclass;
+      typedef itk::SmartPointer< Self >          Pointer;
+      typedef itk::SmartPointer< const Self >    ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( BoundingBox, DataObject );
+      cpPlugins_Id_Macro( BoundingBox, Object );
+      cpPlugins_Compatibility_Macro;
+
+    public:
+      void SetDataObject( DataObject* o );
+
+      void Copy( Self* other );
+      void Blend( Self* other );
+
+      template< class _TPoint >
+      inline void SetMinimum( const _TPoint& p )
+        {
+          this->_SetPoint( 0, p );
+        }
+
+      template< class _TPoint >
+      inline void SetMaximum( const _TPoint& p )
+        {
+          this->_SetPoint( 1, p );
+        }
+
+      template< class _TPoint >
+      inline _TPoint GetMinimum( ) const
+        {
+          return( this->_GetPoint< _TPoint >( 0 ) );
+        }
+
+      template< class _TPoint >
+      inline _TPoint GetMaximum( ) const
+        {
+          return( this->_GetPoint< _TPoint >( 1 ) );
+        }
+
+    protected:
+      BoundingBox( );
+      virtual ~BoundingBox( );
+
+      void _UpdateVTK( );
+
+      template< class _TPoint >
+      inline void _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->_UpdateVTK( );
+          this->Modified( );
+        }
+
+      template< class _TPoint >
+      inline _TPoint _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 );
+        }
+
+    private:
+      // Purposely not implemented
+      BoundingBox( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      std::vector< double > m_Points[ 2 ];
+      vtkSmartPointer< vtkOutlineSource > m_Outline;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+// #include <cpPlugins/DataObjects/BoundingBox.hxx>
+
+#endif // __cpPlugins__DataObjects__BoundingBox__h__
+
+// eof - $RCSfile$
index c83c434f68df18cc517cec0be5a516419e75ccc0..99f07e0d645c71d04dbaeb12ffa234532ded8fd2 100644 (file)
@@ -5,20 +5,20 @@
 SET(
   _dirlist
   Extensions
-  #  AnisotropicDiffusion
-  #  GenericFilters
-  #  ImageArithmeticFilters
-  #  ImageBooleanFilters
-  #  ImageDistanceMaps
-  #  ImageGenericFilters
-  #  ImageGradientFilters
-  #  ImageMeshFilters
-  #  ImageSliceFilters
-  #  ImageSources
-  #  ImageThresholdFilters
+  AnisotropicDiffusion
+  GenericFilters
+  ImageArithmeticFilters
+  ImageBooleanFilters
+  ImageDistanceMaps
+  ImageGenericFilters
+  ImageGradientFilters
+  ImageMeshFilters
+  ImageSliceFilters
+  ImageSources
+  ImageThresholdFilters
   IO
-  #  MeshFilters
-  #  MeshSources
+  MeshFilters
+  MeshSources
   Widgets
   )
 
diff --git a/plugins/Extensions/Simple3DCurve.cxx b/plugins/Extensions/Simple3DCurve.cxx
new file mode 100644 (file)
index 0000000..25aa5a1
--- /dev/null
@@ -0,0 +1,63 @@
+#include <Extensions/Simple3DCurve.h>
+#include <cpExtensions/DataStructures/Simple3DCurve.h>
+#include <cpExtensions/Visualization/Simple3DCurveToPolyData.h>
+
+// -------------------------------------------------------------------------
+void cpPluginsExtensions::Simple3DCurve::
+SetITK( itk::LightObject* o )
+{
+  cpPlugins_Demangle_Simple3DCurve_All_1( o, _ITK_2_VTK )
+  {
+    this->m_VTK = NULL;
+    this->m_ITKvVTK = NULL;
+  }
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsExtensions::Simple3DCurve::
+SetVTK( vtkObjectBase* o )
+{
+  // Do nothing
+  this->m_ITK = NULL;
+  this->m_VTK = NULL;
+  this->m_ITKvVTK = NULL;
+}
+
+// -------------------------------------------------------------------------
+cpPluginsExtensions::Simple3DCurve::
+Simple3DCurve( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPluginsExtensions::Simple3DCurve::
+~Simple3DCurve( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSimple3DCurve >
+void cpPluginsExtensions::Simple3DCurve::
+_ITK_2_VTK( _TSimple3DCurve* curve )
+{
+  typedef
+    cpExtensions::Visualization::Simple3DCurveToPolyData< _TSimple3DCurve >
+    _TFilter;
+  _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
+  if( f == NULL )
+  {
+    _TFilter* nf = _TFilter::New( );
+    this->m_ITKvVTK = nf;
+    f = nf;
+
+  } // fi
+  f->SetInput( curve );
+  f->Update( );
+
+  // Keep object track
+  this->m_ITK = curve;
+  this->m_VTK = f->GetOutput( );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/Extensions/Simple3DCurve.d b/plugins/Extensions/Simple3DCurve.d
new file mode 100644 (file)
index 0000000..998b791
--- /dev/null
@@ -0,0 +1,4 @@
+
+All cpExtensions::DataStructures::Simple3DCurve< #real_types# >
+
+** eof - $RCSfile$
diff --git a/plugins/Extensions/Simple3DCurve.h b/plugins/Extensions/Simple3DCurve.h
new file mode 100644 (file)
index 0000000..cb68176
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __cpPluginsExtensions__Simple3DCurve__h__
+#define __cpPluginsExtensions__Simple3DCurve__h__
+
+#include <cpPluginsExtensions_Export.h>
+#include <cpPlugins/BaseObjects/DataObject.h>
+#include <vtkSmartPointer.h>
+#include <Extensions/Simple3DCurve_Demanglers.h>
+
+// -------------------------------------------------------------------------
+class vtkPolyDataAlgorithm;
+
+// -------------------------------------------------------------------------
+namespace cpPluginsExtensions
+{
+  /**
+   */
+  class cpPluginsExtensions_EXPORT Simple3DCurve
+    : public cpPlugins::BaseObjects::DataObject
+  {
+  public:
+    typedef Simple3DCurve                      Self;
+    typedef cpPlugins::BaseObjects::DataObject Superclass;
+    typedef itk::SmartPointer< Self >          Pointer;
+    typedef itk::SmartPointer< const Self >    ConstPointer;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro(
+      Simple3DCurve, cpPlugins::BaseObjects::DataObject
+      );
+    cpPlugins_Id_Macro( Simple3DCurve, Object );
+    cpPlugins_Compatibility_Macro;
+
+  public:
+    virtual void SetITK( itk::LightObject* o ) cpPlugins_OVERRIDE;
+    virtual void SetVTK( vtkObjectBase* o ) cpPlugins_OVERRIDE;
+
+  protected:
+    Simple3DCurve( );
+    virtual ~Simple3DCurve( );
+
+    template< class _TSimple3DCurve >
+    inline void _ITK_2_VTK( _TSimple3DCurve* curve );
+
+  private:
+    // Purposely not implemented
+    Simple3DCurve( const Self& );
+    Self& operator=( const Self& );
+
+  protected:
+    vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK;
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsExtensions__Simple3DCurve__h__
+
+// eof - $RCSfile$
index 527117444edc332cfd6632d4dbc9a5f7e685c14b..af6facf9438bcecfadeb13a8e22ec9d6a8b9d42c 100644 (file)
@@ -1,6 +1,6 @@
 #include <GenericFilters/PolyLineParametricPathToSimple3DCurve.h>
-#include <cpPlugins/DataObjects/PolyLineParametricPath.h>
-#include <cpPlugins/DataObjects/Simple3DCurve.h>
+#include <Extensions/PolyLineParametricPath.h>
+#include <Extensions/Simple3DCurve.h>
 
 #include <cpExtensions/DataStructures/PolyLineParametricPath.h>
 #include <cpExtensions/DataStructures/Simple3DCurve.h>
@@ -11,8 +11,8 @@ cpPluginsGenericFilters::PolyLineParametricPathToSimple3DCurve::
 PolyLineParametricPathToSimple3DCurve( )
   : Superclass( )
 {
-  typedef cpPlugins::DataObjects::PolyLineParametricPath _TPath;
-  typedef cpPlugins::DataObjects::Simple3DCurve _TCurve;
+  typedef cpPluginsExtensions::PolyLineParametricPath _TPath;
+  typedef cpPluginsExtensions::Simple3DCurve          _TCurve;
   this->_ConfigureInput< _TPath >( "Input", true, false );
   this->_ConfigureOutput< _TCurve >( "Output" );
 
index 4e80ed2230f3cc93a86e8e30a42a41bb529ef15c..77c7f81d9ff28cca4c8fa2cd411ed27f5e638d70 100644 (file)
@@ -1,9 +1,6 @@
 #include <ImageSliceFilters/CPRImageFilter.h>
 #include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/Simple3DCurve.h>
-
-#include <cpPlugins/DataObjects/Image_Demanglers.h>
-#include <cpPlugins/DataObjects/Simple3DCurve_Demanglers.h>
+#include <Extensions/Simple3DCurve.h>
 
 #include <itkImage.h>
 #include <cpExtensions/DataStructures/Simple3DCurve.h>
@@ -14,8 +11,8 @@ cpPluginsImageSliceFilters::CPRImageFilter::
 CPRImageFilter( )
   : Superclass( )
 {
-  typedef cpPlugins::DataObjects::Image _TImage;
-  typedef cpPlugins::DataObjects::Simple3DCurve _TCurve;
+  typedef cpPlugins::DataObjects::Image      _TImage;
+  typedef cpPluginsExtensions::Simple3DCurve _TCurve;
   this->_ConfigureInput< _TImage >( "Image", true, false );
   this->_ConfigureInput< _TCurve >( "Curve", true, false );
   this->_ConfigureOutput< _TImage >( "Output" );