annotate src/vtkplot.cpp @ 43:8aea477c7cf8

Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Mon, 15 Mar 2010 21:10:18 -0600
parents 3f8311cbf602
children 4134a0f2423d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
eaa99e09607d Remove indentation due to namespace scope
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 38
diff changeset
1 #include "include/vtkplot.hpp"
eaa99e09607d Remove indentation due to namespace scope
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 38
diff changeset
2
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
3 #include <vtkPoints.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
4 #include <vtkPointData.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
5 #include <vtkDelaunay2D.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
6 #include <vtkLookupTable.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
7
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
8 #include <vtkPolyData.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
9 #include <vtkPolyDataNormals.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
10 #include <vtkPolyDataMapper.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
11
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
12 #include <vtkWarpScalar.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
13
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
14 #include <vtkCamera.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
15 #include <vtkActor.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
16 #include <vtkRenderWindow.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
17 #include <vtkRenderWindowInteractor.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
18 #include <vtkRenderer.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
19
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
20 #include <vtkInteractorStyleTerrain.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
21
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
22 #include <vtkSmartPointer.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
23 #include <vtkDoubleArray.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
24
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
25 #include <vtkGraphicsFactory.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
26 #include <vtkImagingFactory.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
27 #include <vtkWindowToImageFilter.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
28 #include <vtkPNGWriter.h>
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
30
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
31 #include <vtkSmartPointer.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
32 #include <vtkObjectFactory.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
33 #include <vtkSphereSource.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
34 #include <vtkPolyDataMapper.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
35 #include <vtkActor.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
36 #include <vtkRenderWindow.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
37 #include <vtkRenderer.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
38 #include <vtkRenderWindowInteractor.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
39 #include <vtkProgrammableFilter.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
40 #include <vtkCommand.h>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
41 #include <vtkCamera.h>
37
e87cb53283b4 imported patch vtk-patch
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 36
diff changeset
42
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
43 #include <string>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
44 #include <sstream>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
45 #include <iomanip>
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
46
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
47 #include <boost/function.hpp>
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
48
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
49 namespace kwantix{
37
e87cb53283b4 imported patch vtk-patch
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 36
diff changeset
50
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
51 template<typename RBF>
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
52 vtkplot::vtkplot(const interpolator<RBF>& u,
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
53 bool offscreen_in)
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
54 :hash(u.rbfs_hash), offscreen(offscreen)
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
55 {
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
56 if(u.thebvp -> get_domain() -> get_dimension() != 2)
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
57 {
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
58 badArgument exc;
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
59 exc.reason =
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
60 "Class vtkplot only works on interpolators whose "
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
61 "domain lies in R^2";
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
62 exc.line = __LINE__;
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
63 exc.file = __FILE__;
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
64 throw exc;
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
65 }
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
66
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
67 SetupPipeline(u, offscreen);
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
68 }
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
69
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
70 void vtkplot::set_offscreen(bool offscreen_in)
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
71 {
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
72 offscreen = offscreen_in;
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
73 InitOffscreen();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
74 }
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
75
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
76 template<typename RBF>
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
77 void vtkplot::update_values(const interp_values& vals_in)
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
78 {
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
79 vals = vals_in;
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
80 programmableFilter -> Modified();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
81 }
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
82
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
83 void vtkplot::trampoline(void* this_ptr)
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
84 {
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
85 vtkplot* instance = static_cast<vtkplot*>(this_ptr);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
86 instance -> AdjustPoints();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
87 }
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
88
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
89 template<typename RBF>
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
90 void vtkplot::SetupPipeline(const interpolator<RBF>& u)
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
91 {
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
92
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
93 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
94 vtkSmartPointer<vtkDoubleArray> scalars = vtkSmartPointer<vtkDoubleArray>::New();
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
95
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
96 for(auto i = u.thebvp -> get_domain() -> get_interior().begin();
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
97 i != u.thebvp -> get_domain() -> get_interior().end(); i++)
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
98 {
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
99 double z = 0;
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
100 vtkIdType idx = points -> InsertNextPoint( *i(1), *i(2), 0);
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
101 scalars -> InsertTuple(idx, &z);
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
102 }
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
103 for(auto i = u.thebvp -> get_domain() -> get_boundary().begin();
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
104 i != u.thebvp -> get_domain() -> get_boundary().end(); i++)
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
105 {
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
106 double z = 0;
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
107 vtkIdType idx = points -> InsertNextPoint( *i(1), *i(2), 0);
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
108 scalars -> InsertTuple(idx, &z);
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
109 }
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
110
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
111 //add the grid points to a polydata object
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
112 vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
113 polydata->SetPoints(points);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
114 polydata->GetPointData() -> SetScalars(scalars);
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
115
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
116 //triangulate the grid points
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
117 vtkSmartPointer<vtkDelaunay2D> delaunay
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
118 = vtkSmartPointer<vtkDelaunay2D>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
119 delaunay->SetInput(polydata);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
120 delaunay->Update();
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
121
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
122 InitOffscreen();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
123
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
124 programmableFilter = vtkSmartPointer<vtkProgrammableFilter>::New();
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
125 programmableFilter->SetInput(delaunay -> GetOutput());
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
126 programmableFilter->SetExecuteMethod(trampoline, this);
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
127
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
128 //Normals for Gourad shading
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
129 vtkSmartPointer<vtkPolyDataNormals> normals
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
130 = vtkSmartPointer<vtkPolyDataNormals>::New();
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
131 normals -> SetInputConnection(programmableFilter -> GetOutputPort() );
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
132 normals -> SetFeatureAngle(60);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
133
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
134 //Set the colours for the rendering
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
135 vtkSmartPointer<vtkLookupTable> lut
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
136 = vtkSmartPointer<vtkLookupTable>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
137 lut -> SetHueRange(0.66667, 0.0);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
138 lut -> SetNumberOfColors(256);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
139 lut -> SetRampToLinear();
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
140 lut -> Build();
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
141
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
142
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
143 // map the contours to graphical primitives
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
144 vtkSmartPointer<vtkPolyDataMapper> contMapper
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
145 = vtkSmartPointer<vtkPolyDataMapper>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
146 contMapper->SetInput(normals -> GetOutput() );
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
147 contMapper->SetScalarRange(0,1);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
148 contMapper->SetLookupTable(lut);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
149 contMapper->ImmediateModeRenderingOn();
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
150
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
151
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
152 // create an actor for the contours
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
153 vtkSmartPointer<vtkActor> contActor
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
154 = vtkSmartPointer<vtkActor>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
155 contActor->SetMapper(contMapper);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
156
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
157 // a renderer and render window
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
158 ren1 = vtkSmartPointer<vtkRenderer>::New();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
159 renWin = vtkSmartPointer<vtkRenderWindow>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
160 if(offscreen)
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
161 {
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
162 renWin->SetOffScreenRendering(1);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
163 }
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
164 renWin->AddRenderer(ren1);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
165
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
166 // an interactor
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
167 vtkSmartPointer<vtkRenderWindowInteractor> iren
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
168 = vtkSmartPointer<vtkRenderWindowInteractor>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
169 iren->SetRenderWindow(renWin);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
170
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
171 // Initialize must be called prior to creating timer events.
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
172 iren->Initialize();
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
173 iren->CreateRepeatingTimer(10);
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
174
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
175 // add the actors to the scene
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
176 ren1->SetBackground(0.0,0.0,0.0);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
177 ren1->GetActiveCamera()->SetViewUp(0,0,1);
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
178 ren1->GetActiveCamera()->SetPosition(1, 1, 1);
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
179 ren1->GetActiveCamera()->SetParallelProjection(1);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
180 ren1->AddActor(contActor);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
181 ren1->ResetCamera();
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
182
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
183 if(offscreen)
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
184 {
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
185 for(size_t i = 0; i < 1000; i++)
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
186 {
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
187 using namespace std;
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
188 string filename = "foo";
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
189 stringstream ss; string i_str;
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
190 ss << setw(4) << setfill('0') << i;
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
191 ss >> i_str;
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
192 filename += i_str + ".png";
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
193
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
194 // Write to file
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
195 vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
196 vtkSmartPointer<vtkWindowToImageFilter>::New();
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
197 windowToImageFilter->SetInput(renWin);
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
198 windowToImageFilter->Update();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
199
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
200 vtkSmartPointer<vtkPNGWriter> writer
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
201 = vtkSmartPointer<vtkPNGWriter>::New();
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
202 writer->SetFileName(filename.c_str() );
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
203 writer->SetInput(windowToImageFilter->GetOutput());
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
204 writer->Write();
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
205
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
206 programmableFilter -> Modified();
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
207 }
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
208 }
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
209 else
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
210 {
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
211
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
212 // render an image (lights and cameras are created automatically)
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
213 renWin->Render();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
214 //The style
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
215 vtkSmartPointer<vtkInteractorStyleTerrain> terrain_style
38
cd3bd9ea53c5 imported patch debug
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 37
diff changeset
216 = vtkSmartPointer<vtkInteractorStyleTerrain>::New();
29
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
217
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
218 // Set the style
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
219 iren -> SetInteractorStyle(terrain_style);
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
220
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
221 // begin mouse interaction
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
222 iren->Start();
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
223 }
24f3c4ed5c84 Halfway to replacing all namespaces with the kwantxi namespace
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
224 }
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
225
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
226 void vtkplot::InitOffscreen()
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
227 {
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
228 // Graphics Factory
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
229 vtkSmartPointer<vtkGraphicsFactory> graphics_factory
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
230 = vtkSmartPointer<vtkGraphicsFactory>::New();
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
231 graphics_factory->SetOffScreenOnlyMode( offscreen );
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
232 graphics_factory->SetUseMesaClasses( offscreen );
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
233
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
234 // Imaging Factory
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
235 vtkSmartPointer<vtkImagingFactory> imaging_factory
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
236 = vtkSmartPointer<vtkImagingFactory>::New();
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
237 imaging_factory->SetUseMesaClasses( offscreen );
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
238 }
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
239
43
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
240 void vtkplot::AdjustPoints()
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
241 {
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
242
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
243 if(vals.get_hash() != hash)
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
244 {
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
245 badArgument exc;
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
246 exc.reason =
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
247 "Can't update vtkplot with data from a different "
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
248 "interpolation domain.";
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
249 exc.line = __LINE__;
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
250 exc.file = __FILE__;
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
251 throw exc;
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
252 }
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
253
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
254 vtkPoints* inPts = programmableFilter->GetPolyDataInput()->GetPoints();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
255 vtkIdType numPts = inPts->GetNumberOfPoints();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
256 vtkSmartPointer<vtkPoints> newPts =
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
257 vtkSmartPointer<vtkPoints>::New();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
258 newPts->SetNumberOfPoints(numPts);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
259
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
260 vtkSmartPointer<vtkDoubleArray> newScalars
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
261 = vtkSmartPointer<vtkDoubleArray>::New();
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
262
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
263 for(vtkIdType i = 0; i < numPts; i++)
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
264 {
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
265 double p[3];
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
266 inPts -> GetPoint(i,p);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
267 p[2] = vals(i+1);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
268 newPts -> SetPoint(i,p);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
269 newScalars -> InsertTuple(i, &p[2]);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
270 }
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
271
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
272 programmableFilter->
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
273 GetPolyDataOutput()->CopyStructure(programmableFilter->GetPolyDataInput());
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
274
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
275 programmableFilter->GetPolyDataOutput()->SetPoints(newPts);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
276 programmableFilter
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
277 ->GetPolyDataOutput()
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
278 ->GetPointData() -> SetScalars(newScalars);
8aea477c7cf8 Continue implementation of vtkplot class, only missing to move the tail of the pipeline to the Plot function.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 42
diff changeset
279 }
42
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
280
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
281 } //namespace kwantix
3f8311cbf602 Setup initial class for vtkplot; cleanup interpolator to use C++1x's auto and untabify
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 41
diff changeset
282