Cloud#
Cloud of points classes.
- class volmdlr.cloud.PointCloud2D(points, name: str = '')#
Bases:
DessiaObjectPoint Cloud2D class.
- Parameters:
points – list of points for point cloud.
- bounding_rectangle()#
Calculate the bounding rectangle for the point cloud.
- Returns:
bounds for bounding rectangle.
- plot(ax=None, color='k')#
Plot a point cloud 2d using Matplotlib.
- simplify(resolution=5)#
Simplify cloud point 2d.
- to_coord_matrix() list[list[float]]#
Generate an n_points x 2 matrix of coordinates.
- to_polygon(convex=False)#
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 = '')#
Bases:
DessiaObjectPoint 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)#
Check 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()#
Determine the extrusion vector based on the bounding box.
- Returns:
Tuple containing position, normal, vec1, and vec2.
- extended_cloud(distance_extended: float)#
Extend cloud of point by a given distance.
- Parameters:
distance_extended – distance to extend cloud by.
- Returns:
extended points.
- extract(u, umin, umax)#
Extract 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 = '')#
Create 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')#
Create 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 = '')#
Generate 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)#
Add offset to a shell.
- plot(ax=None, color='k')#
Plot the cloud 3d.
- position_plane(posmax, resolution)#
Calculate 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]]#
Compute 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)#
Compute 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)#
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]]#
Generate an n_points x 3 matrix of coordinates.
- to_shell(resolution: int = 10, normal=None, offset: float = 0)#
Create a Shell from a Cloud of points 3D.
- to_subcloud2d(pos_normal, vec1, vec2)#
Convert 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.