private void RenderWindowControl_Load(object sender, System.EventArgs e) { try { myRenderWindowControl.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK); } }
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(); }
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(); }
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(); } }
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(); }
public void Refresh() { Viewport.Render(); Viewport.ResetCameraClippingRange(); RenWinControl.Refresh(); }