public class MeshComponent extends ICEObject implements Component, IMeshPart
Composite container for Polygons along with any additional information
required to interpret the mesh data.
The MeshComponent breaks a mesh down into vertices and edges. As polygons are
added, the new edges and vertices are incorporated into the mesh, and
IUpdateableListeners registered with the MeshComponent are notified that it
has changed.
All polygons are expected to have a unique ID among all other polygons. This
also holds for vertices and edges.
iComponentVisitor
iComponentListener
Constructor and Description |
---|
MeshComponent()
The default constructor for a MeshComponent.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(IComponentVisitor visitor)
(non-Javadoc)
|
void |
acceptMeshVisitor(IMeshPartVisitor visitor)
This method calls the
IMeshPartVisitor 's visit method. |
void |
addPolygon(Polygon polygon)
Adds a polygon to the MeshComponent.
|
java.lang.Object |
clone()
This operation returns a clone of the MeshComponent using a deep copy.
|
void |
copy(MeshComponent component)
This operation copies the contents of a MeshComponent into the current
object using a deep copy.
|
boolean |
equals(java.lang.Object otherObject)
This operation is used to check equality between this MeshComponent and
another MeshComponent.
|
Edge |
getEdge(int id)
Gets an Edge instance corresponding to an ID.
|
Edge |
getEdgeFromVertices(int firstId,
int secondId)
Returns an Edge that connects two specified vertices if one exists.
|
java.util.ArrayList<Edge> |
getEdges()
Gets a list of all edges associated with this MeshComponent.
|
java.util.ArrayList<Edge> |
getEdgesFromVertex(int id)
Returns a list of Edges attached to the Vertex with the specified ID.
|
int |
getNextEdgeId()
Returns the next available ID for edges.
|
int |
getNextPolygonId()
Returns the next available ID for polygons.
|
int |
getNextVertexId()
Returns the next available ID for vertices.
|
Polygon |
getPolygon(int id)
Gets a Polygon instance corresponding to an ID.
|
java.util.ArrayList<Polygon> |
getPolygons()
Gets a list of all polygons stored in the MeshComponent ordered by their
IDs.
|
java.util.ArrayList<Polygon> |
getPolygonsFromEdge(int id)
Returns a list of Polygons containing the Edge with the specified ID.
|
java.util.ArrayList<Polygon> |
getPolygonsFromVertex(int id)
Returns a list of Polygons containing the Vertex with the specified ID.
|
java.util.ArrayList<Polygon> |
getPolygonsFromVertices(java.util.ArrayList<Vertex> vertices)
Returns a list containing all Polygons in the MeshComponent whose
vertices are a subset of the supplied list of vertices.
|
Vertex |
getVertex(int id)
Gets a Vertex instance corresponding to an ID.
|
java.util.ArrayList<Vertex> |
getVertices()
Gets a list of all vertices associated with this MeshComponent.
|
int |
hashCode()
This operation returns the hash value of the MeshComponent.
|
void |
removePolygon(int id)
Removes a polygon from the MeshComponent.
|
void |
removePolygons(java.util.ArrayList<java.lang.Integer> ids)
Removes a list polygons from the MeshComponent.
|
void |
setPolygons(java.util.ArrayList<Polygon> polygons)
Sets the list of all polygons stored in the MeshComponent.
|
copy, getDescription, getId, getName, register, setDescription, setId, setName, unregister, update
getClass, notify, notifyAll, toString, wait, wait, wait
register, unregister, update
getDescription, getId, getName, setDescription, setId, setName
public MeshComponent()
The default constructor for a MeshComponent. Initializes the list of polygons and any associated bookkeeping structures.
public void addPolygon(Polygon polygon)
Adds a polygon to the MeshComponent. The polygon is expected to have a unique polygon ID. If the polygon can be added, a notification is sent to listeners. If the polygon uses equivalent vertices or edges with different references, then a new polygon is created with references to the vertices and edges already known by this MeshComponent.
polygon
- The new polygon to add to the existing list.
public void removePolygon(int id)
Removes a polygon from the MeshComponent. This will also remove any vertices and edges used only by this polygon. If a polygon was removed, a notification is sent to listeners.
id
- The ID of the polygon to remove from the existing list.
public void removePolygons(java.util.ArrayList<java.lang.Integer> ids)
Removes a list polygons from the MeshComponent. This will also remove any vertices and edges used by these polygons. If a polygon was removed, a notification is sent to listeners.
ids
- An ArrayList containing the IDs of the polygons to remove from the MeshComponent.
public java.util.ArrayList<Polygon> getPolygons()
Gets a list of all polygons stored in the MeshComponent ordered by their IDs.
A list of polygons contained in this MeshComponent.
public Polygon getPolygon(int id)
Gets a Polygon instance corresponding to an ID.
id
- The ID of the polygon.
The polygon referred to by the ID, or null if there is no polygon with the ID.
public int getNextPolygonId()
Returns the next available ID for polygons.
The greatest polygon ID (or zero) plus one.
public void setPolygons(java.util.ArrayList<Polygon> polygons)
Sets the list of all polygons stored in the MeshComponent.
polygons
- The list of polygons to replace the existing list of polygons in the MeshComponent.
public java.util.ArrayList<Vertex> getVertices()
Gets a list of all vertices associated with this MeshComponent.
All vertices managed by this MeshComponent.
public Vertex getVertex(int id)
Gets a Vertex instance corresponding to an ID.
id
- The ID of the vertex.
The vertex referred to by the ID, or null if the ID is invalid.
public int getNextVertexId()
Returns the next available ID for vertices.
The greatest vertex ID (or zero) plus one.
public java.util.ArrayList<Edge> getEdges()
Gets a list of all edges associated with this MeshComponent.
All edges managed by this MeshComponent.
public Edge getEdge(int id)
Gets an Edge instance corresponding to an ID.
id
- The ID of the edge.
The edge referred to by the ID, or null if the ID is invalid.
public int getNextEdgeId()
Returns the next available ID for edges.
The greatest edge ID (or zero) plus one.
public java.util.ArrayList<Edge> getEdgesFromVertex(int id)
Returns a list of Edges attached to the Vertex with the specified ID.
id
- The ID of the vertex.
An ArrayList of Edges that are attached to the vertex with the specified ID. If there are no such edges, e.g., if the vertex ID is invalid, the list will be empty.
public java.util.ArrayList<Polygon> getPolygonsFromVertex(int id)
Returns a list of Polygons containing the Vertex with the specified ID.
id
- The ID of the vertex.
An ArrayList of Polygons that contain the vertex with the specified ID. If there are no such polygons, e.g., if the vertex ID is invalid, the list will be empty.
public java.util.ArrayList<Polygon> getPolygonsFromEdge(int id)
Returns a list of Polygons containing the Edge with the specified ID.
id
- The ID of the edge.
An ArrayList of Polygons that contain the edge with the specified ID. If there are no such polygons, e.g., if the edge ID is invalid, the list will be empty.
public Edge getEdgeFromVertices(int firstId, int secondId)
Returns an Edge that connects two specified vertices if one exists.
firstId
- The ID of the first vertex.
secondId
- The ID of the second vertex.
An Edge instance that connects the first and second vertices, or null if no such edge exists.
public java.util.ArrayList<Polygon> getPolygonsFromVertices(java.util.ArrayList<Vertex> vertices)
Returns a list containing all Polygons in the MeshComponent whose vertices are a subset of the supplied list of vertices.
vertices
- A collection of vertices.
An ArrayList of all Polygons in the MeshComponent that are composed of some subset of the specified vertices.
public int hashCode()
This operation returns the hash value of the MeshComponent.
hashCode
in interface Identifiable
hashCode
in class ICEObject
The hashcode of the ICEObject.
Identifiable.hashCode()
public boolean equals(java.lang.Object otherObject)
This operation is used to check equality between this MeshComponent and another MeshComponent. It returns true if the MeshComponents are equal and false if they are not.
equals
in interface Identifiable
equals
in class ICEObject
otherObject
- The other ICEObject that should be compared with this one.
True if the ICEObjects are equal, false otherwise.
Identifiable.equals(Object otherObject)
public void copy(MeshComponent component)
This operation copies the contents of a MeshComponent into the current object using a deep copy.
component
- The ICEObject from which the values should be copied
public java.lang.Object clone()
This operation returns a clone of the MeshComponent using a deep copy.
clone
in interface Identifiable
clone
in class ICEObject
The new clone
public void accept(IComponentVisitor visitor)
accept
in interface Component
visitor
- The visitor
Component.accept(IComponentVisitor visitor)
public void acceptMeshVisitor(IMeshPartVisitor visitor)
This method calls the IMeshPartVisitor
's visit method.
acceptMeshVisitor
in interface IMeshPart
visitor
-
The IMeshPartVisitor
that is visiting this
IMeshPart
.