changeset 55:afc0c104df35

Remove terrain_test sample VTK code
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Mon, 26 Apr 2010 07:03:35 -0500
parents ac5c22eb647c
children 239ae45e615d
files src/terrain_test.cpp src/terrain_test.tcl
diffstat 2 files changed, 0 insertions(+), 274 deletions(-) [+]
line wrap: on
line diff
deleted file mode 100644
--- a/src/terrain_test.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-#include <vtkPoints.h>
-#include <vtkPointData.h>
-#include <vtkDelaunay2D.h>
-#include <vtkLookupTable.h>
-
-#include <vtkPolyData.h>
-#include <vtkPolyDataNormals.h>
-#include <vtkPolyDataMapper.h>
-
-#include <vtkWarpScalar.h>
-
-#include <vtkCamera.h>
-#include <vtkActor.h>
-#include <vtkRenderWindow.h>
-#include <vtkRenderWindowInteractor.h>
-#include <vtkRenderer.h>
-
-#include <vtkInteractorStyleTerrain.h>
-
-#include <vtkSmartPointer.h>
-#include <vtkDoubleArray.h>
-
-#include <vtkGraphicsFactory.h>
-#include <vtkImagingFactory.h>
-#include <vtkWindowToImageFilter.h>
-#include <vtkPNGWriter.h>
-
-#include <string>
-using std::string;
-
-#include "include/linalg.hpp"
-
-typedef double (*Func3d)(double, double);
-
-void InitOffscreen(bool offscreen);
-vtkSmartPointer<vtkDelaunay2D> TriangulateTerrain(Func3d func);
-
-void PlotPoints(vtkSmartPointer<vtkDelaunay2D> delaunay, 
-                bool offscreen=true,
-                const string& filename="vtkscreenshot.png");
-
-double F(double x, double y)
-{
-  return atan(x*y*sin(y));
-}
-
-int main (int argc, char ** argv)
-{
-	auto delaunay = TriangulateTerrain(&F);	
-  PlotPoints(delaunay,true);
-	return 0;
-}
-
-void InitOffscreen(bool offscreen)
-{
-  // Graphics Factory
-  vtkSmartPointer<vtkGraphicsFactory> graphics_factory
-    = vtkGraphicsFactory::New();
-  graphics_factory->SetOffScreenOnlyMode( offscreen );
-  graphics_factory->SetUseMesaClasses( offscreen );
-
-  // Imaging Factory
-  vtkSmartPointer<vtkImagingFactory>  imaging_factory
-    = vtkImagingFactory::New();
-  imaging_factory->SetUseMesaClasses( offscreen );
-}
-
-vtkSmartPointer<vtkDelaunay2D> TriangulateTerrain(Func3d func)
-{
-
-	vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
-  vtkSmartPointer<vtkDoubleArray> scalars = vtkSmartPointer<vtkDoubleArray>::New();
- 
-	unsigned int GridSize = 50;
-	for(double x = -3; x < 3; x += 6.0/GridSize)
-	{
-		for(double y = -3; y < 3; y += 6.0/GridSize)
-		{
-      double z = func(x,y);
-			vtkIdType idx = points->InsertNextPoint(x, y, z);
-      scalars -> InsertTuple(idx, &z);
-		}
-	}
- 
-	//add the grid points to a polydata object
-	vtkSmartPointer<vtkPolyData> polydata = vtkPolyData::New();
-	polydata->SetPoints(points);
-  polydata->GetPointData() -> SetScalars(scalars);
- 
-	//triangulate the grid points
-	vtkSmartPointer<vtkDelaunay2D> delaunay = vtkDelaunay2D::New();
-	delaunay->SetInput(polydata);
-	delaunay->Update();
-
-  return delaunay;
-}
-
-void PlotPoints(vtkSmartPointer<vtkDelaunay2D> delaunay, 
-                bool offscreen, 
-                const string& filename)
-{
-  InitOffscreen(offscreen);
-
-  //Normals for Gourad shading
-  vtkSmartPointer<vtkPolyDataNormals> normals = vtkPolyDataNormals::New();
-  normals -> SetInputConnection(delaunay ->GetOutputPort() );
-  normals -> SetFeatureAngle(60);
-
-  //Set the colours for the rendering
-  vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
-  lut -> SetHueRange(0.66667, 0.0);
-  lut -> SetNumberOfColors(256);
-  lut -> SetRampToLinear();
-  lut -> Build();
-
-  
-	// map the contours to graphical primitives
-	vtkSmartPointer<vtkPolyDataMapper> contMapper = vtkPolyDataMapper::New();
-  contMapper->SetInput(normals -> GetOutput() );
-  contMapper->SetScalarRange(0,1);
-  contMapper->SetLookupTable(lut);
-  contMapper->ImmediateModeRenderingOn();
-
- 
-  // create an actor for the contours
-	vtkSmartPointer<vtkActor> contActor = vtkActor::New();
-	contActor->SetMapper(contMapper);
- 
-  // a renderer and render window
-	vtkSmartPointer<vtkRenderer> ren1 = vtkRenderer::New();
-	vtkSmartPointer<vtkRenderWindow> renWin = vtkRenderWindow::New();
-  if(offscreen)
-  {
-    renWin->SetOffScreenRendering(1);
-  }
-	renWin->AddRenderer(ren1);
-
-  // an interactor
-  vtkSmartPointer<vtkRenderWindowInteractor> iren 
-    = vtkRenderWindowInteractor::New();
-  iren->SetRenderWindow(renWin);  
-
-	// add the actors to the scene
-	ren1->SetBackground(0.0,0.0,0.0);
-  ren1->GetActiveCamera()->SetViewUp(0,0,1);
-  ren1->GetActiveCamera()->SetPosition(1, 1, 1);
-  ren1->GetActiveCamera()->SetParallelProjection(1);
-	ren1->AddActor(contActor);
-  ren1->ResetCamera();
- 
-  // render an image (lights and cameras are created automatically)
-	renWin->Render();
-
-  if(offscreen)
-  {
-    // Write to file
-    vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter = 
-      vtkSmartPointer<vtkWindowToImageFilter>::New();
-    windowToImageFilter->SetInput(renWin);
-    windowToImageFilter->Update();
- 
-    vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
-    writer->SetFileName(filename.c_str());
-    writer->SetInput(windowToImageFilter->GetOutput());
-    writer->Write();
-  }
-  else
-  {
-    //The style
-    vtkSmartPointer<vtkInteractorStyleTerrain> terrain_style 
-      = vtkInteractorStyleTerrain::New();
- 
-    // Set the style
-    iren -> SetInteractorStyle(terrain_style);
-  
-    // begin mouse interaction
-    iren->Start(); 
-  }
-}
deleted file mode 100644
--- a/src/terrain_test.tcl
+++ /dev/null
@@ -1,95 +0,0 @@
-package require vtk
-package require vtkinteraction
-
-set Scale 5
-vtkLookupTable lut
-  lut SetHueRange 0.6 0
-  lut SetSaturationRange 1.0 0
-  lut SetValueRange 0.5 1.0
-
-set VTK_DATA_ROOT /usr/share/VTKData
-
-vtkDEMReader demModel
-  demModel SetFileName $VTK_DATA_ROOT/Data/SainteHelens.dem
-  demModel Update
-
-demModel Print
-
-set lo [expr $Scale * [lindex [demModel GetElevationBounds] 0]]
-set hi [expr $Scale * [lindex [demModel GetElevationBounds] 1]]
-
-vtkLODActor demActor
-
-# create a pipeline for each lod mapper
-vtkImageShrink3D shrink16
-  shrink16 SetShrinkFactors 16 16 1
-  shrink16 SetInputConnection [demModel GetOutputPort]
-  shrink16 AveragingOn
-
-vtkImageDataGeometryFilter geom16
-  geom16 SetInputConnection [shrink16 GetOutputPort]
-  geom16 ReleaseDataFlagOn
-
-vtkWarpScalar warp16
-  warp16 SetInputConnection [geom16 GetOutputPort]
-  warp16 SetNormal 0 0 1
-  warp16 UseNormalOn
-  warp16 SetScaleFactor $Scale
-  warp16 ReleaseDataFlagOn
-
-vtkElevationFilter elevation16
-  elevation16 SetInputConnection [warp16 GetOutputPort]
-  elevation16 SetLowPoint 0 0 $lo
-  elevation16 SetHighPoint 0 0 $hi
-  eval elevation16 SetScalarRange $lo $hi
-  elevation16 ReleaseDataFlagOn
-
-vtkPolyDataNormals normals16
-  normals16 SetInput [elevation16 GetPolyDataOutput]
-  normals16 SetFeatureAngle 60
-  normals16 ConsistencyOff
-  normals16 SplittingOff
-  normals16 ReleaseDataFlagOn
-
-vtkPolyDataMapper demMapper16
-  demMapper16 SetInputConnection [normals16 GetOutputPort]
-  eval demMapper16 SetScalarRange $lo $hi
-  demMapper16 SetLookupTable lut
-  demMapper16 ImmediateModeRenderingOn
-
-demMapper16 Update
-demActor AddLODMapper demMapper16
-
-# Create the RenderWindow, Renderer and both Actors
-#
-vtkRenderer ren1
-vtkRenderWindow renWin
-    renWin AddRenderer ren1
-vtkRenderWindowInteractor iren
-    iren SetRenderWindow renWin
-vtkInteractorStyleTerrain t
-iren SetInteractorStyle t
- 
-# Add the actors to the renderer, set the background and size
-#
-ren1 AddActor demActor
-ren1 SetBackground .4 .4 .4
-
-iren AddObserver UserEvent {wm deiconify .vtkInteract}
-iren SetDesiredUpdateRate 1
-
-wm withdraw .
-proc TkCheckAbort {} {
-  set foo [renWin GetEventPending]
-    if {$foo != 0} {renWin SetAbortRender 1}
-}
-renWin AddObserver AbortCheckEvent {TkCheckAbort}
-
-[ren1 GetActiveCamera] SetViewUp 0 0 1
-[ren1 GetActiveCamera] SetPosition -99900 -21354 131801
-[ren1 GetActiveCamera] SetFocalPoint 41461 41461 2815
-ren1 ResetCamera
-[ren1 GetActiveCamera] Dolly 1.2
-ren1 ResetCameraClippingRange
-
-renWin Render