Esempio n. 1
0
 public static void main(String astring[]) {
   float f1 = 0.4F;
   float f2 = 0.4F;
   Ex63a ex63a = new Ex63a();
   vtkPanel VtkPanel = new vtkPanel();
   VtkPanel.setSize(400, 400);
   System.out.println("Here we go");
   vtkQuadric VtkQuadric = new vtkQuadric();
   VtkQuadric.SetCoefficients(1.0, 2.0, 3.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0);
   vtkSampleFunction VtkSampleFunction = new vtkSampleFunction();
   VtkSampleFunction.SetSampleDimensions(25, 25, 25);
   VtkSampleFunction.SetImplicitFunction(VtkQuadric);
   VtkSampleFunction.DebugOn();
   vtkContourFilter VtkContourFilter = new vtkContourFilter();
   VtkContourFilter.SetInput(VtkSampleFunction.GetOutput());
   VtkContourFilter.UseScalarTreeOn();
   VtkContourFilter.DebugOn();
   vtkPolyDataMapper VtkPolyDataMapper1 = new vtkPolyDataMapper();
   VtkPolyDataMapper1.SetInput(VtkContourFilter.GetOutput());
   VtkPolyDataMapper1.SetScalarRange(0.0, 7.0);
   vtkActor VtkActor1 = new vtkActor();
   VtkActor1.SetMapper(VtkPolyDataMapper1);
   VtkPanel.getRenderer().AddActor(VtkActor1);
   vtkOutlineFilter VtkOutlineFilter = new vtkOutlineFilter();
   VtkOutlineFilter.SetInput(VtkSampleFunction.GetOutput());
   vtkPolyDataMapper VtkPolyDataMapper2 = new vtkPolyDataMapper();
   VtkPolyDataMapper2.SetInput(VtkOutlineFilter.GetOutput());
   vtkActor VtkActor2 = new vtkActor();
   VtkActor2.SetMapper(VtkPolyDataMapper2);
   VtkActor2.GetProperty().SetColor(1.0, 1.0, 1.0);
   VtkPanel.getRenderer().AddActor(VtkActor2);
   ex63a.add("Center", VtkPanel);
   ex63a.pack();
   MenuBar menuBar = new MenuBar();
   Menu menu = new Menu("File");
   menu.add(new MenuItem("Exit"));
   menuBar.add(menu);
   ex63a.setMenuBar(menuBar);
   ex63a.show();
   for (float f3 = 0.0F; f3 < 12.0; f3++) {
     VtkContourFilter.SetValue(1, (double) (f1 + f3 * f2));
     VtkPanel.Render();
   }
 }
Esempio n. 2
0
  public static void main(String args[]) {
    vtkStructuredPointsReader reader = null;
    vtkActor isoActor = null;
    vtkPolyDataMapper isoMapper = null;

    MriIso f = new MriIso();
    f.vPanel = new vtkPanel2();
    f.vPanel.resize(400, 400);
    // f.savetofile = true;

    System.out.println("Here we go");

    reader = new vtkStructuredPointsReader();
    reader.SetFileName("MRIdata.vtk");

    f.cFilt = new vtkContourFilter();
    f.cFilt.SetValue(0, 225);
    f.cFilt.SetInput(reader.GetOutput());

    isoMapper = new vtkPolyDataMapper();
    isoMapper.SetInput(f.cFilt.GetOutput());

    isoActor = new vtkActor();
    isoActor.SetMapper(isoMapper);

    f.vPanel.GetRenderer().AddActor(isoActor);

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

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

    f.show();
  }
Esempio n. 3
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();
  }