#include "itksys/SystemTools.hxx"
#include "vtkPolyDataWriter.h"
+#include "vtkSmoothPolyDataFilter.h"
void run(const args_info_clitkBinaryImageToMesh& argsInfo);
vtkSmartPointer<vtkContourFilter> pcontour = vtkContourFilter::New();
pcontour->SetValue(0, 0.5);
pcontour->SetInputConnection(pbmp_reader->GetOutputPort());
-
- vtkSmartPointer<vtkDecimatePro> psurface = vtkDecimatePro::New();
- psurface->SetInputConnection(pcontour->GetOutputPort());
+ vtkAlgorithmOutput *data = pcontour->GetOutputPort();
+
+ if ( (argsInfo.decimate_arg>=0) && (argsInfo.decimate_arg<=1) ) {
+ vtkSmartPointer<vtkDecimatePro> psurface = vtkDecimatePro::New();
+ psurface->SetInputConnection(pcontour->GetOutputPort());
+ psurface->SetTargetReduction(argsInfo.decimate_arg);
+
+ data = psurface->GetOutputPort();
+ }
+
+
vtkSmartPointer<vtkPolyDataMapper> skinMapper = vtkPolyDataMapper::New();
- skinMapper->SetInputConnection(psurface->GetOutputPort());
+ skinMapper->SetInputConnection(data); //psurface->GetOutputPort()
skinMapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> skin = vtkActor::New();
}
if (writeVTK) {
vtkSmartPointer<vtkPolyDataWriter> wr = vtkSmartPointer<vtkPolyDataWriter>::New();
- wr->SetInputConnection(psurface->GetOutputPort());
+ wr->SetInputConnection(data); //psurface->GetOutputPort()
wr->SetFileName(output.c_str());
wr->Update();
wr->Write();
option "input" i "Input image" string yes
option "output" o "Output mesh file prefix (if empty, use input file's base name as prefix; if a directoy, output to it using input file's base name as prefix; otherwise, use given name as prefix ; if names ends with .vtk the output is written as a vtkPolyData file" string no
-option "view" - "View result" flag off
+option "decimate" d "Decimate mesh (value in [0-1] is the target reduction percentage, outside this range means NO decimation)" double no default="-1"
+option "view" - "View result" flag off