public void saveView(String filename) { BoundingSphere bs = _ipg.getBoundingSphere(true); Vector3 tvec = _view.getTranslate(); try { FileWriter fw = new FileWriter(filename); PrintWriter out = new PrintWriter(fw); out.println(bs.getRadius()); Point3 center = bs.getCenter(); out.printf("%f %f %f \n", center.x, center.y, center.z); out.println(_view.getAzimuth()); out.println(_view.getElevation()); out.println(_view.getScale()); out.printf("%f %f %f \n", tvec.x, tvec.y, tvec.z); Iterator<ImagePanel> itr = _ipg.getImagePanels(); while (itr.hasNext()) { ImagePanel ip = itr.next(); AxisAlignedFrame aaf = ip.getFrame(); Point3 min = aaf.getCornerMin(); Point3 max = aaf.getCornerMax(); out.printf("%f %f %f %f %f %f\n", min.x, min.y, min.z, max.x, max.y, max.z); } out.println(_pmax); out.println(_color.getCode()); out.close(); } catch (Exception e) { System.out.println(e); } }
public void loadView(String filename) { Point3 point; Vector3 tvec; double radius; double azimuth; double elevation; double scale; double x, y, z; double vx, vy, vz; try { if (_ipg == null) throw new Exception("Must load a cube first!"); Scanner s = new Scanner(new File(filename)); radius = s.nextDouble(); x = s.nextDouble(); y = s.nextDouble(); z = s.nextDouble(); point = new Point3(x, y, z); azimuth = s.nextDouble(); elevation = s.nextDouble(); scale = s.nextDouble(); vx = s.nextDouble(); vy = s.nextDouble(); vz = s.nextDouble(); tvec = new Vector3(vx, vy, vz); Iterator<ImagePanel> itr = _ipg.getImagePanels(); while (itr.hasNext()) { ImagePanel ip = itr.next(); AxisAlignedFrame aaf = ip.getFrame(); double lx = s.nextDouble(); double ly = s.nextDouble(); double lz = s.nextDouble(); double mx = s.nextDouble(); double my = s.nextDouble(); double mz = s.nextDouble(); Point3 min = new Point3(lx, ly, lz); Point3 max = new Point3(mx, my, mz); aaf.setCorners(min, max); } _pmax = s.nextFloat(); int code = s.nextInt(); _color = ColorList.getMatch(code); setColorMap(); _view.setWorldSphere(new BoundingSphere(point, radius)); _view.setTranslate(tvec); _view.setAzimuth(azimuth); _view.setElevation(elevation); _view.setScale(scale); _ipg.setPercentiles(_pmin, _pmax); } catch (Exception e) { System.out.println("Failed to load view point!"); System.out.println(e); } }
public void addRSFTensorEllipsoids() { _tpx = new TensorsPanel(_s1, _s2, _s3, _d); _tpy = new TensorsPanel(_s1, _s2, _s3, _d); ImagePanel ipx = _ipg.getImagePanel(Axis.X); ImagePanel ipy = _ipg.getImagePanel(Axis.Y); ipx.getFrame().addChild(_tpx); ipy.getFrame().addChild(_tpy); _tpx.setEllipsoidSize(8); _tpy.setEllipsoidSize(8); }
public Haikdu(String filename) { try { familySource.Open(filename); int success = wrappedSource.Open(familySource, true); if (success < 0) { familySource.Close(); wrappedSource.Close(); rawSource = new Kdu_simple_file_source(filename); } if (rawSource != null) compositor.Create(rawSource); else compositor.Create(wrappedSource); int numThreads = Kdu_global.Kdu_get_num_processors(); threadEnv.Create(); for (int thread = 1; thread < numThreads; thread++) if (!threadEnv.Add_thread()) numThreads = thread; compositor.Set_thread_env(threadEnv, null); compositor.Add_ilayer(0, new Kdu_dims(), new Kdu_dims()); compositor.Set_scale(false, false, false, 0.050f); // Determine dimensions for the rendered result and start processing. compositor.Get_total_composition_dims(viewDims); viewSize = viewDims.Access_size(); // Construct Swing frame imagePanel = new ImagePanel(viewSize); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); getContentPane().add("Center", imagePanel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setTitle("Haikdu"); setVisible(true); repaint(); Kdu_coords displaySize = new Kdu_coords(imagePanel.getWidth(), imagePanel.getHeight()); if (viewSize.Get_x() > displaySize.Get_x()) viewSize.Set_x(displaySize.Get_y()); if (viewSize.Get_y() > displaySize.Get_y()) viewSize.Set_y(displaySize.Get_y()); compositor.Set_buffer_surface(viewDims); compositorBuffer = compositor.Get_composition_buffer(viewDims); } catch (KduException e) { System.err.printf("Caught exception during Kdu object construction: %s\n", e.getMessage()); } render(); }
public void render() { try { int regionBufferSize = 0; int[] regionBuffer = null; Kdu_dims newRegion = new Kdu_dims(); long kduRenderStart = System.nanoTime(); while (compositor.Process(100000, newRegion)) { Kdu_coords newOffset = newRegion.Access_pos(); Kdu_coords newSize = newRegion.Access_size(); newOffset.Subtract(viewDims.Access_pos()); int newPixels = newSize.Get_x() * newSize.Get_y(); if (newPixels == 0) continue; else if (newPixels > regionBufferSize) { regionBufferSize = newPixels; regionBuffer = new int[regionBufferSize]; } compositorBuffer.Get_region(newRegion, regionBuffer); imagePanel.putRegion( viewSize.Get_x(), viewSize.Get_y(), newSize.Get_x(), newSize.Get_y(), newOffset.Get_x(), newOffset.Get_y(), regionBuffer); } long kduRenderEnd = System.nanoTime(); System.out.printf( "Processed using %d concurrent threads of execution in %.4fms\n", threadEnv.Get_num_threads(), (kduRenderEnd - kduRenderStart) * 1e-6); imagePanel.repaint(); } catch (KduException e) { System.err.printf( "Caught exception '%s'; code '%s'\n", e.getMessage(), Integer.toHexString(e.Get_kdu_exception_code())); } }