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 shape defines 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.grid_sandwich(shape, uv_attr='uv', co_attr='co', uv_faces_attr='uv')[source]

Create a rectangle folded in half with overlapping boundaries identified.

Start with a rectangle of shape (2*m-1, n). Fold the rectangle along the line (m, *). Identify overlapping boundary vertices and edges. Topologically the result is a sphere.

For a shape of (3,3) one obtains

-  7--8--9--8--7
|  |  |  |  |  |
n  3--4--5--6--3
|  |  |  |  |  |
-  0--1--2--1--0

   |--m--|
   |---2*m-1---|

where vertices with equal numbers are identified.

Parameters:
shapetuple of length 2

Shape of the folded rectangle viewed from the top. Should be of the form (m, n) with m >= 2, n >= 3.

uv_attrstr or None (default=”uv”)

Name of the vertex attribute that stores the integere uv coordinates. If None, don’t set attribute.

co_attrstr or None (default=”uv”)

Name of the vertex attribute that stores some default coordinates. If None, don’t set attribute.

uv_attrstr or None (default=”uv”)

Name of the face attribute that stores the half-integer uv coordinates. If None, don’t set attribute.

Returns:
objddg.indexedfaceset.IndexedFaceSet
ddg.indexedfaceset.grid_with_periodicity(shape, periodicity=(0, 0), co_attr='co', uv_co_attr='uv')[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) with 0 <= i_0 <= shape[0] - 1 and 0 <= 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.

uv_co_attrstr or None (default=”uv”)

Name of the vertex attribute that stores the (i,j) Z^2 coordinates. If uv_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]])
>>> grid.vertex_attributes["uv"]
array([[0, 0],
       [1, 0],
       [0, 1],
       [1, 1],
       [0, 2],
       [1, 2]])
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.sample_domain(domain, sampling, unbounded_samples=11, attribute_name='uv', atol=None)[source]

Sample a rectangular domain.

Parameters:
domainlist or tuple of length 2 or 3 of list or tuple of length 2 or 3

Domain of the function passed as a nested lists/tuples representing intervals and their periodicity.

The general form of an interval is (a, b[, p]), where a and b are the lower and upper bounds of the interval respectively and p is its periodicity with p = 0 meaning non-periodic, p = 1 periodic orientation preserving and p = -1 periodic orientation reversing.

Note that for 3-dimensional domains periodicity is not supported.

samplinglist or float
List of sampling options for each direction.
This should be either a nested list with sampling options for each
direction (e.g. [[.5, ‘s’], [.1, 10, ‘c’]]), a single sampling option
used for both directions (e.g. [.1, ‘s’]), or a float
to be used as stepsize for the sampling.
The following options are supported:
‘s’ : stepsize given. The direction of the domain will be sampled with
the given stepsize. If the direction is unbounded only
[unbounded_samples] will be taken. This option is also the default, if
none is explicitely given, e.g. [.2, [.2, ‘s’]] would sample the domain
in both directions with stepsize .2.
Format: [stepsize, ‘s’]
‘t’ : total number of samples given. The direction of the domain will be
divided into the given number of unique samples in an equal fashion.
This option is only available for bounded directions.
Format: [total_samples, ‘t’]
‘c’ : compound sampling. Acts as a combination of option ‘s’ and ‘t’. For
bounded direction this acts like ‘t’, while for unbounded ones
the stepsize option is used where unbounded_samples is replaced with
the total amount of samples given.
Format: [stepsize, total_samples, ‘c’]
unbounded_samplesint (default = 11)

Amount of samples to take for unbounded directions.

attribute_namestr (default = ‘uv’)

Grid attribute name to use for the sampled coordinates.

atollist of 2 floats or float (default = None)

Tolerance to be used during the sampling. If None is given the global defaults are used. See nonexact for more information.

Returns:
ddg.indexedfaceset.IndexedFaceSet
Raises:
ValueError
if any of the given intervals is not of correct shape,
or wrong number of arguments is supplied for sampling option,
or unknown sampling option is given,
or only 2 samplings are given for a 3-dim. domain,
or unbounded interval is supposed to be sampled with option ‘t’
TypeError

if type of argument does not match sampling option, e.g. [.1, ‘t’]

NotImplementedError

if domain is not 2- or 3-dimensional

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 shape defines 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]])
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.dualize(ifs, link_vertex_attributes=True, link_face_attributes=True)[source]

Constructs indexed face set with dual combinatorics.

For the dual combinatorics vertices and faces are interchanged. The enumeration of vertices and faces corresponds to the enumeration in the original surfaces.

Parameters:
ifsddg.indexedfaceset.IndexedFaceSet

Discrete surface to be dualized.

link_vertex_attributesbool (default=True)

If True, vertix attributes of the original ifs are set as face attributes of the dual ifs

link_face_attributesbool (default=True)

If True, face attributes of the original ifs are set as vertex attributes of the dual ifs

Returns:
ddg.indexedfaceset.IndexedFaceSet

The dual surface.

ddg.indexedfaceset.face_boundary(face)[source]
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.mean_values_on_faces(ifs, attr='co')[source]

Creates a new attribute on faces with mean values of the attribute on vertices.

Parameters:
ifsddg.indexedfaceset.IndexedFaceSet

Indexed face set to create the new attribute for.

attrstr

Name of the vertex attribute, which is also used as name for the new face attribute.

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.

ddg.indexedfaceset.transform_attribute(transform, ifs, cell_type, co='uv', attribute_name='f')[source]

Add a transformed attribute to an indexed face set.

Parameters:
transformCallable

Function to transform the attribute with

ifsddg.indexedfaceset.IndexedFaceSet

Indexed face set with the given attribute

cell_typestr

Cell type on which the attribute is defined. Can be either ‘verts’, ‘edges’, or ‘faces’.

costr (default = ‘uv’)

Name of the attribute to use.

attribute_namestr (default = ‘f’)

Name of the transformed attribute

class ddg.indexedfaceset.GeneralizedIndexedFaceSet(faces=[])[source]

Bases: object

Implementation 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.

get_vertex_set()[source]

Returns the set of vertices of an 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 of tuple

List of neighbouring faces in cyclic order.

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 of OrientedFace

List of neighbouring faces in cyclic order.

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))
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.

class ddg.indexedfaceset.IndexedFaceSet(faces=[])[source]

Bases: GeneralizedIndexedFaceSet

An 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 of tuple

List of neighbouring faces in cyclic order.

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 of OrientedFace

List of neighbouring faces in cyclic order.

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: IndexedFaceSet

An 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 of tuple

List of neighbouring faces in cyclic order.

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 of OrientedFace

List of neighbouring faces in cyclic order.

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.OrientedFace(index_tuple, orientation=1)[source]

Bases: object

get_orientation()[source]
get_oriented_tuple()[source]
get_tuple()[source]
set_orientation(new_orientation)[source]
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 of tuple

List of neighbouring faces in cyclic order.

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 of OrientedFace

List of neighbouring faces in cyclic order.

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