Class FileSurface_J3D

java.lang.Object
gov.nih.mipav.view.renderer.J3D.model.file.FileSurface_J3D

public class FileSurface_J3D 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
  • invalid reference
    FileInfoSurfaceXML.java
  • invalid reference
    ModelTriangleMesh.java
  • Constructor Details

    • FileSurface_J3D

      public FileSurface_J3D()
  • Method Details

    • openSurfaces

      public static SurfaceAttributes[] openSurfaces(ModelImage kImage, int iListSize)
      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 - the ModelImage displayed in the SurfaceRender class
      iListSize - the current number of triangle-mesh surfaces displayed in the SurfaceRender class (for calculating the surface color)
      Returns:
      SurfaceAttributes[] an array of surfaces described by their SurfaceAttributes, used to add the surfaces to a scene graph.
    • readSurface

      public static SurfaceAttributes readSurface(ModelImage kImage, File file, javax.vecmath.Color4f color)
      Load a triangle mesh from the specified file and assign to it the specified color.
      Parameters:
      kImage - ModelImage displayed in the SurfaceRender class
      file - The triangle mesh file to load.
      color - The diffuse and specular color for the surface material.
      Returns:
      DOCUMENT ME!
    • saveSurfaces

      public static void saveSurfaces(ModelImage kImage, SurfaceAttributes[] 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 ModelTriangleMesh
      kCommand - the type of save operation to perform
    • 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.
    • openFiles

      private 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.
    • saveMultiMesh

      private static void saveMultiMesh(ModelImage kImage, SurfaceAttributes[] surfaces)
      Writes multiple surfaces to one file.
      Parameters:
      kImage - the ModelImage the surface is associated with.
      surfaces - the list of surfaces to save.
    • savePortableMesh

      private static void savePortableMesh(ModelImage kImage, ModelTriangleMesh[] meshes, PrintWriter kOut, javax.vecmath.Color3f color) throws IOException
      Saves a single level of detail to a mesh file.
      Parameters:
      kImage - ModelImage displayed in the SurfaceRender object.
      meshes - ModelTriangleMesh[] The triangle meshes that make up that level of detail surface.
      kOut - PrintWriter File output reference
      color - Color3f surface color
      Throws:
      IOException - IOException
    • saveSingleMesh

      private static void saveSingleMesh(ModelImage kImage, ModelTriangleMesh[] meshes, boolean isSur, javax.vecmath.Color4f color, SurfaceAttributes surfacesAttribute)
      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
      meshes - The triangle meshes that make up that level of detail surface.
      isSur - true if .sur file, otherwise .wrl file
      color - surface color
    • saveSingleMesh

      private static void saveSingleMesh(String name, ModelImage kImage, ModelTriangleMesh[] meshes, boolean isSur, javax.vecmath.Color4f color, javax.vecmath.Color4f[][] perVertexColorArray)
      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
      meshes - The triangle meshes that make up that level of detail surface.
      isSur - true if .sur file, otherwise .wrl file
      color - surface color
      perVertexColorArray - color per vertex array
    • subTriangles

      private static void subTriangles(ModelImage kImage, float sx1, float sy1, float sz1, float sx2, float sy2, float sz2, float sx3, float sy3, float sz3)
      Subdivide the triangle.
      Parameters:
      kImage - the ModelImage displayed in the SurfaceRender object
      sx1 - float
      sy1 - float
      sz1 - float
      sx2 - float
      sy2 - float
      sz2 - float
      sx3 - float
      sy3 - float
      sz3 - float
    • writeTriangleMeshXML

      private static void writeTriangleMeshXML(ModelImage kImage, ModelTriangleMesh[] kMesh, SurfaceAttributes surface, javax.vecmath.Color4f color)
      Writes a ModelTriangleMesh and Material to disk in the xml format, based on surface.xsd.
      Parameters:
      kMesh - ModelTriangleMesh surface mesh
      surface - Material material reference.