本文整理汇总了C#中vtkRenderWindow.Render方法的典型用法代码示例。如果您正苦于以下问题:C# vtkRenderWindow.Render方法的具体用法?C# vtkRenderWindow.Render怎么用?C# vtkRenderWindow.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtkRenderWindow
的用法示例。
在下文中一共展示了vtkRenderWindow.Render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
string VTK_DATA_ROOT = "C:/Program Files/VTKData";
// Create a vtkBYUReader and read in a data set.
vtkBYUReader fohe = new vtkBYUReader();
fohe.SetGeometryFileName(VTK_DATA_ROOT + "/Data/teapot.g");
// Create a vtkPolyDataNormals filter to calculate the normals of the
// data set.
vtkPolyDataNormals normals = new vtkPolyDataNormals();
normals.SetInputConnection(fohe.GetOutputPort());
// Set up the associated mapper and actor.
vtkPolyDataMapper foheMapper = new vtkPolyDataMapper();
foheMapper.SetInputConnection(normals.GetOutputPort());
vtkLODActor foheActor = new vtkLODActor();
foheActor.SetMapper(foheMapper);
// Create a vtkOutlineFilter to draw the bounding box of the data set.
// Also create the associated mapper and actor.
vtkOutlineFilter outline = new vtkOutlineFilter();
outline.SetInputConnection(normals.GetOutputPort());
vtkPolyDataMapper mapOutline = new vtkPolyDataMapper();
mapOutline.SetInputConnection(outline.GetOutputPort());
vtkActor outlineActor = new vtkActor();
outlineActor.SetMapper(mapOutline);
outlineActor.GetProperty().SetColor(0, 0, 0);
// Create a vtkCamera, and set the camera parameters.
vtkCamera camera = new vtkCamera();
camera.SetClippingRange(1.60187, 20.0842);
camera.SetFocalPoint(0.21406, 1.5, 0);
camera.SetPosition(8.3761, 4.94858, 4.12505);
camera.SetViewUp(0.180325, 0.549245, -0.815974);
// Create a vtkLight, and set the light parameters.
vtkLight light = new vtkLight();
light.SetFocalPoint(0.21406, 1.5, 0);
light.SetPosition(8.3761, 4.94858, 4.12505);
// Create the Renderers. Assign them the appropriate viewport
// coordinates, active camera, and light.
vtkRenderer ren = new vtkRenderer();
ren.SetViewport(0, 0, 0.5, 1.0);
ren.SetActiveCamera(camera);
ren.AddLight(light);
vtkRenderer ren2 = new vtkRenderer();
ren2.SetViewport(0.5, 0, 1.0, 1.0);
ren2.SetActiveCamera(camera);
ren2.AddLight(light);
// Create the RenderWindow and RenderWindowInteractor.
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(ren);
renWin.AddRenderer(ren2);
renWin.SetWindowName("VTK - Cube Axes");
renWin.SetSize(600, 300);
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);
// Add the actors to the renderer, and set the background.
ren.AddViewProp(foheActor);
ren.AddViewProp(outlineActor);
ren2.AddViewProp(foheActor);
ren2.AddViewProp(outlineActor);
ren.SetBackground(0.1, 0.2, 0.4);
ren2.SetBackground(0.1, 0.2, 0.4);
// Create a text property for both cube axes
vtkTextProperty tprop = new vtkTextProperty();
tprop.SetColor(1, 1, 1);
tprop.ShadowOn();
// Create a vtkCubeAxesActor2D. Use the outer edges of the bounding box to
// draw the axes. Add the actor to the renderer.
vtkCubeAxesActor2D axes = new vtkCubeAxesActor2D();
axes.SetInput(normals.GetOutput());
axes.SetCamera(ren.GetActiveCamera());
axes.SetLabelFormat("%6.4g");
axes.SetFlyModeToOuterEdges();
axes.SetFontFactor(0.8);
axes.SetAxisTitleTextProperty(tprop);
axes.SetAxisLabelTextProperty(tprop);
ren.AddViewProp(axes);
// Create a vtkCubeAxesActor2D. Use the closest vertex to the camera to
// determine where to draw the axes. Add the actor to the renderer.
vtkCubeAxesActor2D axes2 = new vtkCubeAxesActor2D();
axes2.SetViewProp(foheActor);
axes2.SetCamera(ren2.GetActiveCamera());
axes2.SetLabelFormat("%6.4g");
axes2.SetFlyModeToClosestTriad();
axes2.SetFontFactor(0.8);
axes2.ScalingOff();
axes2.SetAxisTitleTextProperty(tprop);
axes2.SetAxisLabelTextProperty(tprop);
ren2.AddViewProp(axes2);
renWin.AddObserver((uint) EventIds.AbortCheckEvent, CheckAbort);
//.........这里部分代码省略.........
示例2: Main
///<summary>Entry Point</summary>
static void Main(string[] args)
{
// Create a simple sphere. A pipeline is created.
sphere = vtkSphereSource.New();
sphere.SetThetaResolution(8);
sphere.SetPhiResolution(16);
shrink = vtkShrinkPolyData.New();
shrink.SetInputConnection(sphere.GetOutputPort());
shrink.SetShrinkFactor(0.9);
mapper = vtkPolyDataMapper.New();
mapper.SetInputConnection(shrink.GetOutputPort());
// The actor links the data pipeline to the rendering subsystem
actor = vtkActor.New();
actor.SetMapper(mapper);
actor.GetProperty().SetColor(1, 0, 0);
// Create components of the rendering subsystem
//
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer(ren1);
iren = vtkRenderWindowInteractor.New();
iren.SetRenderWindow(renWin);
// Add the actors to the renderer, set the window size
//
ren1.AddViewProp(actor);
renWin.SetSize(250, 250);
renWin.Render();
camera = ren1.GetActiveCamera();
camera.Zoom(1.5);
// render the image and start the event loop
//
renWin.Render();
iren.Initialize();
iren.Start();
deleteAllVTKObjects();
}
示例3: AVTestSpherePuzzle
/// <summary>
/// The main entry method called by the CSharp driver
/// </summary>
/// <param name="argv"></param>
public static void AVTestSpherePuzzle(String [] argv)
{
//Prefix Content is: ""
// prevent the tk window from showing up then start the event loop[]
renWin = vtkRenderWindow.New();
// create a rendering window and renderer[]
ren1 = vtkRenderer.New();
renWin.AddRenderer((vtkRenderer)ren1);
renWin.SetSize((int)400,(int)400);
puzzle = new vtkSpherePuzzle();
mapper = vtkPolyDataMapper.New();
mapper.SetInputConnection((vtkAlgorithmOutput)puzzle.GetOutputPort());
actor = new vtkActor();
actor.SetMapper((vtkMapper)mapper);
arrows = new vtkSpherePuzzleArrows();
mapper2 = vtkPolyDataMapper.New();
mapper2.SetInputConnection((vtkAlgorithmOutput)arrows.GetOutputPort());
actor2 = new vtkActor();
actor2.SetMapper((vtkMapper)mapper2);
// Add the actors to the renderer, set the background and size[]
//[]
ren1.AddActor((vtkProp)actor);
ren1.AddActor((vtkProp)actor2);
ren1.SetBackground((double)0.1,(double)0.2,(double)0.4);
LastVal = -1;
//method moved
//method moved
renWin.Render();
cam = ren1.GetActiveCamera();
cam.Elevation((double)-40);
puzzle.MoveHorizontal((int)0,(int)100,(int)0);
puzzle.MoveHorizontal((int)1,(int)100,(int)1);
puzzle.MoveHorizontal((int)2,(int)100,(int)0);
puzzle.MoveVertical((int)2,(int)100,(int)0);
puzzle.MoveVertical((int)1,(int)100,(int)0);
renWin.Render();
//deleteAllVTKObjects();
}
示例4: AVTenEllip
/// <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.SetMultiSamples(0);
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();
}
示例5: ReadSTL
/// <summary>
/// 读取stl文件,并在窗口进行显示,并设置全局变量originalMesh
/// </summary>
private void ReadSTL()
{
//Path to vtk data must be set as an environment variable
//VTK_DATA_ROOT=""
vtkSTLReader reader = vtkSTLReader.New();
reader.SetFileName(FileFullName);
reader.Update();
mapper = vtkPolyDataMapper.New();
mapper.SetInputConnection(reader.GetOutputPort());
actor = vtkActor.New();
actor.SetMapper(mapper);
//get a reference to the renderwindow of our renderWindowControll
renderWindow = renderWindowControl1.RenderWindow;
//renderer
renderer = renderWindow.GetRenderers().GetFirstRenderer();
//移除之前所有prop
renderer.RemoveAllViewProps();
//set background color
renderer.SetBackground(0.2, 0.3, 0.4);
//add our actor to the renderer
renderer.AddActor(actor);
originalMesh = vtkPolyData.New();
originalMesh.DeepCopy(reader.GetOutput());
tb_numOfPoint.Text = originalMesh.GetNumberOfPoints().ToString();
//creat a cell picker
picker = vtkCellPicker.New();
vtkRenderWindowInteractor iren = renderWindow.GetInteractor();
iren.SetPicker(picker);
renderer.ResetCamera();
renderWindow.Render();
}
示例6: AVpickCells
/// <summary>
/// The main entry method called by the CSharp driver
/// </summary>
/// <param name="argv"></param>
public static void AVpickCells(String [] argv)
{
//Prefix Content is: ""
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer((vtkRenderer)ren1);
iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow((vtkRenderWindow)renWin);
// create a scene with one of each cell type[]
// Voxel[]
voxelPoints = new vtkPoints();
voxelPoints.SetNumberOfPoints((int)8);
voxelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
voxelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
voxelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
voxelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
voxelPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
voxelPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
voxelPoints.InsertPoint((int)6,(double)0,(double)1,(double)1);
voxelPoints.InsertPoint((int)7,(double)1,(double)1,(double)1);
aVoxel = new vtkVoxel();
aVoxel.GetPointIds().SetId((int)0,(int)0);
aVoxel.GetPointIds().SetId((int)1,(int)1);
aVoxel.GetPointIds().SetId((int)2,(int)2);
aVoxel.GetPointIds().SetId((int)3,(int)3);
aVoxel.GetPointIds().SetId((int)4,(int)4);
aVoxel.GetPointIds().SetId((int)5,(int)5);
aVoxel.GetPointIds().SetId((int)6,(int)6);
aVoxel.GetPointIds().SetId((int)7,(int)7);
aVoxelGrid = new vtkUnstructuredGrid();
aVoxelGrid.Allocate((int)1,(int)1);
aVoxelGrid.InsertNextCell((int)aVoxel.GetCellType(),(vtkIdList)aVoxel.GetPointIds());
aVoxelGrid.SetPoints((vtkPoints)voxelPoints);
aVoxelMapper = new vtkDataSetMapper();
aVoxelMapper.SetInput((vtkDataSet)aVoxelGrid);
aVoxelActor = new vtkActor();
aVoxelActor.SetMapper((vtkMapper)aVoxelMapper);
aVoxelActor.GetProperty().BackfaceCullingOn();
// Hexahedron[]
hexahedronPoints = new vtkPoints();
hexahedronPoints.SetNumberOfPoints((int)8);
hexahedronPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
hexahedronPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
hexahedronPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
hexahedronPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
hexahedronPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
hexahedronPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
hexahedronPoints.InsertPoint((int)6,(double)1,(double)1,(double)1);
hexahedronPoints.InsertPoint((int)7,(double)0,(double)1,(double)1);
aHexahedron = new vtkHexahedron();
aHexahedron.GetPointIds().SetId((int)0,(int)0);
aHexahedron.GetPointIds().SetId((int)1,(int)1);
aHexahedron.GetPointIds().SetId((int)2,(int)2);
aHexahedron.GetPointIds().SetId((int)3,(int)3);
aHexahedron.GetPointIds().SetId((int)4,(int)4);
aHexahedron.GetPointIds().SetId((int)5,(int)5);
aHexahedron.GetPointIds().SetId((int)6,(int)6);
aHexahedron.GetPointIds().SetId((int)7,(int)7);
aHexahedronGrid = new vtkUnstructuredGrid();
aHexahedronGrid.Allocate((int)1,(int)1);
aHexahedronGrid.InsertNextCell((int)aHexahedron.GetCellType(),(vtkIdList)aHexahedron.GetPointIds());
aHexahedronGrid.SetPoints((vtkPoints)hexahedronPoints);
aHexahedronMapper = new vtkDataSetMapper();
aHexahedronMapper.SetInput((vtkDataSet)aHexahedronGrid);
aHexahedronActor = new vtkActor();
aHexahedronActor.SetMapper((vtkMapper)aHexahedronMapper);
aHexahedronActor.AddPosition((double)2,(double)0,(double)0);
aHexahedronActor.GetProperty().BackfaceCullingOn();
// Tetra[]
tetraPoints = new vtkPoints();
tetraPoints.SetNumberOfPoints((int)4);
tetraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
tetraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
tetraPoints.InsertPoint((int)2,(double).5,(double)1,(double)0);
tetraPoints.InsertPoint((int)3,(double).5,(double).5,(double)1);
aTetra = new vtkTetra();
aTetra.GetPointIds().SetId((int)0,(int)0);
aTetra.GetPointIds().SetId((int)1,(int)1);
aTetra.GetPointIds().SetId((int)2,(int)2);
aTetra.GetPointIds().SetId((int)3,(int)3);
aTetraGrid = new vtkUnstructuredGrid();
aTetraGrid.Allocate((int)1,(int)1);
aTetraGrid.InsertNextCell((int)aTetra.GetCellType(),(vtkIdList)aTetra.GetPointIds());
aTetraGrid.SetPoints((vtkPoints)tetraPoints);
aTetraMapper = new vtkDataSetMapper();
aTetraMapper.SetInput((vtkDataSet)aTetraGrid);
aTetraActor = new vtkActor();
aTetraActor.SetMapper((vtkMapper)aTetraMapper);
aTetraActor.AddPosition((double)4,(double)0,(double)0);
aTetraActor.GetProperty().BackfaceCullingOn();
// Wedge[]
wedgePoints = new vtkPoints();
wedgePoints.SetNumberOfPoints((int)6);
wedgePoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
wedgePoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
//.........这里部分代码省略.........
示例7: AVLineIntersectQuadraticCells
//.........这里部分代码省略.........
aPyramid.GetPointIds().SetId((int)4,(int)4);
aPyramid.GetPointIds().SetId((int)5,(int)5);
aPyramid.GetPointIds().SetId((int)6,(int)6);
aPyramid.GetPointIds().SetId((int)7,(int)7);
aPyramid.GetPointIds().SetId((int)8,(int)8);
aPyramid.GetPointIds().SetId((int)9,(int)9);
aPyramid.GetPointIds().SetId((int)10,(int)10);
aPyramid.GetPointIds().SetId((int)11,(int)11);
aPyramid.GetPointIds().SetId((int)12,(int)12);
aPyramidGrid = new vtkUnstructuredGrid();
aPyramidGrid.Allocate((int)1,(int)1);
aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds());
aPyramidGrid.SetPoints((vtkPoints)pyraPoints);
aPyramidGrid.GetPointData().SetScalars((vtkDataArray)pyraScalars);
pyraContours = new vtkClipDataSet();
pyraContours.SetInputData((vtkDataObject)aPyramidGrid);
pyraContours.SetValue((double)0.5);
aPyramidContourMapper = new vtkDataSetMapper();
aPyramidContourMapper.SetInputConnection((vtkAlgorithmOutput)pyraContours.GetOutputPort());
aPyramidContourMapper.ScalarVisibilityOff();
aPyramidMapper = new vtkDataSetMapper();
aPyramidMapper.SetInputData((vtkDataSet)aPyramidGrid);
aPyramidMapper.ScalarVisibilityOff();
aPyramidActor = new vtkActor();
aPyramidActor.SetMapper((vtkMapper)aPyramidMapper);
aPyramidActor.GetProperty().SetRepresentationToWireframe();
aPyramidActor.GetProperty().SetAmbient((double)1.0);
aPyramidContourActor = new vtkActor();
aPyramidContourActor.SetMapper((vtkMapper)aPyramidContourMapper);
aPyramidContourActor.GetProperty().SetAmbient((double)1.0);
// Create the rendering related stuff.[]
// Since some of our actors are a single vertex, we need to remove all[]
// cullers so the single vertex actors will render[]
ren1 = vtkRenderer.New();
ren1.GetCullers().RemoveAllItems();
renWin = vtkRenderWindow.New();
renWin.SetMultiSamples(0);
renWin.AddRenderer((vtkRenderer)ren1);
iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow((vtkRenderWindow)renWin);
ren1.SetBackground((double).1,(double).2,(double).3);
renWin.SetSize((int)400,(int)200);
// specify properties[]
ren1.AddActor((vtkProp)aEdgeActor);
ren1.AddActor((vtkProp)aTriActor);
ren1.AddActor((vtkProp)aQuadActor);
ren1.AddActor((vtkProp)aTetActor);
ren1.AddActor((vtkProp)aHexActor);
ren1.AddActor((vtkProp)aWedgeActor);
ren1.AddActor((vtkProp)aPyramidActor);
// places everyone!![]
aTriActor.AddPosition((double)2,(double)0,(double)0);
aQuadActor.AddPosition((double)4,(double)0,(double)0);
aTetActor.AddPosition((double)6,(double)0,(double)0);
aHexActor.AddPosition((double)8,(double)0,(double)0);
aWedgeActor.AddPosition((double)10,(double)0,(double)0);
aPyramidActor.AddPosition((double)12,(double)0,(double)0);
BuildBackdrop(-1, 15, -1, 4, -1, 2, .1);
ren1.AddActor((vtkProp)base1);
base1.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
ren1.AddActor((vtkProp)left);
left.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
ren1.AddActor((vtkProp)back);
back.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
ren1.ResetCamera();
ren1.GetActiveCamera().Dolly((double)2.5);
示例8: Main
/// <summary>
/// An example that does not use a Windows Form
/// </summary>
/// <param name="argv"></param>
public static void Main(String[] argv)
{
// This example demonstrates the use of vtkCubeAxesActor2D to indicate the
// position in space that the camera is currently viewing.
// The vtkCubeAxesActor2D draws axes on the bounding box of the data set and
// labels the axes with x-y-z coordinates.
//
// First we include the VTK Tcl packages which will make available
// all of the vtk commands to Tcl
//
// Create a vtkBYUReader and read in a data set.
//
fohe = vtkBYUReader.New();
fohe.SetGeometryFileName("../../../teapot.g");
// Create a vtkPolyDataNormals filter to calculate the normals of the data set.
normals = vtkPolyDataNormals.New();
normals.SetInputConnection(fohe.GetOutputPort());
// Set up the associated mapper and actor.
foheMapper = vtkPolyDataMapper.New();
foheMapper.SetInputConnection(normals.GetOutputPort());
foheActor = vtkLODActor.New();
foheActor.SetMapper(foheMapper);
// Create a vtkOutlineFilter to draw the bounding box of the data set. Also
// create the associated mapper and actor.
outline = vtkOutlineFilter.New();
outline.SetInputConnection(normals.GetOutputPort());
mapOutline = vtkPolyDataMapper.New();
mapOutline.SetInputConnection(outline.GetOutputPort());
outlineActor = vtkActor.New();
outlineActor.SetMapper(mapOutline);
outlineActor.GetProperty().SetColor(0, 0, 0);
// Create a vtkCamera, and set the camera parameters.
camera = vtkCamera.New();
camera.SetClippingRange(1.60187, 20.0842);
camera.SetFocalPoint(0.21406, 1.5, 0);
camera.SetPosition(8.3761, 4.94858, 4.12505);
camera.SetViewUp(0.180325, 0.549245, -0.815974);
// Create a vtkLight, and set the light parameters.
light = vtkLight.New();
light.SetFocalPoint(0.21406, 1.5, 0);
light.SetPosition(8.3761, 4.94858, 4.12505);
// Create the Renderers. Assign them the appropriate viewport coordinates,
// active camera, and light.
ren1 = vtkRenderer.New();
ren1.SetViewport(0, 0, 0.5, 1.0);
ren1.SetActiveCamera(camera);
ren1.AddLight(light);
ren2 = vtkRenderer.New();
ren2.SetViewport(0.5, 0, 1.0, 1.0);
ren2.SetActiveCamera(camera);
ren2.AddLight(light);
// Create the RenderWindow and RenderWindowInteractor.
renWin = vtkRenderWindow.New();
renWin.AddRenderer(ren1);
renWin.AddRenderer(ren2);
renWin.SetWindowName("VTK - Cube Axes");
renWin.SetSize(600, 300);
iren = vtkRenderWindowInteractor.New();
iren.SetRenderWindow(renWin);
// Add the actors to the renderer, and set the background.
ren1.AddViewProp(foheActor);
ren1.AddViewProp(outlineActor);
ren2.AddViewProp(foheActor);
ren2.AddViewProp(outlineActor);
ren1.SetBackground(0.1, 0.2, 0.4);
ren2.SetBackground(0.1, 0.2, 0.4);
// Create a text property for both cube axes
tprop = vtkTextProperty.New();
tprop.SetColor(1, 1, 1);
tprop.ShadowOn();
// Create a vtkCubeAxesActor2D. Use the outer edges of the bounding box to
// draw the axes. Add the actor to the renderer.
axes = vtkCubeAxesActor2D.New();
axes.SetInput(normals.GetOutput());
axes.SetCamera(ren1.GetActiveCamera());
axes.SetLabelFormat("%6.4g");
axes.SetFlyModeToOuterEdges();
axes.SetFontFactor(0.8);
axes.SetAxisTitleTextProperty(tprop);
axes.SetAxisLabelTextProperty(tprop);
ren1.AddViewProp(axes);
//.........这里部分代码省略.........
示例9: Main
/// <summary>
/// Entry Point
/// </summary>
/// <param name="argv"></param>
public static void Main(String[] argv)
{
// This example demonstrates how to use the vtkLineWidget to seed
// and manipulate streamlines. Two line widgets are created. One is
// invoked by pressing 'W', the other by pressing 'L'. Both can exist
// together.
// Start by loading some data.
pl3d = vtkMultiBlockPLOT3DReader.New();
pl3d.SetXYZFileName("../../../combxyz.bin");
pl3d.SetQFileName("../../../combq.bin");
pl3d.SetScalarFunctionNumber(100);
pl3d.SetVectorFunctionNumber(202);
pl3d.Update();
// The line widget is used seed the streamlines.
lineWidget = vtkLineWidget.New();
seeds = vtkPolyData.New();
lineWidget.SetInput(pl3d.GetOutput());
lineWidget.SetAlignToYAxis();
lineWidget.PlaceWidget();
lineWidget.GetPolyData(seeds);
lineWidget.ClampToBoundsOn();
rk4 = vtkRungeKutta4.New();
streamer = vtkStreamLine.New();
streamer.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
streamer.SetSource(seeds);
streamer.SetMaximumPropagationTime(100);
streamer.SetIntegrationStepLength(.2);
streamer.SetStepLength(.001);
streamer.SetNumberOfThreads(1);
streamer.SetIntegrationDirectionToForward();
streamer.VorticityOn();
streamer.SetIntegrator(rk4);
rf = vtkRibbonFilter.New();
rf.SetInputConnection(streamer.GetOutputPort());
rf.SetWidth(0.1);
rf.SetWidthFactor(5);
streamMapper = vtkPolyDataMapper.New();
streamMapper.SetInputConnection(rf.GetOutputPort());
streamMapper.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]);
streamline = vtkActor.New();
streamline.SetMapper(streamMapper);
streamline.VisibilityOff();
// The second line widget is used seed more streamlines.
lineWidget2 = vtkLineWidget.New();
seeds2 = vtkPolyData.New();
lineWidget2.SetInput(pl3d.GetOutput());
lineWidget2.PlaceWidget();
lineWidget2.GetPolyData(seeds2);
lineWidget2.SetKeyPressActivationValue((sbyte)108);
streamer2 = vtkStreamLine.New();
streamer2.SetInputDaat((vtkDataSet)pl3d.GetOutput().GetBlock(0));
streamer2.SetSource(seeds2);
streamer2.SetMaximumPropagationTime(100);
streamer2.SetIntegrationStepLength(.2);
streamer2.SetStepLength(.001);
streamer2.SetNumberOfThreads(1);
streamer2.SetIntegrationDirectionToForward();
streamer2.VorticityOn();
streamer2.SetIntegrator(rk4);
rf2 = vtkRibbonFilter.New();
rf2.SetInputConnection(streamer2.GetOutputPort());
rf2.SetWidth(0.1);
rf2.SetWidthFactor(5);
streamMapper2 = vtkPolyDataMapper.New();
streamMapper2.SetInputConnection(rf2.GetOutputPort());
streamMapper2.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]);
streamline2 = vtkActor.New();
streamline2.SetMapper(streamMapper2);
streamline2.VisibilityOff();
outline = vtkStructuredGridOutlineFilter.New();
outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
outlineMapper = vtkPolyDataMapper.New();
outlineMapper.SetInputConnection(outline.GetOutputPort());
outlineActor = vtkActor.New();
outlineActor.SetMapper(outlineMapper);
// Create the RenderWindow, Renderer and both Actors
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer(ren1);
iren = vtkRenderWindowInteractor.New();
iren.SetRenderWindow(renWin);
// Associate the line widget with the interactor
lineWidget.SetInteractor(iren);
//.........这里部分代码省略.........
示例10: AVTestPolygonWriters
/// <summary>
/// The main entry method called by the CSharp driver
/// </summary>
/// <param name="argv"></param>
public static void AVTestPolygonWriters(String [] argv)
{
//Prefix Content is: ""
// Create the RenderWindow, Renderer and both Actors[]
//[]
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer((vtkRenderer)ren1);
iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow((vtkRenderWindow)renWin);
// read data[]
//[]
input = new vtkPolyDataReader();
input.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/brainImageSmooth.vtk");
//[]
// generate vectors[]
clean = new vtkCleanPolyData();
clean.SetInputConnection((vtkAlgorithmOutput)input.GetOutputPort());
smooth = new vtkWindowedSincPolyDataFilter();
smooth.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort());
smooth.GenerateErrorVectorsOn();
smooth.GenerateErrorScalarsOn();
smooth.Update();
mapper = vtkPolyDataMapper.New();
mapper.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
mapper.SetScalarRange((double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[0],
(double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[1]);
brain = new vtkActor();
brain.SetMapper((vtkMapper)mapper);
// Add the actors to the renderer, set the background and size[]
//[]
ren1.AddActor((vtkProp)brain);
renWin.SetSize((int)320,(int)240);
ren1.GetActiveCamera().SetPosition((double)149.653,(double)-65.3464,(double)96.0401);
ren1.GetActiveCamera().SetFocalPoint((double)146.003,(double)22.3839,(double)0.260541);
ren1.GetActiveCamera().SetViewAngle((double)30);
ren1.GetActiveCamera().SetViewUp((double)-0.255578,(double)-0.717754,(double)-0.647695);
ren1.GetActiveCamera().SetClippingRange((double)79.2526,(double)194.052);
iren.Initialize();
renWin.Render();
// render the image[]
//[]
// prevent the tk window from showing up then start the event loop[]
//[]
// If the current directory is writable, then test the witers[]
//[]
try
{
channel = new StreamWriter("test.tmp");
tryCatchError = "NOERROR";
}
catch(Exception)
{tryCatchError = "ERROR";}
if(tryCatchError.Equals("NOERROR"))
{
channel.Close();
File.Delete("test.tmp");
//[]
//[]
// test the writers[]
dsw = new vtkDataSetWriter();
dsw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
dsw.SetFileName((string)"brain.dsw");
dsw.Write();
File.Delete("brain.dsw");
pdw = new vtkPolyDataWriter();
pdw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
pdw.SetFileName((string)"brain.pdw");
pdw.Write();
File.Delete("brain.pdw");
iv = new vtkIVWriter();
iv.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
iv.SetFileName((string)"brain.iv");
iv.Write();
File.Delete("brain.iv");
//[]
// the next writers only handle triangles[]
triangles = new vtkTriangleFilter();
triangles.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
iv2 = new vtkIVWriter();
iv2.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
iv2.SetFileName((string)"brain2.iv");
iv2.Write();
File.Delete("brain2.iv");
edges = new vtkExtractEdges();
edges.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
iv3 = new vtkIVWriter();
iv3.SetInputConnection((vtkAlgorithmOutput)edges.GetOutputPort());
iv3.SetFileName((string)"brain3.iv");
iv3.Write();
File.Delete("brain3.iv");
//.........这里部分代码省略.........
示例11: AVSelectionLoop
/// <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();
}
示例12: Main
static void Main(string[] args)
{
//
// Next we create an instance of vtkConeSource and set some of its
// properties. The instance of vtkConeSource "cone" is part of a visualization
// pipeline (it is a source process object); it produces data (output type is
// vtkPolyData) which other filters may process.
//
vtkConeSource cone = new vtkConeSource();
cone.SetHeight( 3.0f );
cone.SetRadius( 1.0f );
cone.SetResolution( 10 );
//
// In this example we terminate the pipeline with a mapper process object.
// (Intermediate filters such as vtkShrinkPolyData could be inserted in
// between the source and the mapper.) We create an instance of
// vtkPolyDataMapper to map the polygonal data into graphics primitives. We
// connect the output of the cone souece to the input of this mapper.
//
vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
coneMapper.SetInput( cone.GetOutput() );
//
// Create an actor to represent the cone. The actor orchestrates rendering of
// the mapper's graphics primitives. An actor also refers to properties via a
// vtkProperty instance, and includes an internal transformation matrix. We
// set this actor's mapper to be coneMapper which we created above.
//
vtkActor coneActor = new vtkActor();
coneActor.SetMapper( coneMapper );
//
// Create the Renderer and assign actors to it. A renderer is like a
// viewport. It is part or all of a window on the screen and it is
// responsible for drawing the actors it has. We also set the background
// color here
//
vtkRenderer ren1 = new vtkRenderer();
ren1.AddActor( coneActor );
ren1.SetBackground( 0.1f, 0.2f, 0.4f );
//
// Finally we create the render window which will show up on the screen
// We put our renderer into the render window using AddRenderer. We also
// set the size to be 300 pixels by 300
//
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer( ren1 );
renWin.SetSize( 300, 300 );
// Add an observer to the render window.
ren1.AddObserver((uint) EventIds.StartEvent,
new vtkDotNetCallback(PrintCameraPosition));
//
// now we loop over 360 degreeees and render the cone each time
//
for ( int i=0; i<360; i++ )
{
System.Threading.Thread.Sleep(30);
renWin.Render();
ren1.GetActiveCamera().Azimuth( 1 );
}
vtkWin32OpenGLRenderWindow win32win =
vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
if (null != win32win) win32win.Clean();
}
示例13: AVTestGridSynchronizedTemplates3D
/// <summary>
/// The main entry method called by the CSharp driver
/// </summary>
/// <param name="argv"></param>
public static void AVTestGridSynchronizedTemplates3D(String [] argv)
{
//Prefix Content is: ""
// cut data[]
pl3d = new vtkMultiBlockPLOT3DReader();
pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin");
pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin");
pl3d.SetScalarFunctionNumber((int)100);
pl3d.SetVectorFunctionNumber((int)202);
pl3d.Update();
range = ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange();
min = (double)(lindex(range,0));
max = (double)(lindex(range,1));
value = (min+max)/2.0;
//vtkGridSynchronizedTemplates3D cf[]
cf = new vtkContourFilter();
cf.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
cf.SetValue((int)0,(double)value);
//cf ComputeNormalsOff[]
cfMapper = vtkPolyDataMapper.New();
cfMapper.ImmediateModeRenderingOn();
cfMapper.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort());
cfMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[1]);
cfActor = new vtkActor();
cfActor.SetMapper((vtkMapper)cfMapper);
//outline[]
outline = new vtkStructuredGridOutlineFilter();
outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
outlineMapper = vtkPolyDataMapper.New();
outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
outlineActor = new vtkActor();
outlineActor.SetMapper((vtkMapper)outlineMapper);
outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
//# Graphics stuff[]
// Create the RenderWindow, Renderer and both Actors[]
//[]
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.SetMultiSamples(0);
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)outlineActor);
ren1.AddActor((vtkProp)cfActor);
ren1.SetBackground((double)1,(double)1,(double)1);
renWin.SetSize((int)400,(int)400);
cam1 = ren1.GetActiveCamera();
cam1.SetClippingRange((double)3.95297,(double)50);
cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999);
cam1.SetPosition((double)2.7439,(double)-37.3196,(double)38.7167);
cam1.SetViewUp((double)-0.16123,(double)0.264271,(double)0.950876);
iren.Initialize();
// render the image[]
//[]
// loop over surfaces[]
i = 0;
while((i) < 17)
{
cf.SetValue((int)0,(double)min+(i/16.0)*(max-min));
renWin.Render();
i = i + 1;
}
cf.SetValue((int)0,(double)min+(0.2)*(max-min));
renWin.Render();
// prevent the tk window from showing up then start the event loop[]
//deleteAllVTKObjects();
}
示例14: AVgaussian
/// <summary>
/// The main entry method called by the CSharp driver
/// </summary>
/// <param name="argv"></param>
public static void AVgaussian(String [] argv)
{
//Prefix Content is: ""
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer((vtkRenderer)ren1);
renWin.SetSize((int)300,(int)300);
iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow((vtkRenderWindow)renWin);
camera = new vtkCamera();
camera.ParallelProjectionOn();
camera.SetViewUp((double)0,(double)1,(double)0);
camera.SetFocalPoint((double)12,(double)10.5,(double)15);
camera.SetPosition((double)-70,(double)15,(double)34);
camera.ComputeViewPlaneNormal();
ren1.SetActiveCamera((vtkCamera)camera);
// Create the reader for the data[]
//vtkStructuredPointsReader reader[]
reader = new vtkGaussianCubeReader();
reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/m4_TotalDensity.cube");
reader.SetHBScale((double)1.1);
reader.SetBScale((double)10);
reader.Update();
range = reader.GetGridOutput().GetPointData().GetScalars().GetRange();
min = (double)(lindex(range,0));
max = (double)(lindex(range,1));
readerSS = new vtkImageShiftScale();
readerSS.SetInput((vtkDataObject)reader.GetGridOutput());
readerSS.SetShift((double)min*-1);
readerSS.SetScale((double)255/(max-min));
readerSS.SetOutputScalarTypeToUnsignedChar();
bounds = new vtkOutlineFilter();
bounds.SetInput((vtkDataObject)reader.GetGridOutput());
boundsMapper = vtkPolyDataMapper.New();
boundsMapper.SetInputConnection((vtkAlgorithmOutput)bounds.GetOutputPort());
boundsActor = new vtkActor();
boundsActor.SetMapper((vtkMapper)boundsMapper);
boundsActor.GetProperty().SetColor((double)0,(double)0,(double)0);
contour = new vtkContourFilter();
contour.SetInput((vtkDataObject)reader.GetGridOutput());
contour.GenerateValues((int)5,(double)0,(double).05);
contourMapper = vtkPolyDataMapper.New();
contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort());
contourMapper.SetScalarRange((double)0,(double).1);
((vtkLookupTable)contourMapper.GetLookupTable()).SetHueRange(0.32,0);
contourActor = new vtkActor();
contourActor.SetMapper((vtkMapper)contourMapper);
contourActor.GetProperty().SetOpacity((double).5);
// Create transfer mapping scalar value to opacity[]
opacityTransferFunction = new vtkPiecewiseFunction();
opacityTransferFunction.AddPoint((double)0,(double)0.01);
opacityTransferFunction.AddPoint((double)255,(double)0.35);
opacityTransferFunction.ClampingOn();
// Create transfer mapping scalar value to color[]
colorTransferFunction = new vtkColorTransferFunction();
colorTransferFunction.AddHSVPoint((double)0.0,(double)0.66,(double)1.0,(double)1.0);
colorTransferFunction.AddHSVPoint((double)50.0,(double)0.33,(double)1.0,(double)1.0);
colorTransferFunction.AddHSVPoint((double)100.0,(double)0.00,(double)1.0,(double)1.0);
// The property describes how the data will look[]
volumeProperty = new vtkVolumeProperty();
volumeProperty.SetColor((vtkColorTransferFunction)colorTransferFunction);
volumeProperty.SetScalarOpacity((vtkPiecewiseFunction)opacityTransferFunction);
volumeProperty.SetInterpolationTypeToLinear();
// The mapper / ray cast function know how to render the data[]
compositeFunction = new vtkVolumeRayCastCompositeFunction();
volumeMapper = new vtkVolumeRayCastMapper();
//vtkVolumeTextureMapper2D volumeMapper[]
volumeMapper.SetVolumeRayCastFunction((vtkVolumeRayCastFunction)compositeFunction);
volumeMapper.SetInputConnection((vtkAlgorithmOutput)readerSS.GetOutputPort());
// The volume holds the mapper and the property and[]
// can be used to position/orient the volume[]
volume = new vtkVolume();
volume.SetMapper((vtkAbstractVolumeMapper)volumeMapper);
volume.SetProperty((vtkVolumeProperty)volumeProperty);
ren1.AddVolume((vtkProp)volume);
//ren1 AddActor contourActor[]
ren1.AddActor((vtkProp)boundsActor);
//#####################################################################[]
Sphere = new vtkSphereSource();
Sphere.SetCenter((double)0,(double)0,(double)0);
Sphere.SetRadius((double)1);
Sphere.SetThetaResolution((int)16);
Sphere.SetStartTheta((double)0);
Sphere.SetEndTheta((double)360);
Sphere.SetPhiResolution((int)16);
Sphere.SetStartPhi((double)0);
Sphere.SetEndPhi((double)180);
Glyph = new vtkGlyph3D();
Glyph.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
Glyph.SetOrient((int)1);
Glyph.SetColorMode((int)1);
//Glyph ScalingOn[]
Glyph.SetScaleMode((int)2);
Glyph.SetScaleFactor((double).6);
Glyph.SetSource((vtkPolyData)Sphere.GetOutput());
//.........这里部分代码省略.........
示例15: AVTestFixedPointRayCasterNearest
//.........这里部分代码省略.........
// this one is constant 1[]
constant1 = new vtkPiecewiseFunction();
constant1.AddPoint((double)0,(double)1.0);
constant1.AddPoint((double)255,(double)1.0);
// this one is used for gradient opacity[]
gop = new vtkPiecewiseFunction();
gop.AddPoint((double)0,(double)0.0);
gop.AddPoint((double)20,(double)0.0);
gop.AddPoint((double)60,(double)1.0);
gop.AddPoint((double)255,(double)1.0);
// We need a bunch of color functions[]
// This one is a simple rainbow[]
rainbow = new vtkColorTransferFunction();
rainbow.SetColorSpaceToHSV();
rainbow.HSVWrapOff();
rainbow.AddHSVPoint((double)0,(double)0.1,(double)1.0,(double)1.0);
rainbow.AddHSVPoint((double)255,(double)0.9,(double)1.0,(double)1.0);
// this is constant red[]
red = new vtkColorTransferFunction();
red.AddRGBPoint((double)0,(double)1,(double)0,(double)0);
red.AddRGBPoint((double)255,(double)1,(double)0,(double)0);
// this is constant green[]
green = new vtkColorTransferFunction();
green.AddRGBPoint((double)0,(double)0,(double)1,(double)0);
green.AddRGBPoint((double)255,(double)0,(double)1,(double)0);
// this is constant blue[]
blue = new vtkColorTransferFunction();
blue.AddRGBPoint((double)0,(double)0,(double)0,(double)1);
blue.AddRGBPoint((double)255,(double)0,(double)0,(double)1);
// this is constant yellow[]
yellow = new vtkColorTransferFunction();
yellow.AddRGBPoint((double)0,(double)1,(double)1,(double)0);
yellow.AddRGBPoint((double)255,(double)1,(double)1,(double)0);
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer((vtkRenderer)ren1);
renWin.SetSize((int)500,(int)500);
iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow((vtkRenderWindow)renWin);
ren1.GetCullers().InitTraversal();
culler = (vtkFrustumCoverageCuller)ren1.GetCullers().GetNextItem();
culler.SetSortingStyleToBackToFront();
// We need 25 mapper / actor pairs which we will render[]
// in a grid. Going down we will vary the input data[]
// with the top row unsigned char, then float, then[]
// two dependent components, then four dependent components[]
// then four independent components. Going across we[]
// will vary the rendering method with MIP, Composite,[]
// Composite Shade, Composite GO, and Composite GO Shade.[]
j = 0;
while((j) < 5)
{
i = 0;
while((i) < 5)
{
volumeProperty[i,j] = new vtkVolumeProperty();
volumeMapper[i,j] = new vtkFixedPointVolumeRayCastMapper();
volumeMapper[i,j].SetSampleDistance((float)0.25);
volume[i,j] = new vtkVolume();
volume[i,j].SetMapper((vtkAbstractVolumeMapper)volumeMapper[i,j]);
volume[i,j].SetProperty((vtkVolumeProperty)volumeProperty[i,j]);
volume[i,j].AddPosition((double)i*30,(double)j*30,(double)0);
ren1.AddVolume((vtkProp)volume[i,j]);
i = i + 1;
}