comparison src/vtkplot.cpp @ 41:834f8e778a65

Setup initial interface to vtkplot
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Fri, 12 Mar 2010 09:24:31 -0600
parents eaa99e09607d
children 3f8311cbf602
comparison
equal deleted inserted replaced
40:eaa99e09607d 41:834f8e778a65
128 vtkSmartPointer<vtkDelaunay2D> TriangulateTerrain(Func3d func); 128 vtkSmartPointer<vtkDelaunay2D> TriangulateTerrain(Func3d func);
129 129
130 void PlotPoints(vtkSmartPointer<vtkDelaunay2D> delaunay, 130 void PlotPoints(vtkSmartPointer<vtkDelaunay2D> delaunay,
131 bool offscreen); 131 bool offscreen);
132 132
133 //int main ()
134 //{
135 // TriangulateTerrain(&F);
136 // return 0;
137 //}
138
139 void InitOffscreen(bool offscreen) 133 void InitOffscreen(bool offscreen)
140 { 134 {
141 // Graphics Factory 135 // Graphics Factory
142 vtkSmartPointer<vtkGraphicsFactory> graphics_factory 136 vtkSmartPointer<vtkGraphicsFactory> graphics_factory
143 = vtkSmartPointer<vtkGraphicsFactory>::New(); 137 = vtkSmartPointer<vtkGraphicsFactory>::New();
148 vtkSmartPointer<vtkImagingFactory> imaging_factory 142 vtkSmartPointer<vtkImagingFactory> imaging_factory
149 = vtkSmartPointer<vtkImagingFactory>::New(); 143 = vtkSmartPointer<vtkImagingFactory>::New();
150 imaging_factory->SetUseMesaClasses( offscreen ); 144 imaging_factory->SetUseMesaClasses( offscreen );
151 } 145 }
152 146
153 double sign(double x)
154 {
155 if(x > 0)
156 return 1;
157 else
158 return -1;
159 }
160
161 vtkSmartPointer<vtkDelaunay2D> TriangulateTerrain(Func3d func) 147 vtkSmartPointer<vtkDelaunay2D> TriangulateTerrain(Func3d func)
162 { 148 {
163 149
164 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); 150 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
165 vtkSmartPointer<vtkDoubleArray> scalars = vtkSmartPointer<vtkDoubleArray>::New(); 151 vtkSmartPointer<vtkDoubleArray> scalars = vtkSmartPointer<vtkDoubleArray>::New();
167 153
168 for(double x = -3; x < 3; x += 6.0/GridSize) 154 for(double x = -3; x < 3; x += 6.0/GridSize)
169 { 155 {
170 for(double y = -3; y < 3; y += 6.0/GridSize) 156 for(double y = -3; y < 3; y += 6.0/GridSize)
171 { 157 {
172 double r = sign(y)*sqrt(9-y*y)*sqrt(9-x*x)/3; 158 double r = sqrt(9-y*y)*sqrt(9-x*x)/3;
173 double z = func(x,r,0); 159 double z = func(x,r,0);
174 vtkIdType idx = points->InsertNextPoint(x,r, z); 160 vtkIdType idx = points->InsertNextPoint(x,r, z);
175 scalars -> InsertTuple(idx, &z); 161 scalars -> InsertTuple(idx, &z);
176 } 162 }
177 } 163 }