public IcyVtkPanel() {
    super();

    // picker
    // picker = new vtkPropPicker();
    // picker.PickFromListOff();

    picker = new vtkCellPicker();
    picker.PickFromListOff();

    // set ambient color to white
    lgt.SetAmbientColor(1d, 1d, 1d);
    lightFollowCamera = true;

    // assign default renderer to layer 0 (should be the case by default)
    ren.SetLayer(0);

    // initialize axis
    axisRenderer = new vtkRenderer();
    // BUG: with OpenGL window the global render window viewport is limited to the last layer
    // viewport dimension
    // axisRenderer.SetViewport(0.0, 0.0, 0.2, 0.2);
    axisRenderer.SetLayer(1);
    axisRenderer.InteractiveOff();

    rw.AddRenderer(axisRenderer);
    rw.SetNumberOfLayers(2);

    axisCam = axisRenderer.GetActiveCamera();

    axis = new vtkAxesActor();
    axisRenderer.AddActor(axis);

    // default axis offset and scale
    axisOffset = new int[] {124, 124};
    axisScale = 1;

    // reset camera
    axisCam.SetViewUp(0, -1, 0);
    axisCam.Elevation(210);
    axisCam.SetParallelProjection(1);
    axisRenderer.ResetCamera();
    axisRenderer.ResetCameraClippingRange();

    // used for restore quality rendering after a given amount of time
    fineRenderingTime = 0;
    renderingMonitor = new Thread(this, "VTK panel rendering monitor");
    renderingMonitor.start();

    addMouseListener(this);
    addMouseMotionListener(this);
    addMouseWheelListener(this);
    addKeyListener(this);
  }
Exemple #2
0
  /** @param args */
  public static void main(String[] args) {

    vtkPLYReader face1 = new vtkPLYReader();
    face1.SetFileName("/home/m2ivi/vanegue/Documents/VisA/tp4/3Dmodels/Model1.ply");
    face1.Update();
    vtkPLYReader face2 = new vtkPLYReader();
    face2.SetFileName("/home/m2ivi/vanegue/Documents/VisA/tp4/3Dmodels/Model2.ply");
    face2.Update();

    vtkIterativeClosestPointTransform recal = new vtkIterativeClosestPointTransform();
    recal.SetSource(face1.GetOutput());
    recal.SetTarget(face2.GetOutput());
    recal.SetMaximumNumberOfLandmarks(5000);
    recal.GetLandmarkTransform().SetModeToRigidBody();
    recal.StartByMatchingCentroidsOn();
    recal.SetMaximumNumberOfIterations(1);
    recal.Modified();
    recal.Update();

    vtkTransformPolyDataFilter tpd = new vtkTransformPolyDataFilter();
    tpd.SetInput(face1.GetOutput());
    tpd.SetTransform(recal);
    tpd.Update();

    vtkPolyDataMapper map = new vtkPolyDataMapper();
    map.SetInput(tpd.GetOutput());
    vtkPolyDataMapper map2 = new vtkPolyDataMapper();
    map2.SetInput(face2.GetOutput());

    vtkActor actorFace1 = new vtkActor();
    actorFace1.SetMapper(map);
    actorFace1.GetProperty().SetColor(0, 0, 1);
    vtkActor actorFace2 = new vtkActor();
    actorFace2.SetMapper(map2);
    actorFace2.GetProperty().SetColor(0, 1, 0);

    vtkRenderer ren1 = new vtkRenderer();
    ren1.AddActor(actorFace1);
    ren1.AddActor(actorFace2);
    ren1.SetBackground(1, 1, 1);

    vtkRenderWindow renWin = new vtkRenderWindow();
    renWin.AddRenderer(ren1);
    renWin.SetSize(500, 500);

    vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
    iren.SetRenderWindow(renWin);
    renWin.Render();
    iren.Start();
  }