private void DrawTexturePlane() { //load in the texture map vtkBMPReader bmpReader = vtkBMPReader.New(); bmpReader.SetFileName(@"..\..\Data\masonry.bmp"); vtkTexture atext = vtkTexture.New(); atext.SetInputConnection(bmpReader.GetOutputPort()); atext.InterpolateOn(); //create a plane source and actor vtkPlaneSource plane = vtkPlaneSource.New(); plane.SetPoint1(0, 0, 0); vtkPolyDataMapper planeMapper = vtkPolyDataMapper.New(); planeMapper.SetInputConnection(plane.GetOutputPort()); vtkActor planeActor = vtkActor.New(); planeActor.SetMapper(planeMapper); planeActor.SetTexture(atext); vtkRenderer renderer = vtkRenderer.New(); vtkRenderWindow renWin = myRenderWindowControl.RenderWindow; renWin.AddRenderer(renderer); renderer.AddActor(planeActor); }
private void Plane() { // Create a plane vtkPlaneSource planeSource = vtkPlaneSource.New(); planeSource.SetCenter(1.0, 0.0, 0.0); planeSource.SetNormal(1.0, 0.0, 1.0); planeSource.Update(); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(planeSource.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetLineWidth(4); RenderAddActor(actor); }
public void ReadImageIntoObject(RenderWindowControl renderWindowControl, nvmImageModel camera) { vtkRenderWindow renderWindow = renderWindowControl.RenderWindow; vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); string filePath = Path.Combine(tempDirectory, $"{camera.fileName}"); vtkJPEGReader reader = vtkJPEGReader.New(); reader.SetFileName(filePath); reader.Update(); // Treba poriesit ako nasmerovat obrazky bez pokazenia textury var vectoris = Vector3.Transform(new Vector3(0, 0, 1), camera.quaternion); vtkPlaneSource planeSource = vtkPlaneSource.New(); vtkTexture texture = new vtkTexture(); texture.SetInputConnection(reader.GetOutputPort()); vtkTransform transform = new vtkTransform(); transform.RotateX(180); texture.SetTransform(transform); vtkTextureMapToPlane plane = new vtkTextureMapToPlane(); plane.SetInputConnection(planeSource.GetOutputPort()); planeSource.SetCenter(camera.cameraCenter.X, camera.cameraCenter.Y, camera.cameraCenter.Z); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(plane.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.SetTexture(texture); renderer.SetBackground(0.2, 0.3, 0.4); renderer.AddActor(actor); }
private void Plane() { // Create a plane vtkPlaneSource planeSource = vtkPlaneSource.New(); planeSource.SetCenter(1.0, 0.0, 0.0); planeSource.SetNormal(1.0, 0.0, 1.0); planeSource.Update(); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(planeSource.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetLineWidth(4); vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); renderer.SetBackground(0.2, 0.3, 0.4); renderer.AddActor(actor); renderer.ResetCamera(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestSplineFilter(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkMultiBlockPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); ps = new vtkPlaneSource(); ps.SetXResolution((int)4); ps.SetYResolution((int)4); ps.SetOrigin((double)2, (double)-2, (double)26); ps.SetPoint1((double)2, (double)2, (double)26); ps.SetPoint2((double)2, (double)-2, (double)32); psMapper = vtkPolyDataMapper.New(); psMapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort()); psActor = new vtkActor(); psActor.SetMapper((vtkMapper)psMapper); psActor.GetProperty().SetRepresentationToWireframe(); rk4 = new vtkRungeKutta4(); streamer = new vtkStreamLine(); streamer.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); streamer.SetSourceConnection(ps.GetOutputPort()); streamer.SetMaximumPropagationTime((double)100); streamer.SetIntegrationStepLength((double).2); streamer.SetStepLength((double).001); streamer.SetNumberOfThreads((int)1); streamer.SetIntegrationDirectionToForward(); streamer.VorticityOn(); streamer.SetIntegrator((vtkInitialValueProblemSolver)rk4); sf = new vtkSplineFilter(); sf.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); sf.SetSubdivideToLength(); sf.SetLength((double)0.15); rf = new vtkRibbonFilter(); rf.SetInputConnection((vtkAlgorithmOutput)sf.GetOutputPort()); rf.SetWidth((double)0.1); rf.SetWidthFactor((double)5); streamMapper = vtkPolyDataMapper.New(); streamMapper.SetInputConnection((vtkAlgorithmOutput)rf.GetOutputPort()); streamMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); streamline = new vtkActor(); streamline.SetMapper((vtkMapper)streamMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)psActor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)streamline); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)300, (int)300); ren1.SetBackground((double)0.1, (double)0.2, (double)0.4); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297, (double)50); cam1.SetFocalPoint((double)9.71821, (double)0.458166, (double)29.3999); cam1.SetPosition((double)2.7439, (double)-37.3196, (double)38.7167); cam1.SetViewUp((double)-0.16123, (double)0.264271, (double)0.950876); // render the image[] //[] renWin.Render(); // prevent the tk window from showing up then start the event loop[] // for testing[] threshold = 15; //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVcombStreamers2(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); ps = new vtkPlaneSource(); ps.SetXResolution((int)4); ps.SetYResolution((int)4); ps.SetOrigin((double)2,(double)-2,(double)26); ps.SetPoint1((double)2,(double)2,(double)26); ps.SetPoint2((double)2,(double)-2,(double)32); psMapper = vtkPolyDataMapper.New(); psMapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort()); psActor = new vtkActor(); psActor.SetMapper((vtkMapper)psMapper); psActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkDashedStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); streamer.SetSource((vtkDataSet)ps.GetOutput()); streamer.SetMaximumPropagationTime((double)100); streamer.SetIntegrationStepLength((double).2); streamer.SetStepLength((double).001); streamer.SetNumberOfThreads((int)1); streamer.SetIntegrationDirectionToForward(); streamMapper = vtkPolyDataMapper.New(); streamMapper.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamMapper.SetScalarRange( (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); streamline = new vtkActor(); streamline.SetMapper((vtkMapper)streamMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)psActor); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)streamline); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); ren1.SetBackground((double)0.1,(double)0.2,(double)0.4); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297,(double)50); cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999); cam1.SetPosition((double)2.7439,(double)-37.3196,(double)38.7167); cam1.SetViewUp((double)-0.16123,(double)0.264271,(double)0.950876); // render the image[] //[] renWin.Render(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void CreatePlane(cPoint3D Axis1, cPoint3D Axis2, cPoint3D Origin, Color Colour) { Position = new cPoint3D(Origin.X, Origin.Y, Origin.Z); this.Colour = Colour; Plane = vtkPlaneSource.New(); Plane.SetPoint1(Axis1.X, Axis1.Y, Axis1.Z); Plane.SetPoint2(Axis2.X, Axis2.Y, Axis2.Z); Plane.SetOrigin(0, 0, 0); Plane.SetXResolution(1); Plane.SetYResolution(1); vtk_PolyDataMapper = vtkPolyDataMapper.New(); vtk_PolyDataMapper.SetInputConnection(Plane.GetOutputPort()); CreateVTK3DObject(0); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVLineIntersectQuadraticCells(String [] argv) { //Prefix Content is: "" // Contour every quadratic cell type[] // Create a scene with one of each cell type.[] // QuadraticEdge[] edgePoints = new vtkPoints(); edgePoints.SetNumberOfPoints((int)3); edgePoints.InsertPoint((int)0,(double)0,(double)0,(double)0); edgePoints.InsertPoint((int)1,(double)1.0,(double)0,(double)0); edgePoints.InsertPoint((int)2,(double)0.5,(double)0.25,(double)0); edgeScalars = new vtkFloatArray(); edgeScalars.SetNumberOfTuples((int)3); edgeScalars.InsertValue((int)0,(float)0.0); edgeScalars.InsertValue((int)1,(float)0.0); edgeScalars.InsertValue((int)2,(float)0.9); aEdge = new vtkQuadraticEdge(); aEdge.GetPointIds().SetId((int)0,(int)0); aEdge.GetPointIds().SetId((int)1,(int)1); aEdge.GetPointIds().SetId((int)2,(int)2); aEdgeGrid = new vtkUnstructuredGrid(); aEdgeGrid.Allocate((int)1,(int)1); aEdgeGrid.InsertNextCell((int)aEdge.GetCellType(),(vtkIdList)aEdge.GetPointIds()); aEdgeGrid.SetPoints((vtkPoints)edgePoints); aEdgeGrid.GetPointData().SetScalars((vtkDataArray)edgeScalars); aEdgeMapper = new vtkDataSetMapper(); aEdgeMapper.SetInputData((vtkDataSet)aEdgeGrid); aEdgeMapper.ScalarVisibilityOff(); aEdgeActor = new vtkActor(); aEdgeActor.SetMapper((vtkMapper)aEdgeMapper); aEdgeActor.GetProperty().SetRepresentationToWireframe(); aEdgeActor.GetProperty().SetAmbient((double)1.0); // Quadratic triangle[] triPoints = new vtkPoints(); triPoints.SetNumberOfPoints((int)6); triPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0); triPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0); triPoints.InsertPoint((int)2,(double)0.5,(double)0.8,(double)0.0); triPoints.InsertPoint((int)3,(double)0.5,(double)0.0,(double)0.0); triPoints.InsertPoint((int)4,(double)0.75,(double)0.4,(double)0.0); triPoints.InsertPoint((int)5,(double)0.25,(double)0.4,(double)0.0); triScalars = new vtkFloatArray(); triScalars.SetNumberOfTuples((int)6); triScalars.InsertValue((int)0,(float)0.0); triScalars.InsertValue((int)1,(float)0.0); triScalars.InsertValue((int)2,(float)0.0); triScalars.InsertValue((int)3,(float)1.0); triScalars.InsertValue((int)4,(float)0.0); triScalars.InsertValue((int)5,(float)0.0); aTri = new vtkQuadraticTriangle(); aTri.GetPointIds().SetId((int)0,(int)0); aTri.GetPointIds().SetId((int)1,(int)1); aTri.GetPointIds().SetId((int)2,(int)2); aTri.GetPointIds().SetId((int)3,(int)3); aTri.GetPointIds().SetId((int)4,(int)4); aTri.GetPointIds().SetId((int)5,(int)5); aTriGrid = new vtkUnstructuredGrid(); aTriGrid.Allocate((int)1,(int)1); aTriGrid.InsertNextCell((int)aTri.GetCellType(),(vtkIdList)aTri.GetPointIds()); aTriGrid.SetPoints((vtkPoints)triPoints); aTriGrid.GetPointData().SetScalars((vtkDataArray)triScalars); aTriMapper = new vtkDataSetMapper(); aTriMapper.SetInputData((vtkDataSet)aTriGrid); aTriMapper.ScalarVisibilityOff(); aTriActor = new vtkActor(); aTriActor.SetMapper((vtkMapper)aTriMapper); aTriActor.GetProperty().SetRepresentationToWireframe(); aTriActor.GetProperty().SetAmbient((double)1.0); // Quadratic quadrilateral[] quadPoints = new vtkPoints(); quadPoints.SetNumberOfPoints((int)8); quadPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0); quadPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0); quadPoints.InsertPoint((int)2,(double)1.0,(double)1.0,(double)0.0); quadPoints.InsertPoint((int)3,(double)0.0,(double)1.0,(double)0.0); quadPoints.InsertPoint((int)4,(double)0.5,(double)0.0,(double)0.0); quadPoints.InsertPoint((int)5,(double)1.0,(double)0.5,(double)0.0); quadPoints.InsertPoint((int)6,(double)0.5,(double)1.0,(double)0.0); quadPoints.InsertPoint((int)7,(double)0.0,(double)0.5,(double)0.0); quadScalars = new vtkFloatArray(); quadScalars.SetNumberOfTuples((int)8); quadScalars.InsertValue((int)0,(float)0.0); quadScalars.InsertValue((int)1,(float)0.0); quadScalars.InsertValue((int)2,(float)1.0); quadScalars.InsertValue((int)3,(float)1.0); quadScalars.InsertValue((int)4,(float)1.0); quadScalars.InsertValue((int)5,(float)0.0); quadScalars.InsertValue((int)6,(float)0.0); quadScalars.InsertValue((int)7,(float)0.0); aQuad = new vtkQuadraticQuad(); 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); aQuad.GetPointIds().SetId((int)4,(int)4); aQuad.GetPointIds().SetId((int)5,(int)5); aQuad.GetPointIds().SetId((int)6,(int)6); aQuad.GetPointIds().SetId((int)7,(int)7); aQuadGrid = new vtkUnstructuredGrid(); aQuadGrid.Allocate((int)1,(int)1); aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds()); aQuadGrid.SetPoints((vtkPoints)quadPoints); aQuadGrid.GetPointData().SetScalars((vtkDataArray)quadScalars); aQuadMapper = new vtkDataSetMapper(); aQuadMapper.SetInputData((vtkDataSet)aQuadGrid); aQuadMapper.ScalarVisibilityOff(); aQuadActor = new vtkActor(); aQuadActor.SetMapper((vtkMapper)aQuadMapper); aQuadActor.GetProperty().SetRepresentationToWireframe(); aQuadActor.GetProperty().SetAmbient((double)1.0); // Quadratic tetrahedron[] tetPoints = new vtkPoints(); tetPoints.SetNumberOfPoints((int)10); tetPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0); tetPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0); tetPoints.InsertPoint((int)2,(double)0.5,(double)0.8,(double)0.0); tetPoints.InsertPoint((int)3,(double)0.5,(double)0.4,(double)1.0); tetPoints.InsertPoint((int)4,(double)0.5,(double)0.0,(double)0.0); tetPoints.InsertPoint((int)5,(double)0.75,(double)0.4,(double)0.0); tetPoints.InsertPoint((int)6,(double)0.25,(double)0.4,(double)0.0); tetPoints.InsertPoint((int)7,(double)0.25,(double)0.2,(double)0.5); tetPoints.InsertPoint((int)8,(double)0.75,(double)0.2,(double)0.5); tetPoints.InsertPoint((int)9,(double)0.50,(double)0.6,(double)0.5); tetScalars = new vtkFloatArray(); tetScalars.SetNumberOfTuples((int)10); tetScalars.InsertValue((int)0,(float)1.0); tetScalars.InsertValue((int)1,(float)1.0); tetScalars.InsertValue((int)2,(float)1.0); tetScalars.InsertValue((int)3,(float)1.0); tetScalars.InsertValue((int)4,(float)0.0); tetScalars.InsertValue((int)5,(float)0.0); tetScalars.InsertValue((int)6,(float)0.0); tetScalars.InsertValue((int)7,(float)0.0); tetScalars.InsertValue((int)8,(float)0.0); tetScalars.InsertValue((int)9,(float)0.0); aTet = new vtkQuadraticTetra(); aTet.GetPointIds().SetId((int)0,(int)0); aTet.GetPointIds().SetId((int)1,(int)1); aTet.GetPointIds().SetId((int)2,(int)2); aTet.GetPointIds().SetId((int)3,(int)3); aTet.GetPointIds().SetId((int)4,(int)4); aTet.GetPointIds().SetId((int)5,(int)5); aTet.GetPointIds().SetId((int)6,(int)6); aTet.GetPointIds().SetId((int)7,(int)7); aTet.GetPointIds().SetId((int)8,(int)8); aTet.GetPointIds().SetId((int)9,(int)9); aTetGrid = new vtkUnstructuredGrid(); aTetGrid.Allocate((int)1,(int)1); aTetGrid.InsertNextCell((int)aTet.GetCellType(),(vtkIdList)aTet.GetPointIds()); aTetGrid.SetPoints((vtkPoints)tetPoints); aTetGrid.GetPointData().SetScalars((vtkDataArray)tetScalars); aTetMapper = new vtkDataSetMapper(); aTetMapper.SetInputData((vtkDataSet)aTetGrid); aTetMapper.ScalarVisibilityOff(); aTetActor = new vtkActor(); aTetActor.SetMapper((vtkMapper)aTetMapper); aTetActor.GetProperty().SetRepresentationToWireframe(); aTetActor.GetProperty().SetAmbient((double)1.0); // Quadratic hexahedron[] hexPoints = new vtkPoints(); hexPoints.SetNumberOfPoints((int)20); hexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); hexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); hexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); hexPoints.InsertPoint((int)3,(double)0,(double)1,(double)0); hexPoints.InsertPoint((int)4,(double)0,(double)0,(double)1); hexPoints.InsertPoint((int)5,(double)1,(double)0,(double)1); hexPoints.InsertPoint((int)6,(double)1,(double)1,(double)1); hexPoints.InsertPoint((int)7,(double)0,(double)1,(double)1); hexPoints.InsertPoint((int)8,(double)0.5,(double)0,(double)0); hexPoints.InsertPoint((int)9,(double)1,(double)0.5,(double)0); hexPoints.InsertPoint((int)10,(double)0.5,(double)1,(double)0); hexPoints.InsertPoint((int)11,(double)0,(double)0.5,(double)0); hexPoints.InsertPoint((int)12,(double)0.5,(double)0,(double)1); hexPoints.InsertPoint((int)13,(double)1,(double)0.5,(double)1); hexPoints.InsertPoint((int)14,(double)0.5,(double)1,(double)1); hexPoints.InsertPoint((int)15,(double)0,(double)0.5,(double)1); hexPoints.InsertPoint((int)16,(double)0,(double)0,(double)0.5); hexPoints.InsertPoint((int)17,(double)1,(double)0,(double)0.5); hexPoints.InsertPoint((int)18,(double)1,(double)1,(double)0.5); hexPoints.InsertPoint((int)19,(double)0,(double)1,(double)0.5); hexScalars = new vtkFloatArray(); hexScalars.SetNumberOfTuples((int)20); hexScalars.InsertValue((int)0,(float)1.0); hexScalars.InsertValue((int)1,(float)1.0); hexScalars.InsertValue((int)2,(float)1.0); hexScalars.InsertValue((int)3,(float)1.0); hexScalars.InsertValue((int)4,(float)1.0); hexScalars.InsertValue((int)5,(float)1.0); hexScalars.InsertValue((int)6,(float)1.0); hexScalars.InsertValue((int)7,(float)1.0); hexScalars.InsertValue((int)8,(float)0.0); hexScalars.InsertValue((int)9,(float)0.0); hexScalars.InsertValue((int)10,(float)0.0); hexScalars.InsertValue((int)11,(float)0.0); hexScalars.InsertValue((int)12,(float)0.0); hexScalars.InsertValue((int)13,(float)0.0); hexScalars.InsertValue((int)14,(float)0.0); hexScalars.InsertValue((int)15,(float)0.0); hexScalars.InsertValue((int)16,(float)0.0); hexScalars.InsertValue((int)17,(float)0.0); hexScalars.InsertValue((int)18,(float)0.0); hexScalars.InsertValue((int)19,(float)0.0); aHex = new vtkQuadraticHexahedron(); aHex.GetPointIds().SetId((int)0,(int)0); aHex.GetPointIds().SetId((int)1,(int)1); aHex.GetPointIds().SetId((int)2,(int)2); aHex.GetPointIds().SetId((int)3,(int)3); aHex.GetPointIds().SetId((int)4,(int)4); aHex.GetPointIds().SetId((int)5,(int)5); aHex.GetPointIds().SetId((int)6,(int)6); aHex.GetPointIds().SetId((int)7,(int)7); aHex.GetPointIds().SetId((int)8,(int)8); aHex.GetPointIds().SetId((int)9,(int)9); aHex.GetPointIds().SetId((int)10,(int)10); aHex.GetPointIds().SetId((int)11,(int)11); aHex.GetPointIds().SetId((int)12,(int)12); aHex.GetPointIds().SetId((int)13,(int)13); aHex.GetPointIds().SetId((int)14,(int)14); aHex.GetPointIds().SetId((int)15,(int)15); aHex.GetPointIds().SetId((int)16,(int)16); aHex.GetPointIds().SetId((int)17,(int)17); aHex.GetPointIds().SetId((int)18,(int)18); aHex.GetPointIds().SetId((int)19,(int)19); aHexGrid = new vtkUnstructuredGrid(); aHexGrid.Allocate((int)1,(int)1); aHexGrid.InsertNextCell((int)aHex.GetCellType(),(vtkIdList)aHex.GetPointIds()); aHexGrid.SetPoints((vtkPoints)hexPoints); aHexGrid.GetPointData().SetScalars((vtkDataArray)hexScalars); aHexMapper = new vtkDataSetMapper(); aHexMapper.SetInputData((vtkDataSet)aHexGrid); aHexMapper.ScalarVisibilityOff(); aHexActor = new vtkActor(); aHexActor.SetMapper((vtkMapper)aHexMapper); aHexActor.GetProperty().SetRepresentationToWireframe(); aHexActor.GetProperty().SetAmbient((double)1.0); // Quadratic wedge[] wedgePoints = new vtkPoints(); wedgePoints.SetNumberOfPoints((int)15); wedgePoints.InsertPoint((int)0,(double)0,(double)0,(double)0); wedgePoints.InsertPoint((int)1,(double)1,(double)0,(double)0); wedgePoints.InsertPoint((int)2,(double)0,(double)1,(double)0); wedgePoints.InsertPoint((int)3,(double)0,(double)0,(double)1); wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)1); wedgePoints.InsertPoint((int)5,(double)0,(double)1,(double)1); wedgePoints.InsertPoint((int)6,(double)0.5,(double)0,(double)0); wedgePoints.InsertPoint((int)7,(double)0.5,(double)0.5,(double)0); wedgePoints.InsertPoint((int)8,(double)0,(double)0.5,(double)0); wedgePoints.InsertPoint((int)9,(double)0.5,(double)0,(double)1); wedgePoints.InsertPoint((int)10,(double)0.5,(double)0.5,(double)1); wedgePoints.InsertPoint((int)11,(double)0,(double)0.5,(double)1); wedgePoints.InsertPoint((int)12,(double)0,(double)0,(double)0.5); wedgePoints.InsertPoint((int)13,(double)1,(double)0,(double)0.5); wedgePoints.InsertPoint((int)14,(double)0,(double)1,(double)0.5); wedgeScalars = new vtkFloatArray(); wedgeScalars.SetNumberOfTuples((int)15); wedgeScalars.InsertValue((int)0,(float)1.0); wedgeScalars.InsertValue((int)1,(float)1.0); wedgeScalars.InsertValue((int)2,(float)1.0); wedgeScalars.InsertValue((int)3,(float)1.0); wedgeScalars.InsertValue((int)4,(float)1.0); wedgeScalars.InsertValue((int)5,(float)1.0); wedgeScalars.InsertValue((int)6,(float)1.0); wedgeScalars.InsertValue((int)7,(float)1.0); wedgeScalars.InsertValue((int)8,(float)0.0); wedgeScalars.InsertValue((int)9,(float)0.0); wedgeScalars.InsertValue((int)10,(float)0.0); wedgeScalars.InsertValue((int)11,(float)0.0); wedgeScalars.InsertValue((int)12,(float)0.0); wedgeScalars.InsertValue((int)13,(float)0.0); wedgeScalars.InsertValue((int)14,(float)0.0); aWedge = new vtkQuadraticWedge(); 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); aWedge.GetPointIds().SetId((int)6,(int)6); aWedge.GetPointIds().SetId((int)7,(int)7); aWedge.GetPointIds().SetId((int)8,(int)8); aWedge.GetPointIds().SetId((int)9,(int)9); aWedge.GetPointIds().SetId((int)10,(int)10); aWedge.GetPointIds().SetId((int)11,(int)11); aWedge.GetPointIds().SetId((int)12,(int)12); aWedge.GetPointIds().SetId((int)13,(int)13); aWedge.GetPointIds().SetId((int)14,(int)14); aWedgeGrid = new vtkUnstructuredGrid(); aWedgeGrid.Allocate((int)1,(int)1); aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds()); aWedgeGrid.SetPoints((vtkPoints)wedgePoints); aWedgeGrid.GetPointData().SetScalars((vtkDataArray)wedgeScalars); wedgeContours = new vtkClipDataSet(); wedgeContours.SetInputData((vtkDataObject)aWedgeGrid); wedgeContours.SetValue((double)0.5); aWedgeContourMapper = new vtkDataSetMapper(); aWedgeContourMapper.SetInputConnection((vtkAlgorithmOutput)wedgeContours.GetOutputPort()); aWedgeContourMapper.ScalarVisibilityOff(); aWedgeMapper = new vtkDataSetMapper(); aWedgeMapper.SetInputData((vtkDataSet)aWedgeGrid); aWedgeMapper.ScalarVisibilityOff(); aWedgeActor = new vtkActor(); aWedgeActor.SetMapper((vtkMapper)aWedgeMapper); aWedgeActor.GetProperty().SetRepresentationToWireframe(); aWedgeActor.GetProperty().SetAmbient((double)1.0); aWedgeContourActor = new vtkActor(); aWedgeContourActor.SetMapper((vtkMapper)aWedgeContourMapper); aWedgeContourActor.GetProperty().SetAmbient((double)1.0); // Quadratic pyramid[] pyraPoints = new vtkPoints(); pyraPoints.SetNumberOfPoints((int)13); pyraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0); pyraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0); pyraPoints.InsertPoint((int)2,(double)1,(double)1,(double)0); pyraPoints.InsertPoint((int)3,(double)0,(double)1,(double)0); pyraPoints.InsertPoint((int)4,(double)0,(double)0,(double)1); pyraPoints.InsertPoint((int)5,(double)0.5,(double)0,(double)0); pyraPoints.InsertPoint((int)6,(double)1,(double)0.5,(double)0); pyraPoints.InsertPoint((int)7,(double)0.5,(double)1,(double)0); pyraPoints.InsertPoint((int)8,(double)0,(double)0.5,(double)0); pyraPoints.InsertPoint((int)9,(double)0,(double)0,(double)0.5); pyraPoints.InsertPoint((int)10,(double)0.5,(double)0,(double)0.5); pyraPoints.InsertPoint((int)11,(double)0.5,(double)0.5,(double)0.5); pyraPoints.InsertPoint((int)12,(double)0,(double)0.5,(double)0.5); pyraScalars = new vtkFloatArray(); pyraScalars.SetNumberOfTuples((int)13); pyraScalars.InsertValue((int)0,(float)1.0); pyraScalars.InsertValue((int)1,(float)1.0); pyraScalars.InsertValue((int)2,(float)1.0); pyraScalars.InsertValue((int)3,(float)1.0); pyraScalars.InsertValue((int)4,(float)1.0); pyraScalars.InsertValue((int)5,(float)1.0); pyraScalars.InsertValue((int)6,(float)1.0); pyraScalars.InsertValue((int)7,(float)1.0); pyraScalars.InsertValue((int)8,(float)0.0); pyraScalars.InsertValue((int)9,(float)0.0); pyraScalars.InsertValue((int)10,(float)0.0); pyraScalars.InsertValue((int)11,(float)0.0); pyraScalars.InsertValue((int)12,(float)0.0); aPyramid = new vtkQuadraticPyramid(); 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); aPyramid.GetPointIds().SetId((int)5,(int)5); aPyramid.GetPointIds().SetId((int)6,(int)6); aPyramid.GetPointIds().SetId((int)7,(int)7); aPyramid.GetPointIds().SetId((int)8,(int)8); aPyramid.GetPointIds().SetId((int)9,(int)9); aPyramid.GetPointIds().SetId((int)10,(int)10); aPyramid.GetPointIds().SetId((int)11,(int)11); aPyramid.GetPointIds().SetId((int)12,(int)12); aPyramidGrid = new vtkUnstructuredGrid(); aPyramidGrid.Allocate((int)1,(int)1); aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds()); aPyramidGrid.SetPoints((vtkPoints)pyraPoints); aPyramidGrid.GetPointData().SetScalars((vtkDataArray)pyraScalars); pyraContours = new vtkClipDataSet(); pyraContours.SetInputData((vtkDataObject)aPyramidGrid); pyraContours.SetValue((double)0.5); aPyramidContourMapper = new vtkDataSetMapper(); aPyramidContourMapper.SetInputConnection((vtkAlgorithmOutput)pyraContours.GetOutputPort()); aPyramidContourMapper.ScalarVisibilityOff(); aPyramidMapper = new vtkDataSetMapper(); aPyramidMapper.SetInputData((vtkDataSet)aPyramidGrid); aPyramidMapper.ScalarVisibilityOff(); aPyramidActor = new vtkActor(); aPyramidActor.SetMapper((vtkMapper)aPyramidMapper); aPyramidActor.GetProperty().SetRepresentationToWireframe(); aPyramidActor.GetProperty().SetAmbient((double)1.0); aPyramidContourActor = new vtkActor(); aPyramidContourActor.SetMapper((vtkMapper)aPyramidContourMapper); aPyramidContourActor.GetProperty().SetAmbient((double)1.0); // Create the rendering related stuff.[] // Since some of our actors are a single vertex, we need to remove all[] // cullers so the single vertex actors will render[] ren1 = vtkRenderer.New(); ren1.GetCullers().RemoveAllItems(); renWin = vtkRenderWindow.New(); renWin.SetMultiSamples(0); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); ren1.SetBackground((double).1,(double).2,(double).3); renWin.SetSize((int)400,(int)200); // specify properties[] ren1.AddActor((vtkProp)aEdgeActor); ren1.AddActor((vtkProp)aTriActor); ren1.AddActor((vtkProp)aQuadActor); ren1.AddActor((vtkProp)aTetActor); ren1.AddActor((vtkProp)aHexActor); ren1.AddActor((vtkProp)aWedgeActor); ren1.AddActor((vtkProp)aPyramidActor); // places everyone!![] aTriActor.AddPosition((double)2,(double)0,(double)0); aQuadActor.AddPosition((double)4,(double)0,(double)0); aTetActor.AddPosition((double)6,(double)0,(double)0); aHexActor.AddPosition((double)8,(double)0,(double)0); aWedgeActor.AddPosition((double)10,(double)0,(double)0); aPyramidActor.AddPosition((double)12,(double)0,(double)0); BuildBackdrop(-1, 15, -1, 4, -1, 2, .1); ren1.AddActor((vtkProp)base1); base1.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2); ren1.AddActor((vtkProp)left); left.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2); ren1.AddActor((vtkProp)back); back.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2); ren1.ResetCamera(); ren1.GetActiveCamera().Dolly((double)2.5); ren1.ResetCameraClippingRange(); renWin.Render(); // create a little scorecard above each of the cells. These are displayed[] // if a ray cast hits the cell, otherwise they are not shown.[] pm = new vtkPlaneSource(); pm.SetXResolution((int)1); pm.SetYResolution((int)1); pmapper = vtkPolyDataMapper.New(); pmapper.SetInputConnection((vtkAlgorithmOutput)pm.GetOutputPort()); // now try intersecting rays with the cell[] cellPicker = new vtkCellPicker(); edgeCheck = new vtkActor(); edgeCheck.SetMapper((vtkMapper)pmapper); edgeCheck.AddPosition((double)0.5,(double)2.5,(double)0); cellPicker.Pick((double)87,(double)71,(double)0,(vtkRenderer)ren1); if ((cellPicker.GetCellId()) != -1) { ren1.AddActor((vtkProp)edgeCheck); } triCheck = new vtkActor(); triCheck.SetMapper((vtkMapper)pmapper); triCheck.AddPosition((double)2.5,(double)2.5,(double)0); cellPicker.Pick((double)139,(double)72,(double)0,(vtkRenderer)ren1); if ((cellPicker.GetCellId()) != -1) { ren1.AddActor((vtkProp)triCheck); } quadCheck = new vtkActor(); quadCheck.SetMapper((vtkMapper)pmapper); quadCheck.AddPosition((double)4.5,(double)2.5,(double)0); cellPicker.Pick((double)192,(double)78,(double)0,(vtkRenderer)ren1); if ((cellPicker.GetCellId()) != -1) { ren1.AddActor((vtkProp)quadCheck); } tetCheck = new vtkActor(); tetCheck.SetMapper((vtkMapper)pmapper); tetCheck.AddPosition((double)6.5,(double)2.5,(double)0); cellPicker.Pick((double)233,(double)70,(double)0,(vtkRenderer)ren1); if ((cellPicker.GetCellId()) != -1) { ren1.AddActor((vtkProp)tetCheck); } hexCheck = new vtkActor(); hexCheck.SetMapper((vtkMapper)pmapper); hexCheck.AddPosition((double)8.5,(double)2.5,(double)0); cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1); if ((cellPicker.GetCellId()) != -1) { ren1.AddActor((vtkProp)hexCheck); } wedgeCheck = new vtkActor(); wedgeCheck.SetMapper((vtkMapper)pmapper); wedgeCheck.AddPosition((double)10.5,(double)2.5,(double)0); cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1); if ((cellPicker.GetCellId()) != -1) { ren1.AddActor((vtkProp)wedgeCheck); } pyraCheck = new vtkActor(); pyraCheck.SetMapper((vtkMapper)pmapper); pyraCheck.AddPosition((double)12.5,(double)2.5,(double)0); cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1); if ((cellPicker.GetCellId()) != -1) { ren1.AddActor((vtkProp)pyraCheck); } // render the image[] //[] iren.Initialize(); //deleteAllVTKObjects(); }
///<summary> A Set Method for Static Variables </summary> public static void Setp5(vtkPlaneSource toSet) { p5 = toSet; }
///<summary> A Set Method for Static Variables </summary> public static void Setp3(vtkPlaneSource toSet) { p3 = toSet; }
///<summary> A Set Method for Static Variables </summary> public static void Setp4(vtkPlaneSource toSet) { p4 = toSet; }
///<summary> A Set Method for Static Variables </summary> public static void Setp2(vtkPlaneSource toSet) { p2 = toSet; }
///<summary> A Set Method for Static Variables </summary> public static void Setp1(vtkPlaneSource toSet) { p1 = toSet; }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVMatrixToTransform(String [] argv) { //Prefix Content is: "" // This example demonstrates how to use a matrix in place of a transfrom[] // via vtkMatrixToLinearTransform and vtkMatrixToHomogeneousTransform.[] // create a rendering window[] renWin = vtkRenderWindow.New(); renWin.SetSize((int)600, (int)300); // set up first set of polydata[] p1 = new vtkPlaneSource(); p1.SetOrigin((double)0.5, (double)0.508, (double)-0.5); p1.SetPoint1((double)-0.5, (double)0.508, (double)-0.5); p1.SetPoint2((double)0.5, (double)0.508, (double)0.5); p1.SetXResolution((int)5); p1.SetYResolution((int)5); p2 = new vtkPlaneSource(); p2.SetOrigin((double)-0.508, (double)0.5, (double)-0.5); p2.SetPoint1((double)-0.508, (double)-0.5, (double)-0.5); p2.SetPoint2((double)-0.508, (double)0.5, (double)0.5); p2.SetXResolution((int)5); p2.SetYResolution((int)5); p3 = new vtkPlaneSource(); p3.SetOrigin((double)-0.5, (double)-0.508, (double)-0.5); p3.SetPoint1((double)0.5, (double)-0.508, (double)-0.5); p3.SetPoint2((double)-0.5, (double)-0.508, (double)0.5); p3.SetXResolution((int)5); p3.SetYResolution((int)5); p4 = new vtkPlaneSource(); p4.SetOrigin((double)0.508, (double)-0.5, (double)-0.5); p4.SetPoint1((double)0.508, (double)0.5, (double)-0.5); p4.SetPoint2((double)0.508, (double)-0.5, (double)0.5); p4.SetXResolution((int)5); p4.SetYResolution((int)5); p5 = new vtkPlaneSource(); p5.SetOrigin((double)0.5, (double)0.5, (double)-0.508); p5.SetPoint1((double)0.5, (double)-0.5, (double)-0.508); p5.SetPoint2((double)-0.5, (double)0.5, (double)-0.508); p5.SetXResolution((int)5); p5.SetYResolution((int)5); p6 = new vtkPlaneSource(); p6.SetOrigin((double)0.5, (double)0.5, (double)0.508); p6.SetPoint1((double)-0.5, (double)0.5, (double)0.508); p6.SetPoint2((double)0.5, (double)-0.5, (double)0.508); p6.SetXResolution((int)5); p6.SetYResolution((int)5); // append together[] ap = new vtkAppendPolyData(); ap.AddInputConnection(p1.GetOutputPort()); ap.AddInputConnection(p2.GetOutputPort()); ap.AddInputConnection(p3.GetOutputPort()); ap.AddInputConnection(p4.GetOutputPort()); ap.AddInputConnection(p5.GetOutputPort()); ap.AddInputConnection(p6.GetOutputPort()); //--------------------------[] // linear transform matrix[] t1 = new vtkMatrixToLinearTransform(); m1 = new vtkMatrix4x4(); t1.SetInput((vtkMatrix4x4)m1); m1.SetElement((int)0, (int)0, (double)1.127631); m1.SetElement((int)0, (int)1, (double)0.205212); m1.SetElement((int)0, (int)2, (double)-0.355438); m1.SetElement((int)1, (int)0, (double)0.000000); m1.SetElement((int)1, (int)1, (double)0.692820); m1.SetElement((int)1, (int)2, (double)0.400000); m1.SetElement((int)2, (int)0, (double)0.200000); m1.SetElement((int)2, (int)1, (double)-0.469846); m1.SetElement((int)2, (int)2, (double)0.813798); f11 = new vtkTransformPolyDataFilter(); f11.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f11.SetTransform((vtkAbstractTransform)t1); m11 = new vtkDataSetMapper(); m11.SetInputConnection((vtkAlgorithmOutput)f11.GetOutputPort()); a11 = new vtkActor(); a11.SetMapper((vtkMapper)m11); a11.GetProperty().SetColor((double)1, (double)0, (double)0); a11.GetProperty().SetRepresentationToWireframe(); ren11 = vtkRenderer.New(); ren11.SetViewport((double)0.0, (double)0.5, (double)0.25, (double)1.0); ren11.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren11.AddActor((vtkProp)a11); renWin.AddRenderer((vtkRenderer)ren11); // inverse identity transform[] f12 = new vtkTransformPolyDataFilter(); f12.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f12.SetTransform((vtkAbstractTransform)t1.GetInverse()); m12 = new vtkDataSetMapper(); m12.SetInputConnection((vtkAlgorithmOutput)f12.GetOutputPort()); a12 = new vtkActor(); a12.SetMapper((vtkMapper)m12); a12.GetProperty().SetColor((double)0.9, (double)0.9, (double)0); a12.GetProperty().SetRepresentationToWireframe(); ren12 = vtkRenderer.New(); ren12.SetViewport((double)0.0, (double)0.0, (double)0.25, (double)0.5); ren12.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren12.AddActor((vtkProp)a12); renWin.AddRenderer((vtkRenderer)ren12); //--------------------------[] // perspective transform matrix[] m2 = new vtkMatrix4x4(); m2.SetElement((int)3, (int)0, (double)-0.11); m2.SetElement((int)3, (int)1, (double)0.3); m2.SetElement((int)3, (int)2, (double)0.2); t2 = new vtkMatrixToHomogeneousTransform(); t2.SetInput((vtkMatrix4x4)m2); f21 = new vtkTransformPolyDataFilter(); f21.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f21.SetTransform((vtkAbstractTransform)t2); m21 = new vtkDataSetMapper(); m21.SetInputConnection((vtkAlgorithmOutput)f21.GetOutputPort()); a21 = new vtkActor(); a21.SetMapper((vtkMapper)m21); a21.GetProperty().SetColor((double)1, (double)0, (double)0); a21.GetProperty().SetRepresentationToWireframe(); ren21 = vtkRenderer.New(); ren21.SetViewport((double)0.25, (double)0.5, (double)0.50, (double)1.0); ren21.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren21.AddActor((vtkProp)a21); renWin.AddRenderer((vtkRenderer)ren21); // inverse linear transform[] f22 = new vtkTransformPolyDataFilter(); f22.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f22.SetTransform((vtkAbstractTransform)t2.GetInverse()); m22 = new vtkDataSetMapper(); m22.SetInputConnection((vtkAlgorithmOutput)f22.GetOutputPort()); a22 = new vtkActor(); a22.SetMapper((vtkMapper)m22); a22.GetProperty().SetColor((double)0.9, (double)0.9, (double)0); a22.GetProperty().SetRepresentationToWireframe(); ren22 = vtkRenderer.New(); ren22.SetViewport((double)0.25, (double)0.0, (double)0.50, (double)0.5); ren22.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren22.AddActor((vtkProp)a22); renWin.AddRenderer((vtkRenderer)ren22); //--------------------------[] // linear concatenation - should end up with identity here[] t3 = new vtkTransform(); t3.Concatenate((vtkLinearTransform)t1); t3.Concatenate((vtkLinearTransform)t1.GetInverse()); f31 = new vtkTransformPolyDataFilter(); f31.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f31.SetTransform((vtkAbstractTransform)t3); m31 = new vtkDataSetMapper(); m31.SetInputConnection((vtkAlgorithmOutput)f31.GetOutputPort()); a31 = new vtkActor(); a31.SetMapper((vtkMapper)m31); a31.GetProperty().SetColor((double)1, (double)0, (double)0); a31.GetProperty().SetRepresentationToWireframe(); ren31 = vtkRenderer.New(); ren31.SetViewport((double)0.50, (double)0.5, (double)0.75, (double)1.0); ren31.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren31.AddActor((vtkProp)a31); renWin.AddRenderer((vtkRenderer)ren31); // inverse linear transform[] f32 = new vtkTransformPolyDataFilter(); f32.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f32.SetTransform((vtkAbstractTransform)t3.GetInverse()); m32 = new vtkDataSetMapper(); m32.SetInputConnection((vtkAlgorithmOutput)f32.GetOutputPort()); a32 = new vtkActor(); a32.SetMapper((vtkMapper)m32); a32.GetProperty().SetColor((double)0.9, (double)0.9, (double)0); a32.GetProperty().SetRepresentationToWireframe(); ren32 = vtkRenderer.New(); ren32.SetViewport((double)0.5, (double)0.0, (double)0.75, (double)0.5); ren32.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren32.AddActor((vtkProp)a32); renWin.AddRenderer((vtkRenderer)ren32); //--------------------------[] // perspective transform concatenation[] t4 = new vtkPerspectiveTransform(); t4.Concatenate((vtkHomogeneousTransform)t1); t4.Concatenate((vtkHomogeneousTransform)t2); t4.Concatenate((vtkHomogeneousTransform)t3); f41 = new vtkTransformPolyDataFilter(); f41.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f41.SetTransform((vtkAbstractTransform)t4); m41 = new vtkDataSetMapper(); m41.SetInputConnection((vtkAlgorithmOutput)f41.GetOutputPort()); a41 = new vtkActor(); a41.SetMapper((vtkMapper)m41); a41.GetProperty().SetColor((double)1, (double)0, (double)0); a41.GetProperty().SetRepresentationToWireframe(); ren41 = vtkRenderer.New(); ren41.SetViewport((double)0.75, (double)0.5, (double)1.0, (double)1.0); ren41.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren41.AddActor((vtkProp)a41); renWin.AddRenderer((vtkRenderer)ren41); // inverse of transform concatenation[] f42 = new vtkTransformPolyDataFilter(); f42.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f42.SetTransform((vtkAbstractTransform)t4.GetInverse()); m42 = new vtkDataSetMapper(); m42.SetInputConnection((vtkAlgorithmOutput)f42.GetOutputPort()); a42 = new vtkActor(); a42.SetMapper((vtkMapper)m42); a42.GetProperty().SetColor((double)0.9, (double)0.9, (double)0); a42.GetProperty().SetRepresentationToWireframe(); ren42 = vtkRenderer.New(); ren42.SetViewport((double)0.75, (double)0.0, (double)1.0, (double)0.5); ren42.ResetCamera((double)-0.5, (double)0.5, (double)-0.5, (double)0.5, (double)-1, (double)1); ren42.AddActor((vtkProp)a42); renWin.AddRenderer((vtkRenderer)ren42); renWin.Render(); //deleteAllVTKObjects(); }
///<summary> A Set Method for Static Variables </summary> public static void Setps(vtkPlaneSource toSet) { ps = toSet; }
///<summary> A Set Method for Static Variables </summary> public static void Setp6(vtkPlaneSource toSet) { p6 = toSet; }
/// <summary> /// 绘制立方体的五个面 /// 根据index确定需要绘制哪个面 /// </summary> /// <param name="index"></param> /// <param name="renderer"></param> public void PlotSurface(int index, vtkRenderer renderer) { vtkPlaneSource pSrc = vtkPlaneSource.New(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); vtkActor actor = vtkActor.New(); switch (index) { case 0: pSrc.SetCenter(sideLen + 0.5 + offset[0], sideLen + 0.5 + offset[1], 0 + offset[2]); pSrc.SetNormal(0, 0, 1); pSrc.SetPoint1(sideLen + offset[0], 0 + offset[1], 0 + offset[2]); pSrc.SetPoint2(0 + offset[0], sideLen + offset[1], 0 + offset[2]); mapper.SetInput(pSrc.GetOutput()); actor.SetMapper(mapper); renderer.AddActor(actor); break; case 1: pSrc.SetCenter(0 + offset[0], sideLen + 0.5 + offset[1], sideLen - 0.5 + offset[2]); pSrc.SetNormal(1, 0, 0); pSrc.SetPoint1(0 + offset[0], 0 + offset[1], sideLen + offset[2]); pSrc.SetPoint2(0 + offset[0], sideLen + offset[1], 0 + offset[2]); mapper.SetInput(pSrc.GetOutput()); actor.SetMapper(mapper); renderer.AddActor(actor); break; case 2: pSrc.SetCenter(sideLen + offset[0], sideLen + 0.5 + offset[1], sideLen - 0.5 + offset[2]); pSrc.SetNormal(1, 0, 0); pSrc.SetPoint1(sideLen + offset[0], 0 + offset[1], sideLen + offset[2]); pSrc.SetPoint2(sideLen + offset[0], sideLen + offset[1], 0 + offset[2]); mapper.SetInput(pSrc.GetOutput()); actor.SetMapper(mapper); renderer.AddActor(actor); break; case 3: pSrc.SetCenter(sideLen + 0.5 + offset[0], 0 + offset[1], sideLen - 0.5 + offset[2]); pSrc.SetNormal(0, 1, 0); pSrc.SetPoint1(sideLen + offset[0], 0 + offset[1], 0 + offset[2]); pSrc.SetPoint2(0 + offset[0], 0 + offset[1], sideLen + offset[2]); mapper.SetInput(pSrc.GetOutput()); actor.SetMapper(mapper); renderer.AddActor(actor); break; case 4: pSrc.SetCenter(sideLen + 0.5 + offset[0], sideLen + offset[1], sideLen - 0.5 + offset[2]); pSrc.SetNormal(0, 1, 0); pSrc.SetPoint1(sideLen + offset[0], sideLen + offset[1], 0 + offset[2]); pSrc.SetPoint2(0 + offset[0], sideLen + offset[1], sideLen + offset[2]); mapper.SetInput(pSrc.GetOutput()); actor.SetMapper(mapper); renderer.AddActor(actor); break; case 5: break; default: break; } }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVprobeComb(String [] argv) { //Prefix Content is: "" // create planes[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.SetMultiSamples(0); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkMultiBlockPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); plane = new vtkPlaneSource(); plane.SetResolution((int)50, (int)50); transP1 = new vtkTransform(); transP1.Translate((double)3.7, (double)0.0, (double)28.37); transP1.Scale((double)5, (double)5, (double)5); transP1.RotateY((double)90); tpd1 = new vtkTransformPolyDataFilter(); tpd1.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd1.SetTransform((vtkAbstractTransform)transP1); outTpd1 = new vtkOutlineFilter(); outTpd1.SetInputConnection((vtkAlgorithmOutput)tpd1.GetOutputPort()); mapTpd1 = vtkPolyDataMapper.New(); mapTpd1.SetInputConnection((vtkAlgorithmOutput)outTpd1.GetOutputPort()); tpd1Actor = new vtkActor(); tpd1Actor.SetMapper((vtkMapper)mapTpd1); tpd1Actor.GetProperty().SetColor((double)0, (double)0, (double)0); transP2 = new vtkTransform(); transP2.Translate((double)9.2, (double)0.0, (double)31.20); transP2.Scale((double)5, (double)5, (double)5); transP2.RotateY((double)90); tpd2 = new vtkTransformPolyDataFilter(); tpd2.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd2.SetTransform((vtkAbstractTransform)transP2); outTpd2 = new vtkOutlineFilter(); outTpd2.SetInputConnection((vtkAlgorithmOutput)tpd2.GetOutputPort()); mapTpd2 = vtkPolyDataMapper.New(); mapTpd2.SetInputConnection((vtkAlgorithmOutput)outTpd2.GetOutputPort()); tpd2Actor = new vtkActor(); tpd2Actor.SetMapper((vtkMapper)mapTpd2); tpd2Actor.GetProperty().SetColor((double)0, (double)0, (double)0); transP3 = new vtkTransform(); transP3.Translate((double)13.27, (double)0.0, (double)33.30); transP3.Scale((double)5, (double)5, (double)5); transP3.RotateY((double)90); tpd3 = new vtkTransformPolyDataFilter(); tpd3.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd3.SetTransform((vtkAbstractTransform)transP3); outTpd3 = new vtkOutlineFilter(); outTpd3.SetInputConnection((vtkAlgorithmOutput)tpd3.GetOutputPort()); mapTpd3 = vtkPolyDataMapper.New(); mapTpd3.SetInputConnection((vtkAlgorithmOutput)outTpd3.GetOutputPort()); tpd3Actor = new vtkActor(); tpd3Actor.SetMapper((vtkMapper)mapTpd3); tpd3Actor.GetProperty().SetColor((double)0, (double)0, (double)0); appendF = new vtkAppendPolyData(); appendF.AddInputConnection(tpd1.GetOutputPort()); appendF.AddInputConnection(tpd2.GetOutputPort()); appendF.AddInputConnection(tpd3.GetOutputPort()); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)appendF.GetOutputPort()); probe.SetSourceData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); contour.GenerateValues((int)50, (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); contourMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)contourMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0)); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)tpd1Actor); ren1.AddActor((vtkProp)tpd2Actor); ren1.AddActor((vtkProp)tpd3Actor); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)400, (int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297, (double)50); cam1.SetFocalPoint((double)8.88908, (double)0.595038, (double)29.3342); cam1.SetPosition((double)-12.3332, (double)31.7479, (double)41.2387); cam1.SetViewUp((double)0.060772, (double)-0.319905, (double)0.945498); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
//切片模式_绘制 private void DrawMode_Slice() { int[] xyz = m_ImageData.GetDimensions(); double[] sp = m_ImageData.GetSpacing(); double[] pos = new double[] { m_XPos, m_YPos, m_ZPos }; #region -------------------XOY切片(垂直Z轴)------------------- m_ImageResliceXOY = vtkImageReslice.New(); m_ImageResliceXOY.SetInput(m_ImageData); m_ImageResliceXOY.SetResliceAxesDirectionCosines( 1, 0, 0, 0, 1, 0, 0, 0, 1 ); m_ImageResliceXOY.InterpolateOn(); m_ImageResliceXOY.SetInterpolationModeToNearestNeighbor(); m_ImageResliceXOY.SetResliceAxesOrigin(pos[0], pos[1], pos[2]); m_ImageResliceXOY.SetOutputDimensionality(2); m_ImageResliceXOY.Update(); m_TextureXOY = vtkTexture.New(); m_TextureXOY.InterpolateOff(); m_TextureXOY.SetInput(m_ImageResliceXOY.GetOutput()); m_TextureXOY.SetLookupTable(m_LookupTable); m_TextureXOY.MapColorScalarsThroughLookupTableOn(); //---------------------set plane position---------- m_PlaneSourceXOY = vtkPlaneSource.New(); m_PlaneSourceXOY.SetXResolution(xyz[0]); m_PlaneSourceXOY.SetYResolution(xyz[1]); m_PlaneSourceXOY.SetOrigin(0, 0, 0); m_PlaneSourceXOY.SetPoint1((xyz[0] - 1) * sp[0], 0, 0); m_PlaneSourceXOY.SetPoint2(0, (xyz[1] - 1) * sp[1], 0); m_PlaneSourceXOY.Push(pos[2]); //---------------------pipeline-------------------- m_PlaneMapperXOY = vtkPolyDataMapper.New(); m_PlaneMapperXOY.SetInput(m_PlaneSourceXOY.GetOutput()); m_ActorXOY = vtkActor.New(); m_ActorXOY.SetMapper(m_PlaneMapperXOY); m_ActorXOY.SetTexture(m_TextureXOY); #endregion #region -------------------XOZ切片(垂直Y轴)------------------- m_ImageResliceXOZ = vtkImageReslice.New(); m_ImageResliceXOZ.SetInput(m_ImageData); m_ImageResliceXOZ.SetResliceAxesDirectionCosines( 1, 0, 0, 0, 0, -1, 0, 1, 0 ); m_ImageResliceXOZ.InterpolateOn(); m_ImageResliceXOZ.SetInterpolationModeToNearestNeighbor(); m_ImageResliceXOZ.SetResliceAxesOrigin(pos[0], pos[1], pos[2]); m_ImageResliceXOZ.SetOutputDimensionality(2); m_ImageResliceXOZ.Update(); m_TextureXOZ = vtkTexture.New(); m_TextureXOZ.SetInput(m_ImageResliceXOZ.GetOutput()); m_TextureXOZ.SetLookupTable(m_LookupTable); m_TextureXOZ.MapColorScalarsThroughLookupTableOn(); //---------------------set plane position-------------------- m_PlaneSourceXOZ = vtkPlaneSource.New(); m_PlaneSourceXOZ.SetXResolution(xyz[0]); m_PlaneSourceXOZ.SetYResolution(xyz[2]); m_PlaneSourceXOZ.SetOrigin(0, 0, (xyz[2] - 1) * sp[2]); m_PlaneSourceXOZ.SetPoint1((xyz[0] - 1) * sp[0], 0, (xyz[2] - 1) * sp[2]); m_PlaneSourceXOZ.SetPoint2(0, 0, 0); m_PlaneSourceXOZ.Push(pos[1]); //---------------------pipeline------------------------------ m_PlaneMapperXOZ = vtkPolyDataMapper.New(); m_PlaneMapperXOZ.SetInput(m_PlaneSourceXOZ.GetOutput()); m_ActorXOZ = vtkActor.New(); m_ActorXOZ.SetMapper(m_PlaneMapperXOZ); m_ActorXOZ.SetTexture(m_TextureXOZ); #endregion #region -------------------YOZ切片(垂直X轴)------------------- m_ImageResliceYOZ = vtkImageReslice.New(); m_ImageResliceYOZ.SetInput(m_ImageData); m_ImageResliceYOZ.SetResliceAxesDirectionCosines( 0, 0, -1, 0, 1, 0, 1, 0, 0 ); m_ImageResliceYOZ.InterpolateOn(); m_ImageResliceYOZ.SetInterpolationModeToNearestNeighbor(); m_ImageResliceYOZ.SetResliceAxesOrigin(pos[0], pos[1], pos[2]); m_ImageResliceYOZ.SetOutputDimensionality(2); m_ImageResliceYOZ.Update(); m_TextureYOZ = vtkTexture.New(); m_TextureYOZ.SetInput(m_ImageResliceYOZ.GetOutput()); m_TextureYOZ.SetLookupTable(m_LookupTable); m_TextureYOZ.MapColorScalarsThroughLookupTableOn(); //---------------------set plane position-------------------- m_PlaneSourceYOZ = vtkPlaneSource.New(); m_PlaneSourceYOZ.SetXResolution(xyz[2]); m_PlaneSourceYOZ.SetYResolution(xyz[1]); m_PlaneSourceYOZ.SetOrigin(0, 0, (xyz[2] - 1) * sp[2]); m_PlaneSourceYOZ.SetPoint1(0, 0, 0); m_PlaneSourceYOZ.SetPoint2(0, (xyz[1] - 1) * sp[1], (xyz[2] - 1) * sp[2]); m_PlaneSourceYOZ.Push(pos[0]); //---------------------pipeline------------------------------ m_PlaneMapperYOZ = vtkPolyDataMapper.New(); m_PlaneMapperYOZ.SetInput(m_PlaneSourceYOZ.GetOutput()); m_ActorYOZ = vtkActor.New(); m_ActorYOZ.SetMapper(m_PlaneMapperYOZ); m_ActorYOZ.SetTexture(m_TextureYOZ); #endregion m_Renderer.AddActor(m_ActorXOY); m_Renderer.AddActor(m_ActorXOZ); m_Renderer.AddActor(m_ActorYOZ); }
///<summary> A Set Method for Static Variables </summary> public static void Setplane(vtkPlaneSource toSet) { plane = toSet; }
///<summary> A Set Method for Static Variables </summary> public static void Setpm(vtkPlaneSource toSet) { pm = toSet; }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVMatrixToTransform(String [] argv) { //Prefix Content is: "" // This example demonstrates how to use a matrix in place of a transfrom[] // via vtkMatrixToLinearTransform and vtkMatrixToHomogeneousTransform.[] // create a rendering window[] renWin = vtkRenderWindow.New(); renWin.SetSize((int)600,(int)300); // set up first set of polydata[] p1 = new vtkPlaneSource(); p1.SetOrigin((double)0.5,(double)0.508,(double)-0.5); p1.SetPoint1((double)-0.5,(double)0.508,(double)-0.5); p1.SetPoint2((double)0.5,(double)0.508,(double)0.5); p1.SetXResolution((int)5); p1.SetYResolution((int)5); p2 = new vtkPlaneSource(); p2.SetOrigin((double)-0.508,(double)0.5,(double)-0.5); p2.SetPoint1((double)-0.508,(double)-0.5,(double)-0.5); p2.SetPoint2((double)-0.508,(double)0.5,(double)0.5); p2.SetXResolution((int)5); p2.SetYResolution((int)5); p3 = new vtkPlaneSource(); p3.SetOrigin((double)-0.5,(double)-0.508,(double)-0.5); p3.SetPoint1((double)0.5,(double)-0.508,(double)-0.5); p3.SetPoint2((double)-0.5,(double)-0.508,(double)0.5); p3.SetXResolution((int)5); p3.SetYResolution((int)5); p4 = new vtkPlaneSource(); p4.SetOrigin((double)0.508,(double)-0.5,(double)-0.5); p4.SetPoint1((double)0.508,(double)0.5,(double)-0.5); p4.SetPoint2((double)0.508,(double)-0.5,(double)0.5); p4.SetXResolution((int)5); p4.SetYResolution((int)5); p5 = new vtkPlaneSource(); p5.SetOrigin((double)0.5,(double)0.5,(double)-0.508); p5.SetPoint1((double)0.5,(double)-0.5,(double)-0.508); p5.SetPoint2((double)-0.5,(double)0.5,(double)-0.508); p5.SetXResolution((int)5); p5.SetYResolution((int)5); p6 = new vtkPlaneSource(); p6.SetOrigin((double)0.5,(double)0.5,(double)0.508); p6.SetPoint1((double)-0.5,(double)0.5,(double)0.508); p6.SetPoint2((double)0.5,(double)-0.5,(double)0.508); p6.SetXResolution((int)5); p6.SetYResolution((int)5); // append together[] ap = new vtkAppendPolyData(); ap.AddInputConnection(p1.GetOutputPort()); ap.AddInputConnection(p2.GetOutputPort()); ap.AddInputConnection(p3.GetOutputPort()); ap.AddInputConnection(p4.GetOutputPort()); ap.AddInputConnection(p5.GetOutputPort()); ap.AddInputConnection(p6.GetOutputPort()); //--------------------------[] // linear transform matrix[] t1 = new vtkMatrixToLinearTransform(); m1 = new vtkMatrix4x4(); t1.SetInput((vtkMatrix4x4)m1); m1.SetElement((int)0,(int)0,(double)1.127631); m1.SetElement((int)0,(int)1,(double)0.205212); m1.SetElement((int)0,(int)2,(double)-0.355438); m1.SetElement((int)1,(int)0,(double)0.000000); m1.SetElement((int)1,(int)1,(double)0.692820); m1.SetElement((int)1,(int)2,(double)0.400000); m1.SetElement((int)2,(int)0,(double)0.200000); m1.SetElement((int)2,(int)1,(double)-0.469846); m1.SetElement((int)2,(int)2,(double)0.813798); f11 = new vtkTransformPolyDataFilter(); f11.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f11.SetTransform((vtkAbstractTransform)t1); m11 = new vtkDataSetMapper(); m11.SetInputConnection((vtkAlgorithmOutput)f11.GetOutputPort()); a11 = new vtkActor(); a11.SetMapper((vtkMapper)m11); a11.GetProperty().SetColor((double)1,(double)0,(double)0); a11.GetProperty().SetRepresentationToWireframe(); ren11 = vtkRenderer.New(); ren11.SetViewport((double)0.0,(double)0.5,(double)0.25,(double)1.0); ren11.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren11.AddActor((vtkProp)a11); renWin.AddRenderer((vtkRenderer)ren11); // inverse identity transform[] f12 = new vtkTransformPolyDataFilter(); f12.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f12.SetTransform((vtkAbstractTransform)t1.GetInverse()); m12 = new vtkDataSetMapper(); m12.SetInputConnection((vtkAlgorithmOutput)f12.GetOutputPort()); a12 = new vtkActor(); a12.SetMapper((vtkMapper)m12); a12.GetProperty().SetColor((double)0.9,(double)0.9,(double)0); a12.GetProperty().SetRepresentationToWireframe(); ren12 = vtkRenderer.New(); ren12.SetViewport((double)0.0,(double)0.0,(double)0.25,(double)0.5); ren12.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren12.AddActor((vtkProp)a12); renWin.AddRenderer((vtkRenderer)ren12); //--------------------------[] // perspective transform matrix[] m2 = new vtkMatrix4x4(); m2.SetElement((int)3,(int)0,(double)-0.11); m2.SetElement((int)3,(int)1,(double)0.3); m2.SetElement((int)3,(int)2,(double)0.2); t2 = new vtkMatrixToHomogeneousTransform(); t2.SetInput((vtkMatrix4x4)m2); f21 = new vtkTransformPolyDataFilter(); f21.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f21.SetTransform((vtkAbstractTransform)t2); m21 = new vtkDataSetMapper(); m21.SetInputConnection((vtkAlgorithmOutput)f21.GetOutputPort()); a21 = new vtkActor(); a21.SetMapper((vtkMapper)m21); a21.GetProperty().SetColor((double)1,(double)0,(double)0); a21.GetProperty().SetRepresentationToWireframe(); ren21 = vtkRenderer.New(); ren21.SetViewport((double)0.25,(double)0.5,(double)0.50,(double)1.0); ren21.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren21.AddActor((vtkProp)a21); renWin.AddRenderer((vtkRenderer)ren21); // inverse linear transform[] f22 = new vtkTransformPolyDataFilter(); f22.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f22.SetTransform((vtkAbstractTransform)t2.GetInverse()); m22 = new vtkDataSetMapper(); m22.SetInputConnection((vtkAlgorithmOutput)f22.GetOutputPort()); a22 = new vtkActor(); a22.SetMapper((vtkMapper)m22); a22.GetProperty().SetColor((double)0.9,(double)0.9,(double)0); a22.GetProperty().SetRepresentationToWireframe(); ren22 = vtkRenderer.New(); ren22.SetViewport((double)0.25,(double)0.0,(double)0.50,(double)0.5); ren22.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren22.AddActor((vtkProp)a22); renWin.AddRenderer((vtkRenderer)ren22); //--------------------------[] // linear concatenation - should end up with identity here[] t3 = new vtkTransform(); t3.Concatenate((vtkLinearTransform)t1); t3.Concatenate((vtkLinearTransform)t1.GetInverse()); f31 = new vtkTransformPolyDataFilter(); f31.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f31.SetTransform((vtkAbstractTransform)t3); m31 = new vtkDataSetMapper(); m31.SetInputConnection((vtkAlgorithmOutput)f31.GetOutputPort()); a31 = new vtkActor(); a31.SetMapper((vtkMapper)m31); a31.GetProperty().SetColor((double)1,(double)0,(double)0); a31.GetProperty().SetRepresentationToWireframe(); ren31 = vtkRenderer.New(); ren31.SetViewport((double)0.50,(double)0.5,(double)0.75,(double)1.0); ren31.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren31.AddActor((vtkProp)a31); renWin.AddRenderer((vtkRenderer)ren31); // inverse linear transform[] f32 = new vtkTransformPolyDataFilter(); f32.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f32.SetTransform((vtkAbstractTransform)t3.GetInverse()); m32 = new vtkDataSetMapper(); m32.SetInputConnection((vtkAlgorithmOutput)f32.GetOutputPort()); a32 = new vtkActor(); a32.SetMapper((vtkMapper)m32); a32.GetProperty().SetColor((double)0.9,(double)0.9,(double)0); a32.GetProperty().SetRepresentationToWireframe(); ren32 = vtkRenderer.New(); ren32.SetViewport((double)0.5,(double)0.0,(double)0.75,(double)0.5); ren32.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren32.AddActor((vtkProp)a32); renWin.AddRenderer((vtkRenderer)ren32); //--------------------------[] // perspective transform concatenation[] t4 = new vtkPerspectiveTransform(); t4.Concatenate((vtkHomogeneousTransform)t1); t4.Concatenate((vtkHomogeneousTransform)t2); t4.Concatenate((vtkHomogeneousTransform)t3); f41 = new vtkTransformPolyDataFilter(); f41.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f41.SetTransform((vtkAbstractTransform)t4); m41 = new vtkDataSetMapper(); m41.SetInputConnection((vtkAlgorithmOutput)f41.GetOutputPort()); a41 = new vtkActor(); a41.SetMapper((vtkMapper)m41); a41.GetProperty().SetColor((double)1,(double)0,(double)0); a41.GetProperty().SetRepresentationToWireframe(); ren41 = vtkRenderer.New(); ren41.SetViewport((double)0.75,(double)0.5,(double)1.0,(double)1.0); ren41.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren41.AddActor((vtkProp)a41); renWin.AddRenderer((vtkRenderer)ren41); // inverse of transform concatenation[] f42 = new vtkTransformPolyDataFilter(); f42.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort()); f42.SetTransform((vtkAbstractTransform)t4.GetInverse()); m42 = new vtkDataSetMapper(); m42.SetInputConnection((vtkAlgorithmOutput)f42.GetOutputPort()); a42 = new vtkActor(); a42.SetMapper((vtkMapper)m42); a42.GetProperty().SetColor((double)0.9,(double)0.9,(double)0); a42.GetProperty().SetRepresentationToWireframe(); ren42 = vtkRenderer.New(); ren42.SetViewport((double)0.75,(double)0.0,(double)1.0,(double)0.5); ren42.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1); ren42.AddActor((vtkProp)a42); renWin.AddRenderer((vtkRenderer)ren42); renWin.Render(); //deleteAllVTKObjects(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { vtkPoints points = vtkPoints.New(); int GridSize = 10; for (int x = 0; x < GridSize; x++) { for (int y = 0; y < GridSize; y++) { points.InsertNextPoint(x, y, (x + y) / (y + 1)); } } // Add the grid points to a polydata object vtkPolyData polydata = vtkPolyData.New(); polydata.SetPoints(points); // Triangulate the grid points vtkDelaunay2D delaunay = vtkDelaunay2D.New(); delaunay.SetInput(polydata); delaunay.Update(); vtkPlaneSource plane = vtkPlaneSource.New(); //Read the image data from a file vtkJPEGReader reader = vtkJPEGReader.New(); reader.SetFileName("C:\\Users\\georg\\Desktop\\texture.jpg"); //Create texture object vtkTexture texture = vtkTexture.New(); texture.SetInputConnection(reader.GetOutputPort()); //Map texture coordinates vtkTextureMapToPlane map_to_plane = vtkTextureMapToPlane.New(); map_to_plane.SetInputConnection(plane.GetOutputPort()); map_to_plane.SetInputConnection(delaunay.GetOutputPort()); //Create mapper and set the mapped texture as input vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(map_to_plane.GetOutputPort()); //Create actor and set the mapper and the texture vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.SetTexture(texture); vtkRenderer renderer = vtkRenderer.New(); renderer.AddActor(actor); RenderControl1.RenderWindow.AddRenderer(renderer); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVprobeComb(String [] argv) { //Prefix Content is: "" // create planes[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // create pipeline[] //[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); plane = new vtkPlaneSource(); plane.SetResolution((int)50,(int)50); transP1 = new vtkTransform(); transP1.Translate((double)3.7,(double)0.0,(double)28.37); transP1.Scale((double)5,(double)5,(double)5); transP1.RotateY((double)90); tpd1 = new vtkTransformPolyDataFilter(); tpd1.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd1.SetTransform((vtkAbstractTransform)transP1); outTpd1 = new vtkOutlineFilter(); outTpd1.SetInputConnection((vtkAlgorithmOutput)tpd1.GetOutputPort()); mapTpd1 = vtkPolyDataMapper.New(); mapTpd1.SetInputConnection((vtkAlgorithmOutput)outTpd1.GetOutputPort()); tpd1Actor = new vtkActor(); tpd1Actor.SetMapper((vtkMapper)mapTpd1); tpd1Actor.GetProperty().SetColor((double)0,(double)0,(double)0); transP2 = new vtkTransform(); transP2.Translate((double)9.2,(double)0.0,(double)31.20); transP2.Scale((double)5,(double)5,(double)5); transP2.RotateY((double)90); tpd2 = new vtkTransformPolyDataFilter(); tpd2.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd2.SetTransform((vtkAbstractTransform)transP2); outTpd2 = new vtkOutlineFilter(); outTpd2.SetInputConnection((vtkAlgorithmOutput)tpd2.GetOutputPort()); mapTpd2 = vtkPolyDataMapper.New(); mapTpd2.SetInputConnection((vtkAlgorithmOutput)outTpd2.GetOutputPort()); tpd2Actor = new vtkActor(); tpd2Actor.SetMapper((vtkMapper)mapTpd2); tpd2Actor.GetProperty().SetColor((double)0,(double)0,(double)0); transP3 = new vtkTransform(); transP3.Translate((double)13.27,(double)0.0,(double)33.30); transP3.Scale((double)5,(double)5,(double)5); transP3.RotateY((double)90); tpd3 = new vtkTransformPolyDataFilter(); tpd3.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); tpd3.SetTransform((vtkAbstractTransform)transP3); outTpd3 = new vtkOutlineFilter(); outTpd3.SetInputConnection((vtkAlgorithmOutput)tpd3.GetOutputPort()); mapTpd3 = vtkPolyDataMapper.New(); mapTpd3.SetInputConnection((vtkAlgorithmOutput)outTpd3.GetOutputPort()); tpd3Actor = new vtkActor(); tpd3Actor.SetMapper((vtkMapper)mapTpd3); tpd3Actor.GetProperty().SetColor((double)0,(double)0,(double)0); appendF = new vtkAppendPolyData(); appendF.AddInput((vtkPolyData)tpd1.GetOutput()); appendF.AddInput((vtkPolyData)tpd2.GetOutput()); appendF.AddInput((vtkPolyData)tpd3.GetOutput()); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)appendF.GetOutputPort()); probe.SetSource((vtkDataObject)pl3d.GetOutput()); contour = new vtkContourFilter(); contour.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); contour.GenerateValues((int)50,(double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort()); contourMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)contourMapper); outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0); ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)tpd1Actor); ren1.AddActor((vtkProp)tpd2Actor); ren1.AddActor((vtkProp)tpd3Actor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)400,(int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.95297,(double)50); cam1.SetFocalPoint((double)8.88908,(double)0.595038,(double)29.3342); cam1.SetPosition((double)-12.3332,(double)31.7479,(double)41.2387); cam1.SetViewUp((double)0.060772,(double)-0.319905,(double)0.945498); iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }