# Prepare header to build shared libs (windows)
INCLUDE(GenerateExportHeader)
-# Find boost
-FIND_PACKAGE(Boost 1.30 COMPONENTS filesystem system REQUIRED)
-IF(Boost_FOUND)
- INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
-ENDIF(Boost_FOUND)
-
# Find ITK and VTK
FIND_PACKAGE(ITK REQUIRED)
FIND_PACKAGE(VTK REQUIRED)
void ImageMPR::
_triggered_actionOpenInputPolyData( )
{
- /*
// Show dialog and check if it was accepted
QFileDialog dialog( this );
dialog.setFileMode( QFileDialog::ExistingFile );
tr( "Error reading mesh" ),
tr( err.c_str( ) )
);
- */
}
// -------------------------------------------------------------------------
void ImageMPR::
_triggered_actionImageToImage( )
{
- /*
if( this->m_InputImage.IsNull( ) )
return;
tr( "Error executing filter" ),
tr( err.c_str( ) )
);
- */
}
// -------------------------------------------------------------------------
void ImageMPR::
_triggered_actionImageToMesh( )
{
- /*
if( this->m_InputImage.IsNull( ) )
return;
tr( "Error executing filter" ),
tr( err.c_str( ) )
);
- */
}
// eof - $RCSfile$
FOREACH(prog ${BASH_PROGRAMS})
ADD_EXECUTABLE(${prog} ${prog}.cxx)
- TARGET_LINK_LIBRARIES(${prog} ${Boost_LIBRARIES})
ENDFOREACH(prog)
## eof - $RCSfile$
+#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
-#include <boost/filesystem/path.hpp>
+// -------------------------------------------------------------------------
+std::string GetFileName( const std::string& path )
+{
+ // Extract filename
+ char* buffer = new char[ path.size( ) + 1 ];
+ std::memcpy( buffer, path.c_str( ), path.size( ) );
+ buffer[ path.size( ) ] = '\0';
+ char* tok = std::strtok( buffer, "/\\" );
+ char* ptr_fname = tok;
+ while( tok != NULL )
+ {
+ ptr_fname = tok;
+ tok = std::strtok( NULL, "/\\" );
+ } // elihw
+ std::string fname( ptr_fname );
+ delete [] buffer;
+
+ // Delete extension
+ std::size_t pos = fname.find_last_of( "." );
+ if( pos != std::string::npos )
+ fname = fname.substr( 0, pos );
+
+ return( fname );
+}
+
+// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
// Open file
<< " using namespace " << argv[ 2 ] << ";" << std::endl;
for( int i = 3; i < argc; ++i )
- {
- boost::filesystem::path p( argv[ i ] );
output_code
<< " host.add( new "
- << p.stem( ).generic_string( )
+ << GetFileName( argv[ i ] )
<< "Provider( ) );"
<< std::endl;
- } // rof
-
output_code
<< " return( true );" << std::endl
<< "}" << std::endl;
SET(cpPlugins_Interface_LIBRARY cpPlugins_Interface)
SET(cpPlugins_LIBRARY cpPlugins)
+# ======================
+# -- Executable names --
+# ======================
+
+SET(
+ cpPlugins_createHost_APP
+ @PROJECT_BINARY_DIR@/cpPlugins_createHost
+ )
+
## eof - $RCSfile$
+++ /dev/null
-// -------------------------------------------------------------------------
-// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
-// -------------------------------------------------------------------------
-
-#include <cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h>
-#include <itkImage.h>
-#include <itkSymmetricSecondRankTensor.h>
-#include <itkImageRegionConstIteratorWithIndex.h>
-#include <vtkInformation.h>
-#include <vtkInformationVector.h>
-#include <vtkPoints.h>
-#include <vtkPointData.h>
-#include <vtkSmartPointer.h>
-#include <vtkDoubleArray.h>
-
-// -------------------------------------------------------------------------
-template< class I >
-typename cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
-Self* cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
-New( )
-{
- return( new Self );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
-SetInputData( const I* image )
-{
- this->m_ITKImage = image;
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
-SecondRankDiffusionTensorToPolyData( )
- : vtkPolyDataAlgorithm( )
-{
- this->SetNumberOfInputPorts( 0 );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
-~SecondRankDiffusionTensorToPolyData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-int cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
-RequestData(
- vtkInformation* request,
- vtkInformationVector** inputVector,
- vtkInformationVector* outputVector
- )
-{
- if( this->m_ITKImage.IsNull( ) )
- return( 0 );
-
- // get the info objects
- vtkInformation* outInfo = outputVector->GetInformationObject( 0 );
- vtkPolyData* polyData = vtkPolyData::SafeDownCast(
- outInfo->Get(vtkDataObject::DATA_OBJECT())
- );
-
- itk::ImageRegionConstIteratorWithIndex< I > tensorIt( this->m_ITKImage, this->m_ITKImage->GetRequestedRegion() );
-
- vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
- vtkSmartPointer<vtkDoubleArray> vtkTensors = vtkSmartPointer<vtkDoubleArray>::New();
- vtkTensors->SetNumberOfComponents(9);
- for ( tensorIt.GoToBegin(); !tensorIt.IsAtEnd(); ++tensorIt )
- {
- typename I::IndexType tensorIndex = tensorIt.GetIndex();
- typename I::PixelType tensor = tensorIt.Get();
- typename I::PointType ptensor;
-
- // TODO: std::cout << "\n Index [" << tensorIndex[0] << ", " << tensorIndex[1] << ", " << tensorIndex[2] << "]" << std::endl;
- this->m_ITKImage->TransformIndexToPhysicalPoint( tensorIndex, ptensor );
- vtkIdType vtkPointID = points->InsertNextPoint(ptensor[0], ptensor[1], ptensor[2]);
-
- /**
- * Definition included in cdifTypes.
- * typedef itk::SymmetricSecondRankTensor< double > Diffusion2ndRankTensor;
- */
- //Diffusion2ndRankTensor Diffusion2ndRankTensor;
-
-
- /**
- * SYMMETRIC SECOND RANK TENSOR
- *
- * The upper-right triangle of the matrix:
- *
- * | 0 1 2 |
- * | X 3 4 |
- * | X X 5 |
- *
- * | xx xy xz |
- * | X yy yz |
- * | X X zz |
- */
- /*
- Diffusion2ndRankTensor = tensor[0];
- Diffusion2ndRankTensor = tensor[1];
- Diffusion2ndRankTensor = tensor[2];
- Diffusion2ndRankTensor = tensor[3];
- Diffusion2ndRankTensor = tensor[4];
- Diffusion2ndRankTensor = tensor[5];
- */
- typename I::PixelType::EigenValuesArrayType evalues;
- typename I::PixelType::EigenVectorsMatrixType evectors;
-
- /**
- * Return an array containing EigenValues,
- * and a matrix containing Eigenvectors.
- */
- tensor.ComputeEigenAnalysis(evalues, evectors);
-
- /*
- std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen values: " << evalues[0] << ", " << evalues[1] << ", " << evalues[2] << std::endl;
-
- std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen vectors: "
-
- << "(" << evectors(0,0) << ", " << evectors(0,1) << ", " << evectors(0,2) << "), "
- << "(" << evectors(1,0) << ", " << evectors(1,1) << ", " << evectors(1,2) << "), "
- << "(" << evectors(2,0) << ", " << evectors(2,1) << ", " << evectors(2,2) << ")" << std::endl;
- */
- evectors.GetVnlMatrix().scale_row(0, evalues[0]);
- evectors.GetVnlMatrix().scale_row(1, evalues[1]);
- evectors.GetVnlMatrix().scale_row(2, evalues[2]);
-
- /*
- std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen values x Eigen vectors : "
-
- << "(" << evectors(0,0) << ", " << evectors(0,1) << ", " << evectors(0,2) << "), "
- << "(" << evectors(1,0) << ", " << evectors(1,1) << ", " << evectors(1,2) << "), "
- << "(" << evectors(2,0) << ", " << evectors(2,1) << ", " << evectors(2,2) << ")" << std::endl;
- */
- vtkTensors->InsertTuple9(
- vtkPointID,
- evectors(0,0), evectors(0,1), evectors(0,2),
- evectors(1,0), evectors(1,1), evectors(1,2),
- evectors(2,0), evectors(2,1), evectors(2,2)
- );
- } // rof
-
- polyData->SetPoints( points );
- vtkSmartPointer<vtkPointData> pointData = polyData->GetPointData();
- pointData->SetTensors( vtkTensors );
- return( 1 );
-
- /**
- * VISUALISATION CODE BELOW
- */
-
-// vtkSmartPointer<vtkCubeSource> cubeSource = vtkSmartPointer<vtkCubeSource>::New();
-// cubeSource->Update();
-//
-// vtkSmartPointer<vtkTensorGlyph> tensorGlyph = vtkSmartPointer<vtkTensorGlyph>::New();
-//#if VTK_MAJOR_VERSION <= 5
-// tensorGlyph->SetInput(polyData);
-//#else
-// tensorGlyph->SetInputData(polyData);
-//#endif
-// tensorGlyph->SetSourceConnection(cubeSource->GetOutputPort());
-// tensorGlyph->ColorGlyphsOff();
-// tensorGlyph->ThreeGlyphsOff();
-// tensorGlyph->ExtractEigenvaluesOff();
-// tensorGlyph->Update();
-// .
-// .
-// .
-
-}
-
-// -------------------------------------------------------------------------
-template class cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< itk::Image< itk::SymmetricSecondRankTensor< float, 3 >, 3 > >;
-template class cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< itk::Image< itk::SymmetricSecondRankTensor< double, 3 >, 3 > >;
-
-// eof - $RCSfile$
+++ /dev/null
-// -------------------------------------------------------------------------
-// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
-// -------------------------------------------------------------------------
-
-#ifndef __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
-#define __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
-
-#include <cpExtensions/cpExtensions_Export.h>
-
-#include <vtkPolyDataAlgorithm.h>
-
-namespace cpExtensions
-{
- namespace Algorithms
- {
- /**
- */
- template< class I >
- class cpExtensions_EXPORT SecondRankDiffusionTensorToPolyData
- : public vtkPolyDataAlgorithm
- {
- public:
- typedef SecondRankDiffusionTensorToPolyData Self;
-
- public:
- static Self* New( );
- vtkTypeMacro( SecondRankDiffusionTensorToPolyData, vtkPolyDataAlgorithm );
-
- void SetInputData( const I* image );
-
- protected:
- SecondRankDiffusionTensorToPolyData( );
- virtual ~SecondRankDiffusionTensorToPolyData( );
-
- virtual int RequestData(
- vtkInformation* , vtkInformationVector**, vtkInformationVector*
- );
-
- private:
- SecondRankDiffusionTensorToPolyData( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- typename I::ConstPointer m_ITKImage;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h>
-#include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/Mesh.h>
-
-#include <cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h>
-#include <itkSymmetricSecondRankTensor.h>
-
-// -------------------------------------------------------------------------
-cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
-SecondRankDiffusionTensorToPolyData( )
- : Superclass( ),
- m_Algorithm( NULL )
-{
- this->m_ClassName = "cpPlugins::SecondRankDiffusionTensorToPolyData";
- this->m_ClassCategory = "ImageToMeshFilter";
-
- this->SetNumberOfInputs( 1 );
- this->SetNumberOfOutputs( 1 );
- this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
-
- using namespace cpPlugins::Interface;
- this->m_Parameters = this->m_DefaultParameters;
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
-~SecondRankDiffusionTensorToPolyData( )
-{
- if( this->m_Algorithm != NULL )
- this->m_Algorithm->Delete( );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
-_GenerateData( )
-{
- // Get input
- cpPlugins::Interface::Image* image =
- this->GetInput< cpPlugins::Interface::Image >( 0 );
- if( image == NULL )
- return( "SecondRankDiffusionTensorToPolyData: Input data is not a valid image." );
-
- itk::DataObject* itk_image = NULL;
- std::string r = "";
- cpPlugins_ImageArray_Input_Demangle( itk::SymmetricSecondRankTensor, float, 3, 3, image, itk_image, r, _RealGD );
- else cpPlugins_ImageArray_Input_Demangle( itk::SymmetricSecondRankTensor, double, 3, 3, image, itk_image, r, _RealGD );
- else
- r = "SecondRankDiffusionTensorToPolyData: Input does not have a DiffusionTensor3D.";
- return( r );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-std::string cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
-_RealGD( itk::DataObject* image )
-{
- typedef cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I > _F;
-
- // Configure filter
- _F* f = NULL;
- if( this->m_Algorithm == NULL )
- {
- f = _F::New( );
- this->m_Algorithm = f;
-
- } // fi
- f->SetInputData( dynamic_cast< I* >( image ) );
- this->m_Algorithm->Update( );
-
- // Connect output
- cpPlugins::Interface::Mesh* out =
- this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
- if( out != NULL )
- {
- out->SetVTKMesh( this->m_Algorithm->GetOutput( ) );
- return( "" );
- }
- else
- return( "OtsuThresholdImageFilter: output not correctly created." );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
-#define __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
-
-#include <cpPlugins/Plugins/cpPlugins_Export.h>
-#include <cpPlugins/Interface/BaseProcessObjects.h>
-
-class vtkPolyDataAlgorithm;
-
-namespace cpPlugins
-{
- namespace Plugins
- {
- /**
- */
- class cpPlugins_EXPORT SecondRankDiffusionTensorToPolyData
- : public cpPlugins::Interface::ImageToMeshFilter
- {
- public:
- typedef SecondRankDiffusionTensorToPolyData Self;
- typedef cpPlugins::Interface::ImageToMeshFilter Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SecondRankDiffusionTensorToPolyData, cpPluginsInterfaceImageToMeshFilter );
-
- protected:
- SecondRankDiffusionTensorToPolyData( );
- virtual ~SecondRankDiffusionTensorToPolyData( );
-
- virtual std::string _GenerateData( );
-
- template< class I >
- inline std::string _RealGD( itk::DataObject* image );
-
- private:
- // Purposely not implemented
- SecondRankDiffusionTensorToPolyData( const Self& );
- Self& operator=( const Self& );
-
- protected:
- vtkPolyDataAlgorithm* m_Algorithm;
- };
-
- // ---------------------------------------------------------------------
- CPPLUGINS_INHERIT_PROVIDER( SecondRankDiffusionTensorToPolyData );
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
-
-// eof - $RCSfile$