ddg.datastructures.halfedge.modify module
Utils to modify a given surface or its cells
- ddg.datastructures.halfedge.modify.fill_hole(e)[source]
Fills a hole, i.e. a loop of boundary edges, with a face.
- Parameters:
- eedge
An interior halfedge belonging to the loop of boundary edges that is to fill.
- Returns:
- face
- Raises:
- ValueError
If there already is a face and no hole to fill.
- ddg.datastructures.halfedge.modify.join_neighbouring_faces(e)[source]
Joins two adjacent faces by removing the edge they have in common.
- Parameters:
- eedge
The edge to be removed of its corresponding surface.
- Returns:
- None
- ddg.datastructures.halfedge.modify.attach_pyramid(e)[source]
Attaches a pyramid to the loop of boundary edges along a given one.
One new triangle each is glued to every edge of the edge loop of consecutive boundary edges along
eand as well glued to the previously added triangle, such that they all share the same tip and form a pyramid.- Parameters:
- eedge
An edge of the boundary loop along which a pyramid will be attached.
- Returns:
- vertex
The newly added vertex which is the peak of the attached pyramid.
- Raises:
- ValueError
If the edge does not lie opposite to a boundary loop.
- ddg.datastructures.halfedge.modify.bridge_loops(e1, e2)[source]
Creates a bridging loop between two not yet connected loops of boundary edges or components of a surface by gluing a circular strip of new edges and quad-faces in.
The loops of edges that shall be bridged should have the same number of edges. The bridging starts with a quad connecting ‘edge1’ and ‘edge2’.
- Parameters:
- e1edge
An interior halfedge opposite to a boundary loop that shall be bridged.
- e2edge
An interior halfedge opposite to the boundary loop that shall be bridged to the first.
- Returns:
- None
- Raises:
- ValueError
If the loops don’t count the same number of edges.
- ddg.datastructures.halfedge.modify.extrude(f, remove=True)[source]
Extrude a face of a surface, adding a new face between each halfedge.
- Parameters:
- fface
A face of a surface.
- removebool (default=True)
If True, remove the face f after extrusion.
- Returns:
- The extruded face.
- ddg.datastructures.halfedge.modify.zip_digon(f)[source]
Zips a digon to an edge
- Parameters:
- fface
A digon
- Returns:
- f.edge.oppedge
- Raises:
- ValueError if parameter f is not a digon
- ddg.datastructures.halfedge.modify.join_coplanar_faces(surf, co_attr='co', atol=None, rtol=None)[source]
Investigates whether a surface has triangulated, planar faces and if needed the triangulation will be removed, i.e. triangles will be joined to a face with more than three vertices.
- Parameters:
- surfsurface
The halfedge surface.
- co_attrstr
The attribute name that contains the coordinate attribute of the vertices.
- atol, rtolfloat or None (default=None)
Tolerances used to determine whether two faces are coplanar.
This function uses the global tolerance defaults if
atolorrtolare set to None. Seeddg.nonexactfor details.
- ddg.datastructures.halfedge.modify.remove_face(f)[source]
Removes a specified face from its surface.
The corresponding halfedges will be retained and their face set to be None.
- Parameters:
- fface
The face to be removed of its corresponding surface.
- Returns:
- None
- ddg.datastructures.halfedge.modify.remove_vertex(v)[source]
Remove a vertex from a surface.
Also removes all incoming and outgoing edges and any faces that these edges belong to.
- Parameters:
- vvertex
The vertex to be removed from the surface it belongs to.
- ddg.datastructures.halfedge.modify.remove_edge(e)[source]
Remove an edge from a surface.
Also removes faces that
eore.oppbelong to.- Parameters:
- eedge
- ddg.datastructures.halfedge.modify.split_face_at(f, v1, v2)[source]
Insert a new edge between two vertices and thereby split a face into two.
- Parameters:
- fface
The face that will be split into two faces.
- v1, v2vertex
The vertices between a new edge will be inserted to split the face. They need to be vertices in the boundary of
f.
- Returns:
- new_edgeedge
Returns the just added halfedge which is pointing towards v2, i.e. with
edge.head == v2andedge.tail == v1.
- ddg.datastructures.halfedge.modify.stellar_subdivide(f)[source]
Adds a new vertex and subdivides the given face by stellar subdivision.
The given face
fsubdivides into number of boundary edges many triangular faces. The former face is removed.- Parameters:
- fface
- Returns:
- peakvertex
The newly added vertex.
See also
datastructures.halfedge.modify.subdivideSubdivides a half-edge surface’s faces by bisecting the edges and connecting the new vertices.
- ddg.datastructures.halfedge.modify.subdivide_edge(e, number_of_segments)[source]
Subdivides an edge into the given number of segments.
- Parameters:
- eedge
A halfedge of the edge that will be subdivided.
- number_of_segmentsint
The number of segments the edge will be subdivided into.
- Returns:
- list containing
segment of newly subdivided edge based at
e.tailsegment of newly subdivided edge based at
e.opp.tailList of all vertices that were added by subdivision.
- ddg.datastructures.halfedge.modify.contract_edge(e)[source]
Contract an edge and remove the edge and its opposite from the surface.
Note that this can alter the manifold property if an adjacent face is a triangle or
e.headande.tailare boundary vertices:*-----* * /| | /| * |e | -> *--* | \| | \| *-----* * *-----*-----* * * | | | |\ /| | |e | -> | * | | | | |/ \| *-----*-----* * *
- Parameters:
- eedge
to be contracted
- Returns:
- edge, edge
e.pre and e.opp.pre of the contracted edges. Be careful: these edges might also have been deleted if they coincided with e or e.opp
- ddg.datastructures.halfedge.modify.contract_face(f)[source]
Contract a face to a vertex.
Note that this can alter the manifold property if neighboring faces of
fare triangles or opposite sides offare part of a boundary:*-----* /| | * | f | -> *--* \| | *-----* *-----*-----*-----* * * | | | | |\ /| | | f | | -> | * | | | | | |/ \| *-----*-----*-----* * *
- Parameters:
- fface
to be contracted
- Returns:
- vertex
the face was contracted to
- ddg.datastructures.halfedge.modify.subdivide(surface, steps=1, co_attr='co')[source]
Subdivides a half-edge surface’s faces by bisecting the edges and connecting the new vertices.
Bisects every edge of the surface into two segments and a new vertex. Then the vertices of any face form a cycle in which the old and new vertices alternate. The new vertices are connected in this order. This procedure is repeated steps many times. The number of new faces is exponential in steps.
- Parameters:
- surfddg.halfege.Surface
The half-edge surface.
- steps: int (default=1)
Number of repeated subdivisions.
- co_attrstr or None (default=’co’)
A string can be given representing the attribute name that contains the coordinate attribute of the vertices. Then the vertex subdividing the edge is set to its midpoint. If None is given the subdivision is purely combinatorial.
- Returns:
- None
See also
ddg.halfedge.modify.stellar_subdivideAdds a new vertex and subdivides the given face by stellar subdivision.
- ddg.datastructures.halfedge.modify.reverse_orientation(s)[source]
Function to reverse the orientation of edges of a surface.
- Parameters:
- s: ddg.halfedge.Surface
Surface to reverse the orientation on
- ddg.datastructures.halfedge.modify.diagonals(hds, boundary_face_incidence=4, append_single_edges=True)[source]
Creates two hds’ with the diagonal combinatorics to the given hds.
The given hds will be bi-colored and if a vertex of one color is adjacent to more than two vertices of the other color this vertex will be replaced by a face build from the surrounding vertices. In this sense two new halfedge data structures are build. The vertices inherit all (manually set) attributes of the given vertices an additionally have an attribute ‘old_index’ storing the previous vertex index.
- Parameters:
- hds: ddg.datastructures.halfedge.Surface
Surface to create the hds’ from. It must be able to apply halfedge.set.bicolor_vertices to this.
- boundary_face_incidence: int (default=4)
If a boundary vertex is incident to at least this many vertices of the other color, then a face will be added in the above sense. If it is adjacent to less, only the edges will be added, excluding the edge along the boundary of the original surface.
- append_single_edges: bool (default=True)
If set to ‘True’ edges that do not belong to a face will be added (i.e., ‘tentacles’ at the corners of rectangular grid-like hds). This means the resulting hds might not be a manifold.
- Returns:
- hds1, hds2
The resulting hds’ of diagonal combinatoric.
- Raises:
- ddg.datastructures.indexedfaceset.utils.BoundaryException
If in the resulting surface two faces are only connected to each other by one vertex, like this:
/\/\ \/\/