/// <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> /// 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(); }