[vtkusers] vtkContourFilter and vtkElevationFilter for DTM
AFANGNIKE
afangnik at dromadaire.com
Mon Jun 18 08:48:14 EDT 2001
Hi,
This is just a traduction of tcl example i found, it's work well (win Console
application).
// ***************************************************
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkPolyDataReader *reader = vtkPolyDataReader::New() ;
reader->SetFileName("C:\\Langage\\Bc3\\Bcprog\\Vtk\\vtk32\\vtk32\\Data\\dtm.vtk
) ;
vtkElevationFilter *elevation = vtkElevationFilter::New() ;
elevation->SetInput(reader->GetOutput()) ;
elevation->SetLowPoint(0,0,-100) ;
elevation->SetHighPoint(0,0,700) ;
elevation->SetScalarRange(0, 1000) ;
vtkLookupTable *lut = vtkLookupTable::New() ;
lut->SetHueRange(0.6667, 0) ;
lut->SetSaturationRange(1.0, 1.0) ;
lut->SetValueRange(1.0, 1.0) ;
lut->SetAlphaRange(1.0, 1.0) ;
lut->SetNumberOfColors(256) ;
lut->Build() ;
vtkContourFilter *iso = vtkContourFilter::New() ;
iso->SetInput(elevation->GetOutput()) ;
iso->GenerateValues(100, 0 , 1150) ;
// 100 and 1150 is relative to my dtm.vtk data : min and max altitude
vtkDataSetMapper *ugridMapper = vtkDataSetMapper::New();
ugridMapper->SetInput(iso->GetOutput());
ugridMapper->ImmediateModeRenderingOn();
ugridMapper->SetScalarRange(0, 500) ;
ugridMapper->SetLookupTable(lut) ;
vtkActor *ugridActor = vtkActor::New();
ugridActor->SetMapper(ugridMapper);
ugridActor->GetProperty()->SetColor(0,0,0);
ugridActor->AddPosition(0,0.001,0);
vtkActor *wireActor = vtkActor::New();
wireActor->SetMapper(ugridMapper);
wireActor->GetProperty()->SetRepresentationToWireframe();
wireActor->GetProperty()->SetColor(0.5,0.5,0.5);
renderer->AddActor(ugridActor);
renderer->AddActor(wireActor);
renderer->SetBackground(0.4,0.4,0.4);
renWin->SetSize(600,600);
// interact with data
renWin->Render();
iren->Start();
renWin->SetFileName("Triangle.ppm") ;
renWin->SaveImageAsPPM() ;
// Clean up
renderer->Delete();
renWin->Delete();
iren->Delete();
ugrid->Delete();
ugridMapper->Delete();
ugridActor->Delete();
// ***************************************************
By By
Camille From Bordeaux
______________________________________________
Ce courrier a été envoyé depuis http://www.dromadaire.com .
Plus de 2500 cartes virtuelles à envoyer !
More information about the vtkusers
mailing list