public void SetPosition(double[] xyz1, double[] xyz2) { vtkPoints points = vtkPoints.New(); points.InsertPoint(0, xyz1[0], xyz1[1], xyz1[2]); points.InsertPoint(1, xyz2[0], xyz2[1], xyz2[2]); vtkCellArray lines = vtkCellArray.New(); lines.InsertNextCell(2); lines.InsertCellPoint(0); lines.InsertCellPoint(1); vtkPolyData profileData = new vtkPolyData(); profileData.SetPoints(points); profileData.SetLines(lines); profileData.SetVerts(lines); profileData.Update(); vtkCleanPolyData cleanFilter = new vtkCleanPolyData(); cleanFilter.SetInput(profileData); cleanFilter.Update(); vtkTubeFilter profileTubes = new vtkTubeFilter(); profileTubes.SetNumberOfSides(10); profileTubes.SetInput(cleanFilter.GetOutput()); //profileTubes.SetVaryRadiusToVaryRadiusByVector(); profileTubes.SetRadius(1); profileTubes.SetInputArrayToProcess(1, 0, 0, 0, "vectors"); //vtkPolyDataMapper profileMapper = new vtkPolyDataMapper(); //profileMapper.SetInputConnection(profileTubes.GetOutputPort()); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInput(profileTubes.GetOutput()); centerLineActor.SetMapper(mapper); centerLineActor.GetProperty().SetOpacity(0.5); }
public static vtkPolyData Create(List <double[]> xyz1, double radius) { vtkPoints points = new vtkPoints(); for (int index = 0; index < xyz1.Count; index++) { double[] doubles = xyz1[index]; points.InsertPoint(index, doubles[0], doubles[1], doubles[2]); } vtkCellArray lines = new vtkCellArray(); lines.InsertNextCell(xyz1.Count); for (int index = 0; index < xyz1.Count; index++) { lines.InsertCellPoint(index); } vtkPolyData profileData = new vtkPolyData(); profileData.SetPoints(points); profileData.SetLines(lines); profileData.SetVerts(lines); profileData.Update(); vtkCleanPolyData cleanFilter = new vtkCleanPolyData(); cleanFilter.SetInput(profileData); cleanFilter.Update(); vtkTubeFilter profileTubes = new vtkTubeFilter(); profileTubes.SetNumberOfSides(10); profileTubes.SetInput(cleanFilter.GetOutput()); //profileTubes.SetVaryRadiusToVaryRadiusByVector(); profileTubes.SetRadius(radius); profileTubes.SetInputArrayToProcess(1, 0, 0, 0, "vectors"); return(profileTubes.GetOutput()); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestRectilinearGridToTetrahedra(String[] argv) { //Prefix Content is: "" //## SetUp the pipeline[] FormMesh = new vtkRectilinearGridToTetrahedra(); FormMesh.SetInput((double)4, (double)2, (double)2, (double)1, (double)1, (double)1, (double)0.001); FormMesh.RememberVoxelIdOn(); TetraEdges = new vtkExtractEdges(); TetraEdges.SetInputConnection((vtkAlgorithmOutput)FormMesh.GetOutputPort()); tubes = new vtkTubeFilter(); tubes.SetInputConnection((vtkAlgorithmOutput)TetraEdges.GetOutputPort()); tubes.SetRadius((double)0.05); tubes.SetNumberOfSides((int)6); //## Run the pipeline 3 times, with different conversions to TetMesh[] Tubes[0] = new vtkPolyData(); FormMesh.SetTetraPerCellTo5(); tubes.Update(); Tubes[0].DeepCopy((vtkDataObject)tubes.GetOutput()); Tubes[1] = new vtkPolyData(); FormMesh.SetTetraPerCellTo6(); tubes.Update(); Tubes[1].DeepCopy((vtkDataObject)tubes.GetOutput()); Tubes[2] = new vtkPolyData(); FormMesh.SetTetraPerCellTo12(); tubes.Update(); Tubes[2].DeepCopy((vtkDataObject)tubes.GetOutput()); //## Run the pipeline once more, this time converting some cells to[] //## 5 and some data to 12 TetMesh[] //## Determine which cells are which[] DivTypes = new vtkIntArray(); numCell = (long)((vtkDataSet)FormMesh.GetInput()).GetNumberOfCells(); DivTypes.SetNumberOfValues((int)numCell); i = 0; while ((i) < numCell) { DivTypes.SetValue((int)i, (int)5 + (7 * (i % 4))); i = i + 1; } //## Finish this pipeline[] Tubes[3] = new vtkPolyData(); FormMesh.SetTetraPerCellTo5And12(); ((vtkRectilinearGrid)FormMesh.GetInput()).GetCellData().SetScalars(DivTypes); tubes.Update(); Tubes[3].DeepCopy((vtkDataObject)tubes.GetOutput()); //## Finish the 4 pipelines[] i = 1; while ((i) < 5) { mapEdges[i] = vtkPolyDataMapper.New(); mapEdges[i].SetInputData((vtkPolyData)Tubes[i - 1]); edgeActor[i] = new vtkActor(); edgeActor[i].SetMapper((vtkMapper)mapEdges[i]); edgeActor[i].GetProperty().SetColor((double)0.2000, 0.6300, 0.7900); edgeActor[i].GetProperty().SetSpecularColor((double)1, (double)1, (double)1); edgeActor[i].GetProperty().SetSpecular((double)0.3); edgeActor[i].GetProperty().SetSpecularPower((double)20); edgeActor[i].GetProperty().SetAmbient((double)0.2); edgeActor[i].GetProperty().SetDiffuse((double)0.8); ren[i] = vtkRenderer.New(); ren[i].AddActor((vtkProp)edgeActor[i]); ren[i].SetBackground((double)0, (double)0, (double)0); ren[i].ResetCamera(); ren[i].GetActiveCamera().Zoom((double)1); ren[i].GetActiveCamera().SetPosition((double)1.73906, (double)12.7987, (double)-0.257808); ren[i].GetActiveCamera().SetViewUp((double)0.992444, (double)0.00890284, (double)-0.122379); ren[i].GetActiveCamera().SetClippingRange((double)9.36398, (double)15.0496); i = i + 1; } // Create graphics objects[] // Create the rendering window, renderer, and interactive renderer[] renWin = vtkRenderWindow.New(); renWin.AddRenderer(ren[1]); renWin.AddRenderer(ren[2]); renWin.AddRenderer(ren[3]); renWin.AddRenderer(ren[4]); renWin.SetSize(600, 300); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] ren[1].SetViewport((double).75, (double)0, (double)1, (double)1); ren[2].SetViewport((double).50, (double)0, (double).75, (double)1); ren[3].SetViewport((double).25, (double)0, (double).50, (double)1); ren[4].SetViewport((double)0, (double)0, (double).25, (double)1); // render the image[] //[] iren.Initialize(); // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }