Package mgui.geometry

Class Shape3D

java.lang.Object
mgui.geometry.Shape3D
All Implemented Interfaces:
java.lang.Cloneable, Shape, XMLObject
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 contains point.
    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 representation
    java.lang.String getLocalName()
    Returns the local name associated with this XML object.
    double getProximity​(org.jogamp.vecmath.Point3f point)
    Determines the proximity of point to this shape.
    org.jogamp.vecmath.Point3d getProximityPoint​(org.jogamp.vecmath.Point3f point)
    Returns the point on this shape which is closest to point.
    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 a Point3f.
    abstract java.util.ArrayList<org.jogamp.vecmath.Point3f> getVertices()
    Returns a list of this shape's nodes as Point3f'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 representation
    void 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 data
    protected 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)
    Decodes data 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 shape
    abstract 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 matrix M.
    boolean transform​(org.jogamp.vecmath.Matrix4d M)
    Transform this shape with affine transformation matrix M.
    protected void writeAsciiCoords​(java.io.Writer writer, java.lang.String tab, int decimals)
    Write coordinates as ASCII data to an XML writer; formats to decimals 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 in options
    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, as XMLType.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

      protected XMLObject.XMLEncoding 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 of point 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 to point. 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 contains point. Whether this shape can contain a point is particular to the subclass.
      Parameters:
      thisPoint -
      Returns:
      true if this shape contains point; false otherwise.
    • getVertices

      public abstract java.util.ArrayList<org.jogamp.vecmath.Point3f> getVertices()
      Returns a list of this shape's nodes as Point3f'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 a Point3f. 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.
      Specified by:
      getSize in interface Shape
      Returns:
      the number of vertices
    • clone

      public java.lang.Object clone()
      Overrides:
      clone in class java.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()
      Specified by:
      getCoords in interface Shape
    • setCoords

      public abstract void setCoords​(float[] f)
      Specified by:
      setCoords in interface Shape
    • getBoundBox

      public Box3D 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 matrix M.
      Specified by:
      transform in interface Shape
      Returns:
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • transform

      public boolean transform​(org.jogamp.vecmath.Matrix4d M)
      Description copied from interface: Shape
      Transform this shape with affine transformation matrix M.
      Specified by:
      transform in interface Shape
      Returns:
    • getLocalName

      public java.lang.String getLocalName()
      Description copied from interface: XMLObject
      Returns the local name associated with this XML object.
      Specified by:
      getLocalName in interface XMLObject
      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 the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Returns:
    • 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 the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      Returns:
    • handleXMLElementStart

      public void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles the start of an XML element.
      Specified by:
      handleXMLElementStart in interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType of this element
      Throws:
      org.xml.sax.SAXException
    • handleXMLElementEnd

      public void handleXMLElementEnd​(java.lang.String localName) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles the end of an XML element.
      Specified by:
      handleXMLElementEnd in interface XMLObject
      Parameters:
      localName - Local name of the element
      Throws:
      org.xml.sax.SAXException
    • handleXMLString

      public void handleXMLString​(java.lang.String s) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles a string within an XML element.
      Specified by:
      handleXMLString in interface XMLObject
      Parameters:
      s - String to handle
      Throws:
      org.xml.sax.SAXException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer) throws java.io.IOException
      Description 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 of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file, as XMLType.Normal. The default format of XMLFormat.Ascii will be used. The basic contract for this method is that it should not write a newline character at its start or end.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOException
      Description 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 of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • 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 interface XMLObject
      Returns:
    • writeBinaryCoords

      protected void writeBinaryCoords​(java.io.Writer writer, int compress) throws java.io.IOException
      Write 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.IOException
      Write coordinates as ASCII data to an XML writer; formats to decimals 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.IOException
      Writes this shape's coordinates, according the parameters in options
      Parameters:
      tab -
      writer -
      options -
      progress_bar -
      Throws:
      java.io.IOException
    • loadCoords

      protected void loadCoords​(java.lang.String data, XMLObject.XMLEncoding encoding)
      Decodes data 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 -