From: U-PC-de-Rémi\Rémi Date: Tue, 7 May 2013 16:04:50 +0000 (+0200) Subject: Made the mesh decimation optional, and tunable. If on, the resulting mesh may have... X-Git-Tag: v1.4.0~231^2~2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;ds=sidebyside;h=46df890b27e7d340b52be7f67947bc570db4b05f;p=clitk.git Made the mesh decimation optional, and tunable. If on, the resulting mesh may have problems and can be unreadable by transformix --- diff --git a/tools/clitkBinaryImageToMesh.cxx b/tools/clitkBinaryImageToMesh.cxx index 220d033..0eb5db6 100644 --- a/tools/clitkBinaryImageToMesh.cxx +++ b/tools/clitkBinaryImageToMesh.cxx @@ -33,6 +33,7 @@ #include "itksys/SystemTools.hxx" #include "vtkPolyDataWriter.h" +#include "vtkSmoothPolyDataFilter.h" void run(const args_info_clitkBinaryImageToMesh& argsInfo); @@ -57,12 +58,20 @@ void run(const args_info_clitkBinaryImageToMesh& argsInfo) vtkSmartPointer pcontour = vtkContourFilter::New(); pcontour->SetValue(0, 0.5); pcontour->SetInputConnection(pbmp_reader->GetOutputPort()); - - vtkSmartPointer psurface = vtkDecimatePro::New(); - psurface->SetInputConnection(pcontour->GetOutputPort()); + vtkAlgorithmOutput *data = pcontour->GetOutputPort(); + + if ( (argsInfo.decimate_arg>=0) && (argsInfo.decimate_arg<=1) ) { + vtkSmartPointer psurface = vtkDecimatePro::New(); + psurface->SetInputConnection(pcontour->GetOutputPort()); + psurface->SetTargetReduction(argsInfo.decimate_arg); + + data = psurface->GetOutputPort(); + } + + vtkSmartPointer skinMapper = vtkPolyDataMapper::New(); - skinMapper->SetInputConnection(psurface->GetOutputPort()); + skinMapper->SetInputConnection(data); //psurface->GetOutputPort() skinMapper->ScalarVisibilityOff(); vtkSmartPointer skin = vtkActor::New(); @@ -97,7 +106,7 @@ void run(const args_info_clitkBinaryImageToMesh& argsInfo) } if (writeVTK) { vtkSmartPointer wr = vtkSmartPointer::New(); - wr->SetInputConnection(psurface->GetOutputPort()); + wr->SetInputConnection(data); //psurface->GetOutputPort() wr->SetFileName(output.c_str()); wr->Update(); wr->Write(); diff --git a/tools/clitkBinaryImageToMesh.ggo b/tools/clitkBinaryImageToMesh.ggo index 3381298..8c6c7e4 100644 --- a/tools/clitkBinaryImageToMesh.ggo +++ b/tools/clitkBinaryImageToMesh.ggo @@ -8,4 +8,5 @@ option "verbose" v "Verbose" flag off 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