X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Fshape%2FvtkShape.java;h=45ecc35cbbbab3663bf5e0d708dd36320f84ff88;hb=refs%2Fchanges%2F60%2F3460%2F1;hp=8157dfe36c86cd5c8e9b56851277c47e67b11489;hpb=53d55c24c779745f188bdb18d32f71d20acb61b2;p=simantics%2F3d.git diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/shape/vtkShape.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/shape/vtkShape.java index 8157dfe3..45ecc35c 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/shape/vtkShape.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/shape/vtkShape.java @@ -191,5 +191,41 @@ public class vtkShape { return aLineActor; } + + public static vtkActor createLineActor(Tuple3d... p) { + vtkPoints linePoints = new vtkPoints(); + linePoints.SetNumberOfPoints(p.length); + + for (int i = 0; i < p.length; i++) { + Tuple3d p1 = p[i]; + linePoints.InsertPoint(i,p1.x, p1.y, p1.z); + + } + vtkUnstructuredGrid aLineGrid = new vtkUnstructuredGrid(); + //aLineGrid.Allocate(1, 1); + for (int i = 0; i< p.length -1; i++) { + vtkLine aLine = new vtkLine(); + aLine.GetPointIds().SetId(0, i); + aLine.GetPointIds().SetId(1, i+1); + aLineGrid.InsertNextCell(aLine.GetCellType(), aLine.GetPointIds()); + aLine.GetPointIds().Delete(); + aLine.Delete(); + } + + aLineGrid.SetPoints(linePoints); + vtkDataSetMapper aLineMapper = new vtkDataSetMapper(); + aLineMapper.SetInputData(aLineGrid); + vtkActor aLineActor = new vtkActor(); + aLineActor.SetMapper(aLineMapper); + //aLineActor.GetProperty().SetDiffuseColor(.2, 1, 1); + + linePoints.Delete(); + + aLineGrid.Delete(); + aLineMapper.Delete(); + + return aLineActor; + } } +