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 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
|
using Kitware.VTK;
using System;
// input file is C:\VTK\Graphics\Testing\Tcl\HyperScalarBar.tcl
// output file is AVHyperScalarBar.cs
/// <summary>
/// The testing class derived from AVHyperScalarBar
/// </summary>
public class AVHyperScalarBarClass
{
/// <summary>
/// The main entry method called by the CSharp driver
/// </summary>
/// <param name="argv"></param>
public static void AVHyperScalarBar(String [] argv)
{
//Prefix Content is: ""
// Test the scalar bar actor using a logarithmic lookup table[]
//[]
VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
//[]
// generate tensors[]
ptLoad = new vtkPointLoad();
ptLoad.SetLoadValue((double)100.0);
ptLoad.SetSampleDimensions((int)20,(int)20,(int)20);
ptLoad.ComputeEffectiveStressOn();
ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
// Generate hyperstreamlines[]
s1 = new vtkHyperStreamline();
s1.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
s1.SetStartPosition((double)9,(double)9,(double)-9);
s1.IntegrateMinorEigenvector();
s1.SetMaximumPropagationDistance((double)18.0);
s1.SetIntegrationStepLength((double)0.1);
s1.SetStepLength((double)0.01);
s1.SetRadius((double)0.25);
s1.SetNumberOfSides((int)18);
s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
s1.Update();
// Map hyperstreamlines[]
lut = new vtkLogLookupTable();
lut.SetHueRange((double).6667,(double)0.0);
scalarBar = new vtkScalarBarActor();
scalarBar.SetLookupTable((vtkScalarsToColors)lut);
scalarBar.SetTitle((string)"Stress");
scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport();
scalarBar.GetPositionCoordinate().SetValue((double)0.1,(double)0.05);
scalarBar.SetOrientationToVertical();
scalarBar.SetWidth((double)0.1);
scalarBar.SetHeight((double)0.9);
scalarBar.SetPosition((double)0.01,(double)0.1);
scalarBar.SetLabelFormat((string)"%-#6.3f");
scalarBar.GetLabelTextProperty().SetColor((double)1,(double)0,(double)0);
scalarBar.GetTitleTextProperty().SetColor((double)1,(double)0,(double)0);
s1Mapper = vtkPolyDataMapper.New();
s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
ptLoad.Update();
//force update for scalar range[]
s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
s1Actor = new vtkActor();
s1Actor.SetMapper((vtkMapper)s1Mapper);
s2 = new vtkHyperStreamline();
s2.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
s2.SetStartPosition((double)-9,(double)-9,(double)-9);
s2.IntegrateMinorEigenvector();
s2.SetMaximumPropagationDistance((double)18.0);
s2.SetIntegrationStepLength((double)0.1);
s2.SetStepLength((double)0.01);
s2.SetRadius((double)0.25);
s2.SetNumberOfSides((int)18);
s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
s2.Update();
s2Mapper = vtkPolyDataMapper.New();
s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
s2Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
s2Actor = new vtkActor();
s2Actor.SetMapper((vtkMapper)s2Mapper);
s3 = new vtkHyperStreamline();
s3.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
s3.SetStartPosition((double)9,(double)-9,(double)-9);
s3.IntegrateMinorEigenvector();
s3.SetMaximumPropagationDistance((double)18.0);
s3.SetIntegrationStepLength((double)0.1);
s3.SetStepLength((double)0.01);
s3.SetRadius((double)0.25);
s3.SetNumberOfSides((int)18);
s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
s3.Update();
s3Mapper = vtkPolyDataMapper.New();
s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
s3Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
s3Actor = new vtkActor();
s3Actor.SetMapper((vtkMapper)s3Mapper);
s4 = new vtkHyperStreamline();
s4.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
s4.SetStartPosition((double)-9,(double)9,(double)-9);
s4.IntegrateMinorEigenvector();
s4.SetMaximumPropagationDistance((double)18.0);
s4.SetIntegrationStepLength((double)0.1);
s4.SetStepLength((double)0.01);
s4.SetRadius((double)0.25);
s4.SetNumberOfSides((int)18);
s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
s4.Update();
s4Mapper = vtkPolyDataMapper.New();
s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
s4Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
s4Actor = new vtkActor();
s4Actor.SetMapper((vtkMapper)s4Mapper);
// plane for context[]
//[]
g = new vtkImageDataGeometryFilter();
g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
g.Update();
//for scalar range[]
gm = vtkPolyDataMapper.New();
gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
gm.SetScalarRange((double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[0], (double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[1]);
ga = new vtkActor();
ga.SetMapper((vtkMapper)gm);
// 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);
// Create the rendering infrastructure[]
//[]
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer((vtkRenderer)ren1);
iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow((vtkRenderWindow)renWin);
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.AddActor2D((vtkProp)scalarBar);
ren1.AddActor((vtkProp)s1Actor);
ren1.AddActor((vtkProp)s2Actor);
ren1.AddActor((vtkProp)s3Actor);
ren1.AddActor((vtkProp)s4Actor);
ren1.AddActor((vtkProp)outlineActor);
ren1.AddActor((vtkProp)coneActor);
ren1.AddActor((vtkProp)ga);
ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
ren1.SetActiveCamera((vtkCamera)camera);
renWin.SetSize((int)300,(int)300);
renWin.Render();
// prevent the tk window from showing up then start the event loop[]
//deleteAllVTKObjects();
}
static string VTK_DATA_ROOT;
static int threshold;
static int VTK_INTEGRATE_BOTH_DIRECTIONS;
static vtkPointLoad ptLoad;
static vtkHyperStreamline s1;
static vtkLogLookupTable lut;
static vtkScalarBarActor scalarBar;
static vtkPolyDataMapper s1Mapper;
static vtkActor s1Actor;
static vtkHyperStreamline s2;
static vtkPolyDataMapper s2Mapper;
static vtkActor s2Actor;
static vtkHyperStreamline s3;
static vtkPolyDataMapper s3Mapper;
static vtkActor s3Actor;
static vtkHyperStreamline s4;
static vtkPolyDataMapper s4Mapper;
static vtkActor s4Actor;
static vtkImageDataGeometryFilter g;
static vtkPolyDataMapper gm;
static vtkActor ga;
static vtkOutlineFilter outline;
static vtkPolyDataMapper outlineMapper;
static vtkActor outlineActor;
static vtkConeSource coneSrc;
static vtkPolyDataMapper coneMap;
static vtkActor coneActor;
static vtkRenderer ren1;
static vtkRenderWindow renWin;
static vtkRenderWindowInteractor iren;
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 int GetVTK_INTEGRATE_BOTH_DIRECTIONS()
{
return VTK_INTEGRATE_BOTH_DIRECTIONS;
}
///<summary> A Set Method for Static Variables </summary>
public static void SetVTK_INTEGRATE_BOTH_DIRECTIONS(int toSet)
{
VTK_INTEGRATE_BOTH_DIRECTIONS = 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 vtkHyperStreamline Gets1()
{
return s1;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets1(vtkHyperStreamline toSet)
{
s1 = 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 vtkScalarBarActor GetscalarBar()
{
return scalarBar;
}
///<summary> A Set Method for Static Variables </summary>
public static void SetscalarBar(vtkScalarBarActor toSet)
{
scalarBar = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkPolyDataMapper Gets1Mapper()
{
return s1Mapper;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets1Mapper(vtkPolyDataMapper toSet)
{
s1Mapper = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkActor Gets1Actor()
{
return s1Actor;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets1Actor(vtkActor toSet)
{
s1Actor = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkHyperStreamline Gets2()
{
return s2;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets2(vtkHyperStreamline toSet)
{
s2 = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkPolyDataMapper Gets2Mapper()
{
return s2Mapper;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets2Mapper(vtkPolyDataMapper toSet)
{
s2Mapper = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkActor Gets2Actor()
{
return s2Actor;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets2Actor(vtkActor toSet)
{
s2Actor = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkHyperStreamline Gets3()
{
return s3;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets3(vtkHyperStreamline toSet)
{
s3 = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkPolyDataMapper Gets3Mapper()
{
return s3Mapper;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets3Mapper(vtkPolyDataMapper toSet)
{
s3Mapper = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkActor Gets3Actor()
{
return s3Actor;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets3Actor(vtkActor toSet)
{
s3Actor = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkHyperStreamline Gets4()
{
return s4;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets4(vtkHyperStreamline toSet)
{
s4 = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkPolyDataMapper Gets4Mapper()
{
return s4Mapper;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets4Mapper(vtkPolyDataMapper toSet)
{
s4Mapper = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkActor Gets4Actor()
{
return s4Actor;
}
///<summary> A Set Method for Static Variables </summary>
public static void Sets4Actor(vtkActor toSet)
{
s4Actor = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkImageDataGeometryFilter Getg()
{
return g;
}
///<summary> A Set Method for Static Variables </summary>
public static void Setg(vtkImageDataGeometryFilter toSet)
{
g = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkPolyDataMapper Getgm()
{
return gm;
}
///<summary> A Set Method for Static Variables </summary>
public static void Setgm(vtkPolyDataMapper toSet)
{
gm = toSet;
}
///<summary> A Get Method for Static Variables </summary>
public static vtkActor Getga()
{
return ga;
}
///<summary> A Set Method for Static Variables </summary>
public static void Setga(vtkActor toSet)
{
ga = 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 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 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(ptLoad!= null){ptLoad.Dispose();}
if(s1!= null){s1.Dispose();}
if(lut!= null){lut.Dispose();}
if(scalarBar!= null){scalarBar.Dispose();}
if(s1Mapper!= null){s1Mapper.Dispose();}
if(s1Actor!= null){s1Actor.Dispose();}
if(s2!= null){s2.Dispose();}
if(s2Mapper!= null){s2Mapper.Dispose();}
if(s2Actor!= null){s2Actor.Dispose();}
if(s3!= null){s3.Dispose();}
if(s3Mapper!= null){s3Mapper.Dispose();}
if(s3Actor!= null){s3Actor.Dispose();}
if(s4!= null){s4.Dispose();}
if(s4Mapper!= null){s4Mapper.Dispose();}
if(s4Actor!= null){s4Actor.Dispose();}
if(g!= null){g.Dispose();}
if(gm!= null){gm.Dispose();}
if(ga!= null){ga.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(ren1!= null){ren1.Dispose();}
if(renWin!= null){renWin.Dispose();}
if(iren!= null){iren.Dispose();}
if(camera!= null){camera.Dispose();}
}
}
//--- end of script --//
|