Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

DynamicMesh Class Reference

#include <DynamicMesh.h>

Inheritance diagram for DynamicMesh:

Inheritance graph
[legend]
Collaboration diagram for DynamicMesh:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DynamicMesh ()
 Constructor for a dynamic mesh.

void optimize (U32 compi, double(*metric)(const gmVector3 &v1, const gmVector3 &v2, const gmVector3 &v3), double threshold)
 Re-optimize the given mesh component.

U32 event_creation (const gmVector3 &pos)
 Reconfigure the mesh due to a creation event.

void event_destroy (U32 comp)
 Reconfigure the mesh due to a destroy event.

void event_attach (U32 c1, U32 c2, const gmVector3 &pos, const gmVector3 &dir)
 Reconfigure the mesh due to an attach event.

U32 event_detach (U32 c, const gmVector3 &pos, const gmVector3 &dir)
 Reconfigure the mesh due to a detach event.

void event_spackle (U32 c, const gmVector3 &pos, const gmVector3 &dir)
 Reconfigure the mesh due to a spackle event.

void event_pierce (U32 c, const gmVector3 &pos, const gmVector3 &dir)
 Reconfigure the mesh due to a pierce event.

U32 event_bubble (const gmVector3 &pos)
 Reconfigure the mesh due to a bubble event.

void event_burst (U32 comp)
 Reconfigure the mesh due to a burst event.


Public Attributes

double m_component_offset
 When a new component is created, this is the world coordinate distance that the vertices of the component are offset from the critical point.


Private Member Functions

U32 add_component (const gmVector3 &pos, bool is_inward)
 Add a new component to the mesh.

void remove_component (U32 comp)
 Remove a component from the mesh.

void merge (U32 c1, U32 c2)
 Merge all of one mesh group into another.

void add_ring (U32 c, const gmVector3 &pos, const gmVector3 &dir, bool is_inward)
 Create a new ring of polygons around the given separatrix line.

U32 split (U32 c, const gmVector3 &pos, const gmVector3 &dir)
 Split a connected component.

void remove_ring (U32 c, const gmVector3 &pos, const gmVector3 &dir, bool is_inward)
 Remove a ring of polygons, and fill it with fans on either side.

void flip_edge (MeshGroup &comp, IndexEdge &edge)
 Perform an edge-flip.

U32 intersect_ray (U32 c, const gmVector3 &pos, const gmVector3 &dir)
 Intersect a ray with a mesh component.

U32 create_mesh_group ()
 Create a new mesh group.

const gmVector3 & get_opposing_vertex (IndexEdge *e, U32 fid)
 Get the vertex opposite the given face across the given edge.


Constructor & Destructor Documentation

DynamicMesh::DynamicMesh  )  [inline]
 

Constructor for a dynamic mesh.

Definition at line 39 of file DynamicMesh.h.

References m_component_offset, and Mesh::m_groupList.


Member Function Documentation

U32 DynamicMesh::add_component const gmVector3 &  pos,
bool  is_inward
[private]
 

Add a new component to the mesh.

Initially, it is just a tetrahedron around the given position.

Parameters:
pos The position around which to add.
is_inward True, if the polygons should face inward.
Returns:
The new component added.

Definition at line 203 of file DynamicMesh.cpp.

References MeshGroup::addFace(), Mesh::addNormal(), Mesh::addVertex(), create_mesh_group(), IndexFace, m_component_offset, Mesh::m_groupList, and U32.

void DynamicMesh::add_ring U32  c,
const gmVector3 &  pos,
const gmVector3 &  dir,
bool  is_inward
[private]
 

Create a new ring of polygons around the given separatrix line.

This removes the closest polygons in directions dir and -dir, and sews a ring around them. Only polygons in c are considered, and the ring is added to c.

Parameters:
c The mesh group in which to add the ring.
pos The base point around which to add the ring.
dir The directions in which to remove polygons.
is_inward True, if the new polygons should face toward the line; false, otherwise.

Definition at line 352 of file DynamicMesh.cpp.

References MeshGroup::addFace(), Mesh::addFace(), Mesh::addNormal(), dot(), Mesh::getFace(), IndexFace, intersect_ray(), Mesh::m_groupList, MeshGroup::removeFace(), and U32.

U32 DynamicMesh::create_mesh_group  )  [private]
 

Create a new mesh group.

Definition at line 185 of file DynamicMesh.cpp.

References Mesh::m_groupList, MeshGroup::setArbitraryIndex(), and U32.

Referenced by add_component(), and split().

void DynamicMesh::event_attach U32  c1,
U32  c2,
const gmVector3 &  pos,
const gmVector3 &  dir
[inline]
 

Reconfigure the mesh due to an attach event.

