Class FileSurface_WM

java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.Interface.FileSurface_WM

public class FileSurface_WM extends Object
FileSurface. Reads and writes surface files for the JPanelSurface class. When surface files are loaded by the user in the JPanelSurface.java class through the "Add" button, when surfaces are loaded as surfaces attached to .xml image files, or surfaces loaded through the FlyThruRender class. Any time a surface file is read from disk for display in the JPanelSurface (SurfaceRender) class the FileSurface.java class is used to provide the interface. Loaded surfaces are returned in an array of SurfaceAttributes[] which are then used to add the surfaces to the SurfaceRender scene graph.

This class also handles saving files from the JPanelSurface class. Surfaces are saved as surface files (.sur), single-level (.wrl), multi-level (.wrl) or XML surfaces (.xml).

See Also:
  • invalid reference
    JPanelSurface.java
  • invalid reference
    SurfaceRender.java
  • invalid reference
    SurfaceAttributes.java
  • invalid reference
    FileSurfaceXML.java
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static float[]
    image volume bounding box.
    private static float[]
    coordinate used to transform data point from image coordinate to dicom coordinate
    private javax.vecmath.Point3f[]
     
    private static boolean
    flag indicates to read dicom matrix or not.
    private static File
    dicom matrix file.
    private static int[]
    image x, y, z orientation.
    private static boolean
    flag indicates to flip y, z coordinate or not.
    private static double[][]
    inverse dicom matrix array.
    private static TransMatrix
    inverset dicom matrix.
    private WildMagic.LibFoundation.Mathematics.Vector3f[]
     
    private static float[]
    image start location.
    private int[]
     
    private static float[]
    coordinate used to transform data point from image coordinate to dicom coordinate.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static WildMagic.LibGraphics.SceneGraph.VertexBuffer
    convertVertex(ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Convert the vertex from display space to dicom space.
    private static String
    getFileName(boolean bLoad)
    Calls a dialog to get a file name.
    private static WildMagic.LibGraphics.Detail.CollapseRecord
    Support for loading the collapse records from a binary file.
    static WildMagic.LibGraphics.Detail.ClodMesh
    loadCMesh(RandomAccessFile kIn, ViewJProgressBar pBar, int added, int piece)
    Load the clod mesh from a binary file.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    loadGiftiXMLMesh(String absPath, String fileName, String dir)
    Read Gifti mesh from file.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    loadPlyAsciiMesh(File file, ModelImage kImage, boolean isFileCoords)
    Read a TriMesh from a Ply ascii file.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    Load the STL ASCII file.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    Load the STL ASCII file.
    static WildMagic.LibGraphics.SceneGraph.TriMesh
    loadTMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean isVisible, WildMagic.LibGraphics.Rendering.MaterialState kMaterial, float[] startLocation, float[] direction, float[] box)
    Load the TriMesh from a binary file.
    static WildMagic.LibGraphics.SceneGraph.TriMesh
    loadVRMLMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean flag, float[] startLocation, float[] direction, float[] box)
    Load the triangle mesh from a VRML file specifically written by MIPAV.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    loadVTKLegacyMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, String fileName)
    Load legacy VTK mesh.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    loadVTKXMLMesh(String absPath, String fileName, String dir)
    Read VTK mesh from file.
    private static File
    openDicomMatrixFiles(boolean bLoad)
    Returns a dicomMatrix file objects, based on the user-selected filed from the FileChooser dialog.
    static File[]
    openFiles(boolean bLoad)
    Returns an array of File objects, based on the user-selected files from the FileChooser dialog.
    static WildMagic.LibGraphics.SceneGraph.TriMesh[]
    The action taken when the Add button is clicked in the JPanelSurface class.
    static WildMagic.LibGraphics.SceneGraph.TriMesh[]
    openSurfaces(ModelImage kImage, boolean isFileCoords)
    The action taken when the Add button is clicked in the JPanelSurface class.
    static int
    Parses the VRML to see how many surfaces there are.
    private static void
    printAscii(PrintWriter kOut, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Print the contents of the TriMesh in ascii format.
    private static void
    printProstateSTLAscii(PrintWriter kOut, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Print the contents of the TriMesh in STL ascii format.
    private static void
    printSTLAscii(PrintWriter kOut, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Print the contents of the TriMesh in STL ascii format.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    readAscii(File kFile)
    Read a TriMesh from an ascii file.
    private void
    readFacetB(ByteBuffer in, int index)
    Method that reads a face in binary files All binary versions of the methods end by 'B' As in binary files we can read the number of faces, we don't need to use coordArray and normArray (reading binary files should be faster)
    private static String
    Read a line of ASCII text from the input stream.
    private static WildMagic.LibFoundation.Mathematics.Vector3f
    readPoint(StreamTokenizer tokenizer, String label)
    Find the given label in the tokenizer stream and then return the next three numbers as a point.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    Read the STL ASCII file as a single stream tokenizer.
    private static WildMagic.LibGraphics.SceneGraph.TriMesh
    Method for reading binary files Execution is completly different It uses ByteBuffer for reading data and ByteOrder for retrieving the machine's endian (Needs JDK 1.4) TO-DO: 1.
    static WildMagic.LibGraphics.SceneGraph.TriMesh
    readSurface(ModelImage kImage, File file, WildMagic.LibGraphics.Rendering.MaterialState kMaterial)
    Load a triangle mesh from the specified file and assign to it the MaterialState.
    static WildMagic.LibGraphics.SceneGraph.TriMesh
    readSurface(ModelImage kImage, File file, WildMagic.LibGraphics.Rendering.MaterialState kMaterial, boolean isFileCoords)
    Load a triangle mesh from the specified file and assign to it the MaterialState.
    static void
    save(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iType, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix)
    Save a TriMesh to disk
    static void
    save(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, ModelImage image, boolean transform)
     
    private static void
    saveAsGiftiXML(String fileName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Save the TriMesh in Gifti format.
    private static void
    saveAsTextFile(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Save the TriMesh as an ascii text file.
    protected static void
    saveAsVRML(PrintWriter kOut, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box)
    Saves the triangle mesh in VRML97 (VRML 2.0) format.
    private static void
    saveAsVRML(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box)
    Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).
    private static void
    saveAsVTKLegacy(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Save the TriMesh in VTK legacy format.
    private static void
    saveAsVTKXML(String fileName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Save the TriMesh in VTK format.
    static void
    saveClodMesh(String kName, WildMagic.LibGraphics.Detail.ClodMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix)
    Save ClodMesh to disk
    private static void
    saveCollapseRecord(RandomAccessFile kOut, WildMagic.LibGraphics.Detail.CollapseRecord kRecord)
    Support for saving the collapse records to a binary file.
    private static void
    saveProstatePlyMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Saves a single level of detail to a STL mesh file.
    private static void
    saveProstateSTLMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Saves a single level of detail to a STL ascii mesh file.
    static void
    saveProstateSurface(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, ModelImage keyImage)
    Save a TriMesh to disk
    private static void
    saveSingleMesh(ModelImage kImage, boolean isSur, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Saves a single level of detail to a mesh file.
    private static void
    saveSingleMesh(String name, ModelImage kImage, boolean isSur, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Saves a single level of detail to a mesh file.
    private static void
    saveSinglePlyMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Saves a single level of detail to a STL mesh file.
    private static void
    saveSingleSTLMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Saves a single level of detail to a STL mesh file.
    private static void
    saveSur(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iType, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix)
    Write the TriMesh to disk in the .sur format.
    static void
    saveSurfaces(ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh[] akSurfaces, String kCommand)
    The action taken when the one of the save surface buttons is pressed in the JPanelSurface class.
    private static void
    writeTriangleMeshXML(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
    Writes a TriMesh to disk in the xml format, based on surface.xsd.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • flip

      private static boolean flip
      flag indicates to flip y, z coordinate or not.
    • dicom

      private static boolean dicom
      flag indicates to read dicom matrix or not.
    • inverseDicomArray

      private static double[][] inverseDicomArray
      inverse dicom matrix array.
    • inverseDicomMatrix

      private static TransMatrix inverseDicomMatrix
      inverset dicom matrix.
    • direction

      private static int[] direction
      image x, y, z orientation.
    • startLocation

      private static float[] startLocation
      image start location.
    • box

      private static float[] box
      image volume bounding box.
    • tCoord

      private static float[] tCoord
      coordinate used to transform data point from image coordinate to dicom coordinate.
    • coord

      private static float[] coord
      coordinate used to transform data point from image coordinate to dicom coordinate
    • dicomMatrixFile

      private static File dicomMatrixFile
      dicom matrix file.
    • coordArray

      private javax.vecmath.Point3f[] coordArray
    • normArray

      private WildMagic.LibFoundation.Mathematics.Vector3f[] normArray
    • stripCounts

      private int[] stripCounts
  • Constructor Details

    • FileSurface_WM

      public FileSurface_WM()
  • Method Details

    • loadCMesh

      public static WildMagic.LibGraphics.Detail.ClodMesh loadCMesh(RandomAccessFile kIn, ViewJProgressBar pBar, int added, int piece)
      Load the clod mesh from a binary file. The caller must have already opened the file and read the mesh type (0 = TriMesh, 1 = ModelClodMesh) and the number of meshes in the file. The caller then calls this function for each mesh. The format for a mesh is
               int vCount;  // number of vertices
               Point3f vertices[vCount];
               Point3f normals[vCount];
               int iCount;  // number of indices in the connectivity array
               int indices[iCount];
               int rCount;
               ModelCollapseRecord collapses[rCount];
       
      with 4-byte quantities stored in Big Endian format.
      Parameters:
      kIn - the file from which the triangle mesh is loaded
      pBar - DOCUMENT ME!
      added - DOCUMENT ME!
      piece - DOCUMENT ME!
      Returns:
      the loaded triangle mesh
      Throws:
      IOException - if there is an error reading from the file
    • loadTMesh

      public static WildMagic.LibGraphics.SceneGraph.TriMesh loadTMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean isVisible, WildMagic.LibGraphics.Rendering.MaterialState kMaterial, float[] startLocation, float[] direction, float[] box)
      Load the TriMesh from a binary file. The caller must have already opened the file and read the mesh type (0 = TriMesh, 1 = ClodMesh) and the number of meshes in the file. The caller then calls this function for each mesh. The format for a mesh is
       int vCount; // number of vertices Point3f vertices[vCount]; Point3f
       normals[vCount]; int iCount; // number of indices in the connectivity array
       int indices[iCount];
      Parameters:
      kIn - file containing TriMesh data
      progress - progress bar
      added - number of meshes added so far
      total - total number of meshes to add
      isVisible - sets the visibility of the progress bar
      kMaterial - MaterialState for the new mesh
      startLocation - 3D location of the mesh
      direction - 3D orientation of the mesh
      box - mesh bounding box
      Returns:
      new TriMesh
    • loadVRMLMesh

      public static WildMagic.LibGraphics.SceneGraph.TriMesh loadVRMLMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean flag, float[] startLocation, float[] direction, float[] box)
      Load the triangle mesh from a VRML file specifically written by MIPAV. The caller must have already opened the file.
      Parameters:
      kIn - the file from which the triangle mesh is loaded
      progress - progress bar
      added - number of meshes added so far
      total - number of meshes to add
      flag - when true this is the first mesh, read header info.
      startLocation - 3D location of mesh
      direction - 3D orientation of mesh
      box - mesh bounding box
      Returns:
      new TriMesh
    • openSurfaces

      public static WildMagic.LibGraphics.SceneGraph.TriMesh[] openSurfaces(ModelImage kImage)
      The action taken when the Add button is clicked in the JPanelSurface class. A file dialog is launched that allows the user to select new surfaces to load from disk.
      Parameters:
      kImage - ModelImage for location/orientation and scale information.
      Returns:
      array of TriMesh objects.
    • openSurfaces

      public static WildMagic.LibGraphics.SceneGraph.TriMesh[] openSurfaces(ModelImage kImage, boolean isFileCoords)
      The action taken when the Add button is clicked in the JPanelSurface class. A file dialog is launched that allows the user to select new surfaces to load from disk.
      Parameters:
      kImage - ModelImage for location/orientation and scale information.
      Returns:
      array of TriMesh objects.
    • parseVRMLMesh

      public static int parseVRMLMesh(RandomAccessFile kIn) throws IOException, NoSuchElementException
      Parses the VRML to see how many surfaces there are.
      Parameters:
      kIn - the file to parse
      Returns:
      int value for the number of surfaces in the file.
      Throws:
      IOException
      NoSuchElementException
    • save

      public static void save(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, ModelImage image, boolean transform) throws IOException
      Throws:
      IOException
    • save

      public static void save(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iType, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix) throws IOException
      Save a TriMesh to disk
      Parameters:
      kName - file name
      kMesh - TriMesh
      iType - type of mesh TriMesh or ClodMesh
      kVBuffer - VertexBuffer
      flip - invert y,z values
      direction - 3D orientation of mesh
      startLocation - 3D location of mesh
      box - 3D bounding box
      inverseDicomMatrix - dicom matrix
      Throws:
      IOException - file I/O exception
    • saveProstateSurface

      public static void saveProstateSurface(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, ModelImage keyImage) throws IOException
      Save a TriMesh to disk
      Parameters:
      kName - file name
      kMesh - TriMesh
      keyImage - image
      Throws:
      IOException - file I/O exception
    • saveClodMesh

      public static void saveClodMesh(String kName, WildMagic.LibGraphics.Detail.ClodMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix)
      Save ClodMesh to disk
      Parameters:
      kName - file name
      akComponent - array of ClodMesh to save
      flip - invert y,z values
      direction - 3D mesh orientation
      startLocation - 3D mesh location
      box - mesh bounding box
      inverseDicomMatrix - dicom matrix
    • saveSurfaces

      public static void saveSurfaces(ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh[] akSurfaces, String kCommand)
      The action taken when the one of the save surface buttons is pressed in the JPanelSurface class. A file dialog is launched that allows the user to select where to save the surfaces.
      Parameters:
      kImage - the ModelImage displayed in the SurfaceRender class
      akSurfaces - an array of surfaces described by their SurfaceAttributes, containing information that is saved with the TriMesh
      kCommand - the type of save operation to perform
    • saveAsVRML

      protected static void saveAsVRML(PrintWriter kOut, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box)
      Saves the triangle mesh in VRML97 (VRML 2.0) format. File name should end with ".wrl"
      Parameters:
      kOut - the file to which the triangle mesh is saved
      flip - if the y and z axes should be flipped - true in extract and in save of JDialogSurface To have proper orientations in surface file if flip is true flip y and z on reading.
      direction - 1 or -1 for each axis
      startLocation - DOCUMENT ME!
      box - (dimension-1)*resolution
      color - DOCUMENT ME!
      Throws:
      IOException - if there is an error writing to the file
    • getFileName

      private static String getFileName(boolean bLoad)
      Calls a dialog to get a file name.
      Parameters:
      bLoad - if true, make it a load dialog.
      Returns:
      File name.
    • load

      private static WildMagic.LibGraphics.Detail.CollapseRecord load(RandomAccessFile kIn)
      Support for loading the collapse records from a binary file.
      Parameters:
      kIn - the file from which the records are loaded
      Returns:
      CollapseRecord
      Throws:
      IOException - if the there is an error reading from the file
    • loadPlyAsciiMesh

      private static WildMagic.LibGraphics.SceneGraph.TriMesh loadPlyAsciiMesh(File file, ModelImage kImage, boolean isFileCoords)
      Read a TriMesh from a Ply ascii file.
      Parameters:
      file - file storing the mesh
      Returns:
      TriMesh
    • loadSTLAsciiMesh

      private static WildMagic.LibGraphics.SceneGraph.TriMesh loadSTLAsciiMesh(File file, ModelImage kImage)
      Load the STL ASCII file.
      Parameters:
      file - STL surface file reference
      source - image
      Returns:
      TriMesh
    • loadVTKLegacyMesh

      private static WildMagic.LibGraphics.SceneGraph.TriMesh loadVTKLegacyMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, String fileName)
      Load legacy VTK mesh.
      Parameters:
      kIn - file containing mesh
      progress - progress bar
      added - number of meshes read from file so far
      total - total number of meshes in file
      flag - invert y,z values
      Returns:
      TriMesh
      Throws:
      IOException
    • loadVTKXMLMesh

      private static WildMagic.LibGraphics.SceneGraph.TriMesh loadVTKXMLMesh(String absPath, String fileName, String dir)
      Read VTK mesh from file.
      Parameters:
      absPath - file path
      fileName - file name
      dir - file directory
      Returns:
      TriMesh
    • loadGiftiXMLMesh

      private static WildMagic.LibGraphics.SceneGraph.TriMesh loadGiftiXMLMesh(String absPath, String fileName, String dir)
      Read Gifti mesh from file.
      Parameters:
      absPath - file path
      fileName - file name
      dir - file directory
      Returns:
      TriMesh
    • openFiles

      public static File[] openFiles(boolean bLoad)
      Returns an array of File objects, based on the user-selected files from the FileChooser dialog.
      Parameters:
      bLoad - whether the files are opened for reading (bLoad = true) or writing (bLoad = false)
      Returns:
      File[] array of opened files.
    • openDicomMatrixFiles

      private static File openDicomMatrixFiles(boolean bLoad)
      Returns a dicomMatrix file objects, based on the user-selected filed from the FileChooser dialog.
      Parameters:
      bLoad - whether the files are opened for reading (bLoad = true) or writing (bLoad = false)
      Returns:
      File of opened file.
    • printAscii

      private static void printAscii(PrintWriter kOut, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Print the contents of the TriMesh in ascii format.
      Parameters:
      kOut - output
      kMesh - TriMesh
    • printSTLAscii

      private static void printSTLAscii(PrintWriter kOut, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Print the contents of the TriMesh in STL ascii format.
      Parameters:
      kOut - output
      kMesh - TriMesh
    • printProstateSTLAscii

      private static void printProstateSTLAscii(PrintWriter kOut, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Print the contents of the TriMesh in STL ascii format.
      Parameters:
      kOut - output
      kMesh - TriMesh
    • readAscii

      private static WildMagic.LibGraphics.SceneGraph.TriMesh readAscii(File kFile) throws IOException
      Read a TriMesh from an ascii file.
      Parameters:
      kFile - file containing TriMesh
      Returns:
      TriMesh
      Throws:
      IOException - I/O exception
    • readLine

      private static String readLine(InputStream in) throws IOException
      Read a line of ASCII text from the input stream.
      Parameters:
      in - InputStream
      Returns:
      line of the ascii file as a String
      Throws:
      IOException - I/O exception
    • readPoint

      private static WildMagic.LibFoundation.Mathematics.Vector3f readPoint(StreamTokenizer tokenizer, String label) throws IOException
      Find the given label in the tokenizer stream and then return the next three numbers as a point. Return null if end of stream
      Parameters:
      tokenizer - stream in
      label - string label (vertex, normal ) in the STL ASCII file.
      Returns:
      Vector3f point coordinate.
      Throws:
      IOException
    • readSTLAscii

      private static WildMagic.LibGraphics.SceneGraph.TriMesh readSTLAscii(StreamTokenizer tokenizer, ModelImage kImage) throws IOException
      Read the STL ASCII file as a single stream tokenizer.
      Parameters:
      tokenizer - stream in
      Returns:
      Triangle mesh
      Throws:
      IOException
    • loadSTLBinaryMesh

      private static WildMagic.LibGraphics.SceneGraph.TriMesh loadSTLBinaryMesh(File file, ModelImage kImage)
      Load the STL ASCII file.
      Parameters:
      file - STL surface file reference
      source - image
      Returns:
      TriMesh
    • readSTLBinary

      private static WildMagic.LibGraphics.SceneGraph.TriMesh readSTLBinary(FileInputStream data, ModelImage kImage) throws IOException
      Method for reading binary files Execution is completly different It uses ByteBuffer for reading data and ByteOrder for retrieving the machine's endian (Needs JDK 1.4) TO-DO: 1.-Be able to read files over Internet 2.-If the amount of data expected is bigger than what is on the file then the program will block forever
      Parameters:
      file - The name of the file
      Throws:
      IOException
    • readFacetB

      private void readFacetB(ByteBuffer in, int index) throws IOException
      Method that reads a face in binary files All binary versions of the methods end by 'B' As in binary files we can read the number of faces, we don't need to use coordArray and normArray (reading binary files should be faster)
      Parameters:
      in - The ByteBuffer with the data of the object.
      index - The facet index
      Throws:
      IOException
    • readSurface

      public static WildMagic.LibGraphics.SceneGraph.TriMesh readSurface(ModelImage kImage, File file, WildMagic.LibGraphics.Rendering.MaterialState kMaterial)
      Load a triangle mesh from the specified file and assign to it the MaterialState.
      Parameters:
      kImage - ModelImage displayed in the SurfaceRender class
      file - The triangle mesh file to load.
      kMaterial - The Material for the surface.
      Returns:
      TriMesh
    • readSurface

      public static WildMagic.LibGraphics.SceneGraph.TriMesh readSurface(ModelImage kImage, File file, WildMagic.LibGraphics.Rendering.MaterialState kMaterial, boolean isFileCoords)
      Load a triangle mesh from the specified file and assign to it the MaterialState.
      Parameters:
      kImage - ModelImage displayed in the SurfaceRender class
      file - The triangle mesh file to load.
      kMaterial - The Material for the surface.
      Returns:
      TriMesh
    • saveAsTextFile

      private static void saveAsTextFile(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh) throws IOException
      Save the TriMesh as an ascii text file.
      Parameters:
      kName - file name
      kMesh - TriMesh
      Throws:
      IOException - I/O exception
    • saveAsVRML

      private static void saveAsVRML(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box) throws IOException
      Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).
      Parameters:
      kName - the name of file to which the triangle mesh is saved
      kMesh - TriMesh to save.
      kVBuffer - TriMesh VertexBuffer
      flip - if the y and z axes should be flipped - true in extract and in save of JDialogSurface To have proper orientations in surface file if flip is true flip y and z on reading. param direction 1 or -1 for each axis param startLocation param box (dim-1)*resolution
      direction - 3D mesh orientation
      startLocation - 3D mesh location
      box - 3D mesh bounding box
      Throws:
      IOException - if the specified file could not be opened for writing
    • saveAsVTKLegacy

      private static void saveAsVTKLegacy(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh) throws IOException
      Save the TriMesh in VTK legacy format.
      Parameters:
      kName - file name
      kMesh - TriMesh
      Throws:
      IOException - I/O exception
    • saveAsVTKXML

      private static void saveAsVTKXML(String fileName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Save the TriMesh in VTK format.
      Parameters:
      fileName - file name
      kMesh - TriMesh
    • saveAsGiftiXML

      private static void saveAsGiftiXML(String fileName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Save the TriMesh in Gifti format.
      Parameters:
      fileName - file name
      kMesh - TriMesh
    • saveCollapseRecord

      private static void saveCollapseRecord(RandomAccessFile kOut, WildMagic.LibGraphics.Detail.CollapseRecord kRecord) throws IOException
      Support for saving the collapse records to a binary file.
      Parameters:
      kOut - the file to which the records are saved
      kRecord - CollapseRecord to save.
      Throws:
      IOException - if the there is an error writing to the file
    • saveSingleMesh

      private static void saveSingleMesh(ModelImage kImage, boolean isSur, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Saves a single level of detail to a mesh file. Opens a file dialog to get the output file name from the user.
      Parameters:
      kImage - ModelImage displayed in the SurfaceRender object
      isSur - true if .sur file, otherwise .wrl file
      kMesh - TruNesg
    • saveSingleMesh

      private static void saveSingleMesh(String name, ModelImage kImage, boolean isSur, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Saves a single level of detail to a mesh file. The file name is passed as a parameter.
      Parameters:
      name - the file name
      kImage - ModelImage displayed in the SurfaceRender object
      isSur - true if .sur file, otherwise .wrl file
      kMesh - TriMesh
    • saveSinglePlyMesh

      private static void saveSinglePlyMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Saves a single level of detail to a STL mesh file.
      Parameters:
      kName - file name.
      kMesh - Triangle mesh
    • saveProstatePlyMesh

      private static void saveProstatePlyMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Saves a single level of detail to a STL mesh file.
      Parameters:
      kName - file name.
      kMesh - Triangle mesh
    • saveSingleSTLMesh

      private static void saveSingleSTLMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Saves a single level of detail to a STL mesh file.
      Parameters:
      kName - file name.
      kMesh - Triangle mesh
    • saveProstateSTLMesh

      private static void saveProstateSTLMesh(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Saves a single level of detail to a STL ascii mesh file.
      Parameters:
      kName - file name.
      kMesh - Triangle mesh
    • saveSur

      private static void saveSur(String kName, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iType, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix) throws IOException
      Write the TriMesh to disk in the .sur format.
      Parameters:
      kName - file name.
      kMesh - TriMesh.
      iType - type == 0 for TriMesh, type == 1 for ClodMesh
      kVBuffer - TriMesh VertexBuffer
      flip - flag for inverting the y,z values
      direction - 3D mesh direction
      startLocation - 3D mesh location
      box - 3D mesh bounding box
      inverseDicomMatrix - dicom matrix information.
      Throws:
      IOException - if there is an error writing to the file
    • writeTriangleMeshXML

      private static void writeTriangleMeshXML(String kName, ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Writes a TriMesh to disk in the xml format, based on surface.xsd.
      Parameters:
      kName - file name.
      kImage - ModelImage associated with the TriMesh.
      kMesh - TriMesh surface mesh.
    • convertVertex

      private static WildMagic.LibGraphics.SceneGraph.VertexBuffer convertVertex(ModelImage kImage, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
      Convert the vertex from display space to dicom space.
      Parameters:
      kImage - ModelImage
      kMesh - Triangle mesh
      Returns:
      kVBuffer Converted vertex buffer