} // rof
+ if( this->m_UpdateCommand != NULL )
+ this->m_UpdateCommand( this->m_UpdateData );
+
// Update text
this->UpdateText( );
}
cpExtensions::Visualization::ImageSliceActors::
ImageSliceActors( )
: Superclass( ),
- Interpolate( false )
+ Interpolate( false ),
+ m_UpdateCommand( NULL ),
+ m_UpdateData( NULL )
{
this->Clear( );
}
public:
typedef ImageSliceActors Self;
+ typedef void ( *TUpdateCommand )( void* );
+
public:
vtkTypeMacro( ImageSliceActors, vtkPropCollection );
void UpdateText( );
void UpdateText( const double& w, const double& l );
+ TUpdateCommand SetUpdateCommand( TUpdateCommand cmd, void* data )
+ {
+ this->m_UpdateCommand = cmd;
+ this->m_UpdateData = data;
+ }
+
protected:
ImageSliceActors( );
virtual ~ImageSliceActors( );
char TextBuffer[ 1024 ];
vtkSmartPointer< vtkTextActor > TextActor;
vtkSmartPointer< vtkActor > PlaneActor;
+
+
+ TUpdateCommand m_UpdateCommand;
+ void* m_UpdateData;
};
} // ecapseman
} // fi
+ // --------- TODO ---------------
+ typename I::DirectionType norm_dir;
+ norm_dir.SetIdentity( );
+ image->SetDirection( norm_dir );
+ // --------- TODO ---------------
+
// Connect it to VTK
cpPlugins_VTKImage_Demangle_AllDims( I, char, image );
else cpPlugins_VTKImage_Demangle_AllDims( I, short, image );
)
)
{
+ double range[ 2 ];
+ pd->GetScalarRange( range );
+
this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
this->m_Actor = vtkSmartPointer< vtkActor >::New( );
this->m_Mapper->SetInputData( pd );
+ this->m_Mapper->UseLookupTableScalarRangeOff( );
+ this->m_Mapper->SetScalarRange(
+ range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ]
+ );
this->m_Actor->SetMapper( this->m_Mapper );
this->Modified( );
#include <vtkCutter.h>
#include <vtkProperty.h>
+
+#include <vtkPlane.h>
+
// -------------------------------------------------------------------------
cpPlugins::BasicFilters::Cutter::
Cutter( )
return( "Cutter: Input data 1 is not a valid implicit function." );
vtkCutter* cutter = this->_CreateVTK< vtkCutter >( );
+ cutter->DebugOn( );
cutter->SetInputData( mesh->GetVTK< vtkPolyData >( ) );
cutter->SetCutFunction( function->GetVTK< vtkImplicitFunction >( ) );
+ cutter->SetValue( 0, 1 );
cutter->GenerateTrianglesOff( );
cutter->Update( );
--- /dev/null
+#include "ExtractSliceImageFilter.h"
+#include <cpPlugins/Interface/Image.h>
+
+#include <itkExtractImageFilter.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::ExtractSliceImageFilter::
+ExtractSliceImageFilter( )
+ : Superclass( )
+{
+ this->m_ClassName = "cpPlugins::BasicFilters::ExtractSliceImageFilter";
+ this->m_ClassCategory = "ImageToImageFilter";
+ this->SetNumberOfInputs( 1 );
+ this->SetNumberOfOutputs( 1 );
+ this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+
+ using namespace cpPlugins::Interface;
+ this->m_DefaultParameters.Configure( Parameters::Int, "Axis" );
+ this->m_DefaultParameters.Configure( Parameters::Int, "Slice" );
+ this->m_DefaultParameters.SetValueAsInt( "Axis", 0 );
+ this->m_DefaultParameters.SetValueAsInt( "Slice", 0 );
+ this->m_Parameters = this->m_DefaultParameters;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::ExtractSliceImageFilter::
+~ExtractSliceImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::BasicFilters::ExtractSliceImageFilter::
+_GenerateData( )
+{
+ cpPlugins::Interface::Image* image =
+ this->GetInput< cpPlugins::Interface::Image >( 0 );
+ if( image == NULL )
+ return( "ExtractSliceImageFilter: No input image." );
+
+ itk::DataObject* itk_image = NULL;
+ std::string r = "";
+ cpPlugins_Image_Demangle_AllTypes( 3, image, itk_image, r, _GD0 );
+ else cpPlugins_VectorImage_Demangle_AllTypes( 3, image, itk_image, r, _GD0 );
+ else r = "ExtractSliceImageFilter: Input image type not supported.";
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::BasicFilters::ExtractSliceImageFilter::
+_GD0( itk::DataObject* image )
+{
+ return( this->_RealGD< I, I >( image ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+inline std::string cpPlugins::BasicFilters::ExtractSliceImageFilter::
+_RealGD( itk::DataObject* image )
+{
+ typedef itk::ExtractImageFilter< I, O > _F;
+ typedef typename O::PixelType _OP;
+
+ // Get parameters
+ int axis = this->m_Parameters.GetValueAsInt( "Axis" );
+ int slice = this->m_Parameters.GetValueAsInt( "Slice" );
+
+ std::cout << "HOLA: " << slice << std::endl;
+
+
+ // Compute region
+ I* img = dynamic_cast< I* >( image );
+ typename I::RegionType region = img->GetRequestedRegion( );
+ typename I::SizeType size = region.GetSize( );
+ typename I::IndexType index = region.GetIndex( );
+ size[ axis ] = 1;
+ index[ axis ] = slice;
+ region.SetSize( size );
+ region.SetIndex( index );
+
+ std::cout << "HOLA-: " << region << std::endl;
+
+ // Configure filter
+ _F* filter = this->_CreateITK< _F >( );
+ filter->SetInput( img );
+ filter->SetExtractionRegion( region );
+ filter->SetDirectionCollapseToIdentity( );
+ filter->Update( );
+
+ // Connect output
+ cpPlugins::Interface::Image* out =
+ this->GetOutput< cpPlugins::Interface::Image >( 0 );
+ if( out != NULL )
+ {
+ out->SetITK< O >( filter->GetOutput( ) );
+ return( "" );
+ }
+ else
+ return( "ExtractSliceImageFilter: output not correctly created." );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__
+#define __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__
+
+#include <cpPlugins/BasicFilters/cpPluginsBasicFilters_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+namespace cpPlugins
+{
+ namespace BasicFilters
+ {
+ /**
+ */
+ class cpPluginsBasicFilters_EXPORT ExtractSliceImageFilter
+ : public cpPlugins::Interface::ImageToImageFilter
+ {
+ public:
+ typedef ExtractSliceImageFilter Self;
+ typedef cpPlugins::Interface::ImageToImageFilter Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro(
+ ExtractSliceImageFilter, cpPluginsInterfaceImageToImageFilter
+ );
+
+ protected:
+ ExtractSliceImageFilter( );
+ virtual ~ExtractSliceImageFilter( );
+
+ virtual std::string _GenerateData( );
+
+ template< class I >
+ inline std::string _GD0( itk::DataObject* image );
+
+ template< class I, class O >
+ inline std::string _RealGD( itk::DataObject* image );
+
+ private:
+ // Purposely not implemented
+ ExtractSliceImageFilter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+ // ---------------------------------------------------------------------
+ CPPLUGINS_INHERIT_PROVIDER( ExtractSliceImageFilter );
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__
+
+// eof - $RCSfile$
{
itk::Point< double, 3 > center =
this->m_Parameters.GetValueAsPoint< itk::Point< double, 3 > >( "Center" );
+ center.Fill( double( 0 ) ); // TODO
double radius = this->m_Parameters.GetValueAsReal( "Radius" );
unsigned int phi = this->m_Parameters.GetValueAsUint( "PhiResolution" );
unsigned int theta = this->m_Parameters.GetValueAsUint( "ThetaResolution" );
itk::DataObject* itk_image = NULL;
std::string r = "";
-
cpPlugins_Image_Demangle_AllTypes( 2, image, itk_image, r, _RealGD );
else cpPlugins_Image_Demangle_AllTypes( 3, image, itk_image, r, _RealGD );
else cpPlugins_Image_Demangle_AllTypes( 4, image, itk_image, r, _RealGD );