Two connected components join together in a wasp's waist. The two closest polygons pierced by the major eigenvector are assumed to belong to the components to be joined.

Parameters:
c1 One of the components. After the attach, this one will contain the attached component.
c2 The other component. Will not exist after.
pos The position of the critical point.
dir The direction of the line approximating the separatrix. Must pierce both c1 and c2, or results are undefined.

Definition at line 115 of file DynamicMesh.h.

References U32.

U32 DynamicMesh::event_bubble const gmVector3 &  pos  )  [inline]
 

Reconfigure the mesh due to a bubble event.

An air bubble is created in a 'solid' portion of the mesh; similar to a create, but with normals reversed.

Parameters:
pos The position of the critical point.
Returns:
The new component.

Definition at line 200 of file DynamicMesh.h.

References U32.

void DynamicMesh::event_burst U32  comp  )  [inline]
 

Reconfigure the mesh due to a burst event.

An air bubble inside a component is destroyed. Similar to a destroy event.

Parameters:
comp The component to be destroyed.

Definition at line 213 of file DynamicMesh.h.

References U32.

U32 DynamicMesh::event_creation const gmVector3 &  pos  )  [inline]
 

Reconfigure the mesh due to a creation event.

A new connected component is added to the mesh at a given position; we begin with a tetrahedron, and let the particle system adapt it.

Parameters:
pos The position of the critical point of the creation event.
Returns:
A mesh group containing the new connected component.

Definition at line 81 of file DynamicMesh.h.

References U32.

void DynamicMesh::event_destroy U32  comp  )  [inline]
 

Reconfigure the mesh due to a destroy event.

The given group will no longer be valid once the call completes.

Parameters:
comp The component to be destroyed.

Definition at line 94 of file DynamicMesh.h.

References U32.

U32 DynamicMesh::event_detach U32  c,
const gmVector3 &  pos,
const gmVector3 &  dir
[inline]
 

Reconfigure the mesh due to a detach event.

A single connected component becomes two. The ring of polygons intersected by the plane with normal corresponding to the major eigenvector and containing the critical point are removed, and the holes in each component sewn up.

Parameters:
c The component relevant to the detach. Afterward, this will contain the component on the positive half of the separatrix plane (in the direction of dir from pos).
pos The position of the critical point.
dir The direction of the line approximating the separatrix.
Returns:
The other component created by the detach (in the direction -dir from pos).

Definition at line 142 of file DynamicMesh.h.

References U32.

void DynamicMesh::event_pierce U32  c,
const gmVector3 &  pos,
const gmVector3 &  dir
[inline]
 

Reconfigure the mesh due to a pierce event.

A hole is created through a component. Similar to an attach, the polygons pierced by the separatrix plane are removed, and a fan is sewn over opposite ends of the holes.

Parameters:
c The component being pierced.
pos The position of the critical point.
dir The direction of the line approximating the separatrix.

Definition at line 183 of file DynamicMesh.h.

References U32.

void DynamicMesh::event_spackle U32  c,
const gmVector3 &  pos,
const gmVector3 &  dir
[inline]
 

Reconfigure the mesh due to a spackle event.

A hole through a component becomes filled. Similar to a detach, the ring of polygons intersecting the plane with normal corresponding to the separatrix are removed, and each side is sewn up.

Parameters:
c The component having the spackle.
pos The position of the critical point.
dir The direction of the line approximating the separatrix.

Definition at line 163 of file DynamicMesh.h.

References U32.

void DynamicMesh::flip_edge MeshGroup comp,
IndexEdge &  edge
[private]
 

Perform an edge-flip.

An edge flip rearranges the triangles which are shared by an edge; considered as a quad, with the edge being the diagonal, the result of the edge flip is an arrangement with an edge through the other diagonal of the quad.

Parameters:
comp The component to be changed.
edge The edge to be flipped.

Definition at line 8 of file DynamicMesh.cpp.

References MeshGroup::addFace(), Mesh::addFace(), Mesh::addNormal(), edge, Mesh::getVertex(), IndexFace, MeshGroup::removeFace(), and U32.

Referenced by optimize().

const gmVector3 & DynamicMesh::get_opposing_vertex IndexEdge *  e,
U32  fid
[private]
 

Get the vertex opposite the given face across the given edge.

Parameters:
e The edge across which to get the opposite vertex.
fid The face opposing the opposite vertex to be gotten.
Returns:
The opposite vertex.

Definition at line 78 of file DynamicMesh.cpp.

References Mesh::getFace(), Mesh::getVertex(), IndexFace, and U32.

Referenced by optimize().

U32 DynamicMesh::intersect_ray U32  c,
const gmVector3 &  pos,
const gmVector3 &  dir
[private]
 

