]> Creatis software - cpPlugins.git/commitdiff
Widget integration (step 2/6). WARNING: IT DOES NOT COMPILE YETgit shortlog !
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 2 Oct 2015 23:41:14 +0000 (18:41 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 2 Oct 2015 23:41:14 +0000 (18:41 -0500)
16 files changed:
appli/ImageMPR/ImageMPR.cxx
appli/ImageMPR/ImageMPR.h
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpExtensions/Visualization/MPRObjects.cxx
lib/cpExtensions/Visualization/MPRObjects.h
lib/cpPlugins/Interface/CMakeLists.txt
lib/cpPlugins/Interface/DataObject.cxx
lib/cpPlugins/Interface/DataObject.h
lib/cpPlugins/Interface/ImplicitFunction.cxx [new file with mode: 0644]
lib/cpPlugins/Interface/ImplicitFunction.h [new file with mode: 0644]
lib/cpPlugins/Interface/ImplicitFunction.hxx [new file with mode: 0644]
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/BasicFilters/Cutter.h [new file with mode: 0644]
lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx

index 6cc4ed1ccb1c85980acd0f4757286b16fec94a34..7fffc2732df90c2864acef0691e53db90bc2e463 100644 (file)
@@ -23,7 +23,10 @@ ImageMPR::ImageMPR( QWidget* parent )
     m_UI( new Ui::ImageMPR ),
     m_ImageReaderClass( "" ),
     m_ImageWriterClass( "" ),
-    m_InputImage( NULL )
+    m_MeshReaderClass( "" ),
+    m_MeshWriterClass( "" ),
+    m_MeshCutterClass( "" ),
+    m_Image( NULL )
 {
   this->m_UI->setupUi( this );
 
@@ -60,6 +63,11 @@ ImageMPR::ImageMPR( QWidget* parent )
     std::string( "cpPluginsIO." ) +
     std::string( PLUGIN_EXT )
     );
+  this->_LoadPlugins(
+    std::string( PLUGIN_PREFIX ) +
+    std::string( "cpPluginsBasicFilters." ) +
+    std::string( PLUGIN_EXT )
+    );
 }
 
 // -------------------------------------------------------------------------
@@ -84,6 +92,7 @@ _LoadPlugins( const std::string& filename )
   this->m_ImageWriterClass = "";
   this->m_MeshReaderClass = "";
   this->m_MeshWriterClass = "";
+  this->m_MeshCutterClass = "";
   this->m_UI->MenuImageToImage->clear( );
   this->m_UI->MenuImageToMesh->clear( );
 
@@ -106,6 +115,11 @@ _LoadPlugins( const std::string& filename )
       this->m_MeshReaderClass = name;
     else if( category == "MeshWriter" )
       this->m_MeshWriterClass = name;
+    else if( category == "MeshToMeshFilter" )
+    {
+      if( name.find_last_of( "Cutter" ) != std::string::npos )
+        this->m_MeshCutterClass = name;
+    }
     else if( category == "ImageToImageFilter" )
     {
       QAction* action =
@@ -174,6 +188,51 @@ _LoadImage( TPluginImage::Pointer& image )
   return( ret );
 }
 
+// -------------------------------------------------------------------------
+std::string ImageMPR::
+_ConfigureMeshActors( )
+{
+  if( this->m_Mesh.IsNull( ) )
+    return( "Valid mesh not found." );
+  
+  vtkActor* vtk_actor = this->m_Mesh->GetVTKActor( );
+  if( vtk_actor != NULL )
+  {
+    this->m_MPRObjects->Get3DRenderer( )->AddActor( vtk_actor );
+    this->m_MPRObjects->Render( 4 );
+
+  } // fi
+
+  TMPRObjects::TMPRActors* mprActors = this->m_MPRObjects->GetMPRActors( );
+
+  std::string err = "";
+  for( unsigned int i = 0; i < 3; ++i )
+  {
+    this->m_Cutters[ i ] = this->m_Plugins.CreateProcessObject( this->m_MeshCutterClass );
+    this->m_Planes[ i ] = TPluginImplicitFunction::New( );
+    this->m_Planes[ i ]->SetFunction( mprActors->GetSliceActors( i )->GetPlaneFunction( ) );
+    this->m_Cutters[ i ]->SetInput( 0, this->m_Mesh );
+    this->m_Cutters[ i ]->SetInput( 1, this->m_Planes[ i ] );
+    std::string lerr = this->m_Cutters[ i ]->Update( );
+    if( lerr == "" )
+    {
+      vtkActor* actor = this->m_Cutters[ i ]->GetOutput< TPluginMesh >( 0 )->GetVTKActor( );
+      mprActors->GetSliceActors( i )->AddActor( this->m_Cutters[ i ]->GetVTKAlgorithm( ), actor );
+      if( i == 0 )
+        this->m_MPRObjects->GetXRenderer( )->AddActor( actor );
+      else if( i == 1 )
+        this->m_MPRObjects->GetYRenderer( )->AddActor( actor );
+      else if( i == 2 )
+        this->m_MPRObjects->GetZRenderer( )->AddActor( actor );
+
+    } // fi
+    err += lerr;
+
+  } // rof
+  this->m_MPRObjects->RenderAll( );
+  return( err );
+}
+
 // -------------------------------------------------------------------------
 void ImageMPR::
 _triggered_actionOpenPlugins( )
