Package geomss.geom.reader
Class TRIGeomReader
- java.lang.Object
-
- geomss.geom.reader.AbstractGeomReader
-
- geomss.geom.reader.TRIGeomReader
-
- All Implemented Interfaces:
GeomReader
,java.lang.Comparable
public class TRIGeomReader extends AbstractGeomReader
AGeomReader
for reading and writing geometry from/to an Cart3D ASCII configuration TRI (TRIangulation) formatted geometry file.Reference: http://docs.desktop.aero/docs/cart3d/index.php/Surface_Geometry
Modified by: Joseph A. Huwaldt
- Version:
- September 9, 2016
- Author:
- Joseph A. Huwaldt, Date: September 4, 2015
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EXTENSION
-
Fields inherited from interface geomss.geom.reader.GeomReader
MAYBE, NO, YES
-
-
Constructor Summary
Constructors Constructor Description TRIGeomReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
canReadData(java.io.File inputFile)
Method that determines if this reader can read geometry from the specified input file.boolean
canWriteData()
Returns true.java.lang.String
getExtension()
Returns the preferred file extension (not including the ".") for files of this GeomReader's type.boolean
isUnitAware()
This method always returnsfalse
as TRI files do not encode the units that are being used.GeomList<TriangleList>
read(java.io.File inputFile)
Reads in a Cart3D ASCII Configuration *.tri formatted geometry file from the specified input file and returns aGeomList
object that contains a set ofTriangleList
objects (1 for each "configuration" in the *.tri file or a single one if the *.tri file is a component file only).java.lang.String
toString()
Returns a string representation of the object.void
write(java.io.File outputFile, GeometryList geometry)
Writes out a Cart3D ASCII Configuration *.tri formatted geometry file for the geometry contained in the supplied geometry list.-
Methods inherited from class geomss.geom.reader.AbstractGeomReader
compareTo, getWarnings, setFileUnits
-
-
-
-
Field Detail
-
EXTENSION
public static final java.lang.String EXTENSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TRIGeomReader
public TRIGeomReader()
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns a string representation of the object. This will return a brief description of the format read by this reader.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A brief description of the format read by this reader.
-
getExtension
public java.lang.String getExtension()
Returns the preferred file extension (not including the ".") for files of this GeomReader's type.- Returns:
- The preferred file extension for files of this readers type.
-
canReadData
public int canReadData(java.io.File inputFile) throws java.io.IOException
Method that determines if this reader can read geometry from the specified input file.- Specified by:
canReadData
in interfaceGeomReader
- Overrides:
canReadData
in classAbstractGeomReader
- Parameters:
inputFile
- The input file containing the geometry to be read in.- Returns:
- GeomReader.NO if the file format is not recognized by this reader. GeomReader.YES if the file has the extension ".geo" or ".mk5". GeomReader.MAYBE if the file has the extension ".lib".
- Throws:
java.io.IOException
- If there is a problem reading from the specified file.
-
canWriteData
public boolean canWriteData()
Returns true. This class can write triangle and quad-paneled point geometry data to an ASCII *.tri formatted file.- Specified by:
canWriteData
in interfaceGeomReader
- Overrides:
canWriteData
in classAbstractGeomReader
- Returns:
- this method always returns true
-
read
public GeomList<TriangleList> read(java.io.File inputFile) throws java.io.IOException
Reads in a Cart3D ASCII Configuration *.tri formatted geometry file from the specified input file and returns aGeomList
object that contains a set ofTriangleList
objects (1 for each "configuration" in the *.tri file or a single one if the *.tri file is a component file only).WARNING: This file format is not unit aware. You must set the units to be used by calling "setFileUnits()" before calling this method!
- Specified by:
read
in interfaceGeomReader
- Overrides:
read
in classAbstractGeomReader
- Parameters:
inputFile
- The input file containing the geometry to be read in. May not be null.- Returns:
- A
GeomList
object containing the geometry read in from the file. If the file has no geometry in it, then this list will have no triangles in it (will have a size() of zero). - Throws:
java.io.IOException
- If there is a problem reading the specified file.- See Also:
AbstractGeomReader.setFileUnits(javax.measure.unit.Unit)
-
write
public void write(java.io.File outputFile, GeometryList geometry) throws java.io.IOException
Writes out a Cart3D ASCII Configuration *.tri formatted geometry file for the geometry contained in the supplied geometry list. If the list contains only triangles, they are written out as a "Component TRI file". If the list contains lists of triangles, each are written out as separate configurations in a "Configuration TRI file". If the list contains a PointVehicle, then each PointComponent is triangulated and written out as a separate configuration in a "Configuration TRI file". If no triangle or point array based geometry can be found in the geometry list, then nothing will happen (the output file will not be created).The user data key "TRI_TOL" can optionally be set to a Parameter containing the tolerance to use when determining if vertices are coincident. If not supplied, a default tolerance will be used that essentially requires identical vertex coordinates in order to be coincident.
WARNING: This format is not unit aware. The geometry will be written out in whatever its current units are! Make sure to convert to the desired units for the file before calling this method.
- Specified by:
write
in interfaceGeomReader
- Overrides:
write
in classAbstractGeomReader
- Parameters:
outputFile
- The output file to which the geometry is to be written. May not be null.geometry
- The list of triangle or point array geometry to be written out. May not be null.- Throws:
java.io.IOException
- If there is a problem writing to the specified file.
-
isUnitAware
public boolean isUnitAware()
This method always returnsfalse
as TRI files do not encode the units that are being used. You must callsetFileUnits
to set the units being used before reading from a file of this format.- Returns:
- This implementation always returns false.
- See Also:
AbstractGeomReader.setFileUnits(javax.measure.unit.Unit)
-
-