Intersect a ray with a mesh component.

Return the first polygon intersecting the ray.

Parameters:
c The component to be intersected.
pos The start of the ray.
dir The direction of the ray.
Returns:
The face index of the first polygon intersecting.

Definition at line 773 of file DynamicMesh.cpp.

References MeshGroup::facePostIncrement(), IndexFace, Mesh::m_groupList, ray_intersect_triangle(), MeshGroup::rewindFaceList(), and U32.

Referenced by add_ring(), and remove_ring().

void DynamicMesh::merge U32  c1,
U32  c2
[private]
 

Merge all of one mesh group into another.

Parameters:
c1 What will become the final meshgroup.
c2 The mesh group to be merged. Is destroyed in the process.

Definition at line 333 of file DynamicMesh.cpp.

References MeshGroup::addFace(), MeshGroup::facePostIncrement(), IndexFace, Mesh::m_groupList, remove_component(), MeshGroup::rewindFaceList(), and U32.

void DynamicMesh::optimize U32  compi,
double(*  metric)(const gmVector3 &v1, const gmVector3 &v2, const gmVector3 &v3),
double  threshold
 

Re-optimize the given mesh component.

This goes through all the faces and performs edge swaps as necessary in order to optimize the quality of the mesh, as determined by the given metric. The metric should increase with worse quality, with 0 being perfect. Costs of disparate triangles should be combinable with addition, so the cost/benefit of a given edge swap can be evaluated and optimized.

Parameters:
compi The component to be validated.
metric The metric by which to judge triangles. The params are the locations of the vertices of the triangle.
threshold The threshold to use for determining when to swap. Triangles with a cost higher than this are eligible for swapping. (if they're already optimal they won't be swapped, of course).

Definition at line 103 of file DynamicMesh.cpp.

References MeshGroup::facePostIncrement(), flip_edge(), get_opposing_vertex(), IndexEdge, IndexFace, Mesh::m_groupList, MeshGroup::rewindFaceList(), and U32.

void DynamicMesh::remove_component U32  comp  )  [private]
 

Remove a component from the mesh.

All vertices and faces are removed. (it is assumed that any vertex/face only belongs to one component). The MeshGroup should not be used in any way after.

Parameters:
comp The component to be removed.

Definition at line 283 of file DynamicMesh.cpp.

References MeshGroup::facePostIncrement(), IndexFace, Mesh::m_groupList, MeshGroup::removeFace(), MeshGroup::rewindFaceList(), MeshGroup::setArbitraryIndex(), and U32.

Referenced by merge().

void DynamicMesh::remove_ring U32  c,
const gmVector3 &  pos,
const gmVector3 &  dir,
bool  is_inward
[private]
 

Remove a ring of polygons, and fill it with fans on either side.

The ring is specified as those polygons nearest to pos which are split by the plane defined by pos and dir.

Parameters:
c The component in which to remove the ring.
pos The 'middle' of the ring.
dir A direction normal to the plane defining the ring of polygons to be removed.
is_inward True, if the ring of polygons being removed faces inward (toward the line).

Definition at line 543 of file DynamicMesh.cpp.

References Mesh::addNormal(), Mesh::addVertex(), dot(), MeshGroup::facePostIncrement(), Mesh::getFace(), Mesh::getVertex(), IndexEdge, IndexFace, intersect_ray(), is_contained(), m_component_offset, Mesh::m_groupList, MeshGroup::rewindFaceList(), and U32.

U32 DynamicMesh::split U32  c,
const gmVector3 &  pos,
const gmVector3 &  dir
[private]
 

Split a connected component.

It is assumed the component is already 'degenerate' in the sense that it consists of two disjoint parts, where pos and dir define a plane point and normal separating the two parts.

Parameters:
c The component to be split. On return, has the 'top' half (in +dir from pos).
pos A point on the separating plane.
dir The normal to the separating plane.
Returns:
The other component created by the split (in -dir from pos).

Definition at line 498 of file DynamicMesh.cpp.

References MeshGroup::addFace(), create_mesh_group(), dot(), MeshGroup::facePostIncrement(), IndexFace, Mesh::m_groupList, MeshGroup::removeFace(), MeshGroup::rewindFaceList(), and U32.


Member Data Documentation

double DynamicMesh::m_component_offset
 

When a new component is created, this is the world coordinate distance that the vertices of the component are offset from the critical point.

Should be adjusted as necessary according to the scale of the mesh.

Definition at line 33 of file DynamicMesh.h.

Referenced by add_component(), DynamicMesh(), and remove_ring().


The documentation for this class was generated from the following files:
Generated on Mon Jun 28 15:02:14 2004 for Advanced Surface Library by doxygen 1.3.4