It's a series of calls. If you are using Eclipse, the thing to do is put a
breakpoint in and walk through it a few times. The Jvxl.java application is
a streamlined version. You might want to try that. Though the Jmol
application will let you quickly load files and such. One of the tricky
parts is that these are all set up in modules so that they use APIs and can
be loaded independently for the applet. For writing, at least, just take a
look at ASimpleJvxlWriter.java:

public class ASimpleJvxlWriter {

  // example for how to create simple JVXL files from cube data
  // no color mapping, no planes, just simple surfaces.

  public static void main(String[] args) {

    // parameters that need setting:

    String outputFile = "c:/temp/simple.jvxl";
    float cutoff = 0.01f;
    boolean isCutoffAbsolute = false;
    int nX = 31;
    int nY = 31;
    int nZ = 31;

    /*
     * timing: SimpleMarchingCubes with 100,100,100:
     *
     * getEdgeData: 641 ms
     * getEdgeData: 1625 ms
     *
     * old getEdgeData: 688 ms
     * old getEdgeData: 1672 ms
     *
     */
    String title = "created by SimpleJvxlWriter "
        + new SimpleDateFormat("yyyy-MM-dd', 'HH:mm").format(new Date())
        + "\naddional comment line\n";

    VolumeData volumeData;
    VoxelDataCreator vdc;
    JvxlData jvxlData;

    volumeData = new VolumeData();
    volumeData.setVolumetricOrigin(0, 0, 0);
    volumeData.setVolumetricVector(0, 1f, 0f, 0f);
    volumeData.setVolumetricVector(1, 0f, 1f, 0f);
    volumeData.setVolumetricVector(2, 0f, 0f, 1f);
    volumeData.setUnitVectors();
    volumeData.setVoxelCounts(nX, nY, nZ);

    vdc = new VoxelDataCreator(volumeData);
    vdc.createVoxelData();
    jvxlData = new JvxlData();
    jvxlData.cutoff = cutoff;
    jvxlData.isCutoffAbsolute = isCutoffAbsolute;

    // areaVolumeReturn and surfacePointsReturn are optional
    // -- set to null for faster calculation of JVXL data

    float[] areaVolumeReturn = new float[2]; // or null;
    Vector surfacePointsReturn = new Vector(); // or null;

    jvxlData.isXLowToHigh = false;
    writeFile(outputFile + "A", JvxlWrite.jvxlGetData(null, jvxlData,
        volumeData, title, surfacePointsReturn, areaVolumeReturn));

    if (areaVolumeReturn != null)
      System.out.println("calculated area = " + areaVolumeReturn[0]
                         + " volume = " + areaVolumeReturn[1]
                         + " for " + surfacePointsReturn.size()
                         + " surface points");
    // streaming option: null voxelData
    volumeData.setVoxelData(null);
    jvxlData.isXLowToHigh = true;
    writeFile(outputFile + "B", JvxlWrite.jvxlGetData(vdc, jvxlData,
        volumeData, title, surfacePointsReturn, areaVolumeReturn));

    System.out.flush();
    System.exit(0);
  }

  static void writeFile(String fileName, String text) {
    try {
      FileOutputStream os = new FileOutputStream(fileName);
      BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os),
8192);
      bw.write(text);
      bw.close();
      os = null;
    } catch (IOException e) {
      System.out.println("IO Exception: " + e.toString());
    }
  }

}


On Mon, Jul 20, 2009 at 9:26 AM, Sam Bryfczynski <sbry...@gmail.com> wrote:

> Thanks for the help! Sorry I had not posted in the right mailing list.  So
> in order to read a jvxl file you need to perform the marching cubes
> algorithm?  I thought it was just for the creation of the file.  In that
> case, I am going to try and create a command line program that uses your
> code and takes a jvxl filename as input and then writes polygon data as
> output.  So, I guess my hang up now is what is the main function that is
> called to open a jvxl file?  I am looking at JvxlReader and its inherited
> classes VolumeFileReader, SurfaceFileReader, etc and trying to figure out
> what needs to be called to reach the final MeshData where I believe the
> vertices and polygon indices are found.  Is it just a matter of initialized
> a JvxlReader and letting the constructor keep calling super() constructors
> until the process finishes or do I need to call something else after the
> JvxlReader has been initialized? Thanks for all the help!
> ----------------------------
> Sam Bryfczynski
> Computer Science
> Clemson University
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Jmol-developers mailing list
> Jmol-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to