File: AVSelectionLoop.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 (266 lines) | stat: -rw-r--r-- 8,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
using Kitware.VTK;
using System;
// input file is C:\VTK\Filtering\Testing\Tcl\SelectionLoop.tcl
// output file is AVSelectionLoop.cs
/// <summary>
/// The testing class derived from AVSelectionLoop
/// </summary>
public class AVSelectionLoopClass
{
  /// <summary>
  /// The main entry method called by the CSharp driver
  /// </summary>
  /// <param name="argv"></param>
  public static void AVSelectionLoop(String [] argv)
  {
  //Prefix Content is: ""
  
  //[]
  // Demonstrate the use of implicit selection loop as well as closest point[]
  // connectivity[]
  //[]
  // create pipeline[]
  //[]
  sphere = new vtkSphereSource();
  sphere.SetRadius((double)1);
  sphere.SetPhiResolution((int)100);
  sphere.SetThetaResolution((int)100);
  selectionPoints = new vtkPoints();
  selectionPoints.InsertPoint((int)0,(double)0.07325,(double)0.8417,(double)0.5612);
  selectionPoints.InsertPoint((int)1,(double)0.07244,(double)0.6568,(double)0.7450);
  selectionPoints.InsertPoint((int)2,(double)0.1727,(double)0.4597,(double)0.8850);
  selectionPoints.InsertPoint((int)3,(double)0.3265,(double)0.6054,(double)0.7309);
  selectionPoints.InsertPoint((int)4,(double)0.5722,(double)0.5848,(double)0.5927);
  selectionPoints.InsertPoint((int)5,(double)0.4305,(double)0.8138,(double)0.4189);
  loop = new vtkImplicitSelectionLoop();
  loop.SetLoop((vtkPoints)selectionPoints);
  extract = new vtkExtractGeometry();
  extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
  extract.SetImplicitFunction((vtkImplicitFunction)loop);
  connect = new vtkConnectivityFilter();
  connect.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort());
  connect.SetExtractionModeToClosestPointRegion();
  connect.SetClosestPoint((double)selectionPoints.GetPoint((int)0)[0], (double)selectionPoints.GetPoint((int)0)[1],(double)selectionPoints.GetPoint((int)0)[2]);
  clipMapper = new vtkDataSetMapper();
  clipMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort());
  backProp = new vtkProperty();
  backProp.SetDiffuseColor((double) 1.0000, 0.3882, 0.2784 );
  clipActor = new vtkActor();
  clipActor.SetMapper((vtkMapper)clipMapper);
  clipActor.GetProperty().SetColor((double) 0.2000, 0.6300, 0.7900 );
  clipActor.SetBackfaceProperty((vtkProperty)backProp);
  // Create graphics stuff[]
  //[]
  ren1 = vtkRenderer.New();
  renWin = vtkRenderWindow.New();
  renWin.AddRenderer((vtkRenderer)ren1);
  iren = new vtkRenderWindowInteractor();
  iren.SetRenderWindow((vtkRenderWindow)renWin);
  // Add the actors to the renderer, set the background and size[]
  //[]
  ren1.AddActor((vtkProp)clipActor);
  ren1.SetBackground((double)1,(double)1,(double)1);
  ren1.ResetCamera();
  ren1.GetActiveCamera().Azimuth((double)30);
  ren1.GetActiveCamera().Elevation((double)30);
  ren1.GetActiveCamera().Dolly((double)1.2);
  ren1.ResetCameraClippingRange();
  renWin.SetSize((int)400,(int)400);
  renWin.Render();
  // render the image[]
  //[]
  // prevent the tk window from showing up then start the event loop[]
  
//deleteAllVTKObjects();
  }
static string VTK_DATA_ROOT;
static int threshold;
static vtkSphereSource sphere;
static vtkPoints selectionPoints;
static vtkImplicitSelectionLoop loop;
static vtkExtractGeometry extract;
static vtkConnectivityFilter connect;
static vtkDataSetMapper clipMapper;
static vtkProperty backProp;
static vtkActor clipActor;
static vtkRenderer ren1;
static vtkRenderWindow renWin;
static vtkRenderWindowInteractor iren;


        ///<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 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 vtkPoints GetselectionPoints()
        {
            return selectionPoints;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetselectionPoints(vtkPoints toSet)
        {
            selectionPoints = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkImplicitSelectionLoop Getloop()
        {
            return loop;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setloop(vtkImplicitSelectionLoop toSet)
        {
            loop = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkExtractGeometry Getextract()
        {
            return extract;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setextract(vtkExtractGeometry toSet)
        {
            extract = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkConnectivityFilter Getconnect()
        {
            return connect;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void Setconnect(vtkConnectivityFilter toSet)
        {
            connect = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkDataSetMapper GetclipMapper()
        {
            return clipMapper;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetclipMapper(vtkDataSetMapper toSet)
        {
            clipMapper = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkProperty GetbackProp()
        {
            return backProp;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetbackProp(vtkProperty toSet)
        {
            backProp = toSet;
        }
        
        ///<summary> A Get Method for Static Variables </summary>
        public static vtkActor GetclipActor()
        {
            return clipActor;
        }
        
        ///<summary> A Set Method for Static Variables </summary>
        public static void SetclipActor(vtkActor toSet)
        {
            clipActor = 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>Deletes all static objects created</summary>
  public static void deleteAllVTKObjects()
  {
  	//clean up vtk objects
  	if(sphere!= null){sphere.Dispose();}
  	if(selectionPoints!= null){selectionPoints.Dispose();}
  	if(loop!= null){loop.Dispose();}
  	if(extract!= null){extract.Dispose();}
  	if(connect!= null){connect.Dispose();}
  	if(clipMapper!= null){clipMapper.Dispose();}
  	if(backProp!= null){backProp.Dispose();}
  	if(clipActor!= null){clipActor.Dispose();}
  	if(ren1!= null){ren1.Dispose();}
  	if(renWin!= null){renWin.Dispose();}
  	if(iren!= null){iren.Dispose();}
  }

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