ddg.indexedfaceset package
Module contents
- ddg.indexedfaceset.arrow(resolution=20, heights=(0, 0.7, 0.7, 1), radii=(0.05, 0.05, 0.125), co_attr='co')[source]
Create an arrow as an indexed face set.
This is useful to visualise vectors.
By default, the arrow will point up. The bottom will be at (0, 0, 0) and the tip at (0, 0, 1).
- Parameters:
- resolutionint (default=20)
The amount of vertices at the base of the tip
- heightsfloat sequence of length 4 (default=(0, 0.7, 0.7, 1))
First element defines height of the bottom of the stick, the second the height of the top of the stick, the third the height of the base of the head and the fourth the height of the tip.
- radiifloat sequence of length 3 (default=(0.05, 0.05, 0.125))
First element defines the radius of the bottom of the stick, second the radius of the top of the stick and the third the radius of the base of the tip.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
An arrow.
- ddg.indexedfaceset.cone(resolution=20, fill_caps=True, radius=1, length=1, center=(0, 0, 0), normal=(0, 0, 1), co_attr='co')[source]
Create a cone as an indexed face set.
By default, the cone’s base will be at (0, 0, 0) and its tip at (0, 0, 1).
- Parameters:
- resolutionint (default=20)
The number of vertices of the base.
- fill_caps: bool (default=True)
If
True, include the face of the base.- radiusfloat (default=1)
The radius of the base of the cone.
- lengthfloat (default=1)
The length of the cone.
- centerarray_like of shape (3,) (default=(0, 0, 0))
The center of the base of the cone.
- normalarray_like of shape (3,) (default=(0, 0, 1))
The normal of the cone’s base face.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A cone.
- ddg.indexedfaceset.cube(co_attr='co')[source]
Create a cube as an indexed face set
By default, standard coordinates of a unit cube, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A cube.
- ddg.indexedfaceset.cylinder(resolution=20, fill_caps=True, top_radius=1, bot_radius=1, length=1, center=(0, 0, 0), normal=(0, 0, 1), co_attr='co')[source]
Create a cylinder as an indexed face set.
By default, the cylinder’s bottom will be at (0, 0, 0) and its top at (0, 0, 1).
- Parameters:
- resolutionint (default=20)
The number of vertices on each side.
- fill_capsbool (default=True)
If
True, include the faces of the bottom and the top.- top_radiusfloat (default=1)
The radius of the top of the cylinder.
- bot_radiusfloat (default=1)
The radius of the bottom of the cylinder
- lengthfloat (default=1)
The length of the cylinder.
- centerarray_like of shape (3,) (default=(0, 0, 0))
The center of the bottom of the cylinder.
- normalarray_like of shape (3,) (default=(0, 0, 1))
The normal of the cylinder’s top and bottom faces.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A cylinder.
- ddg.indexedfaceset.disc(resolution=20, center=(0, 0, 0), normal=(0, 0, 1), radius=1, co_attr='co')[source]
Create a disc as an indexed face set.
By default, the disc is centered at (0, 0, 0), the normal is (0, 0, 1) and the radius is 1.
- Parameters:
- resolutionint (default=20)
The amount of vertices of the disc
- centerarray_like of shape (3,) (default=(0, 0, 0))
The center of the disc as a list in 3D space.
- normalarray_like of shape (3,) (default=(0, 0, 1))
The normal vector of the disc.
- radiusfloat (default=1)
The radius of the disc.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A disc.
- ddg.indexedfaceset.dodecahedron(co_attr='co')[source]
Create a dodecahedron as an indexed face set.
By default, standard coordinates of a unit dodecahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A dodecahedron.
- ddg.indexedfaceset.grid(shape, co_attr='co')[source]
Create a quad grid as an indexed face set.
The
shapedefines the number of vertices in each direction. Both 2D and 3D grids are supported.- Parameters:
- shapetuple of length 2 or 3
Shape of the grid. The first entry is the number of vertices in the x-direction, the second the number of vertices in the y-direction and the third (if given) the number of vertices in the z-direction.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A quad grid.
Examples
>>> import ddg >>> quad_grid = ddg.indexedfaceset.grid((2, 3)) >>> quad_grid.vertex_attributes["co"] array([[0, 0], [1, 0], [0, 1], [1, 1], [0, 2], [1, 2]])
>>> quad_grid = ddg.indexedfaceset.grid((2, 3, 1)) >>> quad_grid.vertex_attributes["co"] array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 2, 0], [1, 2, 0]])
>>> quad_grid = ddg.indexedfaceset.grid((2, 3, 2)) >>> quad_grid.vertex_attributes["co"] array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 2, 0], [1, 2, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1], [0, 2, 1], [1, 2, 1]])
- ddg.indexedfaceset.icosahedron(co_attr='co')[source]
Create an icosahedron as an indexed face set.
By default, standard coordinates of a unit icosahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
An icosahedron.
- ddg.indexedfaceset.octahedron(co_attr='co')[source]
Create an octahedron as an indexed face set.
By default, standard coordinates of a unit octahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
An octahedron.
- ddg.indexedfaceset.tetrahedron(co_attr='co')[source]
Create a tetrahedron as an indexed face set.
By default, standard coordinates of a unit tetrahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A tetrahedron.
- ddg.indexedfaceset.triangle_grid(shape, co_attr='co')[source]
Create a triangle grid as an indexed face set.
The
shapedefines the number of vertices in each direction. Currently only supports 2D grids and planar grids in 3D.- Parameters:
- shapetuple of length 2 or 3
Shape of the grid. The first entry is the number of vertices in the x-direction, the second the number of vertices in the y-direction and the third (if given) the number of vertices in the z-direction.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A triangle grid.
Examples
>>> import ddg >>> tri_grid = ddg.indexedfaceset.triangle_grid((2, 3)) >>> tri_grid.vertex_attributes["co"] array([[0, 0], [2, 0], [1, 2], [3, 2], [2, 4], [4, 4]])
>>> tri_grid = triangle_grid((2, 3, 1)) >>> tri_grid.vertex_attributes["co"] array([[0, 0, 0], [2, 0, 0], [1, 2, 0], [3, 2, 0], [2, 4, 0], [4, 4, 0]])
- ddg.indexedfaceset.grid_with_periodicity(shape, periodicity=(0, 0), co_attr='co')[source]
Create a quad grid with a periodicity as an indexed face set.
A quad grid with periodicity
(0, 0)is the box in Z^2 with lower-left corner(0, 0)and upper-right corner(shape[0] - 1, shape[1] - 1). In other words, the vertices are(i_0, i_1)with0 <= i_0 <= shape[0] - 1and0 <= i_1 <= shape[1] - 1. A quad grid with periodicity not equal to(0, 0)is obtained from the quad grid with periodicity(0, 0)by gluing the boundary edges as described in the table below.- Parameters:
- shapetuple of length 2
Shape of the grid. The first entry is the number of vertices in the x-direction, the second the number of vertices in the y-direction.
- periodicitytuple of length 2 (default=(0,0))
The periodicity of the grid. This is only meaningful in case of 2D grid. For 3D shape this attribute doesn’t have any effect.
Periodicity
Topology
Gluing Axis
(0, 0)
Disk
None
(1, 0)
Cylinder
along the first axis
(0, 1)
Cylinder
along the second axis
(1, 1)
Torus
along both axes
(-1, 0)
Moebius Band
along the first axis in reversed orientation
(0, -1)
Moebius Band
along the second axis in reversed orientation
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.indexedfaceset.IndexedFaceSet
A quad grid.
Examples
>>> import ddg >>> grid = ddg.indexedfaceset.grid_with_periodicity((2, 3), periodicity=(1, 0)) >>> grid.face_list() [(0, 1, 3, 2), (2, 3, 5, 4), (0, 1, 3, 2), (2, 3, 5, 4)] >>> grid.vertex_attributes["co"] array([[ 1.0000000e+00, 0.0000000e+00, 0.0000000e+00], [-1.0000000e+00, 0.0000000e+00, 1.2246468e-16], [ 1.0000000e+00, 1.0000000e+00, 0.0000000e+00], [-1.0000000e+00, 1.0000000e+00, 1.2246468e-16], [ 1.0000000e+00, 2.0000000e+00, 0.0000000e+00], [-1.0000000e+00, 2.0000000e+00, 1.2246468e-16]])
- exception ddg.indexedfaceset.BoundaryException[source]
Bases:
Exception- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception ddg.indexedfaceset.NonManifoldException[source]
Bases:
Exception- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception ddg.indexedfaceset.NonOrientableException[source]
Bases:
Exception- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- ddg.indexedfaceset.diags_from_faces(faces)[source]
Calculates diagonals of the faces of a quadrilateral mesh.
- Parameters:
- facesnp.ndarray
Array of faces In case only one face exists, it should be passed as a 2D array
- Returns:
- tuple
a tuple of 2d array of two sets of diagonals of the quads
- ddg.indexedfaceset.indexed_face_set_to_surface(ifs, vertex_index_attribute='ifs_index', face_index_attribute='ifs_face_index')[source]
Convert an indexed face set to a half edge data structure. If the indexed face set can not be converted an empty half edge data structure is returned.
- ddg.indexedfaceset.is_manifold(ifs)[source]
Returns whether every edge of the non oriented indexed face set is contained in at most two faces.
- ddg.indexedfaceset.orient(src_ifs, face_map={})[source]
Try to orient a given indexed face set. Raises Value Error if the given set is not orientable.
- class ddg.indexedfaceset.GeneralizedIndexedFaceSet(faces=[])[source]
Bases:
objectImplementation of a combinatorial indexed face set data structure with a list of faces and some utility functions.
- Parameters:
- faces: list
List of face tuples that will generate the indexed face set.
- set_attribute(attr_name, cell_type, attribute, cell_subset=None)[source]
Method to add attributes to cells of an ifs. If the attribute already exists, it changes it. If only a subset is specified, it only updates the subset values.
- Parameters:
- cell_type: str
Type of cell to which the attribute must be added
- attr_namestr
Name of the attribute
- attributeSubscriptable object
A subscriptable object of the attributes to be assigned to each vertex
- cell_subset: set or list depending on the cell type
if the cells in question are not the whole cells of the ifs but a subset of it, they must be given as input in this parameter
- Returns:
- dict
A nested dictionary of all attributes of vertices
- delete_attribute(attr_name, cell_type)[source]
Deletes the attribute given by its name
- Parameters:
- attr_namestr
Name of the attribute
- cell_type: str
Type of cell to which the attribute must be added
- get_attribute(attr_name, cell_type, cell)[source]
get cell attribute
- Parameters:
- attr_namestr
Name of the attribute. Represents keys for the attribute dictionaries
- cell_typestr
Type of cell from which the attribute is to be retrieved
- cellfloat or int for verts, tuples for edges and faces
The cell to which the attribute is assigned. Type depends on the type of the inputs given to create the class.
- Returns:
- The attribute in the specified position. Type depends on the attribute type.
- adjacent_faces_with_orientation(edge)[source]
Get a list of oriented faces adjacent to an given edge.
The resulting faces are of the class OrientedFace with self.orientation = 1 if they contain the edge in the given orientation or self.orientation = -1 if they contain the edge in reversed orientation.
- Parameters:
- edgetuple
Tuple of two integers.
- Returns:
- list
List of instances of the class OrientedFace that are adjacent to the input edge.
- adjacent_faces(edge)[source]
Get a list of faces, i.e. tuples adjacent to an given edge.
- Parameters:
- edgetuple
Tuple of two integers.
- Returns:
- list
List of tuples that represent all adjacent faces despite of orientation.
- opposite_face(face, edge)[source]
Get the other face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- tuple
The other face incident to the given edge.
- None
If edge is adjacent to only one or more than two faces.
- opposite_face_with_orientation(face, edge)[source]
Get the other oriented face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- OrientedFace
The other face incident to the given edge.
- NoneFace
If edge is adjacent to only one or more than two faces.
- neighboring_faces(face)[source]
Get all faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..tuple ..If there exist exactly one neighbouring face to an edge. ..None ..If edge is adjacent to only one or more than two faces. ..
- neighboring_faces_with_orientation(face)[source]
Get all oriented faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..OrientedFace ..If there exist exactly one neighbouring face to an edge. ..NoneFace ..If edge is adjacent to only one or more than two faces. ..
- face_list()[source]
Get all faces of the indexed face set.
- Returns:
- list
List of tuples representing the faces of the indexed face set.
- number_of_faces()[source]
Get the number of faces of the indexed face set.
- Returns:
- int
Number of faces of the indexed face set.
- edge_set()[source]
Get all edges of the indexed face set.
- Returns:
- set
Unordered set of tuples of two integers representing all edges.
- face_boundary(face)[source]
Returns a set of edges bounding the face.
The edges are tuples orded by the orientation of the face.
- Parameters:
- facetuple
The face to be investigated.
- Returns:
- tuple
tuple with ordered edge tuples
Examples
>>> from ddg.indexedfaceset import GeneralizedIndexedFaceSet >>> faceSet = GeneralizedIndexedFaceSet([(1, 2, 4), (2, 3, 4)]) >>> faceSet.face_boundary((1, 2, 4)) ((1, 2), (2, 4), (4, 1))
- class ddg.indexedfaceset.IndexedFaceSet(faces=[])[source]
Bases:
GeneralizedIndexedFaceSetAn indexed face set whose vertices must be integers of indices 0 to n-1 only. The attributes of cells for this class are also restricted to numpy arrays only.
- cell_index(cell_type, cell)[source]
Method to get the index of the given cell. Vertices are already indices. Mostly used to get the cell of edges and faces
- Parameters:
- cell_typestr
type of cells to be indiced. “verts”, “edges” or “faces” are the proper values.
- cellint for verts, tuples for edges and faces
the cell to be indiced.
- Returns:
- The index of the cell
- get_attribute(attr_name, cell_type, cell)[source]
‘Get’ method corresponding the attribute structure of the subclass to override the same method in the parent class
- Parameters:
- cell_typestr
Type of cell from which the attribute are to be recalled
- cell_typestr
Type of cell from which the attribute is to be retrieved
- cellint for verts, int or tuples for edges and faces
The cell or its index. For vertices, these two are the same. For edges and faces these are different. Both form are accepted.
- Returns:
- numpy.ndarray
The attribute in the specified position.
- set_attribute(attr_name, cell_type, attribute, dtype=<class 'float'>)[source]
Method to create a dictionary of attributes for a given cell type.
- Parameters:
- attr_namestr
Name of the attribute to get in string
- attributenp.ndarray
An array of the attributes to be set
- Returns:
- Attribute dictionary
- edge_vertex_list(vertex_index)[source]
Method to find the edges which share a specific vertex.
- Parameters:
- vertex_indexint
The index of the vertex to be found (0,…, n-1)
- Returns:
- numpy.ndarray
2D array of edges as tuples
- face_vertex_list(vertex_index)[source]
Method to find the faces which share a specific vertex
- Parameters:
- vertex_indexint
The index of the vertex to be found (0,…, n-1)
- Returns:
- numpy.ndarray
returns indices of faces
- face_vertex_dict(vertex_index)[source]
Method to create a dictionary which has as values the arrays of faces with which they share a specific vertex and as keys the number of edges of the faces
- Parameters:
- vertex_indexint
The index of the vertex to be found (0,…, n-1)
- Returns:
- dict
Keys : the number of edges of faces Values : thoses faces with the key number of edges which share the input vertex
- face_edge_list(edge_index)[source]
Method to find the faces which share a specific edge
- Parameters:
- edge_indexint
The index of the edge
- Returns:
- numpy.ndarray
For non-uniform meshes the return value is a 1D array of faces as tuples For uniform meshes the return value is a 2D array
- is_boundary_vertex(vertex_index)[source]
checks if a vertex is a boundary vertex or not
- Parameters:
- vertex_index1D list or array
the index of the vertex in question
- Returns:
- True if the the vertex is a boundary vertex, otherwise False
- property boundary_vertices
Method to create a set of boundary vertices of the ifs
- add_face(face)
Adds face to the indexed face set.
Simply adds the face without paying attention to the maifold property.
- Parameters:
- facetuple
The face to be investigated.
- adjacent_faces(edge)
Get a list of faces, i.e. tuples adjacent to an given edge.
- Parameters:
- edgetuple
Tuple of two integers.
- Returns:
- list
List of tuples that represent all adjacent faces despite of orientation.
- adjacent_faces_with_orientation(edge)
Get a list of oriented faces adjacent to an given edge.
The resulting faces are of the class OrientedFace with self.orientation = 1 if they contain the edge in the given orientation or self.orientation = -1 if they contain the edge in reversed orientation.
- Parameters:
- edgetuple
Tuple of two integers.
- Returns:
- list
List of instances of the class OrientedFace that are adjacent to the input edge.
- delete_attribute(attr_name, cell_type)
Deletes the attribute given by its name
- Parameters:
- attr_namestr
Name of the attribute
- cell_type: str
Type of cell to which the attribute must be added
- edge_set()
Get all edges of the indexed face set.
- Returns:
- set
Unordered set of tuples of two integers representing all edges.
- face_boundary(face)
Returns a set of edges bounding the face.
The edges are tuples orded by the orientation of the face.
- Parameters:
- facetuple
The face to be investigated.
- Returns:
- tuple
tuple with ordered edge tuples
Examples
>>> from ddg.indexedfaceset import GeneralizedIndexedFaceSet >>> faceSet = GeneralizedIndexedFaceSet([(1, 2, 4), (2, 3, 4)]) >>> faceSet.face_boundary((1, 2, 4)) ((1, 2), (2, 4), (4, 1))
- face_list()
Get all faces of the indexed face set.
- Returns:
- list
List of tuples representing the faces of the indexed face set.
- get_vertex_set()
Returns the set of vertices of an indexed face set
- neighboring_faces(face)
Get all faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..tuple ..If there exist exactly one neighbouring face to an edge. ..None ..If edge is adjacent to only one or more than two faces. ..
- neighboring_faces_with_orientation(face)
Get all oriented faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..OrientedFace ..If there exist exactly one neighbouring face to an edge. ..NoneFace ..If edge is adjacent to only one or more than two faces. ..
- number_of_faces()
Get the number of faces of the indexed face set.
- Returns:
- int
Number of faces of the indexed face set.
- opposite_face(face, edge)
Get the other face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- tuple
The other face incident to the given edge.
- None
If edge is adjacent to only one or more than two faces.
- opposite_face_with_orientation(face, edge)
Get the other oriented face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- OrientedFace
The other face incident to the given edge.
- NoneFace
If edge is adjacent to only one or more than two faces.
- class ddg.indexedfaceset.NgonalIndexedFaceSet(faces=array([], dtype=float64))[source]
Bases:
IndexedFaceSetAn indexed face set whose faces are of constant valency of k.
- face_vertex_array(vertex_index)[source]
Method to find the faces which share a specific vertex. Overrides the method in parent class.
- Parameters:
- vertex_indexint
The index of the vertex to be found (0,…, n-1)
- Returns:
- numpy.ndarray
returns indices of faces
- face_vertex_incidence()[source]
Method to create the valencies.
- Returns:
- list
the list of valencies in the same order of vertex index
- face_edge_incidence()[source]
Method to create the valency for edge-face.
- Returns:
- list
the list of face-edge-valency in the same order of edge index
- add_face(face)
Adds face to the indexed face set.
Simply adds the face without paying attention to the maifold property.
- Parameters:
- facetuple
The face to be investigated.
- adjacent_faces(edge)
Get a list of faces, i.e. tuples adjacent to an given edge.
- Parameters:
- edgetuple
Tuple of two integers.
- Returns:
- list
List of tuples that represent all adjacent faces despite of orientation.
- adjacent_faces_with_orientation(edge)
Get a list of oriented faces adjacent to an given edge.
The resulting faces are of the class OrientedFace with self.orientation = 1 if they contain the edge in the given orientation or self.orientation = -1 if they contain the edge in reversed orientation.
- Parameters:
- edgetuple
Tuple of two integers.
- Returns:
- list
List of instances of the class OrientedFace that are adjacent to the input edge.
- property boundary_vertices
Method to create a set of boundary vertices of the ifs
- cell_index(cell_type, cell)
Method to get the index of the given cell. Vertices are already indices. Mostly used to get the cell of edges and faces
- Parameters:
- cell_typestr
type of cells to be indiced. “verts”, “edges” or “faces” are the proper values.
- cellint for verts, tuples for edges and faces
the cell to be indiced.
- Returns:
- The index of the cell
- delete_attribute(attr_name, cell_type)
Deletes the attribute given by its name
- Parameters:
- attr_namestr
Name of the attribute
- cell_type: str
Type of cell to which the attribute must be added
- edge_set()
Get all edges of the indexed face set.
- Returns:
- set
Unordered set of tuples of two integers representing all edges.
- edge_vertex_list(vertex_index)
Method to find the edges which share a specific vertex.
- Parameters:
- vertex_indexint
The index of the vertex to be found (0,…, n-1)
- Returns:
- numpy.ndarray
2D array of edges as tuples
- face_boundary(face)
Returns a set of edges bounding the face.
The edges are tuples orded by the orientation of the face.
- Parameters:
- facetuple
The face to be investigated.
- Returns:
- tuple
tuple with ordered edge tuples
Examples
>>> from ddg.indexedfaceset import GeneralizedIndexedFaceSet >>> faceSet = GeneralizedIndexedFaceSet([(1, 2, 4), (2, 3, 4)]) >>> faceSet.face_boundary((1, 2, 4)) ((1, 2), (2, 4), (4, 1))
- face_edge_list(edge_index)
Method to find the faces which share a specific edge
- Parameters:
- edge_indexint
The index of the edge
- Returns:
- numpy.ndarray
For non-uniform meshes the return value is a 1D array of faces as tuples For uniform meshes the return value is a 2D array
- face_list()
Get all faces of the indexed face set.
- Returns:
- list
List of tuples representing the faces of the indexed face set.
- face_vertex_dict(vertex_index)
Method to create a dictionary which has as values the arrays of faces with which they share a specific vertex and as keys the number of edges of the faces
- Parameters:
- vertex_indexint
The index of the vertex to be found (0,…, n-1)
- Returns:
- dict
Keys : the number of edges of faces Values : thoses faces with the key number of edges which share the input vertex
- face_vertex_list(vertex_index)
Method to find the faces which share a specific vertex
- Parameters:
- vertex_indexint
The index of the vertex to be found (0,…, n-1)
- Returns:
- numpy.ndarray
returns indices of faces
- get_attribute(attr_name, cell_type, cell)
‘Get’ method corresponding the attribute structure of the subclass to override the same method in the parent class
- Parameters:
- cell_typestr
Type of cell from which the attribute are to be recalled
- cell_typestr
Type of cell from which the attribute is to be retrieved
- cellint for verts, int or tuples for edges and faces
The cell or its index. For vertices, these two are the same. For edges and faces these are different. Both form are accepted.
- Returns:
- numpy.ndarray
The attribute in the specified position.
- get_vertex_set()
Returns the set of vertices of an indexed face set
- is_boundary_vertex(vertex_index)
checks if a vertex is a boundary vertex or not
- Parameters:
- vertex_index1D list or array
the index of the vertex in question
- Returns:
- True if the the vertex is a boundary vertex, otherwise False
- neighboring_faces(face)
Get all faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..tuple ..If there exist exactly one neighbouring face to an edge. ..None ..If edge is adjacent to only one or more than two faces. ..
- neighboring_faces_with_orientation(face)
Get all oriented faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..OrientedFace ..If there exist exactly one neighbouring face to an edge. ..NoneFace ..If edge is adjacent to only one or more than two faces. ..
- number_of_faces()
Get the number of faces of the indexed face set.
- Returns:
- int
Number of faces of the indexed face set.
- opposite_face(face, edge)
Get the other face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- tuple
The other face incident to the given edge.
- None
If edge is adjacent to only one or more than two faces.
- opposite_face_with_orientation(face, edge)
Get the other oriented face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- OrientedFace
The other face incident to the given edge.
- NoneFace
If edge is adjacent to only one or more than two faces.
- set_attribute(attr_name, cell_type, attribute, dtype=<class 'float'>)
Method to create a dictionary of attributes for a given cell type.
- Parameters:
- attr_namestr
Name of the attribute to get in string
- attributenp.ndarray
An array of the attributes to be set
- Returns:
- Attribute dictionary
- class ddg.indexedfaceset.NoneFace[source]
Bases:
OrientedFace- get_orientation()
- get_oriented_tuple()
- get_tuple()
- set_orientation(new_orientation)
- class ddg.indexedfaceset.OrientedIndexedFaceSet(face_list=[])[source]
Bases:
GeneralizedIndexedFaceSet- adjacent_faces(edge)[source]
Get a list of faces adjacent to an edge given as a tuple of integers. The faces are ordered such that they contain the given edge in the given orientation.
- add_face(face)[source]
Adds face to the indexed face set.
Simply adds the face without paying attention to the maifold property.
- Parameters:
- facetuple
The face to be investigated.
- adjacent_faces_with_orientation(edge)
Get a list of oriented faces adjacent to an given edge.
The resulting faces are of the class OrientedFace with self.orientation = 1 if they contain the edge in the given orientation or self.orientation = -1 if they contain the edge in reversed orientation.
- Parameters:
- edgetuple
Tuple of two integers.
- Returns:
- list
List of instances of the class OrientedFace that are adjacent to the input edge.
- delete_attribute(attr_name, cell_type)
Deletes the attribute given by its name
- Parameters:
- attr_namestr
Name of the attribute
- cell_type: str
Type of cell to which the attribute must be added
- edge_set()
Get all edges of the indexed face set.
- Returns:
- set
Unordered set of tuples of two integers representing all edges.
- face_boundary(face)
Returns a set of edges bounding the face.
The edges are tuples orded by the orientation of the face.
- Parameters:
- facetuple
The face to be investigated.
- Returns:
- tuple
tuple with ordered edge tuples
Examples
>>> from ddg.indexedfaceset import GeneralizedIndexedFaceSet >>> faceSet = GeneralizedIndexedFaceSet([(1, 2, 4), (2, 3, 4)]) >>> faceSet.face_boundary((1, 2, 4)) ((1, 2), (2, 4), (4, 1))
- face_list()
Get all faces of the indexed face set.
- Returns:
- list
List of tuples representing the faces of the indexed face set.
- get_attribute(attr_name, cell_type, cell)
get cell attribute
- Parameters:
- attr_namestr
Name of the attribute. Represents keys for the attribute dictionaries
- cell_typestr
Type of cell from which the attribute is to be retrieved
- cellfloat or int for verts, tuples for edges and faces
The cell to which the attribute is assigned. Type depends on the type of the inputs given to create the class.
- Returns:
- The attribute in the specified position. Type depends on the attribute type.
- get_vertex_set()
Returns the set of vertices of an indexed face set
- neighboring_faces(face)
Get all faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..tuple ..If there exist exactly one neighbouring face to an edge. ..None ..If edge is adjacent to only one or more than two faces. ..
- neighboring_faces_with_orientation(face)
Get all oriented faces that are adjacent to a given a face.
If an edge has none or more than one other neighbouring faces, None will be returned.
- Parameters:
- facetuple
The input face whose neighbouring faces will be determined.
- Returns:
- list
List of neighbouring faces in cyclic order. ..Includes ..OrientedFace ..If there exist exactly one neighbouring face to an edge. ..NoneFace ..If edge is adjacent to only one or more than two faces. ..
- number_of_faces()
Get the number of faces of the indexed face set.
- Returns:
- int
Number of faces of the indexed face set.
- opposite_face(face, edge)
Get the other face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- tuple
The other face incident to the given edge.
- None
If edge is adjacent to only one or more than two faces.
- opposite_face_with_orientation(face, edge)
Get the other oriented face adjacent to a given edge of a face.
If the edge is adjacent to only one or more than two faces return None.
- Parameters:
- edgetuple
Tuple of two integers.
- facetuple
The input face incuding the edge from which the other face will be determined.
- Returns:
- OrientedFace
The other face incident to the given edge.
- NoneFace
If edge is adjacent to only one or more than two faces.
- set_attribute(attr_name, cell_type, attribute, cell_subset=None)
Method to add attributes to cells of an ifs. If the attribute already exists, it changes it. If only a subset is specified, it only updates the subset values.
- Parameters:
- cell_type: str
Type of cell to which the attribute must be added
- attr_namestr
Name of the attribute
- attributeSubscriptable object
A subscriptable object of the attributes to be assigned to each vertex
- cell_subset: set or list depending on the cell type
if the cells in question are not the whole cells of the ifs but a subset of it, they must be given as input in this parameter
- Returns:
- dict
A nested dictionary of all attributes of vertices