// ================================ UPDATE PROPERTIES ============================================ /// <summary> /// Update Part Cell or Point scalars /// <list> /// <item><c>DB</c></item> /// <description> - Database with results (e.g. Nodal displacements, Element stress, etc.)</description> /// <item><c>inc</c></item> /// <description> - increment number for which you want to plot results</description> /// <item><c>Result</c></item> /// <description> - type of result (Stress XX, Displacement Z, etc.)</description> /// <item><c>Style</c></item> /// <description> - style of result (Element Max, Element Average, Contour Map)</description> /// </list> /// </summary> public void UpdateScalar(int inc, string Result, string Style) { // Update Scalars if (Result == "None") { Grid.GetCellData().SetActiveScalars(""); Grid.GetPointData().SetActiveScalars(""); Mapper.ScalarVisibilityOff(); } else { if (Style.Contains("Element")) { Grid.GetCellData().SetActiveScalars( Style.Replace("Element ", "") + " " + Result + " INC " + inc.ToString()); Mapper.SetScalarModeToUseCellData(); } else { Grid.GetPointData().SetActiveScalars(Result + " INC " + inc.ToString()); Mapper.SetScalarModeToUsePointData(); } Mapper.ScalarVisibilityOn(); } Mapper.Update(); }
/// <summary> /// Create new VTK structure of Part: /// <br> Points -> Grid -> Mapper -> Actor </br> /// </summary> public void CreatePart(Dictionary <int, Node> NodeLib, Dictionary <int, Element> ElemLib) { // Catch nodes - only used by Part Nodes = DetectPartNodes(ElemLib); // Initialize Elements - to connect vtkCells with Element IDs (and therefore scalar/result value) Elements = new List <int>(); // Initialize VTK data Points = vtkPoints.New(); Grid = vtkUnstructuredGrid.New(); Mapper = vtkDataSetMapper.New(); Actor = vtkActor.New(); Edges = vtkActor.New(); Faces = vtkPolyData.New(); Filter = vtkDataSetSurfaceFilter.New(); // Insert Points foreach (int n in Nodes.Keys) { Points.InsertNextPoint(NodeLib[n].X, NodeLib[n].Y, NodeLib[n].Z); } Grid.SetPoints(Points); // Add points to Grid CreateMesh(ElemLib); // Create Mesh grid // Add Grid to Mapper Mapper.SetInput(Grid); Mapper.SetScalarModeToUseCellData(); Mapper.ScalarVisibilityOff(); Mapper.InterpolateScalarsBeforeMappingOn(); Mapper.Update(); Actor.SetMapper(Mapper); // Add Mapper to Actor Actor.GetProperty().SetEdgeVisibility(1); // Enable wireframe display mode Actor.GetProperty().SetLineWidth((float)0.5); // Set wireframe line thickness // Set Actor default color ColorID = ID % 13; SetColor(ColorID); // Outer features ExtractFeatures(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToUGrid(String [] argv) { //Prefix Content is: "" // Read a field representing unstructured grid and display it (similar to blow.tcl)[] // create a reader and write out field daya[] reader = new vtkUnstructuredGridReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/blow.vtk"); reader.SetScalarsName((string)"thickness9"); reader.SetVectorsName((string)"displacement9"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); // we must be able to write here[] try { channel = new StreamWriter("UGridField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if (tryCatchError.Equals("NOERROR")) { channel.Close(); write = new vtkDataObjectWriter(); write.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); write.SetFileName((string)"UGridField.vtk"); write.Write(); // Read the field and convert to unstructured grid.[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"UGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToUnstructuredGrid(); do2ds.SetPointComponent((int)0,(string)"Points",(int)0); do2ds.SetPointComponent((int)1,(string)"Points",(int)1); do2ds.SetPointComponent((int)2,(string)"Points",(int)2); do2ds.SetCellTypeComponent((string)"CellTypes",(int)0); do2ds.SetCellConnectivityComponent((string)"Cells",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetUnstructuredGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0,(string)"displacement9",(int)0); fd2ad.SetVectorComponent((int)1,(string)"displacement9",(int)1); fd2ad.SetVectorComponent((int)2,(string)"displacement9",(int)2); fd2ad.SetScalarComponent((int)0,(string)"thickness9",(int)0); // Now start visualizing[] warp = new vtkWarpVector(); warp.SetInput((vtkDataObject)fd2ad.GetUnstructuredGridOutput()); // extract mold from mesh using connectivity[] connect = new vtkConnectivityFilter(); connect.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect.SetExtractionModeToSpecifiedRegions(); connect.AddSpecifiedRegion((int)0); connect.AddSpecifiedRegion((int)1); moldMapper = new vtkDataSetMapper(); moldMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort()); moldMapper.ScalarVisibilityOff(); moldActor = new vtkActor(); moldActor.SetMapper((vtkMapper)moldMapper); moldActor.GetProperty().SetColor((double).2,(double).2,(double).2); moldActor.GetProperty().SetRepresentationToWireframe(); // extract parison from mesh using connectivity[] connect2 = new vtkConnectivityFilter(); connect2.SetInputConnection((vtkAlgorithmOutput)warp.GetOutputPort()); connect2.SetExtractionModeToSpecifiedRegions(); connect2.AddSpecifiedRegion((int)2); parison = new vtkGeometryFilter(); parison.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); normals2 = new vtkPolyDataNormals(); normals2.SetInputConnection((vtkAlgorithmOutput)parison.GetOutputPort()); normals2.SetFeatureAngle((double)60); lut = new vtkLookupTable(); lut.SetHueRange((double)0.0,(double)0.66667); parisonMapper = vtkPolyDataMapper.New(); parisonMapper.SetInputConnection((vtkAlgorithmOutput)normals2.GetOutputPort()); parisonMapper.SetLookupTable((vtkScalarsToColors)lut); parisonMapper.SetScalarRange((double)0.12,(double)1.0); parisonActor = new vtkActor(); parisonActor.SetMapper((vtkMapper)parisonMapper); cf = new vtkContourFilter(); cf.SetInputConnection((vtkAlgorithmOutput)connect2.GetOutputPort()); cf.SetValue((int)0,(double).5); contourMapper = vtkPolyDataMapper.New(); contourMapper.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort()); contours = new vtkActor(); contours.SetMapper((vtkMapper)contourMapper); // Create graphics stuff[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] ren1.AddActor((vtkProp)moldActor); ren1.AddActor((vtkProp)parisonActor); ren1.AddActor((vtkProp)contours); ren1.ResetCamera(); ren1.GetActiveCamera().Azimuth((double)60); ren1.GetActiveCamera().Roll((double)-90); ren1.GetActiveCamera().Dolly((double)2); ren1.ResetCameraClippingRange(); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)375,(int)200); iren.Initialize(); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void 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 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(); }