Modifications


ModifyObject

Class containing all the possible modifications which can be applied to a scalar field.

Attributes:
  • original_geo_object (Callable[[ndarray, tuple], ndarray]) –

    Original SDF.

  • geo_object (Callable[[ndarray, tuple], ndarray]) –

    Modified SDF.

Parameters:
  • geo_object (Callable[[ndarray, tuple], ndarray]) –

    SDF of a geometry.

modifications: list property

All the modifications which were applied to the geometry in chronological order.

Returns:
  • list

    List of modifications.

modified_object: Callable[[np.ndarray, tuple], np.ndarray] property

SDF of the modified geometry.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    SDF of the modified geometry.

original_object: Callable[[np.ndarray, tuple], np.ndarray] property

SDF of the unmodified geometry.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    SDF of the unmodified geometry.

elongation(elon_vector)

Elongates the geometry along a certain vector by the length of the vector in each respective direction.

Parameters:
  • elon_vector (ndarray | tuple | list) –

    3vector defining the direction and distance of the elongation.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

rounding(rounding_radius)

Rounds off the geometry - effectively thickening it by the rounding radius. rounding_radius: Radius by which the edges are rounded and the object thickened.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

rounding_cs(rounding_radius, bb_size)

Rounds off the geometry, but the geometry will be contained in its bounding box. Bounding box size must be specified.

Parameters:
  • rounding_radius (float | int) –

    Radius by which the edges are rounded.

  • bb_size (int | float) –

    Size of the bounding box. Typically, the largest dimension of the object.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

boundary()

Get the boundary of a shape.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

signed_old(co_resolution)

Transform an Unsigned Distance Function into a Signed Distance Function.

Parameters:
  • co_resolution (tuple) –

    Resolution of the coordinate system.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

signed(co_resolution)

Transform an Unsigned Distance Function into a Signed Distance Function.

Parameters:
  • co_resolution (tuple) –

    Resolution of the coordinate system.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

invert(direct=False)

Invert the sign of the SDF.

Parameters:
  • direct (bool, default: False ) –

    If True a function which returns inverts the sign of the SDF is returned without modifying the SDF. If False the same happens as described above but the SDF is also modified.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

sign(direct=False)

Get the sign of the SDF.

Parameters:
  • direct (bool, default: False ) –

    If True a function which returns the sign of the SDF is returned without modifying the SDF. If False the same happens as described above but the SDF is also modified.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

recover_volume(interior)

Recovers the interior of the SDF if a function which outputs the correct value (-1 or 1) is provided. This function should take the same parameters as the SDF. Typically, this function is the output of self.sign().

Parameters:
  • interior (Callable[[ndarray, tuple], ndarray]) –

    Function defining the interior (negative values) of an SDF.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

define_volume(interior, interior_parameters)

Defines the interior of the SDF if with a function.

Parameters:
  • interior (Callable[[ndarray, tuple], ndarray]) –

    Function defining the interior (-1) and exterior (1) of an SDF.

  • interior_parameters (tuple) –

    Parameters of the function defining the interior of the SDF.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

onion(thickness)

Transforms the geometry into a surface with some thickness. Args: thickness: Thickness of the resulting shape.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

concentric(width)

Transforms an isosurface into two concentric isosurfaces which are apart by the value of width. Transforms a volume into an isosurface and rounds it by width/2.

Parameters:
  • width (float | int) –

    Thickness of the resulting shape.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

revolution(radius)

Revolves a 2D shape around the y-axis to generate a 3D shape. First the 2D shape is translated along the x-axis by the radius of revolution, then it is revolved around the y-axis.

Parameters:
  • radius (float | int) –

    Radius of revolution.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

axis_revolution(radius, angle)

Revolves a 2D shape around an axis to generate a 3D shape. First the 2D shape is translated along the x-axis by the radius of revolution, then it is revolved around the axis of revolution. The axis of revolution is angled by the specified angle with respect to the y-axis.

Parameters:
  • radius (float | int) –

    Radius of revolution.

  • angle (float | int) –

    Angle between the axis of revolution and the y-axis.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

extrusion(distance)

Extrudes a 2D shape along the z-axis so that the height of the object is equal to the specified distance.

Parameters:
  • distance (float | int) –

    Final height of the object - distance of extrusion.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

twist(pitch)

Twists the geometry around the z-axis based on the position along the z-axis and the pitch.

Parameters:
  • pitch (float | int) –

    rad/unit length.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

bend(radius, angle)

