/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToUGrid(String [] argv) { //Prefix Content is: "" // Read a field representing unstructured grid and display it (similar to blow.tcl)[] // create a reader and write out field daya[] reader = new vtkUnstructuredGridReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/blow.vtk"); reader.SetScalarsName((string)"thickness9"); reader.SetVectorsName((string)"displacement9"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); // we must be able to write here[] try { channel = new StreamWriter("UGridField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if (tryCatchError.Equals("NOERROR")) { channel.Close(); write = new vtkDataObjectWriter(); write.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); write.SetFileName((string)"UGridField.vtk"); write.Write(); // Read the field and convert to unstructured grid.[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"UGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToUnstructuredGrid(); do2ds.SetPointComponent((int)0,(string)"Points",(int)0); do2ds.SetPointComponent((int)1,(string)"Points",(int)1); do2ds.SetPointComponent((int)2,(string)"Points",(int)2); do2ds.SetCellTypeComponent((string)"CellTypes",(int)0); do2ds.SetCellConnectivityComponent((string)"Cells",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetUnstructuredGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0,(string)"displacement9",(int)0); fd2ad.SetVectorComponent((int)1,(string)"displacement9",(int)1); fd2ad.SetVectorComponent((int)2,(string)"displacement9",(int)2); fd2ad.SetScalarComponent((int)0,(string)"thickness9",(int)0); // Now start visualizing[] warp = new vtkWarpVector(); warp.SetInput((vtkDataObject)fd2ad.GetUnstructuredGridOutput()); // extract mold from mesh using connectivity[] connect = new vtkConnectivityFilter(); connect.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect.SetExtractionModeToSpecifiedRegions(); connect.AddSpecifiedRegion((int)0); connect.AddSpecifiedRegion((int)1); moldMapper = new vtkDataSetMapper(); moldMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort()); moldMapper.ScalarVisibilityOff(); moldActor = new vtkActor(); moldActor.SetMapper((vtkMapper)moldMapper); moldActor.GetProperty().SetColor((double).2,(double).2,(double).2); moldActor.GetProperty().SetRepresentationToWireframe(); // extract parison from mesh using connectivity[] connect2 = new vtkConnectivityFilter(); connect2.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect2.SetExtractionModeToSpecifiedRegions(); connect2.AddSpecifiedRegion((int)2); parison = new vtkGeometryFilter(); parison.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); normals2 = new vtkPolyDataNormals(); normals2.SetInputConnection((vtkAlgorithmOutput)parison.GetOutputPort()); normals2.SetFeatureAngle((double)60); lut = new vtkLookupTable(); lut.SetHueRange((double)0.0,(double)0.66667); parisonMapper = vtkPolyDataMapper.New(); parisonMapper.SetInputConnection((vtkAlgorithmOutput)normals2.GetOutputPort()); parisonMapper.SetLookupTable((vtkScalarsToColors)lut); parisonMapper.SetScalarRange((double)0.12,(double)1.0); parisonActor = new vtkActor(); parisonActor.SetMapper((vtkMapper)parisonMapper); cf = new vtkContourFilter(); cf.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); cf.SetValue((int)0,(double).5); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort()); contours = new vtkActor(); contours.SetMapper((vtkMapper)contourMapper); // Create graphics stuff[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] ren1.AddActor((vtkProp)moldActor); ren1.AddActor((vtkProp)parisonActor); ren1.AddActor((vtkProp)contours); ren1.ResetCamera(); ren1.GetActiveCamera().Azimuth((double)60); ren1.GetActiveCamera().Roll((double)-90); ren1.GetActiveCamera().Dolly((double)2); ren1.ResetCameraClippingRange(); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)375,(int)200); iren.Initialize(); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
///<summary> A Set Method for Static Variables </summary> public static void Setconnect2(vtkConnectivityFilter toSet) { connect2 = toSet; }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToUGrid(String [] argv) { //Prefix Content is: "" // Read a field representing unstructured grid and display it (similar to blow.tcl)[] // create a reader and write out field daya[] reader = new vtkUnstructuredGridReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/blow.vtk"); reader.SetScalarsName((string)"thickness9"); reader.SetVectorsName((string)"displacement9"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); // we must be able to write here[] try { channel = new StreamWriter("UGridField.vtk"); tryCatchError = "NOERROR"; } catch (Exception) { tryCatchError = "ERROR"; } if (tryCatchError.Equals("NOERROR")) { channel.Close(); write = new vtkDataObjectWriter(); write.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); write.SetFileName((string)"UGridField.vtk"); write.Write(); // Read the field and convert to unstructured grid.[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"UGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToUnstructuredGrid(); do2ds.SetPointComponent((int)0, (string)"Points", (int)0); do2ds.SetPointComponent((int)1, (string)"Points", (int)1); do2ds.SetPointComponent((int)2, (string)"Points", (int)2); do2ds.SetCellTypeComponent((string)"CellTypes", (int)0); do2ds.SetCellConnectivityComponent((string)"Cells", (int)0); do2ds.Update(); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInputData((vtkDataObject)do2ds.GetUnstructuredGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0, (string)"displacement9", (int)0); fd2ad.SetVectorComponent((int)1, (string)"displacement9", (int)1); fd2ad.SetVectorComponent((int)2, (string)"displacement9", (int)2); fd2ad.SetScalarComponent((int)0, (string)"thickness9", (int)0); fd2ad.Update(); // Now start visualizing[] warp = new vtkWarpVector(); warp.SetInputData((vtkDataObject)fd2ad.GetUnstructuredGridOutput()); // extract mold from mesh using connectivity[] connect = new vtkConnectivityFilter(); connect.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect.SetExtractionModeToSpecifiedRegions(); connect.AddSpecifiedRegion((int)0); connect.AddSpecifiedRegion((int)1); moldMapper = new vtkDataSetMapper(); moldMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort()); moldMapper.ScalarVisibilityOff(); moldActor = new vtkActor(); moldActor.SetMapper((vtkMapper)moldMapper); moldActor.GetProperty().SetColor((double).2, (double).2, (double).2); moldActor.GetProperty().SetRepresentationToWireframe(); // extract parison from mesh using connectivity[] connect2 = new vtkConnectivityFilter(); connect2.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect2.SetExtractionModeToSpecifiedRegions(); connect2.AddSpecifiedRegion((int)2); parison = new vtkGeometryFilter(); parison.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); normals2 = new vtkPolyDataNormals(); normals2.SetInputConnection((vtkAlgorithmOutput)parison.GetOutputPort()); normals2.SetFeatureAngle((double)60); lut = new vtkLookupTable(); lut.SetHueRange((double)0.0, (double)0.66667); parisonMapper = vtkPolyDataMapper.New(); parisonMapper.SetInputConnection((vtkAlgorithmOutput)normals2.GetOutputPort()); parisonMapper.SetLookupTable((vtkScalarsToColors)lut); parisonMapper.SetScalarRange((double)0.12, (double)1.0); parisonActor = new vtkActor(); parisonActor.SetMapper((vtkMapper)parisonMapper); cf = new vtkContourFilter(); cf.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); cf.SetValue((int)0, (double).5); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort()); contours = new vtkActor(); contours.SetMapper((vtkMapper)contourMapper); // Create graphics stuff[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] ren1.AddActor((vtkProp)moldActor); ren1.AddActor((vtkProp)parisonActor); ren1.AddActor((vtkProp)contours); ren1.ResetCamera(); ren1.GetActiveCamera().Azimuth((double)60); ren1.GetActiveCamera().Roll((double)-90); ren1.GetActiveCamera().Dolly((double)2); ren1.ResetCameraClippingRange(); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)375, (int)200); iren.Initialize(); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVSelectionLoop(String [] argv) { //Prefix Content is: "" //[] // Demonstrate the use of implicit selection loop as well as closest point[] // connectivity[] //[] // create pipeline[] //[] sphere = new vtkSphereSource(); sphere.SetRadius((double)1); sphere.SetPhiResolution((int)100); sphere.SetThetaResolution((int)100); selectionPoints = new vtkPoints(); selectionPoints.InsertPoint((int)0,(double)0.07325,(double)0.8417,(double)0.5612); selectionPoints.InsertPoint((int)1,(double)0.07244,(double)0.6568,(double)0.7450); selectionPoints.InsertPoint((int)2,(double)0.1727,(double)0.4597,(double)0.8850); selectionPoints.InsertPoint((int)3,(double)0.3265,(double)0.6054,(double)0.7309); selectionPoints.InsertPoint((int)4,(double)0.5722,(double)0.5848,(double)0.5927); selectionPoints.InsertPoint((int)5,(double)0.4305,(double)0.8138,(double)0.4189); loop = new vtkImplicitSelectionLoop(); loop.SetLoop((vtkPoints)selectionPoints); extract = new vtkExtractGeometry(); extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); extract.SetImplicitFunction((vtkImplicitFunction)loop); connect = new vtkConnectivityFilter(); connect.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort()); connect.SetExtractionModeToClosestPointRegion(); connect.SetClosestPoint((double)selectionPoints.GetPoint((int)0)[0], (double)selectionPoints.GetPoint((int)0)[1],(double)selectionPoints.GetPoint((int)0)[2]); clipMapper = new vtkDataSetMapper(); clipMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort()); backProp = new vtkProperty(); backProp.SetDiffuseColor((double) 1.0000, 0.3882, 0.2784 ); clipActor = new vtkActor(); clipActor.SetMapper((vtkMapper)clipMapper); clipActor.GetProperty().SetColor((double) 0.2000, 0.6300, 0.7900 ); clipActor.SetBackfaceProperty((vtkProperty)backProp); // Create graphics stuff[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)clipActor); ren1.SetBackground((double)1,(double)1,(double)1); ren1.ResetCamera(); ren1.GetActiveCamera().Azimuth((double)30); ren1.GetActiveCamera().Elevation((double)30); ren1.GetActiveCamera().Dolly((double)1.2); ren1.ResetCameraClippingRange(); renWin.SetSize((int)400,(int)400); renWin.Render(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVSelectionLoop(String [] argv) { //Prefix Content is: "" //[] // Demonstrate the use of implicit selection loop as well as closest point[] // connectivity[] //[] // create pipeline[] //[] sphere = new vtkSphereSource(); sphere.SetRadius((double)1); sphere.SetPhiResolution((int)100); sphere.SetThetaResolution((int)100); selectionPoints = new vtkPoints(); selectionPoints.InsertPoint((int)0, (double)0.07325, (double)0.8417, (double)0.5612); selectionPoints.InsertPoint((int)1, (double)0.07244, (double)0.6568, (double)0.7450); selectionPoints.InsertPoint((int)2, (double)0.1727, (double)0.4597, (double)0.8850); selectionPoints.InsertPoint((int)3, (double)0.3265, (double)0.6054, (double)0.7309); selectionPoints.InsertPoint((int)4, (double)0.5722, (double)0.5848, (double)0.5927); selectionPoints.InsertPoint((int)5, (double)0.4305, (double)0.8138, (double)0.4189); loop = new vtkImplicitSelectionLoop(); loop.SetLoop((vtkPoints)selectionPoints); extract = new vtkExtractGeometry(); extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort()); extract.SetImplicitFunction((vtkImplicitFunction)loop); connect = new vtkConnectivityFilter(); connect.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort()); connect.SetExtractionModeToClosestPointRegion(); connect.SetClosestPoint((double)selectionPoints.GetPoint((int)0)[0], (double)selectionPoints.GetPoint((int)0)[1], (double)selectionPoints.GetPoint((int)0)[2]); clipMapper = new vtkDataSetMapper(); clipMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort()); backProp = new vtkProperty(); backProp.SetDiffuseColor((double)1.0000, 0.3882, 0.2784); clipActor = new vtkActor(); clipActor.SetMapper((vtkMapper)clipMapper); clipActor.GetProperty().SetColor((double)0.2000, 0.6300, 0.7900); clipActor.SetBackfaceProperty((vtkProperty)backProp); // Create graphics stuff[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)clipActor); ren1.SetBackground((double)1, (double)1, (double)1); ren1.ResetCamera(); ren1.GetActiveCamera().Azimuth((double)30); ren1.GetActiveCamera().Elevation((double)30); ren1.GetActiveCamera().Dolly((double)1.2); ren1.ResetCameraClippingRange(); renWin.SetSize((int)400, (int)400); renWin.Render(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }