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=c992547fa76bce98a041f8a2501733bc729ef861;hpb=9783d236a085584ac964444b365b566fd6a921ba;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 c992547f..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 @@ -148,14 +148,14 @@ public class vtkShape { linePoints.Delete(); aLine.GetPointIds().Delete(); - aLine.Delete(); - aLineGrid.Delete(); - aLineMapper.Delete(); - - aLineActor.GetProperty().SetColor(0, 0, 0); - aLineActor.GetProperty().Delete(); - - return aLineActor; + aLine.Delete(); + aLineGrid.Delete(); + aLineMapper.Delete(); + + aLineActor.GetProperty().SetColor(0, 0, 0); + aLineActor.GetProperty().Delete(); + + return aLineActor; } /** @@ -182,14 +182,50 @@ public class vtkShape { vtkActor aLineActor = new vtkActor(); aLineActor.SetMapper(aLineMapper); //aLineActor.GetProperty().SetDiffuseColor(.2, 1, 1); - - linePoints.Delete(); - aLine.GetPointIds().Delete(); - aLine.Delete(); - aLineGrid.Delete(); - aLineMapper.Delete(); - - return aLineActor; + + linePoints.Delete(); + aLine.GetPointIds().Delete(); + aLine.Delete(); + aLineGrid.Delete(); + aLineMapper.Delete(); + + 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; + } } +