private void Arrow() { // Create two arrows. vtkArrowSource arrowSource01 = vtkArrowSource.New(); vtkArrowSource arrowSource02 = vtkArrowSource.New(); arrowSource02.SetShaftResolution(24); // default = 6 arrowSource02.SetTipResolution(36); // default = 6 // Visualize vtkPolyDataMapper mapper01 = vtkPolyDataMapper.New(); vtkPolyDataMapper mapper02 = vtkPolyDataMapper.New(); mapper01.SetInputConnection(arrowSource01.GetOutputPort()); mapper02.SetInputConnection(arrowSource02.GetOutputPort()); vtkActor actor01 = vtkActor.New(); vtkActor actor02 = vtkActor.New(); actor01.SetMapper(mapper01); actor02.SetMapper(mapper02); actor01.SetPosition(0.0, 0.25, 0.0); actor02.SetPosition(0.0, -0.25, 0.0); vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); renderer.SetBackground(0.2, 0.3, 0.4); renderer.AddActor(actor01); renderer.AddActor(actor02); renderer.ResetCamera(); }
private void button2_Click_1(object sender, EventArgs e) { string inscriptionpath = textBox1.Text; vtkVectorText text = vtkVectorText.New(); text.SetText(inscriptionpath); //text.GetOutput().GetPoints().GetNumberOfPoints(); // //vtkLinearExtrusionFilter extrude = vtkLinearExtrusionFilter.New(); //extrude.SetInputConnection(text.GetOutputPort()); //extrude.SetExtrusionTypeToNormalExtrusion(); //extrude.SetVector(0, 0, 1); //extrude.SetScaleFactor(0.5); //vtkTriangleFilter triangle = vtkTriangleFilter.New(); //triangle.SetInputConnection(extrude.GetOutputPort()); vtkDataSetMapper mapper = vtkDataSetMapper.New(); mapper.SetInputConnection(text.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetColor(0.8900, 0.8100, 0.3400); actor.SetPosition(0, 0, 0); renderWindow.AddRenderer(renderer); renderer.AddActor(actor); renderer.ResetCamera(); renderWindow.GetInteractor().Render(); }
private void MoveClipPlane(vtkObject sender, vtkObjectEventArgs e) { if (ClipPlane.GetNormal()[0] != 0) { ClipPlane.SetOrigin(SliderRep.GetValue(), ClipPlane.GetOrigin()[1], ClipPlane.GetOrigin()[2]); } if (ClipPlane.GetNormal()[1] != 0) { ClipPlane.SetOrigin(ClipPlane.GetOrigin()[0], SliderRep.GetValue(), ClipPlane.GetOrigin()[2]); } if (ClipPlane.GetNormal()[2] != 0) { ClipPlane.SetOrigin(ClipPlane.GetOrigin()[0], ClipPlane.GetOrigin()[1], SliderRep.GetValue()); } ClipPlaneActor.SetPosition( ClipPlane.GetOrigin()[0], ClipPlane.GetOrigin()[1], ClipPlane.GetOrigin()[2]); }
/// <summary> /// Changes the actors to whatever the /// animal currently loaded is /// </summary> public void updateAnimal() { //----Go through the pipeline for the animal body //Convert the polydata to triangles (in the default files they are rectangles) triangleAnimal.SetInputConnection(animalData); if (this.checkBox1.Checked) { //smooth the polydata cleanAnimal.SetInputConnection(triangleAnimal.GetOutputPort()); smoothAnimal.SetInputConnection(cleanAnimal.GetOutputPort()); normalsAnimal.SetInputConnection(smoothAnimal.GetOutputPort()); //connect the smoothed data to a mapper animalMapper.SetInputConnection(normalsAnimal.GetOutputPort()); //decimate the smoothed polydata decimateAnimal.SetInputConnection(normalsAnimal.GetOutputPort()); } else { //connect the triangle polydata to a mapper before decimation animalMapper.SetInputConnection(triangleAnimal.GetOutputPort()); //decimate the triangled data decimateAnimal.SetInputConnection(triangleAnimal.GetOutputPort()); } double targetreduc = 0.5; if (double.TryParse(toolStripTextBox1.Text, out targetreduc)) { decimateAnimal.SetTargetReduction(targetreduc); } decimateAnimal.SetPreserveTopology(0); //connect the decimated polydata a mapper deciAnimalMapper.SetInputConnection(decimateAnimal.GetOutputPort()); //----Go through the pipeline for the first eye //Convert the polydata to triangles (in the default files they are rectangles) triangles.SetInputConnection(eyeData1); if (this.checkBox1.Checked) { //smooth the polydata clean.SetInputConnection(triangles.GetOutputPort()); smooth.SetInputConnection(clean.GetOutputPort()); normals.SetInputConnection(smooth.GetOutputPort()); //connect the smoothed data to a mapper sphereTexture.SetInputConnection(normals.GetOutputPort()); //decimate the smoothed polydata eyeMapper1.SetInputConnection(sphereTexture.GetOutputPort()); } else { sphereTexture.SetInputConnection(triangles.GetOutputPort()); //connect the triangle polydata to a mapper before decimation eyeMapper1.SetInputConnection(sphereTexture.GetOutputPort()); } decimate.SetInputConnection(sphereTexture.GetOutputPort()); if (double.TryParse(toolStripTextBox1.Text, out targetreduc)) { decimate.SetTargetReduction(targetreduc); } decimate.SetPreserveTopology(0); //connect the decimated polydata a mapper deciEyeMapper1.SetInputConnection(decimate.GetOutputPort()); //----Go through the pipeline for the second eye //Convert the polydata to triangles (in the default files they are rectangles) triangles.SetInputConnection(eyeData1); if (this.checkBox1.Checked) { //smooth the polydata clean.SetInputConnection(triangles.GetOutputPort()); smooth.SetInputConnection(clean.GetOutputPort()); normals.SetInputConnection(smooth.GetOutputPort()); //connect the smoothed data to a mapper sphereTexture.SetInputConnection(normals.GetOutputPort()); //decimate the smoothed polydata eyeMapper2.SetInputConnection(sphereTexture.GetOutputPort()); } else { sphereTexture.SetInputConnection(triangles.GetOutputPort()); //connect the triangle polydata to a mapper before decimation eyeMapper2.SetInputConnection(sphereTexture.GetOutputPort()); } decimate.SetInputConnection(sphereTexture.GetOutputPort()); if (double.TryParse(toolStripTextBox1.Text, out targetreduc)) { decimate.SetTargetReduction(targetreduc); } decimate.SetPreserveTopology(0); //connect the decimated polydata a mapper deciEyeMapper2.SetInputConnection(decimate.GetOutputPort()); //----Set the textures and position of the decimated model deciAnimalActor.SetMapper(deciAnimalMapper); if (this.checkBox2.Checked) { deciAnimalActor.SetTexture(deciAnimalColorTexture); } else { deciAnimalActor.SetTexture(null); } deciEyeActor1.SetMapper(deciEyeMapper1); if (this.checkBox2.Checked) { deciEyeActor1.SetTexture(eyeColorTexture1); deciEyeActor1.SetTexture(deciEyeColorTexture1); } else { deciEyeActor1.SetTexture(null); } deciEyeActor1.SetPosition(eyeX, eyeY, eyeZ); deciEyeActor2.SetMapper(deciEyeMapper2); if (this.checkBox2.Checked) { deciEyeActor2.SetTexture(eyeColorTexture2); deciEyeActor2.SetTexture(deciEyeColorTexture2); } else { deciEyeActor2.SetTexture(null); } deciEyeActor2.SetPosition(-eyeX, eyeY, eyeZ); //----Set the text to the decimated poly count //Update the mappers to get the number of polygons deciAnimalMapper.Update(); deciEyeMapper1.Update(); deciEyeMapper2.Update(); textAfter.SetInput(((((vtkPolyData)deciAnimalMapper.GetInput()).GetNumberOfPolys() + ((vtkPolyData)deciEyeMapper1.GetInput()).GetNumberOfPolys() + ((vtkPolyData)deciEyeMapper2.GetInput()).GetNumberOfPolys())).ToString() + " Polygons"); textAfter.SetDisplayPosition(10, 10); //----Set the textures and position of the decimated model animalActor.SetMapper(animalMapper); if (this.checkBox2.Checked) { animalActor.SetTexture(animalColorTexture); } else { animalActor.SetTexture(null); } eyeActor1.SetMapper(eyeMapper1); if (this.checkBox2.Checked) { eyeActor1.SetTexture(eyeColorTexture1); } else { eyeActor1.SetTexture(null); } eyeActor1.SetPosition(eyeX, eyeY, eyeZ); eyeActor2.SetMapper(eyeMapper2); if (this.checkBox2.Checked) { eyeActor2.SetTexture(eyeColorTexture2); } else { eyeActor2.SetTexture(null); } eyeActor2.SetPosition(-eyeX, eyeY, eyeZ); //Update the pipeline to get the number of polygons animalMapper.Update(); eyeMapper1.Update(); eyeMapper2.Update(); //----Set the text to the full poly count textBefore.SetInput((((vtkPolyData)animalMapper.GetInput()).GetNumberOfPolys() + ((vtkPolyData)eyeMapper1.GetInput()).GetNumberOfPolys() + ((vtkPolyData)eyeMapper2.GetInput()).GetNumberOfPolys()).ToString() + " Polygons"); textBefore.SetDisplayPosition(10, 10); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVHyper(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and interactive renderer[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); VTK_INTEGRATE_BOTH_DIRECTIONS = 2; //[] // generate tensors[] ptLoad = new vtkPointLoad(); ptLoad.SetLoadValue((double)100.0); ptLoad.SetSampleDimensions((int)20,(int)20,(int)20); ptLoad.ComputeEffectiveStressOn(); ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10); //[] // If the current directory is writable, then test the witers[] //[] try { channel = new StreamWriter("test.tmp"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); File.Delete("test.tmp"); wSP = new vtkDataSetWriter(); wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); wSP.SetFileName((string)"wSP.vtk"); wSP.SetTensorsName((string)"pointload"); wSP.SetScalarsName((string)"effective_stress"); wSP.Write(); rSP = new vtkDataSetReader(); rSP.SetFileName((string)"wSP.vtk"); rSP.SetTensorsName((string)"pointload"); rSP.SetScalarsName((string)"effective_stress"); rSP.Update(); input = rSP.GetOutput(); File.Delete("wSP.vtk"); } else { input = ptLoad.GetOutput(); } // Generate hyperstreamlines[] s1 = new vtkHyperStreamline(); s1.SetInputData((vtkDataObject)input); s1.SetStartPosition((double)9,(double)9,(double)-9); s1.IntegrateMinorEigenvector(); s1.SetMaximumPropagationDistance((double)18.0); s1.SetIntegrationStepLength((double)0.1); s1.SetStepLength((double)0.01); s1.SetRadius((double)0.25); s1.SetNumberOfSides((int)18); s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s1.Update(); // Map hyperstreamlines[] lut = new vtkLogLookupTable(); lut.SetHueRange((double).6667,(double)0.0); s1Mapper = vtkPolyDataMapper.New(); s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort()); s1Mapper.SetLookupTable((vtkScalarsToColors)lut); ptLoad.Update(); //force update for scalar range[] s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]); s1Actor = new vtkActor(); s1Actor.SetMapper((vtkMapper)s1Mapper); s2 = new vtkHyperStreamline(); s2.SetInputData((vtkDataObject)input); s2.SetStartPosition((double)-9,(double)-9,(double)-9); s2.IntegrateMinorEigenvector(); s2.SetMaximumPropagationDistance((double)18.0); s2.SetIntegrationStepLength((double)0.1); s2.SetStepLength((double)0.01); s2.SetRadius((double)0.25); s2.SetNumberOfSides((int)18); s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s2.Update(); s2Mapper = vtkPolyDataMapper.New(); s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort()); s2Mapper.SetLookupTable((vtkScalarsToColors)lut); s2Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]); s2Actor = new vtkActor(); s2Actor.SetMapper((vtkMapper)s2Mapper); s3 = new vtkHyperStreamline(); s3.SetInputData((vtkDataObject)input); s3.SetStartPosition((double)9,(double)-9,(double)-9); s3.IntegrateMinorEigenvector(); s3.SetMaximumPropagationDistance((double)18.0); s3.SetIntegrationStepLength((double)0.1); s3.SetStepLength((double)0.01); s3.SetRadius((double)0.25); s3.SetNumberOfSides((int)18); s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s3.Update(); s3Mapper = vtkPolyDataMapper.New(); s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort()); s3Mapper.SetLookupTable((vtkScalarsToColors)lut); s3Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]); s3Actor = new vtkActor(); s3Actor.SetMapper((vtkMapper)s3Mapper); s4 = new vtkHyperStreamline(); s4.SetInputData((vtkDataObject)input); s4.SetStartPosition((double)-9,(double)9,(double)-9); s4.IntegrateMinorEigenvector(); s4.SetMaximumPropagationDistance((double)18.0); s4.SetIntegrationStepLength((double)0.1); s4.SetStepLength((double)0.01); s4.SetRadius((double)0.25); s4.SetNumberOfSides((int)18); s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s4.Update(); s4Mapper = vtkPolyDataMapper.New(); s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort()); s4Mapper.SetLookupTable((vtkScalarsToColors)lut); s4Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]); s4Actor = new vtkActor(); s4Actor.SetMapper((vtkMapper)s4Mapper); // plane for context[] //[] g = new vtkImageDataGeometryFilter(); g.SetInputData((vtkDataObject)input); g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0); g.Update(); //for scalar range[] gm = vtkPolyDataMapper.New(); gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort()); gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); ga = new vtkActor(); ga.SetMapper((vtkMapper)gm); // Create outline around data[] //[] outline = new vtkOutlineFilter(); outline.SetInputData((vtkDataObject)input); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); // Create cone indicating application of load[] //[] coneSrc = new vtkConeSource(); coneSrc.SetRadius((double).5); coneSrc.SetHeight((double)2); coneMap = vtkPolyDataMapper.New(); coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort()); coneActor = new vtkActor(); coneActor.SetMapper((vtkMapper)coneMap); coneActor.SetPosition((double)0,(double)0,(double)11); coneActor.RotateY((double)90); coneActor.GetProperty().SetColor((double)1,(double)0,(double)0); camera = new vtkCamera(); camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919); camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807); camera.SetViewAngle((double)24.4617); camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879); camera.SetClippingRange((double)1,(double)100); ren1.AddActor((vtkProp)s1Actor); ren1.AddActor((vtkProp)s2Actor); ren1.AddActor((vtkProp)s3Actor); ren1.AddActor((vtkProp)s4Actor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)coneActor); ren1.AddActor((vtkProp)ga); ren1.SetBackground((double)1.0,(double)1.0,(double)1.0); ren1.SetActiveCamera((vtkCamera)camera); renWin.SetSize((int)300,(int)300); renWin.Render(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVHyperScalarBar(String [] argv) { //Prefix Content is: "" // Test the scalar bar actor using a logarithmic lookup table[] //[] VTK_INTEGRATE_BOTH_DIRECTIONS = 2; //[] // generate tensors[] ptLoad = new vtkPointLoad(); ptLoad.SetLoadValue((double)100.0); ptLoad.SetSampleDimensions((int)20,(int)20,(int)20); ptLoad.ComputeEffectiveStressOn(); ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10); // Generate hyperstreamlines[] s1 = new vtkHyperStreamline(); s1.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); s1.SetStartPosition((double)9,(double)9,(double)-9); s1.IntegrateMinorEigenvector(); s1.SetMaximumPropagationDistance((double)18.0); s1.SetIntegrationStepLength((double)0.1); s1.SetStepLength((double)0.01); s1.SetRadius((double)0.25); s1.SetNumberOfSides((int)18); s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s1.Update(); // Map hyperstreamlines[] lut = new vtkLogLookupTable(); lut.SetHueRange((double).6667,(double)0.0); scalarBar = new vtkScalarBarActor(); scalarBar.SetLookupTable((vtkScalarsToColors)lut); scalarBar.SetTitle((string)"Stress"); scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport(); scalarBar.GetPositionCoordinate().SetValue((double)0.1,(double)0.05); scalarBar.SetOrientationToVertical(); scalarBar.SetWidth((double)0.1); scalarBar.SetHeight((double)0.9); scalarBar.SetPosition((double)0.01,(double)0.1); scalarBar.SetLabelFormat((string)"%-#6.3f"); scalarBar.GetLabelTextProperty().SetColor((double)1,(double)0,(double)0); scalarBar.GetTitleTextProperty().SetColor((double)1,(double)0,(double)0); s1Mapper = vtkPolyDataMapper.New(); s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort()); s1Mapper.SetLookupTable((vtkScalarsToColors)lut); ptLoad.Update(); //force update for scalar range[] s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]); s1Actor = new vtkActor(); s1Actor.SetMapper((vtkMapper)s1Mapper); s2 = new vtkHyperStreamline(); s2.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); s2.SetStartPosition((double)-9,(double)-9,(double)-9); s2.IntegrateMinorEigenvector(); s2.SetMaximumPropagationDistance((double)18.0); s2.SetIntegrationStepLength((double)0.1); s2.SetStepLength((double)0.01); s2.SetRadius((double)0.25); s2.SetNumberOfSides((int)18); s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s2.Update(); s2Mapper = vtkPolyDataMapper.New(); s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort()); s2Mapper.SetLookupTable((vtkScalarsToColors)lut); s2Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]); s2Actor = new vtkActor(); s2Actor.SetMapper((vtkMapper)s2Mapper); s3 = new vtkHyperStreamline(); s3.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); s3.SetStartPosition((double)9,(double)-9,(double)-9); s3.IntegrateMinorEigenvector(); s3.SetMaximumPropagationDistance((double)18.0); s3.SetIntegrationStepLength((double)0.1); s3.SetStepLength((double)0.01); s3.SetRadius((double)0.25); s3.SetNumberOfSides((int)18); s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s3.Update(); s3Mapper = vtkPolyDataMapper.New(); s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort()); s3Mapper.SetLookupTable((vtkScalarsToColors)lut); s3Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]); s3Actor = new vtkActor(); s3Actor.SetMapper((vtkMapper)s3Mapper); s4 = new vtkHyperStreamline(); s4.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); s4.SetStartPosition((double)-9,(double)9,(double)-9); s4.IntegrateMinorEigenvector(); s4.SetMaximumPropagationDistance((double)18.0); s4.SetIntegrationStepLength((double)0.1); s4.SetStepLength((double)0.01); s4.SetRadius((double)0.25); s4.SetNumberOfSides((int)18); s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS); s4.Update(); s4Mapper = vtkPolyDataMapper.New(); s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort()); s4Mapper.SetLookupTable((vtkScalarsToColors)lut); s4Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]); s4Actor = new vtkActor(); s4Actor.SetMapper((vtkMapper)s4Mapper); // plane for context[] //[] g = new vtkImageDataGeometryFilter(); g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0); g.Update(); //for scalar range[] gm = vtkPolyDataMapper.New(); gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort()); gm.SetScalarRange((double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[0], (double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[1]); ga = new vtkActor(); ga.SetMapper((vtkMapper)gm); // Create outline around data[] //[] outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); // Create cone indicating application of load[] //[] coneSrc = new vtkConeSource(); coneSrc.SetRadius((double).5); coneSrc.SetHeight((double)2); coneMap = vtkPolyDataMapper.New(); coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort()); coneActor = new vtkActor(); coneActor.SetMapper((vtkMapper)coneMap); coneActor.SetPosition((double)0,(double)0,(double)11); coneActor.RotateY((double)90); coneActor.GetProperty().SetColor((double)1,(double)0,(double)0); // Create the rendering infrastructure[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); camera = new vtkCamera(); camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919); camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807); camera.SetViewAngle((double)24.4617); camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879); camera.SetClippingRange((double)1,(double)100); ren1.AddActor2D((vtkProp)scalarBar); ren1.AddActor((vtkProp)s1Actor); ren1.AddActor((vtkProp)s2Actor); ren1.AddActor((vtkProp)s3Actor); ren1.AddActor((vtkProp)s4Actor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)coneActor); ren1.AddActor((vtkProp)ga); ren1.SetBackground((double)1.0,(double)1.0,(double)1.0); ren1.SetActiveCamera((vtkCamera)camera); renWin.SetSize((int)300,(int)300); renWin.Render(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void 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 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 AVTestCellDerivs(String [] argv) { //Prefix Content is: "" // Demonstrates vtkCellDerivatives for all cell types[] //[] // get the interactor ui[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create a scene with one of each cell type[] // Voxel[] voxelPoints = new vtkPoints(); voxelPoints.SetNumberOfPoints((int)8); voxelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); voxelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); voxelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0); voxelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0); voxelPoints.InsertPoint((int)4,(double)0,(double)0,(double)1); voxelPoints.InsertPoint((int)5,(double)1,(double)0,(double)1); voxelPoints.InsertPoint((int)6,(double)0,(double)1,(double)1); voxelPoints.InsertPoint((int)7,(double)1,(double)1,(double)1); aVoxel = new vtkVoxel(); aVoxel.GetPointIds().SetId((int)0,(int)0); aVoxel.GetPointIds().SetId((int)1,(int)1); aVoxel.GetPointIds().SetId((int)2,(int)2); aVoxel.GetPointIds().SetId((int)3,(int)3); aVoxel.GetPointIds().SetId((int)4,(int)4); aVoxel.GetPointIds().SetId((int)5,(int)5); aVoxel.GetPointIds().SetId((int)6,(int)6); aVoxel.GetPointIds().SetId((int)7,(int)7); aVoxelGrid = new vtkUnstructuredGrid(); aVoxelGrid.Allocate((int)1,(int)1); aVoxelGrid.InsertNextCell((int)aVoxel.GetCellType(),(vtkIdList)aVoxel.GetPointIds()); aVoxelGrid.SetPoints((vtkPoints)voxelPoints); aVoxelMapper = new vtkDataSetMapper(); aVoxelMapper.SetInput((vtkDataSet)aVoxelGrid); aVoxelActor = new vtkActor(); aVoxelActor.SetMapper((vtkMapper)aVoxelMapper); aVoxelActor.GetProperty().BackfaceCullingOn(); // Hexahedron[] hexahedronPoints = new vtkPoints(); hexahedronPoints.SetNumberOfPoints((int)8); hexahedronPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); hexahedronPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); hexahedronPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); hexahedronPoints.InsertPoint((int)3,(double)0,(double)1,(double)0); hexahedronPoints.InsertPoint((int)4,(double)0,(double)0,(double)1); hexahedronPoints.InsertPoint((int)5,(double)1,(double)0,(double)1); hexahedronPoints.InsertPoint((int)6,(double)1,(double)1,(double)1); hexahedronPoints.InsertPoint((int)7,(double)0,(double)1,(double)1); aHexahedron = new vtkHexahedron(); aHexahedron.GetPointIds().SetId((int)0,(int)0); aHexahedron.GetPointIds().SetId((int)1,(int)1); aHexahedron.GetPointIds().SetId((int)2,(int)2); aHexahedron.GetPointIds().SetId((int)3,(int)3); aHexahedron.GetPointIds().SetId((int)4,(int)4); aHexahedron.GetPointIds().SetId((int)5,(int)5); aHexahedron.GetPointIds().SetId((int)6,(int)6); aHexahedron.GetPointIds().SetId((int)7,(int)7); aHexahedronGrid = new vtkUnstructuredGrid(); aHexahedronGrid.Allocate((int)1,(int)1); aHexahedronGrid.InsertNextCell((int)aHexahedron.GetCellType(),(vtkIdList)aHexahedron.GetPointIds()); aHexahedronGrid.SetPoints((vtkPoints)hexahedronPoints); aHexahedronMapper = new vtkDataSetMapper(); aHexahedronMapper.SetInput((vtkDataSet)aHexahedronGrid); aHexahedronActor = new vtkActor(); aHexahedronActor.SetMapper((vtkMapper)aHexahedronMapper); aHexahedronActor.AddPosition((double)2,(double)0,(double)0); aHexahedronActor.GetProperty().BackfaceCullingOn(); // Tetra[] tetraPoints = new vtkPoints(); tetraPoints.SetNumberOfPoints((int)4); tetraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); tetraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); tetraPoints.InsertPoint((int)2,(double)0,(double)1,(double)0); tetraPoints.InsertPoint((int)3,(double)1,(double)1,(double)1); aTetra = new vtkTetra(); aTetra.GetPointIds().SetId((int)0,(int)0); aTetra.GetPointIds().SetId((int)1,(int)1); aTetra.GetPointIds().SetId((int)2,(int)2); aTetra.GetPointIds().SetId((int)3,(int)3); aTetraGrid = new vtkUnstructuredGrid(); aTetraGrid.Allocate((int)1,(int)1); aTetraGrid.InsertNextCell((int)aTetra.GetCellType(),(vtkIdList)aTetra.GetPointIds()); aTetraGrid.SetPoints((vtkPoints)tetraPoints); aTetraMapper = new vtkDataSetMapper(); aTetraMapper.SetInput((vtkDataSet)aTetraGrid); aTetraActor = new vtkActor(); aTetraActor.SetMapper((vtkMapper)aTetraMapper); aTetraActor.AddPosition((double)4,(double)0,(double)0); aTetraActor.GetProperty().BackfaceCullingOn(); // Wedge[] wedgePoints = new vtkPoints(); wedgePoints.SetNumberOfPoints((int)6); wedgePoints.InsertPoint((int)0,(double)0,(double)1,(double)0); wedgePoints.InsertPoint((int)1,(double)0,(double)0,(double)0); wedgePoints.InsertPoint((int)2,(double)0,(double).5,(double).5); wedgePoints.InsertPoint((int)3,(double)1,(double)1,(double)0); wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)0); wedgePoints.InsertPoint((int)5,(double)1,(double).5,(double).5); aWedge = new vtkWedge(); aWedge.GetPointIds().SetId((int)0,(int)0); aWedge.GetPointIds().SetId((int)1,(int)1); aWedge.GetPointIds().SetId((int)2,(int)2); aWedge.GetPointIds().SetId((int)3,(int)3); aWedge.GetPointIds().SetId((int)4,(int)4); aWedge.GetPointIds().SetId((int)5,(int)5); aWedgeGrid = new vtkUnstructuredGrid(); aWedgeGrid.Allocate((int)1,(int)1); aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds()); aWedgeGrid.SetPoints((vtkPoints)wedgePoints); aWedgeMapper = new vtkDataSetMapper(); aWedgeMapper.SetInput((vtkDataSet)aWedgeGrid); aWedgeActor = new vtkActor(); aWedgeActor.SetMapper((vtkMapper)aWedgeMapper); aWedgeActor.AddPosition((double)6,(double)0,(double)0); aWedgeActor.GetProperty().BackfaceCullingOn(); // Pyramid[] pyramidPoints = new vtkPoints(); pyramidPoints.SetNumberOfPoints((int)5); pyramidPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); pyramidPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); pyramidPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); pyramidPoints.InsertPoint((int)3,(double)0,(double)1,(double)0); pyramidPoints.InsertPoint((int)4,(double).5,(double).5,(double)1); aPyramid = new vtkPyramid(); aPyramid.GetPointIds().SetId((int)0,(int)0); aPyramid.GetPointIds().SetId((int)1,(int)1); aPyramid.GetPointIds().SetId((int)2,(int)2); aPyramid.GetPointIds().SetId((int)3,(int)3); aPyramid.GetPointIds().SetId((int)4,(int)4); aPyramidGrid = new vtkUnstructuredGrid(); aPyramidGrid.Allocate((int)1,(int)1); aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds()); aPyramidGrid.SetPoints((vtkPoints)pyramidPoints); aPyramidMapper = new vtkDataSetMapper(); aPyramidMapper.SetInput((vtkDataSet)aPyramidGrid); aPyramidActor = new vtkActor(); aPyramidActor.SetMapper((vtkMapper)aPyramidMapper); aPyramidActor.AddPosition((double)8,(double)0,(double)0); aPyramidActor.GetProperty().BackfaceCullingOn(); // Pixel[] pixelPoints = new vtkPoints(); pixelPoints.SetNumberOfPoints((int)4); pixelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); pixelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); pixelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0); pixelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0); aPixel = new vtkPixel(); aPixel.GetPointIds().SetId((int)0,(int)0); aPixel.GetPointIds().SetId((int)1,(int)1); aPixel.GetPointIds().SetId((int)2,(int)2); aPixel.GetPointIds().SetId((int)3,(int)3); aPixelGrid = new vtkUnstructuredGrid(); aPixelGrid.Allocate((int)1,(int)1); aPixelGrid.InsertNextCell((int)aPixel.GetCellType(),(vtkIdList)aPixel.GetPointIds()); aPixelGrid.SetPoints((vtkPoints)pixelPoints); aPixelMapper = new vtkDataSetMapper(); aPixelMapper.SetInput((vtkDataSet)aPixelGrid); aPixelActor = new vtkActor(); aPixelActor.SetMapper((vtkMapper)aPixelMapper); aPixelActor.AddPosition((double)0,(double)0,(double)2); aPixelActor.GetProperty().BackfaceCullingOn(); // Quad[] quadPoints = new vtkPoints(); quadPoints.SetNumberOfPoints((int)4); quadPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); quadPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); quadPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); quadPoints.InsertPoint((int)3,(double)0,(double)1,(double)0); aQuad = new vtkQuad(); aQuad.GetPointIds().SetId((int)0,(int)0); aQuad.GetPointIds().SetId((int)1,(int)1); aQuad.GetPointIds().SetId((int)2,(int)2); aQuad.GetPointIds().SetId((int)3,(int)3); aQuadGrid = new vtkUnstructuredGrid(); aQuadGrid.Allocate((int)1,(int)1); aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds()); aQuadGrid.SetPoints((vtkPoints)quadPoints); aQuadMapper = new vtkDataSetMapper(); aQuadMapper.SetInput((vtkDataSet)aQuadGrid); aQuadActor = new vtkActor(); aQuadActor.SetMapper((vtkMapper)aQuadMapper); aQuadActor.AddPosition((double)2,(double)0,(double)2); aQuadActor.GetProperty().BackfaceCullingOn(); // Triangle[] trianglePoints = new vtkPoints(); trianglePoints.SetNumberOfPoints((int)3); trianglePoints.InsertPoint((int)0,(double)0,(double)0,(double)0); trianglePoints.InsertPoint((int)1,(double)1,(double)0,(double)0); trianglePoints.InsertPoint((int)2,(double).5,(double).5,(double)0); triangleTCoords = new vtkFloatArray(); triangleTCoords.SetNumberOfComponents((int)2); triangleTCoords.SetNumberOfTuples((int)3); triangleTCoords.InsertTuple2((int)0,(double)1,(double)1); triangleTCoords.InsertTuple2((int)1,(double)2,(double)2); triangleTCoords.InsertTuple2((int)2,(double)3,(double)3); aTriangle = new vtkTriangle(); aTriangle.GetPointIds().SetId((int)0,(int)0); aTriangle.GetPointIds().SetId((int)1,(int)1); aTriangle.GetPointIds().SetId((int)2,(int)2); aTriangleGrid = new vtkUnstructuredGrid(); aTriangleGrid.Allocate((int)1,(int)1); aTriangleGrid.InsertNextCell((int)aTriangle.GetCellType(),(vtkIdList)aTriangle.GetPointIds()); aTriangleGrid.SetPoints((vtkPoints)trianglePoints); aTriangleGrid.GetPointData().SetTCoords((vtkDataArray)triangleTCoords); aTriangleMapper = new vtkDataSetMapper(); aTriangleMapper.SetInput((vtkDataSet)aTriangleGrid); aTriangleActor = new vtkActor(); aTriangleActor.SetMapper((vtkMapper)aTriangleMapper); aTriangleActor.AddPosition((double)4,(double)0,(double)2); aTriangleActor.GetProperty().BackfaceCullingOn(); // Polygon[] polygonPoints = new vtkPoints(); polygonPoints.SetNumberOfPoints((int)4); polygonPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); polygonPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); polygonPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); polygonPoints.InsertPoint((int)3,(double)0,(double)1,(double)0); aPolygon = new vtkPolygon(); aPolygon.GetPointIds().SetNumberOfIds((int)4); aPolygon.GetPointIds().SetId((int)0,(int)0); aPolygon.GetPointIds().SetId((int)1,(int)1); aPolygon.GetPointIds().SetId((int)2,(int)2); aPolygon.GetPointIds().SetId((int)3,(int)3); aPolygonGrid = new vtkUnstructuredGrid(); aPolygonGrid.Allocate((int)1,(int)1); aPolygonGrid.InsertNextCell((int)aPolygon.GetCellType(),(vtkIdList)aPolygon.GetPointIds()); aPolygonGrid.SetPoints((vtkPoints)polygonPoints); aPolygonMapper = new vtkDataSetMapper(); aPolygonMapper.SetInput((vtkDataSet)aPolygonGrid); aPolygonActor = new vtkActor(); aPolygonActor.SetMapper((vtkMapper)aPolygonMapper); aPolygonActor.AddPosition((double)6,(double)0,(double)2); aPolygonActor.GetProperty().BackfaceCullingOn(); // Triangle strip[] triangleStripPoints = new vtkPoints(); triangleStripPoints.SetNumberOfPoints((int)5); triangleStripPoints.InsertPoint((int)0,(double)0,(double)1,(double)0); triangleStripPoints.InsertPoint((int)1,(double)0,(double)0,(double)0); triangleStripPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); triangleStripPoints.InsertPoint((int)3,(double)1,(double)0,(double)0); triangleStripPoints.InsertPoint((int)4,(double)2,(double)1,(double)0); triangleStripTCoords = new vtkFloatArray(); triangleStripTCoords.SetNumberOfComponents((int)2); triangleStripTCoords.SetNumberOfTuples((int)3); triangleStripTCoords.InsertTuple2((int)0,(double)1,(double)1); triangleStripTCoords.InsertTuple2((int)1,(double)2,(double)2); triangleStripTCoords.InsertTuple2((int)2,(double)3,(double)3); triangleStripTCoords.InsertTuple2((int)3,(double)4,(double)4); triangleStripTCoords.InsertTuple2((int)4,(double)5,(double)5); aTriangleStrip = new vtkTriangleStrip(); aTriangleStrip.GetPointIds().SetNumberOfIds((int)5); aTriangleStrip.GetPointIds().SetId((int)0,(int)0); aTriangleStrip.GetPointIds().SetId((int)1,(int)1); aTriangleStrip.GetPointIds().SetId((int)2,(int)2); aTriangleStrip.GetPointIds().SetId((int)3,(int)3); aTriangleStrip.GetPointIds().SetId((int)4,(int)4); aTriangleStripGrid = new vtkUnstructuredGrid(); aTriangleStripGrid.Allocate((int)1,(int)1); aTriangleStripGrid.InsertNextCell((int)aTriangleStrip.GetCellType(),(vtkIdList)aTriangleStrip.GetPointIds()); aTriangleStripGrid.SetPoints((vtkPoints)triangleStripPoints); aTriangleStripGrid.GetPointData().SetTCoords((vtkDataArray)triangleStripTCoords); aTriangleStripMapper = new vtkDataSetMapper(); aTriangleStripMapper.SetInput((vtkDataSet)aTriangleStripGrid); aTriangleStripActor = new vtkActor(); aTriangleStripActor.SetMapper((vtkMapper)aTriangleStripMapper); aTriangleStripActor.AddPosition((double)8,(double)0,(double)2); aTriangleStripActor.GetProperty().BackfaceCullingOn(); // Line[] linePoints = new vtkPoints(); linePoints.SetNumberOfPoints((int)2); linePoints.InsertPoint((int)0,(double)0,(double)0,(double)0); linePoints.InsertPoint((int)1,(double)1,(double)1,(double)0); aLine = new vtkLine(); aLine.GetPointIds().SetId((int)0,(int)0); aLine.GetPointIds().SetId((int)1,(int)1); aLineGrid = new vtkUnstructuredGrid(); aLineGrid.Allocate((int)1,(int)1); aLineGrid.InsertNextCell((int)aLine.GetCellType(),(vtkIdList)aLine.GetPointIds()); aLineGrid.SetPoints((vtkPoints)linePoints); aLineMapper = new vtkDataSetMapper(); aLineMapper.SetInput((vtkDataSet)aLineGrid); aLineActor = new vtkActor(); aLineActor.SetMapper((vtkMapper)aLineMapper); aLineActor.AddPosition((double)0,(double)0,(double)4); aLineActor.GetProperty().BackfaceCullingOn(); // Polyline[] polyLinePoints = new vtkPoints(); polyLinePoints.SetNumberOfPoints((int)3); polyLinePoints.InsertPoint((int)0,(double)0,(double)0,(double)0); polyLinePoints.InsertPoint((int)1,(double)1,(double)1,(double)0); polyLinePoints.InsertPoint((int)2,(double)1,(double)0,(double)0); aPolyLine = new vtkPolyLine(); aPolyLine.GetPointIds().SetNumberOfIds((int)3); aPolyLine.GetPointIds().SetId((int)0,(int)0); aPolyLine.GetPointIds().SetId((int)1,(int)1); aPolyLine.GetPointIds().SetId((int)2,(int)2); aPolyLineGrid = new vtkUnstructuredGrid(); aPolyLineGrid.Allocate((int)1,(int)1); aPolyLineGrid.InsertNextCell((int)aPolyLine.GetCellType(),(vtkIdList)aPolyLine.GetPointIds()); aPolyLineGrid.SetPoints((vtkPoints)polyLinePoints); aPolyLineMapper = new vtkDataSetMapper(); aPolyLineMapper.SetInput((vtkDataSet)aPolyLineGrid); aPolyLineActor = new vtkActor(); aPolyLineActor.SetMapper((vtkMapper)aPolyLineMapper); aPolyLineActor.AddPosition((double)2,(double)0,(double)4); aPolyLineActor.GetProperty().BackfaceCullingOn(); // Vertex[] vertexPoints = new vtkPoints(); vertexPoints.SetNumberOfPoints((int)1); vertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); aVertex = new vtkVertex(); aVertex.GetPointIds().SetId((int)0,(int)0); aVertexGrid = new vtkUnstructuredGrid(); aVertexGrid.Allocate((int)1,(int)1); aVertexGrid.InsertNextCell((int)aVertex.GetCellType(),(vtkIdList)aVertex.GetPointIds()); aVertexGrid.SetPoints((vtkPoints)vertexPoints); aVertexMapper = new vtkDataSetMapper(); aVertexMapper.SetInput((vtkDataSet)aVertexGrid); aVertexActor = new vtkActor(); aVertexActor.SetMapper((vtkMapper)aVertexMapper); aVertexActor.AddPosition((double)0,(double)0,(double)6); aVertexActor.GetProperty().BackfaceCullingOn(); // Polyvertex[] polyVertexPoints = new vtkPoints(); polyVertexPoints.SetNumberOfPoints((int)3); polyVertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); polyVertexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); polyVertexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); aPolyVertex = new vtkPolyVertex(); aPolyVertex.GetPointIds().SetNumberOfIds((int)3); aPolyVertex.GetPointIds().SetId((int)0,(int)0); aPolyVertex.GetPointIds().SetId((int)1,(int)1); aPolyVertex.GetPointIds().SetId((int)2,(int)2); aPolyVertexGrid = new vtkUnstructuredGrid(); aPolyVertexGrid.Allocate((int)1,(int)1); aPolyVertexGrid.InsertNextCell((int)aPolyVertex.GetCellType(),(vtkIdList)aPolyVertex.GetPointIds()); aPolyVertexGrid.SetPoints((vtkPoints)polyVertexPoints); aPolyVertexMapper = new vtkDataSetMapper(); aPolyVertexMapper.SetInput((vtkDataSet)aPolyVertexGrid); aPolyVertexActor = new vtkActor(); aPolyVertexActor.SetMapper((vtkMapper)aPolyVertexMapper); aPolyVertexActor.AddPosition((double)2,(double)0,(double)6); aPolyVertexActor.GetProperty().BackfaceCullingOn(); // Pentagonal prism[] pentaPoints = new vtkPoints(); pentaPoints.SetNumberOfPoints((int)10); pentaPoints.InsertPoint((int)0,(double)0.25,(double)0.0,(double)0.0); pentaPoints.InsertPoint((int)1,(double)0.75,(double)0.0,(double)0.0); pentaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0); pentaPoints.InsertPoint((int)3,(double)0.5,(double)1.0,(double)0.0); pentaPoints.InsertPoint((int)4,(double)0.0,(double)0.5,(double)0.0); pentaPoints.InsertPoint((int)5,(double)0.25,(double)0.0,(double)1.0); pentaPoints.InsertPoint((int)6,(double)0.75,(double)0.0,(double)1.0); pentaPoints.InsertPoint((int)7,(double)1.0,(double)0.5,(double)1.0); pentaPoints.InsertPoint((int)8,(double)0.5,(double)1.0,(double)1.0); pentaPoints.InsertPoint((int)9,(double)0.0,(double)0.5,(double)1.0); aPenta = new vtkPentagonalPrism(); aPenta.GetPointIds().SetId((int)0,(int)0); aPenta.GetPointIds().SetId((int)1,(int)1); aPenta.GetPointIds().SetId((int)2,(int)2); aPenta.GetPointIds().SetId((int)3,(int)3); aPenta.GetPointIds().SetId((int)4,(int)4); aPenta.GetPointIds().SetId((int)5,(int)5); aPenta.GetPointIds().SetId((int)6,(int)6); aPenta.GetPointIds().SetId((int)7,(int)7); aPenta.GetPointIds().SetId((int)8,(int)8); aPenta.GetPointIds().SetId((int)9,(int)9); aPentaGrid = new vtkUnstructuredGrid(); aPentaGrid.Allocate((int)1,(int)1); aPentaGrid.InsertNextCell((int)aPenta.GetCellType(),(vtkIdList)aPenta.GetPointIds()); aPentaGrid.SetPoints((vtkPoints)pentaPoints); aPentaMapper = new vtkDataSetMapper(); aPentaMapper.SetInput((vtkDataSet)aPentaGrid); aPentaActor = new vtkActor(); aPentaActor.SetMapper((vtkMapper)aPentaMapper); aPentaActor.AddPosition((double)10,(double)0,(double)0); aPentaActor.GetProperty().BackfaceCullingOn(); // Hexagonal prism[] hexaPoints = new vtkPoints(); hexaPoints.SetNumberOfPoints((int)12); hexaPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0); hexaPoints.InsertPoint((int)1,(double)0.5,(double)0.0,(double)0.0); hexaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0); hexaPoints.InsertPoint((int)3,(double)1.0,(double)1.0,(double)0.0); hexaPoints.InsertPoint((int)4,(double)0.5,(double)1.0,(double)0.0); hexaPoints.InsertPoint((int)5,(double)0.0,(double)0.5,(double)0.0); hexaPoints.InsertPoint((int)6,(double)0.0,(double)0.0,(double)1.0); hexaPoints.InsertPoint((int)7,(double)0.5,(double)0.0,(double)1.0); hexaPoints.InsertPoint((int)8,(double)1.0,(double)0.5,(double)1.0); hexaPoints.InsertPoint((int)9,(double)1.0,(double)1.0,(double)1.0); hexaPoints.InsertPoint((int)10,(double)0.5,(double)1.0,(double)1.0); hexaPoints.InsertPoint((int)11,(double)0.0,(double)0.5,(double)1.0); aHexa = new vtkHexagonalPrism(); aHexa.GetPointIds().SetId((int)0,(int)0); aHexa.GetPointIds().SetId((int)1,(int)1); aHexa.GetPointIds().SetId((int)2,(int)2); aHexa.GetPointIds().SetId((int)3,(int)3); aHexa.GetPointIds().SetId((int)4,(int)4); aHexa.GetPointIds().SetId((int)5,(int)5); aHexa.GetPointIds().SetId((int)6,(int)6); aHexa.GetPointIds().SetId((int)7,(int)7); aHexa.GetPointIds().SetId((int)8,(int)8); aHexa.GetPointIds().SetId((int)9,(int)9); aHexa.GetPointIds().SetId((int)10,(int)10); aHexa.GetPointIds().SetId((int)11,(int)11); aHexaGrid = new vtkUnstructuredGrid(); aHexaGrid.Allocate((int)1,(int)1); aHexaGrid.InsertNextCell((int)aHexa.GetCellType(),(vtkIdList)aHexa.GetPointIds()); aHexaGrid.SetPoints((vtkPoints)hexaPoints); aHexaMapper = new vtkDataSetMapper(); aHexaMapper.SetInput((vtkDataSet)aHexaGrid); aHexaActor = new vtkActor(); aHexaActor.SetMapper((vtkMapper)aHexaMapper); aHexaActor.AddPosition((double)12,(double)0,(double)0); aHexaActor.GetProperty().BackfaceCullingOn(); ren1.SetBackground((double)1,(double)1,(double)1); ren1.AddActor((vtkProp)aVoxelActor); aVoxelActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)0); ren1.AddActor((vtkProp)aHexahedronActor); aHexahedronActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0); ren1.AddActor((vtkProp)aTetraActor); aTetraActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)0); ren1.AddActor((vtkProp)aWedgeActor); aWedgeActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1); ren1.AddActor((vtkProp)aPyramidActor); aPyramidActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1); ren1.AddActor((vtkProp)aPixelActor); aPixelActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1); ren1.AddActor((vtkProp)aQuadActor); aQuadActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1); ren1.AddActor((vtkProp)aTriangleActor); aTriangleActor.GetProperty().SetDiffuseColor((double).3,(double)1,(double).5); ren1.AddActor((vtkProp)aPolygonActor); aPolygonActor.GetProperty().SetDiffuseColor((double)1,(double).4,(double).5); ren1.AddActor((vtkProp)aTriangleStripActor); aTriangleStripActor.GetProperty().SetDiffuseColor((double).3,(double).7,(double)1); ren1.AddActor((vtkProp)aLineActor); aLineActor.GetProperty().SetDiffuseColor((double).2,(double)1,(double)1); ren1.AddActor((vtkProp)aPolyLineActor); aPolyLineActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1); ren1.AddActor((vtkProp)aVertexActor); aVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1); ren1.AddActor((vtkProp)aPolyVertexActor); aPolyVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1); ren1.AddActor((vtkProp)aPentaActor); aPentaActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0); ren1.AddActor((vtkProp)aHexaActor); aHexaActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0); //[] // get the cell center of each type and put a glyph there[] //[] ball = new vtkSphereSource(); ball.SetRadius((double).2); bool tryWorked = false; aVoxelScalars = new vtkFloatArray(); N = aVoxelGrid.GetNumberOfPoints(); aVoxelScalar = new vtkFloatArray(); aVoxelScalar.SetNumberOfTuples((int)N); aVoxelScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aVoxelScalar.SetValue(i,0); i = i + 1; } aVoxelScalar.SetValue(0,4); aVoxelGrid.GetPointData().SetScalars(aVoxelScalar); aHexahedronScalars = new vtkFloatArray(); N = aHexahedronGrid.GetNumberOfPoints(); aHexahedronScalar = new vtkFloatArray(); aHexahedronScalar.SetNumberOfTuples((int)N); aHexahedronScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aHexahedronScalar.SetValue(i,0); i = i + 1; } aHexahedronScalar.SetValue(0,4); aHexahedronGrid.GetPointData().SetScalars(aHexahedronScalar); aWedgeScalars = new vtkFloatArray(); N = aWedgeGrid.GetNumberOfPoints(); aWedgeScalar = new vtkFloatArray(); aWedgeScalar.SetNumberOfTuples((int)N); aWedgeScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aWedgeScalar.SetValue(i,0); i = i + 1; } aWedgeScalar.SetValue(0,4); aWedgeGrid.GetPointData().SetScalars(aWedgeScalar); aPyramidScalars = new vtkFloatArray(); N = aPyramidGrid.GetNumberOfPoints(); aPyramidScalar = new vtkFloatArray(); aPyramidScalar.SetNumberOfTuples((int)N); aPyramidScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aPyramidScalar.SetValue(i,0); i = i + 1; } aPyramidScalar.SetValue(0,4); aPyramidGrid.GetPointData().SetScalars(aPyramidScalar); aTetraScalars = new vtkFloatArray(); N = aTetraGrid.GetNumberOfPoints(); aTetraScalar = new vtkFloatArray(); aTetraScalar.SetNumberOfTuples((int)N); aTetraScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aTetraScalar.SetValue(i,0); i = i + 1; } aTetraScalar.SetValue(0,4); aTetraGrid.GetPointData().SetScalars(aTetraScalar); aQuadScalars = new vtkFloatArray(); N = aQuadGrid.GetNumberOfPoints(); aQuadScalar = new vtkFloatArray(); aQuadScalar.SetNumberOfTuples((int)N); aQuadScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aQuadScalar.SetValue(i,0); i = i + 1; } aQuadScalar.SetValue(0,4); aQuadGrid.GetPointData().SetScalars(aQuadScalar); aTriangleScalars = new vtkFloatArray(); N = aTriangleGrid.GetNumberOfPoints(); aTriangleScalar = new vtkFloatArray(); aTriangleScalar.SetNumberOfTuples((int)N); aTriangleScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aTriangleScalar.SetValue(i,0); i = i + 1; } aTriangleScalar.SetValue(0,4); aTriangleGrid.GetPointData().SetScalars(aTriangleScalar); aTriangleStripScalars = new vtkFloatArray(); N = aTriangleStripGrid.GetNumberOfPoints(); aTriangleStripScalar = new vtkFloatArray(); aTriangleStripScalar.SetNumberOfTuples((int)N); aTriangleStripScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aTriangleStripScalar.SetValue(i,0); i = i + 1; } aTriangleStripScalar.SetValue(0,4); aTriangleStripGrid.GetPointData().SetScalars(aTriangleStripScalar); aLineScalars = new vtkFloatArray(); N = aLineGrid.GetNumberOfPoints(); aLineScalar = new vtkFloatArray(); aLineScalar.SetNumberOfTuples((int)N); aLineScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aLineScalar.SetValue(i,0); i = i + 1; } aLineScalar.SetValue(0,4); aLineGrid.GetPointData().SetScalars(aLineScalar); aPolyLineScalars = new vtkFloatArray(); N = aPolyLineGrid.GetNumberOfPoints(); aPolyLineScalar = new vtkFloatArray(); aPolyLineScalar.SetNumberOfTuples((int)N); aPolyLineScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aPolyLineScalar.SetValue(i,0); i = i + 1; } aPolyLineScalar.SetValue(0,4); aPolyLineGrid.GetPointData().SetScalars(aPolyLineScalar); aVertexScalars = new vtkFloatArray(); N = aVertexGrid.GetNumberOfPoints(); aVertexScalar = new vtkFloatArray(); aVertexScalar.SetNumberOfTuples((int)N); aVertexScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aVertexScalar.SetValue(i,0); i = i + 1; } aVertexScalar.SetValue(0,4); aVertexGrid.GetPointData().SetScalars(aVertexScalar); aPolyVertexScalars = new vtkFloatArray(); N = aPolyVertexGrid.GetNumberOfPoints(); aPolyVertexScalar = new vtkFloatArray(); aPolyVertexScalar.SetNumberOfTuples((int)N); aPolyVertexScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aPolyVertexScalar.SetValue(i,0); i = i + 1; } aPolyVertexScalar.SetValue(0,4); aPolyVertexGrid.GetPointData().SetScalars(aPolyVertexScalar); aPixelScalars = new vtkFloatArray(); N = aPixelGrid.GetNumberOfPoints(); aPixelScalar = new vtkFloatArray(); aPixelScalar.SetNumberOfTuples((int)N); aPixelScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aPixelScalar.SetValue(i,0); i = i + 1; } aPixelScalar.SetValue(0,4); aPixelGrid.GetPointData().SetScalars(aPixelScalar); aPolygonScalars = new vtkFloatArray(); N = aPolygonGrid.GetNumberOfPoints(); aPolygonScalar = new vtkFloatArray(); aPolygonScalar.SetNumberOfTuples((int)N); aPolygonScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aPolygonScalar.SetValue(i,0); i = i + 1; } aPolygonScalar.SetValue(0,4); aPolygonGrid.GetPointData().SetScalars(aPolygonScalar); aPentaScalars = new vtkFloatArray(); N = aPentaGrid.GetNumberOfPoints(); aPentaScalar = new vtkFloatArray(); aPentaScalar.SetNumberOfTuples((int)N); aPentaScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aPentaScalar.SetValue(i,0); i = i + 1; } aPentaScalar.SetValue(0,4); aPentaGrid.GetPointData().SetScalars(aPentaScalar); aHexaScalars = new vtkFloatArray(); N = aHexaGrid.GetNumberOfPoints(); aHexaScalar = new vtkFloatArray(); aHexaScalar.SetNumberOfTuples((int)N); aHexaScalar.SetNumberOfComponents(1); i = 0; while((i) < N) { aHexaScalar.SetValue(i,0); i = i + 1; } aHexaScalar.SetValue(0,4); aHexaGrid.GetPointData().SetScalars(aHexaScalar); // write to the temp directory if possible, otherwise use .[] dir = "."; dir = TclToCsScriptTestDriver.GetTempDirectory(); aVoxelderivs = new vtkCellDerivatives(); aVoxelderivs.SetInput(aVoxelGrid); aVoxelderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aVoxel"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aVoxelWriter = new vtkUnstructuredGridWriter(); aVoxelWriter.SetInputConnection(aVoxelderivs.GetOutputPort()); aVoxelWriter.SetFileName(FileName); aVoxelWriter.Write(); // delete the file[] File.Delete("FileName"); } aVoxelCenters = new vtkCellCenters(); aVoxelCenters.SetInputConnection(aVoxelderivs.GetOutputPort()); aVoxelCenters.VertexCellsOn(); aVoxelhog = new vtkHedgeHog(); aVoxelhog.SetInputConnection(aVoxelCenters.GetOutputPort()); aVoxelmapHog = vtkPolyDataMapper.New(); aVoxelmapHog.SetInputConnection(aVoxelhog.GetOutputPort()); aVoxelmapHog.SetScalarModeToUseCellData(); aVoxelmapHog.ScalarVisibilityOff(); aVoxelhogActor = new vtkActor(); aVoxelhogActor.SetMapper(aVoxelmapHog); aVoxelhogActor.GetProperty().SetColor(0,1,0); aVoxelGlyph3D = new vtkGlyph3D(); aVoxelGlyph3D.SetInputConnection(aVoxelCenters.GetOutputPort()); aVoxelGlyph3D.SetSource(ball.GetOutput()); aVoxelCentersMapper = vtkPolyDataMapper.New(); aVoxelCentersMapper.SetInputConnection(aVoxelGlyph3D.GetOutputPort()); aVoxelCentersActor = new vtkActor(); aVoxelCentersActor.SetMapper(aVoxelCentersMapper); aVoxelhogActor.SetPosition(aVoxelActor.GetPosition()[0],aVoxelActor.GetPosition()[1],aVoxelActor.GetPosition()[2]); ren1.AddActor((vtkProp)aVoxelhogActor); aVoxelhogActor.GetProperty().SetRepresentationToWireframe(); aHexahedronderivs = new vtkCellDerivatives(); aHexahedronderivs.SetInput(aHexahedronGrid); aHexahedronderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aHexahedron"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aHexahedronWriter = new vtkUnstructuredGridWriter(); aHexahedronWriter.SetInputConnection(aHexahedronderivs.GetOutputPort()); aHexahedronWriter.SetFileName(FileName); aHexahedronWriter.Write(); // delete the file[] File.Delete("FileName"); } aHexahedronCenters = new vtkCellCenters(); aHexahedronCenters.SetInputConnection(aHexahedronderivs.GetOutputPort()); aHexahedronCenters.VertexCellsOn(); aHexahedronhog = new vtkHedgeHog(); aHexahedronhog.SetInputConnection(aHexahedronCenters.GetOutputPort()); aHexahedronmapHog = vtkPolyDataMapper.New(); aHexahedronmapHog.SetInputConnection(aHexahedronhog.GetOutputPort()); aHexahedronmapHog.SetScalarModeToUseCellData(); aHexahedronmapHog.ScalarVisibilityOff(); aHexahedronhogActor = new vtkActor(); aHexahedronhogActor.SetMapper(aHexahedronmapHog); aHexahedronhogActor.GetProperty().SetColor(0,1,0); aHexahedronGlyph3D = new vtkGlyph3D(); aHexahedronGlyph3D.SetInputConnection(aHexahedronCenters.GetOutputPort()); aHexahedronGlyph3D.SetSource(ball.GetOutput()); aHexahedronCentersMapper = vtkPolyDataMapper.New(); aHexahedronCentersMapper.SetInputConnection(aHexahedronGlyph3D.GetOutputPort()); aHexahedronCentersActor = new vtkActor(); aHexahedronCentersActor.SetMapper(aHexahedronCentersMapper); aHexahedronhogActor.SetPosition(aHexahedronActor.GetPosition()[0],aHexahedronActor.GetPosition()[1],aHexahedronActor.GetPosition()[2]); ren1.AddActor((vtkProp)aHexahedronhogActor); aHexahedronhogActor.GetProperty().SetRepresentationToWireframe(); aWedgederivs = new vtkCellDerivatives(); aWedgederivs.SetInput(aWedgeGrid); aWedgederivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aWedge"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aWedgeWriter = new vtkUnstructuredGridWriter(); aWedgeWriter.SetInputConnection(aWedgederivs.GetOutputPort()); aWedgeWriter.SetFileName(FileName); aWedgeWriter.Write(); // delete the file[] File.Delete("FileName"); } aWedgeCenters = new vtkCellCenters(); aWedgeCenters.SetInputConnection(aWedgederivs.GetOutputPort()); aWedgeCenters.VertexCellsOn(); aWedgehog = new vtkHedgeHog(); aWedgehog.SetInputConnection(aWedgeCenters.GetOutputPort()); aWedgemapHog = vtkPolyDataMapper.New(); aWedgemapHog.SetInputConnection(aWedgehog.GetOutputPort()); aWedgemapHog.SetScalarModeToUseCellData(); aWedgemapHog.ScalarVisibilityOff(); aWedgehogActor = new vtkActor(); aWedgehogActor.SetMapper(aWedgemapHog); aWedgehogActor.GetProperty().SetColor(0,1,0); aWedgeGlyph3D = new vtkGlyph3D(); aWedgeGlyph3D.SetInputConnection(aWedgeCenters.GetOutputPort()); aWedgeGlyph3D.SetSource(ball.GetOutput()); aWedgeCentersMapper = vtkPolyDataMapper.New(); aWedgeCentersMapper.SetInputConnection(aWedgeGlyph3D.GetOutputPort()); aWedgeCentersActor = new vtkActor(); aWedgeCentersActor.SetMapper(aWedgeCentersMapper); aWedgehogActor.SetPosition(aWedgeActor.GetPosition()[0],aWedgeActor.GetPosition()[1],aWedgeActor.GetPosition()[2]); ren1.AddActor((vtkProp)aWedgehogActor); aWedgehogActor.GetProperty().SetRepresentationToWireframe(); aPyramidderivs = new vtkCellDerivatives(); aPyramidderivs.SetInput(aPyramidGrid); aPyramidderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aPyramid"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aPyramidWriter = new vtkUnstructuredGridWriter(); aPyramidWriter.SetInputConnection(aPyramidderivs.GetOutputPort()); aPyramidWriter.SetFileName(FileName); aPyramidWriter.Write(); // delete the file[] File.Delete("FileName"); } aPyramidCenters = new vtkCellCenters(); aPyramidCenters.SetInputConnection(aPyramidderivs.GetOutputPort()); aPyramidCenters.VertexCellsOn(); aPyramidhog = new vtkHedgeHog(); aPyramidhog.SetInputConnection(aPyramidCenters.GetOutputPort()); aPyramidmapHog = vtkPolyDataMapper.New(); aPyramidmapHog.SetInputConnection(aPyramidhog.GetOutputPort()); aPyramidmapHog.SetScalarModeToUseCellData(); aPyramidmapHog.ScalarVisibilityOff(); aPyramidhogActor = new vtkActor(); aPyramidhogActor.SetMapper(aPyramidmapHog); aPyramidhogActor.GetProperty().SetColor(0,1,0); aPyramidGlyph3D = new vtkGlyph3D(); aPyramidGlyph3D.SetInputConnection(aPyramidCenters.GetOutputPort()); aPyramidGlyph3D.SetSource(ball.GetOutput()); aPyramidCentersMapper = vtkPolyDataMapper.New(); aPyramidCentersMapper.SetInputConnection(aPyramidGlyph3D.GetOutputPort()); aPyramidCentersActor = new vtkActor(); aPyramidCentersActor.SetMapper(aPyramidCentersMapper); aPyramidhogActor.SetPosition(aPyramidActor.GetPosition()[0],aPyramidActor.GetPosition()[1],aPyramidActor.GetPosition()[2]); ren1.AddActor((vtkProp)aPyramidhogActor); aPyramidhogActor.GetProperty().SetRepresentationToWireframe(); aTetraderivs = new vtkCellDerivatives(); aTetraderivs.SetInput(aTetraGrid); aTetraderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aTetra"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aTetraWriter = new vtkUnstructuredGridWriter(); aTetraWriter.SetInputConnection(aTetraderivs.GetOutputPort()); aTetraWriter.SetFileName(FileName); aTetraWriter.Write(); // delete the file[] File.Delete("FileName"); } aTetraCenters = new vtkCellCenters(); aTetraCenters.SetInputConnection(aTetraderivs.GetOutputPort()); aTetraCenters.VertexCellsOn(); aTetrahog = new vtkHedgeHog(); aTetrahog.SetInputConnection(aTetraCenters.GetOutputPort()); aTetramapHog = vtkPolyDataMapper.New(); aTetramapHog.SetInputConnection(aTetrahog.GetOutputPort()); aTetramapHog.SetScalarModeToUseCellData(); aTetramapHog.ScalarVisibilityOff(); aTetrahogActor = new vtkActor(); aTetrahogActor.SetMapper(aTetramapHog); aTetrahogActor.GetProperty().SetColor(0,1,0); aTetraGlyph3D = new vtkGlyph3D(); aTetraGlyph3D.SetInputConnection(aTetraCenters.GetOutputPort()); aTetraGlyph3D.SetSource(ball.GetOutput()); aTetraCentersMapper = vtkPolyDataMapper.New(); aTetraCentersMapper.SetInputConnection(aTetraGlyph3D.GetOutputPort()); aTetraCentersActor = new vtkActor(); aTetraCentersActor.SetMapper(aTetraCentersMapper); aTetrahogActor.SetPosition(aTetraActor.GetPosition()[0],aTetraActor.GetPosition()[1],aTetraActor.GetPosition()[2]); ren1.AddActor((vtkProp)aTetrahogActor); aTetrahogActor.GetProperty().SetRepresentationToWireframe(); aQuadderivs = new vtkCellDerivatives(); aQuadderivs.SetInput(aQuadGrid); aQuadderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aQuad"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aQuadWriter = new vtkUnstructuredGridWriter(); aQuadWriter.SetInputConnection(aQuadderivs.GetOutputPort()); aQuadWriter.SetFileName(FileName); aQuadWriter.Write(); // delete the file[] File.Delete("FileName"); } aQuadCenters = new vtkCellCenters(); aQuadCenters.SetInputConnection(aQuadderivs.GetOutputPort()); aQuadCenters.VertexCellsOn(); aQuadhog = new vtkHedgeHog(); aQuadhog.SetInputConnection(aQuadCenters.GetOutputPort()); aQuadmapHog = vtkPolyDataMapper.New(); aQuadmapHog.SetInputConnection(aQuadhog.GetOutputPort()); aQuadmapHog.SetScalarModeToUseCellData(); aQuadmapHog.ScalarVisibilityOff(); aQuadhogActor = new vtkActor(); aQuadhogActor.SetMapper(aQuadmapHog); aQuadhogActor.GetProperty().SetColor(0,1,0); aQuadGlyph3D = new vtkGlyph3D(); aQuadGlyph3D.SetInputConnection(aQuadCenters.GetOutputPort()); aQuadGlyph3D.SetSource(ball.GetOutput()); aQuadCentersMapper = vtkPolyDataMapper.New(); aQuadCentersMapper.SetInputConnection(aQuadGlyph3D.GetOutputPort()); aQuadCentersActor = new vtkActor(); aQuadCentersActor.SetMapper(aQuadCentersMapper); aQuadhogActor.SetPosition(aQuadActor.GetPosition()[0],aQuadActor.GetPosition()[1],aQuadActor.GetPosition()[2]); ren1.AddActor((vtkProp)aQuadhogActor); aQuadhogActor.GetProperty().SetRepresentationToWireframe(); aTrianglederivs = new vtkCellDerivatives(); aTrianglederivs.SetInput(aTriangleGrid); aTrianglederivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aTriangle"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aTriangleWriter = new vtkUnstructuredGridWriter(); aTriangleWriter.SetInputConnection(aTrianglederivs.GetOutputPort()); aTriangleWriter.SetFileName(FileName); aTriangleWriter.Write(); // delete the file[] File.Delete("FileName"); } aTriangleCenters = new vtkCellCenters(); aTriangleCenters.SetInputConnection(aTrianglederivs.GetOutputPort()); aTriangleCenters.VertexCellsOn(); aTrianglehog = new vtkHedgeHog(); aTrianglehog.SetInputConnection(aTriangleCenters.GetOutputPort()); aTrianglemapHog = vtkPolyDataMapper.New(); aTrianglemapHog.SetInputConnection(aTrianglehog.GetOutputPort()); aTrianglemapHog.SetScalarModeToUseCellData(); aTrianglemapHog.ScalarVisibilityOff(); aTrianglehogActor = new vtkActor(); aTrianglehogActor.SetMapper(aTrianglemapHog); aTrianglehogActor.GetProperty().SetColor(0,1,0); aTriangleGlyph3D = new vtkGlyph3D(); aTriangleGlyph3D.SetInputConnection(aTriangleCenters.GetOutputPort()); aTriangleGlyph3D.SetSource(ball.GetOutput()); aTriangleCentersMapper = vtkPolyDataMapper.New(); aTriangleCentersMapper.SetInputConnection(aTriangleGlyph3D.GetOutputPort()); aTriangleCentersActor = new vtkActor(); aTriangleCentersActor.SetMapper(aTriangleCentersMapper); aTrianglehogActor.SetPosition(aTriangleActor.GetPosition()[0],aTriangleActor.GetPosition()[1],aTriangleActor.GetPosition()[2]); ren1.AddActor((vtkProp)aTrianglehogActor); aTrianglehogActor.GetProperty().SetRepresentationToWireframe(); aTriangleStripderivs = new vtkCellDerivatives(); aTriangleStripderivs.SetInput(aTriangleStripGrid); aTriangleStripderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aTriangleStrip"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aTriangleStripWriter = new vtkUnstructuredGridWriter(); aTriangleStripWriter.SetInputConnection(aTriangleStripderivs.GetOutputPort()); aTriangleStripWriter.SetFileName(FileName); aTriangleStripWriter.Write(); // delete the file[] File.Delete("FileName"); } aTriangleStripCenters = new vtkCellCenters(); aTriangleStripCenters.SetInputConnection(aTriangleStripderivs.GetOutputPort()); aTriangleStripCenters.VertexCellsOn(); aTriangleStriphog = new vtkHedgeHog(); aTriangleStriphog.SetInputConnection(aTriangleStripCenters.GetOutputPort()); aTriangleStripmapHog = vtkPolyDataMapper.New(); aTriangleStripmapHog.SetInputConnection(aTriangleStriphog.GetOutputPort()); aTriangleStripmapHog.SetScalarModeToUseCellData(); aTriangleStripmapHog.ScalarVisibilityOff(); aTriangleStriphogActor = new vtkActor(); aTriangleStriphogActor.SetMapper(aTriangleStripmapHog); aTriangleStriphogActor.GetProperty().SetColor(0,1,0); aTriangleStripGlyph3D = new vtkGlyph3D(); aTriangleStripGlyph3D.SetInputConnection(aTriangleStripCenters.GetOutputPort()); aTriangleStripGlyph3D.SetSource(ball.GetOutput()); aTriangleStripCentersMapper = vtkPolyDataMapper.New(); aTriangleStripCentersMapper.SetInputConnection(aTriangleStripGlyph3D.GetOutputPort()); aTriangleStripCentersActor = new vtkActor(); aTriangleStripCentersActor.SetMapper(aTriangleStripCentersMapper); aTriangleStriphogActor.SetPosition(aTriangleStripActor.GetPosition()[0],aTriangleStripActor.GetPosition()[1],aTriangleStripActor.GetPosition()[2]); ren1.AddActor((vtkProp)aTriangleStriphogActor); aTriangleStriphogActor.GetProperty().SetRepresentationToWireframe(); aLinederivs = new vtkCellDerivatives(); aLinederivs.SetInput(aLineGrid); aLinederivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aLine"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aLineWriter = new vtkUnstructuredGridWriter(); aLineWriter.SetInputConnection(aLinederivs.GetOutputPort()); aLineWriter.SetFileName(FileName); aLineWriter.Write(); // delete the file[] File.Delete("FileName"); } aLineCenters = new vtkCellCenters(); aLineCenters.SetInputConnection(aLinederivs.GetOutputPort()); aLineCenters.VertexCellsOn(); aLinehog = new vtkHedgeHog(); aLinehog.SetInputConnection(aLineCenters.GetOutputPort()); aLinemapHog = vtkPolyDataMapper.New(); aLinemapHog.SetInputConnection(aLinehog.GetOutputPort()); aLinemapHog.SetScalarModeToUseCellData(); aLinemapHog.ScalarVisibilityOff(); aLinehogActor = new vtkActor(); aLinehogActor.SetMapper(aLinemapHog); aLinehogActor.GetProperty().SetColor(0,1,0); aLineGlyph3D = new vtkGlyph3D(); aLineGlyph3D.SetInputConnection(aLineCenters.GetOutputPort()); aLineGlyph3D.SetSource(ball.GetOutput()); aLineCentersMapper = vtkPolyDataMapper.New(); aLineCentersMapper.SetInputConnection(aLineGlyph3D.GetOutputPort()); aLineCentersActor = new vtkActor(); aLineCentersActor.SetMapper(aLineCentersMapper); aLinehogActor.SetPosition(aLineActor.GetPosition()[0],aLineActor.GetPosition()[1],aLineActor.GetPosition()[2]); ren1.AddActor((vtkProp)aLinehogActor); aLinehogActor.GetProperty().SetRepresentationToWireframe(); aPolyLinederivs = new vtkCellDerivatives(); aPolyLinederivs.SetInput(aPolyLineGrid); aPolyLinederivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aPolyLine"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aPolyLineWriter = new vtkUnstructuredGridWriter(); aPolyLineWriter.SetInputConnection(aPolyLinederivs.GetOutputPort()); aPolyLineWriter.SetFileName(FileName); aPolyLineWriter.Write(); // delete the file[] File.Delete("FileName"); } aPolyLineCenters = new vtkCellCenters(); aPolyLineCenters.SetInputConnection(aPolyLinederivs.GetOutputPort()); aPolyLineCenters.VertexCellsOn(); aPolyLinehog = new vtkHedgeHog(); aPolyLinehog.SetInputConnection(aPolyLineCenters.GetOutputPort()); aPolyLinemapHog = vtkPolyDataMapper.New(); aPolyLinemapHog.SetInputConnection(aPolyLinehog.GetOutputPort()); aPolyLinemapHog.SetScalarModeToUseCellData(); aPolyLinemapHog.ScalarVisibilityOff(); aPolyLinehogActor = new vtkActor(); aPolyLinehogActor.SetMapper(aPolyLinemapHog); aPolyLinehogActor.GetProperty().SetColor(0,1,0); aPolyLineGlyph3D = new vtkGlyph3D(); aPolyLineGlyph3D.SetInputConnection(aPolyLineCenters.GetOutputPort()); aPolyLineGlyph3D.SetSource(ball.GetOutput()); aPolyLineCentersMapper = vtkPolyDataMapper.New(); aPolyLineCentersMapper.SetInputConnection(aPolyLineGlyph3D.GetOutputPort()); aPolyLineCentersActor = new vtkActor(); aPolyLineCentersActor.SetMapper(aPolyLineCentersMapper); aPolyLinehogActor.SetPosition(aPolyLineActor.GetPosition()[0],aPolyLineActor.GetPosition()[1],aPolyLineActor.GetPosition()[2]); ren1.AddActor((vtkProp)aPolyLinehogActor); aPolyLinehogActor.GetProperty().SetRepresentationToWireframe(); aVertexderivs = new vtkCellDerivatives(); aVertexderivs.SetInput(aVertexGrid); aVertexderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aVertex"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aVertexWriter = new vtkUnstructuredGridWriter(); aVertexWriter.SetInputConnection(aVertexderivs.GetOutputPort()); aVertexWriter.SetFileName(FileName); aVertexWriter.Write(); // delete the file[] File.Delete("FileName"); } aVertexCenters = new vtkCellCenters(); aVertexCenters.SetInputConnection(aVertexderivs.GetOutputPort()); aVertexCenters.VertexCellsOn(); aVertexhog = new vtkHedgeHog(); aVertexhog.SetInputConnection(aVertexCenters.GetOutputPort()); aVertexmapHog = vtkPolyDataMapper.New(); aVertexmapHog.SetInputConnection(aVertexhog.GetOutputPort()); aVertexmapHog.SetScalarModeToUseCellData(); aVertexmapHog.ScalarVisibilityOff(); aVertexhogActor = new vtkActor(); aVertexhogActor.SetMapper(aVertexmapHog); aVertexhogActor.GetProperty().SetColor(0,1,0); aVertexGlyph3D = new vtkGlyph3D(); aVertexGlyph3D.SetInputConnection(aVertexCenters.GetOutputPort()); aVertexGlyph3D.SetSource(ball.GetOutput()); aVertexCentersMapper = vtkPolyDataMapper.New(); aVertexCentersMapper.SetInputConnection(aVertexGlyph3D.GetOutputPort()); aVertexCentersActor = new vtkActor(); aVertexCentersActor.SetMapper(aVertexCentersMapper); aVertexhogActor.SetPosition(aVertexActor.GetPosition()[0],aVertexActor.GetPosition()[1],aVertexActor.GetPosition()[2]); ren1.AddActor((vtkProp)aVertexhogActor); aVertexhogActor.GetProperty().SetRepresentationToWireframe(); aPolyVertexderivs = new vtkCellDerivatives(); aPolyVertexderivs.SetInput(aPolyVertexGrid); aPolyVertexderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aPolyVertex"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aPolyVertexWriter = new vtkUnstructuredGridWriter(); aPolyVertexWriter.SetInputConnection(aPolyVertexderivs.GetOutputPort()); aPolyVertexWriter.SetFileName(FileName); aPolyVertexWriter.Write(); // delete the file[] File.Delete("FileName"); } aPolyVertexCenters = new vtkCellCenters(); aPolyVertexCenters.SetInputConnection(aPolyVertexderivs.GetOutputPort()); aPolyVertexCenters.VertexCellsOn(); aPolyVertexhog = new vtkHedgeHog(); aPolyVertexhog.SetInputConnection(aPolyVertexCenters.GetOutputPort()); aPolyVertexmapHog = vtkPolyDataMapper.New(); aPolyVertexmapHog.SetInputConnection(aPolyVertexhog.GetOutputPort()); aPolyVertexmapHog.SetScalarModeToUseCellData(); aPolyVertexmapHog.ScalarVisibilityOff(); aPolyVertexhogActor = new vtkActor(); aPolyVertexhogActor.SetMapper(aPolyVertexmapHog); aPolyVertexhogActor.GetProperty().SetColor(0,1,0); aPolyVertexGlyph3D = new vtkGlyph3D(); aPolyVertexGlyph3D.SetInputConnection(aPolyVertexCenters.GetOutputPort()); aPolyVertexGlyph3D.SetSource(ball.GetOutput()); aPolyVertexCentersMapper = vtkPolyDataMapper.New(); aPolyVertexCentersMapper.SetInputConnection(aPolyVertexGlyph3D.GetOutputPort()); aPolyVertexCentersActor = new vtkActor(); aPolyVertexCentersActor.SetMapper(aPolyVertexCentersMapper); aPolyVertexhogActor.SetPosition(aPolyVertexActor.GetPosition()[0],aPolyVertexActor.GetPosition()[1],aPolyVertexActor.GetPosition()[2]); ren1.AddActor((vtkProp)aPolyVertexhogActor); aPolyVertexhogActor.GetProperty().SetRepresentationToWireframe(); aPixelderivs = new vtkCellDerivatives(); aPixelderivs.SetInput(aPixelGrid); aPixelderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aPixel"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aPixelWriter = new vtkUnstructuredGridWriter(); aPixelWriter.SetInputConnection(aPixelderivs.GetOutputPort()); aPixelWriter.SetFileName(FileName); aPixelWriter.Write(); // delete the file[] File.Delete("FileName"); } aPixelCenters = new vtkCellCenters(); aPixelCenters.SetInputConnection(aPixelderivs.GetOutputPort()); aPixelCenters.VertexCellsOn(); aPixelhog = new vtkHedgeHog(); aPixelhog.SetInputConnection(aPixelCenters.GetOutputPort()); aPixelmapHog = vtkPolyDataMapper.New(); aPixelmapHog.SetInputConnection(aPixelhog.GetOutputPort()); aPixelmapHog.SetScalarModeToUseCellData(); aPixelmapHog.ScalarVisibilityOff(); aPixelhogActor = new vtkActor(); aPixelhogActor.SetMapper(aPixelmapHog); aPixelhogActor.GetProperty().SetColor(0,1,0); aPixelGlyph3D = new vtkGlyph3D(); aPixelGlyph3D.SetInputConnection(aPixelCenters.GetOutputPort()); aPixelGlyph3D.SetSource(ball.GetOutput()); aPixelCentersMapper = vtkPolyDataMapper.New(); aPixelCentersMapper.SetInputConnection(aPixelGlyph3D.GetOutputPort()); aPixelCentersActor = new vtkActor(); aPixelCentersActor.SetMapper(aPixelCentersMapper); aPixelhogActor.SetPosition(aPixelActor.GetPosition()[0],aPixelActor.GetPosition()[1],aPixelActor.GetPosition()[2]); ren1.AddActor((vtkProp)aPixelhogActor); aPixelhogActor.GetProperty().SetRepresentationToWireframe(); aPolygonderivs = new vtkCellDerivatives(); aPolygonderivs.SetInput(aPolygonGrid); aPolygonderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aPolygon"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aPolygonWriter = new vtkUnstructuredGridWriter(); aPolygonWriter.SetInputConnection(aPolygonderivs.GetOutputPort()); aPolygonWriter.SetFileName(FileName); aPolygonWriter.Write(); // delete the file[] File.Delete("FileName"); } aPolygonCenters = new vtkCellCenters(); aPolygonCenters.SetInputConnection(aPolygonderivs.GetOutputPort()); aPolygonCenters.VertexCellsOn(); aPolygonhog = new vtkHedgeHog(); aPolygonhog.SetInputConnection(aPolygonCenters.GetOutputPort()); aPolygonmapHog = vtkPolyDataMapper.New(); aPolygonmapHog.SetInputConnection(aPolygonhog.GetOutputPort()); aPolygonmapHog.SetScalarModeToUseCellData(); aPolygonmapHog.ScalarVisibilityOff(); aPolygonhogActor = new vtkActor(); aPolygonhogActor.SetMapper(aPolygonmapHog); aPolygonhogActor.GetProperty().SetColor(0,1,0); aPolygonGlyph3D = new vtkGlyph3D(); aPolygonGlyph3D.SetInputConnection(aPolygonCenters.GetOutputPort()); aPolygonGlyph3D.SetSource(ball.GetOutput()); aPolygonCentersMapper = vtkPolyDataMapper.New(); aPolygonCentersMapper.SetInputConnection(aPolygonGlyph3D.GetOutputPort()); aPolygonCentersActor = new vtkActor(); aPolygonCentersActor.SetMapper(aPolygonCentersMapper); aPolygonhogActor.SetPosition(aPolygonActor.GetPosition()[0],aPolygonActor.GetPosition()[1],aPolygonActor.GetPosition()[2]); ren1.AddActor((vtkProp)aPolygonhogActor); aPolygonhogActor.GetProperty().SetRepresentationToWireframe(); aPentaderivs = new vtkCellDerivatives(); aPentaderivs.SetInput(aPentaGrid); aPentaderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aPenta"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aPentaWriter = new vtkUnstructuredGridWriter(); aPentaWriter.SetInputConnection(aPentaderivs.GetOutputPort()); aPentaWriter.SetFileName(FileName); aPentaWriter.Write(); // delete the file[] File.Delete("FileName"); } aPentaCenters = new vtkCellCenters(); aPentaCenters.SetInputConnection(aPentaderivs.GetOutputPort()); aPentaCenters.VertexCellsOn(); aPentahog = new vtkHedgeHog(); aPentahog.SetInputConnection(aPentaCenters.GetOutputPort()); aPentamapHog = vtkPolyDataMapper.New(); aPentamapHog.SetInputConnection(aPentahog.GetOutputPort()); aPentamapHog.SetScalarModeToUseCellData(); aPentamapHog.ScalarVisibilityOff(); aPentahogActor = new vtkActor(); aPentahogActor.SetMapper(aPentamapHog); aPentahogActor.GetProperty().SetColor(0,1,0); aPentaGlyph3D = new vtkGlyph3D(); aPentaGlyph3D.SetInputConnection(aPentaCenters.GetOutputPort()); aPentaGlyph3D.SetSource(ball.GetOutput()); aPentaCentersMapper = vtkPolyDataMapper.New(); aPentaCentersMapper.SetInputConnection(aPentaGlyph3D.GetOutputPort()); aPentaCentersActor = new vtkActor(); aPentaCentersActor.SetMapper(aPentaCentersMapper); aPentahogActor.SetPosition(aPentaActor.GetPosition()[0],aPentaActor.GetPosition()[1],aPentaActor.GetPosition()[2]); ren1.AddActor((vtkProp)aPentahogActor); aPentahogActor.GetProperty().SetRepresentationToWireframe(); aHexaderivs = new vtkCellDerivatives(); aHexaderivs.SetInput(aHexaGrid); aHexaderivs.SetVectorModeToComputeGradient(); FileName = dir; FileName += "/aHexa"; FileName += ".vtk"; // make sure the directory is writeable first[] tryWorked = false; try { channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp"); tryWorked = true; } catch(Exception) { tryWorked = false; } if(tryWorked) { channel.Close(); File.Delete("" + (dir.ToString()) + "/test.tmp"); aHexaWriter = new vtkUnstructuredGridWriter(); aHexaWriter.SetInputConnection(aHexaderivs.GetOutputPort()); aHexaWriter.SetFileName(FileName); aHexaWriter.Write(); // delete the file[] File.Delete("FileName"); } aHexaCenters = new vtkCellCenters(); aHexaCenters.SetInputConnection(aHexaderivs.GetOutputPort()); aHexaCenters.VertexCellsOn(); aHexahog = new vtkHedgeHog(); aHexahog.SetInputConnection(aHexaCenters.GetOutputPort()); aHexamapHog = vtkPolyDataMapper.New(); aHexamapHog.SetInputConnection(aHexahog.GetOutputPort()); aHexamapHog.SetScalarModeToUseCellData(); aHexamapHog.ScalarVisibilityOff(); aHexahogActor = new vtkActor(); aHexahogActor.SetMapper(aHexamapHog); aHexahogActor.GetProperty().SetColor(0,1,0); aHexaGlyph3D = new vtkGlyph3D(); aHexaGlyph3D.SetInputConnection(aHexaCenters.GetOutputPort()); aHexaGlyph3D.SetSource(ball.GetOutput()); aHexaCentersMapper = vtkPolyDataMapper.New(); aHexaCentersMapper.SetInputConnection(aHexaGlyph3D.GetOutputPort()); aHexaCentersActor = new vtkActor(); aHexaCentersActor.SetMapper(aHexaCentersMapper); aHexahogActor.SetPosition(aHexaActor.GetPosition()[0],aHexaActor.GetPosition()[1],aHexaActor.GetPosition()[2]); ren1.AddActor((vtkProp)aHexahogActor); aHexahogActor.GetProperty().SetRepresentationToWireframe(); ren1.ResetCamera(); ren1.GetActiveCamera().Azimuth((double)30); ren1.GetActiveCamera().Elevation((double)20); ren1.GetActiveCamera().Dolly((double)3.0); ren1.ResetCameraClippingRange(); renWin.SetSize((int)300,(int)150); renWin.Render(); // render the image[] //[] iren.Initialize(); //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(); }
public void DisplayHull(vtkRenderer Currentrenderer) { if (hullActor == null) { vtkPolyDataMapper mapHull = vtkPolyDataMapper.New(); mapHull.SetInput(hullFilter.GetOutput()); hullActor = vtkActor.New(); hullActor.SetMapper(mapHull); hullActor.SetPosition(GetPosition().X, GetPosition().Y, GetPosition().Z); // hullActor.GetProperty().SetRepresentationToWireframe(); hullActor.GetProperty().SetOpacity(0.3); Currentrenderer.AddActor(hullActor); } else { if (hullActor.GetVisibility() == 0) hullActor.SetVisibility(1); else hullActor.SetVisibility(0); } }
//public void AddPointingArrow(double scale, Color Colour) //{ // vtkArrowSource ArrowSource = vtkArrowSource.New(); // ArrowActor = vtkActor.New(); // vtkPolyDataMapper ArrowMapper = vtkPolyDataMapper.New(); // ArrowMapper.SetInputConnection(ArrowSource.GetOutputPort()); // ArrowActor.SetMapper(ArrowMapper); // ArrowActor.SetPosition(Position.X - 6, Position.Y - 0, Position.Z - 6); // ArrowActor.RotateY(-45); // ArrowActor.SetScale(scale); // ArrowActor.SetPickable(0); // Color C = Color.MediumPurple; // ArrowActor.GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.G / 255.0); // // CreateVTK3DObject(); // // CurrentWorld.ren1.AddActor(ArrowActor); //} //public void AddPointingArrow(double scale) //{ // AddPointingArrow(scale, Color.White); //} public void DisplayCentroid(c3DWorld CurrentWorld, double scale) { if (SphereActor == null) { vtkSphereSource SphereSource = vtkSphereSource.New(); vtkPolyDataMapper SphereMapper = vtkPolyDataMapper.New(); SphereActor = vtkActor.New(); SphereMapper = vtkPolyDataMapper.New(); SphereMapper.SetInputConnection(SphereSource.GetOutputPort()); SphereActor.SetMapper(SphereMapper); double[] CenterPos = vtk_Actor.GetCenter(); SphereActor.SetPosition(CenterPos[0], CenterPos[1], CenterPos[2]); SphereActor.SetScale(scale); SphereActor.SetPickable(0); Color C = Color.YellowGreen; SphereActor.GetProperty().SetColor(C.R / 255.0, C.G / 255.0, C.B / 255.0); CurrentWorld.ren1.AddActor(SphereActor); } else { if (SphereActor.GetVisibility() == 0) SphereActor.SetVisibility(1); else SphereActor.SetVisibility(0); } }
/// <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 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(); }
private void DrawAssembly() { //Create four parts: a top level assembly and three primitives vtkSphereSource sphereSource = vtkSphereSource.New(); vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New(); sphereMapper.SetInputConnection(sphereSource.GetOutputPort()); vtkActor sphereActor = vtkActor.New(); sphereActor.SetMapper(sphereMapper); sphereActor.SetOrigin(2, 1, 3); sphereActor.RotateY(6); sphereActor.SetPosition(2.25, 0, 0); sphereActor.GetProperty().SetColor(1, 0, 1); vtkCubeSource cubeSource = vtkCubeSource.New(); vtkPolyDataMapper cubeMapper = vtkPolyDataMapper.New(); cubeMapper.SetInputConnection(cubeSource.GetOutputPort()); vtkActor cubeActor = vtkActor.New(); cubeActor.SetMapper(cubeMapper); cubeActor.SetPosition(0, 2.25, 0); cubeActor.GetProperty().SetColor(0, 0, 1); vtkConeSource coneSource = vtkConeSource.New(); vtkPolyDataMapper coneMapper = vtkPolyDataMapper.New(); coneMapper.SetInputConnection(coneSource.GetOutputPort()); vtkActor coneActor = vtkActor.New(); coneActor.SetMapper(coneMapper); coneActor.SetPosition(0, 0, 2.25); coneActor.GetProperty().SetColor(0, 1, 0); vtkCylinderSource cylinderSource = vtkCylinderSource.New(); vtkPolyDataMapper cylinderMapper = vtkPolyDataMapper.New(); cylinderMapper.SetInputConnection(cylinderSource.GetOutputPort()); vtkActor cylinderActor = vtkActor.New(); cylinderActor.SetMapper(cylinderMapper); //cylinderActor.SetPosition(0, 0, 0); cylinderActor.GetProperty().SetColor(1, 0, 0); vtkAssembly assembly = vtkAssembly.New(); assembly.AddPart(cylinderActor); assembly.AddPart(sphereActor); assembly.AddPart(cubeActor); assembly.AddPart(coneActor); assembly.SetOrigin(5, 10, 5); assembly.AddPosition(5, 0, 0); assembly.RotateX(15); vtkRenderer renderer = vtkRenderer.New(); vtkRenderWindow renWin = myRenderWindowControl.RenderWindow; renWin.AddRenderer(renderer); renderer.AddActor(assembly); renderer.AddActor(coneActor); }
public Simulation(vtkRenderWindow renderWindow) { RenderWindow = renderWindow; Renderer = renderWindow.GetRenderers().GetFirstRenderer(); //Background Renderer.GradientBackgroundOn(); Renderer.SetBackground((double)colorBackground.R / 255, (double)colorBackground.G / 255, (double)colorBackground.B / 255); Renderer.SetBackground2((double)colorBackground2.R / 255, (double)colorBackground2.G / 255, (double)colorBackground2.B / 255); //Base baseAxes.SetTotalLength(200, 200, 200); baseAxes.AxisLabelsOff(); Renderer.AddActor(baseAxes); //Floor vtkPlaneSource planeSource = vtkPlaneSource.New(); planeSource.SetOrigin(-1000.0, -1000.0, 0); planeSource.SetPoint1(-1000.0, 1000.0, 0); planeSource.SetPoint2(1000.0, -1000.0, 0); planeSource.Update(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); vtkPolyData plane = planeSource.GetOutput(); mapper.SetInput(plane); floor = vtkActor.New(); floor.SetMapper(mapper); floor.GetProperty().SetColor(0.8, 0.8, 0.8); Renderer.AddActor(floor); //Robot1 robot1Pos = new Position(-500, 0, 0, 0, 0, 0); //Robots.Robot1.Base = new Position(-500, 0, 0, 0, 0, 0); robot1part1 = LoadSTL(robot1part1, @"\Robot\agilus_00.stl", Color.FromArgb(25, 25, 25)); robot1part2 = LoadSTL(robot1part2, @"\Robot\agilus_01.stl", Color.FromArgb(255, 110, 0)); robot1part3 = LoadSTL(robot1part3, @"\Robot\agilus_02.stl", Color.FromArgb(255, 110, 0)); robot1part4 = LoadSTL(robot1part4, @"\Robot\agilus_03.stl", Color.FromArgb(255, 110, 0)); robot1part5 = LoadSTL(robot1part5, @"\Robot\agilus_04.stl", Color.FromArgb(255, 110, 0)); robot1part6 = LoadSTL(robot1part6, @"\Robot\agilus_05.stl", Color.FromArgb(255, 110, 0)); robot1part7 = LoadSTL(robot1part6, @"\Robot\agilus_06.stl", Color.DarkGray); robot1part1.SetPosition(robot1Pos.X, robot1Pos.Y, robot1Pos.Z); Renderer.AddActor(robot1part1); Renderer.AddActor(robot1part2); Renderer.AddActor(robot1part3); Renderer.AddActor(robot1part4); Renderer.AddActor(robot1part5); Renderer.AddActor(robot1part6); Renderer.AddActor(robot1part7); robot1axes1.SetTotalLength(200, 200, 200); robot1axes1.AxisLabelsOff(); Renderer.AddActor(robot1axes1); robot1axes2.SetTotalLength(200, 200, 200); robot1axes2.AxisLabelsOff(); Renderer.AddActor(robot1axes2); robot1axes3.SetTotalLength(200, 200, 200); robot1axes3.AxisLabelsOff(); Renderer.AddActor(robot1axes3); robot1axes4.SetTotalLength(200, 200, 200); robot1axes4.AxisLabelsOff(); Renderer.AddActor(robot1axes4); robot1axes5.SetTotalLength(200, 200, 200); robot1axes5.AxisLabelsOff(); Renderer.AddActor(robot1axes5); robot1axes6.SetTotalLength(200, 200, 200); robot1axes6.AxisLabelsOff(); Renderer.AddActor(robot1axes6); //Robot2 robot2Pos = new Position(1000, 0, 0, 0, 0, 0); Robots.Robot2.Base = robot2Pos; robot2part1 = LoadSTL(robot2part1, @"\Robot\agilus_00.stl", Color.FromArgb(25, 25, 25)); robot2part2 = LoadSTL(robot2part2, @"\Robot\agilus_01.stl", Color.FromArgb(255, 110, 0)); robot2part3 = LoadSTL(robot2part3, @"\Robot\agilus_02.stl", Color.FromArgb(255, 110, 0)); robot2part4 = LoadSTL(robot2part4, @"\Robot\agilus_03.stl", Color.FromArgb(255, 110, 0)); robot2part5 = LoadSTL(robot2part5, @"\Robot\agilus_04.stl", Color.FromArgb(255, 110, 0)); robot2part6 = LoadSTL(robot2part6, @"\Robot\agilus_05.stl", Color.FromArgb(255, 110, 0)); robot2part7 = LoadSTL(robot2part6, @"\Robot\agilus_06.stl", Color.DarkGray); robot2part1.SetPosition(Robots.Robot2.Base.X, Robots.Robot2.Base.Y, Robots.Robot2.Base.Z); Renderer.AddActor(robot2part1); Renderer.AddActor(robot2part2); Renderer.AddActor(robot2part3); Renderer.AddActor(robot2part4); Renderer.AddActor(robot2part5); Renderer.AddActor(robot2part6); Renderer.AddActor(robot2part7); robot2axes1.SetTotalLength(200, 200, 200); robot2axes1.AxisLabelsOff(); Renderer.AddActor(robot2axes1); robot2axes2.SetTotalLength(200, 200, 200); robot2axes2.AxisLabelsOff(); Renderer.AddActor(robot2axes2); robot2axes3.SetTotalLength(200, 200, 200); robot2axes3.AxisLabelsOff(); Renderer.AddActor(robot2axes3); robot2axes4.SetTotalLength(200, 200, 200); robot2axes4.AxisLabelsOff(); Renderer.AddActor(robot2axes4); robot2axes5.SetTotalLength(200, 200, 200); robot2axes5.AxisLabelsOff(); Renderer.AddActor(robot2axes5); robot2axes6.SetTotalLength(200, 200, 200); robot2axes6.AxisLabelsOff(); Renderer.AddActor(robot2axes6); Renderer.AddActor(drawPointCloud()); Renderer.Render(); worker.DoWork += worker_DoWork; worker.RunWorkerAsync(); }
/// <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 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 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 AVTestPDataSetReaderGrid(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); //[] // 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"); // ====== Structured Grid ======[] // First save out a grid in parallel form.[] reader = new vtkMultiBlockPLOT3DReader(); reader.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); reader.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); writer = new vtkPDataSetWriter(); writer.SetFileName((string)"comb.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader = new vtkPDataSetReader(); pReader.SetFileName((string)"comb.pvtk"); surface = new vtkDataSetSurfaceFilter(); surface.SetInputConnection((vtkAlgorithmOutput)pReader.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)surface.GetOutputPort()); mapper.SetNumberOfPieces((int)2); mapper.SetPiece((int)0); mapper.SetGhostLevel((int)1); mapper.Update(); File.Delete("comb.pvtk"); File.Delete("comb.0.vtk"); File.Delete("comb.1.vtk"); File.Delete("comb.2.vtk"); File.Delete("comb.3.vtk"); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); actor.SetPosition((double)-5, (double)0, (double)-29); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor); // ====== ImageData ======[] // First save out a grid in parallel form.[] fractal = new vtkImageMandelbrotSource(); fractal.SetWholeExtent((int)0, (int)9, (int)0, (int)9, (int)0, (int)9); fractal.SetSampleCX((double)0.1, (double)0.1, (double)0.1, (double)0.1); fractal.SetMaximumNumberOfIterations((ushort)10); writer2 = new vtkPDataSetWriter(); writer.SetFileName((string)"fractal.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)fractal.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader2 = new vtkPDataSetReader(); pReader2.SetFileName((string)"fractal.pvtk"); iso = new vtkContourFilter(); iso.SetInputConnection((vtkAlgorithmOutput)pReader2.GetOutputPort()); iso.SetValue((int)0, (double)4); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); mapper2.SetNumberOfPieces((int)3); mapper2.SetPiece((int)0); mapper2.SetGhostLevel((int)0); mapper2.Update(); File.Delete("fractal.pvtk"); File.Delete("fractal.0.vtk"); File.Delete("fractal.1.vtk"); File.Delete("fractal.2.vtk"); File.Delete("fractal.3.vtk"); actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetScale((double)5, (double)5, (double)5); actor2.SetPosition((double)6, (double)6, (double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor2); // ====== PolyData ======[] // First save out a grid in parallel form.[] sphere = new vtkSphereSource(); sphere.SetRadius((double)2); writer3 = new vtkPDataSetWriter(); writer3.SetFileName((string)"sphere.pvtk"); writer3.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); writer3.SetNumberOfPieces((int)4); writer3.Write(); pReader3 = new vtkPDataSetReader(); pReader3.SetFileName((string)"sphere.pvtk"); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)pReader3.GetOutputPort()); mapper3.SetNumberOfPieces((int)2); mapper3.SetPiece((int)0); mapper3.SetGhostLevel((int)1); mapper3.Update(); File.Delete("sphere.pvtk"); File.Delete("sphere.0.vtk"); File.Delete("sphere.1.vtk"); File.Delete("sphere.2.vtk"); File.Delete("sphere.3.vtk"); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)6, (double)6, (double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor3); } ren1.SetBackground((double)0.1, (double)0.2, (double)0.4); renWin.SetSize((int)300, (int)300); // render the image[] //[] cam1 = ren1.GetActiveCamera(); cam1.Azimuth((double)20); cam1.Elevation((double)40); ren1.ResetCamera(); cam1.Zoom((double)1.2); 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 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 AVTestPDataSetReaderGrid(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); //[] // 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"); // ====== Structured Grid ======[] // First save out a grid in parallel form.[] reader = new vtkMultiBlockPLOT3DReader(); reader.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); reader.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); writer = new vtkPDataSetWriter(); writer.SetFileName((string)"comb.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader = new vtkPDataSetReader(); pReader.SetFileName((string)"comb.pvtk"); surface = new vtkDataSetSurfaceFilter(); surface.SetInputConnection((vtkAlgorithmOutput)pReader.GetOutputPort()); mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection((vtkAlgorithmOutput)surface.GetOutputPort()); mapper.SetNumberOfPieces((int)2); mapper.SetPiece((int)0); mapper.SetGhostLevel((int)1); mapper.Update(); File.Delete("comb.pvtk"); File.Delete("comb.0.vtk"); File.Delete("comb.1.vtk"); File.Delete("comb.2.vtk"); File.Delete("comb.3.vtk"); actor = new vtkActor(); actor.SetMapper((vtkMapper)mapper); actor.SetPosition((double)-5,(double)0,(double)-29); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor); // ====== ImageData ======[] // First save out a grid in parallel form.[] fractal = new vtkImageMandelbrotSource(); fractal.SetWholeExtent((int)0,(int)9,(int)0,(int)9,(int)0,(int)9); fractal.SetSampleCX((double)0.1,(double)0.1,(double)0.1,(double)0.1); fractal.SetMaximumNumberOfIterations((ushort)10); writer2 = new vtkPDataSetWriter(); writer.SetFileName((string)"fractal.pvtk"); writer.SetInputConnection((vtkAlgorithmOutput)fractal.GetOutputPort()); writer.SetNumberOfPieces((int)4); writer.Write(); pReader2 = new vtkPDataSetReader(); pReader2.SetFileName((string)"fractal.pvtk"); iso = new vtkContourFilter(); iso.SetInputConnection((vtkAlgorithmOutput)pReader2.GetOutputPort()); iso.SetValue((int)0,(double)4); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); mapper2.SetNumberOfPieces((int)3); mapper2.SetPiece((int)0); mapper2.SetGhostLevel((int)0); mapper2.Update(); File.Delete("fractal.pvtk"); File.Delete("fractal.0.vtk"); File.Delete("fractal.1.vtk"); File.Delete("fractal.2.vtk"); File.Delete("fractal.3.vtk"); actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetScale((double)5,(double)5,(double)5); actor2.SetPosition((double)6,(double)6,(double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor2); // ====== PolyData ======[] // First save out a grid in parallel form.[] sphere = new vtkSphereSource(); sphere.SetRadius((double)2); writer3 = new vtkPDataSetWriter(); writer3.SetFileName((string)"sphere.pvtk"); writer3.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); writer3.SetNumberOfPieces((int)4); writer3.Write(); pReader3 = new vtkPDataSetReader(); pReader3.SetFileName((string)"sphere.pvtk"); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)pReader3.GetOutputPort()); mapper3.SetNumberOfPieces((int)2); mapper3.SetPiece((int)0); mapper3.SetGhostLevel((int)1); mapper3.Update(); File.Delete("sphere.pvtk"); File.Delete("sphere.0.vtk"); File.Delete("sphere.1.vtk"); File.Delete("sphere.2.vtk"); File.Delete("sphere.3.vtk"); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)6,(double)6,(double)6); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)actor3); } ren1.SetBackground((double)0.1,(double)0.2,(double)0.4); renWin.SetSize((int)300,(int)300); // render the image[] //[] cam1 = ren1.GetActiveCamera(); cam1.Azimuth((double)20); cam1.Elevation((double)40); ren1.ResetCamera(); cam1.Zoom((double)1.2); 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 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 AVExtractTensors(String [] argv) { //Prefix Content is: "" // create tensor ellipsoids[] // Create the RenderWindow, Renderer and interactive renderer[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); ptLoad = new vtkPointLoad(); ptLoad.SetLoadValue((double)100.0); ptLoad.SetSampleDimensions((int)30, (int)30, (int)30); ptLoad.ComputeEffectiveStressOn(); ptLoad.SetModelBounds((double)-10, (double)10, (double)-10, (double)10, (double)-10, (double)10); extractTensor = new vtkExtractTensorComponents(); extractTensor.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); extractTensor.ScalarIsEffectiveStress(); extractTensor.ScalarIsComponent(); extractTensor.ExtractScalarsOn(); extractTensor.ExtractVectorsOn(); extractTensor.ExtractNormalsOff(); extractTensor.ExtractTCoordsOn(); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)extractTensor.GetOutputPort()); contour.SetValue((int)0, (double)0); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); probe.SetSourceConnection(ptLoad.GetOutputPort()); su = new vtkLoopSubdivisionFilter(); su.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); su.SetNumberOfSubdivisions((int)1); s1Mapper = vtkPolyDataMapper.New(); s1Mapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); // s1Mapper SetInputConnection [su GetOutputPort][] s1Actor = new vtkActor(); s1Actor.SetMapper((vtkMapper)s1Mapper); //[] // plane for context[] //[] g = new vtkImageDataGeometryFilter(); g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); g.SetExtent((int)0, (int)100, (int)0, (int)100, (int)0, (int)0); g.Update(); //for scalar range[] gm = vtkPolyDataMapper.New(); gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort()); gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); ga = new vtkActor(); ga.SetMapper((vtkMapper)gm); s1Mapper.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]); //[] // Create outline around data[] //[] outline = new vtkOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0); //[] // Create cone indicating application of load[] //[] coneSrc = new vtkConeSource(); coneSrc.SetRadius((double).5); coneSrc.SetHeight((double)2); coneMap = vtkPolyDataMapper.New(); coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort()); coneActor = new vtkActor(); coneActor.SetMapper((vtkMapper)coneMap); coneActor.SetPosition((double)0, (double)0, (double)11); coneActor.RotateY((double)90); coneActor.GetProperty().SetColor((double)1, (double)0, (double)0); camera = new vtkCamera(); camera.SetFocalPoint((double)0.113766, (double)-1.13665, (double)-1.01919); camera.SetPosition((double)-29.4886, (double)-63.1488, (double)26.5807); camera.SetViewAngle((double)24.4617); camera.SetViewUp((double)0.17138, (double)0.331163, (double)0.927879); camera.SetClippingRange((double)1, (double)100); ren1.AddActor((vtkProp)s1Actor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)coneActor); ren1.AddActor((vtkProp)ga); ren1.SetBackground((double)1.0, (double)1.0, (double)1.0); ren1.SetActiveCamera((vtkCamera)camera); renWin.SetSize((int)300, (int)300); renWin.Render(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void 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(); }
public void AddPointingArrow(c3DWorld CurrentWorld, double scale, Color Colour) { vtkArrowSource ArrowSource = vtkArrowSource.New(); ArrowActor = vtkActor.New(); vtkPolyDataMapper ArrowMapper = vtkPolyDataMapper.New(); ArrowMapper.SetInputConnection(ArrowSource.GetOutputPort()); ArrowActor.SetMapper(ArrowMapper); ArrowActor.SetPosition(Position.X - 6, Position.Y - 0, Position.Z - 6); ArrowActor.RotateY(-45); ArrowActor.SetScale(scale); ArrowActor.SetPickable(0); Color C = Color.MediumPurple; ArrowActor.GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.G / 255.0); // CreateVTK3DObject(); CurrentWorld.ren1.AddActor(ArrowActor); }