Class FileSurface_J3D
- java.lang.Object
-
- gov.nih.mipav.view.renderer.J3D.model.file.FileSurface_J3D
-
public class FileSurface_J3D extends java.lang.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:
JPanelSurface.java
,SurfaceRender.java
,SurfaceAttributes.java
,FileSurfaceXML.java
,FileInfoSurfaceXML.java
,ModelTriangleMesh.java
-
-
Constructor Summary
Constructors Constructor Description FileSurface_J3D()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
getFileName(boolean bLoad)
Calls a dialog to get a file name.private static java.io.File[]
openFiles(boolean bLoad)
Returns an array of File objects, based on the user-selected files from the FileChooser dialog.static SurfaceAttributes[]
openSurfaces(ModelImage kImage, int iListSize)
The action taken when the Add button is clicked in the JPanelSurface class.static SurfaceAttributes
readSurface(ModelImage kImage, java.io.File file, javax.vecmath.Color4f color)
Load a triangle mesh from the specified file and assign to it the specified color.private static void
saveMultiMesh(ModelImage kImage, SurfaceAttributes[] surfaces)
Writes multiple surfaces to one file.private static void
savePortableMesh(ModelImage kImage, ModelTriangleMesh[] meshes, java.io.PrintWriter kOut, javax.vecmath.Color3f color)
Saves a single level of detail to a mesh file.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.private static void
saveSingleMesh(java.lang.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.static void
saveSurfaces(ModelImage kImage, SurfaceAttributes[] akSurfaces, java.lang.String kCommand)
The action taken when the one of the save surface buttons is pressed in the JPanelSurface class.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.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.
-
-
-
Method Detail
-
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 classiListSize
- 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, java.io.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 classfile
- 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, java.lang.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 classakSurfaces
- an array of surfaces described by their SurfaceAttributes, containing information that is saved with the ModelTriangleMeshkCommand
- the type of save operation to perform
-
getFileName
private static java.lang.String getFileName(boolean bLoad)
Calls a dialog to get a file name.- Parameters:
bLoad
- iftrue
, make it a load dialog.- Returns:
- File name.
-
openFiles
private static java.io.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, java.io.PrintWriter kOut, javax.vecmath.Color3f color) throws java.io.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 referencecolor
- Color3f surface color- Throws:
java.io.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 objectmeshes
- The triangle meshes that make up that level of detail surface.isSur
- true if .sur file, otherwise .wrl filecolor
- surface color
-
saveSingleMesh
private static void saveSingleMesh(java.lang.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 namekImage
- ModelImage displayed in the SurfaceRender objectmeshes
- The triangle meshes that make up that level of detail surface.isSur
- true if .sur file, otherwise .wrl filecolor
- surface colorperVertexColorArray
- 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 objectsx1
- floatsy1
- floatsz1
- floatsx2
- floatsy2
- floatsz2
- floatsx3
- floatsy3
- floatsz3
- 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 meshsurface
- Material material reference.
-
-