[vtkusers] how to build a vtkTetra with arcs
Leguay Romain
romain.leguay at etu.u-bordeaux1.fr
Mon May 31 09:52:02 EDT 2010
Good afternoon everyone!
I a new user with VTK. For a college work, I need to create a
tetrahedron with arcs instead of "classic" edge.
I found some examples to create some arcs from a random graph source
(http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Infovis/Testing/Cxx/TestArcEdges.cxx?root=VTK&content-type=text/plain) but I can't find any examples for the vtkGeoArcs or
vtkArcsSource.
I work in Java environment with VTK 5.6.
Regards,
Romain LEGUAY
PS: I try to execute the following code but my tetrahedron doesn't appear.
package tetra;
import vtk.vtkActor;
import vtk.vtkArcSource;
import vtk.vtkDataSetMapper;
import vtk.vtkGeoArcs;
import vtk.vtkPoints;
import vtk.vtkPolygon;
import vtk.vtkRenderWindow;
import vtk.vtkRenderWindowInteractor;
import vtk.vtkRenderer;
import vtk.vtkTetra;
import vtk.vtkUnstructuredGrid;
public class TestTetraArcs {
static {
System.loadLibrary("vtkCommonJava");
System.loadLibrary("vtkFilteringJava");
System.loadLibrary("vtkIOJava");
System.loadLibrary("vtkImagingJava");
System.loadLibrary("vtkGraphicsJava");
System.loadLibrary("vtkRenderingJava");
System.loadLibrary("vtkGeovisJava");
}
public static void main(String[] args) {
//Tableau de points
vtkPoints points = new vtkPoints();
//points.SetDataTypeToDouble();
double[] p1 = {0,0,0};
double[] p2 = {-1,0,0};
double[] p3 = {0.5,1,0};
double[] p4 = {0.5,0.5,1};
points.SetNumberOfPoints(4);
points.InsertPoint(0, p1);
points.InsertPoint(1, p2);
points.InsertPoint(2, p3);
points.InsertPoint(3, p4);
//Cellule de type tetraèdre
vtkTetra tetra = new vtkTetra();
tetra.GetPointIds().SetId(0, 0);
tetra.GetPointIds().SetId(1, 1);
tetra.GetPointIds().SetId(2, 2);
tetra.GetPointIds().SetId(3, 3);
vtkUnstructuredGrid tetraGrid = new vtkUnstructuredGrid();
//tetraGrid.Allocate(1, 1);
tetraGrid.InsertNextCell(tetra.GetCellType(), tetra.GetPointIds());
tetraGrid.SetPoints(points);
vtkGeoArcs arcs = new vtkGeoArcs();
arcs.AddInput(tetraGrid);
arcs.Update();
vtkDataSetMapper tetraMapper = new vtkDataSetMapper();
tetraMapper.AddInputConnection(arcs.GetOutputPort());
vtkActor tetraActor = new vtkActor();
tetraActor.SetMapper(tetraMapper);
// Nous créons un renderer qui va faire le rendu de notre entitée.
vtkRenderer renderer = new vtkRenderer();
renderer.AddActor(tetraActor);
renderer.SetBackground(0, 0.5, 1);
// Nous créons une fenêtre de rendu
vtkRenderWindow win = new vtkRenderWindow();
win.AddRenderer(renderer);
win.SetSize(640,480);
// Nous créons un interactor qui permet de bouger la caméra.
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(win);
// Nous lançons le rendu et l'interaction
win.Render();
iren.Start();
}
}
More information about the vtkusers
mailing list