Cloud#

Cloud of points classes.

class volmdlr.cloud.PointCloud2D(points, name: str = '')[source]#

Bases: DessiaObject

Point Cloud2D class.

Parameters:

points – list of points for point cloud.

bounding_rectangle()[source]#

Calculates the bounding rectangle for the point cloud.

Returns:

bounds for bounding rectangle.

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

Plot a point cloud 2d using Matplotlib.

simplify(resolution=5)[source]#

Simplify cloud point 2d.

to_coord_matrix() List[List[float]][source]#

Generate an n_points x 2 matrix of coordinates.

to_polygon(convex=False)[source]#

Use a Cloud point 2d to create a polygon.

Parameters:

convex – if True, it will return a convex polygon. If false, it will search for a concave polygon.

Returns:

closed polygon 2d.

class volmdlr.cloud.PointCloud3D(points: List[Point3D], name: str = '')[source]#

Bases: DessiaObject

Point Cloud3D, a list of points.

Parameters:

points – a list of points.

property bounding_box#

Property to get the bounding box of the point cloud.

Returns:

Bounding box object.

static check_area_polygon(initial_polygons2d, position_plane, normal, vec1, vec2)[source]#

Checks and processes area of polygons.

Parameters:
  • initial_polygons2d – List of 2D polygons.

  • position_plane – Position of planes.

  • normal – Normal vector.

  • vec1 – Vector 1.

  • vec2 – Vector 2.

Returns:

List of processed 3D polygons.

determine_extrusion_vector()[source]#

Determines the extrusion vector based on the bounding box.

Returns:

Tuple containing position, normal, vec1, and vec2.

extended_cloud(distance_extended: float)[source]#

Extends cloud.

extract(u, umin, umax)[source]#

Extracts a subset of points within a given range from a plane.

Parameters:
  • u – Normal vector of the plane.

  • umin – Minimum distance to the plane.

  • umax – Maximum distance to the plane.

Returns:

PointCloud3D object containing the extracted points.

classmethod from_step(step_file: str, name: str = '')[source]#

Creates a cloud of points from a step file.

Parameters:
  • step_file – step file.

  • name – object’s name.

Returns:

Point Cloud 3D.

classmethod from_stl(file_path, name: str = 'from_stl')[source]#

Creates a point cloud 3d from a stl file.

Parameters:
  • file_path – path to stl file.

  • name – object’s name.

Returns:

point cloud 3d object.

classmethod generate_shell(polygons_3d: List[ClosedPolygon3D], normal: Vector3D, vec1: Vector3D, vec2: Vector3D, name: str = '')[source]#

Generates a shell from a list of polygon 3d, using a sewing algorithm.

Parameters:
  • polygons_3d – list of polygon 3d to be sewed.

  • normal – normal to the sewing plane.

  • vec1 – u vector in the sewing plane.

  • vec2 – v vector in the sewing plane.

  • name – object’s name.

Returns:

return a shell.

static offset_to_shell(positions_plane: List[Plane3D], polygons2d: List[ClosedPolygon2D], offset: float)[source]#

Offsets a Shell.

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

Plot the cloud 3d.

position_plane(posmax, resolution)[source]#

Calculates the position of planes.

Parameters:
  • posmax – Position index.

  • resolution – Resolution of the plane.

Returns:

Tuple containing distance between planes and position of planes.

shell_distances(shells: OpenTriangleShell3D) Tuple[PointCloud3D, List[float], List[int]][source]#

Computes distance of point to shell for each point in self.points.

Returns:

The point cloud of points projection on nearest triangle, their distances and the corresponding

triangles index :rtype: Tuple[PointCloud3D, List[float], List[int]]

shell_distances_ndarray(shells: OpenTriangleShell3D)[source]#

Computes distance of point to shell for each point in self.points in a numpy formatted data.

Returns:

The point cloud of points projection on nearest triangle, their distances and the corresponding

triangles index :rtype: Tuple[numpy.ndarray(float), numpy.ndarray(float), numpy.ndarray(int)]

to_2d(plane_origin, x, y)[source]#

Projects the point cloud on a 2D plane.

Parameters:
  • plane_origin – Origin of the plane in 3D.

  • x – X-axis vector in 3D.

  • y – Y-axis vector in 3D.

Returns:

PointCloud2D object.

to_coord_matrix() List[List[float]][source]#

Generate an n_points x 3 matrix of coordinates.

to_shell(resolution: int = 10, normal=None, offset: float = 0)[source]#

Creates a Shell from a Cloud of points 3D.

to_subcloud2d(pos_normal, vec1, vec2)[source]#

Converts the point cloud to a simplified 2D sub-cloud.

Parameters:
  • pos_normal – Position and normal vector.

  • vec1 – Vector 1.

  • vec2 – Vector 2.

Returns:

Simplified PointCloud2D object.