]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/shape/vtkShape.java
Compiler warning elimination
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / shape / vtkShape.java
index 8157dfe36c86cd5c8e9b56851277c47e67b11489..45ecc35cbbbab3663bf5e0d708dd36320f84ff88 100644 (file)
@@ -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;
+    }
 
 }
+