]> 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 c992547fa76bce98a041f8a2501733bc729ef861..45ecc35cbbbab3663bf5e0d708dd36320f84ff88 100644 (file)
@@ -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;
+    }
 
 }
+