File: AVTenEllip.cs

package info (click to toggle)
activiz.net 1%3A1.0~git20111214-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,280 kB
  • ctags: 5,957
  • sloc: cs: 28,767; python: 915; cpp: 130; makefile: 35; sh: 11
file content (389 lines) | stat: -rw-r--r-- 12,796 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
using Kitware.VTK;
using System;
// input file is C:\VTK\Graphics\Testing\Tcl\TenEllip.tcl
// output file is AVTenEllip.cs
/// <summary>
/// The testing class derived from AVTenEllip
/// </summary>
public class AVTenEllipClass
{
  /// <summary>
  /// The main entry method called by the CSharp driver
  /// </summary>
  /// <param name="argv"></param>
  public static void AVTenEllip(String [] argv)
  {
  //Prefix Content is: ""
  
  // create tensor ellipsoids[]
  // Create the RenderWindow, Renderer and interactive renderer[]
  //[]
  ren1 = vtkRenderer.New();
  renWin = vtkRenderWindow.New();
  renWin.AddRenderer((vtkRenderer)ren1);
  iren = new vtkRenderWindowInteractor();
  iren.SetRenderWindow((vtkRenderWindow)renWin);
  //[]
  // Create tensor ellipsoids[]
  //[]
  // generate tensors[]
  ptLoad = new vtkPointLoad();
  ptLoad.SetLoadValue((double)100.0);
  ptLoad.SetSampleDimensions((int)6,(int)6,(int)6);
  ptLoad.ComputeEffectiveStressOn();
  ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
  // extract plane of data[]
  plane = new vtkImageDataGeometryFilter();
  plane.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
  plane.SetExtent((int)2,(int)2,(int)0,(int)99,(int)0,(int)99);
  // Generate ellipsoids[]
  sphere = new vtkSphereSource();
  sphere.SetThetaResolution((int)8);
  sphere.SetPhiResolution((int)8);
  ellipsoids = new vtkTensorGlyph();
  ellipsoids.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
  ellipsoids.SetSourceConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
  ellipsoids.SetScaleFactor((double)10);
  ellipsoids.ClampScalingOn();
  ellipNormals = new vtkPolyDataNormals();
  ellipNormals.SetInputConnection((vtkAlgorithmOutput)ellipsoids.GetOutputPort());
  // Map contour[]
  lut = new vtkLogLookupTable();
  lut.SetHueRange((double).6667,(double)0.0);
  ellipMapper = vtkPolyDataMapper.New();
  ellipMapper.SetInputConnection((vtkAlgorithmOutput)ellipNormals.GetOutputPort());
  ellipMapper.SetLookupTable((vtkScalarsToColors)lut);
  plane.Update();
  //force update for scalar range[]
  ellipMapper.SetScalarRange((double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[1]);
  ellipActor = new vtkActor();
  ellipActor.SetMapper((vtkMapper)ellipMapper);
  //[]
  // Create outline around data[]
  //[]
  outline = new vtkOutlineFilter();
  outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
  outlineMapper = vtkPolyDataMapper.New();
  outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
  outlineActor = new vtkActor();
  outlineActor.SetMapper((vtkMapper)outlineMapper);
  outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
  //[]
  // Create cone indicating application of load[]
  //[]
  coneSrc = new vtkConeSource();
  coneSrc.SetRadius((double).5);
  coneSrc.SetHeight((double)2);
  coneMap = vtkPolyDataMapper.New();
  coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
  coneActor = new vtkActor();
  coneActor.SetMapper((vtkMapper)coneMap);
  coneActor.SetPosition((double)0,(double)0,(double)11);
  coneActor.RotateY((double)90);
  coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
  camera = new vtkCamera();
  camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
  camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
  camera.SetViewAngle((double)24.4617);
  camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
  camera.SetClippingRange((double)1,(double)100);
  ren1.AddActor((vtkProp)ellipActor);
  ren1.AddActor((vtkProp)outlineActor);
  ren1.AddActor((vtkProp)coneActor);
  ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
  ren1.SetActiveCamera((vtkCamera)camera);
  renWin.SetSize((int)400,(int)400);
  renWin.Render();
  // prevent the tk window from showing up then start the event loop[]
  
//deleteAllVTKObjects();
  }
static string VTK_DATA_ROOT;
static int threshold;
static vtkRenderer ren1;
static vtkRenderWindow renWin;
static vtkRenderWindowInteractor iren;
static vtkPointLoad ptLoad;
static vtkImageDataGeometryFilter plane;
static vtkSphereSource sphere;
static vtkTensorGlyph ellipsoids;
static vtkPolyDataNormals ellipNormals;
static vtkLogLookupTable lut;
static vtkPolyDataMapper ellipMapper;
static vtkActor ellipActor;
static vtkOutlineFilter outline;
static vtkPolyDataMapper outlineMapper;
static vtkActor outlineActor;
static vtkConeSource coneSrc;
static vtkPolyDataMapper coneMap;
static vtkActor coneActor;
static vtkCamera camera;


        ///<summary> A Get Method for Static Variables </summary>
        public static string GetVTK_DATA_ROOT()
        {
            return VTK_DATA_ROOT;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetVTK_DATA_ROOT(string toSet)
        {
            VTK_DATA_ROOT = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static int Getthreshold()
        {
            return threshold;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setthreshold(int toSet)
        {
            threshold = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkRenderer Getren1()
        {
            return ren1;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setren1(vtkRenderer toSet)
        {
            ren1 = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkRenderWindow GetrenWin()
        {
            return renWin;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetrenWin(vtkRenderWindow toSet)
        {
            renWin = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkRenderWindowInteractor Getiren()
        {
            return iren;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setiren(vtkRenderWindowInteractor toSet)
        {
            iren = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkPointLoad GetptLoad()
        {
            return ptLoad;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetptLoad(vtkPointLoad toSet)
        {
            ptLoad = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkImageDataGeometryFilter Getplane()
        {
            return plane;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setplane(vtkImageDataGeometryFilter toSet)
        {
            plane = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkSphereSource Getsphere()
        {
            return sphere;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setsphere(vtkSphereSource toSet)
        {
            sphere = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkTensorGlyph Getellipsoids()
        {
            return ellipsoids;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setellipsoids(vtkTensorGlyph toSet)
        {
            ellipsoids = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkPolyDataNormals GetellipNormals()
        {
            return ellipNormals;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetellipNormals(vtkPolyDataNormals toSet)
        {
            ellipNormals = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkLogLookupTable Getlut()
        {
            return lut;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setlut(vtkLogLookupTable toSet)
        {
            lut = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkPolyDataMapper GetellipMapper()
        {
            return ellipMapper;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetellipMapper(vtkPolyDataMapper toSet)
        {
            ellipMapper = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkActor GetellipActor()
        {
            return ellipActor;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetellipActor(vtkActor toSet)
        {
            ellipActor = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkOutlineFilter Getoutline()
        {
            return outline;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setoutline(vtkOutlineFilter toSet)
        {
            outline = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkPolyDataMapper GetoutlineMapper()
        {
            return outlineMapper;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetoutlineMapper(vtkPolyDataMapper toSet)
        {
            outlineMapper = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkActor GetoutlineActor()
        {
            return outlineActor;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetoutlineActor(vtkActor toSet)
        {
            outlineActor = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkConeSource GetconeSrc()
        {
            return coneSrc;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetconeSrc(vtkConeSource toSet)
        {
            coneSrc = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkPolyDataMapper GetconeMap()
        {
            return coneMap;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetconeMap(vtkPolyDataMapper toSet)
        {
            coneMap = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkActor GetconeActor()
        {
            return coneActor;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetconeActor(vtkActor toSet)
        {
            coneActor = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkCamera Getcamera()
        {
            return camera;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setcamera(vtkCamera toSet)
        {
            camera = toSet;
        }
        
  ///<summary>Deletes all static objects created</summary>
  public static void deleteAllVTKObjects()
  {
  	//clean up vtk objects
  	if(ren1!= null){ren1.Dispose();}
  	if(renWin!= null){renWin.Dispose();}
  	if(iren!= null){iren.Dispose();}
  	if(ptLoad!= null){ptLoad.Dispose();}
  	if(plane!= null){plane.Dispose();}
  	if(sphere!= null){sphere.Dispose();}
  	if(ellipsoids!= null){ellipsoids.Dispose();}
  	if(ellipNormals!= null){ellipNormals.Dispose();}
  	if(lut!= null){lut.Dispose();}
  	if(ellipMapper!= null){ellipMapper.Dispose();}
  	if(ellipActor!= null){ellipActor.Dispose();}
  	if(outline!= null){outline.Dispose();}
  	if(outlineMapper!= null){outlineMapper.Dispose();}
  	if(outlineActor!= null){outlineActor.Dispose();}
  	if(coneSrc!= null){coneSrc.Dispose();}
  	if(coneMap!= null){coneMap.Dispose();}
  	if(coneActor!= null){coneActor.Dispose();}
  	if(camera!= null){camera.Dispose();}
  }

}
//--- end of script --//