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 );
std::string( "cpPluginsIO." ) +
std::string( PLUGIN_EXT )
);
+ this->_LoadPlugins(
+ std::string( PLUGIN_PREFIX ) +
+ std::string( "cpPluginsBasicFilters." ) +
+ std::string( PLUGIN_EXT )
+ );
}
// -------------------------------------------------------------------------
this->m_ImageWriterClass = "";
this->m_MeshReaderClass = "";
this->m_MeshWriterClass = "";
+ this->m_MeshCutterClass = "";
this->m_UI->MenuImageToImage->clear( );
this->m_UI->MenuImageToMesh->clear( );
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 =
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( )
_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 );
void ImageMPR::
_triggered_actionOpenSegmentation( )
{
- if( this->m_InputImage.IsNull( ) )
+ if( this->m_Image.IsNull( ) )
{
QMessageBox::critical(
this,
} // 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 );
void ImageMPR::
_triggered_actionOpenInputPolyData( )
{
- this->m_InputMesh = NULL;
+ this->m_Mesh = NULL;
// Get a reader from plugins
TPluginFilter::Pointer reader =
// 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(
void ImageMPR::
_triggered_actionImageToImage( )
{
- if( this->m_InputImage.IsNull( ) )
+ if( this->m_Image.IsNull( ) )
return;
// Get filter name
// 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 );
{
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(
void ImageMPR::
_triggered_actionImageToMesh( )
{
- if( this->m_InputImage.IsNull( ) )
+ if( this->m_Image.IsNull( ) )
return;
// Get filter name
// 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 );
{
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
#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>
// -------------------------------------------------------------------------
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;
protected:
bool _LoadPlugins( const std::string& filename );
std::string _LoadImage( TPluginImage::Pointer& image );
+ std::string _ConfigureMeshActors( );
private slots:
void _triggered_actionOpenPlugins( );
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;
// 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
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 )
} // 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 ] );
}
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 ] );
}
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 ] );
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( );
}
#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>
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( );
// 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 ];
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( )
const vtkRenderer* GetZRenderer( ) const;
const vtkRenderer* Get3DRenderer( ) const;
+ TMPRActors* GetMPRActors( );
+ const TMPRActors* GetMPRActors( ) const;
+
protected:
MPRObjects( );
virtual ~MPRObjects( );
BaseProcessObjects.h
DataObject.h
Image.h
+ ImplicitFunction.h
Interface.h
Macros.h
Mesh.h
SET(
LIB_HEADERS_HXX
Image.hxx
+ ImplicitFunction.hxx
Mesh.hxx
Parameters.hxx
ProcessObject.hxx
BaseProcessObjects.cxx
DataObject.cxx
Image.cxx
+ ImplicitFunction.cxx
Interface.cxx
Mesh.cxx
Object.cxx
// -------------------------------------------------------------------------
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";
#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>
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
--- /dev/null
+#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$
--- /dev/null
+#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$
--- /dev/null
+#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$
#include <itkProcessObject.h>
+class vtkAlgorithm;
+
namespace cpPlugins
{
namespace Interface
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 );
--- /dev/null
+#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$
--- /dev/null
+#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$
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 ] );