Class Polyhedron_3<X extends Point_>
java.lang.Object
Jcg.polyhedron.Polyhedron_3<X>
- Record Components:
X- the type of geometric coordinates (2D or 3D), real or integer coordinates
Pointer-based implementation of the Half-edge data structure for polyhedral meshes
(for representing planar and surface orientable meshes).
This data structure allows us to represent both planar maps (embedded in 2D) and 3D surface meshes (embedded in R^3).
The generic type
This data structure allows us to represent both planar maps (embedded in 2D) and 3D surface meshes (embedded in R^3).
The generic type
X allows us to choose between the two cases: X may be set either as Point_2
or Point_3- Author:
- Luca Castelli Aleardi (Ecole Polytechnique, INF562/INF574, 2010-2022)
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intdynamic array storing the faces of the meshdynamic array storing the half-edges of the meshstatic final intintdynamic array storing the vertices of the mesh -
Constructor Summary
ConstructorsConstructorDescriptionPolyhedron_3(int n, int e, int f) Initialize a polyhedron wiith a given number of vertices, edges and faces -
Method Summary
Modifier and TypeMethodDescriptionaddTriangleToBorder(Halfedge h, X point) Creates a new triangle facet within the hole incident to 'h' by connecting the tip of 'h' with two new halfedges and a new vertex.voidclean()Remove all undefined (nullreferences) vertices, half-edges and faces.voidcreateCenterVertex(Face<X> f, X point) Split a face by inserting a new vertexvoidvoidPerform the collapse of half-edge e=(u,v).Return a string representing the list of facesErase the vertex 'v' pointed by 'e', by replacing the star of 'v' by a new face.voideraseCenterVertex(Vertex<X> v) Replace the star of a vertex v by a new face.Return a string representing the list of facesvoidPerform the flip of an edge e=(u, v)
Remarks:
-) an edge can be flipped only if the two incident faces (u, v, w) and (u, v, z) are both triangles
-) boundary edges cannot be flipped
-) w and z must be not adjacent: otherwise we create a multiple edgeintgenus()Return the genus of the mesh (given by Euler formula).Return all separating separating containing the half-edge 'e1'.Return all separating separating in the triangulation
Warnings:
-) it assumes that all edges and vertices have an index
-) it works only for (closed) triangulationsbooleanisClosed()Check whether the mesh is closed (no boundaries)booleanCheck whether three edges define an (oriented) cycle of length 3 (a triangle, not necessarily a face).booleanCheck whether three half-edges define a triangle face of the mesh.booleanCheck whether all vertices have degree exactly two.booleanCheck whether the polyhedral surface is a quad mesh (all faces are quadrangles)booleanCheck whether the polyhedral surface is a triangle mesh (all faces are triangles)booleanCheck whether all vertices have degree exactly three.booleanCheck whether three edges define an (oriented) cycle of length 3 (a triangle, not necessarily a face).booleanisTriangle(Halfedge<X> h) Warning: not implemented yetbooleanisValid(boolean borders) Check whether the polyhedral surface is combinatorially consistent: manifold polygonal mesh.
Ifborders==truenormalization of the border edges is checked too.Join the the facets incident to the half-edge h.makeTriangle(X p1, X p2, X p3) A triangle with border edges is added to the polyhedral surface.intCompute and return the number of boundariesvoidReset indices for all: vertices, faces and halfedges.intintintSplit the half-edge h=(u,v) by inserting a new vertex, with coordinates given by the point p.splitFacet(Halfedge<X> h, Halfedge<X> g) Split the facet incident to h and g into two facets with a new diagonal between the two vertices denoted by h and g respectively.intvertexDegree(Vertex<X> v) compute the degree of a vertexReturn a string representing the list of vertices
-
Field Details
-
NOTHING
public static final int NOTHING- See Also:
-
ALL
public static final int ALL- See Also:
-
verbosity
public int verbosity -
vertices
-
facets
-
halfedges
-
-
Constructor Details
-
Polyhedron_3
public Polyhedron_3() -
Polyhedron_3
public Polyhedron_3(int n, int e, int f) Initialize a polyhedron wiith a given number of vertices, edges and faces- Parameters:
n- number of verticese- number of half-edgesf- number of faces
-
-
Method Details
-
clean
public void clean()Remove all undefined (nullreferences) vertices, half-edges and faces.
Indices of vertices/edges/faces are reset. -
DecorateVertices
public void DecorateVertices() -
sizeOfVertices
public int sizeOfVertices() -
sizeOfFacets
public int sizeOfFacets() -
sizeOfHalfedges
public int sizeOfHalfedges() -
vertexDegree
-
isClosed
public boolean isClosed()Check whether the mesh is closed (no boundaries)- Returns:
- true if there are no border edges
-
isPureBivalent
public boolean isPureBivalent()Check whether all vertices have degree exactly two.
Warning: not implemented yet- Returns:
- true if all vertices have exactly two incident edges
-
isPureTrivalent
public boolean isPureTrivalent()Check whether all vertices have degree exactly three.
Warning: not implemented yet- Returns:
- true if all vertices have exactly three incident edges
-
isPureTriangle
public boolean isPureTriangle()Check whether the polyhedral surface is a triangle mesh (all faces are triangles)- Returns:
- true iff the every face is a triangle
-
isPureQuad
public boolean isPureQuad()Check whether the polyhedral surface is a quad mesh (all faces are quadrangles)- Returns:
- true iff the every face is a quadrangle
-
isTriangle
-
genus
public int genus()Return the genus of the mesh (given by Euler formula).
Warning: works only for meshes with one connected component- Returns:
- the genus of the mesh
-
numberOfBoundaries
public int numberOfBoundaries()Compute and return the number of boundaries -
isValid
public boolean isValid(boolean borders) Check whether the polyhedral surface is combinatorially consistent: manifold polygonal mesh.
Ifborders==truenormalization of the border edges is checked too.
This method checks that each facet is at least a triangle and that the two incident facets of a non-border edge are distinct. -
isFace
-
isCycle
-
isSeparatingCycle
Check whether three edges define an (oriented) cycle of length 3 (a triangle, not necessarily a face).
The three input halfedges are assumed to have a coherent orientation
Warning: it works only for (closed) triangulations -
getSeparatingCycles
Return all separating separating containing the half-edge 'e1'. All resulting triangles are oriented. A triangle is stored using an array of 3 hal-edges.
Warning: it works only for (closed) triangulations- Returns:
- the list of all (oriented) separating triangles
-
getSeparatingTriangles
-
flipEdge
Perform the flip of an edge e=(u, v)
Remarks:
-) an edge can be flipped only if the two incident faces (u, v, w) and (u, v, z) are both triangles
-) boundary edges cannot be flipped
-) w and z must be not adjacent: otherwise we create a multiple edge- Parameters:
e- the half-edge to be flipped
-
createCenterVertex
-
eraseCenterVertex
-
eraseCenterVertex
Erase the vertex 'v' pointed by 'e', by replacing the star of 'v' by a new face.
Warning: this method is not computationally efficient, requiring O(n) time: it remove all elements (6 halfedges, 1 vertex, 2 faces) from the corresponding collections ('ArrayList').Remarks:
-) it only does work with vertices having degree 3
-) the faces incident to vertex 'v' are assumed to exist (no holes incident to 'v')
-) faces are assumed to be ccw oriented (only for combinatorics)- Returns:
- the halfedge h which precedes 'e' in ccw direction (in the new triangular face)
-
makeHole
-
fillHole
-
addTriangleToBorder
-
makeTriangle
-
splitFacet
Split the facet incident to h and g into two facets with a new diagonal between the two vertices denoted by h and g respectively.
Returnsh->next()after the operation, i.e., the new diagonal. The new face is to the right of the new diagonal, the old face is to the left.
The time is proportional to the distance from h to g around the facet. -
joinFacet
Join the the facets incident to the half-edge h.
Returnsh->prev()after the operation, i.e., one edge of the (merged) face.
Warning: we assume that faces and edges are indexed.
The time is proportional to the size of the two facets.- Parameters:
h- the half-edge to be removed (the two incident vertices must have degree at least three)
-
edgeCollapse
-
splitEdge
Split the half-edge h=(u,v) by inserting a new vertex, with coordinates given by the point p. As a result, a new pair of half-edges is inserted in the mesh.
Remark: it works also for meshes with boundaries.
Assumption: the half-edge must be incident to a face:h.face!=null- Parameters:
h- the half-edge to be splitp- coordinates of the new vertex to insert- Returns:
- the new inserted half-edge, having target point is p
-
resetMeshIndices
public void resetMeshIndices()Reset indices for all: vertices, faces and halfedges.
Indices correspond to the order of storage in the collections (e.g., vertex v0 is the first in the ArrayList 'vertices') -
verticesToString
Return a string representing the list of vertices -
facesToString
Return a string representing the list of faces -
edgesToString
Return a string representing the list of faces
-