1 package org.simantics.g3d.vtk.shape;
3 import org.simantics.g3d.shape.Mesh;
4 import org.simantics.g3d.vtk.common.VtkView;
5 import org.simantics.utils.threads.ThreadUtils;
7 import vtk.vtkRenderer;
9 public class vtkMeshObject {
11 private VtkView panel;
14 private MeshActor meshActor;
16 public vtkMeshObject(VtkView panel, Mesh mesh) {
21 public void visualizeMesh() {
23 meshActor = new MeshActor();
24 meshActor.setMesh(mesh);
25 //System.out.println("Set mesh " + mesh.getVertices().size() + " " + mesh.getIndices().size() + " " + this);
29 public MeshActor getActor() {
30 assert (Thread.currentThread() == panel.getThreadQueue().getThread());
34 public void showActorsVTK() {
35 //System.out.println("showActorsAWT " + this + " " + meshActor != null);
36 assert (Thread.currentThread() == panel.getThreadQueue().getThread());
38 vtkRenderer ren = panel.getRenderer();
39 if (meshActor != null)
40 ren.AddActor(meshActor);
44 public void showActors() {
45 ThreadUtils.asyncExec(panel.getThreadQueue(), new Runnable() {
54 public void clearActorsVTK() {
55 assert (Thread.currentThread() == panel.getThreadQueue().getThread());
57 if (meshActor == null)
59 //System.out.println("clearActorsAwt " + this);
60 vtkRenderer ren = panel.getRenderer();
64 if (meshActor.GetVTKId() != 0) {
65 ren.RemoveActor(meshActor);
72 private void clearActorsVTK(MeshActor meshActor) {
73 assert (Thread.currentThread() == panel.getThreadQueue().getThread());
75 if (meshActor == null)
77 //System.out.println("clearActorsAwt2 " + this);
78 vtkRenderer ren = panel.getRenderer();
82 if (meshActor.GetVTKId() != 0) {
83 ren.RemoveActor(meshActor);
90 public void clearActors() {
91 if (meshActor == null)
93 ThreadUtils.asyncExec(panel.getThreadQueue(), new Runnable() {
97 clearActorsVTK(meshActor);
102 public void dispose() {
107 public void delete() {