Package mgui.geometry
Class Shape3D
java.lang.Object
mgui.geometry.Shape3D
- Direct Known Subclasses:
Box3D
,Cube3D
,Graph3D
,LineSegment3D
,Mesh3D
,Plane3D
,PointSet3D
,Polygon3D
,Rect3D
,Sphere3D
,Triangle3D
,Vector3D
public abstract class Shape3D extends java.lang.Object implements Shape, java.lang.Cloneable
Base class to be extended by all 3D shapes.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description protected int
xml_count
protected java.lang.String
xml_current_block
protected XMLObject.XMLEncoding
xml_encoding
protected int
xml_itr
protected java.util.ArrayList<org.jogamp.vecmath.Point3f>
xml_vertices
-
Constructor Summary
Constructors Constructor Description Shape3D()
-
Method Summary
Modifier and Type Method Description java.lang.Object
clone()
boolean
contains(org.jogamp.vecmath.Point3f point)
Determines whether this shape containspoint
.Box3D
getBoundBox()
org.jogamp.vecmath.Point3f
getCenter()
abstract float[]
getCoords()
java.lang.String
getDTD()
Returns the Data Type Declaration (DTD) for this object's XML representationjava.lang.String
getLocalName()
Returns the local name associated with this XML object.double
getProximity(org.jogamp.vecmath.Point3f point)
Determines the proximity ofpoint
to this shape.org.jogamp.vecmath.Point3d
getProximityPoint(org.jogamp.vecmath.Point3f point)
Returns the point on this shape which is closest topoint
.java.lang.String
getShortXML(int tab)
Returns a short XML representation of this object.int
getSize()
Returns the number of vertices in this shape.abstract org.jogamp.vecmath.Point3f
getVertex(int index)
Returns the vertex at the specified index as aPoint3f
.abstract java.util.ArrayList<org.jogamp.vecmath.Point3f>
getVertices()
Returns a list of this shape's nodes asPoint3f
's.java.lang.String
getXML()
Returns this object's XML representation as a single string.java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.java.lang.String
getXMLSchema()
Returns the XML schema for this object's XML representationvoid
handleXMLElementEnd(java.lang.String localName)
Handles the end of an XML element.void
handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
Handles the start of an XML element.void
handleXMLString(java.lang.String s)
Handles a string within an XML element.protected void
loadAsciiCoords(java.lang.String data)
Load vertices from Ascii encoded dataprotected void
loadBinaryCoords(java.lang.String data, int compression)
Load vertices from Base64 binary encoded data.protected void
loadCoords(java.lang.String data, XMLObject.XMLEncoding encoding)
Decodesdata
and sets this shape's coordinates.protected void
loadXMLCoord(org.xml.sax.Attributes attributes)
Load a single vertex from XML format, and add to this shapeabstract void
setCoords(float[] f)
abstract void
setVertices(java.util.ArrayList<org.jogamp.vecmath.Point3f> n)
void
setVertices(org.jogamp.vecmath.Point3f[] n)
boolean
transform(Jama.Matrix T)
Transform this shape with affine transformation Jama matrixM
.boolean
transform(org.jogamp.vecmath.Matrix4d M)
Transform this shape with affine transformation matrixM
.protected void
writeAsciiCoords(java.io.Writer writer, java.lang.String tab, int decimals)
Write coordinates as ASCII data to an XML writer; formats todecimals
decimal places.protected void
writeBinaryCoords(java.io.Writer writer, int compress)
Write mesh coordinates as Base64 encoded binary data to an XML writer, in row major order.protected void
writeCoords(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)
Writes this shape's coordinates, according the parameters inoptions
void
writeXML(int tab, java.io.Writer writer)
Writes the XML representation of this object to file.void
writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)
Writes the XML representation of this object to file, asXMLType.Normal
.void
writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)
Writes the XML representation of this object to file.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
xml_encoding
-
xml_current_block
protected java.lang.String xml_current_block -
xml_vertices
protected java.util.ArrayList<org.jogamp.vecmath.Point3f> xml_vertices -
xml_count
protected int xml_count -
xml_itr
protected int xml_itr
-
-
Constructor Details
-
Shape3D
public Shape3D()
-
-
Method Details
-
getProximity
public double getProximity(org.jogamp.vecmath.Point3f point)Determines the proximity ofpoint
to this shape.- Parameters:
thisPoint
-- Returns:
- the proximity, or
Double.NaN
if the distance cannot be determined, or the subclass has not implemented this method.
-
getProximityPoint
public org.jogamp.vecmath.Point3d getProximityPoint(org.jogamp.vecmath.Point3f point)Returns the point on this shape which is closest topoint
. The returned point need not be a vertex of this shape; its determination is particular to the subclass.- Parameters:
point
-- Returns:
- The closest point, or
null
if this cannot be determined, or the subclass has not implemented this method.
-
contains
public boolean contains(org.jogamp.vecmath.Point3f point)Determines whether this shape containspoint
. Whether this shape can contain a point is particular to the subclass.- Parameters:
thisPoint
-- Returns:
true
if this shape containspoint
;false
otherwise.
-
getVertices
public abstract java.util.ArrayList<org.jogamp.vecmath.Point3f> getVertices()Returns a list of this shape's nodes asPoint3f
's. This list is a copy, so operations performed on these nodes will not affect this shape.- Returns:
-
getVertex
public abstract org.jogamp.vecmath.Point3f getVertex(int index)Returns the vertex at the specified index as aPoint3f
. This vertex is a copy, so operations performed on it will not affect this shape.Note: subclasses may want to provide a more efficient implementation of this method.
- Parameters:
index
-- Returns:
-
getSize
public int getSize()Returns the number of vertices in this shape. Subclasses can provide more efficient implementations. -
clone
public java.lang.Object clone()- Overrides:
clone
in classjava.lang.Object
-
setVertices
public void setVertices(org.jogamp.vecmath.Point3f[] n) -
setVertices
public abstract void setVertices(java.util.ArrayList<org.jogamp.vecmath.Point3f> n) -
getCoords
public abstract float[] getCoords() -
setCoords
public abstract void setCoords(float[] f) -
getBoundBox
-
getCenter
public org.jogamp.vecmath.Point3f getCenter() -
transform
public boolean transform(Jama.Matrix T)Description copied from interface:Shape
Transform this shape with affine transformation Jama matrixM
. -
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObject
Returns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
transform
public boolean transform(org.jogamp.vecmath.Matrix4d M)Description copied from interface:Shape
Transform this shape with affine transformation matrixM
. -
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObject
Returns the local name associated with this XML object.- Specified by:
getLocalName
in interfaceXMLObject
- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObject
Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObject
Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObject
Returns the XML schema for this object's XML representation- Specified by:
getXMLSchema
in interfaceXMLObject
- Returns:
-
handleXMLElementStart
public void handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObject
Handles the start of an XML element.- Specified by:
handleXMLElementStart
in interfaceXMLObject
- Parameters:
localName
- Local name of the elementattributes
- Set of element attributestype
- TheXMLType
of this element- Throws:
org.xml.sax.SAXException
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObject
Handles the end of an XML element.- Specified by:
handleXMLElementEnd
in interfaceXMLObject
- Parameters:
localName
- Local name of the element- Throws:
org.xml.sax.SAXException
-
handleXMLString
public void handleXMLString(java.lang.String s) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObject
Handles a string within an XML element.- Specified by:
handleXMLString
in interfaceXMLObject
- Parameters:
s
- String to handle- Throws:
org.xml.sax.SAXException
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Ascii
will be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file, asXMLType.Normal
. The default format ofXMLFormat.Ascii
will be used. The basic contract for this method is that it should not write a newline character at its start or end. -
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Ascii
will be used. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObject
Returns a short XML representation of this object.- Specified by:
getShortXML
in interfaceXMLObject
- Returns:
-
writeBinaryCoords
protected void writeBinaryCoords(java.io.Writer writer, int compress) throws java.io.IOExceptionWrite mesh coordinates as Base64 encoded binary data to an XML writer, in row major order.- Parameters:
mesh
-encoding
-compress
- Compression; 0 for none, 1 for zip, 2 for gzip- Throws:
java.io.IOException
-
writeAsciiCoords
protected void writeAsciiCoords(java.io.Writer writer, java.lang.String tab, int decimals) throws java.io.IOExceptionWrite coordinates as ASCII data to an XML writer; formats todecimals
decimal places. Wraps line when it exceeds 76 characters.- Parameters:
mesh
-encoding
-- Throws:
java.io.IOException
-
writeCoords
protected void writeCoords(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionWrites this shape's coordinates, according the parameters inoptions
- Parameters:
tab
-writer
-options
-progress_bar
-- Throws:
java.io.IOException
-
loadCoords
Decodesdata
and sets this shape's coordinates.- Parameters:
data
-encoding
-
-
loadBinaryCoords
protected void loadBinaryCoords(java.lang.String data, int compression)Load vertices from Base64 binary encoded data.- Parameters:
data
-compression
- Compression; 0 for none, 1 for zip, 2 for gzip
-
loadAsciiCoords
protected void loadAsciiCoords(java.lang.String data)Load vertices from Ascii encoded data- Parameters:
data
-
-
loadXMLCoord
protected void loadXMLCoord(org.xml.sax.Attributes attributes)Load a single vertex from XML format, and add to this shape- Parameters:
attributes
-
-