@@ -201,10 +260,10 @@ void ImageMPR::
 _triggered_actionOpenInputImage( )
 {
   // Read image
-  std::string err = this->_LoadImage( this->m_InputImage );
+  std::string err = this->_LoadImage( this->m_Image );
   if( err == "" )
   {
-    vtkImageData* vtk_id = this->m_InputImage->GetVTKImageData( );
+    vtkImageData* vtk_id = this->m_Image->GetVTKImageData( );
     if( vtk_id != NULL )
     {
       this->m_MPRObjects->SetImage( vtk_id );
@@ -231,7 +290,7 @@ _triggered_actionOpenInputImage( )
 void ImageMPR::
 _triggered_actionOpenSegmentation( )
 {
-  if( this->m_InputImage.IsNull( ) )
+  if( this->m_Image.IsNull( ) )
   {
     QMessageBox::critical(
       this,
@@ -243,10 +302,10 @@ _triggered_actionOpenSegmentation( )
   } // fi
 
   // Read image
-  std::string err = this->_LoadImage( this->m_InputSegmentation );
+  std::string err = this->_LoadImage( this->m_Segmentation );
   if( err == "" )
   {
-    vtkImageData* vtk_id = this->m_InputSegmentation->GetVTKImageData( );
+    vtkImageData* vtk_id = this->m_Segmentation->GetVTKImageData( );
     if( vtk_id != NULL )
     {
       this->m_MPRObjects->AddAuxiliaryImage( vtk_id );
@@ -271,7 +330,7 @@ _triggered_actionOpenSegmentation( )
 void ImageMPR::
 _triggered_actionOpenInputPolyData( )
 {
-  this->m_InputMesh = NULL;
+  this->m_Mesh = NULL;
 
   // Get a reader from plugins
   TPluginFilter::Pointer reader =
@@ -292,24 +351,15 @@ _triggered_actionOpenInputPolyData( )
       // Assign fresh mesh, if any
       if( err == "" )
       {
-        this->m_InputMesh = reader->GetOutput< TPluginMesh >( 0 );
+        this->m_Mesh = reader->GetOutput< TPluginMesh >( 0 );
         reader->DisconnectOutputs( );
-        if( this->m_InputMesh.IsNotNull( ) )
-        {
-          vtkActor* vtk_actor = this->m_InputMesh->GetVTKActor( );
-          if( vtk_actor != NULL )
-          {
-            this->m_MPRObjects->Get3DRenderer( )->AddActor( vtk_actor );
-            this->m_MPRObjects->Render( 4 );
-          }
-          else
-            QMessageBox::critical(
-              this,
-              tr( "Error message" ),
-              tr( "Read mesh does not have a valid vtkActor." )
-              );
-
-        } // fi
+        err = this->_ConfigureMeshActors( );
+        if( err != "" )
+          QMessageBox::critical(
+            this,
+            tr( "Error message" ),
+            tr( err.c_str( ) )
+            );
       }
       else
         QMessageBox::critical(
@@ -332,7 +382,7 @@ _triggered_actionOpenInputPolyData( )
 void ImageMPR::
 _triggered_actionImageToImage( )
 {
-  if( this->m_InputImage.IsNull( ) )
+  if( this->m_Image.IsNull( ) )
     return;
 
   // Get filter name
@@ -351,7 +401,7 @@ _triggered_actionImageToImage( )
   // Execute filter
   QApplication::setOverrideCursor( Qt::WaitCursor );
   this->setEnabled( false );
-  filter->SetInput( 0, this->m_InputImage );
+  filter->SetInput( 0, this->m_Image );
   std::string err = filter->Update( );
   QApplication::restoreOverrideCursor( );
   this->setEnabled( true );
@@ -361,9 +411,9 @@ _triggered_actionImageToImage( )
   {
     TPluginImage* result = filter->GetOutput< TPluginImage >( 0 );
     result->DisconnectPipeline( );
-    this->m_InputImage = result;
-    if( this->m_InputImage.IsNotNull( ) )
-      this->m_MPRObjects->SetImage( this->m_InputImage->GetVTKImageData( ) );
+    this->m_Image = result;
+    if( this->m_Image.IsNotNull( ) )
+      this->m_MPRObjects->SetImage( this->m_Image->GetVTKImageData( ) );
   }
   else
     QMessageBox::critical(
@@ -377,7 +427,7 @@ _triggered_actionImageToImage( )
 void ImageMPR::
 _triggered_actionImageToMesh( )
 {
-  if( this->m_InputImage.IsNull( ) )
+  if( this->m_Image.IsNull( ) )
     return;
 
   // Get filter name
@@ -396,7 +446,7 @@ _triggered_actionImageToMesh( )
   // Execute filter
   QApplication::setOverrideCursor( Qt::WaitCursor );
   this->setEnabled( false );
-  filter->SetInput( 0, this->m_InputImage );
+  filter->SetInput( 0, this->m_Image );
   std::string err = filter->Update( );
   QApplication::restoreOverrideCursor( );
   this->setEnabled( true );
@@ -406,10 +456,13 @@ _triggered_actionImageToMesh( )
   {
     TPluginMesh* result = filter->GetOutput< TPluginMesh >( 0 );
     result->DisconnectPipeline( );
-    this->m_InputMesh = result;
-    if( this->m_InputMesh.IsNotNull( ) )
-      this->m_MPRObjects->Get3DRenderer( )->AddActor(
-        this->m_InputMesh->GetVTKActor( )
+    this->m_Mesh = result;
+    err = this->_ConfigureMeshActors( );
+    if( err != "" )
+      QMessageBox::critical(
+        this,
+        tr( "Error message" ),
+        tr( err.c_str( ) )
         );
   }
   else
index d82f026f7b108393568c3e2709f10753e58824a5..82e2e197f313d5a2509e27668121706c89ff511d 100644 (file)
@@ -14,6 +14,7 @@
 #include <cpPlugins/Interface/Interface.h>
 #include <cpPlugins/Interface/ProcessObject.h>
 #include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/ImplicitFunction.h>
 #include <cpPlugins/Interface/Mesh.h>
 
 // -------------------------------------------------------------------------
@@ -32,13 +33,14 @@ class ImageMPR
 
 public:
   // Plugins types
-  typedef cpPlugins::Interface::Interface     TPluginsInterface;
-  typedef cpPlugins::Interface::Object        TPluginObject;
-  typedef cpPlugins::Interface::DataObject    TPluginData;
-  typedef cpPlugins::Interface::Image         TPluginImage;
-  typedef cpPlugins::Interface::Mesh          TPluginMesh;
-  typedef cpPlugins::Interface::ProcessObject TPluginFilter;
-  typedef cpPlugins::Interface::Parameters    TParameters;
+  typedef cpPlugins::Interface::Interface        TPluginsInterface;
+  typedef cpPlugins::Interface::Object           TPluginObject;
+  typedef cpPlugins::Interface::DataObject       TPluginData;
+  typedef cpPlugins::Interface::Image            TPluginImage;
+  typedef cpPlugins::Interface::ImplicitFunction TPluginImplicitFunction;
+  typedef cpPlugins::Interface::Mesh             TPluginMesh;
+  typedef cpPlugins::Interface::ProcessObject    TPluginFilter;
+  typedef cpPlugins::Interface::Parameters       TParameters;
 
   typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
 
@@ -49,6 +51,7 @@ public:
 protected:
   bool _LoadPlugins( const std::string& filename );
   std::string _LoadImage( TPluginImage::Pointer& image );
+  std::string _ConfigureMeshActors( );
 
 private slots:
   void _triggered_actionOpenPlugins( );
@@ -69,11 +72,16 @@ private:
   std::string m_ImageWriterClass;
   std::string m_MeshReaderClass;
   std::string m_MeshWriterClass;
+  std::string m_MeshCutterClass;
 
   // Real data
-  TPluginImage::Pointer m_InputImage;
-  TPluginImage::Pointer m_InputSegmentation;
-  TPluginMesh::Pointer  m_InputMesh;
+  TPluginImage::Pointer m_Image;
+  TPluginImage::Pointer m_Segmentation;
+  TPluginMesh::Pointer  m_Mesh;
+
+  // Cutters
+  TPluginFilter::Pointer m_Cutters[ 3 ];
+  TPluginImplicitFunction::Pointer m_Planes[ 3 ];
 
   // Visualization stuff
   vtkSmartPointer< TMPRObjects > m_MPRObjects;
index ef55f5463bacf96bb4475edb98d6b1679178ade3..31787e54fc66c9e7736ea37180e4adf19a2fa573 100644 (file)
@@ -50,12 +50,14 @@ Clear( )
   // Delete all images
   this->SliceMappers.clear( );
   this->ImageActors.clear( );
+  this->OtherActors.clear( );
 
   // Reconfigure unique objects
-  this->PlaneSource = vtkSmartPointer< vtkPolyData >::New( );
-  this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
-  this->TextActor   = vtkSmartPointer< vtkTextActor >::New( );
-  this->PlaneActor  = vtkSmartPointer< vtkActor >::New( );
+  this->PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
+  this->PlaneSource   = vtkSmartPointer< vtkPolyData >::New( );
+  this->PlaneMapper   = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->TextActor     = vtkSmartPointer< vtkTextActor >::New( );
+  this->PlaneActor    = vtkSmartPointer< vtkActor >::New( );
   this->TextBuffer[ 0 ] = '\0';
 
   // Unique objects configuration
@@ -150,6 +152,28 @@ GetPlaneActor( ) const
   return( this->PlaneActor );
 }
 
+// -------------------------------------------------------------------------
+vtkPlane* cpExtensions::Visualization::ImageSliceActors::
+GetPlaneFunction( )
+{
+  return( this->PlaneFunction );
+}
+
+// -------------------------------------------------------------------------
+const vtkPlane* cpExtensions::Visualization::ImageSliceActors::
+GetPlaneFunction( ) const
+{
+  return( this->PlaneFunction );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+AddActor( vtkAlgorithm* algorithm, vtkActor* actor )
+{
+  this->OtherActors.push_back( std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > >( algorithm, actor ) );
+  this->AddItem( actor );
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 SetInterpolate( bool v )
@@ -308,12 +332,17 @@ SetSliceNumber( const int& slice )
 
   } // fi
 
+  // Plane function origin
+  this->PlaneFunction->SetOrigin( pos );
+
+  // Configure visualization and implicit plane orientation
   int axis = this->SliceMappers[ 0 ]->GetOrientation( );
   this->PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
   this->PlaneActor->GetProperty( )->SetLineWidth( 2 );
   vtkPoints* plane_points = this->PlaneSource->GetPoints( );
   if( axis == 0 ) // YZ, x-normal
   {
+    this->PlaneFunction->SetNormal( 1, 0, 0 );
     plane_points->SetPoint( 0, pos[ 0 ], ybnds[ 0 ], zbnds[ 0 ] );
     plane_points->SetPoint( 1, pos[ 0 ], ybnds[ 1 ], zbnds[ 0 ] );
     plane_points->SetPoint( 2, pos[ 0 ], ybnds[ 1 ], zbnds[ 1 ] );
@@ -322,6 +351,7 @@ SetSliceNumber( const int& slice )
   }
   else if( axis == 1 ) // ZX, y-normal
   {
+    this->PlaneFunction->SetNormal( 0, 1, 0 );
     plane_points->SetPoint( 0, xbnds[ 0 ], pos[ 1 ], zbnds[ 0 ] );
     plane_points->SetPoint( 1, xbnds[ 0 ], pos[ 1 ], zbnds[ 1 ] );
     plane_points->SetPoint( 2, xbnds[ 1 ], pos[ 1 ], zbnds[ 1 ] );
@@ -330,6 +360,7 @@ SetSliceNumber( const int& slice )
   }
   else // XY, z-normal
   {
+    this->PlaneFunction->SetNormal( 0, 0, 1 );
     plane_points->SetPoint( 0, xbnds[ 0 ], ybnds[ 0 ], pos[ 2 ] );
     plane_points->SetPoint( 1, xbnds[ 1 ], ybnds[ 0 ], pos[ 2 ] );
     plane_points->SetPoint( 2, xbnds[ 1 ], ybnds[ 1 ], pos[ 2 ] );
@@ -337,9 +368,24 @@ SetSliceNumber( const int& slice )
     this->PlaneActor->GetProperty( )->SetColor( 0, 0, 1 );
 
   } // fi
+  this->PlaneFunction->Modified( );
   this->PlaneSource->Modified( );
   this->PlaneMapper->Modified( );
   this->PlaneActor->Modified( );
+
+  // Prepare other actors to update
+  for( unsigned int i = 0; i < this->OtherActors.size( ); ++i )
+  {
+#error CLEAN UP CODING STYLE AND NULL POINTER CHECK
+
+    this->OtherActors[ i ].first->Modified( );
+    this->OtherActors[ i ].first->Update( );
+    this->OtherActors[ i ].second->GetMapper( )->Modified( );
+    this->OtherActors[ i ].second->Modified( );
+
+  } // rof
+
+  // Update text
   this->UpdateText( );
 }
 
index 90b9ff018f4ed2d75a0ced687465dd42ad20a9a8..091b7bcf89ce399cceabf473b48b6cac111fa671 100644 (file)
@@ -3,11 +3,13 @@
 
 #include <cpExtensions/cpExtensions_Export.h>
 
+#include <utility>
 #include <vector>
 
 #include <vtkActor.h>
 #include <vtkImageActor.h>
 #include <vtkImageSliceMapper.h>
+#include <vtkPlane.h>
 #include <vtkPolyData.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkPropCollection.h>
@@ -49,6 +51,10 @@ namespace cpExtensions
       const vtkTextActor* GetTextActor( ) const;
       vtkActor* GetPlaneActor( );
       const vtkActor* GetPlaneActor( ) const;
+      vtkPlane* GetPlaneFunction( );
+      const vtkPlane* GetPlaneFunction( ) const;
+
+      void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
 
       void SetInterpolate( bool v );
       void InterpolateOn( );
@@ -80,9 +86,11 @@ namespace cpExtensions
       // Multiple actors
       std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
       std::vector< vtkSmartPointer< vtkImageActor > >       ImageActors;
+      std::vector< std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > > >            OtherActors;
       bool Interpolate;
 
       // Unique objects
+      vtkSmartPointer< vtkPlane >          PlaneFunction;
       vtkSmartPointer< vtkPolyData >       PlaneSource;
       vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
       char                                 TextBuffer[ 1024 ];
index 914c46de29d47490ec867cd2a4e527f65c4ef483..a32824c455926d3f674f3f6d310afa629668af2c 100644 (file)
@@ -236,6 +236,22 @@ Get3DRenderer( ) const
   return( this->m_Renderers[ 3 ] );
 }
 
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::MPRObjects::
+TMPRActors* cpExtensions::Visualization::MPRObjects::
+GetMPRActors( )
+{
+  return( this->m_MPRActors );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::Visualization::MPRObjects::
+TMPRActors* cpExtensions::Visualization::MPRObjects::
+GetMPRActors( ) const
+{
+  return( this->m_MPRActors );
+}
+
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::MPRObjects::
 MPRObjects( )
index 1a8135012044c928cd02d9af8171e60a879597b1..cbec46ff5c0b243861a9d9b0632007219e3a0c52 100644 (file)
@@ -51,6 +51,9 @@ namespace cpExtensions
       const vtkRenderer* GetZRenderer( ) const;
       const vtkRenderer* Get3DRenderer( ) const;
 
+      TMPRActors* GetMPRActors( );
+      const TMPRActors* GetMPRActors( ) const;
+
     protected:
       MPRObjects( );
       virtual ~MPRObjects( );
index a3990cc02c4b674d6d93e77bb94a7a4ef6f7ec27..8ee622177e320c774d787591844a42170ef01ad2 100644 (file)
@@ -15,6 +15,7 @@ SET(
   BaseProcessObjects.h
   DataObject.h
   Image.h
+  ImplicitFunction.h
   Interface.h
   Macros.h
   Mesh.h
@@ -30,6 +31,7 @@ SET(
 SET(
   LIB_HEADERS_HXX
   Image.hxx
+  ImplicitFunction.hxx
   Mesh.hxx
   Parameters.hxx
   ProcessObject.hxx
@@ -50,6 +52,7 @@ SET(
   BaseProcessObjects.cxx
   DataObject.cxx
   Image.cxx
+  ImplicitFunction.cxx
   Interface.cxx
   Mesh.cxx
   Object.cxx
index 09df979f3b0da19aceae48562c54c305a3ce435d..d68d2b7769148b53f44995ec37f5dbf5df35fd46 100644 (file)
@@ -65,7 +65,10 @@ DisconnectPipeline( )
 // -------------------------------------------------------------------------
 cpPlugins::Interface::DataObject::
 DataObject( )
-  : Superclass( )
+  : Superclass( ),
+    m_ITKObject( NULL ),
+    m_VTKObject( NULL ),
+    m_Source( NULL )
 {
   this->m_ClassName = "cpPlugins::Interface::DataObject";
   this->m_ClassCategory = "BasicObject";
index c08b3a345475f28fc4521c3876fee70233ff513a..aad997708c5a8df08947efb2065d76f2e1be2e06 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <map>
 #include <string>
-#include <vtkDataObject.h>
+#include <vtkObject.h>
 #include <vtkSmartPointer.h>
 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/Object.h>
@@ -45,9 +45,9 @@ namespace cpPlugins
       Self& operator=( const Self& );
 
     protected:
-      itk::DataObject::Pointer         m_ITKObject;
-      vtkSmartPointer< vtkDataObject > m_VTKObject;
-      Object::Pointer                  m_Source;
+      itk::DataObject::Pointer     m_ITKObject;
+      vtkSmartPointer< vtkObject > m_VTKObject;
+      Object::Pointer              m_Source;
     };
 
   } // ecapseman
diff --git a/lib/cpPlugins/Interface/ImplicitFunction.cxx b/lib/cpPlugins/Interface/ImplicitFunction.cxx
new file mode 100644 (file)
index 0000000..1ffc516
--- /dev/null
@@ -0,0 +1,95 @@
+#include <cpPlugins/Interface/ImplicitFunction.h>
+
+#include <vtkBox.h>
+#include <vtkCone.h>
+#include <vtkCylinder.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitDataSet.h>
+#include <vtkImplicitHalo.h>
+#include <vtkImplicitPolyDataDistance.h>
+#include <vtkImplicitSelectionLoop.h>
+#include <vtkImplicitSum.h>
+#include <vtkImplicitVolume.h>
+#include <vtkImplicitWindowFunction.h>
+#include <vtkPerlinNoise.h>
+#include <vtkPlane.h>
+#include <vtkPlanes.h>
+#include <vtkPlanesIntersection.h>
+#include <vtkPolyPlane.h>
+#include <vtkQuadric.h>
+#include <vtkSphere.h>
+#include <vtkSuperquadric.h>
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Interface_ImplicitFunction_DEF( T )                   \
+  void cpPlugins::Interface::ImplicitFunction::SetFunctionTo##T( )      \
+  {                                                                     \
+    this->m_VTKObject = vtkSmartPointer< vtk##T >::New( );              \
+    this->Modified( );                                                  \
+  }
+
+// -------------------------------------------------------------------------
+cpPlugins_Interface_ImplicitFunction_DEF( Box );
+cpPlugins_Interface_ImplicitFunction_DEF( Cone );
+cpPlugins_Interface_ImplicitFunction_DEF( Cylinder );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitBoolean );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitDataSet );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitHalo );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitPolyDataDistance );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitSelectionLoop );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitSum );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitVolume );
+cpPlugins_Interface_ImplicitFunction_DEF( ImplicitWindowFunction );
+cpPlugins_Interface_ImplicitFunction_DEF( PerlinNoise );
+cpPlugins_Interface_ImplicitFunction_DEF( Plane );
+cpPlugins_Interface_ImplicitFunction_DEF( Planes );
+cpPlugins_Interface_ImplicitFunction_DEF( PlanesIntersection );
+cpPlugins_Interface_ImplicitFunction_DEF( PolyPlane );
+cpPlugins_Interface_ImplicitFunction_DEF( Quadric );
+cpPlugins_Interface_ImplicitFunction_DEF( Sphere );
+cpPlugins_Interface_ImplicitFunction_DEF( Superquadric );
+
+// -------------------------------------------------------------------------
+vtkImplicitFunction* cpPlugins::Interface::ImplicitFunction::
+GetVTKImplicitFunction( )
+{
+  return(
+    dynamic_cast< vtkImplicitFunction* >(
+      this->m_VTKObject.GetPointer( )
+      )
+    );
+}
+
+// -------------------------------------------------------------------------
+const vtkImplicitFunction* cpPlugins::Interface::ImplicitFunction::
+GetVTKImplicitFunction( ) const
+{
+  return(
+    dynamic_cast< const vtkImplicitFunction* >(
+      this->m_VTKObject.GetPointer( )
+      )
+    );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ImplicitFunction::
+SetFunction( vtkImplicitFunction* function )
+{
+  this->m_VTKObject = function;
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ImplicitFunction::
+ImplicitFunction( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ImplicitFunction::
+~ImplicitFunction( )
+{
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/ImplicitFunction.h b/lib/cpPlugins/Interface/ImplicitFunction.h
new file mode 100644 (file)
index 0000000..6b9c7ee
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__H__
+#define __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__H__
+
+#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#include <cpPlugins/Interface/DataObject.h>
+
+#include <itkSpatialObject.h>
+
+#include <vtkSmartPointer.h>
+#include <vtkImplicitFunction.h>
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class cpPlugins_Interface_EXPORT ImplicitFunction
+      : public DataObject
+    {
+    public:
+      typedef ImplicitFunction                Self;
+      typedef DataObject                      Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( ImplicitFunction, DataObject );
+
+    public:
+      template< class F >
+        inline F* GetITKImplicitFunction( );
+
+      template< class F >
+        inline const F* GetITKImplicitFunction( ) const;
+
+      template< class F >
+        inline F* GetVTKImplicitFunction( );
+
+      template< class F >
+        inline const F* GetVTKImplicitFunction( ) const;
+
+      virtual vtkImplicitFunction* GetVTKImplicitFunction( );
+      virtual const vtkImplicitFunction* GetVTKImplicitFunction( ) const;
+
+      void SetFunction( vtkImplicitFunction* function );
+
+      void SetFunctionToBox( );
+      void SetFunctionToCone( );
+      void SetFunctionToCylinder( );
+      void SetFunctionToImplicitBoolean( );
+      void SetFunctionToImplicitDataSet( );
+      void SetFunctionToImplicitHalo( );
+      void SetFunctionToImplicitPolyDataDistance( );
+      void SetFunctionToImplicitSelectionLoop( );
+      void SetFunctionToImplicitSum( );
+      void SetFunctionToImplicitVolume( );
+      void SetFunctionToImplicitWindowFunction( );
+      void SetFunctionToPerlinNoise( );
+      void SetFunctionToPlane( );
+      void SetFunctionToPlanes( );
+      void SetFunctionToPlanesIntersection( );
+      void SetFunctionToPolyPlane( );
+      void SetFunctionToQuadric( );
+      void SetFunctionToSphere( );
+      void SetFunctionToSuperquadric( );
+
+    protected:
+      ImplicitFunction( );
+      virtual ~ImplicitFunction( );
+
+    private:
+      // Purposely not implemented
+      ImplicitFunction( const Self& );
+      Self& operator=( const Self& );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/ImplicitFunction.hxx b/lib/cpPlugins/Interface/ImplicitFunction.hxx
new file mode 100644 (file)
index 0000000..307d437
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__HXX__
+#define __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__HXX__
+
+// -------------------------------------------------------------------------
+template< class F >
+F* cpPlugins::Interface::ImplicitFunction::
+GetITKImplicitFunction( )
+{
+  return( dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class F >
+const F* cpPlugins::Interface::ImplicitFunction::
+GetITKImplicitFunction( ) const
+{
+  return( dynamic_cast< const F* >( this->m_ITKObject.GetPointer( ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class F >
+F* cpPlugins::Interface::ImplicitFunction::
+GetVTKImplicitFunction( )
+{
+  return( dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class F >
+const F* cpPlugins::Interface::ImplicitFunction::
+GetVTKImplicitFunction( ) const
+{
+  return( dynamic_cast< const F* >( this->m_VTKObject.GetPointer( ) ) );
+}
+
+#endif // __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__HXX__
+
+// eof - $RCSfile$
index 82492db180639484e977f5fae5659c371b90781c..51cf06742c0ccb72ce01c3d9d9c2cf97e4266055 100644 (file)
@@ -15,6 +15,8 @@ typedef char QWidget
 
 #include <itkProcessObject.h>
 
+class vtkAlgorithm;
+
 namespace cpPlugins
 {
   namespace Interface
@@ -34,6 +36,11 @@ namespace cpPlugins
       itkTypeMacro( ProcessObject, Object );
 
     public:
+      virtual vtkAlgorithm* GetVTKAlgorithm( )
+      { return( NULL ); }
+      virtual const vtkAlgorithm* GetVTKAlgorithm( ) const
+      { return( NULL ); }
+
       virtual const Parameters& GetDefaultParameters( ) const;
       virtual void SetParameters( const Parameters& params );
 
diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx
new file mode 100644 (file)
index 0000000..0ae95d5
--- /dev/null
@@ -0,0 +1,76 @@
+#include "Cutter.h"
+#include <cpPlugins/Interface/ImplicitFunction.h>
+#include <cpPlugins/Interface/Mesh.h>
+
+#include <vtkCutter.h>
+#include <vtkProperty.h>
+
+// -------------------------------------------------------------------------
+vtkAlgorithm* cpPlugins::BasicFilters::Cutter::
+GetVTKAlgorithm( )
+{
+  return( this->m_Algorithm );
+}
+
+// -------------------------------------------------------------------------
+const vtkAlgorithm* cpPlugins::BasicFilters::Cutter::
+GetVTKAlgorithm( ) const
+{
+  return( this->m_Algorithm );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::Cutter::
+Cutter( )
+  : Superclass( ),
+    m_Algorithm( NULL )
+{
+  this->m_ClassName = "cpPlugins::BasicFilters::Cutter";
+  this->m_ClassCategory = "MeshToMeshFilter";
+
+  this->SetNumberOfInputs( 2 );
+  this->SetNumberOfOutputs( 1 );
+  this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+
+  this->m_Parameters = this->m_DefaultParameters;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::Cutter::
+~Cutter( )
+{
+  if( this->m_Algorithm != NULL )
+    this->m_Algorithm->Delete( );
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::BasicFilters::Cutter::
+_GenerateData( )
+{
+  // Get inputs
+  cpPlugins::Interface::Mesh* mesh =
+    this->GetInput< cpPlugins::Interface::Mesh >( 0 );
+  cpPlugins::Interface::ImplicitFunction* function =
+    this->GetInput< cpPlugins::Interface::ImplicitFunction >( 1 );
+  if( function == NULL )
+    return( "Cutter: Input data 1 is not a valid implicit function." );
+
+  if( this->m_Algorithm != NULL )
+    this->m_Algorithm->Delete( );
+
+  vtkCutter* cutter = vtkCutter::New( );
+  cutter->SetInputData( mesh->GetVTKMesh( ) );
+  cutter->SetCutFunction( function->GetVTKImplicitFunction( ) );
+  cutter->GenerateTrianglesOff( );
+  this->m_Algorithm = cutter;
+
+  // Execute filter
+  this->m_Algorithm->Update( );
+  cpPlugins::Interface::Mesh* out =
+    this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
+  out->SetVTKMesh( this->m_Algorithm->GetOutput( ) );
+
+  return( "" );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.h b/lib/cpPlugins/Plugins/BasicFilters/Cutter.h
new file mode 100644 (file)
index 0000000..8887adc
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef __CPPLUGINS__PLUGINS__CUTTER__H__
+#define __CPPLUGINS__PLUGINS__CUTTER__H__
+
+#include <cpPlugins/BasicFilters/cpPluginsBasicFilters_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+class vtkAlgorithm;
+class vtkPolyDataAlgorithm;
+
+namespace cpPlugins
+{
+  namespace BasicFilters
+  {
+    /**
+     */
+    class cpPluginsBasicFilters_EXPORT Cutter
+      : public cpPlugins::Interface::MeshToMeshFilter
+    {
+    public:
+      typedef Cutter                                 Self;
+      typedef cpPlugins::Interface::MeshToMeshFilter Superclass;
+      typedef itk::SmartPointer< Self >              Pointer;
+      typedef itk::SmartPointer< const Self >        ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( Cutter, cpPluginsInterfaceMeshToMeshFilter );
+
+    public:
+      virtual vtkAlgorithm* GetVTKAlgorithm( );
+      virtual const vtkAlgorithm* GetVTKAlgorithm( ) const;
+
+    protected:
+      Cutter( );
+      virtual ~Cutter( );
+
+      virtual std::string _GenerateData( );
+
+    private:
+      // Purposely not implemented
+      Cutter( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      vtkPolyDataAlgorithm* m_Algorithm;
+    };
+
+    // ---------------------------------------------------------------------
+    CPPLUGINS_INHERIT_PROVIDER( Cutter );
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__CUTTER__H__
+
+// eof - $RCSfile$
index 38f7dbc848c987daa95e1b45a69fe58d1cdc7275..e061017b328f68fddf64bc8cbafefc8bdecf0b2a 100644 (file)
@@ -61,6 +61,7 @@ _GenerateData( )
   else if( vtk_image->GetDataDimension( ) == 3 )
   {
     vtkMarchingCubes* mc = vtkMarchingCubes::New( );
+    mc->ComputeNormalsOff( );
     mc->SetInputData( vtk_image );
     for( unsigned int i = 0; i < values.size( ); ++i )
       mc->SetValue( i, values[ i ] );