Base Modules#

Core Compiled#

Cython functions

class volmdlr.core_compiled.Arrow3D(x, y, z, starting_point=None, *args, **kwargs)#

Bases: FancyArrowPatch

draw(renderer)#

Draw the arrow by overloading a Matplotlib method. Do not rename this method!

plot(ax=None, color='b')#
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, arrowstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, connectionstyle=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, patchA=<UNSET>, patchB=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)#

Set multiple properties at once.

Supported properties are

Properties:

agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool antialiased or aa: bool or None arrowstyle: str or ~matplotlib.patches.ArrowStyle capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None color: color connectionstyle: [ ‘arc3’ | ‘angle3’ | ‘angle’ | ‘arc’ | ‘bar’ ] edgecolor or ec: color or None facecolor or fc: color or None figure: ~matplotlib.figure.Figure fill: bool gid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} in_layout: bool joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} label: object linestyle or ls: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …} linewidth or lw: float or None mouseover: bool mutation_aspect: float mutation_scale: float patchA: .patches.Patch patchB: .patches.Patch path_effects: list of .AbstractPathEffect picker: None or bool or float or callable positions: unknown rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float

class volmdlr.core_compiled.Basis(name: str = '', **kwargs)#

Bases: DessiaObject

Abstract class of a basis

copy(deep=True, memo=None)#

Copy object.

Parameters:
  • deep – If False, perform a shallow copy. If True, perform a deep copy.

  • memo – A dict that keep track of references.

class volmdlr.core_compiled.Basis2D(u: Vector2D, v: Vector2D, name: Text = '')#

Bases: Basis

Defines a 2D basis.

Parameters:
  • u (volmdlr.Vector2D) – First vector of the basis

  • v (volmdlr.Vector2D) – Second vector of the basis

copy(deep=True, memo=None)#

Creates a copy of a 2-dimensional basis.

Parameters:
  • deepnot used

  • memonot used

Returns:

A copy of the Basis2D

Return type:

volmdlr.Basis2D

global_to_local_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis2D.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector2D

inverse_transfer_matrix()#

Computes the inverse transfer matrix of the 2-dimensional basis.

Returns:

The 2x2 inverse transfer matrix

Return type:

volmdlr.Matrix22

local_to_global_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the local landmark of this Basis2D to the global landmark.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector2D

new_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis2D.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector2D

Deprecated since version Use: global_to_local_coordinates instead.

normalize()#

Normalizes the basis, and return a new object.

Returns:

A new normalized basis

Return type:

Basis2D

old_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the local landmark of this Basis2D to the global landmark.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector2D

Deprecated since version Use: local_to_global_coordinates instead.

rotation(angle: float)#

Rotates the 2-dimensional basis and returns a new rotated one.

Parameters:

angle (float) – The angle of rotation in rad

Returns:

The rotated Basis2D

Return type:

volmdlr.Basis2D

to_dict(*args, **kwargs)#

Serializes a 2-dimensional basis into a dictionary.

Returns:

A serialized version of the Basis2D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

to_frame(origin: Point2D) Frame2D#

Returns the 2-dimensional frame oriented the same way as the Basis2D and having for origin the given 2-dimensional point.

Parameters:

origin (volmdlr.Point2D) – The origin of the 2-dimensional frame

Returns:

A 2-dimensional frame

Return type:

volmdlr.Frame2D

transfer_matrix()#

Computes the transfer matrix of the 2-dimensional basis.

Returns:

The 2x2 transfer matrix

Return type:

volmdlr.Matrix22

property vectors#
class volmdlr.core_compiled.Basis3D(u: Vector3D, v: Vector3D, w: Vector3D, name: Text = '')#

Bases: Basis

Defines a 3D basis.

Parameters:
  • u (volmdlr.Vector3D) – First vector of the basis

  • v (volmdlr.Vector3D) – Second vector of the basis

  • w (volmdlr.Vector3D) – Third vector of the basis

copy(deep=True, memo=None)#

Creates a copy of a 3-dimensional basis.

Parameters:
  • deepnot used

  • memonot used

Returns:

A copy of the Basis3D

Return type:

volmdlr.Basis3D

euler_rotation(angles: Tuple[float, float, float])#

Rotates the 3-dimensional basis using euler rotation and returns a new basis as a result.

Parameters:

angles (tuple) – Three angles corresponding to psi, theta, phi in rad

Returns:

The rotated basis

Return type:

volmdlr.Basis3D

euler_rotation_parameters(angles: Tuple[float, float, float])#

Computes the new basis’ parameter after rotation of the basis using euler rotation.

Parameters:

angles (tuple) – Three angles corresponding to psi, theta, phi in rad

Returns:

The new vectors of rotated basis

Return type:

tuple

classmethod from_two_vectors(vector1: Vector3D, vector2: Vector3D, name: str = '') Basis3D#

Creates a basis with first vector1 adimensionned, as u, v is the vector2 subtracted of u component, w is the cross product of u and v.

Parameters:
  • vector1 (volmdlr.Vector3D.) – The first vector of the Basis3D

  • name – object’s name.

  • vector2 (volmdlr.Vector3D) – The second vector of the Basis3D

global_to_local_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis3D.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector3D

inverse_transfer_matrix()#

Computes the inverse transfer matrix of the 3-dimensional basis.

Returns:

The 3x3 inverse transfer matrix

Return type:

volmdlr.Matrix33

is_normalized(tol: float = 1e-06)#

Check if the basis vectors are normal to each other.

Parameters:

tol (float) – Tolerance for considering a unit vector.

Returns:

True if the basis vectors are normalized, False otherwise.

Return type:

bool

is_orthogonal(tol: float = 1e-06)#

Check if the basis vectors are orthogonal to each other.

Parameters:

tol (float) – Tolerance for considering a dot product as zero.

Returns:

True if the basis vectors are orthogonal, False otherwise.

Return type:

bool

is_orthonormal(tol: float = 1e-06)#

Check if the basis vectors are orthonormal to each other.

Parameters:

tol (float) – Tolerance for considering an orthonormal basis.

Returns:

True if the basis vectors are orthonormal, False otherwise.

Return type:

bool

local_to_global_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the local landmark of this Basis3D to the global landmark.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector3D

new_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis3D.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector3D

Deprecated since version Use: global_to_local_coordinates instead.

normalize()#

Normalizes the basis, modifying its coordinates in place.

Returns:

New normalized basis

Return type:

Basis3D

old_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the local landmark of this Basis3D to the global landmark.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector3D

Deprecated since version Use: local_to_global_coordinates instead.

rotation(axis: Vector3D, angle: float)#

Rotates the 3-dimensional basis and returns a new rotated one.

Parameters:
  • axis (volmdlr.Vector3D) – The axis around which the rotation is made

  • angle (float) – The angle of rotation in rad

Returns:

The rotated Basis3D

Return type:

volmdlr.Basis3D

to_dict(*args, **kwargs)#

Serializes a 3-dimensional basis into a dictionary.

Returns:

A serialized version of the Basis3D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

to_frame(origin)#

Returns the 3-dimensional frame oriented the same way as the Basis3D and having for origin the given 3-dimensional point.

Parameters:

origin (volmdlr.Point3D) – The origin of the 3-dimensional frame

Returns:

A 3-dimensional frame

Return type:

volmdlr.Frame3D

transfer_matrix()#

Computes the transfer matrix of the 3-dimensional basis.

Returns:

The 3x3 transfer matrix

Return type:

volmdlr.Matrix33

property vectors#
x_rotation(angle: float)#

Rotates the basis around the X axis and a new basis is returned as a result.

Parameters:

angle (float) – The rotation angle

Returns:

The rotated Basis3D

Return type:

volmdlr.Basis3D

y_rotation(angle: float)#

Rotates the basis around the Y axis and a new basis is returned as a result.

Parameters:

angle (float) – The rotation angle

Returns:

The rotated Basis3D

Return type:

volmdlr.Basis3D

z_rotation(angle: float)#

Rotates the basis around the Z axis and a new basis is returned as a result.

Parameters:

angle (float) – The rotation angle

Returns:

The rotated Basis3D

Return type:

volmdlr.Basis3D

class volmdlr.core_compiled.Frame2D(origin: Point2D, u: Vector2D, v: Vector2D, name: Text = '')#

Bases: Basis2D

Defines a 2D basis :param origin:Point2D: origin of the basis :param u:Vector2D: first vector of the basis :param v:Vector2D: second vector of the basis

Draw(ax=None, style='ok')#

# TODO : unused ? to be deleted ?

Parameters:
  • ax

  • style

Returns:

basis()#

Returns the 2-dimensional basis oriented the same way as the Frame2D.

Returns:

A 2-dimensional basis

Return type:

volmdlr.Basis2D

