ddg.conversion.arrays module

ddg.conversion.arrays.from_discrete_net(net, /)[source]

Compute all points and faces of a discrete net.

Parameters:
netddg.datastructures.nets.net.DiscreteNet

A net with net.domain.bounded == True.

Returns:
tuple of numpy.ndarray and numpy.ndarray

The first array is of shape (n, d) and comprises of the n points in R^d of the net. The second array is of shape (m, k) and comprises of the m faces of net.domain.face_data. Note that k isn’t necessarily equal to 3.

ddg.conversion.arrays.from_discrete_curve(curve, /)[source]

Compute all points of a discrete curve.

Parameters:
curveddg.datastructures.nets.net.DiscreteCurve

A curve with curve.domain.bounded == True.

Returns:
tuple of numpy.ndarray and bool

The array is of shape (n, d) and comprises of the n points in R^d of the curve. The bool is equal to curve.domain.periodic.

ddg.conversion.arrays.from_empty_net(_, /)[source]

Convert an empty net to an empty mesh.

Parameters:
_ddg.datastructures.nets.net.EmptyNet
Returns:
tuple of () and ()
ddg.conversion.arrays.from_point_net(net, /)[source]

Convert a point net to a mesh of one point and no faces.

Parameters:
netddg.datastructures.nets.net.PointNet
Returns:
tuple of numpy.ndarray of shape ((1, n)) and ()

The array contains the value of net(), which is a point in R^n.

ddg.conversion.arrays.from_net_collection(net_collection, /)[source]

Convert a net collection to a list of curves and meshes.

Parameters:
netsddg.datastructures.nets.net.NetCollection

Every net in the collection has to be a DiscreteCurve or DiscreteNet with bounded domain or a PointNet or an EmptyNet.

Returns:
list of curves and meshes

A curve is a pair of points and periodicity. A mesh is a pair of points and faces.

ddg.conversion.arrays.from_half_edge_surface(surface, coordinate_attribute='co', /)[source]

Get the points, isolated edges and faces of a half edge surface.

Parameters:
surfaceddg.datastructures.halfedge.Surface
coordinate_attributestr (default=”co”)
Returns:
tuple of numpy.ndarray, numpy.ndarray and list

The first array is of shape (n, d), where n is the number of points lying in R^d. The second array is of shape (k, 2), where k is the number of edges which don’t belong to a face. The list contains tuples of integers. Each tuple corresponds to a face and each integer is the index of a vertex of that face.

ddg.conversion.arrays.from_1d_subspace(line, length, /)[source]

Sample a 1-dimensional subspace.

Parameters:
lineddg.geometry.subspaces.Subspace

A subspace with line.dimension == 1.

lengthfloat

Must be greater than or equal to 0.0.

Returns:
(a, b), False

a and b are of type numpy.ndarray. b - a has length length and b - a / 2 is the closest point of the line to the origin.

Raises:
ValueError

If line.dimension != 1 or length < 0.0.

ddg.conversion.arrays.from_2d_subspace(plane, side_length_1, side_length_2, /)[source]

Convert a 2-dimensional subspace to a mesh.

The mesh is given as two triangles:

d       c
 ┌─────┐  ┐
 │    /│  │
 │   / │  │
 │  x  │  │ side_length_2
 │ /   │  │
 │/    │  │
 └─────┘  ┘
a       b
 └─────┘
 side_length_1

such that x is the closest point of the subspace to the origin.

Parameters:
planeddg.geometry.subspaces.Subspace

A subspace with subspace.dimension == 2.

side_length_1float

Must be greater than or equal to 0.0.

side_length_2float

Must be greater than or equal to 0.0.

Returns:
points, facestuple of numpy.ndarray and tuple

The first entry points has shape (4, 3) and comprises of a, b, c, d. The second entry faces comprises of two tuples of 3 integers encoding the two triangles.

Raises:
ValueError

If plane.dimension != 2 or side_length_1 < 0.0 or side_length_2 < 0.0.

ddg.conversion.arrays.from_quadric(quadric, /, *num_step)[source]

Convert a quadric to a curve or a mesh or a list thereof.

Every convertible quadric has a parametrization, which is sampled. These parametrizations are implementation details, but the following guarantees hold:

  • every parametrization is defined on a box I_1 x … x I_d, where d is the dimension of the quadric and I_1, …, I_d are possibly unbounded intervals

  • the k-th num_step argument determines how I_k is sampled
    • the first entry num of the k-th num_step determines the number of samples of I_k

    • if I_k is unbounded, the second entry step of the k-th num_step determines the step size between the samples of I_k

Consequently,

  • increasing the num arguments increases the number of points and additionally the number of faces if the quadric is 2-dimensional.

  • if I_k isn’t bounded, decreasing the respective step results in a finer curve or mesh.

Parameters:
quadricddg.geometry.quadrics.Quadric
*num_steptuple of an int and a float

The length of num_step must be 0 if quadric.dimension is -1 or 0 and otherwise must be equal to quadric.dimension.

Returns:
curve or mesh or a list of curves and meshes

A curve is an tuple of points of type numpy.ndarray and the periodicity of type bool. A mesh is an tuple of points of type numpy.ndarray and the faces of type numpy.ndarray.

Raises:
ValueError

If the quadric is a (possibly empty) set of points and num_step is given.

ddg.conversion.arrays.from_sphere(sphere, num, /)[source]

Convert a sphere to a curve or a mesh.

Circles are converted to curves and 2-dimensional spheres are converted to meshes.

Parameters:
sphereddg.geometry.spheres.Sphere
numint

Increasing this number increases the number of samples in each direction of the sphere parametrization.

Returns:
curve or mesh

A curve is an tuple of points of type numpy.ndarray and the periodicity of type bool. A mesh is an tuple of points of type numpy.ndarray and the faces of type numpy.ndarray.

ddg.conversion.arrays.from_indexed_face_set(ifs, coordinate_key='co', /)[source]

Get the points, and faces of an indexed face set.

Parameters:
ifsddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
coordinate_attributestr (default=”co”)
Returns:
tuple of numpy.ndarray and list