private void PlatonicSolid() { vtkPlatonicSolidSource platonicSolidSource = vtkPlatonicSolidSource.New(); platonicSolidSource.SetSolidTypeToOctahedron(); // Each face has a different cell scalar vtkLookupTable lut = vtkLookupTable.New(); lut.SetNumberOfTableValues(8); lut.SetTableRange(0.0, 7.0); lut.Build(); lut.SetTableValue(0, 0, 0, 0, 1); lut.SetTableValue(1, 0, 0, 1, 1); lut.SetTableValue(2, 0, 1, 0, 1); lut.SetTableValue(3, 0, 1, 1, 1); lut.SetTableValue(4, 1, 0, 0, 1); lut.SetTableValue(5, 1, 0, 1, 1); lut.SetTableValue(6, 1, 1, 0, 1); lut.SetTableValue(7, 1, 1, 1, 1); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(platonicSolidSource.GetOutputPort()); mapper.SetLookupTable(lut); mapper.SetScalarRange(0, 7); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); RenderAddActor(actor); }
private void RenderRaw() { // Read the file vtkParticleReader reader = vtkParticleReader.New(); reader.SetFileName(m_FileName); reader.SetDataByteOrderToBigEndian(); reader.Update(); //MessageBox.Show("NumberOfPieces: " + reader.GetOutput().GetNumberOfPieces()); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(reader.GetOutputPort()); mapper.SetScalarRange(4, 9); mapper.SetPiece(1); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetPointSize(4); actor.GetProperty().SetColor(1, 0, 0); // add our actor to the renderer m_Renderer.AddActor(actor); }
public void ExtractEdgesVTKBuilderWithoutRunning(ref vtkActor actor, ref vtkPoints points, ref vtkCellArray polys, ref vtkFloatArray scalars, ref vtkLookupTable Luk) { int pointsNum = 0; TowerModelInstance.VTKDrawModel(ref points, ref polys, ref scalars, ref pointsNum, paras); vtkPolyData profile = vtkPolyData.New(); profile.SetPoints(points); profile.SetPolys(polys); vtkExtractEdges ExtProfile = new vtkExtractEdges(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); if (paras.RotateAngle == 0) { profile.GetCellData().SetScalars(scalars); ExtProfile.SetInput(profile); mapper.SetInputConnection(ExtProfile.GetOutputPort()); } else { vtkRotationalExtrusionFilter refilter = vtkRotationalExtrusionFilter.New(); profile.Update(); profile.GetCellData().SetScalars(scalars); //profile.GetPointData().SetScalars(scalars); ExtProfile.SetInput(profile); refilter.SetInputConnection(ExtProfile.GetOutputPort()); refilter.SetResolution(50); refilter.SetAngle(paras.RotateAngle); refilter.SetTranslation(0); refilter.SetDeltaRadius(0); mapper.SetInputConnection(refilter.GetOutputPort()); } mapper.SetScalarRange(0, 5); mapper.SetLookupTable(Luk); actor.SetMapper(mapper); Luk.SetNumberOfTableValues(7); Luk.SetTableValue(0, 0, 1, 0, 1); // Luk.SetTableValue(1, 0, 0, 0.8, 1); //inner surface Luk.SetTableValue(2, 0, 1, 0, 1); // Luk.SetTableValue(3, 0, 0, 1, 1); Luk.SetTableValue(4, 0, 0, 0.8, 1); //insider Luk.SetTableValue(5, 0, 0.8, 0, 1); //outer surface Luk.Build(); }
private void ColorDisconnectedRegions() { // Create some spheres vtkSphereSource sphereSource1 = vtkSphereSource.New(); sphereSource1.Update(); vtkSphereSource sphereSource2 = vtkSphereSource.New(); sphereSource2.SetCenter(5, 0, 0); sphereSource2.Update(); vtkSphereSource sphereSource3 = vtkSphereSource.New(); sphereSource3.SetCenter(10, 0, 0); sphereSource3.Update(); vtkAppendPolyData appendFilter = vtkAppendPolyData.New(); appendFilter.AddInputConnection(sphereSource1.GetOutputPort()); appendFilter.AddInputConnection(sphereSource2.GetOutputPort()); appendFilter.AddInputConnection(sphereSource3.GetOutputPort()); vtkPolyDataConnectivityFilter connectivityFilter = vtkPolyDataConnectivityFilter.New(); connectivityFilter.SetInputConnection(appendFilter.GetOutputPort()); connectivityFilter.SetExtractionModeToAllRegions(); connectivityFilter.ColorRegionsOn(); connectivityFilter.Update(); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(connectivityFilter.GetOutputPort()); double[] range = connectivityFilter.GetOutput().GetPointData().GetArray("RegionId").GetRange(); mapper.SetScalarRange(range[0], range[1]); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(0.0, 0.0, 0.0); // add our actor to the renderer renderer.AddActor(actor); }
private void Curvature() { // Path to vtk data must be set as an environment variable // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0" vtkTesting test = vtkTesting.New(); string root = test.GetDataRoot(); // note: one should use a coarse surface mesh to achieve a good visual effect string filePath = System.IO.Path.Combine(root, @"Data\bunny.vtp"); // Create a polydata vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New(); reader.SetFileName(filePath); vtkCurvatures curvaturesFilter = vtkCurvatures.New(); curvaturesFilter.SetInputConnection(reader.GetOutputPort()); //curvaturesFilter.SetCurvatureTypeToGaussian(); //curvaturesFilter.SetCurvatureTypeToMean(); //curvaturesFilter.SetCurvatureTypeToMaximum(); curvaturesFilter.SetCurvatureTypeToMinimum(); // To inspect more closely, if required vtkXMLPolyDataWriter writer = vtkXMLPolyDataWriter.New(); writer.SetInputConnection(curvaturesFilter.GetOutputPort()); writer.SetFileName(System.IO.Path.Combine(root, @"Data\gauss.vtp")); writer.Write(); // Create a mapper and actor vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(curvaturesFilter.GetOutputPort()); double[] range = curvaturesFilter.GetOutput().GetScalarRange(); mapper.SetScalarRange(range[0], range[1]); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(0.0, 0.0, 0.0); // add our actor to the renderer renderer.AddActor(actor); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestExtractVOI(String [] argv) { //Prefix Content is: "" // to mark the origin[] sphere = new vtkSphereSource(); sphere.SetRadius((double)2.0); sphereMapper = vtkPolyDataMapper.New(); sphereMapper.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); sphereMapper.ImmediateModeRenderingOn(); sphereActor = new vtkActor(); sphereActor.SetMapper((vtkMapper)sphereMapper); rt = new vtkRTAnalyticSource(); rt.SetWholeExtent((int)-50,(int)50,(int)-50,(int)50,(int)0,(int)0); voi = new vtkExtractVOI(); voi.SetInputConnection((vtkAlgorithmOutput)rt.GetOutputPort()); voi.SetVOI((int)-11,(int)39,(int)5,(int)45,(int)0,(int)0); voi.SetSampleRate((int)5,(int)5,(int)1); // Get rid ambiguous triagulation issues.[] surf = new vtkDataSetSurfaceFilter(); surf.SetInputConnection((vtkAlgorithmOutput)voi.GetOutputPort()); tris = new vtkTriangleFilter(); tris.SetInputConnection((vtkAlgorithmOutput)surf.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort()); mapper.ImmediateModeRenderingOn(); mapper.SetScalarRange((double)130,(double)280); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); ren = vtkRenderer.New(); ren.AddActor((vtkProp)actor); ren.AddActor((vtkProp)sphereActor); ren.ResetCamera(); camera = ren.GetActiveCamera(); //$camera SetPosition 68.1939 -23.4323 12.6465[] //$camera SetViewUp 0.46563 0.882375 0.0678508 [] //$camera SetFocalPoint 3.65707 11.4552 1.83509 [] //$camera SetClippingRange 59.2626 101.825 [] renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); iren.Initialize(); //deleteAllVTKObjects(); }
private void ParticleReader() { // Path to vtk data must be set as an environment variable // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0" vtkTesting test = vtkTesting.New(); string root = test.GetDataRoot(); string filePath = System.IO.Path.Combine(root, @"Data\Particles.raw"); // Read the file vtkParticleReader reader = vtkParticleReader.New(); reader.SetFileName(filePath); reader.SetDataByteOrderToBigEndian(); reader.Update(); Debug.WriteLine("NumberOfPieces: " + reader.GetOutput().GetNumberOfPieces()); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(reader.GetOutputPort()); mapper.SetScalarRange(4, 9); mapper.SetPiece(1); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetPointSize(4); actor.GetProperty().SetColor(1, 0, 0); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(0.2, 0.3, 0.4); // add our actor to the renderer renderer.AddActor(actor); }
/// <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 AVcombStreamers2(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); ps = new vtkPlaneSource(); ps.SetXResolution((int)4); ps.SetYResolution((int)4); ps.SetOrigin((double)2,(double)-2,(double)26); ps.SetPoint1((double)2,(double)2,(double)26); ps.SetPoint2((double)2,(double)-2,(double)32); psMapper = vtkPolyDataMapper.New(); psMapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort()); psActor = new vtkActor(); psActor.SetMapper((vtkMapper)psMapper); psActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkDashedStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); streamer.SetSource((vtkDataSet)ps.GetOutput()); streamer.SetMaximumPropagationTime((double)100); streamer.SetIntegrationStepLength((double).2); streamer.SetStepLength((double).001); streamer.SetNumberOfThreads((int)1); streamer.SetIntegrationDirectionToForward(); streamMapper = vtkPolyDataMapper.New(); streamMapper.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamMapper.SetScalarRange( (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); streamline = new vtkActor(); streamline.SetMapper((vtkMapper)streamMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)psActor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)streamline); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); ren1.SetBackground((double)0.1,(double)0.2,(double)0.4); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297,(double)50); cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999); cam1.SetPosition((double)2.7439,(double)-37.3196,(double)38.7167); cam1.SetViewUp((double)-0.16123,(double)0.264271,(double)0.950876); // render the image[] //[] 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 AVfieldToPolyData(String [] argv) { //Prefix Content is: "" // This example demonstrates the reading of a field and conversion to PolyData[] // The output should be the same as polyEx.tcl.[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkPolyDataReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/polyEx.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("PolyField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"PolyField.vtk"); writer.Write(); // create pipeline[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"PolyField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToPolyData(); do2ds.SetPointComponent((int)0,(string)"Points",(int)0); do2ds.SetPointComponent((int)1,(string)"Points",(int)1); do2ds.SetPointComponent((int)2,(string)"Points",(int)2); do2ds.SetPolysComponent((string)"Polys",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetPolyDataOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetScalarComponent((int)0,(string)"my_scalars",(int)0); mapper = vtkPolyDataMapper.New(); mapper.SetInput((vtkPolyData)fd2ad.GetPolyDataOutput()); mapper.SetScalarRange((double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[1]); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); // Create the RenderWindow, Renderer and both Actors[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); ren1.AddActor((vtkProp)actor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); ren1.ResetCamera(); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double).348,(double)17.43); cam1.SetPosition((double)2.92,(double)2.62,(double)-0.836); cam1.SetViewUp((double)-0.436,(double)-0.067,(double)-0.897); cam1.Azimuth((double)90); // render the image[] //[] renWin.Render(); File.Delete("PolyField.vtk"); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void 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 AVstreamTracer(String [] argv) { //Prefix Content is: "" ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); // this test has some wireframe geometry // Make sure multisampling is disabled to avoid generating multiple // regression images // renWin SetMultiSamples 0 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[] 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); rk = new vtkRungeKutta45(); // Create source for streamtubes[] streamer = new vtkStreamTracer(); streamer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); streamer.SetStartPosition((double)0.1,(double)2.1,(double)0.5); streamer.SetMaximumPropagation((double)500); streamer.SetIntegrationStepUnit(2); streamer.SetMinimumIntegrationStep((double)0.1); streamer.SetMaximumIntegrationStep((double)1.0); streamer.SetInitialIntegrationStep((double)0.2); streamer.SetIntegrationDirection((int)0); streamer.SetIntegrator((vtkInitialValueProblemSolver)rk); streamer.SetRotationScale((double)0.5); streamer.SetMaximumError((double)1.0e-8); aa = new vtkAssignAttribute(); aa.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); aa.Assign((string)"Normals",(string)"NORMALS",(string)"POINT_DATA"); rf1 = new vtkRibbonFilter(); rf1.SetInputConnection((vtkAlgorithmOutput)aa.GetOutputPort()); rf1.SetWidth((double)0.1); rf1.VaryWidthOff(); mapStream = vtkPolyDataMapper.New(); mapStream.SetInputConnection((vtkAlgorithmOutput)rf1.GetOutputPort()); mapStream.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[1]); streamActor = new vtkActor(); streamActor.SetMapper((vtkMapper)mapStream); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)streamActor); ren1.SetBackground((double)0.4,(double)0.4,(double)0.5); cam = ren1.GetActiveCamera(); cam.SetPosition((double)-2.35599,(double)-3.35001,(double)4.59236); cam.SetFocalPoint((double)2.255,(double)2.255,(double)1.28413); cam.SetViewUp((double)0.311311,(double)0.279912,(double)0.908149); cam.SetClippingRange((double)1.12294,(double)16.6226); renWin.SetSize((int)300,(int)200); iren.Initialize(); // interact with data[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVmergeFilter(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); ren2 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); renWin.AddRenderer((vtkRenderer)ren2); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)110); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); probeLine = new vtkLineSource(); probeLine.SetPoint1((double)1,(double)1,(double)29); probeLine.SetPoint2((double)16.5,(double)5,(double)31.7693); probeLine.SetResolution((int)500); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)probeLine.GetOutputPort()); probe.SetSource((vtkDataObject)pl3d.GetOutput()); probeTube = new vtkTubeFilter(); probeTube.SetInput((vtkDataObject)probe.GetPolyDataOutput()); probeTube.SetNumberOfSides((int)5); probeTube.SetRadius((double).05); probeMapper = vtkPolyDataMapper.New(); probeMapper.SetInputConnection((vtkAlgorithmOutput)probeTube.GetOutputPort()); probeMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); probeActor = new vtkActor(); probeActor.SetMapper((vtkMapper)probeMapper); displayLine = new vtkLineSource(); displayLine.SetPoint1((double)0,(double)0,(double)0); displayLine.SetPoint2((double)1,(double)0,(double)0); displayLine.SetResolution((int)probeLine.GetResolution()); displayMerge = new vtkMergeFilter(); displayMerge.SetGeometry((vtkDataSet)displayLine.GetOutput()); displayMerge.SetScalars((vtkDataSet)probe.GetPolyDataOutput()); displayWarp = new vtkWarpScalar(); displayWarp.SetInput((vtkDataObject)displayMerge.GetPolyDataOutput()); displayWarp.SetNormal((double)0,(double)1,(double)0); displayWarp.SetScaleFactor((double).000001); displayMapper = vtkPolyDataMapper.New(); displayMapper.SetInput((vtkPolyData)displayWarp.GetPolyDataOutput()); displayMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); displayActor = new vtkActor(); displayActor.SetMapper((vtkMapper)displayMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)probeActor); ren1.SetBackground((double)1,(double)1,(double)1); ren1.SetViewport((double)0,(double).25,(double)1,(double)1); ren2.AddActor((vtkProp)displayActor); ren2.SetBackground((double)0,(double)0,(double)0); ren2.SetViewport((double)0,(double)0,(double)1,(double).25); renWin.SetSize((int)300,(int)300); ren1.ResetCamera(); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297,(double)50); cam1.SetFocalPoint((double)8.88908,(double)0.595038,(double)29.3342); cam1.SetPosition((double)9.9,(double)-26,(double)41); cam1.SetViewUp((double)0.060772,(double)-0.319905,(double)0.945498); ren2.ResetCamera(); cam2 = ren2.GetActiveCamera(); cam2.ParallelProjectionOn(); cam2.SetParallelScale((double).15); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void SampleFunction() { vtkSphere sphere = vtkSphere.New(); // Sample the function vtkSampleFunction sample = vtkSampleFunction.New(); sample.SetSampleDimensions(50, 50, 50); sample.SetImplicitFunction(sphere); double value = 2.0; double xmin = -value, xmax = value, ymin = -value, ymax = value, zmin = -value, zmax = value; sample.SetModelBounds(xmin, xmax, ymin, ymax, zmin, zmax); // Create the 0 isosurface vtkContourFilter contours = vtkContourFilter.New(); #if VTK_MAJOR_VERSION_5 contours.SetInputConnection(sample.GetOutputPort()); #else contours.SetInputData(sample); #endif contours.GenerateValues(1, 1, 1); // Map the contours to graphical primitives vtkPolyDataMapper contourMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 contourMapper.SetInputConnection(contours.GetOutputPort()); #else contourMapper.SetInputData(contours); #endif contourMapper.SetScalarRange(0.0, 1.2); // Create an actor for the contours vtkActor contourActor = vtkActor.New(); contourActor.SetMapper(contourMapper); // -- create a box around the function to indicate the sampling volume -- // Create outline vtkOutlineFilter outline = vtkOutlineFilter.New(); #if VTK_MAJOR_VERSION_5 outline.SetInputConnection(sample.GetOutputPort()); #else outline.SetInputData(sample); #endif // Map it to graphics primitives vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 outlineMapper.SetInputConnection(outline.GetOutputPort()); #else outlineMapper.SetInputData(outline); #endif // Create an actor for it vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); outlineActor.GetProperty().SetColor(0, 0, 0); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(1.0, 1.0, 1.0); // add our actor to the renderer renderer.AddActor(contourActor); renderer.AddActor(outlineActor); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestGridSynchronizedTemplates3D(String [] argv) { //Prefix Content is: "" // cut data[] pl3d = new vtkMultiBlockPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); range = ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange(); min = (double)(lindex(range,0)); max = (double)(lindex(range,1)); value = (min+max)/2.0; //vtkGridSynchronizedTemplates3D cf[] cf = new vtkContourFilter(); cf.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); cf.SetValue((int)0,(double)value); //cf ComputeNormalsOff[] cfMapper = vtkPolyDataMapper.New(); cfMapper.ImmediateModeRenderingOn(); cfMapper.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort()); cfMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[1]); cfActor = new vtkActor(); cfActor.SetMapper((vtkMapper)cfMapper); //outline[] outline = new vtkStructuredGridOutlineFilter(); outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); //# Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.SetMultiSamples(0); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)cfActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)400,(int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297,(double)50); cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999); cam1.SetPosition((double)2.7439,(double)-37.3196,(double)38.7167); cam1.SetViewUp((double)-0.16123,(double)0.264271,(double)0.950876); iren.Initialize(); // render the image[] //[] // loop over surfaces[] i = 0; while((i) < 17) { cf.SetValue((int)0,(double)min+(i/16.0)*(max-min)); renWin.Render(); i = i + 1; } cf.SetValue((int)0,(double)min+(0.2)*(max-min)); renWin.Render(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void OBBDicer(string filePath) { vtkPolyData inputPolyData; if (filePath != null) { vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New(); reader.SetFileName(filePath); reader.Update(); inputPolyData = reader.GetOutput(); } else { vtkSphereSource sphereSource = vtkSphereSource.New(); sphereSource.SetThetaResolution(30); sphereSource.SetPhiResolution(15); sphereSource.Update(); inputPolyData = sphereSource.GetOutput(); } // Create pipeline vtkOBBDicer dicer = vtkOBBDicer.New(); #if VTK_MAJOR_VERSION_5 dicer.SetInput(inputPolyData); #else dicer.SetInputData(inputPolyData); #endif dicer.SetNumberOfPieces(4); dicer.SetDiceModeToSpecifiedNumberOfPieces(); dicer.Update(); vtkPolyDataMapper inputMapper = vtkPolyDataMapper.New(); inputMapper.SetInputConnection(dicer.GetOutputPort()); inputMapper.SetScalarRange(0, dicer.GetNumberOfActualPieces()); Debug.WriteLine("Asked for: " + dicer.GetNumberOfPieces() + " pieces, got: " + dicer.GetNumberOfActualPieces()); vtkActor inputActor = vtkActor.New(); inputActor.SetMapper(inputMapper); inputActor.GetProperty().SetInterpolationToFlat(); vtkOutlineCornerFilter outline = vtkOutlineCornerFilter.New(); #if VTK_MAJOR_VERSION_5 outline.SetInput(inputPolyData); #else outline.SetInputData(inputPolyData); #endif vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection(outline.GetOutputPort()); vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); outlineActor.GetProperty().SetColor(0, 0, 0); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(.2, .3, .4); // add our actor to the renderer renderer.AddActor(inputActor); renderer.AddActor(outlineActor); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestCutMaterial(String [] argv) { //Prefix Content is: "" // Lets create a data set.[] data = new vtkImageData(); data.SetExtent((int)0,(int)31,(int)0,(int)31,(int)0,(int)31); data.SetScalarTypeToFloat(); // First the data array:[] gauss = new vtkImageGaussianSource(); gauss.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30); gauss.SetCenter((double)18,(double)12,(double)20); gauss.SetMaximum((double)1.0); gauss.SetStandardDeviation((double)10.0); gauss.Update(); a = gauss.GetOutput().GetPointData().GetScalars(); a.SetName((string)"Gauss"); data.GetCellData().SetScalars((vtkDataArray)a); //skipping Delete gauss // Now the material array:[] ellipse = new vtkImageEllipsoidSource(); ellipse.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30); ellipse.SetCenter((double)11,(double)12,(double)13); ellipse.SetRadius((double)5,(double)9,(double)13); ellipse.SetInValue((double)1); ellipse.SetOutValue((double)0); ellipse.SetOutputScalarTypeToInt(); ellipse.Update(); m = ellipse.GetOutput().GetPointData().GetScalars(); m.SetName((string)"Material"); data.GetCellData().AddArray((vtkAbstractArray)m); //skipping Delete ellipse cut = new vtkCutMaterial(); cut.SetInput((vtkDataObject)data); cut.SetMaterialArrayName((string)"Material"); cut.SetMaterial((int)1); cut.SetArrayName((string)"Gauss"); cut.SetUpVector((double)1,(double)0,(double)0); cut.Update(); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)cut.GetOutputPort()); mapper2.SetScalarRange((double)0,(double)1); //apper2 SetScalarModeToUseCellFieldData[] //apper2 SetColorModeToMapScalars [] //apper2 ColorByArrayComponent "vtkGhostLevels" 0[] actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetPosition((double)1.5,(double)0,(double)0); ren = vtkRenderer.New(); ren.AddActor((vtkProp)actor2); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren); p = cut.GetCenterPoint(); n = cut.GetNormal(); cam = ren.GetActiveCamera(); cam.SetFocalPoint(p[0],p[1],p[2]); cam.SetViewUp(cut.GetUpVector()[0], cut.GetUpVector()[1], cut.GetUpVector()[2]); cam.SetPosition( (double)(lindex(n,0))+(double)(lindex(p,0)), (double)(lindex(n,1))+(double)(lindex(p,1)), (double)(lindex(n,2))+(double)(lindex(p,2))); ren.ResetCamera(); iren = vtkRenderWindowInteractor.New(); iren.SetRenderWindow(renWin); iren.Initialize(); //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestPolygonWriters(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // read data[] //[] input = new vtkPolyDataReader(); input.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/brainImageSmooth.vtk"); //[] // generate vectors[] clean = new vtkCleanPolyData(); clean.SetInputConnection((vtkAlgorithmOutput)input.GetOutputPort()); smooth = new vtkWindowedSincPolyDataFilter(); smooth.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort()); smooth.GenerateErrorVectorsOn(); smooth.GenerateErrorScalarsOn(); smooth.Update(); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); mapper.SetScalarRange((double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[1]); brain = new vtkActor(); brain.SetMapper((vtkMapper)mapper); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)brain); renWin.SetSize((int)320,(int)240); ren1.GetActiveCamera().SetPosition((double)149.653,(double)-65.3464,(double)96.0401); ren1.GetActiveCamera().SetFocalPoint((double)146.003,(double)22.3839,(double)0.260541); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)-0.255578,(double)-0.717754,(double)-0.647695); ren1.GetActiveCamera().SetClippingRange((double)79.2526,(double)194.052); iren.Initialize(); renWin.Render(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //[] // If the current directory is writable, then test the witers[] //[] try { channel = new StreamWriter("test.tmp"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); File.Delete("test.tmp"); //[] //[] // test the writers[] dsw = new vtkDataSetWriter(); dsw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); dsw.SetFileName((string)"brain.dsw"); dsw.Write(); File.Delete("brain.dsw"); pdw = new vtkPolyDataWriter(); pdw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); pdw.SetFileName((string)"brain.pdw"); pdw.Write(); File.Delete("brain.pdw"); iv = new vtkIVWriter(); iv.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); iv.SetFileName((string)"brain.iv"); iv.Write(); File.Delete("brain.iv"); //[] // the next writers only handle triangles[] triangles = new vtkTriangleFilter(); triangles.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort()); iv2 = new vtkIVWriter(); iv2.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); iv2.SetFileName((string)"brain2.iv"); iv2.Write(); File.Delete("brain2.iv"); edges = new vtkExtractEdges(); edges.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); iv3 = new vtkIVWriter(); iv3.SetInputConnection((vtkAlgorithmOutput)edges.GetOutputPort()); iv3.SetFileName((string)"brain3.iv"); iv3.Write(); File.Delete("brain3.iv"); byu = new vtkBYUWriter(); byu.SetGeometryFileName((string)"brain.g"); byu.SetScalarFileName((string)"brain.s"); byu.SetDisplacementFileName((string)"brain.d"); byu.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); byu.Write(); File.Delete("brain.g"); File.Delete("brain.s"); File.Delete("brain.d"); mcubes = new vtkMCubesWriter(); mcubes.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); mcubes.SetFileName((string)"brain.tri"); mcubes.SetLimitsFileName((string)"brain.lim"); mcubes.Write(); File.Delete("brain.lim"); File.Delete("brain.tri"); stl = new vtkSTLWriter(); stl.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); stl.SetFileName((string)"brain.stl"); stl.Write(); File.Delete("brain.stl"); stlBinary = new vtkSTLWriter(); stlBinary.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort()); stlBinary.SetFileName((string)"brainBinary.stl"); stlBinary.SetFileType((int)2); stlBinary.Write(); File.Delete("brainBinary.stl"); } //deleteAllVTKObjects(); }
/// <summary> /// Entry Point /// </summary> /// <param name="argv"></param> public static void Main(String[] argv) { // This example demonstrates how to use the vtkLineWidget to seed // and manipulate streamlines. Two line widgets are created. One is // invoked by pressing 'W', the other by pressing 'L'. Both can exist // together. // Start by loading some data. pl3d = vtkMultiBlockPLOT3DReader.New(); pl3d.SetXYZFileName("../../../combxyz.bin"); pl3d.SetQFileName("../../../combq.bin"); pl3d.SetScalarFunctionNumber(100); pl3d.SetVectorFunctionNumber(202); pl3d.Update(); // The line widget is used seed the streamlines. lineWidget = vtkLineWidget.New(); seeds = vtkPolyData.New(); lineWidget.SetInput(pl3d.GetOutput()); lineWidget.SetAlignToYAxis(); lineWidget.PlaceWidget(); lineWidget.GetPolyData(seeds); lineWidget.ClampToBoundsOn(); rk4 = vtkRungeKutta4.New(); streamer = vtkStreamLine.New(); streamer.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); streamer.SetSource(seeds); streamer.SetMaximumPropagationTime(100); streamer.SetIntegrationStepLength(.2); streamer.SetStepLength(.001); streamer.SetNumberOfThreads(1); streamer.SetIntegrationDirectionToForward(); streamer.VorticityOn(); streamer.SetIntegrator(rk4); rf = vtkRibbonFilter.New(); rf.SetInputConnection(streamer.GetOutputPort()); rf.SetWidth(0.1); rf.SetWidthFactor(5); streamMapper = vtkPolyDataMapper.New(); streamMapper.SetInputConnection(rf.GetOutputPort()); streamMapper.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]); streamline = vtkActor.New(); streamline.SetMapper(streamMapper); streamline.VisibilityOff(); // The second line widget is used seed more streamlines. lineWidget2 = vtkLineWidget.New(); seeds2 = vtkPolyData.New(); lineWidget2.SetInput(pl3d.GetOutput()); lineWidget2.PlaceWidget(); lineWidget2.GetPolyData(seeds2); lineWidget2.SetKeyPressActivationValue((sbyte)108); streamer2 = vtkStreamLine.New(); streamer2.SetInputDaat((vtkDataSet)pl3d.GetOutput().GetBlock(0)); streamer2.SetSource(seeds2); streamer2.SetMaximumPropagationTime(100); streamer2.SetIntegrationStepLength(.2); streamer2.SetStepLength(.001); streamer2.SetNumberOfThreads(1); streamer2.SetIntegrationDirectionToForward(); streamer2.VorticityOn(); streamer2.SetIntegrator(rk4); rf2 = vtkRibbonFilter.New(); rf2.SetInputConnection(streamer2.GetOutputPort()); rf2.SetWidth(0.1); rf2.SetWidthFactor(5); streamMapper2 = vtkPolyDataMapper.New(); streamMapper2.SetInputConnection(rf2.GetOutputPort()); streamMapper2.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]); streamline2 = vtkActor.New(); streamline2.SetMapper(streamMapper2); streamline2.VisibilityOff(); outline = vtkStructuredGridOutlineFilter.New(); outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection(outline.GetOutputPort()); outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); // Create the RenderWindow, Renderer and both Actors ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer(ren1); iren = vtkRenderWindowInteractor.New(); iren.SetRenderWindow(renWin); // Associate the line widget with the interactor lineWidget.SetInteractor(iren); lineWidget.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(BeginInteraction); lineWidget.InteractionEvt += new vtkObject.vtkObjectEventHandler(GenerateStreamlines); lineWidget2.SetInteractor(iren); lineWidget2.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(BeginInteraction2); lineWidget2.EndInteractionEvt += new vtkObject.vtkObjectEventHandler(GenerateStreamlines2); // Add the actors to the renderer, set the background and size ren1.AddActor(outlineActor); ren1.AddActor(streamline); ren1.AddActor(streamline2); ren1.SetBackground(1, 1, 1); renWin.SetSize(300, 300); ren1.SetBackground(0.1, 0.2, 0.4); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange(3.95297, 50); cam1.SetFocalPoint(9.71821, 0.458166, 29.3999); cam1.SetPosition(2.7439, -37.3196, 38.7167); cam1.SetViewUp(-0.16123, 0.264271, 0.950876); // render the image renWin.Render(); lineWidget2.On(); iren.Initialize(); iren.Start(); //Clean Up deleteAllVTKObjects(); }
private void MarchingSquares() { // Path to vtk data must be set as an environment variable // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0" vtkTesting test = vtkTesting.New(); string root = test.GetDataRoot(); vtkVolume16Reader v16 = vtkVolume16Reader.New(); v16.SetDataDimensions(64, 64); v16.GetOutput().SetOrigin(0.0, 0.0, 0.0); v16.SetDataByteOrderToLittleEndian(); v16.SetFilePrefix(System.IO.Path.Combine(root, @"Data\headsq\quarter")); v16.SetImageRange(1, 93); v16.SetDataSpacing(3.2, 3.2, 1.5); v16.Update(); vtkMergePoints myLocator = vtkMergePoints.New(); vtkMarchingSquares isoXY = vtkMarchingSquares.New(); #if VTK_MAJOR_VERSION_5 isoXY.SetInputConnection(v16.GetOutputPort()); #else isoXY.SetInputData(v16); #endif isoXY.GenerateValues(2, 600, 1200); isoXY.SetImageRange(0, 32, 32, 63, 45, 45); isoXY.SetLocator(myLocator); vtkPolyDataMapper isoXYMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 isoXYMapper.SetInputConnection(isoXY.GetOutputPort()); #else isoXYMapper.SetInputData(isoXY); #endif isoXYMapper.SetScalarRange(600, 1200); vtkActor isoXYActor = vtkActor.New(); isoXYActor.SetMapper(isoXYMapper); vtkMarchingSquares isoYZ = vtkMarchingSquares.New(); #if VTK_MAJOR_VERSION_5 isoYZ.SetInputConnection(v16.GetOutputPort()); #else isoYZ.SetInputData(v16); #endif isoYZ.GenerateValues(2, 600, 1200); isoYZ.SetImageRange(32, 32, 32, 63, 46, 92); vtkPolyDataMapper isoYZMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 isoYZMapper.SetInputConnection(isoYZ.GetOutputPort()); #else isoYZMapper.SetInputData(isoYZ); #endif isoYZMapper.SetScalarRange(600, 1200); vtkActor isoYZActor = vtkActor.New(); isoYZActor.SetMapper(isoYZMapper); vtkMarchingSquares isoXZ = vtkMarchingSquares.New(); #if VTK_MAJOR_VERSION_5 isoXZ.SetInputConnection(v16.GetOutputPort()); #else isoXZ.SetInputData(v16); #endif isoXZ.GenerateValues(2, 600, 1200); isoXZ.SetImageRange(0, 32, 32, 32, 0, 46); vtkPolyDataMapper isoXZMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 isoXZMapper.SetInputConnection(isoXZ.GetOutputPort()); #else isoXZMapper.SetInputData(isoXZ); #endif isoXZMapper.SetScalarRange(600, 1200); vtkActor isoXZActor = vtkActor.New(); isoXZActor.SetMapper(isoXZMapper); vtkOutlineFilter outline = vtkOutlineFilter.New(); #if VTK_MAJOR_VERSION_5 outline.SetInputConnection(v16.GetOutputPort()); #else outline.SetInputData(v16); #endif vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 outlineMapper.SetInputConnection(outline.GetOutputPort()); #else outlineMapper.SetInputData(outline); #endif vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); outlineActor.VisibilityOff(); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(1.0, 1.0, 1.0); //Add the actors to the renderer, set the background and size renderer.AddActor(outlineActor); renderer.AddActor(isoXYActor); renderer.AddActor(isoYZActor); renderer.AddActor(isoXZActor); renderer.GetActiveCamera().SetPosition(324.368, 284.266, -19.3293); renderer.GetActiveCamera().SetFocalPoint(73.5683, 120.903, 70.7309); renderer.GetActiveCamera().SetViewAngle(30); renderer.GetActiveCamera().SetViewUp(-0.304692, -0.0563843, -0.950781); }
private void FilledContours(string filePath, int numberOfContours) { // Read the file vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New(); reader.SetFileName(filePath); reader.Update(); // Update so that we can get the scalar range double[] scalarRange = reader.GetOutput().GetPointData().GetScalars().GetRange(); vtkAppendPolyData appendFilledContours = vtkAppendPolyData.New(); double delta = (scalarRange[1] - scalarRange[0]) / (numberOfContours - 1); // Keep the clippers alive List <vtkClipPolyData> clippersLo = new List <vtkClipPolyData>(); List <vtkClipPolyData> clippersHi = new List <vtkClipPolyData>(); for (int i = 0; i < numberOfContours; i++) { double valueLo = scalarRange[0] + i * delta; double valueHi = scalarRange[0] + (i + 1) * delta; clippersLo.Add(vtkClipPolyData.New()); clippersLo[i].SetValue(valueLo); if (i == 0) { clippersLo[i].SetInputConnection(reader.GetOutputPort()); } else { clippersLo[i].SetInputConnection(clippersHi[i - 1].GetOutputPort(1)); } clippersLo[i].InsideOutOff(); clippersLo[i].Update(); clippersHi.Add(vtkClipPolyData.New()); clippersHi[i].SetValue(valueHi); clippersHi[i].SetInputConnection(clippersLo[i].GetOutputPort()); clippersHi[i].GenerateClippedOutputOn(); clippersHi[i].InsideOutOn(); clippersHi[i].Update(); if (clippersHi[i].GetOutput().GetNumberOfCells() == 0) { continue; } vtkFloatArray cd = vtkFloatArray.New(); cd.SetNumberOfComponents(1); cd.SetNumberOfTuples(clippersHi[i].GetOutput().GetNumberOfCells()); cd.FillComponent(0, valueLo); clippersHi[i].GetOutput().GetCellData().SetScalars(cd); appendFilledContours.AddInputConnection(clippersHi[i].GetOutputPort()); } vtkCleanPolyData filledContours = vtkCleanPolyData.New(); filledContours.SetInputConnection(appendFilledContours.GetOutputPort()); vtkLookupTable lut = vtkLookupTable.New(); lut.SetNumberOfTableValues(numberOfContours + 1); lut.Build(); vtkPolyDataMapper contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection(filledContours.GetOutputPort()); contourMapper.SetScalarRange(scalarRange[0], scalarRange[1]); contourMapper.SetScalarModeToUseCellData(); contourMapper.SetLookupTable(lut); vtkActor contourActor = vtkActor.New(); contourActor.SetMapper(contourMapper); contourActor.GetProperty().SetInterpolationToFlat(); vtkContourFilter contours = vtkContourFilter.New(); contours.SetInputConnection(filledContours.GetOutputPort()); contours.GenerateValues(numberOfContours, scalarRange[0], scalarRange[1]); vtkPolyDataMapper contourLineMapperer = vtkPolyDataMapper.New(); contourLineMapperer.SetInputConnection(contours.GetOutputPort()); contourLineMapperer.SetScalarRange(scalarRange[0], scalarRange[1]); contourLineMapperer.ScalarVisibilityOff(); vtkActor contourLineActor = vtkActor.New(); contourLineActor.SetMapper(contourLineMapperer); contourLineActor.GetProperty().SetLineWidth(2); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(.2, .3, .4); // add our actor to the renderer renderer.AddActor(contourActor); renderer.AddActor(contourLineActor); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVprobeComb(String [] argv) { //Prefix Content is: "" // create planes[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); plane = new vtkPlaneSource(); plane.SetResolution((int)50,(int)50); transP1 = new vtkTransform(); transP1.Translate((double)3.7,(double)0.0,(double)28.37); transP1.Scale((double)5,(double)5,(double)5); transP1.RotateY((double)90); tpd1 = new vtkTransformPolyDataFilter(); tpd1.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd1.SetTransform((vtkAbstractTransform)transP1); outTpd1 = new vtkOutlineFilter(); outTpd1.SetInputConnection((vtkAlgorithmOutput)tpd1.GetOutputPort()); mapTpd1 = vtkPolyDataMapper.New(); mapTpd1.SetInputConnection((vtkAlgorithmOutput)outTpd1.GetOutputPort()); tpd1Actor = new vtkActor(); tpd1Actor.SetMapper((vtkMapper)mapTpd1); tpd1Actor.GetProperty().SetColor((double)0,(double)0,(double)0); transP2 = new vtkTransform(); transP2.Translate((double)9.2,(double)0.0,(double)31.20); transP2.Scale((double)5,(double)5,(double)5); transP2.RotateY((double)90); tpd2 = new vtkTransformPolyDataFilter(); tpd2.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd2.SetTransform((vtkAbstractTransform)transP2); outTpd2 = new vtkOutlineFilter(); outTpd2.SetInputConnection((vtkAlgorithmOutput)tpd2.GetOutputPort()); mapTpd2 = vtkPolyDataMapper.New(); mapTpd2.SetInputConnection((vtkAlgorithmOutput)outTpd2.GetOutputPort()); tpd2Actor = new vtkActor(); tpd2Actor.SetMapper((vtkMapper)mapTpd2); tpd2Actor.GetProperty().SetColor((double)0,(double)0,(double)0); transP3 = new vtkTransform(); transP3.Translate((double)13.27,(double)0.0,(double)33.30); transP3.Scale((double)5,(double)5,(double)5); transP3.RotateY((double)90); tpd3 = new vtkTransformPolyDataFilter(); tpd3.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd3.SetTransform((vtkAbstractTransform)transP3); outTpd3 = new vtkOutlineFilter(); outTpd3.SetInputConnection((vtkAlgorithmOutput)tpd3.GetOutputPort()); mapTpd3 = vtkPolyDataMapper.New(); mapTpd3.SetInputConnection((vtkAlgorithmOutput)outTpd3.GetOutputPort()); tpd3Actor = new vtkActor(); tpd3Actor.SetMapper((vtkMapper)mapTpd3); tpd3Actor.GetProperty().SetColor((double)0,(double)0,(double)0); appendF = new vtkAppendPolyData(); appendF.AddInput((vtkPolyData)tpd1.GetOutput()); appendF.AddInput((vtkPolyData)tpd2.GetOutput()); appendF.AddInput((vtkPolyData)tpd3.GetOutput()); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)appendF.GetOutputPort()); probe.SetSource((vtkDataObject)pl3d.GetOutput()); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); contour.GenerateValues((int)50,(double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); contourMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)contourMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)tpd1Actor); ren1.AddActor((vtkProp)tpd2Actor); ren1.AddActor((vtkProp)tpd3Actor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)400,(int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297,(double)50); cam1.SetFocalPoint((double)8.88908,(double)0.595038,(double)29.3342); cam1.SetPosition((double)-12.3332,(double)31.7479,(double)41.2387); cam1.SetViewUp((double)0.060772,(double)-0.319905,(double)0.945498); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void DrawVisQuad() { //# This example demonstrates the use of the contour filter, and the use of //# the vtkSampleFunction to generate a volume of data samples from an //# implicit function. //# VTK supports implicit functions of the form f(x,y,z)=constant. These //# functions can represent things spheres, cones, etc. Here we use a //# general form for a quadric to create an elliptical data field. vtkQuadric quadricFunction = vtkQuadric.New(); quadricFunction.SetCoefficients(0.5, 1, 0.2, 0, 0.1, 0, 0, 0.2, 0, 0); //# vtkSampleFunction samples an implicit function over the x-y-z range //# specified (here it defaults to -1,1 in the x,y,z directions). vtkSampleFunction sample = vtkSampleFunction.New(); sample.SetSampleDimensions(30, 30, 30); sample.SetImplicitFunction(quadricFunction); //# Create five surfaces F(x,y,z) = constant between range specified. The //# GenerateValues() method creates n isocontour values between the range //# specified. vtkContourFilter contourFilter = vtkContourFilter.New(); contourFilter.SetInputConnection(sample.GetOutputPort()); contourFilter.GenerateValues(10, 0.0, 1.2); vtkPolyDataMapper contMapper = vtkPolyDataMapper.New(); contMapper.SetInputConnection(contourFilter.GetOutputPort()); contMapper.SetScalarRange(0.0, 1.2); vtkActor conActor = vtkActor.New(); conActor.SetMapper(contMapper); //We'll put a simple outline around the data vtkOutlineFilter outline = vtkOutlineFilter.New(); outline.SetInputConnection(sample.GetOutputPort()); vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection(outline.GetOutputPort()); vtkActor outlineActor = vtkActor.New(); outlineActor.SetMapper(outlineMapper); outlineActor.GetProperty().SetColor(0, 0, 0); //The usual rendering stuff vtkRenderer ren = vtkRenderer.New(); vtkRenderWindow renWin = myRenderWindowControl.RenderWindow; //vtkRenderWindow renWin = vtkRenderWindow.New(); renWin.AddRenderer(ren); //vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New(); //iren.SetRenderWindow(renWin); ren.SetBackground(1, 1, 1); ren.AddActor(conActor); ren.AddActor(outlineActor); //iren.Initialize(); //renWin.Render(); //iren.Start(); }
//Parameters for building a model private void BasicVTKBuilder(ref vtkActor actor, ref vtkPoints points, ref vtkCellArray polys, ref vtkFloatArray scalars, ref vtkLookupTable Luk, ref vtkActor2D actor2D) { int pointsNum = 0; TowerModelInstance.VTKDrawModel(ref points, ref polys, ref scalars, ref pointsNum, paras); vtkPolyData profile = vtkPolyData.New(); profile.SetPoints(points); profile.SetPolys(polys); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); if (paras.RotateAngle == 0) { profile.GetCellData().SetScalars(scalars); mapper.SetInput(profile); } else { vtkRotationalExtrusionFilter refilter = vtkRotationalExtrusionFilter.New(); profile.Update(); profile.GetCellData().SetScalars(scalars); //profile.GetPointData().SetScalars(scalars); refilter.SetInput(profile); refilter.SetResolution(50); refilter.SetAngle(paras.RotateAngle); refilter.SetTranslation(0); refilter.SetDeltaRadius(0); mapper.SetInputConnection(refilter.GetOutputPort()); } mapper.SetScalarRange(TowerModelInstance.GetColorGenColorTableMinvalue(), TowerModelInstance.GetColorGenColorTableMaxValue()); actor.SetMapper(mapper); // This text property is for scalarBar vtkTextProperty textProperty = vtkTextProperty.New(); //textProperty.SetFontFamilyToCourier(); //textProperty.SetColor(1.0, 1.0, 0.5); textProperty.SetFontSize(10); vtkScalarBarActor scalarBar = vtkScalarBarActor.New(); scalarBar.SetLookupTable(mapper.GetLookupTable()); scalarBar.SetTitle("Color Table"); scalarBar.SetNumberOfLabels(TowerModelInstance.GetColorGenColorTableSize()); scalarBar.SetTitleTextProperty(textProperty); scalarBar.SetLabelTextProperty(textProperty); scalarBar.SetWidth(0.07); scalarBar.SetHeight(0.6); //scalarBar.SetDrawFrame(1); vtkLookupTable hueLut = vtkLookupTable.New(); hueLut.SetTableRange(TowerModelInstance.GetColorGenColorTableMinvalue(), TowerModelInstance.GetColorGenColorTableMaxValue()); hueLut.SetHueRange(0.667, 0); hueLut.SetSaturationRange(1, 1); hueLut.SetValueRange(1, 1); hueLut.SetNumberOfTableValues(TowerModelInstance.GetColorGenColorTableSize()); hueLut.Build(); mapper.SetLookupTable(hueLut); scalarBar.SetLookupTable(hueLut); // The actor links the data pipeline to the rendering subsystem actor2D = scalarBar; //actor.GetProperty().SetColor(0.388, 0.388, 0.388); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToRGrid(String [] argv) { //Prefix Content is: "" //# Generate a rectilinear grid from a field.[] //#[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkDataSetReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("RGridField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"RGridField.vtk"); writer.Write(); // Read the field[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"RGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToRectilinearGrid(); do2ds.SetDimensionsComponent((string)"Dimensions",(int)0); do2ds.SetPointComponent((int)0,(string)"XCoordinates",(int)0); do2ds.SetPointComponent((int)1,(string)"YCoordinates",(int)0); do2ds.SetPointComponent((int)2,(string)"ZCoordinates",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetRectilinearGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0,(string)"vectors",(int)0); fd2ad.SetVectorComponent((int)1,(string)"vectors",(int)1); fd2ad.SetVectorComponent((int)2,(string)"vectors",(int)2); fd2ad.SetScalarComponent((int)0,(string)"scalars",(int)0); fd2ad.Update(); // create pipeline[] //[] plane = new vtkRectilinearGridGeometryFilter(); plane.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813,(double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); cutPlane.SetOrigin(fd2ad.GetOutput().GetCenter()[0],fd2ad.GetOutput().GetCenter()[1],fd2ad.GetOutput().GetCenter()[2]); cutPlane.SetNormal((double)1,(double)0,(double)0); planeCut = new vtkCutter(); planeCut.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); iso.SetValue((int)0,(double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 ); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)fd2ad.GetOutputPort()); streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadiusToVaryRadiusByVector(); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 ); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); ren1.GetActiveCamera().SetPosition((double)0.0390893,(double)0.184813,(double)-3.94026); ren1.GetActiveCamera().SetFocalPoint((double)-0.00578326,(double)0,(double)0.701967); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)0.00850257,(double)0.999169,(double)0.0398605); ren1.GetActiveCamera().SetClippingRange((double)3.08127,(double)6.62716); iren.Initialize(); // render the image[] //[] File.Delete("RGridField.vtk"); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void BandedPolyDataContourFilter() { vtkPoints pts = vtkPoints.New(); pts.InsertPoint(0, 0, 0, 0); pts.InsertPoint(1, 0, 1, 0); pts.InsertPoint(2, 0, 2, 0); pts.InsertPoint(3, 1, 0, 0); pts.InsertPoint(4, 1, 1, 0); pts.InsertPoint(5, 1, 2, 0); pts.InsertPoint(6, 2, 0, 0); pts.InsertPoint(7, 2, 2, 0); pts.InsertPoint(8, 3, 0, 0); pts.InsertPoint(9, 3, 1, 0); pts.InsertPoint(10, 3, 2, 0); pts.InsertPoint(11, 4, 0, 0); pts.InsertPoint(12, 6, 0, 0); pts.InsertPoint(13, 5, 2, 0); pts.InsertPoint(14, 7, 0, 0); pts.InsertPoint(15, 9, 0, 0); pts.InsertPoint(16, 7, 2, 0); pts.InsertPoint(17, 9, 2, 0); pts.InsertPoint(18, 10, 0, 0); pts.InsertPoint(19, 12, 0, 0); pts.InsertPoint(20, 10, 1, 0); pts.InsertPoint(21, 12, 1, 0); pts.InsertPoint(22, 10, 2, 0); pts.InsertPoint(23, 12, 2, 0); pts.InsertPoint(24, 10, 3, 0); pts.InsertPoint(25, 12, 3, 0); vtkCellArray polys = vtkCellArray.New(); polys.InsertNextCell(4); polys.InsertCellPoint(14); polys.InsertCellPoint(15); polys.InsertCellPoint(17); polys.InsertCellPoint(16); polys.InsertNextCell(3); polys.InsertCellPoint(11); polys.InsertCellPoint(12); polys.InsertCellPoint(13); vtkFloatArray scalars = vtkFloatArray.New(); scalars.SetNumberOfTuples(26); scalars.SetTuple1(0, 0); scalars.SetTuple1(1, 50); scalars.SetTuple1(2, 100); scalars.SetTuple1(3, 0); scalars.SetTuple1(4, 50); scalars.SetTuple1(5, 100); scalars.SetTuple1(6, 10); scalars.SetTuple1(7, 90); scalars.SetTuple1(8, 10); scalars.SetTuple1(9, 50); scalars.SetTuple1(10, 90); scalars.SetTuple1(11, 10); scalars.SetTuple1(12, 40); scalars.SetTuple1(13, 100); scalars.SetTuple1(14, 0); scalars.SetTuple1(15, 60); scalars.SetTuple1(16, 40); scalars.SetTuple1(17, 100); scalars.SetTuple1(18, 0); scalars.SetTuple1(19, 25); scalars.SetTuple1(20, 25); scalars.SetTuple1(21, 50); scalars.SetTuple1(22, 50); scalars.SetTuple1(23, 75); scalars.SetTuple1(24, 75); scalars.SetTuple1(25, 100); vtkPolyData polyData = vtkPolyData.New(); polyData.SetPoints(pts); polyData.SetPolys(polys); polyData.GetPointData().SetScalars(scalars); vtkBandedPolyDataContourFilter bf = vtkBandedPolyDataContourFilter.New(); #if VTK_MAJOR_VERSION_5 bf.SetInput(polyData); #else bf.SetInputData(polyData); #endif bf.GenerateValues(3, 25, 75); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(bf.GetOutputPort()); mapper.SetScalarModeToUseCellData(); mapper.SetScalarRange(0, 4); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(.2, .3, .4); // add our actor to the renderer renderer.AddActor(actor); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVlabeledContours(String [] argv) { //Prefix Content is: "" // demonstrate labeling of contour with scalar value[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.SetMultiSamples(0); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Read a slice and contour it[] v16 = new vtkVolume16Reader(); v16.SetDataDimensions((int)64,(int)64); v16.GetOutput().SetOrigin((double)0.0,(double)0.0,(double)0.0); v16.SetDataByteOrderToLittleEndian(); v16.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter"); v16.SetImageRange((int)45,(int)45); v16.SetDataSpacing((double)3.2,(double)3.2,(double)1.5); iso = new vtkContourFilter(); iso.SetInputConnection((vtkAlgorithmOutput)v16.GetOutputPort()); iso.GenerateValues((int)6,(double)500,(double)1150); iso.Update(); numPts = iso.GetOutput().GetNumberOfPoints(); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); isoMapper.ScalarVisibilityOn(); isoMapper.SetScalarRange((double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[1]); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); // Subsample the points and label them[] mask = new vtkMaskPoints(); mask.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); mask.SetOnRatio((int)(numPts/50)); mask.SetMaximumNumberOfPoints((int)50); mask.RandomModeOn(); // Create labels for points - only show visible points[] visPts = new vtkSelectVisiblePoints(); visPts.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort()); visPts.SetRenderer((vtkRenderer)ren1); ldm = new vtkLabeledDataMapper(); ldm.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort()); // ldm SetLabelFormat "%g"[] ldm.SetLabelModeToLabelScalars(); tprop = ldm.GetLabelTextProperty(); tprop.SetFontFamilyToArial(); tprop.SetFontSize((int)10); tprop.SetColor((double)1,(double)0,(double)0); contourLabels = new vtkActor2D(); contourLabels.SetMapper((vtkMapper2D)ldm); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor2D((vtkProp)isoActor); ren1.AddActor2D((vtkProp)contourLabels); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)500,(int)500); renWin.Render(); ren1.GetActiveCamera().Zoom((double)1.5); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void 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 AVTestPolyDataPieces(String [] argv) { //Prefix Content is: "" math = new vtkMath(); vtkMath.RandomSeed((int)22); pf = new vtkParallelFactory(); vtkParallelFactory.RegisterFactory((vtkObjectFactory)pf); sphere = new vtkSphereSource(); sphere.SetPhiResolution((int)32); sphere.SetThetaResolution((int)32); extract = new vtkExtractPolyDataPiece(); extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort()); ps = new vtkPieceScalars(); ps.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort()); mapper.SetNumberOfPieces((int)2); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); sphere2 = new vtkSphereSource(); sphere2.SetPhiResolution((int)32); sphere2.SetThetaResolution((int)32); extract2 = new vtkExtractPolyDataPiece(); extract2.SetInputConnection((vtkAlgorithmOutput)sphere2.GetOutputPort()); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)extract2.GetOutputPort()); mapper2.SetNumberOfPieces((int)2); mapper2.SetPiece((int)1); mapper2.SetScalarRange((double)0,(double)4); mapper2.SetScalarModeToUseCellFieldData(); mapper2.SetColorModeToMapScalars(); mapper2.ColorByArrayComponent((string)"vtkGhostLevels",(int)0); mapper2.SetGhostLevel((int)4); // check the pipeline size[] extract2.UpdateInformation(); psize = new vtkPipelineSize(); if ((psize.GetEstimatedSize((vtkAlgorithm)extract2,(int)0,(int)0)) > 100) { //puts skipedputs ['stderr', '"ERROR: Pipeline Size increased"'] } if ((psize.GetNumberOfSubPieces((uint)10,(vtkPolyDataMapper)mapper2)) != 2) { //puts skipedputs ['stderr', '"ERROR: Number of sub pieces changed"'] } actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetPosition((double)1.5,(double)0,(double)0); sphere3 = new vtkSphereSource(); sphere3.SetPhiResolution((int)32); sphere3.SetThetaResolution((int)32); extract3 = new vtkExtractPolyDataPiece(); extract3.SetInputConnection((vtkAlgorithmOutput)sphere3.GetOutputPort()); ps3 = new vtkPieceScalars(); ps3.SetInputConnection((vtkAlgorithmOutput)extract3.GetOutputPort()); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)ps3.GetOutputPort()); mapper3.SetNumberOfSubPieces((int)8); mapper3.SetScalarRange((double)0,(double)8); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)0,(double)-1.5,(double)0); sphere4 = new vtkSphereSource(); sphere4.SetPhiResolution((int)32); sphere4.SetThetaResolution((int)32); extract4 = new vtkExtractPolyDataPiece(); extract4.SetInputConnection((vtkAlgorithmOutput)sphere4.GetOutputPort()); ps4 = new vtkPieceScalars(); ps4.RandomModeOn(); ps4.SetScalarModeToCellData(); ps4.SetInputConnection((vtkAlgorithmOutput)extract4.GetOutputPort()); mapper4 = vtkPolyDataMapper.New(); mapper4.SetInputConnection((vtkAlgorithmOutput)ps4.GetOutputPort()); mapper4.SetNumberOfSubPieces((int)8); mapper4.SetScalarRange((double)0,(double)8); actor4 = new vtkActor(); actor4.SetMapper((vtkMapper)mapper4); actor4.SetPosition((double)1.5,(double)-1.5,(double)0); ren = vtkRenderer.New(); ren.AddActor((vtkProp)actor); ren.AddActor((vtkProp)actor2); ren.AddActor((vtkProp)actor3); ren.AddActor((vtkProp)actor4); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); iren.Initialize(); //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVextractRectGrid(String [] argv) { //Prefix Content is: "" // create pipeline - rectilinear grid[] //[] rgridReader = new vtkRectilinearGridReader(); rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); rgridReader.Update(); extract1 = new vtkExtractRectilinearGrid(); extract1.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); //extract1 SetVOI 0 46 0 32 0 10[] extract1.SetVOI((int)23,(int)40,(int)16,(int)30,(int)9,(int)9); extract1.SetSampleRate((int)2,(int)2,(int)1); extract1.IncludeBoundaryOn(); extract1.Update(); surf1 = new vtkDataSetSurfaceFilter(); surf1.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort()); tris = new vtkTriangleFilter(); tris.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort()); mapper1 = vtkPolyDataMapper.New(); mapper1.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort()); mapper1.SetScalarRange((double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[1]); actor1 = new vtkActor(); actor1.SetMapper((vtkMapper)mapper1); // write out a rect grid[] // write to the temp directory if possible, otherwise use .[] dir = "."; dir = TclToCsScriptTestDriver.GetTempDirectory(); // make sure the directory is writeable first[] try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); rectWriter = new vtkRectilinearGridWriter(); rectWriter.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort()); rectWriter.SetFileName((string)"" + (dir.ToString()) + "/rect.tmp"); rectWriter.Write(); // delete the file[] File.Delete("" + (dir.ToString()) + "/rect.tmp"); } // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); //ren1 AddActor actor[] ren1.AddActor((vtkProp)actor1); renWin.SetSize((int)340,(int)400); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVEnSightRectGridASCII(String [] argv) { //Prefix Content is: "" VTK_VARY_RADIUS_BY_VECTOR = 2; // create pipeline[] //[] reader = new vtkGenericEnSightReader(); // Make sure all algorithms use the composite data pipeline[] cdp = new vtkCompositeDataPipeline(); vtkGenericEnSightReader.SetDefaultExecutivePrototype((vtkExecutive)cdp); reader.SetCaseFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/EnSight/RectGrid_ascii.case"); reader.Update(); toRectilinearGrid = new vtkCastToConcrete(); // toRectilinearGrid SetInputConnection [reader GetOutputPort] [] toRectilinearGrid.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); plane = new vtkRectilinearGridGeometryFilter(); plane.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15); tri = new vtkTriangleFilter(); tri.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)tri.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813,(double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); // eval cutPlane SetOrigin [[reader GetOutput] GetCenter][] cutPlane.SetOrigin((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[1], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[2]); cutPlane.SetNormal((double)1,(double)0,(double)0); planeCut = new vtkCutter(); planeCut.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange((double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); iso.SetValue((int)0,(double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 ); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); // streamer SetInputConnection [reader GetOutputPort][] streamer.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadius((int)VTK_VARY_RADIUS_BY_VECTOR); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]); // [[[[reader GetOutput] GetPointData] GetScalars] GetRange][] streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 ); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)400,(int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.76213,(double)10.712); cam1.SetFocalPoint((double)-0.0842503,(double)-0.136905,(double)0.610234); cam1.SetPosition((double)2.53813,(double)2.2678,(double)-5.22172); cam1.SetViewUp((double)-0.241047,(double)0.930635,(double)0.275343); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] vtkGenericEnSightReader.SetDefaultExecutivePrototype(null); //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToUGrid(String [] argv) { //Prefix Content is: "" // Read a field representing unstructured grid and display it (similar to blow.tcl)[] // create a reader and write out field daya[] reader = new vtkUnstructuredGridReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/blow.vtk"); reader.SetScalarsName((string)"thickness9"); reader.SetVectorsName((string)"displacement9"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); // we must be able to write here[] try { channel = new StreamWriter("UGridField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if (tryCatchError.Equals("NOERROR")) { channel.Close(); write = new vtkDataObjectWriter(); write.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); write.SetFileName((string)"UGridField.vtk"); write.Write(); // Read the field and convert to unstructured grid.[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"UGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToUnstructuredGrid(); do2ds.SetPointComponent((int)0,(string)"Points",(int)0); do2ds.SetPointComponent((int)1,(string)"Points",(int)1); do2ds.SetPointComponent((int)2,(string)"Points",(int)2); do2ds.SetCellTypeComponent((string)"CellTypes",(int)0); do2ds.SetCellConnectivityComponent((string)"Cells",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetUnstructuredGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0,(string)"displacement9",(int)0); fd2ad.SetVectorComponent((int)1,(string)"displacement9",(int)1); fd2ad.SetVectorComponent((int)2,(string)"displacement9",(int)2); fd2ad.SetScalarComponent((int)0,(string)"thickness9",(int)0); // Now start visualizing[] warp = new vtkWarpVector(); warp.SetInput((vtkDataObject)fd2ad.GetUnstructuredGridOutput()); // extract mold from mesh using connectivity[] connect = new vtkConnectivityFilter(); connect.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect.SetExtractionModeToSpecifiedRegions(); connect.AddSpecifiedRegion((int)0); connect.AddSpecifiedRegion((int)1); moldMapper = new vtkDataSetMapper(); moldMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort()); moldMapper.ScalarVisibilityOff(); moldActor = new vtkActor(); moldActor.SetMapper((vtkMapper)moldMapper); moldActor.GetProperty().SetColor((double).2,(double).2,(double).2); moldActor.GetProperty().SetRepresentationToWireframe(); // extract parison from mesh using connectivity[] connect2 = new vtkConnectivityFilter(); connect2.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect2.SetExtractionModeToSpecifiedRegions(); connect2.AddSpecifiedRegion((int)2); parison = new vtkGeometryFilter(); parison.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); normals2 = new vtkPolyDataNormals(); normals2.SetInputConnection((vtkAlgorithmOutput)parison.GetOutputPort()); normals2.SetFeatureAngle((double)60); lut = new vtkLookupTable(); lut.SetHueRange((double)0.0,(double)0.66667); parisonMapper = vtkPolyDataMapper.New(); parisonMapper.SetInputConnection((vtkAlgorithmOutput)normals2.GetOutputPort()); parisonMapper.SetLookupTable((vtkScalarsToColors)lut); parisonMapper.SetScalarRange((double)0.12,(double)1.0); parisonActor = new vtkActor(); parisonActor.SetMapper((vtkMapper)parisonMapper); cf = new vtkContourFilter(); cf.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); cf.SetValue((int)0,(double).5); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort()); contours = new vtkActor(); contours.SetMapper((vtkMapper)contourMapper); // Create graphics stuff[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] ren1.AddActor((vtkProp)moldActor); ren1.AddActor((vtkProp)parisonActor); ren1.AddActor((vtkProp)contours); ren1.ResetCamera(); ren1.GetActiveCamera().Azimuth((double)60); ren1.GetActiveCamera().Roll((double)-90); ren1.GetActiveCamera().Dolly((double)2); ren1.ResetCameraClippingRange(); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)375,(int)200); iren.Initialize(); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTenEllip(String [] argv) { //Prefix Content is: "" // create tensor ellipsoids[] // Create the RenderWindow, Renderer and interactive renderer[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.SetMultiSamples(0); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); //[] // Create tensor ellipsoids[] //[] // generate tensors[] ptLoad = new vtkPointLoad(); ptLoad.SetLoadValue((double)100.0); ptLoad.SetSampleDimensions((int)6,(int)6,(int)6); ptLoad.ComputeEffectiveStressOn(); ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10); // extract plane of data[] plane = new vtkImageDataGeometryFilter(); plane.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); plane.SetExtent((int)2,(int)2,(int)0,(int)99,(int)0,(int)99); // Generate ellipsoids[] sphere = new vtkSphereSource(); sphere.SetThetaResolution((int)8); sphere.SetPhiResolution((int)8); ellipsoids = new vtkTensorGlyph(); ellipsoids.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); ellipsoids.SetSourceConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); ellipsoids.SetScaleFactor((double)10); ellipsoids.ClampScalingOn(); ellipNormals = new vtkPolyDataNormals(); ellipNormals.SetInputConnection((vtkAlgorithmOutput)ellipsoids.GetOutputPort()); // Map contour[] lut = new vtkLogLookupTable(); lut.SetHueRange((double).6667,(double)0.0); ellipMapper = vtkPolyDataMapper.New(); ellipMapper.SetInputConnection((vtkAlgorithmOutput)ellipNormals.GetOutputPort()); ellipMapper.SetLookupTable((vtkScalarsToColors)lut); plane.Update(); //force update for scalar range[] ellipMapper.SetScalarRange((double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[1]); ellipActor = new vtkActor(); ellipActor.SetMapper((vtkMapper)ellipMapper); //[] // Create outline around data[] //[] outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); //[] // Create cone indicating application of load[] //[] coneSrc = new vtkConeSource(); coneSrc.SetRadius((double).5); coneSrc.SetHeight((double)2); coneMap = vtkPolyDataMapper.New(); coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort()); coneActor = new vtkActor(); coneActor.SetMapper((vtkMapper)coneMap); coneActor.SetPosition((double)0,(double)0,(double)11); coneActor.RotateY((double)90); coneActor.GetProperty().SetColor((double)1,(double)0,(double)0); camera = new vtkCamera(); camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919); camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807); camera.SetViewAngle((double)24.4617); camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879); camera.SetClippingRange((double)1,(double)100); ren1.AddActor((vtkProp)ellipActor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)coneActor); ren1.SetBackground((double)1.0,(double)1.0,(double)1.0); ren1.SetActiveCamera((vtkCamera)camera); renWin.SetSize((int)400,(int)400); renWin.Render(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVgaussian(String [] argv) { //Prefix Content is: "" ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); renWin.SetSize((int)300,(int)300); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); camera = new vtkCamera(); camera.ParallelProjectionOn(); camera.SetViewUp((double)0,(double)1,(double)0); camera.SetFocalPoint((double)12,(double)10.5,(double)15); camera.SetPosition((double)-70,(double)15,(double)34); camera.ComputeViewPlaneNormal(); ren1.SetActiveCamera((vtkCamera)camera); // Create the reader for the data[] //vtkStructuredPointsReader reader[] reader = new vtkGaussianCubeReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/m4_TotalDensity.cube"); reader.SetHBScale((double)1.1); reader.SetBScale((double)10); reader.Update(); range = reader.GetGridOutput().GetPointData().GetScalars().GetRange(); min = (double)(lindex(range,0)); max = (double)(lindex(range,1)); readerSS = new vtkImageShiftScale(); readerSS.SetInput((vtkDataObject)reader.GetGridOutput()); readerSS.SetShift((double)min*-1); readerSS.SetScale((double)255/(max-min)); readerSS.SetOutputScalarTypeToUnsignedChar(); bounds = new vtkOutlineFilter(); bounds.SetInput((vtkDataObject)reader.GetGridOutput()); boundsMapper = vtkPolyDataMapper.New(); boundsMapper.SetInputConnection((vtkAlgorithmOutput)bounds.GetOutputPort()); boundsActor = new vtkActor(); boundsActor.SetMapper((vtkMapper)boundsMapper); boundsActor.GetProperty().SetColor((double)0,(double)0,(double)0); contour = new vtkContourFilter(); contour.SetInput((vtkDataObject)reader.GetGridOutput()); contour.GenerateValues((int)5,(double)0,(double).05); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); contourMapper.SetScalarRange((double)0,(double).1); ((vtkLookupTable)contourMapper.GetLookupTable()).SetHueRange(0.32,0); contourActor = new vtkActor(); contourActor.SetMapper((vtkMapper)contourMapper); contourActor.GetProperty().SetOpacity((double).5); // Create transfer mapping scalar value to opacity[] opacityTransferFunction = new vtkPiecewiseFunction(); opacityTransferFunction.AddPoint((double)0,(double)0.01); opacityTransferFunction.AddPoint((double)255,(double)0.35); opacityTransferFunction.ClampingOn(); // Create transfer mapping scalar value to color[] colorTransferFunction = new vtkColorTransferFunction(); colorTransferFunction.AddHSVPoint((double)0.0,(double)0.66,(double)1.0,(double)1.0); colorTransferFunction.AddHSVPoint((double)50.0,(double)0.33,(double)1.0,(double)1.0); colorTransferFunction.AddHSVPoint((double)100.0,(double)0.00,(double)1.0,(double)1.0); // The property describes how the data will look[] volumeProperty = new vtkVolumeProperty(); volumeProperty.SetColor((vtkColorTransferFunction)colorTransferFunction); volumeProperty.SetScalarOpacity((vtkPiecewiseFunction)opacityTransferFunction); volumeProperty.SetInterpolationTypeToLinear(); // The mapper / ray cast function know how to render the data[] compositeFunction = new vtkVolumeRayCastCompositeFunction(); volumeMapper = new vtkVolumeRayCastMapper(); //vtkVolumeTextureMapper2D volumeMapper[] volumeMapper.SetVolumeRayCastFunction((vtkVolumeRayCastFunction)compositeFunction); volumeMapper.SetInputConnection((vtkAlgorithmOutput)readerSS.GetOutputPort()); // The volume holds the mapper and the property and[] // can be used to position/orient the volume[] volume = new vtkVolume(); volume.SetMapper((vtkAbstractVolumeMapper)volumeMapper); volume.SetProperty((vtkVolumeProperty)volumeProperty); ren1.AddVolume((vtkProp)volume); //ren1 AddActor contourActor[] ren1.AddActor((vtkProp)boundsActor); //#####################################################################[] Sphere = new vtkSphereSource(); Sphere.SetCenter((double)0,(double)0,(double)0); Sphere.SetRadius((double)1); Sphere.SetThetaResolution((int)16); Sphere.SetStartTheta((double)0); Sphere.SetEndTheta((double)360); Sphere.SetPhiResolution((int)16); Sphere.SetStartPhi((double)0); Sphere.SetEndPhi((double)180); Glyph = new vtkGlyph3D(); Glyph.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); Glyph.SetOrient((int)1); Glyph.SetColorMode((int)1); //Glyph ScalingOn[] Glyph.SetScaleMode((int)2); Glyph.SetScaleFactor((double).6); Glyph.SetSource((vtkPolyData)Sphere.GetOutput()); AtomsMapper = vtkPolyDataMapper.New(); AtomsMapper.SetInputConnection((vtkAlgorithmOutput)Glyph.GetOutputPort()); AtomsMapper.SetImmediateModeRendering((int)1); AtomsMapper.UseLookupTableScalarRangeOff(); AtomsMapper.SetScalarVisibility((int)1); AtomsMapper.SetScalarModeToDefault(); Atoms = new vtkActor(); Atoms.SetMapper((vtkMapper)AtomsMapper); Atoms.GetProperty().SetRepresentationToSurface(); Atoms.GetProperty().SetInterpolationToGouraud(); Atoms.GetProperty().SetAmbient((double)0.15); Atoms.GetProperty().SetDiffuse((double)0.85); Atoms.GetProperty().SetSpecular((double)0.1); Atoms.GetProperty().SetSpecularPower((double)100); Atoms.GetProperty().SetSpecularColor((double)1,(double)1,(double)1); Atoms.GetProperty().SetColor((double)1,(double)1,(double)1); Tube = new vtkTubeFilter(); Tube.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); Tube.SetNumberOfSides((int)16); Tube.SetCapping((int)0); Tube.SetRadius((double)0.2); Tube.SetVaryRadius((int)0); Tube.SetRadiusFactor((double)10); BondsMapper = vtkPolyDataMapper.New(); BondsMapper.SetInputConnection((vtkAlgorithmOutput)Tube.GetOutputPort()); BondsMapper.SetImmediateModeRendering((int)1); BondsMapper.UseLookupTableScalarRangeOff(); BondsMapper.SetScalarVisibility((int)1); BondsMapper.SetScalarModeToDefault(); Bonds = new vtkActor(); Bonds.SetMapper((vtkMapper)BondsMapper); Bonds.GetProperty().SetRepresentationToSurface(); Bonds.GetProperty().SetInterpolationToGouraud(); Bonds.GetProperty().SetAmbient((double)0.15); Bonds.GetProperty().SetDiffuse((double)0.85); Bonds.GetProperty().SetSpecular((double)0.1); Bonds.GetProperty().SetSpecularPower((double)100); Bonds.GetProperty().SetSpecularColor((double)1,(double)1,(double)1); Bonds.GetProperty().SetColor((double)1,(double)1,(double)1); ren1.AddActor((vtkProp)Bonds); ren1.AddActor((vtkProp)Atoms); //###################################################[] ren1.SetBackground((double)1,(double)1,(double)1); ren1.ResetCamera(); renWin.Render(); //method moved renWin.AbortCheckEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(TkCheckAbort_Command.Execute); iren.Initialize(); //deleteAllVTKObjects(); }
/// <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 AVgeomFilter(String [] argv) { //Prefix Content is: "" // create pipeline - structured grid[] //[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); gf = new vtkGeometryFilter(); gf.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); gMapper = vtkPolyDataMapper.New(); gMapper.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort()); gMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); gActor = new vtkActor(); gActor.SetMapper((vtkMapper)gMapper); gf2 = new vtkGeometryFilter(); gf2.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); gf2.ExtentClippingOn(); gf2.SetExtent((double)10,(double)17,(double)-6,(double)6,(double)23,(double)37); gf2.PointClippingOn(); gf2.SetPointMinimum((int)0); gf2.SetPointMaximum((int)10000); gf2.CellClippingOn(); gf2.SetCellMinimum((int)0); gf2.SetCellMaximum((int)7500); g2Mapper = vtkPolyDataMapper.New(); g2Mapper.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort()); g2Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g2Actor = new vtkActor(); g2Actor.SetMapper((vtkMapper)g2Mapper); g2Actor.AddPosition((double)0,(double)15,(double)0); // create pipeline - poly data[] //[] gf3 = new vtkGeometryFilter(); gf3.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort()); g3Mapper = vtkPolyDataMapper.New(); g3Mapper.SetInputConnection((vtkAlgorithmOutput)gf3.GetOutputPort()); g3Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g3Actor = new vtkActor(); g3Actor.SetMapper((vtkMapper)g3Mapper); g3Actor.AddPosition((double)0,(double)0,(double)15); gf4 = new vtkGeometryFilter(); gf4.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort()); gf4.ExtentClippingOn(); gf4.SetExtent((double)10,(double)17,(double)-6,(double)6,(double)23,(double)37); gf4.PointClippingOn(); gf4.SetPointMinimum((int)0); gf4.SetPointMaximum((int)10000); gf4.CellClippingOn(); gf4.SetCellMinimum((int)0); gf4.SetCellMaximum((int)7500); g4Mapper = vtkPolyDataMapper.New(); g4Mapper.SetInputConnection((vtkAlgorithmOutput)gf4.GetOutputPort()); g4Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g4Actor = new vtkActor(); g4Actor.SetMapper((vtkMapper)g4Mapper); g4Actor.AddPosition((double)0,(double)15,(double)15); // create pipeline - unstructured grid[] //[] s = new vtkSphere(); s.SetCenter(pl3d.GetOutput().GetCenter()[0],pl3d.GetOutput().GetCenter()[1],pl3d.GetOutput().GetCenter()[2]); s.SetRadius((double)100.0); //everything[] eg = new vtkExtractGeometry(); eg.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); eg.SetImplicitFunction((vtkImplicitFunction)s); gf5 = new vtkGeometryFilter(); gf5.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort()); g5Mapper = vtkPolyDataMapper.New(); g5Mapper.SetInputConnection((vtkAlgorithmOutput)gf5.GetOutputPort()); g5Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g5Actor = new vtkActor(); g5Actor.SetMapper((vtkMapper)g5Mapper); g5Actor.AddPosition((double)0,(double)0,(double)30); gf6 = new vtkGeometryFilter(); gf6.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort()); gf6.ExtentClippingOn(); gf6.SetExtent((double)10,(double)17,(double)-6,(double)6,(double)23,(double)37); gf6.PointClippingOn(); gf6.SetPointMinimum((int)0); gf6.SetPointMaximum((int)10000); gf6.CellClippingOn(); gf6.SetCellMinimum((int)0); gf6.SetCellMaximum((int)7500); g6Mapper = vtkPolyDataMapper.New(); g6Mapper.SetInputConnection((vtkAlgorithmOutput)gf6.GetOutputPort()); g6Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); g6Actor = new vtkActor(); g6Actor.SetMapper((vtkMapper)g6Mapper); g6Actor.AddPosition((double)0,(double)15,(double)30); // create pipeline - rectilinear grid[] //[] rgridReader = new vtkRectilinearGridReader(); rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); rgridReader.Update(); gf7 = new vtkGeometryFilter(); gf7.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); g7Mapper = vtkPolyDataMapper.New(); g7Mapper.SetInputConnection((vtkAlgorithmOutput)gf7.GetOutputPort()); g7Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]); g7Actor = new vtkActor(); g7Actor.SetMapper((vtkMapper)g7Mapper); g7Actor.SetScale((double)3,(double)3,(double)3); gf8 = new vtkGeometryFilter(); gf8.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort()); gf8.ExtentClippingOn(); gf8.SetExtent((double)0,(double)1,(double)-2,(double)2,(double)0,(double)4); gf8.PointClippingOn(); gf8.SetPointMinimum((int)0); gf8.SetPointMaximum((int)10000); gf8.CellClippingOn(); gf8.SetCellMinimum((int)0); gf8.SetCellMaximum((int)7500); g8Mapper = vtkPolyDataMapper.New(); g8Mapper.SetInputConnection((vtkAlgorithmOutput)gf8.GetOutputPort()); g8Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]); g8Actor = new vtkActor(); g8Actor.SetMapper((vtkMapper)g8Mapper); g8Actor.SetScale((double)3,(double)3,(double)3); g8Actor.AddPosition((double)0,(double)15,(double)0); // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); ren1.AddActor((vtkProp)gActor); ren1.AddActor((vtkProp)g2Actor); ren1.AddActor((vtkProp)g3Actor); ren1.AddActor((vtkProp)g4Actor); ren1.AddActor((vtkProp)g5Actor); ren1.AddActor((vtkProp)g6Actor); ren1.AddActor((vtkProp)g7Actor); ren1.AddActor((vtkProp)g8Actor); renWin.SetSize((int)340,(int)550); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)84,(double)174); cam1.SetFocalPoint((double)5.22824,(double)6.09412,(double)35.9813); cam1.SetPosition((double)100.052,(double)62.875,(double)102.818); cam1.SetViewUp((double)-0.307455,(double)-0.464269,(double)0.830617); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVpolyConn(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // read data[] //[] pl3d = new vtkMultiBlockPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); // planes to connect[] plane1 = new vtkStructuredGridGeometryFilter(); plane1.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); plane1.SetExtent((int)20,(int)20,(int)0,(int)100,(int)0,(int)100); conn = new vtkPolyDataConnectivityFilter(); conn.SetInputConnection((vtkAlgorithmOutput)plane1.GetOutputPort()); conn.ScalarConnectivityOn(); conn.SetScalarRange((double)0.19,(double)0.25); plane1Map = vtkPolyDataMapper.New(); plane1Map.SetInputConnection((vtkAlgorithmOutput)conn.GetOutputPort()); plane1Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); plane1Actor = new vtkActor(); plane1Actor.SetMapper((vtkMapper)plane1Map); plane1Actor.GetProperty().SetOpacity((double)0.999); // outline[] outline = new vtkStructuredGridOutlineFilter(); outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineProp = outlineActor.GetProperty(); outlineProp.SetColor((double)0,(double)0,(double)0); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)plane1Actor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); cam1 = new vtkCamera(); cam1.SetClippingRange((double)14.29,(double)63.53); cam1.SetFocalPoint((double)8.58522,(double)1.58266,(double)30.6486); cam1.SetPosition((double)37.6808,(double)-20.1298,(double)35.4016); cam1.SetViewAngle((double)30); cam1.SetViewUp((double)-0.0566235,(double)0.140504,(double)0.98846); ren1.SetActiveCamera((vtkCamera)cam1); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void RenderXYZColor() { FileStream fs = null; StreamReader sr = null; String sLineBuffer; String[] sXYZ; char[] chDelimiter = new char[] { ' ', '\t', ';' }; double[] xyz = new double[3]; double[] rgb = new double[3]; vtkPoints points = vtkPoints.New(); vtkPoints colors = vtkPoints.New(); int cnt = 0; try { // in case file must be open in another application too use "FileShare.ReadWrite" fs = new FileStream(m_FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); sr = new StreamReader(fs); vtkDoubleArray colorScalor = new vtkDoubleArray(); int n = 1; while (!sr.EndOfStream) { sLineBuffer = sr.ReadLine(); cnt++; sXYZ = sLineBuffer.Split(chDelimiter, StringSplitOptions.RemoveEmptyEntries); if (sXYZ == null || sXYZ.Length != 6) { MessageBox.Show("data seems to be in wrong format at line " + cnt, "Format Exception", MessageBoxButtons.OK); return; } xyz[0] = double.Parse(sXYZ[0], CultureInfo.InvariantCulture) * 11100; xyz[1] = double.Parse(sXYZ[1], CultureInfo.InvariantCulture) * 11100; xyz[2] = double.Parse(sXYZ[2], CultureInfo.InvariantCulture); rgb[0] = double.Parse(sXYZ[0], CultureInfo.InvariantCulture); rgb[1] = double.Parse(sXYZ[1], CultureInfo.InvariantCulture); rgb[2] = double.Parse(sXYZ[2], CultureInfo.InvariantCulture); points.InsertNextPoint(xyz[0], xyz[1], xyz[2]); colors.InsertNextPoint(rgb[0], rgb[1], rgb[2]); colorScalor.InsertNextTuple1(n++); } vtkPolyData polydata = vtkPolyData.New(); polydata.SetPoints(points); polydata.GetPointData().SetScalars(colorScalor); //设置点的Scalar(标量)属性 vtkVertexGlyphFilter glyphFilter = vtkVertexGlyphFilter.New(); glyphFilter.SetInputConnection(polydata.GetProducerPort()); vtkLookupTable lookupTable = new vtkLookupTable(); lookupTable.SetNumberOfColors(n); // SetSetTableValue(vtkIdType indx, double r, double g, double b, double a); Random random = new Random(); for (int i = 0; i < n; i++) { double[] tmp = colors.GetPoint(i); double r = tmp[0]; double g = tmp[1]; double b = tmp[2]; lookupTable.SetTableValue(i, r, g, b, 1); } // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(glyphFilter.GetOutputPort()); mapper.SetLookupTable(lookupTable); mapper.SetScalarRange(1, n); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetPointSize(1); //actor.GetProperty().SetColor(1, 0.5, 0); // add our actor to the renderer m_Renderer.AddActor(actor); imgPropList.Add(actor); m_Renderer.ResetCamera(); //Rerender the screen m_RenderWindow.Render(); m_Renderer.Render(); } catch (IOException ex) { MessageBox.Show(ex.Message, "IOException", MessageBoxButtons.OK); } finally { if (sr != null) { sr.Close(); sr.Dispose(); sr = null; } } }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestBranchExtentTranslator(String [] argv) { //Prefix Content is: "" gauss = new vtkImageGaussianSource(); gauss.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)2); gauss.SetCenter((double)18,(double)12,(double)0); gauss.SetMaximum((double)1.0); gauss.SetStandardDeviation((double)6.0); gauss.Update(); translator = new vtkBranchExtentTranslator(); translator.SetOriginalSource((vtkImageData)gauss.GetOutput()); gauss.GetOutput().SetExtentTranslator((vtkExtentTranslator)translator); clip1 = new vtkImageClip(); clip1.SetOutputWholeExtent((int)7,(int)28,(int)0,(int)15,(int)1,(int)1); clip1.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf1 = new vtkDataSetSurfaceFilter(); surf1.SetInputConnection((vtkAlgorithmOutput)clip1.GetOutputPort()); tf1 = new vtkTriangleFilter(); tf1.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort()); mapper1 = vtkPolyDataMapper.New(); mapper1.SetInputConnection((vtkAlgorithmOutput)tf1.GetOutputPort()); mapper1.SetScalarRange((double)0,(double)1); mapper1.SetNumberOfPieces((int)4); mapper1.SetPiece((int)1); actor1 = new vtkActor(); actor1.SetMapper((vtkMapper)mapper1); actor1.SetPosition((double)0,(double)0,(double)0); // For coverage, a case where all four sides get clipped by the whole extent.[] clip2 = new vtkImageClip(); clip2.SetOutputWholeExtent((int)16,(int)18,(int)3,(int)10,(int)0,(int)0); clip2.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf2 = new vtkDataSetSurfaceFilter(); surf2.SetInputConnection((vtkAlgorithmOutput)clip2.GetOutputPort()); tf2 = new vtkTriangleFilter(); tf2.SetInputConnection((vtkAlgorithmOutput)surf2.GetOutputPort()); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)tf2.GetOutputPort()); mapper2.SetScalarRange((double)0,(double)1); mapper2.SetNumberOfPieces((int)4); mapper2.SetPiece((int)1); actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetPosition((double)15,(double)0,(double)0); // nothing in intersection (empty case)[] clip3 = new vtkImageClip(); clip3.SetOutputWholeExtent((int)1,(int)10,(int)0,(int)15,(int)0,(int)2); clip3.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf3 = new vtkDataSetSurfaceFilter(); surf3.SetInputConnection((vtkAlgorithmOutput)clip3.GetOutputPort()); tf3 = new vtkTriangleFilter(); tf3.SetInputConnection((vtkAlgorithmOutput)surf3.GetOutputPort()); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)tf3.GetOutputPort()); mapper3.SetScalarRange((double)0,(double)1); mapper3.SetNumberOfPieces((int)4); mapper3.SetPiece((int)1); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)30,(double)0,(double)0); ren = vtkRenderer.New(); ren.AddActor((vtkProp)actor1); ren.AddActor((vtkProp)actor2); ren.AddActor((vtkProp)actor3); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren); //set cam [ren GetActiveCamera][] //ren ResetCamera[] iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); iren.Initialize(); renWin.Render(); // break loop to avoid a memory leak.[] translator.SetOriginalSource(null); //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(); }