copy(deep=True, memo=None)#

Creates a copy of a 2-dimensional frame.

Parameters:
  • deepnot used

  • memonot used

Returns:

A copy of the Frame2D

Return type:

volmdlr.Frame2D

frame_mapping(frame: Frame2D, side: str)#
global_to_local_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame2D.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector2D

is_close(other_frame, abs_tol: float = 1e-06)#

Verifies if two frames are the same, up to given tolerance.

Parameters:
  • other_frame – other frame.

  • abs_tol – tolerance used

Returns:

local_to_global_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the local landmark of this Frame2D to the global landmark.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector2D

new_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame2D.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector2D

Deprecated since version Use: global_to_local_coordinates instead.

normalize()#

Normalizes the Frame, and return a new object.

Returns:

A new normalized basis

Return type:

Frame2D

old_coordinates(vector: Vector2D) Vector2D#

Convert the given vector’s coordinates from the local landmark of this Frame2D to the global landmark.

Parameters:

vector (volmdlr.Vector2D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector2D

Deprecated since version Use: local_to_global_coordinates instead.

plot(ax=None, color='b', alpha=1.0, plot_points=True, ratio=1.0)#

Plots the 2-dimensional frame.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – The Axes on which the Point2D will be drawn. Default value is None, creating a new drawing figure

  • color (str, optional) – not used

  • alpha (float, optional) – not used

  • plot_points (bool, optional) – not used

  • ratio (float, optional) – A ratio for controlling the size of the 2-dimensional frame. Default value is 1

Returns:

A matplotlib Axes object on which the Point2D have been plotted

Return type:

matplotlib.axes.Axes

rotation(center: Point2D, angle: float, rotate_basis: bool = False)#

Returns a rotated 2-dimensional frame.

Parameters:
  • center (volmdlr.Point2D) – The center of rotation

  • angle (float) – The rotation angle

Returns:

New rotated frame

Return type:

volmdlr.Frame2D

to_dict(*args, **kwargs)#

Serializes a 2-dimensional frame into a dictionary.

Returns:

A serialized version of the Frame2D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

translation(vector)#

Returns a translated 2-dimensional frame.

Parameters:

vector (volmdlr.Vector2D) – The translation vector

Returns:

A new translated 2-dimensional frame

Return type:

volmdlr.Frame2D

class volmdlr.core_compiled.Frame3D(origin: Point3D, u: Vector3D, v: Vector3D, w: Vector3D, name: Text = '')#

Bases: Basis3D

Defines a 3D frame :param origin:Point3D: origin of the basis :param u:Vector3D: first vector of the basis :param v:Vector3D: second vector of the basis :param w:Vector3D: third vector of the basis

basis()#

Returns the 3-dimensional basis oriented the same way as the Frame3D.

Returns:

A 3-dimensional basis

Return type:

volmdlr.Basis3D

copy(deep=True, memo=None)#

Creates a copy of a 3-dimensional frame.

Parameters:
  • deepnot used

  • memonot used

Returns:

A copy of the Frame3D

Return type:

volmdlr.Frame3D

frame_mapping(frame: Frame3D, side: str)#
classmethod from_3_points(point1, point2, point3, name: str = '')#

Creates a frame 3d from 3 points.

Parameters:
  • point1 – point 1.

  • point2 – point 2.

  • point3 – point 3.

  • name – object’s name.

Returns:

a frame 3d.

classmethod from_point_and_normal(origin, normal, name: str = '')#

Creates a frame 3D from a point and a normal vector.

classmethod from_point_and_vector(point: Point3D, vector: Vector3D, main_axis: Vector3D = Vector3D(1.0, 0.0, 0.0), name: str = '')#

Creates a new frame from a point and vector by rotating the global frame. Global frame rotates in order to have ‘vector’ and ‘main_axis’ collinear. This method is very useful to compute a local frame of an object.

Parameters:
  • point (volmdlr.Point3D) – The origin of the new frame

  • vector (volmdlr.Vector3D) – The vector used to define one of the main axis (by default X-axis) of the local frame

  • main_axis (volmdlr.Vector3D, optional) – The axis of global frame you want to match ‘vector’ (can be X3D, Y3D or Z3D). Default value is X3D, the vector (1, 0, 0)

  • name (str) – Frame’s name.

Returns:

The created local frame

Return type:

volmdlr.Frame3D

classmethod from_step(arguments, object_dict, **kwargs)#

Converts a step primitive from a 3-dimensional point to a Frame3D.

Parameters:
  • arguments (list) – The arguments of the step primitive. The last element represents the unit_conversion_factor.

  • object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated

Returns:

The corresponding Frame3D object

Return type:

volmdlr.Frame3D

global_to_local_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame3D.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector3D

is_close(other_frame, abs_tol: float = 1e-06)#

Verifies if two frames are the same, up to given tolerance.

Parameters:
  • other_frame – other frame.

  • abs_tol – tolerance used

Returns:

local_to_global_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the local landmark of this Frame3D to the global landmark.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector3D

new_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame3D.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in global coordinates.

Returns:

The converted vector, in local coordinates.

Return type:

volmdlr.Vector3D

Deprecated since version Use: global_to_local_coordinates instead.

normalize()#

Normalizes the Frame, and return a new object.

Returns:

A new normalized basis

Return type:

Frame2D

old_coordinates(vector: Vector3D) Vector3D#

Convert the given vector’s coordinates from the local landmark of this Frame3D to the global landmark.

Parameters:

vector (volmdlr.Vector3D) – The vector to convert, given in local coordinates.

Returns:

The converted vector, in global coordinates.

Return type:

volmdlr.Vector3D

Deprecated since version Use: local_to_global_coordinates instead.

plot(ax=None, color='b', alpha=1.0, plot_points=True, ratio=1.0)#

Plots the 3-dimensional frame.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – The Axes on which the Point3D will be drawn. Default value is None, creating a new drawing figure

  • color (str, optional) – not used

  • alpha (float, optional) – not used

  • plot_points (bool, optional) – not used

  • ratio (float, optional) – A ratio for controlling the size of the 3-dimensional frame. Default value is 1

Returns:

A matplotlib Axes object on which the Point3D have been plotted

Return type:

matplotlib.axes.Axes

plot2d(x=Vector3D(1.0, 0.0, 0.0), y=Vector3D(0.0, 1.0, 0.0), ax=None, color='k')#

Plots the 3-dimensional frame on a 2-dimensional surface given by (x, y).

Parameters:
  • x (volmdlr.Vector3D, optional) – The first 3-dimensional vector of the 2-dimensional surface. Default value is X3D, the vector (1, 0, 0)

  • y (volmdlr.Vector3D, optional) – The second 3-dimensional vector of the 2-dimensional surface. Default value is Y3D, the vector (0, 1, 0)

  • ax (matplotlib.axes.Axes, optional) – The Axes on which the Frame3D will be drawn. Default value is None, creating a new drawing figure

  • color (str, optional) – The color of the frame. Default value is ‘k’, for black

Returns:

A matplotlib Axes object on which the 2-dimensional representation of the Frame3D have been plotted

Return type:

matplotlib.axes.Axes

rotation(center: Point3D, axis: Vector3D, angle: float)#

Rotates the center as a point and vectors as directions (calling Basis), and returns a new 3-dimensional frame.

Parameters:
  • center (volmdlr.Point3D) – The center of rotation

  • axis (volmdlr.Vector3D) – The axis around which the rotation will be made

  • angle (float) – The rotation angle

Returns:

New rotated frame

Return type:

volmdlr.Frame3D

to_dict(*args, **kwargs)#

Serializes a 3-dimensional frame into a dictionary.

Returns:

A serialized version of the Frame3D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

to_step(current_id)#

Writes a step primitive from a 3-dimensional frame.

Parameters:

current_id (int) – The id of the last written primitive

Returns:

A tuple containing the string representing the step primitive and the new current id

Return type:

tuple

translation(offset: Vector3D)#

Translates a 3-dimensional frame.

Parameters:

offset (volmdlr.Vector3D) – The translation vector

Returns:

new translated frame

Return type:

Frame3D

volmdlr.core_compiled.LineSegment3DDistance(points_linesegment1, points_linesegment2)#
class volmdlr.core_compiled.Matrix22(M11: float, M12: float, M21: float, M22: float)#

Bases: object

Class representing a 2x2 matrix.

Parameters:
  • M11 (float) – The first line, first column value

  • M12 (float) – The first line, second column value

  • M21 (float) – The second line, first column value

  • M22 (float) – The second line, second column value

determinent()#

Computes the determinent of the matrix.

Returns:

The determinent of the matrix

Return type:

float

inverse()#

Computes the invert matrix.

Returns:

The inverse of the matrix

Return type:

volmdlr.Matrix22

vector_multiplication(vector)#

Multiplies the matrix by a 2-dimensional vector.

Parameters:

vector (volmdlr.Vector2D) – A Vector2D-like object

Returns:

A Vector2D-like object

Return type:

volmdlr.Vector2D

class volmdlr.core_compiled.Matrix33(M11: float, M12: float, M13: float, M21: float, M22: float, M23: float, M31: float, M32: float, M33: float)#

Bases: object

Class representing a 3x3 matrix.

Parameters:
  • M11 (float) – The first line, first column value

  • M12 (float) – The first line, second column value

  • M13 (float) – The first line, third column value

  • M21 (float) – The second line, first column value

  • M22 (float) – The second line, second column value

  • M23 (float) – The second line, third column value

  • M31 (float) – The third line, first column value

  • M32 (float) – The third line, second column value

  • M33 (float) – The third line, third column value

determinent()#

Computes the determinent of the matrix.

Returns:

The determinent of the matrix

Return type:

float

float_multiplication(float_value: float)#

Multiplies the whole matrix by a scalar value.

Parameters:

float_value (float) – The value of the scalar

Returns:

The new matrix after multiplication

Return type:

volmdlr.Matrix33

inverse()#

Computes the invert matrix.

Returns:

The inverse of the matrix

Return type:

volmdlr.Matrix33

classmethod random_matrix(minimum: float = 0.0, maximum: float = 1.0, name: str = '')#

Creates a random matrix with values between bounds.

Parameters:
  • minimum (float, optional) – Minimum possible value of matrix coefficients. Default value is 0

  • maximum (float, optional.) – Maximum possible value of matrix coefficients. Default value is 1

  • name – object’s name.

Returns:

A random matrix

Return type:

volmdlr.Matrix33

to_numpy()#

Returns the numpy array corresponding to the matrix.

Returns:

A numpy array of the matrix

Return type:

numpy.array

vector_multiplication(vector: Vector3D) Vector3D#

Multiplies the matrix by a 3-dimensional vector.

Parameters:

vector (volmdlr.Vector3D) – A Vector3D-like object

Returns:

A Vector3D-like object

Return type:

volmdlr.Vector3D

class volmdlr.core_compiled.Point2D#

Bases: Vector2D

Class representing a 2-dimensional point.

Parameters:
  • x (float) – The vector’s abscissa

  • y (float) – The vector’s ordinate

  • name (str) – The vector’s name

axial_symmetry(line: Line2D)#

Returns the symmetric two-dimensional point according to a line.

Parameters:

line (volmdlr.edges.Line2D) – the line used for axial symmetry

Returns:

the symmetrical point

Return type:

volmdlr.Point2D

coordinates()#

Gets x,y coordinates of a point2d.

get_geo_lines(tag: int, point_mesh_size: float | None = None)#

Gets the lines that define a Point2D in a .geo file.

Parameters:
  • tag (int) – The point index

  • mesh_size (float, optional) – The target mesh size close to the point, defaults to None

Returns:

A line

Return type:

str

in_list(list_points, tol: float = 1e-06)#

Return True if point is in the list with a given tolerance. Returns False otherwise.

classmethod line_intersection(line1: volmdlr.edges.Line2D, line2: volmdlr.edges.Line2D, curvilinear_abscissa: bool = False, name: str = '')#

Returns a Point2D based on the intersection between two infinite lines.

Parameters:
  • line1 (volmdlr.edges.Line2D) – The first line

  • line2 (volmdlr.edges.Line2D) – The second line

  • curvilinear_abscissa (bool, optional) – True will return, in addition to the intersection point, the curvilinear abscissa of the point on the first line and on the second line. Otherwise, only the point will be returned

  • name – Object’s name.

Returns:

The two-dimensional point at the intersection of the two lines

Return type:

volmdlr.Point2D

classmethod line_projection(point: Vector2D, line: volmdlr.edges.Line2D, name='')#

Computes the projection of a two-dimensional vector-like object on an infinite two-dimensional line

Parameters:
  • point (volmdlr.Vector2D) – the point to be projected

  • line (volmdlr.edges.Line2D.) – the infinite line

  • name – object’s name.

Returns:

the projected point

Return type:

volmdlr.Point2D

classmethod middle_point(point1: Vector2D, point2: Vector2D, name='')#

Computes the middle point between two two-dimensional vector-like objects.

Parameters:
  • point1 (volmdlr.Vector2D) – the first point

  • point2 (volmdlr.Vector2D.) – the second point

  • name – object’s name.

Returns:

the middle point

Return type:

volmdlr.Point2D

nearest_point(points: List[Vector2D])#

Finds the nearest point out of a list of two-dimensional vector-like objects.

Parameters:

points (List[volmdlr.Vector2D]) – a list of points

Returns:

the nearest point out of the list

Return type:

volmdlr.Vector2D

plot(ax=None, color='k', alpha=1, plot_points=True)#

Plots the 2-dimensional point as a dot.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – The Axes on which the Vector2D will be drawn

  • color (str, optional) – The color of the arrow

  • alpha (float, optional) – The transparency of the point from 0 to 1. 0 being fully transparent

  • plot_points (bool, optional) – # TODO: delete this attribute

Returns:

A matplotlib Axes object on which the Point2D have been plotted

Return type:

matplotlib.axes.Axes

plot_data(marker=None, color='black', size=1, opacity=1, arrow=False, stroke_width=None)#

Transforms the two-dimensional point into a plot_data twe-dimensional point.

Parameters:
  • marker (str, optional) – # TODO: unused parameter

  • color (str, optional) – # TODO: unused parameter

  • size (float, optional) – # TODO: unused parameter

  • opacity (float, optional) – # TODO: unused parameter

  • arrow (bool, optional) – # TODO: unused parameter

  • stroke_width (float, optional) – # TODO: unused parameter

Returns:

a plot_data two-dimensional point

Return type:

plot_data.Point2D

point_distance(other_point: Point2D)#

Computes the euclidiean distance between two Point2D objects.

Parameters:

other_point (volmdlr.Point2D) – A Point2D object

Returns:

The euclidiean distance

Return type:

float

classmethod segment_intersection(segment1: LineSegment2D, segment2: LineSegment2D, curvilinear_abscissa: bool = False, name: str = '')#

Returns a Point2D based on the intersection between two finite lines.

Parameters:
  • segment1 (volmdlr.edges.LineSegment2D) – The first line segment

  • segment2 (volmdlr.edges.LineSegment2D) – The second line segment

  • curvilinear_abscissa (bool, optional) – True will return, in addition to the intersection point, the curvilinear abscissa of the point on the first line segment and on the second line segment. Otherwise, only the point will be returned

  • name – object’s name.

Returns:

The two-dimensional point at the intersection of the two lines segments

Return type:

volmdlr.Point2D

to_3d(plane_origin: Vector3D, vx: Vector3D, vy: Vector3D)#

Returns the 3-dimensional point corresponding to the 2-dimensional point placed on the 3-dimensional plane (XY) of the 3-dimensional frame (centered on plane_origin, having for basis (vx, vy, vz), vz being the cross product of vx and vy).

Parameters:
  • plane_origin (volmdlr.Vector3D) – The origin of the plane, on which lies the Vector2D

  • vx (volmdlr.Vector3D) – The first direction of the plane

  • vy (volmdlr.Vector3D) – The second direction of the plane

Returns:

The Point3D from the Point2D set in the 3-dimensional space

Return type:

volmdlr.Point3D

to_dict(*args, **kwargs)#

Serializes a 2-dimensional point into a dictionary.

Returns:

A serialized version of the Point2D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

to_step(current_id, vertex=False)#

Write a step primitive from a 2-dimensional vector.

Parameters:
  • current_id (int) – The id of the last written primitive

  • vector (bool, optional) – If ‘True’ creates a step VECTOR primitive. Otherwise, only a DIRECTION primitive will be created. Default value set to ‘False’

  • vertex (bool, optional) – If ‘True’ calls the to_step method of Point3D. Default value set to ‘False’

Returns:

A tuple containing the string representing the step primitive and the new current id

Return type:

tuple

to_vector()#

Transforms a Point2D into a Vector2D and returns it.

Returns:

A Vector2D

Return type:

volmdlr.Vector2D

class volmdlr.core_compiled.Point3D#

Bases: Vector3D

Class representing a 3-dimensional point.

Parameters:
  • x (float) – The vector’s abscissa

  • y (float) – The vector’s ordinate

  • z – The vector’s applicate

  • name (str) – The vector’s name

babylon_script()#

# TODO: to be deleted ? Returns the babylonjs script for 3D display in browser.

Returns:

A babylonjs script

Return type:

str

coordinates()#

Returns the coordinates of a Point3D as a tuple of values.

Returns:

A tuple containing the abscissan, the ordiante and the applicate of the Point3D

Return type:

tuple

classmethod from_step(arguments, object_dict, **kwargs)#

Converts a step primitive from a 3-dimensional point to a Point3D.

Parameters:
  • arguments (list) – The arguments of the step primitive

  • object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated

Returns:

The corresponding Point3D object

Return type:

volmdlr.Point3D

get_geo_lines(tag: int, point_mesh_size: float | None = None)#

Gets the lines that define a Point3D in a .geo file.

Parameters:
  • tag (int) – The point index

  • mesh_size (float, optional) – The target mesh size close to the point, defaults to None

Returns:

A line

Return type:

str

in_list(list_points, tol: float = 1e-06)#

Return True if point is in the list with a given tolerance. Returns False otherwise.

classmethod middle_point(point1: Point3D, point2: Point3D, name='')#

Computes the middle point between two 3-dimensional points.

Parameters:
  • point1 (volmdlr.Point3D) – The first 3-dimensional point

  • point2 (volmdlr.Point3D.) – The second 3-dimensional point

  • name – object’s name.

Returns:

The middle point

Return type:

volmdlr.Point3D

nearest_point(points: List[Point3D])#

Returns the nearest 3-dimensional point out of the list.

Parameters:

points (List[volmdlr.Point3D]) – A list of 3-dimensional points

Returns:

The closest point

Return type:

volmdlr.Point3D

plot(ax=None, color='k', alpha=1, marker='o')#

Plots the 3-dimensional point.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – The Axes on which the Point3D will be drawn. Default value is None, creating a new drawing figure

  • color (str, optional) – The color of the point. Default value is ‘k’, for black

  • alpha (float, optional) – The transparency of the Point3D. Default value is 1, for full opacity

  • marker (str, optional) – The shape of the Point3D. Default value is ‘o’, for a round marker

Returns:

A matplotlib Axes object on which the Point3D have been plotted

Return type:

matplotlib.axes.Axes

point_distance(point2: Point3D) float#

Computes the euclidean distance between two 3-dimensional points.

Parameters:

point2 (volmdlr.Point3D) – The other 3-dimensional point

Returns:

The euclidean distance

Return type:

float

to_dict(*args, **kwargs)#

Serializes a 3-dimensional point into a dictionary.

Returns:

A serialized version of the Point3D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

to_step(current_id, vertex=False)#

Writes a step primitive from a 3-dimensional point.

Parameters:
  • current_id (int) – The id of the last written primitive

  • vertex (bool, optional) – If ‘True’, adds a VERTEX_POINT step primitive on top of the CARTESIAN_POINT step primitive. Default value set to ‘False’

Returns:

A tuple containing the string representing the step primitive and the new current id

Return type:

tuple

to_vector()#

Converts a Point3D object to a Vector3D object.

Returns:

A Vector3D

Return type:

volmdlr.Vector3D

class volmdlr.core_compiled.Vector#

Bases: object

Abstract class of vector

is_colinear_to(other_vector: Vector, abs_tol: float = 1e-06)#

Checks if two vectors are colinear. The two vectors should be of same dimension.

Parameters:
  • other_vector (volmdlr.Vector) – A vector-like object

  • abs_tol (float) – Absolute tolerance to consider colinear

Returns:

True if the two vectors are colinear, False otherwise

Return type:

bool

is_perpendicular_to(other_vector: Vector, abs_tol: float = 1e-05)#

Checks if two vectors are perpendicular. The two vectors should be of same dimension.

Parameters:
  • other_vector (volmdlr.Vector) – A vector-like object

  • abs_tol (float) – Absolute tolerance to consider perpendicular

Returns:

True if the two vectors are perpendicular, False otherwise

Return type:

bool

classmethod mean_point(points: List[Vector], name='')#

Find the mean point from a list of points. All the objects of this list should be of same dimension.

Parameters:
  • points (List[volmdlr.Vector]) – A list of vector-like objects

  • name – object’s name.

Returns:

The mean point or vector

Return type:

volmdlr.Vector

name#
classmethod remove_duplicate(points: List[Vector])#

An approximative method to remove duplicated points from a list. All the objects of this list should be of same dimension.

Parameters:

points (List[volmdlr.Vector]) – A list of vector-like objects with potential duplicates

Returns:

The new list of vector-like objects without duplicates&

Return type:

List[volmdlr.Vector]

to_vector()#
vector_projection(other_vector)#

Projects the vector onto other_vector.

Parameters:

other_vector – Vector to project self.

class volmdlr.core_compiled.Vector2D#

Bases: Vector

Class representing a 2-dimensional vector.

Parameters:
  • x (float) – The vector’s abscissa

  • y (float) – The vector’s ordinate

approx_hash()#

Computes an approximative hash value based on the coordinates.

Returns:

An approximative hash value

Return type:

int

copy(deep=True, memo=None)#

Creates a copy of a 2-dimensional vector.

Parameters:
  • deepnot used

  • memonot used

Returns:

A copy of the Vector2D-like object

Return type:

volmdlr.Vector2D

cross(other_vector: Vector2D)#

Computes the cross product of two 2-dimensional vectors.

Parameters:

other_vector (volmdlr.Vector2D) – A Vector2D-like object

Returns:

A scalar, result of the cross product

Return type:

float

deterministic_unit_normal_vector()#

# TODO: to be deleted ? # TODO: Or unit_normal_vector should be renamed deterministic_unit_normal_vector ?

classmethod dict_to_object(dict_, *args, **kwargs)#

Deserializes a dictionary to a 3-dimensional point.

Parameters:

dict (dict) – The dictionary of a serialized Point3D

Returns:

Return type:

volmdlr.Point3D

See also

How serialization and deserialization works in dessia_common

dot(other_vector: Vector2D)#

Computes the dot product (scalar product) of two 2-dimensional vectors.

Parameters:

other_vector (volmdlr.Vector2D) – A Vector2D-like object

Returns:

A scalar, result of the dot product

Return type:

float

frame_mapping(frame: Frame2D, side: str)#

# TODO: Needs correction. Add an example ? Transforms a 2-dimensional vector from the current reference frame to a new one. Choose side equals to ‘old’ if the current reference frame is the old one ; choose side equals to ‘new’ if the input reference frame is the new one. This way, choosing ‘old’ will return the frame mapped vector of the input reference frame.

Parameters:
  • frame (volmdlr.Frame2D) – The input reference frame

  • side (str) – Choose between ‘old’ and ‘new’

Returns:

A frame mapped Vector2D-like object

Return type:

volmdlr.Vector2D

is_close(other_vector: Vector2D, tol: float = 1e-06)#

Checks if two vectors are close to each other considering the Euclidean distance. The tolerance can be modified. The two vectors should be of same dimension.

Parameters:
  • other_vector (volmdlr.Vector2D) – A Vector2D-like object

  • tol (float) – The tolerance under which the euclidean distance is considered equal to 0

Returns:

True if the two Vector2D-like objects are close enough to each other, False otherwise

Return type:

bool

norm()#

Computes the euclidiean norm of a 2-dimensional vector.

Returns:

Norm of the Vector2D-like object

Return type:

float

normal_vector()#

Returns the normal vector located pi/2 (counterclockwise) to the 2-dimensional vector.

Returns:

A normal Vector2D

Return type:

volmdlr.Vector2D

plot(head_width: float = 3.0, origin: Vector2D = None, ax: matplotlib.axes.Axes = None, color: str = 'k', label: str = None)#

Plots the 2-dimensional vector. If the vector has a norm greater than 1e-9, it will be plotted with an arrow, else it will be plotted with a point.

Parameters:
  • head_width (float, optional) – The width of the head of the arrow

  • origin (volmdlr.Vector2D, optional) – The starting point of the tail of the arrow

  • ax (matplotlib.axes.Axes, optional) – The Axes on which the Vector2D will be drawn

  • color (str, optional) – The color of the arrow

  • label (str, optional) – The text you want to display

Returns:

A matplotlib Axes object on which the Vector2D have been plotted

Return type:

matplotlib.axes.Axes

point_distance(other_vector: Vector2D)#

Computes the euclidiean distance between two Vector2D objects.

Parameters:

other_vector (volmdlr.Vector2D) – A Vector2D object

Returns:

The euclidiean distance

Return type:

float

classmethod random(xmin: float, xmax: float, ymin: float, ymax: float, name: str = '')#

Returns a random 2-dimensional point.

Parameters:
  • xmin (float) – The minimal abscissa

  • xmax (float) – The maximal abscissa

  • ymin (float) – The minimal ordinate

  • ymax (float) – The maximal ordinate

  • name – object’s name.

Returns:

A random Vector2D

Return type:

volmdlr.Vector2D

rotation(center: Point2D, angle: float)#

Rotates the 2-dimensional vector and returns a new rotated vector

Parameters:
  • center (volmdlr.Point2D) – The center of rotation

  • angle (float) – The angle of the rotation in radian

Returns:

A rotated Vector2D-like object

Return type:

volmdlr.Vector2D

rotation_parameters(center: Point2D, angle: float)#

Calculates the parameters to be used in rotation methods

Parameters:
  • center (volmdlr.Point2D) – The center of rotation

  • angle (float) – The angle of the rotation in radian

Returns:

The abscissa and ordinate of the rotated vector

Return type:

tuple

to_3d(plane_origin: Point3D, vx: Vector3D, vy: Vector3D)#

Returns the 3-dimensional vector corresponding to the 2-dimensional vector placed on the 3-dimensional plane (XY) of the 3-dimensional frame (centered on plane_origin, having for basis (vx, vy, vz), vz being the cross product of vx and vy).

Parameters:
  • plane_origin (volmdlr.Vector3D) – The origin of the plane, on which lies the Vector2D

  • vx (volmdlr.Vector3D) – The first direction of the plane

  • vy (volmdlr.Vector3D) – The second direction of the plane

Returns:

The Vector3D from the Vector2D set in the 3-dimensional space

Return type:

volmdlr.Vector3D

to_dict(*args, **kwargs)#

Serializes a 2-dimensional vector into a dictionary.

Returns:

A serialized version of the Vector2D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

to_point()#

Transforms a Vector2D into a Point2D and returns it.

Returns:

A Point2D

Return type:

volmdlr.Point2D

to_step(current_id, vector=False, vertex=False)#

Write a step primitive from a 2-dimensional vector.

Parameters:
  • current_id (int) – The id of the last written primitive

  • vector (bool, optional) – If ‘True’ creates a step VECTOR primitive. Otherwise, only a DIRECTION primitive will be created. Default value set to ‘False’

  • vertex (bool, optional) – If ‘True’ calls the to_step method of Point3D. Default value set to ‘False’

Returns:

A tuple containing the string representing the step primitive and the new current id

Return type:

tuple

translation(offset: Vector2D)#

Translates the 2-dimensional vector and returns a new translated vector

Parameters:

offset (volmdlr.Vector2D) – The offset vector of the translation

Returns:

A translated Vector2D-like object

Return type:

volmdlr.Vector2D

unit_normal_vector()#

Returns the unit normal vector located pi/2 (counterclockwise) to the 2-dimensional vector.

Returns:

A unit normal Vector2D

Return type:

volmdlr.Vector2D

unit_vector()#

Calculates the unit vector.

x#
y#
class volmdlr.core_compiled.Vector3D#

Bases: Vector

Class representing a 3-dimensional vector.

Parameters:
  • x (float) – The vector’s abscissa

  • y (float) – The vector’s ordinate

  • Z – The vector’s applicate

  • name (str) – The vector’s name

approx_hash()#

Computes an approximative hash value based on the coordinates.

Returns:

An approximative hash value

Return type:

int

static axis_rotation_parameters(axis1_value, axis2_value, angle)#

# TODO: to be completed Calcules new axis1 and axis2 new values after vector rotation.

Parameters:
  • axis1_value

  • axis2_value

  • angle

Returns:

Return type:

tuple

copy(deep=True, memo=None)#

Creates a copy of a 2-dimensional vector.

Parameters:
  • deepnot used

  • memonot used

Returns:

A copy of the Vector2D-like object

Return type:

volmdlr.Vector2D

cross(other_vector: Vector3D) Vector3D#

Computes the cross product between two 3-dimensional vectors.

Parameters:

other_vector (volmdlr.Vector3D) – A Vector3D-like object

Returns:

Value of the cross product

Return type:

float

deterministic_normal_vector()#

Returns a deterministic normal 3-dimensional vector.

Returns:

A normal Vector3D

Return type:

volmdlr.Vector3D

deterministic_unit_normal_vector()#

Returns a deterministic unit normal 3-dimensional vector.

Returns:

A normal Vector3D

Return type:

volmdlr.Vector3D

classmethod dict_to_object(dict_, *args, **kwargs)#

Deserializes a dictionary to a 3-dimensional vector.

Parameters:
  • dict (dict) – The dictionary of a serialized Vector3D

  • global_dict (dict, optional) – The global dictionary. Default value is None

  • pointers_memo (dict, optional) – A dictionary from path to python object of already serialized values. Default value is None

  • path (str, optional) – The path in the global object. In most cases, append ‘/attribute_name’ to given path for your attributes. Default value is ‘#’

Returns:

Return type:

volmdlr.Vector3D

See also

How serialization and deserialization works in dessia_common

dot(other_vector)#

Computes the dot product between two 3-dimensional vectors.

Parameters:

other_vector (volmdlr.Vector3D) – A Vector3D-like object

Returns:

Value of the dot product

Return type:

float

frame_mapping(frame: Frame3D, side: str)#

# TODO: Needs correction. Add an example ? Transforms a 3-dimensional vector from the current reference frame to a new one. Choose side equals to ‘old’ if the current reference frame is the old one ; choose side equals to ‘new’ if the input reference frame is the new one. This way, choosing ‘old’ will return the frame mapped vector of the input reference frame.

Parameters:
  • frame (volmdlr.Frame3D) – The input reference frame

  • side (str) – Choose between ‘old’ and ‘new’

Returns:

A frame mapped Vector3D-like object

Return type:

volmdlr.Vector3D

classmethod from_step(arguments, object_dict, **kwargs)#

Converts a step primitive from a 3-dimensional vector to a Vector3D.

Parameters:
  • arguments (list) – The arguments of the step primitive.

  • object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated

Returns:

The corresponding Vector3D object

Return type:

volmdlr.Vector3D

is_close(other_vector, tol=1e-06)#

Checks if two vectors are close to each other considering the Euclidean distance. The tolerance can be modified. The two vectors should be of same dimension.

Parameters:
  • other_vector (volmdlr.Vector3D) – A Vector3D-like object

  • tol (float) – The tolerance under which the euclidean distance is considered equal to 0

Returns:

True if the two Vector3D-like objects are close enough to each other, False otherwise

Return type:

bool

norm() float#

Computes the euclidiean norm of a 3-dimensional vector.

Returns:

Norm of the Vector3D-like object

Return type:

float

plane_projection2d(plane_origin: Vector3D, x: Vector3D, y: Vector3D)#

Projects a Vector3D-like object on a 2D plane.

Parameters:
  • plane_origin (volmdlr.Vector3D) – The 3D origin of the 2D projection plane

  • x (volmdlr.Vector3D) – The 3D X axis of the 2D plane

  • y (volmdlr.Vector3D) – The 3D Y axis of the 2D plane

Returns:

The projection on the 2D plane

Return type:

volmdlr.Point2D

plane_projection3d(plane_origin: Vector3D, x: Vector3D, y: Vector3D)#

Projects a Vector3D-like object on a 3D plane.

Parameters:
  • plane_origin (volmdlr.Vector3D) – The origin of the 3D projection plane

  • x (volmdlr.Vector3D) – The X axis of the 3D plane

  • y (volmdlr.Vector3D) – The Y axis of the 3D plane

Returns:

The projection on the 3D plane

Return type:

volmdlr.Vector3D

plot(ax=None, starting_point=None, color='k')#

Plots the 3-dimensional vector.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – The Axes on which the Vector2D will be drawn

  • starting_point (volmdlr.Vector3D, optional) – The location of the origin of the vector. Default value is None, corresponding to (0, 0, 0)

  • color (str, optional) – The color of the drawn vector. Default value is empty string for black

Returns:

A matplotlib Axes object on which the Vector3D have been plotted

Return type:

matplotlib.axes.Axes

point_distance(other_vector: Vector3D) float#

Computes the euclidiean distance between two Vector3D objects.

Parameters:

other_vector (volmdlr.Vector3D) – A Vector3D object

Returns:

The euclidiean distance

Return type:

float

classmethod random(xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float, name: str = '')#

Returns a random 2-dimensional point.

Parameters:
  • xmin (float) – The minimal abscissa

  • xmax (float) – The maximal abscissa

  • ymin (float) – The minimal ordinate

  • ymax (float) – The maximal ordinate

  • zmin (float) – The minimal applicate

  • zmax (float.) – The maximal applicate

  • name – object’s name.

Returns:

A random Vector3D

Return type:

volmdlr.Vector3D

random_unit_normal_vector()#

Returns a random normal 3-dimensional vector.

Returns:

A normal Vector3D

Return type:

volmdlr.Vector3D

rotation(center: Point3D, axis: Vector3D, angle: float)#

Rotates of angle around axis the 2-dimensional vector and returns a new rotated vector. Using Rodrigues Formula:

Parameters:
  • center (volmdlr.Point3D) – The center of rotation

  • axis (volmdlr.Vector3D) – The axis of rotation

  • angle (float) – The angle of the rotation in radian

Returns:

A rotated Vector3D-like object

Return type:

volmdlr.Vector3D

to_2d(plane_origin: Point3D, x: Vector3D, y: Vector3D)#

# TODO: difference with plane_projection2d needs details Transforms a Vector3D-like object to a Point2D.

Parameters:
  • plane_origin (volmdlr.Vector3D) – The 3D origin of the 2D projection plane

  • x (volmdlr.Vector3D) – The 3D X axis of the 2D plane

  • y (volmdlr.Vector3D) – The 3D Y axis of the 2D plane

Returns:

The transformed Point2D

Return type:

volmdlr.Point2D

to_dict(*args, **kwargs)#

Serializes a 3-dimensional vector into a dictionary.

Returns:

A serialized version of the Vector3D

Return type:

dict

See also

How serialization and deserialization works in dessia_common

to_point()#

Converts a Vector3D object to a Point3D object.

Returns:

A Point3D

Return type:

volmdlr.Point3D

to_step(current_id, vector=False, vertex=False)#

Write a step primitive from a 3-dimensional vector.

Parameters:
  • current_id (int) – The id of the last written primitive

  • vector (bool, optional) – If ‘True’ creates a step VECTOR primitive. Otherwise, only a DIRECTION primitive will be created. Default value set to ‘False’

  • vertex (bool, optional) – If ‘True’ calls the to_step method of Point3D. Default value set to ‘False’

Returns:

A tuple containing the string representing the step primitive and the new current id

Return type:

tuple

translation(offset: Vector3D)#

Translates the vector and returns a new translated vector

Parameters:

offset (volmdlr.Vector3D) – A Vector3D-like object used for offsetting

Returns:

A translated Vector3D-like object

Return type:

volmdlr.Vector3D

unit_vector()#

Calculates the unit vector.

x#
x_rotation(angle: float)#

Rotation of angle around X axis and returns a new vector as a result.

Parameters:

angle (float) – Value of the angle

Returns:

A 3-dimensional point

Return type:

volmdlr.Point3D

y#
y_rotation(angle: float)#

Rotation of angle around Y axis and returns a new vector as result.

Parameters:

angle (float) – Value of the angle

Returns:

A 3-dimensional point

Return type:

volmdlr.Point3D

z#
z_rotation(angle: float)#

rrotation of angle around Z axis and returns a new vector as result.

Parameters:

angle (float) – Value of the angle

Returns:

A 3-dimensional point

Return type:

volmdlr.Point3D

volmdlr.core_compiled.bbox_is_intersecting(bbox1, bbox2, tol)#

Verifies if the two bounding boxes are intersecting, or touching.

volmdlr.core_compiled.get_minimum_distance_points_lines(linesegment1_start, linesegment1_end, linesegment2_start, linesegment2_end)#

Returns the points minimum distance points between two lines.

volmdlr.core_compiled.linesegment2d_point_distance(start, end, point)#
volmdlr.core_compiled.linesegment3d_point_distance(start, end, point)#
volmdlr.core_compiled.points_in_polygon(polygon, points, include_edge_points=False, tol=1e-06)#
volmdlr.core_compiled.polygon_point_belongs(polygon, point, include_edge_points=False, tol=1e-06)#

Core#

Base classes.

class volmdlr.core.Assembly(components: List[Primitive3D], positions: List[Frame3D], frame: Frame3D = Frame3D(origin=Point3D(0.0, 0.0, 0.0), u=Vector3D(1.0, 0.0, 0.0), v=Vector3D(0.0, 1.0, 0.0), w=Vector3D(0.0, 0.0, 1.0)), name: str = '')[source]#

Bases: PhysicalObject

Defines an assembly.

Parameters:
  • components (List[volmdlr.core.Primitive3D]) – A list of volmdlr objects

  • positions (List[volmdlr.Frame3D]) – A list of volmdlr.Frame3D representing the positions of each component in the assembly absolute frame.

  • name (str) – The Assembly’s name

babylon_data(merge_meshes=True)[source]#

Get babylonjs data.

Returns:

Dictionary with babylon data.

property bounding_box#

Returns the bounding box.

frame_mapping(frame: Frame3D, side: str)[source]#

Changes frame_mapping and return a new Assembly.

side = ‘old’ or ‘new’

plot(ax=None, equal_aspect=True)[source]#

Matplotlib plot of model.

To use for debug.

to_step(current_id)[source]#

Creates step file entities from volmdlr objects.

to_step_product(current_id)[source]#

Returns step product entities from volmdlr objects.

volmdlr_primitives()[source]#

Return a list of volmdlr primitives to build up an Assembly.

class volmdlr.core.BoundingBox(xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float, name: str = '')[source]#

Bases: DessiaObject

An axis aligned boundary box.

property center#

Computes the center of the bounding box.

TODO: change lru_cache to cached property when support for py3.7 is dropped.

distance_to_bbox(bbox2: BoundingBox) float[source]#

Calculates the distance between the bounding box and another bounding box.

If the bounding boxes intersect, the distance is 0. Otherwise, the distance is the minimum Euclidean distance between their closest faces.

Parameters:

bbox2 (BoundingBox) – Another bounding box to compare with.

Returns:

The distance between the bounding boxes.

Return type:

float

distance_to_point(point: Point3D) float[source]#

Calculates the minimum Euclidean distance between the bounding box and a point.

Parameters:

point (volmdlr.Point3D) – The point to compare with.

Returns:

The minimum distance between the point and the bounding box.

Return type:

float

classmethod from_bounding_boxes(bounding_boxes: List[BoundingBox], name: str = '') BoundingBox[source]#

Create a bounding box that contains multiple bounding boxes.

Parameters:
  • bounding_boxes (List[BoundingBox]) – A list of bounding boxes that need to be contained.

  • name (str) – A name for the bounding box, optional.

Returns:

A new bounding box that contains all the input bounding boxes.

Return type:

BoundingBox

classmethod from_points(points: List[Point3D], name: str = '') BoundingBox[source]#

Initializes a bounding box from a list of points.

Parameters:
  • points (List[volmdlr.Point3D].) – The list of points to create the bounding box from.

  • name – object’s name.

Returns:

The bounding box initialized from the list of points.

Return type:

BoundingBox

get_points_inside_bbox(points_x, points_y, points_z)[source]#

Gets points inside the BoudingBox.

Parameters:
  • points_x – Number of points in x direction.

  • points_y – Number of points in y direction.

  • points_z – Number of points in z direction.

Returns:

list of points inside bounding box.

intersection_volume(bbox2: BoundingBox) float[source]#

Calculate the volume of the intersection of two bounding boxes.

Parameters:

bbox2 (BoundingBox) – The second bounding box to intersect with the first one.

Returns:

The volume of the intersection of two bounding boxes.

Return type:

float

is_close(other_bounding_box: BoundingBox, tol: float = 1e-06) bool[source]#

Check if two bounding boxes are close to each other considering the Euclidean distance of their corners points.

The tolerance can be modified.

Parameters:
  • other_bounding_box (BoundingBox) – the other bounding box.

  • tol (float) – The tolerance under which the Euclidean distance is considered equal to 0.

Returns:

True if the bounding boxes are equal at the given tolerance, False otherwise.

Return type:

bool

is_inside_bbox(bbox2: BoundingBox) bool[source]#

Checks if a bounding box is contained inside another bounding box.

Parameters:

bbox2 (BoundingBox) – The bounding box to check against.

Returns:

True if the bounding box is contained inside bbox2, False otherwise.

Return type:

bool

is_intersecting(bbox2, tol: float = 1e-06)[source]#

Checks if two bounding boxes are intersecting or touching.

Parameters:
  • self – BoundingBox object representing the first bounding box.

  • bbox2 – BoundingBox object representing the second bounding box.

  • tol – tolerance to be considered.

Returns:

True if the bounding boxes are intersecting or touching, False otherwise.

is_intersecting_triangle(triangle: Triangle3D) bool[source]#

Check if the bounding box and a triangle are intersecting or touching.

Parameters:

triangle (Triangle3D) – the triangle to check if there is an intersection with.

Returns:

True if the bounding box and the triangle are intersecting or touching, False otherwise.

Return type:

bool

octree()[source]#

Creates a simple octree structure for a bounding box.

plot(ax=None, color='gray')[source]#

Plot the bounding box on 3D axes.

Parameters:
  • ax (Matplotlib.axes._subplots.Axes3DSubplot, optional) – The 3D axes to plot on. If not provided, a new figure will be created.

  • color (str, optional) – The color of the lines used to plot the bounding box.

Returns:

The 3D axes with the plotted bounding box.

Return type:

Matplotlib.axes._subplots.Axes3DSubplot

point_inside(point: Point3D, tol=1e-06) bool[source]#

Determines if a point belongs to the bounding box.

Parameters:
  • point (volmdlr.Point3D) – The point to check for inclusion.

  • tol – tolerance.

Returns:

True if the point belongs to the bounding box, False otherwise.

Return type:

bool

property points: List[Point3D]#

Returns the eight corner points of the bounding box.

Returns:

A list of eight 3D points representing the corners of the bounding box.

Return type:

list of volmdlr.Point3D

scale(factor: float) BoundingBox[source]#

Scales the bounding box by a given factor and returns a new BoundingBox.

Parameters:

factor (float) – The scaling factor.

Returns:

A new scaled BoundingBox.

Return type:

BoundingBox

property size#

Gets the Size of the Bounding Box.

to_dict(*args, **kwargs) dict[source]#

Converts the bounding box to a dictionary representation.

Parameters:
  • use_pointers (bool, optional) – DESCRIPTION, defaults to True

  • memo (TYPE, optional) – DESCRIPTION, defaults to None

  • path (str, optional) – A string representing the current position of the object in the serialized data structure.

Returns:

The dictionary representation of the bounding box.

Return type:

dict

to_frame() Frame3D[source]#

Converts the bounding box to a 3D frame.

Returns:

A 3D frame with origin at the center and axes aligned with the x, y, and z dimensions of the bounding box.

Return type:

volmdlr.Frame3D

volume() float[source]#

Calculates the volume of a bounding box.

Returns:

The volume of the bounding box.

Return type:

float

class volmdlr.core.BoundingRectangle(xmin: float, xmax: float, ymin: float, ymax: float, name: str = '')[source]#

Bases: DessiaObject

Bounding rectangle.

Parameters:
  • xmin (float) – minimal x coordinate

  • xmax (float) – maximal x coordinate

  • ymin (float) – minimal y coordinate

  • ymax (float) – maximal y coordinate

area()[source]#

Calculates the area of the bounding rectangle.

b_rectangle_intersection(b_rectangle2)[source]#

Returns True if there is an intersection with another specified bounding rectangle or False otherwise.

Parameters:

b_rectangle2 (BoundingRectangle) – bounding rectangle to verify intersection

bounding_points()[source]#

Return the bounds of the BoundingRectangle.

bounds()[source]#

Return the bounds of the BoundingRectangle.

center()[source]#

Calculates the bounding rectangle center.

distance_to_b_rectangle(b_rectangle2)[source]#

Calculates the minimal distance between two bounding rectangles.

Parameters:

b_rectangle2 (BoundingRectangle) – A bounding rectangle

distance_to_point(point: Point2D)[source]#

Calculate the minimal distance between the bounding rectangle and a specified point.

Parameters:

point (volmdlr.Point2D) – A 2D point

classmethod from_points(points: List[Point2D], name: str = '') BoundingRectangle[source]#

Initializes a bounding rectangle from a list of points.

Parameters:
  • points (List[volmdlr.Point2D].) – The list of points to create the bounding rectangle from.

  • name – object’s name.

Returns:

The bounding rectangle initialized from the list of points.

Return type:

BoundingRectangle

intersection_area(b_rectangle2)[source]#

Calculates the intersection area between two bounding rectangle.

Parameters:

b_rectangle2 (BoundingRectangle) – A bounding rectangle

is_inside_b_rectangle(b_rectangle2, tol: float = 1e-06)[source]#

Returns True if the bounding rectangle is totally inside specified bounding rectangle and False otherwise.

Parameters:
  • b_rectangle2 (BoundingRectangle) – A bounding rectangle

  • tol (float) – A tolerance for considering inside

is_intersecting(b_rectangle2)[source]#

Returns True if there is an intersection with another specified bounding rectangle or False otherwise.

Parameters:

b_rectangle2 (BoundingRectangle) – bounding rectangle to verify intersection

plot(ax=None, color='k', linestyle='dotted')[source]#

Plot of the bounding rectangle and its vertex.

point_inside(point: Point2D)[source]#

Returns True if a specified point is inside the bounding rectangle and False otherwise.

Parameters:

point (volmdlr.Point2D) – A 2 dimensional point

class volmdlr.core.CompositePrimitive3D(primitives: List[Primitive3D], color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Bases: Primitive3D

A collection of simple primitives3D.

plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]#

Plot the 3D primitives onto the given Axes3D object.

Parameters:

ax (Matplotlib plot) – optional The Axes3D object onto which to plot the primitives. If None, a new figure and Axes3D object will be created.

edge_styleoptional

The EdgeStyle to use when plotting the primitives.

Returns:

The Axes3D object onto which the primitives were plotted.

Return type:

Matplotlib plot

to_dict(*args, **kwargs)[source]#

Avoids storing points in memo that makes serialization slow.

class volmdlr.core.Compound(primitives, name: str = '')[source]#

Bases: PhysicalObject

A class that can be a collection of any volmdlr primitives.

babylon_data(merge_meshes=True)[source]#

Get babylonjs data.

Returns:

Dictionary with babylon data.

property bounding_box#

Returns the bounding box.

property compound_type#

Returns the compound type.

frame_mapping(frame: Frame3D, side: str)[source]#

Changes frame_mapping and return a new Compound.

side = ‘old’ or ‘new’

to_step(current_id)[source]#

Creates step file entities from volmdlr objects.

volmdlr_primitives()[source]#

Return primitives.

class volmdlr.core.EdgeStyle(color: str = 'k', alpha: float = 1, edge_ends: bool = False, edge_direction: bool = False, width: float | None = None, arrow: bool = False, plot_points: bool = False, dashed: bool = True, linestyle: str = '-', linewidth: float = 1, equal_aspect: bool = True)[source]#

Bases: object

Data class for styling edges Matplotlib plots.

alpha: float = 1#
arrow: bool = False#
color: str = 'k'#
dashed: bool = True#
edge_direction: bool = False#
edge_ends: bool = False#
equal_aspect: bool = True#
linestyle: str = '-'#
linewidth: float = 1#
plot_points: bool = False#
width: float = None#
class volmdlr.core.MovingVolumeModel(primitives: List[Primitive3D], step_frames: List[List[Frame3D]], name: str = '')[source]#

Bases: VolumeModel

A volume model with possibility to declare time steps at which the primitives are positioned with frames.

babylon_data(merge_meshes=True)[source]#

Get babylonjs data.

Returns:

Dictionary with babylonjs data.

is_consistent()[source]#

Check if the number of frames for each step corresponds to the number of primitives of the model.

step_volume_model(istep: int)[source]#

Moves the volume model with a list of local frames.

class volmdlr.core.Primitive3D(color: Tuple[float, float, float] | None = None, alpha: float = 1.0, reference_path: str = '#', name: str = '')[source]#

Bases: PhysicalObject

Defines a Primitive3D.

babylon_meshes(*args, **kwargs)[source]#

Returns the babylonjs mesh.

babylon_param()[source]#

Returns babylonjs parameters.

Returns:

babylonjs parameters (alpha, name, color)

Return type:

dict

triangulation(*args, **kwargs)[source]#

Get object triangulation.

volmdlr_primitives()[source]#

Return a list of volmdlr primitives to build up volume model.

class volmdlr.core.VolumeModel(primitives: List[Primitive3D], name: str = '')[source]#

Bases: PhysicalObject

A class containing one or several volmdlr.core.Primitive3D.

Parameters:
babylon_data(merge_meshes=True)[source]#

Get babylonjs data.

Returns:

Dictionary with babylon data.

babylonjs(page_name: str | None = None, use_cdn: bool = True, debug: bool = False, merge_meshes: bool = True, dark_mode: bool = False)[source]#

Generate and display an HTML file to visualize the 3D model using Babylon.js in a web browser.

This method creates a 3D representation of the volume model using the Babylon.js framework. The method allows options for debugging, merging meshes, and toggling dark mode for the visualization. The resulting HTML file can either be a temporary file or a user-specified file.

Parameters:
  • page_name (str, optional) – The name of the HTML file to be generated. If None, a temporary file is created.

  • use_cdn (bool) – Flag to use CDN for loading Babylon.js resources. Defaults to True.

  • debug (bool) – Enable debugging mode for more detailed console output in the browser. Defaults to False.

  • merge_meshes (bool) – Flag to chose to merge all the faces of each shell into a single mesh. Defaults to True. If False, shell are decomposed according to their faces in the Babylon.js scene nodes tree.

  • dark_mode (bool) – Enable dark mode for the HTML visualization. Defaults to False.

Returns:

The file path of the generated HTML file.

Return type:

str

classmethod babylonjs_script(babylon_data, use_cdn=True, **kwargs)[source]#

Run babylonjs script.

property bounding_box#

Returns the bounding box.

copy(deep=True, memo=None)[source]#

Specific copy.

frame_mapping(frame: Frame3D, side: str)[source]#

Changes frame_mapping and return a new VolumeModel.

side = ‘old’ or ‘new’

static generate_msh_file(file_name, mesh_dimension, mesh_order)[source]#

Generates a mesh written in a .msh file using GMSH library.

Parameters:
  • file_name (TYPE) – DESCRIPTION

  • mesh_dimension (TYPE) – DESCRIPTION

  • mesh_order (int) – The msh order (1: linear, 2: 2nd order)

Returns:

DESCRIPTION

Return type:

TYPE

static get_elements_lines(gmsh_model)[source]#

Helper function to export the volume model into gmsh format.

get_geo_lines()[source]#

Gets the lines that define a VolumeModel geometry in a .geo file.

Returns:

A list of lines that describe the geometry

Return type:

List[str]

get_mesh_lines(factor: float, **kwargs)[source]#

Gets the lines that define mesh parameters for a VolumeModel, to be added to a .geo file.

Parameters:

factor – A float, between 0 and 1, that describes the mesh quality

(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional

Returns:

A list of lines that describe mesh parameters

Return type:

List[str]

static get_nodes_lines(gmsh_model)[source]#

Get nodes lines.

get_shells()[source]#

Dissociates all the assemblies to get a list of shells only.

Returns:

A list of closed shells

Return type:

List[OpenShell3D]

plot(equal_aspect=True)[source]#

Matplotlib plot of model.

To use for debug.

rotation(center: Point3D, axis: Vector3D, angle: float)[source]#

Rotates the VolumeModel.

Parameters:
  • center – rotation center

  • axis – rotation axis

  • angle – angle rotation

Returns:

a new rotated VolumeModel

save_babylonjs_to_file(filename: str | None = None, use_cdn=True, debug=False, dark_mode=False)[source]#

Export a html file of the model.

to_geo(file_name: str = '', factor: float = 0.5, **kwargs)[source]#

Gets the .geo file for the VolumeModel.

Parameters:
  • file_name (str) – The geo. file name

  • factor – A float, between 0 and 1, that describes the mesh quality

(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional

Returns:

A txt file

Return type:

.txt

to_geo_stream(stream: StringFile, factor: float, **kwargs)[source]#

Gets the .geo file for the VolumeModel.

Parameters:
  • file_name (str) – The geo. file name

  • factor – A float, between 0 and 1, that describes the mesh quality

(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional

Returns:

A txt file

Return type:

.txt

to_geo_with_stl(file_name: str, factor: float, **kwargs)[source]#

Gets the .geo file for the VolumeModel, with saving each closed shell in a stl file.

Parameters:
  • file_name (str) – The geo. file name

  • factor – A float, between 0 and 1, that describes the mesh quality

(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional

Returns:

A txt file

Return type:

.txt

to_mesh(merge_vertices: bool = True, merge_triangles: bool = True)[source]#

Converts the volume model to a Mesh3D object.

Parameters:
  • merge_vertices – Flag to indicate whether to merge vertices of the shells meshes.

  • merge_triangles – Flag to indicate whether to merge triangles of the shells meshes.

Returns:

A Mesh3D of the VolumeModel

to_mesh_list()[source]#

Converts the volume model to a list Mesh3D object.

Returns:

A list of Mesh3D objects representing the VolumeModel shells.

to_msh(mesh_dimension: int, factor: float, mesh_order: int = 1, file_name: str = '', **kwargs)[source]#

Gets .msh file for the VolumeModel generated by gmsh.

Parameters:
  • file_name (str) – The msh. file name

  • mesh_dimension (int) – The mesh dimension (1: 1D-Edge, 2: 2D-Triangle, 3D-Tetrahedra)

  • mesh_order (int) – The msh order (1: linear, 2: 2nd order)

  • factor – A float, between 0 and 1, that describes the mesh quality

(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional

Returns:

A txt file

Return type:

.txt

to_msh_file(mesh_dimension: int, factor: float, stream: StringFile, mesh_order: int = 1, file_name: str = '', **kwargs)[source]#

Convert and write model to a .msh file.

to_msh_stream(mesh_dimension: int, factor: float, stream: StringFile, mesh_order: int = 1, file_name: str = '', **kwargs)[source]#

Gets .msh file for the VolumeModel generated by gmsh.

Parameters:
  • file_name (str) – The msh. file name

  • mesh_dimension (int) – The mesh dimension (1: 1D-Edge, 2: 2D-Triangle, 3D-Tetrahedra)

  • mesh_order (int) – The msh order (1: linear, 2: 2nd order)

  • factor – A float, between 0 and 1, that describes the mesh quality

(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional

Returns:

A txt file

Return type:

.txt

to_step(filepath: str)[source]#

Export a step file of the model.

to_step_stream(stream: StringFile)[source]#

Export object CAD to given stream in STEP format.

to_stl(filepath: str)[source]#

Export a stl file of the model.

to_stl_model()[source]#

Converts the model into a stl object.

to_stl_stream(stream: BinaryFile)[source]#

Converts the model into a stl stream file.

translation(offset: Vector3D)[source]#

Translates the VolumeModel.

Parameters:

offset – translation vector

Returns:

A new translated VolumeModel

static update_surfaces_list(face_contours, surfaces, contours, i)[source]#

Update surfaces list.

volmdlr_volume_model()[source]#

Method needed due to PhysicalObject inheritance.

volume() float[source]#

Return the sum of volumes of the primitives.

It does not make any Boolean operation in case of overlapping.

volmdlr.core.delete_double_point(list_point)[source]#

Delete duplicate points from a list of points.

Parameters:

list_point (Union[List[volmdlr.Point2D], List[volmdlr.Point3D]]) – The initial list of points

Returns:

The final list of points containing no duplicates

Return type:

Union[List[volmdlr.Point2D], List[volmdlr.Point3D]]

volmdlr.core.determinant(vec1, vec2, vec3)[source]#

Calculates the determinant for a three vector matrix.

volmdlr.core.edge_in_list(edge, list_edges, tol: float = 1e-06)[source]#

Verifies if an edge is inside a list of edges, considering a certain tolerance.

Parameters:
  • edge – Edge to be verified inside list.

  • list_edges – List of edges to be used.

  • tol – Tolerance to consider if two points are the same.

Returns:

True if there is an edge inside the list close to the edge to given tolerance.

volmdlr.core.element_in_list(element, list_elements, tol: float = 1e-06)[source]#

Verifies if a volmdlr element is inside a list of elements, considering a certain tolerance.

Parameters:
  • element – Element to be verified inside list.

  • list_elements – List of elements to be used.

  • tol – Tolerance to consider if two points are the same.

Returns:

True if there is an element inside the list close to the element to given tolerance.

volmdlr.core.get_edge_index_in_list(edge, list_edges, tol: float = 1e-06)[source]#

Gets the index a edge inside a list of edges, considering a certain tolerance.

Parameters:
  • edge – Edge to be verified inside list.

  • list_edges – List of edges to be used.

  • tol – Tolerance to consider if two edges are the same.

Returns:

The edge index.

volmdlr.core.get_element_index_in_list(element, list_elements, tol: float = 1e-06)[source]#

Gets the index an element inside a list of elements, considering a certain tolerance.

Parameters:
  • element – Element to be verified inside list.

  • list_elements – List of elements to be used.

  • tol – Tolerance to consider if two elements are the same.

Returns:

The element index.

volmdlr.core.get_point_index_in_list(point, list_points, tol: float = 1e-06)[source]#

Gets the index a point inside a list of points, considering a certain tolerance.

Parameters:
  • point – Point to be verified inside list.

  • list_points – List of points to be used.

  • tol – Tolerance to consider if two points are the same.

Returns:

The point index.

volmdlr.core.helper_babylon_data(babylon_data, display_points)[source]#

Helper function to babylon_data.

volmdlr.core.map_primitive_with_initial_and_final_frames(primitive, initial_frame, final_frame)[source]#

Frame maps a primitive in an assembly to its good position.

Parameters:
  • primitive (Primitive3D) – primitive to map

  • initial_frame (volmdlr.Frame3D) – Initial frame

  • final_frame (volmdlr.Frame3D) – The frame resulted after applying a transformation to the initial frame

Returns:

A new positioned primitive

Return type:

Primitive3D

volmdlr.core.point_in_list(point, list_points, tol: float = 1e-06)[source]#

Verifies if a point is inside a list of points, considering a certain tolerance.

Parameters:
  • point – Point to be verified inside list.

  • list_points – List of points to be used.

  • tol – Tolerance to consider if two points are the same.

Returns:

True if there is a point inside the list close to the point to given tolerance.