|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jcae.mesh.amibe.ds.Mesh
public class Mesh
Mesh data structure. A mesh is composed of triangles, edges and vertices. There are many data structures to represent meshes, and we focused on the following constraints:
Triangle
is composed of three
Vertex
, three links to adjacent triangles, and each vertex
contains a backward link to one of its incident triangles. It is
then possible to loop within triangles or around vertices.
But there is also a need for lighter data structures. For instance,
visualization does not need adjacency relations, we only need to
store triangle vertices.
Mesh
constructor takes an optional MeshTraitsBuilder
argument to fully describe the desired mesh data structure. Once a
Mesh
instance is created, its features cannot be modified.
With this argument, it is possible to specify if adjacent relations
between triangles have to be computed, if an octree is needed to
locate vertices, if triangles and/or nodes are stored in a list
or a set, etc. Example:
MeshTraitsBuilder mtb = new MeshTraitsBuilder(); // Store triangles into a set mtb.addTriangleSet(); TriangleTraitsBuilder ttb = new TriangleTraitsBuilder(); // Store adjacency relations with HalfEdge ttb.addHalfEdge(); mtb.add(ttb); // Create a new instance with these features Mesh mesh = new Mesh(mtb); // Then each triangle created by mesh.createTriangle // will contain objects needed to store adjacency relations. Triangle t = (Triangle) mesh.createTriangle(...); // Vertices must be created by mesh.createVertex Vertex v = (Vertex) mesh.createVertex(...);
Field Summary | |
---|---|
protected ElementFactoryInterface |
factory
|
protected int |
maxLabel
|
protected MeshParameters |
meshParameters
User-defined mesh parameters. |
protected boolean |
outerTrianglesAreConnected
|
Vertex |
outerVertex
Vertex at infinite. |
protected Traits |
traits
User-defined traits |
protected MeshTraitsBuilder |
traitsBuilder
User-defined traits builder. |
Constructor Summary | |
---|---|
Mesh()
Creates an empty mesh. |
|
Mesh(MeshTraitsBuilder builder)
|
|
Mesh(MeshTraitsBuilder builder,
MeshParameters mp)
Creates an empty mesh with specific features. |
Method Summary | |
---|---|
void |
add(Triangle t)
Adds an existing triangle to triangle list. |
void |
add(Vertex vertex)
Adds a vertex to vertex list. |
void |
buildAdjacency()
Build adjacency relations between triangles. |
void |
buildAdjacency(double minAngle)
Build adjacency relations between triangles. |
boolean |
canCollapseEdge(AbstractHalfEdge e,
Vertex v)
Checks whether an edge can be contracted. |
Triangle |
createTetrahedron(Vertex[] v)
Creates a triangle composed of four vertices, to emulate a tetrahedron. |
Triangle |
createTriangle(Triangle that)
Clones a triangle. |
Triangle |
createTriangle(Vertex[] v)
Creates a triangle composed of three vertices. |
Triangle |
createTriangle(Vertex v0,
Vertex v1,
Vertex v2)
Creates a triangle composed of three vertices. |
Vertex |
createVertex(double[] p)
Creates a 2D or 3D vertex. |
Vertex |
createVertex(double u,
double v)
Creates a 2D vertex. |
Vertex |
createVertex(double x,
double y,
double z)
Creates a 3D vertex. |
double |
distance2(Vertex start,
Vertex end,
Vertex vm)
Returns square distance between 2 vertices. |
AbstractHalfEdge |
edgeCollapse(AbstractHalfEdge e,
Vertex v)
Contracts an edge. |
AbstractHalfEdge |
edgeSwap(AbstractHalfEdge e)
Swaps an edge. |
void |
ensureCapacity(int triangles)
Resizes internal collections of vertices and triangles. |
double[] |
getBounds(Vertex v)
|
KdTree |
getKdTree()
Returns the Kd-tree associated with this mesh. |
MeshParameters |
getMeshParameters()
|
java.util.Collection<Vertex> |
getNodes()
Returns vertex list. |
java.util.Collection<Triangle> |
getTriangles()
Returns triangle list. |
boolean |
hasAdjacency()
Tells whether mesh contains adjacency relations. |
boolean |
hasNodes()
Tells whether nodes are stored. |
boolean |
isValid()
Checks whether this mesh is valid. |
boolean |
isValid(boolean constrained)
Checks whether this mesh is valid. |
void |
remove(Triangle t)
Removes a triangle from triangle list. |
void |
remove(Vertex v)
Removes a vertex from vertex list. |
void |
resetKdTree(double[] bbmin,
double[] bbmax)
Initializes Kd-tree with a given bounding box. |
void |
setRefVertexOnboundary(Vertex v)
Sets an unused boundary reference on a vertex. |
AbstractHalfEdge |
vertexSplit(AbstractHalfEdge e,
Vertex v)
Splits an edge. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final MeshTraitsBuilder traitsBuilder
protected final Traits traits
protected final MeshParameters meshParameters
public Vertex outerVertex
protected ElementFactoryInterface factory
protected boolean outerTrianglesAreConnected
protected int maxLabel
Constructor Detail |
---|
public Mesh()
MeshTraitsBuilder
is passed, MeshTraitsBuilder.getDefault3D()
is called
implicitly.
public Mesh(MeshTraitsBuilder builder)
public Mesh(MeshTraitsBuilder builder, MeshParameters mp)
builder
- mesh traits builderMethod Detail |
---|
public MeshParameters getMeshParameters()
public void add(Triangle t)
t
- triangle being added.public void remove(Triangle t)
t
- triangle being removed.public java.util.Collection<Triangle> getTriangles()
public void ensureCapacity(int triangles)
triangles
- desired number of trianglespublic void add(Vertex vertex)
public void remove(Vertex v)
v
- vertex being removed.public java.util.Collection<Vertex> getNodes()
public boolean hasNodes()
true
if mesh was created with a MeshTraitsBuilder
instance defining nodes, and false
otherwise.public KdTree getKdTree()
public void resetKdTree(double[] bbmin, double[] bbmax)
bbmin
- coordinates of bottom-left vertexbbmax
- coordinates of top-right vertexpublic Triangle createTriangle(Vertex[] v)
v
- array of three vertices
Triangle
instance composed of three verticespublic Triangle createTetrahedron(Vertex[] v)
v
- array of four vertices
Triangle
instance composed of four verticespublic Triangle createTriangle(Vertex v0, Vertex v1, Vertex v2)
v0
- first vertexv1
- second vertexv2
- third vertex
Triangle
instance composed of three verticespublic Triangle createTriangle(Triangle that)
that
- triangle to clone
Triangle
instancepublic Vertex createVertex(double[] p)
p
- coordinates
Vertex
instance with this location.public Vertex createVertex(double u, double v)
u
- first coordinatev
- second coordinate
Vertex
instance with this location.public Vertex createVertex(double x, double y, double z)
x
- first coordinatey
- second coordinatez
- third coordinate
Vertex
instance with this location.public boolean hasAdjacency()
true
if mesh contains adjacency relations,
false
otherwise.public void buildAdjacency()
public void buildAdjacency(double minAngle)
minAngle
- when an edge has a dihedral angle greater than this value,
it is considered as a ridge and its endpoints are treated as if they
belong to a CAD edge. By convention, a negative value means that this
check is not performed.public void setRefVertexOnboundary(Vertex v)
public double distance2(Vertex start, Vertex end, Vertex vm)
public double[] getBounds(Vertex v)
public boolean canCollapseEdge(AbstractHalfEdge e, Vertex v)
e
- edge to be checkedv
- the resulting vertex
true
if this edge can be contracted into the single vertex n, false
otherwise.public AbstractHalfEdge edgeCollapse(AbstractHalfEdge e, Vertex v)
e
- edge to contractv
- the resulting vertex
n
and with the same apex
java.lang.IllegalArgumentException
- if edge belongs to an outer triangle,
because there would be no valid return value. User must then run this
method against symmetric edge, this is not done automatically.public AbstractHalfEdge vertexSplit(AbstractHalfEdge e, Vertex v)
edgeCollapse(org.jcae.mesh.amibe.ds.AbstractHalfEdge, org.jcae.mesh.amibe.ds.Vertex)
.
e
- edge being splittedv
- the resulting vertexpublic AbstractHalfEdge edgeSwap(AbstractHalfEdge e)
java.lang.IllegalArgumentException
- if edge is on a boundary or belongs
to an outer triangle.public boolean isValid()
isValid(true)
.
isValid(boolean)
public boolean isValid(boolean constrained)
constrained
- true
if mesh is constrained.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |