Primitives#

Primitives#

Common abstract primitives.

class volmdlr.primitives.RoundedLineSegments(points: List[Point3D], radius: Dict[str, float], closed: bool = False, adapt_radius: bool = False, reference_path: str = '#', name: str = '')[source]#

Bases: object

Rounded Line Segments class.

arc_class#

alias of ArcMixin

arc_features(point_index: int)[source]#

Returns the arc features for point at index.

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

Changes frame_mapping and return a new RoundedLineSegments.

side = ‘old’ or ‘new’

get_points(point_index)[source]#

Gets points to calculate the arc features.

line_class#

alias of LineSegment

primitives_from_arcs(arcs)[source]#

Get Rounded line segment from arcs.

Primitives2d#

Extended primitives 2D classes.

class volmdlr.primitives2d.ClosedRoundedLineSegments2D(points: List[Point2D], radius: Dict[int, float], adapt_radius: bool = False, reference_path: str = '#', name: str = '')[source]#

Bases: RoundedLineSegments2D, Contour2D

Defines a polygon with some rounded corners.

Parameters:
  • points (List of Point2D) – Points used to draw the wire

  • radius ({position1(n): float which is the radius linked the n-1 and n+1 points, position2(n+1):...}) – Radius used to connect different parts of the wire

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

Returns a copy of the object.

class volmdlr.primitives2d.Measure2D(point1, point2, label='', unit: str = 'mm', type_: str = 'distance')[source]#

Bases: LineSegment2D

Measure 2D class.

Parameters:

unit – ‘mm’, ‘m’ or None. If None, the distance won’t be in the label.

plot(ax, edge_style: 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]#

Plots the Measure2D.

class volmdlr.primitives2d.OpenedRoundedLineSegments2D(points: List[Point2D], radius: Dict[int, float], adapt_radius: bool = False, reference_path: str = '#', name: str = '')[source]#

Bases: RoundedLineSegments2D, Wire2D

Opened Rounded LineSegment2D class.

Parameters:
  • points (List of Point2D.) – Points used to draw the wire.

  • radius ({position1(n): float which is the radius linked the n-1 and n+1 points, position2(n+1):...}.) – Radius used to connect different parts of the wire.

class volmdlr.primitives2d.RoundedLineSegments2D(points: List[Point2D], radius: Dict[int, float], adapt_radius: bool = False, reference_path: str = '#', name: str = '')[source]#

Bases: RoundedLineSegments

A class representing a series of rounded line segments in 2D.

This class inherits from the RoundedLineSegments class, and provides methods to work with rounded line segments in 2D.

Parameters:
  • points (List[volmdlr.Point2D]) – The list of points defining the line segments.

  • radius – The dictionary mapping segment indices to their respective radii.

:type radius:Dict[int, float] :param adapt_radius: Flag indicating whether to adapt the radius based on segment length. Defaults to False. :type adapt_radius: bool, optional :param name: The name of the rounded line segments. Defaults to ‘’. :type name: str, optional

arc_class#

alias of Arc2D

arc_features(point_index: int)[source]#

Returns the arc features for point at index.

get_offset_new_points(line_indexes, offset, distance_dir1, distance_dir2, directive_vector1, directive_vector2, normal_vectors)[source]#

Get Offset new points.

get_offset_normal_vectors(line_indexes)[source]#

Gets offset normal vectors.

Parameters:

line_indexes

Returns:

A list of consecutive line indexes.

line_class#

alias of LineSegment2D

offset(offset)[source]#

Return a new rounded line segment with the specified offset.

This method creates a new rounded line segment by offsetting the current one by a given distance. The offset can be both positive and negative, moving the line segments outward or inward.

Parameters:

offset (float) – The offset distance for the new rounded line segment.

Returns:

A new RoundedLineSegments2D instance with the specified offset.

Return type:

RoundedLineSegments2D

offset_lines(line_indexes, offset)[source]#

Line indexes is a list of consecutive line indexes.

These line should all be aligned line_indexes = 0 being the 1st line.

if self.close last line_index can be len(self.points)-1 if not, last line_index can be len(self.points)-2

rotation(center: Point2D, angle: float)[source]#

OpenedRoundedLineSegments2D rotation.

Parameters:
  • center – rotation center

  • angle – angle rotation

Returns:

a new rotated OpenedRoundedLineSegments2D

translation(offset: Vector2D)[source]#

OpenedRoundedLineSegments2D translation.

Parameters:

offset – translation vector

Returns:

A new translated OpenedRoundedLineSegments2D

Primitives3d#

Common primitives 3D.

class volmdlr.primitives3d.BSplineExtrusion(obj, vectorextru: Vector3D, reference_path: str = '#', name: str = '')[source]#

Bases: Primitive3D

Defines the extrusion of a BSpline.

Parameters:

vectorextru – extrusion vector.

classmethod from_step(arguments, object_dict, **kwargs)[source]#

Converts a step primitive to a BSplineExtrusion.

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 BSplineExtrusion object.

Return type:

volmdlr.primitives3d.BSplineExtrusion

class volmdlr.primitives3d.Block(frame: Frame3D, *, color: Tuple[float, float, float] | None = None, alpha: float = 1.0, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Creates a block.

Parameters:

frame – a frame 3D. The origin of the frame is the center of the block, the 3 vectors are defining the edges. The frame has not to be orthogonal

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

Creates a copy of a Block.

cut_by_orthogonal_plane(plane_3d: Plane3D)[source]#

Cuts Block by orthogonal plane, and return a plane face at this plane, bounded by the block volume.

edges()[source]#

Computes the edges of the block.

face_contours3d()[source]#

Get face contours.

faces_center()[source]#

Computes the faces center of the block.

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

Changes frame_mapping and return a new Frame3D.

Parameters:

side – ‘old’ or ‘new’

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

Helper function to frame mapping.

classmethod from_bounding_box(bounding_box: BoundingBox, name: str = '')[source]#

Create a block from a bounding box.

Parameters:
  • bounding_box (BoundingBox) – the bounding box sued to create the block.

  • name (str) – the name of the block, optional.

Returns:

the created block.

Return type:

Block

get_bounding_box() BoundingBox[source]#

Get the bounding box of the block.

Returns:

the created bounding box.

Return type:

BoundingBox

octree()[source]#

Subdivide block into eight other blocks.

plot2d(x3d, y3d, ax=None)[source]#

Plot 2d with Matplotlib.

plot_data(x3d, y3d, edge_style=<class 'plot_data.core.EdgeStyle'>)[source]#

Plot the 2D projections of a block.

quadtree()[source]#

Subdivide block into four other blocks.

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

Block rotation.

Parameters:
  • center – rotation center

  • axis – rotation axis

  • angle – angle rotation

Returns:

a new rotated Block

shell_faces()[source]#

Computes the faces of the block.

subdivide_block(number_blocks_x, number_blocks_y, number_blocks_z)[source]#

Divide block into sub blocks.

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

Custom to_dict for performance.

translation(offset: Vector3D)[source]#

Returns a new translated block.

Parameters:

offset – translation vector.

Returns:

A new translated Block.

vertices()[source]#

Computes the vertices of the block.

volume()[source]#

Returns the volume of the block.

class volmdlr.primitives3d.ClosedRoundedLineSegments3D(points: List[Point3D], radius: float, adapt_radius: bool = False, name: str = '')[source]#

Bases: RoundedLineSegments3D, Contour3D

Defines a closed rounded line segment in 3D.

Parameters:
  • points (List of Point3D) – Points used to draw the wire

  • radius ({position1(n): float which is the radius linked the n-1 and) – Radius used to connect different parts of the wire

n+1 points, position2(n+1):…}

class volmdlr.primitives3d.Cone(frame: Frame3D, radius: float, length: float, color: Tuple[float, float, float] | None = None, alpha: float = 1.0, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Represents a 3D cone defined by its frame, radius, and length.

classmethod from_center_point_and_axis(center_point: Point3D, axis: Vector3D, radius: float, length: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '') Cone[source]#

Create a cone from a center point, an axis, radius, and length.

Parameters:
  • center_point (volmdlr.Point3D) – The center point of the cone (i.e. the middle point of the axis of the cone).

  • axis (volmdlr.Vector3D) – The axis of revolution for the cone.

  • radius (float) – The radius of the cone.

  • length (float) – The length of the cone.

  • color (Tuple[float, float, float], optional) – The color of the cone as an RGB tuple. Default is None.

  • alpha (float, optional) – The opacity of the cone (0.0 to 1.0). Default is 1.0.

  • reference_path (str) – A path corresponding to the “location” of the equivalent python object in the overall structure. “#/path/to/displayed_object”

  • name (str, optional) – The name of the cone. Default is an empty string.

Returns:

A Cone instance created from the specified center point, axis, radius, and length.

Return type:

Cone

get_bounding_box() BoundingBox[source]#

Compute the bounding box of the cone.

A is the point at the basis. B is the top.

Returns:

The BoundingBox of the Cone.

Return type:

volmdlr.core.BoundingBox

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

Cone rotation.

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

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

  • angle (float) – The angle of rotation.

Returns:

A new rotated Cone.

Return type:

Cone

shell_faces()[source]#

Computes the shell faces from init data.

translation(offset: Vector3D) Cone[source]#

Cone translation.

Parameters:

offset (volmdlr.Vector3D) – The translation vector.

Returns:

A new translated Cone.

Return type:

Cone

volume() float[source]#

Compute the volume of the cone.

Returns:

The computed volume of the cone.

Return type:

float

class volmdlr.primitives3d.Cylinder(frame: Frame3D, radius: float, length: float, color: Tuple[float, float, float] | None = None, alpha: float = 1.0, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Represents a 3D cylinder defined by its frame, radius, and length.

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

Creates a copy of Cylinder.

Returns:

A copy of a current Cylinder.

Return type:

Cylinder

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

Changes frame_mapping and return a new Frame3D.

side = ‘old’ or ‘new’

classmethod from_center_point_and_axis(center_point: Point3D, axis: Vector3D, radius: float, length: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '') Cylinder[source]#

Create a cylinder from a center point, an axis, radius, and length.

Parameters:
  • center_point (volmdlr.Point3D) – The center point of the cylinder (i.e. the middle point of the axis of the cylinder).

  • axis (volmdlr.Vector3D) – The axis of revolution for the cylinder.

  • radius (float) – The radius of the cylinder.

  • length (float) – The length of the cylinder.

  • color (Tuple[float, float, float], optional) – The color of the cylinder as an RGB tuple. Default is None.

  • alpha (float, optional) – The opacity of the cylinder (0.0 to 1.0). Default is 1.0.

  • reference_path (str) – A path corresponding to the “location” of the equivalent python object in the overall structure. “#/path/to/displayed_object”

  • name (str, optional) – The name of the cylinder. Default is an empty string.

Returns:

A Cylinder instance created from the specified center point, axis, radius, and length.

Return type:

Cylinder

classmethod from_end_points(point1: Point3D, point2: Point3D, radius: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Create a cylinder from two end points.

Parameters:
  • point1 (volmdlr.Point3D) – The first end point defining the base of the cylinder.

  • point2 (volmdlr.Point3D) – The second end point defining the top of the cylinder.

  • radius (float) – The radius of the cylinder.

  • color (Tuple[float, float, float], optional) – The color of the cylinder as an RGB tuple. Default is None.

  • alpha (float, optional) – The opacity of the cylinder (0.0 to 1.0). Default is 1.0.

  • reference_path (str) – A path corresponding to the “location” of the equivalent python object in the overall structure. “#/path/to/displayed_object”

  • name (str, optional) – The name of the cylinder. Default is an empty string.

Returns:

A Cylinder instance created from the specified end points.

Return type:

Cylinder

classmethod from_extremal_points(point1: Point3D, point2: Point3D, radius: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Deprecated class method. Use ‘from_end_points’ instead.

get_bounding_box() BoundingBox[source]#

Computes the bounding box of a cylinder.

Returns:

The BoundingBox of the Cylinder.

Return type:

volmdlr.core.BoundingBox

interference_volume_with_other_cylinder(other_cylinder: Cylinder, n_points: int = 1000) float[source]#

Estimation of the interpenetration volume using LHS sampling (inspired by Monte-Carlo method).

Parameters:
  • other_cylinder (Cylinder) – The other cylinder to compute the interference volume with.

  • n_points (int) – Optional parameter used for the number of random point used to discretize the cylinder

Returns:

An estimation of the interference volume.

Return type:

float

is_intersecting_other_cylinder(other_cylinder: Cylinder) bool[source]#

Verifies if two cylinders are intersecting or not.

Parameters:

other_cylinder (Cylinder) – The other cylinder to compute if there is an intersection with.

Returns:

True if cylinders are intersecting, False otherwise

Return type:

bool

lhs_points_inside(n_points: int) List[Point3D][source]#

Returns some points inside the cylinder from a LHS samplings.

Parameters:

n_points (int) – The number of points to generate.

Returns:

The Latin Hypercube Sampling points inside the cylinder.

Return type:

list[volmdlr.Point3D]

min_distance_to_other_cylinder(other_cylinder: Cylinder) float[source]#

Compute the minimal distance between two volmdlr cylinders.

Parameters:

other_cylinder (Cylinder) – The other cylinder to compute the distance with.

Returns:

The minimal distance between the two 3D cylinders.

Return type:

float

point_belongs(point3d: Point3D, **kwargs) bool[source]#

Check if the point belongs to the cylinder.

Parameters:

point3d (volmdlr.Point3D) – The point to check if it’s the cylinder.

Returns:

True if the given point is inside the cylinder, False otherwise.

Return type:

bool

random_point_inside() Point3D[source]#

Return a random point inside a cylinder.

Returns:

a random point inside the Cylinder

Return type:

volmdlr.Point3D

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

Cylinder rotation.

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

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

  • angle (float) – The angle of rotation.

Returns:

A new rotated Cylinder.

Return type:

Cylinder

shell_faces()[source]#

Computes the shell faces from init data.

translation(offset: Vector3D) Cylinder[source]#

Cylinder translation.

Parameters:

offset (volmdlr.Vector3D) – The translation vector.

Returns:

A new translated Cylinder.

Return type:

Cylinder

volume() float[source]#

Compute the volume of the cylinder.

Returns:

The computed volume of the Cylinder.

Return type:

float

class volmdlr.primitives3d.ExtrudedProfile(frame: Frame3D, outer_contour2d: Contour2D, inner_contours2d: List[Contour2D], extrusion_length: float, color: Tuple[float, float, float] | None = None, alpha: float = 1.0, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Extrude a profile given by outer and inner contours.

TODO: In the future change to a frame and a surface2D and an extrusion vector.

area()[source]#

Returns the area of the extruded 2D surface.

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

Creates a copy of Extruded Profile.

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

Changes frame_mapping and return a new ExtrudeProfile.

Parameters:

side – = ‘old’ or ‘new’.

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

Extruded Profile rotation.

Parameters:
  • center – rotation center.

  • axis – rotation axis.

  • angle – angle rotation.

Returns:

a new rotated ExtrudedProfile.

shell_faces()[source]#

Computes the shell faces from init data.

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

Serialize the ExtrudedProfile.

translation(offset: Vector3D)[source]#

Extruded Profile translation.

Parameters:

offset – translation vector

Returns:

A new translated ExtrudedProfile

volume()[source]#

Gets the Volume of an extruded profile volume.

Returns:

class volmdlr.primitives3d.HollowCylinder(frame: Frame3D, inner_radius: float, outer_radius: float, length: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Represents a 3D hollow cylinder defined by its frame, radii, and length.

copy(*args, **kwargs) HollowCylinder[source]#

Creates a copy of HollowCylinder.

Returns:

A copy of a current HollowCylinder.

Return type:

HollowCylinder

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

Changes frame_mapping and return a new HollowCylinder.

side = ‘old’ or ‘new’.

classmethod from_center_point_and_axis(center_point: Point3D, axis: Vector3D, inner_radius: float, outer_radius: float, length: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '') HollowCylinder[source]#

Create a hollow cylinder from a center point, an axis, radius, and length.

Parameters:
  • center_point (volmdlr.Point3D) – The center point of the hollow cylinder (i.e. the middle point of the axis of the hollow cylinder).

  • axis (volmdlr.Vector3D) – The axis of revolution for the hollow cylinder.

  • inner_radius (float) – The inner radius of the hollow cylinder.

  • outer_radius (float) – The outer radius of the hollow cylinder.

  • length (float) – The length of the hollow cylinder.

  • color (Tuple[float, float, float], optional) – The color of the hollow cylinder as an RGB tuple. Default is None.

  • alpha (float, optional) – The opacity of the hollow cylinder (0.0 to 1.0). Default is 1.0.

  • reference_path (str) – A path corresponding to the “location” of the equivalent python object in the overall structure. “#/path/to/displayed_object”

  • name (str, optional) – The name of the hollow cylinder. Default is an empty string.

Returns:

A HollowCylinder instance created from the specified center point, axis, radii, and length.

Return type:

HollowCylinder

classmethod from_end_points(point1: Point3D, point2: Point3D, inner_radius: float, outer_radius: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Create a hollow cylinder from two end points.

Parameters:
  • point1 (volmdlr.Point3D) – The first end point defining the base of the hollow cylinder.

  • point2 (volmdlr.Point3D) – The second end point defining the top of the hollow cylinder.

  • inner_radius (float) – The inner radius of the hollow cylinder.

  • outer_radius (float) – The outer radius of the hollow cylinder.

  • color (Tuple[float, float, float], optional) – The color of the hollow cylinder as an RGB tuple. Default is None.

  • alpha (float, optional) – The opacity of the hollow cylinder (0.0 to 1.0). Default is 1.0.

  • reference_path (str) – A path corresponding to the “location” of the equivalent python object in the overall structure. “#/path/to/displayed_object”

  • name (str, optional) – The name of the hollow cylinder. Default is an empty string.

Returns:

A HollowCylinder instance created from the specified end points.

Return type:

HollowCylinder

classmethod from_extremal_points(point1: Point3D, point2: Point3D, inner_radius: float, outer_radius: float, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Deprecated class method. Use ‘from_end_points’ instead.

get_bounding_box() BoundingBox[source]#

Computes the bounding box of a hollow cylinder.

Returns:

The BoundingBox of the HollowCylinder.

Return type:

volmdlr.core.BoundingBox

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

Hollow cylinder rotation.

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

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

  • angle (float) – The angle of rotation.

Returns:

A new rotated HollowCylinder.

Return type:

HollowCylinder

shell_faces()[source]#

Computes the shell faces from init data.

translation(offset: Vector3D) HollowCylinder[source]#

Hollow cylinder translation.

Parameters:

offset (volmdlr.Vector3D) – The translation vector.

Returns:

A new translated HollowCylinder.

Return type:

HollowCylinder

volume() float[source]#

Compute the volume of the hollow cylinder.

Returns:

The computed volume of the Cylinder.

Return type:

float

class volmdlr.primitives3d.Measure3D(point1: Point3D, point2: Point3D, color: Tuple[float, float, float] = (1.0, 0, 0))[source]#

Bases: object

Used to create a measure between two points in 3D.

class volmdlr.primitives3d.OpenRoundedLineSegments3D(points: List[Point3D], radius: Dict[str, float], adapt_radius: bool = False, name: str = '')[source]#

Bases: Wire3D, RoundedLineSegments3D

Defines an open rounded line segments.

Parameters:
  • points (List of Point3D.) – Points used to draw the wire.

  • radius ({position1(n): float which is the radius linked the n-1 and.) – Radius used to connect different parts of the wire.

n+1 points, position2(n+1):…}

class volmdlr.primitives3d.RevolvedProfile(frame: Frame3D, contour2d: Contour2D, axis_point: Point3D, axis: Vector3D, angle: float = 6.283185307179586, *, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Revolve a 2D profile along an axis around a certain angle.

property contour3d#

Gets the positionned contour for revolution.

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

Creates a copy of Revolved-profile.

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

Changes frame_mapping and return a new Revolved Profile.

side = ‘old’ or ‘new’

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

Apply transformation to object’s parameters.

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

Revolved profile rotation.

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

  • axis (volmdlr.Vector3D) – rotation axis

  • angle (float) – angle rotation

Returns:

a new rotated Revolved Profile

Return type:

Revolved Profile

shell_faces()[source]#

Computes the shell faces from init data.

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

Custom to dict for performance.

translation(offset: Vector3D)[source]#

Revolved Profile translation.

Parameters:

offset – translation vector.

Returns:

A new translated Revolved Profile.

volume()[source]#

Volume from Guldin formulae.

class volmdlr.primitives3d.RoundedLineSegments3D(points: List[Point3D], radius: Dict[str, float], adapt_radius: bool = False, name: str = '')[source]#

Bases: RoundedLineSegments

A class representing a series of rounded line segments in 3D.

This class inherits from the RoundedLineSegments class, and provides methods to work with rounded line segments in 3D.

Parameters:
  • points (List[volmdlr.Point3D]) – The list of points defining the line segments.

  • radius – The dictionary mapping segment indices to their respective radii.

:type radius:Dict[int, float] :param adapt_radius: Flag indicating whether to adapt the radius based on segment length. Defaults to False. :type adapt_radius: bool, optional :param name: The name of the rounded line segments. Defaults to ‘’. :type name: str, optional

arc_class#

alias of Arc3D

arc_features(point_index: int)[source]#

Gets arc features.

line_class#

alias of LineSegment3D

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

OpenRoundedLineSegments3D rotation.

Parameters:
  • center – rotation center

  • axis – rotation axis

  • angle – angle rotation

Returns:

a new rotated OpenRoundedLineSegments3D

translation(offset: Vector3D)[source]#

OpenRoundedLineSegments3D translation.

Parameters:

offset – translation vector

Returns:

A new translated OpenRoundedLineSegments3D

class volmdlr.primitives3d.Sphere(center: Point3D, radius: float, color: Tuple[float, float, float] | None = None, alpha: float = 1.0, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Defines a sphere at a given position & radius.

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

Changes frame_mapping and return a new Sphere.

Parameters:

side – ‘old’ or ‘new’

inner_points(resolution: float = 0.001)[source]#

Gives points inside the sphere with a sub-sphere strategy.

point_belongs(point3d: Point3D, **kwargs) bool[source]#

Returns if the point belongs to the sphere.

Parameters:

point3d – volmdlr Point3D

Returns:

True if the given point is inside the sphere, False otherwise

skin_points(resolution: float = 0.001)[source]#

Gives points on the skin with respect to a resolution.

volume()[source]#

Computes the volume of the sphere.

Returns:

sphere’s volume (m³)

class volmdlr.primitives3d.Sweep(contour2d: Contour2D, wire3d: Wire3D, starting_frame=None, *, color: Tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')[source]#

Bases: ClosedShell3D

Sweep a profile along a path.

The resulting shape is defined by a contour in 2D and a path with C1 continuity provided by the 3D wire. The starting frame defines the position and orientation of the profile in the 3D space.

Parameters:
  • contour2d (volmdlr.wires.Contour2D) – The 2D contour, defining the profile to be swept along the wire.

  • wire3d (volmdlr.wires.Wire3D) – The 3D wire path along which the contour is swept. The path must be C1 continuous.

  • starting_frame (volmdlr.Frame3D) – (optional) The starting frame for the sweep. This parameter is used to control the orientation of the profile in 3D space. The frame’s origin should be coincident with the start of the path. If not provided, it is determined from the orientation of the wire and may provide unexpected sweep orientation, if the aspect ratio of the profile is different of 1.

  • color (Tuple[float, float, float]) – (optional) The RGB color of the resulting shell.

  • alpha (float) – (optional) The transparency of the resulting shell.

  • name (str) – The name of the sweep.

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

Creates a copy of the Sweep.

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

Changes frame_mapping and return a new Sweep.

Parameters:
  • frame – Frame to map.

  • side – ‘old’ or ‘new’

shell_faces()[source]#

Generates the shell faces.

For now, it does not take into account rotation of sections.

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

Custom serialization for performance.