X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkBinaryImageToMesh.cxx;h=0eb5db618af80b6ee894010c86112ea763f500ea;hb=HEAD;hp=220d033946908c4d7f490d358693eb62eb9a307c;hpb=3abd767ea72e82f5f3de805917014a0ae2a71da9;p=clitk.git 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();