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); iren.Initialize(); renWin.Render(); iren.Start(); vtkWin32OpenGLRenderWindow win32win = vtkWin32OpenGLRenderWindow.SafeDownCast(renWin); if (null != win32win) win32win.Clean(); }
private void IsoContours() { vtkImageData data = vtkImageData.New(); CreateData(ref data); // Create an isosurface _ContourFilter = vtkContourFilter.New(); #if VTK_MAJOR_VERSION_5 _ContourFilter.SetInput(data); #else contourFilter.SetInputData(data); #endif _ContourFilter.GenerateValues(1, 10, 10); // (numContours, rangeStart, rangeEnd) // Map the contours to graphical primitives vtkPolyDataMapper contourMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 contourMapper.SetInputConnection(_ContourFilter.GetOutputPort()); #else contourMapper.SetInputData(contourFilter); #endif // Create an actor for the contours vtkActor contourActor = vtkActor.New(); contourActor.SetMapper(contourMapper); // Create the outline vtkOutlineFilter outlineFilter = vtkOutlineFilter.New(); vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 outlineFilter.SetInput(data); outlineMapper.SetInputConnection(outlineFilter.GetOutputPort()); #else outlineFilter.SetInputData(data); outlineMapper.SetInputData(outlineFilter); #endif vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); // get a reference to the renderwindow of our renderWindowControl1 _RenderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = _RenderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(.2, .3, .4); // add our actor to the renderer renderer.AddActor(contourActor); renderer.AddActor(outlineActor); }
//绘制外边框 private vtkActor BuildOutlineActor(vtkImageData ImageData) { //创建Outline vtkOutlineFilter OutlineFilter = vtkOutlineFilter.New(); OutlineFilter.SetInput(ImageData); vtkPolyDataMapper OutlineMapper = vtkPolyDataMapper.New(); OutlineMapper.SetInputConnection(OutlineFilter.GetOutputPort()); vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(OutlineMapper); outlineActor.GetProperty().SetColor(0.5, 0.5, 0.5); return(outlineActor); }
/// <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); // Create a vtkCubeAxesActor2D. Use the closest vertex to the camera to // determine where to draw the axes. Add the actor to the renderer. axes2 = vtkCubeAxesActor2D.New(); 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); // Render renWin.Render(); // Set the user method (bound to key 'u') iren.Initialize(); iren.Start(); // Set up a check for aborting rendering. renWin.AbortCheckEvt += new vtkObject.vtkObjectEventHandler(TkCheckAbort); //Clean Up deleteAllVTKObjects(); }
/// <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()); AtomsMapper = vtkPolyDataMapper.New(); AtomsMapper.SetInputConnection((vtkAlgorithmOutput)Glyph.GetOutputPort()); AtomsMapper.SetImmediateModeRendering((int)1); AtomsMapper.UseLookupTableScalarRangeOff(); AtomsMapper.SetScalarVisibility((int)1); AtomsMapper.SetScalarModeToDefault(); Atoms = new vtkActor(); Atoms.SetMapper((vtkMapper)AtomsMapper); Atoms.GetProperty().SetRepresentationToSurface(); Atoms.GetProperty().SetInterpolationToGouraud(); Atoms.GetProperty().SetAmbient((double)0.15); Atoms.GetProperty().SetDiffuse((double)0.85); Atoms.GetProperty().SetSpecular((double)0.1); Atoms.GetProperty().SetSpecularPower((double)100); Atoms.GetProperty().SetSpecularColor((double)1,(double)1,(double)1); Atoms.GetProperty().SetColor((double)1,(double)1,(double)1); Tube = new vtkTubeFilter(); Tube.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); Tube.SetNumberOfSides((int)16); Tube.SetCapping((int)0); Tube.SetRadius((double)0.2); Tube.SetVaryRadius((int)0); Tube.SetRadiusFactor((double)10); BondsMapper = vtkPolyDataMapper.New(); BondsMapper.SetInputConnection((vtkAlgorithmOutput)Tube.GetOutputPort()); BondsMapper.SetImmediateModeRendering((int)1); BondsMapper.UseLookupTableScalarRangeOff(); BondsMapper.SetScalarVisibility((int)1); BondsMapper.SetScalarModeToDefault(); Bonds = new vtkActor(); Bonds.SetMapper((vtkMapper)BondsMapper); Bonds.GetProperty().SetRepresentationToSurface(); Bonds.GetProperty().SetInterpolationToGouraud(); Bonds.GetProperty().SetAmbient((double)0.15); Bonds.GetProperty().SetDiffuse((double)0.85); Bonds.GetProperty().SetSpecular((double)0.1); Bonds.GetProperty().SetSpecularPower((double)100); Bonds.GetProperty().SetSpecularColor((double)1,(double)1,(double)1); Bonds.GetProperty().SetColor((double)1,(double)1,(double)1); ren1.AddActor((vtkProp)Bonds); ren1.AddActor((vtkProp)Atoms); //###################################################[] ren1.SetBackground((double)1,(double)1,(double)1); ren1.ResetCamera(); renWin.Render(); //method moved renWin.AbortCheckEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(TkCheckAbort_Command.Execute); iren.Initialize(); //deleteAllVTKObjects(); }
private void SampleFunction() { vtkSphere sphere = vtkSphere.New(); // Sample the function vtkSampleFunction sample = vtkSampleFunction.New(); sample.SetSampleDimensions(50, 50, 50); sample.SetImplicitFunction(sphere); double value = 2.0; double xmin = -value, xmax = value, ymin = -value, ymax = value, zmin = -value, zmax = value; sample.SetModelBounds(xmin, xmax, ymin, ymax, zmin, zmax); // Create the 0 isosurface vtkContourFilter contours = vtkContourFilter.New(); #if VTK_MAJOR_VERSION_5 contours.SetInputConnection(sample.GetOutputPort()); #else contours.SetInputData(sample); #endif contours.GenerateValues(1, 1, 1); // Map the contours to graphical primitives vtkPolyDataMapper contourMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 contourMapper.SetInputConnection(contours.GetOutputPort()); #else contourMapper.SetInputData(contours); #endif contourMapper.SetScalarRange(0.0, 1.2); // Create an actor for the contours vtkActor contourActor = vtkActor.New(); contourActor.SetMapper(contourMapper); // -- create a box around the function to indicate the sampling volume -- // Create outline vtkOutlineFilter outline = vtkOutlineFilter.New(); #if VTK_MAJOR_VERSION_5 outline.SetInputConnection(sample.GetOutputPort()); #else outline.SetInputData(sample); #endif // Map it to graphics primitives vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 outlineMapper.SetInputConnection(outline.GetOutputPort()); #else outlineMapper.SetInputData(outline); #endif // Create an actor for it vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); outlineActor.GetProperty().SetColor(0, 0, 0); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(1.0, 1.0, 1.0); // add our actor to the renderer renderer.AddActor(contourActor); renderer.AddActor(outlineActor); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVextractRectGrid(String [] argv) { //Prefix Content is: "" // create pipeline - rectilinear grid[] //[] rgridReader = new vtkRectilinearGridReader(); rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); rgridReader.Update(); extract1 = new vtkExtractRectilinearGrid(); extract1.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); //extract1 SetVOI 0 46 0 32 0 10[] extract1.SetVOI((int)23,(int)40,(int)16,(int)30,(int)9,(int)9); extract1.SetSampleRate((int)2,(int)2,(int)1); extract1.IncludeBoundaryOn(); extract1.Update(); surf1 = new vtkDataSetSurfaceFilter(); surf1.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort()); tris = new vtkTriangleFilter(); tris.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort()); mapper1 = vtkPolyDataMapper.New(); mapper1.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort()); mapper1.SetScalarRange((double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[1]); actor1 = new vtkActor(); actor1.SetMapper((vtkMapper)mapper1); // write out a rect grid[] // write to the temp directory if possible, otherwise use .[] dir = "."; dir = TclToCsScriptTestDriver.GetTempDirectory(); // make sure the directory is writeable first[] try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); rectWriter = new vtkRectilinearGridWriter(); rectWriter.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort()); rectWriter.SetFileName((string)"" + (dir.ToString()) + "/rect.tmp"); rectWriter.Write(); // delete the file[] File.Delete("" + (dir.ToString()) + "/rect.tmp"); } // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); //ren1 AddActor actor[] ren1.AddActor((vtkProp)actor1); renWin.SetSize((int)340,(int)400); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVprobeComb(String [] argv) { //Prefix Content is: "" // create planes[] // 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); // create pipeline[] //[] 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(); plane = new vtkPlaneSource(); plane.SetResolution((int)50, (int)50); transP1 = new vtkTransform(); transP1.Translate((double)3.7, (double)0.0, (double)28.37); transP1.Scale((double)5, (double)5, (double)5); transP1.RotateY((double)90); tpd1 = new vtkTransformPolyDataFilter(); tpd1.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd1.SetTransform((vtkAbstractTransform)transP1); outTpd1 = new vtkOutlineFilter(); outTpd1.SetInputConnection((vtkAlgorithmOutput)tpd1.GetOutputPort()); mapTpd1 = vtkPolyDataMapper.New(); mapTpd1.SetInputConnection((vtkAlgorithmOutput)outTpd1.GetOutputPort()); tpd1Actor = new vtkActor(); tpd1Actor.SetMapper((vtkMapper)mapTpd1); tpd1Actor.GetProperty().SetColor((double)0, (double)0, (double)0); transP2 = new vtkTransform(); transP2.Translate((double)9.2, (double)0.0, (double)31.20); transP2.Scale((double)5, (double)5, (double)5); transP2.RotateY((double)90); tpd2 = new vtkTransformPolyDataFilter(); tpd2.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd2.SetTransform((vtkAbstractTransform)transP2); outTpd2 = new vtkOutlineFilter(); outTpd2.SetInputConnection((vtkAlgorithmOutput)tpd2.GetOutputPort()); mapTpd2 = vtkPolyDataMapper.New(); mapTpd2.SetInputConnection((vtkAlgorithmOutput)outTpd2.GetOutputPort()); tpd2Actor = new vtkActor(); tpd2Actor.SetMapper((vtkMapper)mapTpd2); tpd2Actor.GetProperty().SetColor((double)0, (double)0, (double)0); transP3 = new vtkTransform(); transP3.Translate((double)13.27, (double)0.0, (double)33.30); transP3.Scale((double)5, (double)5, (double)5); transP3.RotateY((double)90); tpd3 = new vtkTransformPolyDataFilter(); tpd3.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd3.SetTransform((vtkAbstractTransform)transP3); outTpd3 = new vtkOutlineFilter(); outTpd3.SetInputConnection((vtkAlgorithmOutput)tpd3.GetOutputPort()); mapTpd3 = vtkPolyDataMapper.New(); mapTpd3.SetInputConnection((vtkAlgorithmOutput)outTpd3.GetOutputPort()); tpd3Actor = new vtkActor(); tpd3Actor.SetMapper((vtkMapper)mapTpd3); tpd3Actor.GetProperty().SetColor((double)0, (double)0, (double)0); appendF = new vtkAppendPolyData(); appendF.AddInputConnection(tpd1.GetOutputPort()); appendF.AddInputConnection(tpd2.GetOutputPort()); appendF.AddInputConnection(tpd3.GetOutputPort()); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)appendF.GetOutputPort()); probe.SetSourceData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); contour.GenerateValues((int)50, (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); contourMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)contourMapper); 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); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)tpd1Actor); ren1.AddActor((vtkProp)tpd2Actor); ren1.AddActor((vtkProp)tpd3Actor); 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)8.88908, (double)0.595038, (double)29.3342); cam1.SetPosition((double)-12.3332, (double)31.7479, (double)41.2387); cam1.SetViewUp((double)0.060772, (double)-0.319905, (double)0.945498); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <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(); }
private void DrawVisQuad() { //# This example demonstrates the use of the contour filter, and the use of //# the vtkSampleFunction to generate a volume of data samples from an //# implicit function. //# VTK supports implicit functions of the form f(x,y,z)=constant. These //# functions can represent things spheres, cones, etc. Here we use a //# general form for a quadric to create an elliptical data field. vtkQuadric quadricFunction = vtkQuadric.New(); quadricFunction.SetCoefficients(0.5, 1, 0.2, 0, 0.1, 0, 0, 0.2, 0, 0); //# vtkSampleFunction samples an implicit function over the x-y-z range //# specified (here it defaults to -1,1 in the x,y,z directions). vtkSampleFunction sample = vtkSampleFunction.New(); sample.SetSampleDimensions(30, 30, 30); sample.SetImplicitFunction(quadricFunction); //# Create five surfaces F(x,y,z) = constant between range specified. The //# GenerateValues() method creates n isocontour values between the range //# specified. vtkContourFilter contourFilter = vtkContourFilter.New(); contourFilter.SetInputConnection(sample.GetOutputPort()); contourFilter.GenerateValues(10, 0.0, 1.2); vtkPolyDataMapper contMapper = vtkPolyDataMapper.New(); contMapper.SetInputConnection(contourFilter.GetOutputPort()); contMapper.SetScalarRange(0.0, 1.2); vtkActor conActor = vtkActor.New(); conActor.SetMapper(contMapper); //We'll put a simple outline around the data vtkOutlineFilter outline = vtkOutlineFilter.New(); outline.SetInputConnection(sample.GetOutputPort()); vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection(outline.GetOutputPort()); vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); outlineActor.GetProperty().SetColor(0, 0, 0); //The usual rendering stuff vtkRenderer ren = vtkRenderer.New(); vtkRenderWindow renWin = myRenderWindowControl.RenderWindow; //vtkRenderWindow renWin = vtkRenderWindow.New(); renWin.AddRenderer(ren); //vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New(); //iren.SetRenderWindow(renWin); ren.SetBackground(1, 1, 1); ren.AddActor(conActor); ren.AddActor(outlineActor); //iren.Initialize(); //renWin.Render(); //iren.Start(); }
/// <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(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVExtractTensors(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); ptLoad = new vtkPointLoad(); ptLoad.SetLoadValue((double)100.0); ptLoad.SetSampleDimensions((int)30,(int)30,(int)30); ptLoad.ComputeEffectiveStressOn(); ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10); extractTensor = new vtkExtractTensorComponents(); extractTensor.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); extractTensor.ScalarIsEffectiveStress(); extractTensor.ScalarIsComponent(); extractTensor.ExtractScalarsOn(); extractTensor.ExtractVectorsOn(); extractTensor.ExtractNormalsOff(); extractTensor.ExtractTCoordsOn(); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)extractTensor.GetOutputPort()); contour.SetValue((int)0,(double)0); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); probe.SetSource((vtkDataObject)ptLoad.GetOutput()); su = new vtkLoopSubdivisionFilter(); su.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); su.SetNumberOfSubdivisions((int)1); s1Mapper = vtkPolyDataMapper.New(); s1Mapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); // s1Mapper SetInputConnection [su GetOutputPort][] s1Actor = new vtkActor(); s1Actor.SetMapper((vtkMapper)s1Mapper); //[] // 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)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); ga = new vtkActor(); ga.SetMapper((vtkMapper)gm); s1Mapper.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); //[] // 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)s1Actor); 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(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVHyper(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and interactive renderer[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); 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); //[] // 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"); wSP = new vtkDataSetWriter(); wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); wSP.SetFileName((string)"wSP.vtk"); wSP.SetTensorsName((string)"pointload"); wSP.SetScalarsName((string)"effective_stress"); wSP.Write(); rSP = new vtkDataSetReader(); rSP.SetFileName((string)"wSP.vtk"); rSP.SetTensorsName((string)"pointload"); rSP.SetScalarsName((string)"effective_stress"); rSP.Update(); input = rSP.GetOutput(); File.Delete("wSP.vtk"); } else { input = ptLoad.GetOutput(); } // Generate hyperstreamlines[] s1 = new vtkHyperStreamline(); s1.SetInputData((vtkDataObject)input); 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); 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.SetInputData((vtkDataObject)input); 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)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]); s2Actor = new vtkActor(); s2Actor.SetMapper((vtkMapper)s2Mapper); s3 = new vtkHyperStreamline(); s3.SetInputData((vtkDataObject)input); 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)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]); s3Actor = new vtkActor(); s3Actor.SetMapper((vtkMapper)s3Mapper); s4 = new vtkHyperStreamline(); s4.SetInputData((vtkDataObject)input); 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)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]); s4Actor = new vtkActor(); s4Actor.SetMapper((vtkMapper)s4Mapper); // plane for context[] //[] g = new vtkImageDataGeometryFilter(); g.SetInputData((vtkDataObject)input); 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)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); ga = new vtkActor(); ga.SetMapper((vtkMapper)gm); // Create outline around data[] //[] outline = new vtkOutlineFilter(); outline.SetInputData((vtkDataObject)input); 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)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(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToRGrid(String [] argv) { //Prefix Content is: "" //# Generate a rectilinear grid from a field.[] //#[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkDataSetReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("RGridField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"RGridField.vtk"); writer.Write(); // Read the field[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"RGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToRectilinearGrid(); do2ds.SetDimensionsComponent((string)"Dimensions",(int)0); do2ds.SetPointComponent((int)0,(string)"XCoordinates",(int)0); do2ds.SetPointComponent((int)1,(string)"YCoordinates",(int)0); do2ds.SetPointComponent((int)2,(string)"ZCoordinates",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetRectilinearGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0,(string)"vectors",(int)0); fd2ad.SetVectorComponent((int)1,(string)"vectors",(int)1); fd2ad.SetVectorComponent((int)2,(string)"vectors",(int)2); fd2ad.SetScalarComponent((int)0,(string)"scalars",(int)0); fd2ad.Update(); // create pipeline[] //[] plane = new vtkRectilinearGridGeometryFilter(); plane.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813,(double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); cutPlane.SetOrigin(fd2ad.GetOutput().GetCenter()[0],fd2ad.GetOutput().GetCenter()[1],fd2ad.GetOutput().GetCenter()[2]); cutPlane.SetNormal((double)1,(double)0,(double)0); planeCut = new vtkCutter(); planeCut.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); iso.SetValue((int)0,(double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 ); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)fd2ad.GetOutputPort()); streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadiusToVaryRadiusByVector(); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 ); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] 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)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); ren1.GetActiveCamera().SetPosition((double)0.0390893,(double)0.184813,(double)-3.94026); ren1.GetActiveCamera().SetFocalPoint((double)-0.00578326,(double)0,(double)0.701967); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)0.00850257,(double)0.999169,(double)0.0398605); ren1.GetActiveCamera().SetClippingRange((double)3.08127,(double)6.62716); iren.Initialize(); // render the image[] //[] File.Delete("RGridField.vtk"); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToRGrid(String [] argv) { //Prefix Content is: "" //# Generate a rectilinear grid from a field.[] //#[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkDataSetReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("RGridField.vtk"); tryCatchError = "NOERROR"; } catch (Exception) { tryCatchError = "ERROR"; } if (tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"RGridField.vtk"); writer.Write(); // Read the field[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"RGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToRectilinearGrid(); do2ds.SetDimensionsComponent((string)"Dimensions", (int)0); do2ds.SetPointComponent((int)0, (string)"XCoordinates", (int)0); do2ds.SetPointComponent((int)1, (string)"YCoordinates", (int)0); do2ds.SetPointComponent((int)2, (string)"ZCoordinates", (int)0); do2ds.Update(); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInputData((vtkDataObject)do2ds.GetRectilinearGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0, (string)"vectors", (int)0); fd2ad.SetVectorComponent((int)1, (string)"vectors", (int)1); fd2ad.SetVectorComponent((int)2, (string)"vectors", (int)2); fd2ad.SetScalarComponent((int)0, (string)"scalars", (int)0); fd2ad.Update(); // create pipeline[] //[] plane = new vtkRectilinearGridGeometryFilter(); plane.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); plane.SetExtent((int)0, (int)100, (int)0, (int)100, (int)15, (int)15); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813, (double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); cutPlane.SetOrigin(fd2ad.GetOutput().GetCenter()[0], fd2ad.GetOutput().GetCenter()[1], fd2ad.GetOutput().GetCenter()[2]); cutPlane.SetNormal((double)1, (double)0, (double)0); planeCut = new vtkCutter(); planeCut.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); iso.SetValue((int)0, (double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double)1.0000, 0.8941, 0.7686); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)fd2ad.GetOutputPort()); streamer.SetStartPosition((double)-1.2, (double)-0.1, (double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadiusToVaryRadiusByVector(); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0.0000, 0.0000, 0.0000); // 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)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)300, (int)300); ren1.GetActiveCamera().SetPosition((double)0.0390893, (double)0.184813, (double)-3.94026); ren1.GetActiveCamera().SetFocalPoint((double)-0.00578326, (double)0, (double)0.701967); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)0.00850257, (double)0.999169, (double)0.0398605); ren1.GetActiveCamera().SetClippingRange((double)3.08127, (double)6.62716); iren.Initialize(); // render the image[] //[] File.Delete("RGridField.vtk"); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVprobeComb(String [] argv) { //Prefix Content is: "" // create planes[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkPLOT3DReader(); 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(); plane = new vtkPlaneSource(); plane.SetResolution((int)50,(int)50); transP1 = new vtkTransform(); transP1.Translate((double)3.7,(double)0.0,(double)28.37); transP1.Scale((double)5,(double)5,(double)5); transP1.RotateY((double)90); tpd1 = new vtkTransformPolyDataFilter(); tpd1.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd1.SetTransform((vtkAbstractTransform)transP1); outTpd1 = new vtkOutlineFilter(); outTpd1.SetInputConnection((vtkAlgorithmOutput)tpd1.GetOutputPort()); mapTpd1 = vtkPolyDataMapper.New(); mapTpd1.SetInputConnection((vtkAlgorithmOutput)outTpd1.GetOutputPort()); tpd1Actor = new vtkActor(); tpd1Actor.SetMapper((vtkMapper)mapTpd1); tpd1Actor.GetProperty().SetColor((double)0,(double)0,(double)0); transP2 = new vtkTransform(); transP2.Translate((double)9.2,(double)0.0,(double)31.20); transP2.Scale((double)5,(double)5,(double)5); transP2.RotateY((double)90); tpd2 = new vtkTransformPolyDataFilter(); tpd2.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd2.SetTransform((vtkAbstractTransform)transP2); outTpd2 = new vtkOutlineFilter(); outTpd2.SetInputConnection((vtkAlgorithmOutput)tpd2.GetOutputPort()); mapTpd2 = vtkPolyDataMapper.New(); mapTpd2.SetInputConnection((vtkAlgorithmOutput)outTpd2.GetOutputPort()); tpd2Actor = new vtkActor(); tpd2Actor.SetMapper((vtkMapper)mapTpd2); tpd2Actor.GetProperty().SetColor((double)0,(double)0,(double)0); transP3 = new vtkTransform(); transP3.Translate((double)13.27,(double)0.0,(double)33.30); transP3.Scale((double)5,(double)5,(double)5); transP3.RotateY((double)90); tpd3 = new vtkTransformPolyDataFilter(); tpd3.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd3.SetTransform((vtkAbstractTransform)transP3); outTpd3 = new vtkOutlineFilter(); outTpd3.SetInputConnection((vtkAlgorithmOutput)tpd3.GetOutputPort()); mapTpd3 = vtkPolyDataMapper.New(); mapTpd3.SetInputConnection((vtkAlgorithmOutput)outTpd3.GetOutputPort()); tpd3Actor = new vtkActor(); tpd3Actor.SetMapper((vtkMapper)mapTpd3); tpd3Actor.GetProperty().SetColor((double)0,(double)0,(double)0); appendF = new vtkAppendPolyData(); appendF.AddInput((vtkPolyData)tpd1.GetOutput()); appendF.AddInput((vtkPolyData)tpd2.GetOutput()); appendF.AddInput((vtkPolyData)tpd3.GetOutput()); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)appendF.GetOutputPort()); probe.SetSource((vtkDataObject)pl3d.GetOutput()); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); contour.GenerateValues((int)50,(double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); contourMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)contourMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)pl3d.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); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)tpd1Actor); ren1.AddActor((vtkProp)tpd2Actor); ren1.AddActor((vtkProp)tpd3Actor); 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)8.88908,(double)0.595038,(double)29.3342); cam1.SetPosition((double)-12.3332,(double)31.7479,(double)41.2387); cam1.SetViewUp((double)0.060772,(double)-0.319905,(double)0.945498); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void MarchingSquares() { // Path to vtk data must be set as an environment variable // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0" vtkTesting test = vtkTesting.New(); string root = test.GetDataRoot(); vtkVolume16Reader v16 = vtkVolume16Reader.New(); v16.SetDataDimensions(64, 64); v16.GetOutput().SetOrigin(0.0, 0.0, 0.0); v16.SetDataByteOrderToLittleEndian(); v16.SetFilePrefix(System.IO.Path.Combine(root, @"Data\headsq\quarter")); v16.SetImageRange(1, 93); v16.SetDataSpacing(3.2, 3.2, 1.5); v16.Update(); vtkMergePoints myLocator = vtkMergePoints.New(); vtkMarchingSquares isoXY = vtkMarchingSquares.New(); #if VTK_MAJOR_VERSION_5 isoXY.SetInputConnection(v16.GetOutputPort()); #else isoXY.SetInputData(v16); #endif isoXY.GenerateValues(2, 600, 1200); isoXY.SetImageRange(0, 32, 32, 63, 45, 45); isoXY.SetLocator(myLocator); vtkPolyDataMapper isoXYMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 isoXYMapper.SetInputConnection(isoXY.GetOutputPort()); #else isoXYMapper.SetInputData(isoXY); #endif isoXYMapper.SetScalarRange(600, 1200); vtkActor isoXYActor = vtkActor.New(); isoXYActor.SetMapper(isoXYMapper); vtkMarchingSquares isoYZ = vtkMarchingSquares.New(); #if VTK_MAJOR_VERSION_5 isoYZ.SetInputConnection(v16.GetOutputPort()); #else isoYZ.SetInputData(v16); #endif isoYZ.GenerateValues(2, 600, 1200); isoYZ.SetImageRange(32, 32, 32, 63, 46, 92); vtkPolyDataMapper isoYZMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 isoYZMapper.SetInputConnection(isoYZ.GetOutputPort()); #else isoYZMapper.SetInputData(isoYZ); #endif isoYZMapper.SetScalarRange(600, 1200); vtkActor isoYZActor = vtkActor.New(); isoYZActor.SetMapper(isoYZMapper); vtkMarchingSquares isoXZ = vtkMarchingSquares.New(); #if VTK_MAJOR_VERSION_5 isoXZ.SetInputConnection(v16.GetOutputPort()); #else isoXZ.SetInputData(v16); #endif isoXZ.GenerateValues(2, 600, 1200); isoXZ.SetImageRange(0, 32, 32, 32, 0, 46); vtkPolyDataMapper isoXZMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 isoXZMapper.SetInputConnection(isoXZ.GetOutputPort()); #else isoXZMapper.SetInputData(isoXZ); #endif isoXZMapper.SetScalarRange(600, 1200); vtkActor isoXZActor = vtkActor.New(); isoXZActor.SetMapper(isoXZMapper); vtkOutlineFilter outline = vtkOutlineFilter.New(); #if VTK_MAJOR_VERSION_5 outline.SetInputConnection(v16.GetOutputPort()); #else outline.SetInputData(v16); #endif vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 outlineMapper.SetInputConnection(outline.GetOutputPort()); #else outlineMapper.SetInputData(outline); #endif vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); outlineActor.VisibilityOff(); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(1.0, 1.0, 1.0); //Add the actors to the renderer, set the background and size renderer.AddActor(outlineActor); renderer.AddActor(isoXYActor); renderer.AddActor(isoYZActor); renderer.AddActor(isoXZActor); renderer.GetActiveCamera().SetPosition(324.368, 284.266, -19.3293); renderer.GetActiveCamera().SetFocalPoint(73.5683, 120.903, 70.7309); renderer.GetActiveCamera().SetViewAngle(30); renderer.GetActiveCamera().SetViewUp(-0.304692, -0.0563843, -0.950781); }
/// <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(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVextractRectGrid(String [] argv) { //Prefix Content is: "" // create pipeline - rectilinear grid[] //[] rgridReader = new vtkRectilinearGridReader(); rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); rgridReader.Update(); extract1 = new vtkExtractRectilinearGrid(); extract1.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); //extract1 SetVOI 0 46 0 32 0 10[] extract1.SetVOI((int)23, (int)40, (int)16, (int)30, (int)9, (int)9); extract1.SetSampleRate((int)2, (int)2, (int)1); extract1.IncludeBoundaryOn(); extract1.Update(); surf1 = new vtkDataSetSurfaceFilter(); surf1.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort()); tris = new vtkTriangleFilter(); tris.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort()); mapper1 = vtkPolyDataMapper.New(); mapper1.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort()); mapper1.SetScalarRange((double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[1]); actor1 = new vtkActor(); actor1.SetMapper((vtkMapper)mapper1); // write out a rect grid[] // write to the temp directory if possible, otherwise use .[] dir = "."; dir = TclToCsScriptTestDriver.GetTempDirectory(); // make sure the directory is writeable first[] try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryCatchError = "NOERROR"; } catch (Exception) { tryCatchError = "ERROR"; } if (tryCatchError.Equals("NOERROR")) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); rectWriter = new vtkRectilinearGridWriter(); rectWriter.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort()); rectWriter.SetFileName((string)"" + (dir.ToString()) + "/rect.tmp"); rectWriter.Write(); // delete the file[] File.Delete("" + (dir.ToString()) + "/rect.tmp"); } // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); //ren1 AddActor actor[] ren1.AddActor((vtkProp)actor1); renWin.SetSize((int)340, (int)400); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <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.SetMultiSamples(0); 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.SetInputData((vtkDataObject)reader.GetGridOutput()); readerSS.SetShift((double)min * -1); readerSS.SetScale((double)255 / (max - min)); readerSS.SetOutputScalarTypeToUnsignedChar(); bounds = new vtkOutlineFilter(); bounds.SetInputData((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.SetInputData((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.SetSourceConnection(Sphere.GetOutputPort()); AtomsMapper = vtkPolyDataMapper.New(); AtomsMapper.SetInputConnection((vtkAlgorithmOutput)Glyph.GetOutputPort()); AtomsMapper.SetImmediateModeRendering((int)1); AtomsMapper.UseLookupTableScalarRangeOff(); AtomsMapper.SetScalarVisibility((int)1); AtomsMapper.SetScalarModeToDefault(); Atoms = new vtkActor(); Atoms.SetMapper((vtkMapper)AtomsMapper); Atoms.GetProperty().SetRepresentationToSurface(); Atoms.GetProperty().SetInterpolationToGouraud(); Atoms.GetProperty().SetAmbient((double)0.15); Atoms.GetProperty().SetDiffuse((double)0.85); Atoms.GetProperty().SetSpecular((double)0.1); Atoms.GetProperty().SetSpecularPower((double)100); Atoms.GetProperty().SetSpecularColor((double)1, (double)1, (double)1); Atoms.GetProperty().SetColor((double)1, (double)1, (double)1); Tube = new vtkTubeFilter(); Tube.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); Tube.SetNumberOfSides((int)16); Tube.SetCapping((int)0); Tube.SetRadius((double)0.2); Tube.SetVaryRadius((int)0); Tube.SetRadiusFactor((double)10); BondsMapper = vtkPolyDataMapper.New(); BondsMapper.SetInputConnection((vtkAlgorithmOutput)Tube.GetOutputPort()); BondsMapper.SetImmediateModeRendering((int)1); BondsMapper.UseLookupTableScalarRangeOff(); BondsMapper.SetScalarVisibility((int)1); BondsMapper.SetScalarModeToDefault(); Bonds = new vtkActor(); Bonds.SetMapper((vtkMapper)BondsMapper); Bonds.GetProperty().SetRepresentationToSurface(); Bonds.GetProperty().SetInterpolationToGouraud(); Bonds.GetProperty().SetAmbient((double)0.15); Bonds.GetProperty().SetDiffuse((double)0.85); Bonds.GetProperty().SetSpecular((double)0.1); Bonds.GetProperty().SetSpecularPower((double)100); Bonds.GetProperty().SetSpecularColor((double)1, (double)1, (double)1); Bonds.GetProperty().SetColor((double)1, (double)1, (double)1); ren1.AddActor((vtkProp)Bonds); ren1.AddActor((vtkProp)Atoms); //###################################################[] ren1.SetBackground((double)1, (double)1, (double)1); ren1.ResetCamera(); renWin.Render(); //method moved renWin.AbortCheckEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(TkCheckAbort_Command.Execute); iren.Initialize(); //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVExtractTensors(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); ptLoad = new vtkPointLoad(); ptLoad.SetLoadValue((double)100.0); ptLoad.SetSampleDimensions((int)30, (int)30, (int)30); ptLoad.ComputeEffectiveStressOn(); ptLoad.SetModelBounds((double)-10, (double)10, (double)-10, (double)10, (double)-10, (double)10); extractTensor = new vtkExtractTensorComponents(); extractTensor.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); extractTensor.ScalarIsEffectiveStress(); extractTensor.ScalarIsComponent(); extractTensor.ExtractScalarsOn(); extractTensor.ExtractVectorsOn(); extractTensor.ExtractNormalsOff(); extractTensor.ExtractTCoordsOn(); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)extractTensor.GetOutputPort()); contour.SetValue((int)0, (double)0); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); probe.SetSourceConnection(ptLoad.GetOutputPort()); su = new vtkLoopSubdivisionFilter(); su.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); su.SetNumberOfSubdivisions((int)1); s1Mapper = vtkPolyDataMapper.New(); s1Mapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); // s1Mapper SetInputConnection [su GetOutputPort][] s1Actor = new vtkActor(); s1Actor.SetMapper((vtkMapper)s1Mapper); //[] // 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)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); ga = new vtkActor(); ga.SetMapper((vtkMapper)gm); s1Mapper.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); //[] // 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)s1Actor); 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(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVcursor3D(String [] argv) { //Prefix Content is: "" // This little example shows how a cursor can be created in [] // image viewers, and renderers. The standard TkImageViewerWidget and[] // TkRenderWidget bindings are used. There is a new binding:[] // middle button in the image viewer sets the position of the cursor. [] // First we include the VTK Tcl packages which will make available [] // all of the vtk commands to Tcl[] // Global values[] CURSOR_X = 20; CURSOR_Y = 20; CURSOR_Z = 20; IMAGE_MAG_X = 4; IMAGE_MAG_Y = 4; IMAGE_MAG_Z = 1; // Pipeline stuff[] reader = new vtkSLCReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/neghip.slc"); // Cursor stuff[] magnify = new vtkImageMagnify(); magnify.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); magnify.SetMagnificationFactors((int)IMAGE_MAG_X,(int)IMAGE_MAG_Y,(int)IMAGE_MAG_Z); image_cursor = new vtkImageCursor3D(); image_cursor.SetInputConnection((vtkAlgorithmOutput)magnify.GetOutputPort()); image_cursor.SetCursorPosition((double)CURSOR_X*IMAGE_MAG_X,(double)CURSOR_Y*IMAGE_MAG_Y,(double)CURSOR_Z*IMAGE_MAG_Z); image_cursor.SetCursorValue((double)255); image_cursor.SetCursorRadius((int)50*IMAGE_MAG_X); axes = new vtkAxes(); axes.SymmetricOn(); axes.SetOrigin((double)CURSOR_X,(double)CURSOR_Y,(double)CURSOR_Z); axes.SetScaleFactor((double)50.0); axes_mapper = vtkPolyDataMapper.New(); axes_mapper.SetInputConnection((vtkAlgorithmOutput)axes.GetOutputPort()); axesActor = new vtkActor(); axesActor.SetMapper((vtkMapper)axes_mapper); axesActor.GetProperty().SetAmbient((double)0.5); // Image viewer stuff[] viewer = new vtkImageViewer(); viewer.SetInputConnection((vtkAlgorithmOutput)image_cursor.GetOutputPort()); viewer.SetZSlice((int)CURSOR_Z*IMAGE_MAG_Z); viewer.SetColorWindow((double)256); viewer.SetColorLevel((double)128); //method moved //method moved //method moved // Create transfer functions for opacity and color[] opacity_transfer_function = new vtkPiecewiseFunction(); opacity_transfer_function.AddPoint((double)20,(double)0.0); opacity_transfer_function.AddPoint((double)255,(double)0.2); color_transfer_function = new vtkColorTransferFunction(); color_transfer_function.AddRGBPoint((double)0,(double)0,(double)0,(double)0); color_transfer_function.AddRGBPoint((double)64,(double)1,(double)0,(double)0); color_transfer_function.AddRGBPoint((double)128,(double)0,(double)0,(double)1); color_transfer_function.AddRGBPoint((double)192,(double)0,(double)1,(double)0); color_transfer_function.AddRGBPoint((double)255,(double)0,(double).2,(double)0); // Create properties, mappers, volume actors, and ray cast function[] volume_property = new vtkVolumeProperty(); volume_property.SetColor((vtkColorTransferFunction)color_transfer_function); volume_property.SetScalarOpacity((vtkPiecewiseFunction)opacity_transfer_function); composite_function = new vtkVolumeRayCastCompositeFunction(); volume_mapper = new vtkVolumeRayCastMapper(); volume_mapper.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); volume_mapper.SetVolumeRayCastFunction((vtkVolumeRayCastFunction)composite_function); volume = new vtkVolume(); volume.SetMapper((vtkAbstractVolumeMapper)volume_mapper); volume.SetProperty((vtkVolumeProperty)volume_property); // Create outline[] outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); outline_mapper = vtkPolyDataMapper.New(); outline_mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outline_mapper); outlineActor.GetProperty().SetColor((double)1,(double)1,(double)1); // Create the renderer[] ren1 = vtkRenderer.New(); ren1.AddActor((vtkProp)axesActor); ren1.AddVolume((vtkProp)volume); ren1.SetBackground((double)0.1,(double)0.2,(double)0.4); renWin2 = vtkRenderWindow.New(); renWin2.AddRenderer((vtkRenderer)ren1); renWin2.SetSize((int)256,(int)256); // Create the GUI: two renderer widgets and a quit button[] //tk window skipped.. // Set the window manager (wm command) so that it registers a[] // command to handle the WM_DELETE_WINDOW protocal request. This[] // request is triggered when the widget is closed using the standard[] // window manager icons or buttons. In this case the exit callback[] // will be called and it will free up any objects we created then exit[] // the application.[] // Help label, frame and quit button[] //tk window skipped.. //tk window skipped.. //tk window skipped.. //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVHyper(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and interactive renderer[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); 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); //[] // 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"); wSP = new vtkDataSetWriter(); wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); wSP.SetFileName((string)"wSP.vtk"); wSP.SetTensorsName((string)"pointload"); wSP.SetScalarsName((string)"effective_stress"); wSP.Write(); rSP = new vtkDataSetReader(); rSP.SetFileName((string)"wSP.vtk"); rSP.SetTensorsName((string)"pointload"); rSP.SetScalarsName((string)"effective_stress"); rSP.Update(); input = rSP.GetOutput(); File.Delete("wSP.vtk"); } else { input = ptLoad.GetOutput(); } // Generate hyperstreamlines[] s1 = new vtkHyperStreamline(); s1.SetInputData((vtkDataObject)input); 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); 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.SetInputData((vtkDataObject)input); 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)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]); s2Actor = new vtkActor(); s2Actor.SetMapper((vtkMapper)s2Mapper); s3 = new vtkHyperStreamline(); s3.SetInputData((vtkDataObject)input); 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)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]); s3Actor = new vtkActor(); s3Actor.SetMapper((vtkMapper)s3Mapper); s4 = new vtkHyperStreamline(); s4.SetInputData((vtkDataObject)input); 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)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]); s4Actor = new vtkActor(); s4Actor.SetMapper((vtkMapper)s4Mapper); // plane for context[] //[] g = new vtkImageDataGeometryFilter(); g.SetInputData((vtkDataObject)input); 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)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); ga = new vtkActor(); ga.SetMapper((vtkMapper)gm); // Create outline around data[] //[] outline = new vtkOutlineFilter(); outline.SetInputData((vtkDataObject)input); 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)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(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVEnSightRectGridASCII(String [] argv) { //Prefix Content is: "" VTK_VARY_RADIUS_BY_VECTOR = 2; // create pipeline[] //[] reader = new vtkGenericEnSightReader(); // Make sure all algorithms use the composite data pipeline[] cdp = new vtkCompositeDataPipeline(); vtkGenericEnSightReader.SetDefaultExecutivePrototype((vtkExecutive)cdp); reader.SetCaseFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/EnSight/RectGrid_ascii.case"); reader.Update(); toRectilinearGrid = new vtkCastToConcrete(); // toRectilinearGrid SetInputConnection [reader GetOutputPort] [] toRectilinearGrid.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); plane = new vtkRectilinearGridGeometryFilter(); plane.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15); tri = new vtkTriangleFilter(); tri.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)tri.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813,(double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); // eval cutPlane SetOrigin [[reader GetOutput] GetCenter][] cutPlane.SetOrigin((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[1], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[2]); cutPlane.SetNormal((double)1,(double)0,(double)0); planeCut = new vtkCutter(); planeCut.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange((double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); iso.SetValue((int)0,(double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 ); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); // streamer SetInputConnection [reader GetOutputPort][] streamer.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadius((int)VTK_VARY_RADIUS_BY_VECTOR); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]); // [[[[reader GetOutput] GetPointData] GetScalars] GetRange][] streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 ); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] 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)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)400,(int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.76213,(double)10.712); cam1.SetFocalPoint((double)-0.0842503,(double)-0.136905,(double)0.610234); cam1.SetPosition((double)2.53813,(double)2.2678,(double)-5.22172); cam1.SetViewUp((double)-0.241047,(double)0.930635,(double)0.275343); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] vtkGenericEnSightReader.SetDefaultExecutivePrototype(null); //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVrectGrid(String [] argv) { //Prefix Content is: "" VTK_VARY_RADIUS_BY_VECTOR = 2; // create pipeline[] //[] reader = new vtkDataSetReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); reader.Update(); toRectilinearGrid = new vtkCastToConcrete(); toRectilinearGrid.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); toRectilinearGrid.Update(); plane = new vtkRectilinearGridGeometryFilter(); plane.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); plane.SetExtent((int)0, (int)100, (int)0, (int)100, (int)15, (int)15); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813, (double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); cutPlane.SetOrigin(reader.GetOutput().GetCenter()[0], reader.GetOutput().GetCenter()[1], reader.GetOutput().GetCenter()[2]); cutPlane.SetNormal((double)1, (double)0, (double)0); planeCut = new vtkCutter(); planeCut.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); iso.SetValue((int)0, (double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double)1.0000, 0.8941, 0.7686); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); streamer.SetStartPosition((double)-1.2, (double)-0.1, (double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadius((int)VTK_VARY_RADIUS_BY_VECTOR); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[1]); streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0.0000, 0.0000, 0.0000); // 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)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)400, (int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.76213, (double)10.712); cam1.SetFocalPoint((double)-0.0842503, (double)-0.136905, (double)0.610234); cam1.SetPosition((double)2.53813, (double)2.2678, (double)-5.22172); cam1.SetViewUp((double)-0.241047, (double)0.930635, (double)0.275343); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVcursor3D(String [] argv) { //Prefix Content is: "" // This little example shows how a cursor can be created in [] // image viewers, and renderers. The standard TkImageViewerWidget and[] // TkRenderWidget bindings are used. There is a new binding:[] // middle button in the image viewer sets the position of the cursor. [] // First we include the VTK Tcl packages which will make available [] // all of the vtk commands to Tcl[] // Global values[] CURSOR_X = 20; CURSOR_Y = 20; CURSOR_Z = 20; IMAGE_MAG_X = 4; IMAGE_MAG_Y = 4; IMAGE_MAG_Z = 1; // Pipeline stuff[] reader = new vtkSLCReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/neghip.slc"); // Cursor stuff[] magnify = new vtkImageMagnify(); magnify.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); magnify.SetMagnificationFactors((int)IMAGE_MAG_X, (int)IMAGE_MAG_Y, (int)IMAGE_MAG_Z); image_cursor = new vtkImageCursor3D(); image_cursor.SetInputConnection((vtkAlgorithmOutput)magnify.GetOutputPort()); image_cursor.SetCursorPosition((double)CURSOR_X * IMAGE_MAG_X, (double)CURSOR_Y * IMAGE_MAG_Y, (double)CURSOR_Z * IMAGE_MAG_Z); image_cursor.SetCursorValue((double)255); image_cursor.SetCursorRadius((int)50 * IMAGE_MAG_X); axes = new vtkAxes(); axes.SymmetricOn(); axes.SetOrigin((double)CURSOR_X, (double)CURSOR_Y, (double)CURSOR_Z); axes.SetScaleFactor((double)50.0); axes_mapper = vtkPolyDataMapper.New(); axes_mapper.SetInputConnection((vtkAlgorithmOutput)axes.GetOutputPort()); axesActor = new vtkActor(); axesActor.SetMapper((vtkMapper)axes_mapper); axesActor.GetProperty().SetAmbient((double)0.5); // Image viewer stuff[] viewer = new vtkImageViewer(); viewer.SetInputConnection((vtkAlgorithmOutput)image_cursor.GetOutputPort()); viewer.SetZSlice((int)CURSOR_Z * IMAGE_MAG_Z); viewer.SetColorWindow((double)256); viewer.SetColorLevel((double)128); //method moved //method moved //method moved // Create transfer functions for opacity and color[] opacity_transfer_function = new vtkPiecewiseFunction(); opacity_transfer_function.AddPoint((double)20, (double)0.0); opacity_transfer_function.AddPoint((double)255, (double)0.2); color_transfer_function = new vtkColorTransferFunction(); color_transfer_function.AddRGBPoint((double)0, (double)0, (double)0, (double)0); color_transfer_function.AddRGBPoint((double)64, (double)1, (double)0, (double)0); color_transfer_function.AddRGBPoint((double)128, (double)0, (double)0, (double)1); color_transfer_function.AddRGBPoint((double)192, (double)0, (double)1, (double)0); color_transfer_function.AddRGBPoint((double)255, (double)0, (double).2, (double)0); // Create properties, mappers, volume actors, and ray cast function[] volume_property = new vtkVolumeProperty(); volume_property.SetColor((vtkColorTransferFunction)color_transfer_function); volume_property.SetScalarOpacity((vtkPiecewiseFunction)opacity_transfer_function); composite_function = new vtkVolumeRayCastCompositeFunction(); volume_mapper = new vtkVolumeRayCastMapper(); volume_mapper.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); volume_mapper.SetVolumeRayCastFunction((vtkVolumeRayCastFunction)composite_function); volume = new vtkVolume(); volume.SetMapper((vtkAbstractVolumeMapper)volume_mapper); volume.SetProperty((vtkVolumeProperty)volume_property); // Create outline[] outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); outline_mapper = vtkPolyDataMapper.New(); outline_mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outline_mapper); outlineActor.GetProperty().SetColor((double)1, (double)1, (double)1); // Create the renderer[] ren1 = vtkRenderer.New(); ren1.AddActor((vtkProp)axesActor); ren1.AddVolume((vtkProp)volume); ren1.SetBackground((double)0.1, (double)0.2, (double)0.4); renWin2 = vtkRenderWindow.New(); renWin2.AddRenderer((vtkRenderer)ren1); renWin2.SetSize((int)256, (int)256); // Create the GUI: two renderer widgets and a quit button[] //tk window skipped.. // Set the window manager (wm command) so that it registers a[] // command to handle the WM_DELETE_WINDOW protocal request. This[] // request is triggered when the widget is closed using the standard[] // window manager icons or buttons. In this case the exit callback[] // will be called and it will free up any objects we created then exit[] // the application.[] // Help label, frame and quit button[] //tk window skipped.. //tk window skipped.. //tk window skipped.. //deleteAllVTKObjects(); }
/// <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(); }