Bends the geometry around the z-axis, based on the specified bending radius and angle. The length of the bent section is radius*angle.

Parameters:
  • radius (float | int) –

    Bending radius.

  • angle (float | int) –

    Bending angle.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

displacement(displacement_function, displacement_function_parameters)

Displaces the surface of an object based on the values of the displacement function. Should be applied last.

Parameters:
  • displacement_function (Callable[[ndarray, tuple], ndarray]) –

    Function which takes an array of coordinates with shape (D, N) and a tuple of parameters. D - number of dimensions (2 or 3); N - number of points in the point cloud.

  • displacement_function_parameters (tuple) –

    Parameters of the displacement function.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

infinite_repetition(distances)

Infinitely repeats geometry in space on a cubic lattice.

Parameters:
  • distances (tuple | list | ndarray) –

    3vector determining the distances between instances along each axis.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

finite_repetition(size, repetitions)

Repeats the geometry finite amount of times along each axis within a defined bounding box.

Parameters:
  • size (tuple | list | ndarray) –

    Size of the bounding box along each axis in which the geometry is repeated.

  • repetitions (tuple | list | ndarray) –

    Number of repetitions along each axis inside the bounding box.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

finite_repetition_rescaled(size, repetitions, instance_size, padding)

Repeats the geometry finite amount of times along each axis within a defined bounding box. The geometry is rescaled based on the provided geometry bounding box size and padding along each axis. Args: size: Size of the bounding box along each axis in which the geometry is repeated. repetitions: Number of repetitions along each axis inside the bounding box. instance_size: Size of the bounding box around one instance of geometry along each axis. padding: Padding around each instance along each axis.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

symmetry(axis)

Applies symmetry along an axis of the object.

Parameters:
  • axis (int) –

    Index of the axis along which the symmetry is applied.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

mirror(a, b)

Applies mirroring along an axis connecting the two specified points.

Parameters:
  • a (tuple | list | ndarray) –

    Position of the object's mirror image.

  • b (tuple | list | ndarray) –

    Position of the object.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

rotational_symmetry(n, radius, phase)

Applies n-fold rotational symmetry to the object.

Parameters:
  • n (int) –

    Order of the symmetry.

  • radius (float | int) –

    By how much the geometry is moved from the centre.

  • phase (float | int) –

    Angle by which the circular pattern is rotated by.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

linear_instancing(n, a, b)

Instances the geometry n-times along the length of a segment defined by two points.

Parameters:
  • n (int) –

    Number of instances along the segment.

  • a (tuple | list | ndarray) –

    Starting point of the segment.

  • b (tuple | list | ndarray) –

    Ending point of the segment.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

curve_instancing(f, f_parameters, t_range)

Instances the geometry n-times along the length of a parametric curve defined by a function.

Parameters:
  • f (Callable[[ndarray, tuple], ndarray]) –

    Function defining the parametric curve.

  • f_parameters (tuple) –

    Parameters of the function defining the parametric curve.

  • t_range (tuple) –

    (t_start, t_end, n_instances): t_start - initial value of the parameter t, which is feed into the parametric curve. t_end - final value of the parameter t. n_instances - number of instances of the geometry along the parametric curve.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

aligned_curve_instancing(f, f_parameters, t_range)

Instances the geometry n-times along the length of a parametric curve defined by a function. The x-axis of the geometry is aligned with the tangent vector of the parametric curve.

Parameters:
  • f (Callable[[ndarray, tuple], ndarray]) –

    Function defining the parametric curve.

  • f_parameters (tuple) –

    Parameters of the function defining the parametric curve.

  • t_range (tuple) –

    (t_start, t_end, n_instances): t_start - initial value of the parameter t, which is feed into the parametric curve. t_end - final value of the parameter t. n_instances - number of instances of the geometry along the parametric curve.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

fully_aligned_curve_instancing(f, f_parameters, t_range)

Instances the geometry n-times along the length of a parametric curve defined by a function. The x-axis of the geometry is aligned with the tangent vector of the parametric curve. The y-axis of the geometry is aligned with the normal vector of the parametric curve. The z-axis of the geometry is aligned with the binormal vector of the parametric curve.

Parameters:
  • f (Callable[[ndarray, tuple], ndarray]) –

    Function defining the parametric curve.

  • f_parameters (tuple) –

    Parameters of the function defining the parametric curve.

  • t_range (tuple) –

    (t_start, t_end, n_instances): t_start - initial value of the parameter t, which is feed into the parametric curve. t_end - final value of the parameter t. n_instances - number of instances of the geometry along the parametric curve.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified SDF.

