34 #ifndef __QGoMeshLevelSetAlgo_h
35 #define __QGoMeshLevelSetAlgo_h
41 #include "QGoGUILibConfigure.h"
42 #include "vtkSmartPointer.h"
43 #include "vtkPolyData.h"
44 #include "vtkImageData.h"
45 #include "vtkTransform.h"
46 #include "vtkTransformPolyDataFilter.h"
65 bool iIsInvertedOn =
false);
69 template <
class TPixel >
74 const std::vector<double>& iCenter,
75 typename itk::Image< TPixel, 3 >::Pointer iImages)
77 assert( iCenter.size() == 3);
79 const unsigned int ImageDimension = 3;
81 typedef TPixel PixelType;
83 typedef itk::Image< PixelType, ImageDimension > ImageType;
84 typedef typename ImageType::Pointer ImagePointer;
89 std::vector< double > bounds( 2 * ImageDimension, 0. );
91 for(
unsigned int dim = 0; dim < ImageDimension; dim++ )
93 bounds[k++] = iCenter[dim] - 2. * radius;
94 bounds[k++] = iCenter[dim] + 2. * radius;
98 ImagePointer ITK_ROI_Image =
99 this->ITKExtractROI< PixelType, ImageDimension >( bounds, iImages );
111 ItkOutPut = Filter.GetOutput3D();
115 vtkImageData * FilterOutPutToVTK =
118 ImageDimension>( ItkOutPut );
120 vtkPolyData* temp_output = this->
ExtractPolyData(FilterOutPutToVTK, 0);
121 FilterOutPutToVTK->Delete();
123 double temp_bounds[6];
124 temp_output->GetBounds( temp_bounds );
126 double temp_center[3];
127 temp_center[0] = ( temp_bounds[0] + temp_bounds[1] ) * 0.5;
128 temp_center[1] = ( temp_bounds[2] + temp_bounds[3] ) * 0.5;
129 temp_center[2] = ( temp_bounds[4] + temp_bounds[5] ) * 0.5;
131 vtkSmartPointer< vtkTransform > translation =
132 vtkSmartPointer< vtkTransform >::New();
135 translation->Translate(iCenter[0] - temp_center[0],
136 iCenter[1] - temp_center[1],
137 iCenter[2] - temp_center[2] );
139 vtkSmartPointer< vtkTransformPolyDataFilter > mesh_transform =
140 vtkSmartPointer< vtkTransformPolyDataFilter >::New();
141 mesh_transform->SetTransform(translation);
142 mesh_transform->SetInput( temp_output );
143 mesh_transform->Update();
144 temp_output->Delete();
147 vtkPolyData* mesh = vtkPolyData::New();
148 mesh->DeepCopy( mesh_transform->GetOutput() );
vtkPolyData * ApplyLevelSetFilter(const std::vector< double > &iCenter, typename itk::Image< TPixel, 3 >::Pointer iImages)
Levelset segmentation algorithm implementation. Can generate contours and meshes. Will generate 2D ob...
void Apply3DFilter(typename itk::Image< TPixel, 3 >::Pointer iITKInput, const std::vector< double > &iCenter, const double &iRadius, const int &iIterations, const int &iCurvature)
Output3DType::Pointer Output3DPointer
QGoMeshLevelSetAlgo(std::vector< vtkPoints * > *iSeeds, QWidget *iParent=0)
std::vector< vtkPolyData * > ExtractPolyData(std::vector< vtkImageData * > &iInputImage, const double &iThreshold)
QGoAlgoParameter< double > * m_Radius
QGoAlgoParameter< int > * m_Iterations
class to be the interface between the levelset algo for meshes, contours and set of contours and GoFi...
std::vector< vtkPolyData * > ApplyAlgo(GoImageProcessor *iImages, std::string iChannel, bool iIsInvertedOn=false)
return the vtkpolydata created by the algorithm
QGoAlgoParameter< int > * m_Curvature
Interface between image reader and vtkImageData.
vtkImageData * ConvertITK2VTK(typename itk::Image< PixelType, VImageDimension >::Pointer iInput)
class to be the interface between the levelset algo for meshes and GoFigure