Beispiel #1
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();
  }
Beispiel #2
0
  public static void main(String args[]) {
    vtkCamera camera;
    vtkPanel panel = new vtkPanel();
    Ex94a f = new Ex94a();

    vtkPLOT3DReader pl3d = new vtkPLOT3DReader();
    pl3d.SetXYZFileName("g:/vtkdata/combxyz.bin");
    pl3d.SetQFileName("g:/vtkdata/combq.bin");
    pl3d.SetScalarFunctionNumber(100);
    pl3d.SetVectorFunctionNumber(202);
    pl3d.Update();

    vtkPlaneSource plane = new vtkPlaneSource();
    plane.SetResolution(50, 50);

    vtkTransform transP1 = new vtkTransform();
    transP1.Translate(3.7, 0.0, 28.37);
    transP1.Scale(5, 5, 5);
    transP1.RotateY(90);

    vtkTransformPolyDataFilter tpd1 = new vtkTransformPolyDataFilter();
    tpd1.SetInput(plane.GetOutput());
    tpd1.SetTransform(transP1);

    vtkOutlineFilter outTpd1 = new vtkOutlineFilter();
    outTpd1.SetInput(tpd1.GetOutput());

    vtkPolyDataMapper mapTpd1 = new vtkPolyDataMapper(); // same as vtkPolyMapper in tcl
    mapTpd1.SetInput(outTpd1.GetOutput());

    vtkActor tpd1Actor = new vtkActor();
    tpd1Actor.SetMapper(mapTpd1);
    tpd1Actor.GetProperty().SetColor(0, 0, 0);

    vtkTransform transP2 = new vtkTransform();
    transP2.Translate(9.2, 0.0, 31.20);
    transP2.Scale(5, 5, 5);
    transP2.RotateY(90);

    vtkTransformPolyDataFilter tpd2 = new vtkTransformPolyDataFilter();
    tpd2.SetInput(plane.GetOutput());
    tpd2.SetTransform(transP2);

    vtkOutlineFilter outTpd2 = new vtkOutlineFilter();
    outTpd2.SetInput(tpd2.GetOutput());

    vtkPolyDataMapper mapTpd2 = new vtkPolyDataMapper();
    mapTpd2.SetInput(outTpd2.GetOutput());

    vtkActor tpd2Actor = new vtkActor();
    tpd2Actor.SetMapper(mapTpd2);
    tpd2Actor.GetProperty().SetColor(0, 0, 0);

    vtkTransform transP3 = new vtkTransform();
    transP3.Translate(13.27, 0.0, 33.30);
    transP3.Scale(5, 5, 5);
    transP3.RotateY(90);

    vtkTransformPolyDataFilter tpd3 = new vtkTransformPolyDataFilter();
    tpd3.SetInput(plane.GetOutput());
    tpd3.SetTransform(transP3);

    vtkOutlineFilter outTpd3 = new vtkOutlineFilter();
    outTpd3.SetInput(tpd3.GetOutput());

    vtkPolyDataMapper mapTpd3 = new vtkPolyDataMapper();
    mapTpd3.SetInput(outTpd3.GetOutput());

    vtkActor tpd3Actor = new vtkActor();
    tpd3Actor.SetMapper(mapTpd3);
    tpd3Actor.GetProperty().SetColor(0, 0, 0);

    vtkAppendPolyData appendF = new vtkAppendPolyData();
    appendF.AddInput(tpd1.GetOutput());
    appendF.AddInput(tpd2.GetOutput());
    appendF.AddInput(tpd3.GetOutput());

    vtkProbeFilter probe = new vtkProbeFilter();
    probe.SetInput(appendF.GetOutput());
    probe.SetSource(pl3d.GetOutput());

    vtkHedgeHog hedgehog = new vtkHedgeHog(); // use hedgehog instead of contourfilter
    hedgehog.SetInput(probe.GetOutput());
    hedgehog.SetScaleFactor(0.015);

    vtkPolyDataMapper hedgehogMapper = new vtkPolyDataMapper();
    hedgehogMapper.SetInput(hedgehog.GetOutput());
    hedgehogMapper.SetScalarRange(pl3d.GetOutput().GetScalarRange());

    vtkActor planeActor = new vtkActor();
    planeActor.SetMapper(hedgehogMapper);

    vtkStructuredGridOutlineFilter outline = new vtkStructuredGridOutlineFilter();
    outline.SetInput(pl3d.GetOutput());

    vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
    outlineMapper.SetInput(outline.GetOutput());

    vtkActor outlineActor = new vtkActor();
    outlineActor.SetMapper(outlineMapper);
    outlineActor.GetProperty().SetColor(0, 0, 0);

    panel.getRenderer().AddActor(outlineActor);
    panel.getRenderer().AddActor(planeActor);
    panel.getRenderer().AddActor(tpd1Actor);
    panel.getRenderer().AddActor(tpd2Actor);
    panel.getRenderer().AddActor(tpd3Actor);
    panel.getRenderer().SetBackground(1, 1, 1);
    panel.setSize(500, 500);

    camera = panel.getRenderer().GetActiveCamera();
    camera.SetClippingRange(3.95297, 50);
    camera.SetFocalPoint(8.88908, 0.595038, 29.3342);
    camera.SetPosition(-12.3332, 31.7479, 41.2387);
    camera.ComputeViewPlaneNormal();
    camera.SetViewUp(0.060772, -0.319905, 0.945498);

    f.add("Center", panel);
    f.pack();

    // Set up the menu
    MenuBar mb = new MenuBar();
    Menu file = new Menu("File");
    file.add(new MenuItem("Exit"));
    mb.add(file);
    f.setMenuBar(mb);

    f.show();
  }