org.smurn.jply
Class ElementType

java.lang.Object
  extended by org.smurn.jply.ElementType

public final class ElementType
extends Object

Declaration of an element type.

Each element in a PLY file has a type. The type defines what values (properties) the element has.

Some element types are described in the PLY specification and should only be used accordingly to ensure best compatibility with other PLY applications.

vertex
Element type for vertex definitions. The vertex type should have at least three (non-list) properties named x, y and z for the position of the vertex.
The specification also mentions optional red, green, blue (non-list) properties to define the color of a vertex.
For more material properties a reference to a material definition can be added to a vertex with the material_index property (of an integer type). The value of that property is a (zero-based) index to an element of type material (see below).
face
Element type for polygon definitions. The face type should have at least one list-property called vertex_index, storing a list of (zero-based) indicies into the vertex elements.
The indicies select the vertices that form the polygon. The vertices should all lie on a common plane. There should be at least three vertices per face.
Color and material of a polygon can be specified with the same properties as used for vertices.
edge
Element type for line segments. The edge type should have at least two (non-list) properties vertex1 and vertex2, storing a (zero-based) index into the vertex elements defining the start and end point of the edge.
Color and material of an edge can be specified with the same properties as used for vertices.
material
Type for material description elements. Each element describes a material. Materials can be referenced from other elements using the material_index property.
There are several properties of a material mentioned in the specification:
  • ambient_red
  • ambient_green
  • ambient_blue
  • ambient_coeff
  • diffuse_red
  • diffuse_green
  • diffuse_blue
  • diffuse_coeff
  • specular_red
  • specular_green
  • specular_blue
  • specular_coeff
  • specular_power
  • The data type mentioned in the specification is float for all properties but indices where it should be int and color components where it should be uchar.

    All instances of this class are immutable.


    Constructor Summary
    ElementType(String name, List<Property> properties)
              Creates an instance.
    ElementType(String name, Property... properties)
              Creates an instance.
     
    Method Summary
     boolean equals(Object obj)
               
     String getName()
              Gets the name of the element type.
     List<Property> getProperties()
              Gets all properties defined for this element type.
     int hashCode()
               
     String toString()
               
     
    Methods inherited from class java.lang.Object
    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
     

    Constructor Detail

    ElementType

    public ElementType(String name,
                       List<Property> properties)
    Creates an instance.

    Parameters:
    name - Name of the element type.
    properties - Properties of the elements of this type. Must not be null.
    Throws:
    NullPointerException - if name or properties is null.
    IllegalArgumentException - if the properties don't have unique names.

    ElementType

    public ElementType(String name,
                       Property... properties)
    Creates an instance.

    Parameters:
    name - Name of the element type.
    properties - Properties of the elements of this type.
    Throws:
    NullPointerException - if name or properties is null.
    IllegalArgumentException - if the properties don't have unique names.
    Method Detail

    getName

    public String getName()
    Gets the name of the element type.

    Some names are given a specific meaning by the PLY specification and should only be used accordingly. See ElementType.

    Returns:
    Name of the element type. Is never null or empty, contains only ASCII characters.

    getProperties

    public List<Property> getProperties()
    Gets all properties defined for this element type.

    Returns:
    Immutable list of properties. I never null.

    toString

    public String toString()
    Overrides:
    toString in class Object

    equals

    public boolean equals(Object obj)
    Overrides:
    equals in class Object

    hashCode

    public int hashCode()
    Overrides:
    hashCode in class Object


    Copyright © 2011. All Rights Reserved.