changeset 26:093a9e7e26df

Add more ignore tags, play more with the VTK code
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Mon, 01 Feb 2010 19:36:19 -0600
parents 6c6003bcad16
children 6e180e470f4b
files .hgignore vtk/terrain_test.cpp
diffstat 2 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore
+++ b/.hgignore
@@ -2,6 +2,8 @@
 html/*
 *.ogg
 *.ogv
+*.png
 *.matrix
 *.map
 *.o
+*build*
--- a/vtk/terrain_test.cpp
+++ b/vtk/terrain_test.cpp
@@ -25,21 +25,27 @@
 #include <vtkWindowToImageFilter.h>
 #include <vtkPNGWriter.h>
 
+#include <string>
+using std::string;
+
 typedef double (*Func3d)(double, double);
 
 void InitOffscreen(bool offscreen);
 vtkSmartPointer<vtkDelaunay2D> TriangulateTerrain(Func3d func);
-void PlotPoints(vtkSmartPointer<vtkDelaunay2D> delaunay, bool offscreen=true);
+
+void PlotPoints(vtkSmartPointer<vtkDelaunay2D> delaunay, 
+                bool offscreen=true,
+                const string& filename="vtkscreenshot.png");
 
 double F(double x, double y)
 {
-  return atan(x*y*y);
+  return atan(x*y*sin(y));
 }
 
 int main (int argc, char ** argv)
 {
 	auto delaunay = TriangulateTerrain(&F);	
-  PlotPoints(delaunay,false);
+  PlotPoints(delaunay,true);
 	return 0;
 }
 
@@ -87,11 +93,12 @@
   return delaunay;
 }
 
-void PlotPoints(vtkSmartPointer<vtkDelaunay2D> delaunay, bool offscreen)
+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() );
@@ -134,7 +141,7 @@
 	// 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()->SetPosition(1, 1, 1);
   ren1->GetActiveCamera()->SetParallelProjection(1);
 	ren1->AddActor(contActor);
   ren1->ResetCamera();
@@ -151,7 +158,7 @@
     windowToImageFilter->Update();
  
     vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
-    writer->SetFileName("screenshot.png");
+    writer->SetFileName(filename.c_str());
     writer->SetInput(windowToImageFilter->GetOutput());
     writer->Write();
   }