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 = '')#

Bases: object

Rounded Line Segments class.

arc_class#

alias of ArcMixin

arc_features(point_index: int)#

Return the arc features for point at index.

frame_mapping(frame: Frame3D, side: str)#

Change frame_mapping and return a new RoundedLineSegments.

side = ‘old’ or ‘new’

get_points(point_index)#

Get points to calculate the arc features.

line_class#

alias of LineSegment

primitives_from_arcs(arcs)#

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 = '')#

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

Return a copy of the object.

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

Bases: LineSegment2D

Measure 2D class.

Parameters:

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

plot(ax=None, edge_style: EdgeStyle | None = None)#

Plot the Measure2D.

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

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 = '')#

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

Return the arc features for point at index.

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

Get Offset new points.

get_offset_normal_vectors(line_indexes)#

Get offset normal vectors.

Parameters:

line_indexes

Returns:

A list of consecutive line indexes.

line_class#

alias of LineSegment2D

offset(offset)#

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

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

OpenedRoundedLineSegments2D rotation.

Parameters:
  • center – rotation center

  • angle – angle rotation

Returns:

a new rotated OpenedRoundedLineSegments2D

translation(offset: Vector2D)#

OpenedRoundedLineSegments2D translation.

Parameters:

offset – translation vector

Returns:

A new translated OpenedRoundedLineSegments2D