custom_modification(modification, modification_parameters, modification_name='custom')

Applies a custom user-specified modification to a scalar (Signed Distance Function) field.

Parameters:
  • modification (Callable[[Callable[[ndarray, tuple], ndarray], ndarray, tuple, tuple], ndarray]) –

    A custom modification which takes the SDF as a first argument, point cloud of coordinates at which the SDF is evaluated as the second argument, parameters of the SDF as the third argument, and the custom modification parameters as the fourth argument.

  • modification_parameters (tuple) –

    Parameters of the custom modification.

  • modification_name (str, default: 'custom' ) –

    Name of the custom modification.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

sigmoid_falloff(amplitude, width)

Applies a sigmoid to the scalar (Signed Distance Function) field.

Parameters:
  • amplitude (float | int) –

    Maximum value of the transformed scalar field.

  • width (float | int) –

    Width of the sigmoid.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

positive_sigmoid_falloff(amplitude, width)

Applies a sigmoid, shifted to the positive velues by the value of the width parameter, to the scalar (Signed Distance Function) field.

Parameters:
  • amplitude (float | int) –

    Maximum value of the transformed scalar field.

  • width (float | int) –

    Width of the sigmoid.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

capped_exponential(amplitude, width)

Applies a decreasing exponential functon to the scalar (Signed Distance Function) field. to the scalar (Signed Distance Function) field.

Parameters:
  • amplitude (float | int) –

    Maximum value of the transformed scalar field.

  • width (float | int) –

    Range at which the value of the transformed scalar field drops to almost zero.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

hard_binarization(threshold)

Binarizes the Signed Distance field/pattern based on a threshold. Values below the threshold are 1 and values above are 0.

Parameters:
  • threshold (float) –

    Binarization threshold.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

linear_falloff(amplitude, width)

Applies a decreasing linear function to the scalar (Signed Distance Function) field.

Parameters:
  • amplitude (float | int) –

    Maximum value of the transformed scalar field.

  • width (float | int) –

    Range at which the value of the transformed scalar field drops to zero.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

relu(width)

Applies the ReLU function to the scalar (Signed Distance Function) field.

Parameters:
  • width (float | int) –

    Range at which the value of the transformed field reaches one.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

smooth_relu(smooth_width, width=1, threshold=0.01)

Applies the "squareplus" function to the scalar (Signed Distance Function) field. https://en.wikipedia.org/wiki/Rectifier_(neural_networks)

Parameters:
  • smooth_width (float | int) –

    Distance from the origin at which the Smooth ReLU function is greater than ReLU for less than the value of the threshold parameter.

  • width (float | int, default: 1 ) –

    Range at which the value of the transformed field reaches one.

  • threshold (int | float, default: 0.01 ) –

    At smooth_width distance from the origin the value of the Smooth ReLU function is greater than ReLU for the value of the threshold parameter. at smooth_width distance from the origin.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Transformed scalar field.

slowstart(smooth_width, width=1, threshold=0.01, ground=True)

Applies the SlowStart function to the scalar (Signed Distance Function) field.

Parameters:
  • smooth_width (float | int) –

    Distance from the origin at which the SlowStart function is greater than ReLU for less than the value of the threshold parameter.

  • width (float | int, default: 1 ) –

    Range at which the value of the transformed field reaches one.

  • threshold (int | float, default: 0.01 ) –

    At smooth_width distance from the origin the value of the SlowStart function is greater than ReLU for the value of the threshold parameter.

  • ground (bool, default: True ) –

    if True the value of the function is zero at zero.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Transformed scalar field.

gaussian_boundary(amplitude, width)

Applies the Gaussian to the scalar (Signed Distance Function) field.

Parameters:
  • amplitude (float | int) –

    Maximum value of the transformed scalar field.

  • width (float | int) –

    Range at which the value of the transformed scalar field drops to almost zero.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

gaussian_falloff(amplitude, width)

Applies the Gaussian to the positive values of the scalar (Signed Distance Function) field.

Parameters:
  • amplitude (float | int) –

    Maximum value of the transformed scalar field (and points at which the scalar field was < 0).

  • width (float | int) –

    Range at which the value of the transformed scalar field drops to almost zero.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

conv_averaging(kernel_size, iterations, co_resolution)

Averages the field using an averaging convolutional kernel of the specified size.

Parameters:
  • kernel_size (int | tuple | list | ndarray) –

    Size of the averaging kernel. Must be an integer or a tuple/array of the same dimension as the scaler field.

  • iterations (int) –

    Number of times the convolutional averaging is applied to the input scalar field.

  • co_resolution (tuple) –

    Resolution of the coordinate system.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

conv_edge_detection(co_resolution)

Edge detection based ona 3x3 convolutional kernel.

Parameters:
  • co_resolution (tuple) –

    Resolution of the coordinate system.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

custom_post_process(function, parameters, post_process_name='custom')

Applies a custom user-specified post-processing function to a scalar (Signed Distance Function) field.

Parameters:
  • function (Callable[[ndarray, tuple], ndarray]) –

    A custom post-processing function which takes the SDF as a first argument and the parameters of the function as the next arguments.

  • parameters (tuple) –

    Parameters of the custom post-processing function.

  • post_process_name (str, default: 'custom' ) –

    Name of the custom post-processing function.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified Scalar Field.

ModifyVectorObject

Class containing all the possible modifications which can be applied to a vector field.

Attributes:
  • original_vf (Callable[[ndarray, tuple], ndarray]) –

    Original vector field.

  • vf (Callable[[ndarray, tuple], ndarray]) –

    Modified vector field.

Parameters:
  • vf (Callable[[ndarray, tuple], ndarray]) –

    Vector field.

modifications: list property

All the modifications which were applied to the vector field in chronological order.

Returns:
  • list

    List of modifications.

modified_object: Callable[[np.ndarray, tuple], np.ndarray] property

Modified vector field.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

original_object: Callable[[np.ndarray, tuple], np.ndarray] property

Unmodified vector field.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Unmodified vector field.

add(second_field)

Adds a number, vector, or a vector field of the same shape to the vector field.

Parameters:
  • second_field (int | float | ndarray) –

    a number, vector, or a vector field to be added.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

subtract(second_field)

Subtracts a number, vector, or a vector field of the same shape to the vector field.

Parameters:
  • second_field (int | float | ndarray) –

    a number, vector, or a vector field to be subtracted.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

rescale(second_field)

Rescales the lengths of vectors in the vector field by a number, vector, or a vector field of the same shape.

Parameters:
  • second_field (int | float | ndarray) –

    a number, vector, or a vector field used for rescaling.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

rotate_phi(phi)

Rotates vectors in a 3D vector field by some azimuthal angle.

Parameters:
  • phi (int | float | ndarray) –

    Spatially dependent or independent angle by which to rotate the vectors in the xy-plane.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

rotate_theta(theta)

Rotates vectors in a 3D vector field by some polar angle.

Parameters:
  • theta (int | float | ndarray) –

    Spatially dependent or independent angle by which to rotate the vectors in the polar direction.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

rotate_x(alpha)

Rotates vectors in a 3D vector field by some angle.

Parameters:
  • alpha (int | float | ndarray) –

    Spatially dependent or independent angle by which to rotate the vectors around the x axis.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

rotate_y(alpha)

Rotates vectors in a 3D vector field by some angle.

Parameters:
  • alpha (int | float | ndarray) –

    Spatially dependent or independent angle by which to rotate the vectors around the y axis.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

rotate_z(alpha)

Rotates vectors in a 3D vector field by some angle.

Parameters:
  • alpha (int | float | ndarray) –

    Spatially dependent or independent angle by which to rotate the vectors around the z axis.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

rotate_axis(axis, alpha)

Rotates vectors in a 3D vector field by some angle around some axis.

Parameters:
  • axis (tuple | list | ndarray) –

    A single or an array exes around which the vectors in the vector field will be rotated.

  • alpha (int | float | ndarray) –

    Spatially dependent or independent angle by which to rotate the vectors around the specified axis.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

revolution_x(co)

Revolves a 2D vector field around the x-axis to generate a 3D vector field.

Parameters:
  • co (ndarray) –

    Coordinate system with shape (3, N).

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

revolution_y(co)

Revolves a 2D vector field around the y-axis to generate a 3D vector field.

Parameters:
  • co (ndarray) –

    Coordinate system with shape (3, N).

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

revolution_z(co)

Revolves a 2D vector field around the z-axis to generate a 3D vector field.

Parameters:
  • co (ndarray) –

    Coordinate system with shape (3, N).

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.

normalize()

Normalizes the vector field.

Returns:
  • Callable[[ndarray, tuple], ndarray]

    Modified vector field.