public Cone(ARenderable parent) : base(parent) { Name = "Cone"; cone = vtkConeSource.New(); cone.SetAngle(10); cone.SetRadius(0.2); cone.SetHeight(0.5); cone.SetResolution(20); move = vtkTransform.New(); move.Translate(_random.NextDouble(), _random.NextDouble(), _random.NextDouble()); moveFilter = vtkTransformPolyDataFilter.New(); moveFilter.SetTransform(move); moveFilter.SetInputConnection(cone.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(moveFilter.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); Actors = new ObservableCollection <vtkActor>(); Actors.Add(actor); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVEnSightOfficeBin(String [] argv) { //Prefix Content is: "" ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // read data[] //[] 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/office_bin.case"); reader.Update(); // to add coverage for vtkOnePieceExtentTranslator[] translator = new vtkOnePieceExtentTranslator(); vtkStreamingDemandDrivenPipeline.SetExtentTranslator(reader.GetOutputInformation(0), (vtkExtentTranslator)translator); outline = new vtkStructuredGridOutlineFilter(); // outline SetInputConnection [reader GetOutputPort][] outline.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); mapOutline = vtkPolyDataMapper.New(); mapOutline.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)mapOutline); outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0); // Create source for streamtubes[] streamer = new vtkStreamPoints(); // streamer SetInputConnection [reader GetOutputPort][] streamer.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); streamer.SetStartPosition((double)0.1, (double)2.1, (double)0.5); streamer.SetMaximumPropagationTime((double)500); streamer.SetTimeIncrement((double)0.5); streamer.SetIntegrationDirectionToForward(); cone = new vtkConeSource(); cone.SetResolution((int)8); cones = new vtkGlyph3D(); cones.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); cones.SetSourceConnection(cone.GetOutputPort()); cones.SetScaleFactor((double)0.9); cones.SetScaleModeToScaleByVector(); mapCones = vtkPolyDataMapper.New(); mapCones.SetInputConnection((vtkAlgorithmOutput)cones.GetOutputPort()); // eval mapCones SetScalarRange [[reader GetOutput] GetScalarRange][] mapCones.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[1]); conesActor = new vtkActor(); conesActor.SetMapper((vtkMapper)mapCones); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)conesActor); ren1.SetBackground((double)0.4, (double)0.4, (double)0.5); renWin.SetSize((int)300, (int)300); iren.Initialize(); // interact with data[] vtkGenericEnSightReader.SetDefaultExecutivePrototype(null); //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVEnSightOfficeBin(String [] argv) { //Prefix Content is: "" ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // read data[] //[] 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/office_bin.case"); reader.Update(); // to add coverage for vtkOnePieceExtentTranslator[] translator = new vtkOnePieceExtentTranslator(); vtkStreamingDemandDrivenPipeline.SetExtentTranslator(reader.GetOutputInformation(0), (vtkExtentTranslator)translator); outline = new vtkStructuredGridOutlineFilter(); // outline SetInputConnection [reader GetOutputPort][] outline.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); mapOutline = vtkPolyDataMapper.New(); mapOutline.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)mapOutline); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); // Create source for streamtubes[] streamer = new vtkStreamPoints(); // streamer SetInputConnection [reader GetOutputPort][] streamer.SetInputData((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); streamer.SetStartPosition((double)0.1,(double)2.1,(double)0.5); streamer.SetMaximumPropagationTime((double)500); streamer.SetTimeIncrement((double)0.5); streamer.SetIntegrationDirectionToForward(); cone = new vtkConeSource(); cone.SetResolution((int)8); cones = new vtkGlyph3D(); cones.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); cones.SetSourceConnection(cone.GetOutputPort()); cones.SetScaleFactor((double)0.9); cones.SetScaleModeToScaleByVector(); mapCones = vtkPolyDataMapper.New(); mapCones.SetInputConnection((vtkAlgorithmOutput)cones.GetOutputPort()); // eval mapCones SetScalarRange [[reader GetOutput] GetScalarRange][] mapCones.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetScalarRange()[1]); conesActor = new vtkActor(); conesActor.SetMapper((vtkMapper)mapCones); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)conesActor); ren1.SetBackground((double)0.4,(double)0.4,(double)0.5); renWin.SetSize((int)300,(int)300); iren.Initialize(); // interact with data[] vtkGenericEnSightReader.SetDefaultExecutivePrototype(null); //deleteAllVTKObjects(); }
// Static void method with same signature as "Main" is always // file base name: // /// <summary> /// VTK test Main method /// </summary> public static void vtkConeSourceTest(string[] args) { bool interactive = false; foreach (string s in args) { // -I means "interactive" test -- do not automatically quit: // if (s == "-I") { interactive = true; } } vtkConeSource source = new vtkConeSource(); vtkMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(source.GetOutputPort()); vtkActor actor = new vtkActor(); actor.SetMapper(mapper); vtkRenderer ren1 = vtkRenderer.New(); ren1.AddActor(actor); ren1.SetBackground(0.1, 0.2, 0.4); vtkRenderWindow renWin = vtkRenderWindow.New(); renWin.AddRenderer(ren1); renWin.SetSize(400, 300); vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New(); iren.SetRenderWindow(renWin); iren.Initialize(); Kitware.mummy.Runtime.Methods.Print(false); Kitware.mummy.Runtime.Methods.PrintWrappedObjectsTable(); if (interactive) { iren.Start(); } ren1.SetRenderWindow(null); iren.SetRenderWindow(null); renWin.Dispose(); }
static public vtkAlgorithmOutput genFrustumCone(double total_dis, double end_radius, double distance, bool is_reverse) { vtkConeSource cone = vtkConeSource.New(); cone.SetHeight(total_dis * 1.2); cone.SetRadius(end_radius * 1.2); cone.SetCenter(0, 0, total_dis * 0.4); cone.SetResolution(80); cone.SetDirection(0, 0, 1); cone.Update(); vtkPlane plane = vtkPlane.New(); plane.SetOrigin(0, 0, 0); plane.SetNormal(0, 0, 1); vtkClipPolyData clipPolyData = vtkClipPolyData.New(); clipPolyData.SetInputConnection(cone.GetOutputPort()); clipPolyData.SetClipFunction(plane); clipPolyData.GenerateClippedOutputOn(); clipPolyData.Update(); vtkPlane plane2 = vtkPlane.New(); plane2.SetOrigin(0, 0, distance); plane2.SetNormal(0, 0, -1); vtkClipPolyData clipPolyData2 = vtkClipPolyData.New(); clipPolyData2.SetInputConnection(clipPolyData.GetOutputPort()); clipPolyData2.SetClipFunction(plane2); clipPolyData2.GenerateClippedOutputOn(); clipPolyData2.Update(); if (is_reverse) { vtkTransform transform = vtkTransform.New(); transform.RotateWXYZ(180, 0, 1, 0); transform.Translate(0, 0, -distance); vtkTransformPolyDataFilter transFilter = vtkTransformPolyDataFilter.New(); transFilter.SetInputConnection(clipPolyData2.GetOutputPort()); transFilter.SetTransform(transform); //use vtkTransform (or maybe vtkLinearTransform) transFilter.Update(); return(transFilter.GetOutputPort()); } return(clipPolyData2.GetOutputPort()); }
private void Cone() { // Create a cone. vtkConeSource coneSource = vtkConeSource.New(); // coneSource.SetCapping(1); // coneSource.SetRadius(0.5); // coneSource.SetResolution(32); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(coneSource.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); renderer.SetBackground(0.3, 0.2, 0.1); renderer.AddActor(actor); renderer.ResetCamera(); }
/// <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 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> /// Update Boundary Condition actor (arrows) in Viewport /// </summary> public void Update_Arrows(Dictionary <int, Node> NodeLib, double scale, int Step, bool ClipMode) { vtkPoints PointsX = vtkPoints.New(); vtkPoints PointsY = vtkPoints.New(); vtkPoints PointsZ = vtkPoints.New(); // Create Cone Sources for X, Y and Z direction vtkConeSource ConeSourceX = vtkConeSource.New(); vtkConeSource ConeSourceY = vtkConeSource.New(); vtkConeSource ConeSourceZ = vtkConeSource.New(); ConeSourceX.SetAngle(15); ConeSourceX.SetHeight(scale); ConeSourceX.SetRadius(scale / 4); ConeSourceX.SetResolution(12); ConeSourceX.SetDirection(1, 0, 0); ConeSourceY.SetAngle(15); ConeSourceY.SetHeight(scale); ConeSourceY.SetRadius(scale / 4); ConeSourceY.SetResolution(12); ConeSourceY.SetDirection(0, 1, 0); ConeSourceZ.SetAngle(15); ConeSourceZ.SetHeight(scale); ConeSourceZ.SetRadius(scale / 4); ConeSourceZ.SetResolution(12); ConeSourceZ.SetDirection(0, 0, 1); // Create Points foreach (int i in NodalValues.Keys) { double X = NodeLib[i].X + NodeLib[i].GetDisp(Step, 0); double Y = NodeLib[i].Y + NodeLib[i].GetDisp(Step, 1); double Z = NodeLib[i].Z + NodeLib[i].GetDisp(Step, 2); if (NodalValues[i].Get(0, 0) != 0) { PointsX.InsertNextPoint(X - scale / 2, Y, Z); } if (NodalValues[i].Get(1, 0) != 0) { PointsY.InsertNextPoint(X, Y - scale / 2, Z); } if (NodalValues[i].Get(2, 0) != 0) { PointsZ.InsertNextPoint(X, Y, Z - scale / 2); } } // Set Points to PolyData vtkPolyData PolyX = vtkPolyData.New(); PolyX.SetPoints(PointsX); vtkPolyData PolyY = vtkPolyData.New(); PolyY.SetPoints(PointsY); vtkPolyData PolyZ = vtkPolyData.New(); PolyZ.SetPoints(PointsZ); // Create Glyphs 3D GlyphX = vtkGlyph3D.New(); GlyphY = vtkGlyph3D.New(); GlyphZ = vtkGlyph3D.New(); GlyphX.SetSourceConnection(ConeSourceX.GetOutputPort()); GlyphX.SetInput(PolyX); GlyphX.Update(); GlyphY.SetSourceConnection(ConeSourceY.GetOutputPort()); GlyphY.SetInput(PolyY); GlyphY.Update(); GlyphZ.SetSourceConnection(ConeSourceZ.GetOutputPort()); GlyphZ.SetInput(PolyZ); GlyphZ.Update(); // Set Mapper based on Clip Mode if (ClipMode == true) { // Add Clippers to Mapper ClipperX.SetInputConnection(GlyphX.GetOutputPort()); ClipperX.Update(); MapperX.SetInputConnection(ClipperX.GetOutputPort()); MapperX.Update(); ClipperY.SetInputConnection(GlyphY.GetOutputPort()); ClipperY.Update(); MapperY.SetInputConnection(ClipperY.GetOutputPort()); MapperY.Update(); ClipperZ.SetInputConnection(GlyphZ.GetOutputPort()); ClipperZ.Update(); MapperZ.SetInputConnection(ClipperZ.GetOutputPort()); MapperZ.Update(); } else { // Add Glyphs to Mapper MapperX.SetInputConnection(GlyphX.GetOutputPort()); MapperY.SetInputConnection(GlyphY.GetOutputPort()); MapperZ.SetInputConnection(GlyphZ.GetOutputPort()); MapperX.Update(); MapperY.Update(); MapperZ.Update(); } // Update Actor color ActorX.GetProperty().SetColor( GetColor()[0] / 255.0, GetColor()[1] / 255.0, GetColor()[2] / 255.0); ActorY.GetProperty().SetColor( GetColor()[0] / 255.0, GetColor()[1] / 255.0, GetColor()[2] / 255.0); ActorZ.GetProperty().SetColor( GetColor()[0] / 255.0, GetColor()[1] / 255.0, GetColor()[2] / 255.0); }
private void DrawAssembly() { //Create four parts: a top level assembly and three primitives vtkSphereSource sphereSource = vtkSphereSource.New(); vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New(); sphereMapper.SetInputConnection(sphereSource.GetOutputPort()); vtkActor sphereActor = vtkActor.New(); sphereActor.SetMapper(sphereMapper); sphereActor.SetOrigin(2, 1, 3); sphereActor.RotateY(6); sphereActor.SetPosition(2.25, 0, 0); sphereActor.GetProperty().SetColor(1, 0, 1); vtkCubeSource cubeSource = vtkCubeSource.New(); vtkPolyDataMapper cubeMapper = vtkPolyDataMapper.New(); cubeMapper.SetInputConnection(cubeSource.GetOutputPort()); vtkActor cubeActor = vtkActor.New(); cubeActor.SetMapper(cubeMapper); cubeActor.SetPosition(0, 2.25, 0); cubeActor.GetProperty().SetColor(0, 0, 1); vtkConeSource coneSource = vtkConeSource.New(); vtkPolyDataMapper coneMapper = vtkPolyDataMapper.New(); coneMapper.SetInputConnection(coneSource.GetOutputPort()); vtkActor coneActor = vtkActor.New(); coneActor.SetMapper(coneMapper); coneActor.SetPosition(0, 0, 2.25); coneActor.GetProperty().SetColor(0, 1, 0); vtkCylinderSource cylinderSource = vtkCylinderSource.New(); vtkPolyDataMapper cylinderMapper = vtkPolyDataMapper.New(); cylinderMapper.SetInputConnection(cylinderSource.GetOutputPort()); vtkActor cylinderActor = vtkActor.New(); cylinderActor.SetMapper(cylinderMapper); //cylinderActor.SetPosition(0, 0, 0); cylinderActor.GetProperty().SetColor(1, 0, 0); vtkAssembly assembly = vtkAssembly.New(); assembly.AddPart(cylinderActor); assembly.AddPart(sphereActor); assembly.AddPart(cubeActor); assembly.AddPart(coneActor); assembly.SetOrigin(5, 10, 5); assembly.AddPosition(5, 0, 0); assembly.RotateX(15); vtkRenderer renderer = vtkRenderer.New(); vtkRenderWindow renWin = myRenderWindowControl.RenderWindow; renWin.AddRenderer(renderer); renderer.AddActor(assembly); renderer.AddActor(coneActor); }
/// <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 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 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 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 AVofficeStreamPoints(String [] argv) { //Prefix Content is: "" ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // read data[] //[] reader = new vtkStructuredGridReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/office.binary.vtk"); reader.Update(); //force a read to occur[] // to add coverage for vtkOnePieceExtentTranslator[] translator = new vtkOnePieceExtentTranslator(); vtkStreamingDemandDrivenPipeline.SetExtentTranslator(reader.GetOutputInformation(0), (vtkExtentTranslator)translator); length = reader.GetOutput().GetLength(); maxVelocity = reader.GetOutput().GetPointData().GetVectors().GetMaxNorm(); maxTime = 35.0*length/maxVelocity; table1 = new vtkStructuredGridGeometryFilter(); table1.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); table1.SetExtent((int)11,(int)15,(int)7,(int)9,(int)8,(int)8); mapTable1 = vtkPolyDataMapper.New(); mapTable1.SetInputConnection((vtkAlgorithmOutput)table1.GetOutputPort()); mapTable1.ScalarVisibilityOff(); table1Actor = new vtkActor(); table1Actor.SetMapper((vtkMapper)mapTable1); table1Actor.GetProperty().SetColor((double).59,(double).427,(double).392); table2 = new vtkStructuredGridGeometryFilter(); table2.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); table2.SetExtent((int)11,(int)15,(int)10,(int)12,(int)8,(int)8); mapTable2 = vtkPolyDataMapper.New(); mapTable2.SetInputConnection((vtkAlgorithmOutput)table2.GetOutputPort()); mapTable2.ScalarVisibilityOff(); table2Actor = new vtkActor(); table2Actor.SetMapper((vtkMapper)mapTable2); table2Actor.GetProperty().SetColor((double).59,(double).427,(double).392); FilingCabinet1 = new vtkStructuredGridGeometryFilter(); FilingCabinet1.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); FilingCabinet1.SetExtent((int)15,(int)15,(int)7,(int)9,(int)0,(int)8); mapFilingCabinet1 = vtkPolyDataMapper.New(); mapFilingCabinet1.SetInputConnection((vtkAlgorithmOutput)FilingCabinet1.GetOutputPort()); mapFilingCabinet1.ScalarVisibilityOff(); FilingCabinet1Actor = new vtkActor(); FilingCabinet1Actor.SetMapper((vtkMapper)mapFilingCabinet1); FilingCabinet1Actor.GetProperty().SetColor((double).8,(double).8,(double).6); FilingCabinet2 = new vtkStructuredGridGeometryFilter(); FilingCabinet2.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); FilingCabinet2.SetExtent((int)15,(int)15,(int)10,(int)12,(int)0,(int)8); mapFilingCabinet2 = vtkPolyDataMapper.New(); mapFilingCabinet2.SetInputConnection((vtkAlgorithmOutput)FilingCabinet2.GetOutputPort()); mapFilingCabinet2.ScalarVisibilityOff(); FilingCabinet2Actor = new vtkActor(); FilingCabinet2Actor.SetMapper((vtkMapper)mapFilingCabinet2); FilingCabinet2Actor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf1Top = new vtkStructuredGridGeometryFilter(); bookshelf1Top.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf1Top.SetExtent((int)13,(int)13,(int)0,(int)4,(int)0,(int)11); mapBookshelf1Top = vtkPolyDataMapper.New(); mapBookshelf1Top.SetInputConnection((vtkAlgorithmOutput)bookshelf1Top.GetOutputPort()); mapBookshelf1Top.ScalarVisibilityOff(); bookshelf1TopActor = new vtkActor(); bookshelf1TopActor.SetMapper((vtkMapper)mapBookshelf1Top); bookshelf1TopActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf1Bottom = new vtkStructuredGridGeometryFilter(); bookshelf1Bottom.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf1Bottom.SetExtent((int)20,(int)20,(int)0,(int)4,(int)0,(int)11); mapBookshelf1Bottom = vtkPolyDataMapper.New(); mapBookshelf1Bottom.SetInputConnection((vtkAlgorithmOutput)bookshelf1Bottom.GetOutputPort()); mapBookshelf1Bottom.ScalarVisibilityOff(); bookshelf1BottomActor = new vtkActor(); bookshelf1BottomActor.SetMapper((vtkMapper)mapBookshelf1Bottom); bookshelf1BottomActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf1Front = new vtkStructuredGridGeometryFilter(); bookshelf1Front.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf1Front.SetExtent((int)13,(int)20,(int)0,(int)0,(int)0,(int)11); mapBookshelf1Front = vtkPolyDataMapper.New(); mapBookshelf1Front.SetInputConnection((vtkAlgorithmOutput)bookshelf1Front.GetOutputPort()); mapBookshelf1Front.ScalarVisibilityOff(); bookshelf1FrontActor = new vtkActor(); bookshelf1FrontActor.SetMapper((vtkMapper)mapBookshelf1Front); bookshelf1FrontActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf1Back = new vtkStructuredGridGeometryFilter(); bookshelf1Back.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf1Back.SetExtent((int)13,(int)20,(int)4,(int)4,(int)0,(int)11); mapBookshelf1Back = vtkPolyDataMapper.New(); mapBookshelf1Back.SetInputConnection((vtkAlgorithmOutput)bookshelf1Back.GetOutputPort()); mapBookshelf1Back.ScalarVisibilityOff(); bookshelf1BackActor = new vtkActor(); bookshelf1BackActor.SetMapper((vtkMapper)mapBookshelf1Back); bookshelf1BackActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf1LHS = new vtkStructuredGridGeometryFilter(); bookshelf1LHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf1LHS.SetExtent((int)13,(int)20,(int)0,(int)4,(int)0,(int)0); mapBookshelf1LHS = vtkPolyDataMapper.New(); mapBookshelf1LHS.SetInputConnection((vtkAlgorithmOutput)bookshelf1LHS.GetOutputPort()); mapBookshelf1LHS.ScalarVisibilityOff(); bookshelf1LHSActor = new vtkActor(); bookshelf1LHSActor.SetMapper((vtkMapper)mapBookshelf1LHS); bookshelf1LHSActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf1RHS = new vtkStructuredGridGeometryFilter(); bookshelf1RHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf1RHS.SetExtent((int)13,(int)20,(int)0,(int)4,(int)11,(int)11); mapBookshelf1RHS = vtkPolyDataMapper.New(); mapBookshelf1RHS.SetInputConnection((vtkAlgorithmOutput)bookshelf1RHS.GetOutputPort()); mapBookshelf1RHS.ScalarVisibilityOff(); bookshelf1RHSActor = new vtkActor(); bookshelf1RHSActor.SetMapper((vtkMapper)mapBookshelf1RHS); bookshelf1RHSActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf2Top = new vtkStructuredGridGeometryFilter(); bookshelf2Top.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf2Top.SetExtent((int)13,(int)13,(int)15,(int)19,(int)0,(int)11); mapBookshelf2Top = vtkPolyDataMapper.New(); mapBookshelf2Top.SetInputConnection((vtkAlgorithmOutput)bookshelf2Top.GetOutputPort()); mapBookshelf2Top.ScalarVisibilityOff(); bookshelf2TopActor = new vtkActor(); bookshelf2TopActor.SetMapper((vtkMapper)mapBookshelf2Top); bookshelf2TopActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf2Bottom = new vtkStructuredGridGeometryFilter(); bookshelf2Bottom.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf2Bottom.SetExtent((int)20,(int)20,(int)15,(int)19,(int)0,(int)11); mapBookshelf2Bottom = vtkPolyDataMapper.New(); mapBookshelf2Bottom.SetInputConnection((vtkAlgorithmOutput)bookshelf2Bottom.GetOutputPort()); mapBookshelf2Bottom.ScalarVisibilityOff(); bookshelf2BottomActor = new vtkActor(); bookshelf2BottomActor.SetMapper((vtkMapper)mapBookshelf2Bottom); bookshelf2BottomActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf2Front = new vtkStructuredGridGeometryFilter(); bookshelf2Front.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf2Front.SetExtent((int)13,(int)20,(int)15,(int)15,(int)0,(int)11); mapBookshelf2Front = vtkPolyDataMapper.New(); mapBookshelf2Front.SetInputConnection((vtkAlgorithmOutput)bookshelf2Front.GetOutputPort()); mapBookshelf2Front.ScalarVisibilityOff(); bookshelf2FrontActor = new vtkActor(); bookshelf2FrontActor.SetMapper((vtkMapper)mapBookshelf2Front); bookshelf2FrontActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf2Back = new vtkStructuredGridGeometryFilter(); bookshelf2Back.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf2Back.SetExtent((int)13,(int)20,(int)19,(int)19,(int)0,(int)11); mapBookshelf2Back = vtkPolyDataMapper.New(); mapBookshelf2Back.SetInputConnection((vtkAlgorithmOutput)bookshelf2Back.GetOutputPort()); mapBookshelf2Back.ScalarVisibilityOff(); bookshelf2BackActor = new vtkActor(); bookshelf2BackActor.SetMapper((vtkMapper)mapBookshelf2Back); bookshelf2BackActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf2LHS = new vtkStructuredGridGeometryFilter(); bookshelf2LHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf2LHS.SetExtent((int)13,(int)20,(int)15,(int)19,(int)0,(int)0); mapBookshelf2LHS = vtkPolyDataMapper.New(); mapBookshelf2LHS.SetInputConnection((vtkAlgorithmOutput)bookshelf2LHS.GetOutputPort()); mapBookshelf2LHS.ScalarVisibilityOff(); bookshelf2LHSActor = new vtkActor(); bookshelf2LHSActor.SetMapper((vtkMapper)mapBookshelf2LHS); bookshelf2LHSActor.GetProperty().SetColor((double).8,(double).8,(double).6); bookshelf2RHS = new vtkStructuredGridGeometryFilter(); bookshelf2RHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); bookshelf2RHS.SetExtent((int)13,(int)20,(int)15,(int)19,(int)11,(int)11); mapBookshelf2RHS = vtkPolyDataMapper.New(); mapBookshelf2RHS.SetInputConnection((vtkAlgorithmOutput)bookshelf2RHS.GetOutputPort()); mapBookshelf2RHS.ScalarVisibilityOff(); bookshelf2RHSActor = new vtkActor(); bookshelf2RHSActor.SetMapper((vtkMapper)mapBookshelf2RHS); bookshelf2RHSActor.GetProperty().SetColor((double).8,(double).8,(double).6); window = new vtkStructuredGridGeometryFilter(); window.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); window.SetExtent((int)20,(int)20,(int)6,(int)13,(int)10,(int)13); mapWindow = vtkPolyDataMapper.New(); mapWindow.SetInputConnection((vtkAlgorithmOutput)window.GetOutputPort()); mapWindow.ScalarVisibilityOff(); windowActor = new vtkActor(); windowActor.SetMapper((vtkMapper)mapWindow); windowActor.GetProperty().SetColor((double).3,(double).3,(double).5); outlet = new vtkStructuredGridGeometryFilter(); outlet.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); outlet.SetExtent((int)0,(int)0,(int)9,(int)10,(int)14,(int)16); mapOutlet = vtkPolyDataMapper.New(); mapOutlet.SetInputConnection((vtkAlgorithmOutput)outlet.GetOutputPort()); mapOutlet.ScalarVisibilityOff(); outletActor = new vtkActor(); outletActor.SetMapper((vtkMapper)mapOutlet); outletActor.GetProperty().SetColor((double)0,(double)0,(double)0); inlet = new vtkStructuredGridGeometryFilter(); inlet.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); inlet.SetExtent((int)0,(int)0,(int)9,(int)10,(int)0,(int)6); mapInlet = vtkPolyDataMapper.New(); mapInlet.SetInputConnection((vtkAlgorithmOutput)inlet.GetOutputPort()); mapInlet.ScalarVisibilityOff(); inletActor = new vtkActor(); inletActor.SetMapper((vtkMapper)mapInlet); inletActor.GetProperty().SetColor((double)0,(double)0,(double)0); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); mapOutline = vtkPolyDataMapper.New(); mapOutline.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)mapOutline); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); // Create source for streamtubes[] streamer = new vtkStreamPoints(); streamer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); streamer.SetStartPosition((double)0.1,(double)2.1,(double)0.5); streamer.SetMaximumPropagationTime((double)500); streamer.SetTimeIncrement((double)0.5); streamer.SetIntegrationDirectionToForward(); cone = new vtkConeSource(); cone.SetResolution((int)8); cones = new vtkGlyph3D(); cones.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); cones.SetSourceConnection(cone.GetOutputPort()); cones.SetScaleFactor((double)0.5); cones.SetScaleModeToScaleByVector(); mapCones = vtkPolyDataMapper.New(); mapCones.SetInputConnection((vtkAlgorithmOutput)cones.GetOutputPort()); mapCones.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[1]); conesActor = new vtkActor(); conesActor.SetMapper((vtkMapper)mapCones); ren1.AddActor((vtkProp)table1Actor); ren1.AddActor((vtkProp)table2Actor); ren1.AddActor((vtkProp)FilingCabinet1Actor); ren1.AddActor((vtkProp)FilingCabinet2Actor); ren1.AddActor((vtkProp)bookshelf1TopActor); ren1.AddActor((vtkProp)bookshelf1BottomActor); ren1.AddActor((vtkProp)bookshelf1FrontActor); ren1.AddActor((vtkProp)bookshelf1BackActor); ren1.AddActor((vtkProp)bookshelf1LHSActor); ren1.AddActor((vtkProp)bookshelf1RHSActor); ren1.AddActor((vtkProp)bookshelf2TopActor); ren1.AddActor((vtkProp)bookshelf2BottomActor); ren1.AddActor((vtkProp)bookshelf2FrontActor); ren1.AddActor((vtkProp)bookshelf2BackActor); ren1.AddActor((vtkProp)bookshelf2LHSActor); ren1.AddActor((vtkProp)bookshelf2RHSActor); ren1.AddActor((vtkProp)windowActor); ren1.AddActor((vtkProp)outletActor); ren1.AddActor((vtkProp)inletActor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)conesActor); ren1.SetBackground((double)0.4,(double)0.4,(double)0.5); aCamera = new vtkCamera(); aCamera.SetClippingRange((double)0.7724,(double)39); aCamera.SetFocalPoint((double)1.14798,(double)3.08416,(double)2.47187); aCamera.SetPosition((double)-2.64683,(double)-3.55525,(double)3.55848); aCamera.SetViewUp((double)0.0511273,(double)0.132773,(double)0.989827); aCamera.SetViewAngle((double)15.5033); ren1.SetActiveCamera((vtkCamera)aCamera); renWin.SetSize((int)500,(int)300); iren.Initialize(); // interact with data[] //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(); }