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 intxml_countprotected java.lang.Stringxml_current_blockprotected XMLObject.XMLEncodingxml_encodingprotected intxml_itrprotected java.util.ArrayList<org.jogamp.vecmath.Point3f>xml_vertices -
Constructor Summary
Constructors Constructor Description Shape3D() -
Method Summary
Modifier and Type Method Description java.lang.Objectclone()booleancontains(org.jogamp.vecmath.Point3f point)Determines whether this shape containspoint.Box3DgetBoundBox()org.jogamp.vecmath.Point3fgetCenter()abstract float[]getCoords()java.lang.StringgetDTD()Returns the Data Type Declaration (DTD) for this object's XML representationjava.lang.StringgetLocalName()Returns the local name associated with this XML object.doublegetProximity(org.jogamp.vecmath.Point3f point)Determines the proximity ofpointto this shape.org.jogamp.vecmath.Point3dgetProximityPoint(org.jogamp.vecmath.Point3f point)Returns the point on this shape which is closest topoint.java.lang.StringgetShortXML(int tab)Returns a short XML representation of this object.intgetSize()Returns the number of vertices in this shape.abstract org.jogamp.vecmath.Point3fgetVertex(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.StringgetXML()Returns this object's XML representation as a single string.java.lang.StringgetXML(int tab)Returns this object's XML representation as a single string.java.lang.StringgetXMLSchema()Returns the XML schema for this object's XML representationvoidhandleXMLElementEnd(java.lang.String localName)Handles the end of an XML element.voidhandleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Handles the start of an XML element.voidhandleXMLString(java.lang.String s)Handles a string within an XML element.protected voidloadAsciiCoords(java.lang.String data)Load vertices from Ascii encoded dataprotected voidloadBinaryCoords(java.lang.String data, int compression)Load vertices from Base64 binary encoded data.protected voidloadCoords(java.lang.String data, XMLObject.XMLEncoding encoding)Decodesdataand sets this shape's coordinates.protected voidloadXMLCoord(org.xml.sax.Attributes attributes)Load a single vertex from XML format, and add to this shapeabstract voidsetCoords(float[] f)abstract voidsetVertices(java.util.ArrayList<org.jogamp.vecmath.Point3f> n)voidsetVertices(org.jogamp.vecmath.Point3f[] n)booleantransform(Jama.Matrix T)Transform this shape with affine transformation Jama matrixM.booleantransform(org.jogamp.vecmath.Matrix4d M)Transform this shape with affine transformation matrixM.protected voidwriteAsciiCoords(java.io.Writer writer, java.lang.String tab, int decimals)Write coordinates as ASCII data to an XML writer; formats todecimalsdecimal places.protected voidwriteBinaryCoords(java.io.Writer writer, int compress)Write mesh coordinates as Base64 encoded binary data to an XML writer, in row major order.protected voidwriteCoords(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)Writes this shape's coordinates, according the parameters inoptionsvoidwriteXML(int tab, java.io.Writer writer)Writes the XML representation of this object to file.voidwriteXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)Writes the XML representation of this object to file, asXMLType.Normal.voidwriteXML(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 ofpointto this shape.- Parameters:
thisPoint-- Returns:
- the proximity, or
Double.NaNif 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
nullif 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:
trueif this shape containspoint;falseotherwise.
-
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:
clonein 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:ShapeTransform this shape with affine transformation Jama matrixM. -
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObjectReturns 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:ShapeTransform this shape with affine transformation matrixM. -
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObjectReturns the local name associated with this XML object.- Specified by:
getLocalNamein interfaceXMLObject- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObjectReturns 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:XMLObjectReturns 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:XMLObjectReturns the XML schema for this object's XML representation- Specified by:
getXMLSchemain 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:XMLObjectHandles the start of an XML element.- Specified by:
handleXMLElementStartin interfaceXMLObject- Parameters:
localName- Local name of the elementattributes- Set of element attributestype- TheXMLTypeof this element- Throws:
org.xml.sax.SAXException
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles the end of an XML element.- Specified by:
handleXMLElementEndin 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:XMLObjectHandles a string within an XML element.- Specified by:
handleXMLStringin 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:XMLObjectWrites 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.Asciiwill be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file, asXMLType.Normal. The default format ofXMLFormat.Asciiwill 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:XMLObjectWrites 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.Asciiwill be used. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObjectReturns a short XML representation of this object.- Specified by:
getShortXMLin 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 todecimalsdecimal 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
Decodesdataand 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-
-