[vtkusers] Decimation of Mesh

mail.ru patalog at mail.ru
Thu Mar 4 00:32:05 EST 2004


Hello Hamp,

[]

HD> Hi
HD>       I do not know Tcl. Can somebody provide me the
HD> example deciFran.tcl in C++. It provides the
HD> decimation of meshes and located in
HD> VTK/Examples/VisualizationAlgorithms/Tcl directory. 

char* vtk_data_root = getenv("VTK_DATA_ROOT");
if (!vtk_data_root)
      return;

std::string path(vtk_data_root);
path += "/fran_cut.vtk";
vtkPolyDataReader* fran = vtkPolyDataReader::New();
fran->SetFileName(path.c_str());

vtkDecimatePro* deci = vtkDecimatePro::New();
deci->SetInput(fran->GetOutput());
deci->SetTargetReduction(0.9);
deci->PreserveTopologyOn();

vtkPolyDataNormals* normals = vtkPolyDataNormals::New();
normals->SetInput(deci->GetOutput() /*fran->GetOutput() in original example. Why?*/);
normals->FlipNormalsOn();

vtkPolyDataMapper* franMapper  = vtkPolyDataMapper::New();
franMapper->SetInput(normals->GetOutput());

vtkActor* franActor = vtkActor::New();
franActor->SetMapper(franMapper);
franActor->GetProperty()->SetColor(1.0, 0.49, 0.25);

vtkRenderer* ren1 = vtkRenderer::New();
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);

ren1->AddActor(franActor);
ren1->SetBackground(1, 1, 1);
renWin->SetSize(250, 250);

vtkCamera* cam1 = vtkCamera::New();
cam1->SetClippingRange(0.0475572, 2.37786);
cam1->SetFocalPoint(0.052665, -0.129454, -0.0573973);
cam1->SetPosition(0.327637, -0.116299, -0.256418);
cam1->SetViewUp(-0.0225386, 0.999137, 0.034901);
ren1->SetActiveCamera(cam1);

iren->Initialize();
renWin->Render();
iren->Start();

//clean up
fran->Delete();
deci->Delete();
normals->Delete();
franMapper->Delete();
franActor->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
cam1->Delete();

-- 
Best regards,
 Dmitry Gurulev                           mailto:patalog at mail.ru




More information about the vtkusers mailing list