public void ShowItemOnView(RenderWindowControl renderWindow, EDisplayItem typeOfItem) { switch (typeOfItem) { case EDisplayItem.PointCloud: _winForm.ReadNVM(renderWindow); break; } }
/// <summary> /// 对指定的RenderWindowControl进行截屏并保存 /// </summary> /// <param name="fn"></param> /// <param name="rwc"></param> /// <returns></returns> public static bool SaveRendererWindowsAsPic(string fn, ref RenderWindowControl rwc) { bool res = true; try { vtkWindowToImageFilter screenShot = vtkWindowToImageFilter.New(); screenShot.SetInput(rwc.RenderWindow); //screenShot.SetMagnification(3); screenShot.SetInputBufferTypeToRGB(); screenShot.ReadFrontBufferOff(); screenShot.Update(); vtkPNGWriter writer = vtkPNGWriter.New(); writer.SetFileName(fn); writer.SetInputConnection(screenShot.GetOutputPort()); writer.Write(); } catch { res = false; } return(res); }
static public void Show(RenderWindowControl aRenderControl) { // get a reference to the renderwindow of our renderWindowControl1 var aRenderWindow = aRenderControl.RenderWindow; // get a reference to the renderer var aRenderer = aRenderWindow.GetRenderers().GetFirstRenderer(); aRenderer.Clear(); aRenderer.RemoveAllViewProps(); // set background color aRenderer.SetBackground(0.2, 0.3, 0.4); var aMesher = new CMshBasicMesherDouble(); FvmChannel2D.GenerateMesh(aMesher, aRenderer); var anUnstructuredGrid = vtkUnstructuredGrid.New(); FvmChannel2D.DrawMesh(aMesher, anUnstructuredGrid); FvmChannel2D.Simulate(aMesher, anUnstructuredGrid, aRenderer, aRenderControl); aRenderer.ResetCamera(); aRenderControl.Refresh(); }
private vtkRenderer Renderer() { RenderWindowControl rw = (RenderWindowControl)wfh.Child; vtkRendererCollection rs = rw.RenderWindow.GetRenderers(); vtkRenderer r = rs.GetFirstRenderer(); return(r); }
public Form1() { InitializeComponent(); myRenderWindowControl = new RenderWindowControl(); myRenderWindowControl.SetBounds(0, 0, panel1.Width, panel1.Height); myRenderWindowControl.Dock = DockStyle.Fill; panel1.Controls.Add(this.myRenderWindowControl); myRenderWindowControl.Load += RenderWindowControl_Load; }
public MyInteractorStyle(RenderWindowControl ctrl) { m_RWCtrl = ctrl; m_rendWin = ctrl.RenderWindow; m_renderer = m_rendWin.GetRenderers().GetFirstRenderer(); m_iren = m_rendWin.GetInteractor(); m_iren.LeftButtonReleaseEvt += new vtkObjectEventHandler(m_interactor_LeftButtonReleaseEvt); m_iren.LeftButtonPressEvt += new vtkObjectEventHandler(m_iren_RightButtonPressEvt); }
/// <summary> /// Creating the 2D visualization window. /// </summary> /// <param name="window">Orginal window component. </param> public Visualization2D(RenderWindowControl window) { _window = window; vtkInteractorStyleImage imageStyle = vtkInteractorStyleImage.New(); _viewer = vtkImageViewer2.New(); _viewer.OffScreenRenderingOn(); _window.RenderWindow.AddRenderer(_viewer.GetRenderer()); _window.RenderWindow.GetInteractor().SetInteractorStyle(imageStyle); _viewer.Render(); }
public Visualization2D(RenderWindowControl window, vtkDICOMImageReader dicomReader) { this.window = window; this.dicomReader = dicomReader; vtkRenderer renderer = window.RenderWindow.GetRenderers().GetFirstRenderer(); vtkRenderWindowInteractor renderWindowInteractor = window.RenderWindow.GetInteractor(); viewer = vtkImageViewer2.New(); viewer.OffScreenRenderingOn(); viewer.SetupInteractor(renderWindowInteractor); viewer.SetRenderer(renderer); }
public void ReadNVM(RenderWindowControl renderWindowControl) { var nvmFile = sfmHelper.LoadPointCloud(); foreach (var model in nvmFile) { foreach (var camera in model.listImageModel) { ReadImageIntoObject(renderWindowControl, camera); } ReadPointIntoObject(renderWindowControl, model.listPointModel); } }
//wizualizacja 3d ----------------------------------------------------------------- public Visualization3D(RenderWindowControl window, DicomLoader dicomLoader, Chart chart) { _chart = chart; _window = window; _dicomLoader = dicomLoader; PresetReader = new XmlPresetReader(); // Create a mapper and actor _mapper = vtkSmartVolumeMapper.New(); _mapper.SetInput(_dicomLoader.GetOutput()); _volume = vtkVolume.New(); SetOpacityFunction(); SetGradientOpacity(); _volume.SetMapper(_mapper); renderer = vtkRenderer.New(); renderer.AddVolume(_volume); _window.RenderWindow.GetRenderers().RemoveAllItems(); _window.RenderWindow.AddRenderer(renderer); _window.RenderWindow.GetRenderers().GetFirstRenderer().AddVolume(_volume); // An interactor _renderWindowInteractor = vtkRenderWindowInteractor.New(); _renderWindowInteractor.SetRenderWindow(_window.RenderWindow); //Camera style vtkInteractorStyleTrackballCamera style = vtkInteractorStyleTrackballCamera.New(); style.AutoAdjustCameraClippingRangeOff(); _renderWindowInteractor.SetInteractorStyle(style); //Create and setup planes PlaneWidgetX = new PlaneWidget(Axis.X); SetupPlane(PlaneWidgetX); PlaneWidgetY = new PlaneWidget(Axis.Y); SetupPlane(PlaneWidgetY); PlaneWidgetZ = new PlaneWidget(Axis.Z); SetupPlane(PlaneWidgetZ); // Render _window.RenderWindow.Render(); //ClipingModule _clipingModule = new ClipingModule(GetObjectSize()); }
public void ReadPointIntoObject(RenderWindowControl renderWindowControl, List <nvmPointModel> listPointModel) { vtkUnsignedCharArray colors = vtkUnsignedCharArray.New(); colors.SetNumberOfComponents(3); colors.SetName("Colors"); vtkPoints points = vtkPoints.New(); foreach (var point in listPointModel) { colors.InsertNextValue(byte.Parse(point.color.X.ToString(), CultureInfo.InvariantCulture)); colors.InsertNextValue(byte.Parse(point.color.Y.ToString(), CultureInfo.InvariantCulture)); colors.InsertNextValue(byte.Parse(point.color.Z.ToString(), CultureInfo.InvariantCulture)); points.InsertNextPoint( double.Parse(point.position.X.ToString(), CultureInfo.InvariantCulture), double.Parse(point.position.Y.ToString(), CultureInfo.InvariantCulture), double.Parse(point.position.Z.ToString(), CultureInfo.InvariantCulture)); } vtkPolyData polydata = vtkPolyData.New(); polydata.SetPoints(points); polydata.GetPointData().SetScalars(colors); vtkVertexGlyphFilter glyphFilter = vtkVertexGlyphFilter.New(); glyphFilter.SetInputConnection(polydata.GetProducerPort()); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(glyphFilter.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetPointSize(2); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(0.2, 0.3, 0.4); // add our actor to the renderer renderer.AddActor(actor); renderer.ResetCamera(); }
static public void Show(RenderWindowControl aRenderControl) { // get a reference to the renderwindow of our renderWindowControl1 var aRenderWindow = aRenderControl.RenderWindow; // get a reference to the renderer var aRenderer = aRenderWindow.GetRenderers().GetFirstRenderer(); aRenderer.Clear(); aRenderer.RemoveAllViewProps(); PolygonClip.DrawPolygon(aRenderer); aRenderer.ResetCamera(); aRenderControl.Refresh(); }
//wizualizacja 3d ----------------------------------------------------------------- public Visualization3D(RenderWindowControl window, vtkDICOMImageReader dicomReader) { this.window = window; this.dicomReader = dicomReader; this.presetMapper = new PresetMapper(); vtkRenderer renderer = window.RenderWindow.GetRenderers().GetFirstRenderer(); vtkSmartVolumeMapper mapper = vtkSmartVolumeMapper.New(); vol = vtkVolume.New(); vtkLookupTable bwLut = vtkLookupTable.New(); bwLut.SetTableRange(0, 2000); bwLut.SetSaturationRange(0, 0); bwLut.SetHueRange(0, 0); bwLut.SetValueRange(0, 1); bwLut.Build(); //effective built vtkImageMapToColors sagittalColors = vtkImageMapToColors.New(); sagittalColors.SetInputConnection(dicomReader.GetOutputPort()); sagittalColors.SetLookupTable(bwLut); sagittalColors.Update(); vtkImageActor sagittal = vtkImageActor.New(); sagittal.SetInput(sagittalColors.GetOutput()); sagittal.SetDisplayExtent(117, 117, 0, 173, 1, 180); vtkImageReslice reslicer = vtkImageReslice.New(); reslicer.SetResliceAxesDirectionCosines(1, 0, 0, 2, 0, 0, 0, 0, 0); mapper.SetInputConnection(dicomReader.GetOutputPort()); this.setColorFunction(); this.setOpacityFunction(); this.setGradientOpacity(); vol.SetMapper(mapper); renderer.AddActor(sagittal); renderer.AddVolume(vol); }
public void ReadImageIntoObject(RenderWindowControl renderWindowControl, nvmImageModel camera) { vtkRenderWindow renderWindow = renderWindowControl.RenderWindow; vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); string filePath = Path.Combine(tempDirectory, $"{camera.fileName}"); vtkJPEGReader reader = vtkJPEGReader.New(); reader.SetFileName(filePath); reader.Update(); // Treba poriesit ako nasmerovat obrazky bez pokazenia textury var vectoris = Vector3.Transform(new Vector3(0, 0, 1), camera.quaternion); vtkPlaneSource planeSource = vtkPlaneSource.New(); vtkTexture texture = new vtkTexture(); texture.SetInputConnection(reader.GetOutputPort()); vtkTransform transform = new vtkTransform(); transform.RotateX(180); texture.SetTransform(transform); vtkTextureMapToPlane plane = new vtkTextureMapToPlane(); plane.SetInputConnection(planeSource.GetOutputPort()); planeSource.SetCenter(camera.cameraCenter.X, camera.cameraCenter.Y, camera.cameraCenter.Z); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(plane.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.SetTexture(texture); renderer.SetBackground(0.2, 0.3, 0.4); renderer.AddActor(actor); }
private RenderWindowControl RenderWindow() { RenderWindowControl rw = (RenderWindowControl)wfh.Child; return(rw); }
public void CreateViewport(Grid Window) { WindowsFormsHost VTK_Window = new WindowsFormsHost(); // Create Windows Forms Host for VTK Window RenWinControl = new RenderWindowControl(); // Initialize VTK Renderer Window Control // Clear input Window and add new host Window.Children.Clear(); Window.Children.Add(VTK_Window); VTK_Window.Child = RenWinControl; // Create Render Window renderWindow = RenWinControl.RenderWindow; // Initialize Interactor Inter = vtkRenderWindowInteractor.New(); Inter.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(SelectPointClick); Inter.RightButtonPressEvt += new vtkObject.vtkObjectEventHandler(UnselectPointClick); renderWindow.SetInteractor(Inter); Inter.Initialize(); InterStyleTrack = vtkInteractorStyleTrackballCamera.New(); //Inter.SetInteractorStyle(InterStyleTrack); InterStylePick = vtkInteractorStyleRubberBandPick.New(); Inter.SetInteractorStyle(InterStylePick); // Initialize View Viewport = renderWindow.GetRenderers().GetFirstRenderer(); Viewport.RemoveAllViewProps(); CreateViewportBorder(Viewport, new double[3] { 128.0, 128.0, 128.0 }); // Set default background color Viewport.GradientBackgroundOn(); Viewport.SetBackground(163.0 / 255.0, 163.0 / 255.0, 163.0 / 255.0); Viewport.SetBackground2(45.0 / 255.0, 85.0 / 255.0, 125.0 / 255.0); // Other properties Viewport.GetActiveCamera().ParallelProjectionOn(); // Initialize Selection objects AppendFaces = vtkAppendPolyData.New(); Faces = vtkPolyData.New(); SelectionMode = false; SelectionSize = 0.1; SelectionPoints = vtkPoints.New(); SelectionActor = vtkActor.New(); SelectionPolyData = vtkPolyData.New(); SelectionPolyData.SetPoints(SelectionPoints); SelectionSphere = vtkSphereSource.New(); SelectionSphere.SetPhiResolution(12); SelectionSphere.SetThetaResolution(12); SelectionSphere.SetRadius(SelectionSize); SelectionGlyph = vtkGlyph3D.New(); SelectionGlyph.SetInput(SelectionPolyData); SelectionGlyph.SetSourceConnection(SelectionSphere.GetOutputPort()); SelectionMapper = vtkPolyDataMapper.New(); SelectionMapper.SetInputConnection(SelectionGlyph.GetOutputPort()); SelectionActor.SetMapper(SelectionMapper); SelectionActor.GetProperty().SetColor(1, 1, 1); SelectionActor.VisibilityOn(); Viewport.AddActor(SelectionActor); // Create new Properties and Objects CreateColorMap(); CreateScalarBar(); CreateAxes(); CreateSlider(); CreateClipPlane(); }
private void InitializeComponent() { if (!CSHARPGL) { // parte di activiz-------------------------------------------------------------------- //all other controls added by the designer renderWindowControl1 = new RenderWindowControl(); renderWindowControl1.SetBounds(0, 0, 640, 480); this.Controls.Add(this.renderWindowControl1); /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> this.SuspendLayout(); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(819, 477); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } else if (CSHARPGL) { // parte di CSHARPGL - scommentare per volumetrica // parte di CSharpGL-------------------------------------------------------------------- this.winGLCanvas1 = new CSharpGL.WinGLCanvas(); ((System.ComponentModel.ISupportInitialize)(this.winGLCanvas1)).BeginInit(); this.SuspendLayout(); // // winGLCanvas1 // this.winGLCanvas1.AccumAlphaBits = ((byte)(0)); this.winGLCanvas1.AccumBits = ((byte)(0)); this.winGLCanvas1.AccumBlueBits = ((byte)(0)); this.winGLCanvas1.AccumGreenBits = ((byte)(0)); this.winGLCanvas1.AccumRedBits = ((byte)(0)); this.winGLCanvas1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.winGLCanvas1.Location = new System.Drawing.Point(12, 12); this.winGLCanvas1.Name = "winGLCanvas1"; this.winGLCanvas1.RenderTrigger = CSharpGL.RenderTrigger.Manual; this.winGLCanvas1.Size = new System.Drawing.Size(961, 553); this.winGLCanvas1.StencilBits = ((byte)(0)); this.winGLCanvas1.TabIndex = 0; this.winGLCanvas1.TimerTriggerInterval = 40; this.winGLCanvas1.UpdateContextVersion = true; // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(985, 577); this.Controls.Add(this.winGLCanvas1); this.Name = "FormMain"; this.Text = "Raycast Volume Rendering - CSharpGL"; ((System.ComponentModel.ISupportInitialize)(this.winGLCanvas1)).EndInit(); this.ResumeLayout(false); } }
private void SetUpRenderWindow() { // create a VTK output control and make the forms host point to it rwc = new RenderWindowControl(); rwc.CreateGraphics(); windowsFormsHost.Child = rwc; // set up basic viewing vtkRenderer ren = rwc.RenderWindow.GetRenderers().GetFirstRenderer(); // background color ren.SetBackground(0.0, 0.0, 0.0); // interactor style vtkInteractorStyleSwitch istyle = vtkInteractorStyleSwitch.New(); rwc.RenderWindow.GetInteractor().SetInteractorStyle(istyle); rwc.RenderWindow.GetInteractor().SetPicker(vtkCellPicker.New()); (istyle).SetCurrentStyleToTrackballCamera(); // Demonstrate how to use the vtkBoxWidget 3D widget, vtkSphereSource sphere = vtkSphereSource.New(); sphere.SetRadius(0.25); vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New(); sphereMapper.SetInputConnection(sphere.GetOutputPort()); vtkActor sphereActor; vtkTransform widgetTransform = vtkTransform.New(); List <Region> region_list = configurator.SimConfig.scenario.regions.ToList(); for (int ii = 0; ii < region_list.Count; ++ii) { this.TransferMatrixToVTKTransform(region_list[ii].region_box_spec.transform_matrix, widgetTransform); sphereActor = vtkActor.New(); sphereActor.SetMapper(sphereMapper); sphereActor.SetUserTransform(widgetTransform); sphereActor.GetProperty().SetOpacity(0.5); sphereActor.SetVisibility(region_list[ii].region_visibility ? 1 : 0); sphereActorList.Add(sphereActor); ren.AddActor(sphereActorList[ii]); } vtkCubeSource cube = vtkCubeSource.New(); cube.SetXLength(5.0); cube.SetYLength(5.0); cube.SetZLength(5.0); vtkOutlineSource outline = vtkOutlineSource.New(); outline.SetBounds(-2, 2, -2, 2, -2, 2); vtkPolyDataMapper cubeMapper = vtkPolyDataMapper.New(); cubeMapper.SetInputConnection(outline.GetOutputPort()); vtkLODActor cubeActor = vtkLODActor.New(); cubeActor.SetMapper(cubeMapper); cubeActor.VisibilityOn(); ren.AddActor(cubeActor); boxRep = vtkBoxRepresentation.New(); boxRep.SetTransform(widgetTransform); boxWidget = vtkBoxWidget2.New(); boxWidget.SetInteractor(rwc.RenderWindow.GetInteractor()); boxWidget.SetRepresentation(boxRep); boxWidget.SetPriority(1); boxWidget.InteractionEvt += this.boxInteractionCallback; ren.ResetCamera(); }
static public void Show(RenderWindowControl aRenderControl) { // get a reference to the renderwindow of our renderWindowControl1 var aRenderWindow = aRenderControl.RenderWindow; // get a reference to the renderer var aRenderer = aRenderWindow.GetRenderers().GetFirstRenderer(); aRenderer.Clear(); aRenderer.RemoveAllViewProps(); // set background color aRenderer.SetBackground(0.2, 0.3, 0.4); var aCenter = new CGeoCoordinateDouble(0, 0, 0); var aRadius = new CGeoVectorDouble(1.0); var a = CCsgCubeDouble.create(aCenter, aRadius); var b = CCsgSphereDouble.create(aCenter, 1.35, 16, 12); var aVertex_x1 = new CGeoCoordinateDouble(-2, 0, 0); var aVertex_x2 = new CGeoCoordinateDouble(+2, 0, 0); var c = CCsgCylinderDouble.create(aVertex_x1, aVertex_x2, 0.7, 16); var aVertex_y1 = new CGeoCoordinateDouble(0, -2, 0); var aVertex_y2 = new CGeoCoordinateDouble(0, +2, 0); var d = CCsgCylinderDouble.create(aVertex_y1, aVertex_y2, 0.7, 16); var aVertex_z1 = new CGeoCoordinateDouble(0, 0, -2); var aVertex_z2 = new CGeoCoordinateDouble(0, 0, +2); var e = CCsgCylinderDouble.create(aVertex_z1, aVertex_z2, 0.7, 16); a.setTolerance(1E-6); b.setTolerance(1E-6); c.setTolerance(1E-6); d.setTolerance(1E-6); e.setTolerance(1E-6); var f = a.intersect(b).subtract(c.add(d).add(e)); var aFileName = "demo.stl"; f.toStl().save(aFileName); var aReader = vtkSTLReader.New(); aReader.SetFileName(aFileName); aReader.Update(); var aMapper = vtkPolyDataMapper.New(); aMapper.SetInputConnection(aReader.GetOutputPort()); var anActor = vtkActor.New(); anActor.SetMapper(aMapper); aRenderer.AddActor(anActor); aRenderer.ResetCamera(); aRenderControl.Refresh(); }
static public void Simulate(CMshBasicMesherDouble aMesher, vtkUnstructuredGrid anUnstructuredGrid, vtkRenderer aRenderer, RenderWindowControl aRenderControl) { aMesher.mesh().generateFaces(1E-12); aMesher.mesh().calculateFaceCentroid(); aMesher.mesh().calculateElementCentroid(); var aFvmMesh = new CFvmMeshDouble(aMesher.mesh()); double U = 1.0; // Lid velocity double mu = 0.001; // dynamic viscosity double rho = 1.0; // density double nu = mu / rho; // kinematic viscosity var aPisoSolver = new CFvmPisoSolverDouble(aFvmMesh); aPisoSolver.setGravity(0.0, 0.0, 0.0); aPisoSolver.setMaterialProperties(rho, mu); var sFaceIds = new StdVectorInt(); sFaceIds.Clear(); for (int i = 0; i < aFvmMesh.nbFaces(); ++i) { int aFaceId = aFvmMesh.faceId(i); var aFace = aFvmMesh.face(aFaceId); aFace.calculateCentroid(); if (aFace.centroid().y() == 0.0 || aFace.centroid().y() == 0.1) { sFaceIds.Add(aFaceId); } } aPisoSolver.setBoundaryVelocity(sFaceIds, EBoundaryType.BT_WALL_NO_SLIP, 0.0, 0.0, 0.0); aPisoSolver.setBoundaryPressure(sFaceIds, EBoundaryType.BT_WALL_NO_SLIP, 0.0); sFaceIds.Clear(); for (int i = 0; i < aFvmMesh.nbFaces(); ++i) { int aFaceId = aFvmMesh.faceId(i); var aFace = aFvmMesh.face(aFaceId); aFace.calculateCentroid(); if (aFace.centroid().x() == 0.0) { sFaceIds.Add(aFaceId); } } aPisoSolver.setBoundaryVelocity(sFaceIds, EBoundaryType.BT_INLET_FLOW, U, 0.0, 0.0); sFaceIds.Clear(); for (int i = 0; i < aFvmMesh.nbFaces(); ++i) { int aFaceId = aFvmMesh.faceId(i); var aFace = aFvmMesh.face(aFaceId); aFace.calculateCentroid(); if (aFace.centroid().x() == 1.0) { sFaceIds.Add(aFaceId); } } aPisoSolver.setBoundaryVelocity(sFaceIds, EBoundaryType.BT_OUTLET, 0.0, 0.0, 0.0); double dt = U / 100; // Courant < 1 var sScalars = vtkFloatArray.New(); sScalars.SetNumberOfTuples(aFvmMesh.nbControlVolumes()); var aGeometryFilter = vtkGeometryFilter.New(); var aCellDataToPointDataFilter1 = vtkCellDataToPointData.New(); var aBoundedFilter = vtkBandedPolyDataContourFilter.New(); var aLookupTable = vtkLookupTable.New(); aLookupTable.SetNumberOfColors(256); aLookupTable.SetHueRange(0.667, 0.0); aLookupTable.Build(); var aBandedMapper = vtkPolyDataMapper.New(); // add actor to the renderer var aMeshActor = vtkActor.New(); aRenderer.AddActor(aMeshActor); var aScalarBarActor = vtkScalarBarActor.New(); aRenderer.AddActor(aScalarBarActor); int nIter = 40; // Flow in a rectangle for (int ii = 0; ii < nIter; ++ii) { aPisoSolver.iterate(dt); for (int i = 0; i < aFvmMesh.nbControlVolumes(); ++i) { var aControlVolumeId = aFvmMesh.controlVolumeId(i); double u = aPisoSolver.u(aControlVolumeId); double v = aPisoSolver.v(aControlVolumeId); double vel = Math.Sqrt(u * u + v * v); sScalars.SetTuple1(aControlVolumeId, vel); } sScalars.Modified(); anUnstructuredGrid.GetCellData().SetScalars(sScalars); aGeometryFilter.SetInput(anUnstructuredGrid); aGeometryFilter.Update(); aCellDataToPointDataFilter1.SetInputConnection(aGeometryFilter.GetOutputPort()); aCellDataToPointDataFilter1.Update(); aBoundedFilter.SetInput(aCellDataToPointDataFilter1.GetOutput()); aBoundedFilter.GenerateValues(24, sScalars.GetRange()[0], sScalars.GetRange()[1]); aBandedMapper.SetInputConnection(aBoundedFilter.GetOutputPort()); aBandedMapper.SetScalarModeToUsePointData(); aBandedMapper.SetScalarRange(sScalars.GetRange()[0], sScalars.GetRange()[1]); aBandedMapper.SetLookupTable(aLookupTable); aMeshActor.SetMapper(aBandedMapper); aScalarBarActor.SetLookupTable(aLookupTable); aScalarBarActor.SetTitle("Velocity"); aScalarBarActor.SetNumberOfLabels(6); aRenderer.Render(); if (ii == 0) { aRenderer.ResetCamera(); } aRenderControl.Refresh(); } }