Export¶
Cad¶
This module provides functions for exporting CAD data to different formats. It includes functions for exporting to STEP, IGES, and STL formats.
- diffinytrace.export.cad.lens_to_solid(lens, resolution: int, tol: float = 0.001, smoothing=None, minDeg: int = 1, maxDeg: int = 3) Solid[source]¶
Convert a lens object to a CAD solid.
- Parameters:
lens – The lens object to be converted.
resolution (int) – Resolution of the CAD model.
tol (float) – Tolerance for the CAD model.
smoothing – Smoothing parameter for the CAD model.
minDeg (int) – Minimum degree for the B-spline surface.
maxDeg (int) – Maximum degree for the B-spline surface.
- Returns:
The CAD solid representing the lens.
- Return type:
cq.Solid
- diffinytrace.export.cad.extract_knots_and_multiplicities(knots: List[float]) Tuple[List[float], List[int]][source]¶
Extract unique knots and their multiplicities from a knot vector.
- Parameters:
knots (List[float]) – The knot vector with implicit multiplicities.
- Returns:
A list of unique knots. multiplicities (List[int]): A list of multiplicities corresponding to the unique knots.
- Return type:
unique_knots (List[float])
- diffinytrace.export.cad.makeNurbsFace(control_points, weights, U1, U2, u_degree: int, v_degree: int, u_periodic: bool = False, v_periodic: bool = False) Face[source]¶
Create a B-spline surface from control points, weights, and implicit knot vectors.
- Parameters:
control_points (list) – 2D list of control points as Vectors.
weights (list) – 2D list of weights for each control point.
U1 (list) – Knot vector in U direction with implicit multiplicities.
U2 (list) – Knot vector in V direction with implicit multiplicities.
u_degree (int) – Degree of the B-spline in the U direction.
v_degree (int) – Degree of the B-spline in the V direction.
u_periodic (bool) – If True, makes the surface periodic in the U direction.
v_periodic (bool) – If True, makes the surface periodic in the V direction.
- Returns:
Face instance representing the B-spline surface.
- Return type:
cq.Face
- diffinytrace.export.cad.makeBsplineFace(control_points, U1, U2, u_degree: int, v_degree: int, u_periodic: bool = False, v_periodic: bool = False) Face[source]¶
Create a non-rational B-spline surface face from control points and knot vectors.
- Parameters:
control_points (np.ndarray) – 2D array of control points (shape: [num_u, num_v, 3]).
U1 (list) – Knot vector in U direction with implicit multiplicities.
U2 (list) – Knot vector in V direction with implicit multiplicities.
u_degree (int) – Degree of the B-spline in the U direction.
v_degree (int) – Degree of the B-spline in the V direction.
u_periodic (bool, optional) – If True, makes the surface periodic in the U direction. Defaults to False.
v_periodic (bool, optional) – If True, makes the surface periodic in the V direction. Defaults to False.
- Returns:
Face instance representing the B-spline surface.
- Return type:
cq.Face
- diffinytrace.export.cad.export_lens(file_path: str, lens, resolution: int, tol: float = 0.001)[source]¶
Export a lens to a CAD file.
- Parameters:
file_path (str) – The path to save the CAD file.
lens – The lens object to be exported.
resolution (int) – Resolution of the CAD model.
tol (float) – Tolerance for the CAD model.