Surfaces¶
design3d module for 3D Surfaces.
- class design3d.surfaces.BSplineSurface3D(degree_u: int, degree_v: int, control_points: List[Point3D], nb_u: int, nb_v: int, u_multiplicities: List[int], v_multiplicities: List[int], u_knots: List[float], v_knots: List[float], weights: List[float] = None, name: str = '')[source]¶
Bases:
Surface3D
A class representing a 3D B-spline surface.
A B-spline surface is a smooth surface defined by a set of control points and a set of basis functions called B-spline basis functions. The shape of the surface is determined by the position of the control points and can be modified by moving the control points.
- Parameters:
degree_u (int) – The degree of the B-spline curve in the u direction.
degree_v (int) – The degree of the B-spline curve in the v direction.
control_points (List[design3d.Point3D]) – A list of 3D control points that define the shape of the surface.
nb_u (int) – The number of control points in the u direction.
nb_v (int) – The number of control points in the v direction.
u_multiplicities (List[int]) – A list of multiplicities for the knots in the u direction. The multiplicity of a knot is the number of times it appears in the knot vector.
v_multiplicities (List[int]) – A list of multiplicities for the knots in the v direction. The multiplicity of a knot is the number of times it appears in the knot vector.
u_knots (List[float]) – A list of knots in the u direction. The knots are real numbers that define the position of the control points along the u direction.
v_knots (List[float]) – A list of knots in the v direction. The knots are real numbers that define the position of the control points along the v direction.
weights (List[float]) – (optional) A list of weights for the control points. The weights can be used to adjust the influence of each control point on the shape of the surface. Default is None.
name (str) – (optional) A name for the surface. Default is an empty string.
- arc2d_parametric_to_dimension(arc2d, grid2d: Grid2D)[source]¶
Convert an arc 2d from the parametric to the dimensioned frame.
- arc2d_with_dimension_to_3d(arc2d)[source]¶
Compute the arc 3d, on a Bspline surface, of an arc 2d in the dimensioned frame.
- arc2d_with_dimension_to_parametric_frame(arc2d)[source]¶
Convert an arc 2d from the dimensioned to the parametric frame.
- arc3d_to_2d(arc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- arc3d_to_2d_with_dimension(arc3d, grid2d: Grid2D)[source]¶
Compute the arc 2d of an arc 3d, on a Bspline surface, in the dimensioned frame.
- arcellipse3d_to_2d(arcellipse3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- blending_matrix_u(u)[source]¶
Compute a matrix of basis_functions in u direction for a vector u like [0,1].
- blending_matrix_v(v)[source]¶
Compute a matrix of basis_functions in v direction for a vector v like [0,1].
- property bounding_box¶
Gets the Bounding box of the BSpline Surface 3d.
- bsplinecurve2d_parametric_to_dimension(bsplinecurve2d, grid2d: Grid2D)[source]¶
Convert a bsplinecurve2d from the parametric to the dimensioned frame.
- bsplinecurve2d_to_3d(bspline_curve2d)[source]¶
Converts the parametric boundary representation into a 3D primitive.
- bsplinecurve2d_with_dimension_to_3d(bsplinecurve2d)[source]¶
Compute the bsplinecurve3d, on a Bspline surface, of a bsplinecurve2d defined in the dimensioned frame.
- bsplinecurve2d_with_dimension_to_parametric_frame(bsplinecurve2d)[source]¶
Convert a bsplinecurve2d from the dimensioned to the parametric frame.
- bsplinecurve3d_to_2d(bspline_curve3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- bsplinecurve3d_to_2d_with_dimension(bsplinecurve3d, grid2d: Grid2D)[source]¶
Compute the bsplinecurve2d of a bsplinecurve3d, on a Bspline surface, in the dimensioned frame.
- static check_convergence(surf_derivatives, distance_vector, tol1: float = 1e-06, tol2: float = 1e-08)[source]¶
Check convergence of point inversion method.
- connect_contours(outer_contour, inner_contours)[source]¶
Create connections between contours on parametric domain.
- Parameters:
outer_contour – Outer contour 2D.
inner_contours (list) – List of 2D contours.
- contour2d_parametric_to_dimension(contour2d: Contour2D, grid2d: Grid2D)[source]¶
Convert a contour 2d from the parametric to the dimensioned frame.
- contour2d_with_dimension_to_3d(contour2d)[source]¶
Compute the contour3d, on a Bspline surface, of a contour2d define in the dimensioned frame.
- contour2d_with_dimension_to_parametric_frame(contour2d)[source]¶
Convert a contour 2d from the dimensioned to the parametric frame.
- contour3d_to_2d_with_dimension(contour3d: Contour3D, grid2d: Grid2D)[source]¶
Compute the Contour 2d of a Contour 3d, on a Bspline surface, in the dimensioned frame.
- property control_points¶
Gets control points.
- control_points_matrix(coordinates)[source]¶
Define control points like a matrix, for each coordinate: x:0, y:1, z:2.
- property control_points_table¶
Creates control points table.
- copy(deep: bool = True, **kwargs)[source]¶
Returns a copy of the instance.
- Parameters:
deep – If False, perform a shallow copy. If True, perform a deep copy.
- ctrlpts2d()[source]¶
Each row represents the control points in u direction and each column the points in v direction.
- property data¶
Returns a dictionary of the BSpline data.
- decompose(return_params: bool = False, decompose_dir='uv')[source]¶
Decomposes the surface into Bezier surface patches of the same degree.
- Parameters:
return_params (bool) – If True, returns the parameters from start and end of each Bézier patch with repect to the input curve.
decompose_dir (str) – Direction of decomposition. ‘uv’, ‘u’ or ‘v’.
- property delta¶
Evaluation delta for both u- and v-directions.
- Getter:
Gets evaluation delta as a tuple of values corresponding to u- and v-directions
- Setter:
Sets evaluation delta for both u- and v-directions
- Type:
float
- property delta_u¶
Evaluation delta for the u-direction.
- Getter:
Gets evaluation delta for the u-direction
- Setter:
Sets evaluation delta for the u-direction
- Type:
float
- property delta_v¶
Evaluation delta for the v-direction.
- Getter:
Gets evaluation delta for the v-direction
- Setter:
Sets evaluation delta for the v-direction
- Type:
float
- derivatives(u, v, order)[source]¶
Evaluates n-th order surface derivatives at the given (u, v) parameter pair.
- Parameters:
u (float) – Point’s u coordinate.
v (float) – Point’s v coordinate.
order (int) – Order of the derivatives.
- Returns:
A list SKL, where SKL[k][l] is the derivative of the surface S(u,v) with respect
to u k times and v l times :rtype: List[design3d.Vector3D]
- property domain¶
Domain.
Domain is determined using the knot vector(s).
- Getter:
Gets the domain
- edge3d_to_2d_with_dimension(edge3d, grid2d: Grid2D)[source]¶
Compute the edge 2d of an edge 3d, on a Bspline surface, in the dimensioned frame.
- error_with_edge3d(edge3d)[source]¶
Compute the error/distance between the Bspline surface and an edge 3d.
it’s the mean of the start and end points errors’
- error_with_point3d(point3d)[source]¶
Compute the error/distance between the Bspline surface and a point 3d.
- property evalpts¶
Evaluated points.
- Getter:
Gets the coordinates of the evaluated points
- Type:
list
- evaluate(**kwargs)[source]¶
Evaluates the surface.
The evaluated points are stored in
evalpts
property.- Keyword Arguments:
start_u
: start parameter on the u-directionstop_u
: stop parameter on the u-directionstart_v
: start parameter on the v-directionstop_v
: stop parameter on the v-direction
The
start_u
,start_v
andstop_u
andstop_v
parameters allow evaluation of a surface segment in the range [start_u, stop_u][start_v, stop_v] i.e. the surface will also be evaluated at thestop_u
andstop_v
parameter values.
- extract_curves(u: List[float] = None, v: List[float] = None)[source]¶
Extracts curves from a surface.
- Parameters:
u – a list of parameters in ascending order in u direction to extract curves
v – a list of parameters in ascending order in v direction to extract curves
- Returns:
a dictionary containing the extracted curves in u and v direction
- Return type:
dict
- face_class = 'BSplineFace3D'¶
- fix_start_end_singularity_point_any_direction(edge3d, points, points3d, tol: float = 1e-06)[source]¶
Helper function.
Uses local discretization and line intersection with the tangent line at the point just before the undefined point on the BREP of the 3D edge to find the real values on parametric domain.
- fix_undefined_brep_with_neighbors(edge, previous_edge, next_edge)[source]¶
Uses neighbors edges to fix edge contained within the periodicity boundary.
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes frame_mapping and return a new BSplineSurface3D.
side = ‘old’ or ‘new’
- classmethod from_cylindrical_face(cylindrical_face, degree_u, degree_v, name: str = '', **kwargs)[source]¶
Define a bspline surface from a cylindrical face.
Parameters¶
- cylindrical_facedesign3d.faces.CylindricalFace3D
face 3d
- degree_uint
degree of the output surface for the u-direction.
- degree_vint
degree of the output surface for the v-direction.
- points_xint
number of points in x-direction
- points_yint
number of points in y-direction
- name: str
object’s name.
Returns¶
B-spline surface
- classmethod from_cylindrical_faces(cylindrical_faces, degree_u, degree_v, points_x: int = 10, points_y: int = 10, name: str = '')[source]¶
Define a bspline surface from a list of cylindrical faces.
Parameters¶
- cylindrical_facesList[design3d.faces.CylindricalFace3D]
faces 3d
- degree_uint
degree of the output surface for the u-direction
- degree_vint
degree of the output surface for the v-direction
- points_xint
number of points in x-direction
- points_yint
number of points in y-direction
- name: str
object’s name.
Returns¶
B-spline surface
- classmethod from_geomdl_surface(surface, name: str = '')[source]¶
Create a design3d BSpline_Surface3D from a geomdl’s one.
- classmethod from_points_approximation(points_3d: List[Point3D], size_u: int, size_v: int, degree_u: int, degree_v: int, name: str = '', **kwargs)[source]¶
Bspline Surface approximate through 3d points.
- Parameters:
points_3d (List[design3d.Point3D]) – data points.
size_u (int) – number of data points on the u-direction.
size_v (int) – number of data points on the v-direction.
degree_u (int) – degree of the output surface for the u-direction.
degree_v (int) – degree of the output surface for the v-direction.
name (str) – (Optional) instance name.
- Keyword Arguments:
ctrlpts_size_u
: number of control points on the u-direction. Default: size_u - 1ctrlpts_size_v
: number of control points on the v-direction. Default: size_v - 1
- Returns:
B-spline surface.
- Return type:
- classmethod from_points_interpolation(points_3d: List[Point3D], size_u: int, size_v: int, degree_u: int, degree_v: int, name: str = '')[source]¶
Bspline Surface interpolation through 3d points.
- Parameters:
points_3d (List[design3d.Point3D]) – data points.
size_u (int) – number of data points on the u-direction.
size_v (int) – number of data points on the v-direction.
degree_u (int) – degree of the output surface for the u-direction.
degree_v (int) – degree of the output surface for the v-direction.
name (str) – (Optional) instance name.
- Returns:
B-spline surface.
- Return type:
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a BSplineSurface3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated.
- Returns:
The corresponding BSplineSurface3D object.
- Return type:
design3d.faces.BSplineSurface3D
- fullarcellipse3d_to_2d(fullarcellipse3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- grid2d_deformation(grid2d: Grid2D)[source]¶
Compute the deformation/displacement (dx/dy) of a Grid2D based on a Bspline surface.
- grid2d_deformed(grid2d: Grid2D)[source]¶
Dimension and deform a Grid2D points based on a Bspline surface.
- intersection_with(other_bspline_surface3d)[source]¶
Compute intersection points between two Bspline surfaces.
return u,v parameters for intersection points for both surfaces
- is_intersected_with(other_bspline_surface3d)[source]¶
Check if the two surfaces are intersected or not.
return True, when there are more 50points on the intersection zone.
- is_singularity_point(point, *args, **kwargs)[source]¶
Returns True if the point belongs to the surface singularity and False otherwise.
- is_undefined_brep(edge)[source]¶
Returns True if the edge is contained within the periodicity boundary.
- property knots_vector_u¶
Compute the global knot vector (u direction) based on knot elements and multiplicities.
- property knots_vector_v¶
Compute the global knot vector (v direction) based on knot elements and multiplicities.
- property knotvector¶
Knot vector in u and v direction respectively.
- linesegment2d_parametric_to_dimension(linesegment2d, grid2d: Grid2D)[source]¶
Convert a linesegment2d from the parametric to the dimensioned frame.
- linesegment2d_to_3d(linesegment2d)[source]¶
Evaluates the Euclidean form for the parametric line segment.
- linesegment2d_with_dimension_to_3d(linesegment2d)[source]¶
Compute the linesegment3d, on a Bspline surface, of a linesegment2d defined in the dimensioned frame.
- linesegment2d_with_dimension_to_parametric_frame(linesegment2d)[source]¶
Convert a linesegment2d from the dimensioned to the parametric frame.
- linesegment3d_to_2d(linesegment3d)[source]¶
A line segment on a BSplineSurface3D will be in any case a line in 2D?.
- linesegment3d_to_2d_with_dimension(linesegment3d, grid2d: Grid2D)[source]¶
Compute the linesegment2d of a linesegment3d, on a Bspline surface, in the dimensioned frame.
- merge_with(other_bspline_surface3d, abs_tol: float = 1e-06)[source]¶
Merges two adjacent surfaces based on their faces.
- Parameters:
other_bspline_surface3d (
design3d.faces.BSplineSurface3D
) – Other adjacent surfaceabs_tol (float.) – tolerance.
- Returns:
Merged surface
- Return type:
design3d.faces.BSplineSurface3D
- nearest_edges3d(contour3d, threshold: float)[source]¶
Compute the nearest edges of a contour 3d to a Bspline_surface3d based on a threshold.
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the BSpline surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the BSpline surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the BSpline surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- plane_intersections(plane3d)[source]¶
Compute intersection points between a Bspline surface and a plane 3d.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), **kwargs)[source]¶
Plot representation of the surface.
- point2d_parametric_to_dimension(point2d: Point3D, grid2d: Grid2D)[source]¶
Convert a point 2d from the parametric to the dimensioned frame.
- point2d_with_dimension_to_3d(point2d, grid2d: Grid2D)[source]¶
Compute the point 3d, on a Bspline surface, of a point 2d define in the dimensioned frame.
- point2d_with_dimension_to_parametric_frame(point2d, grid2d: Grid2D)[source]¶
Convert a point 2d from the dimensioned to the parametric frame.
- point3d_to_2d(point3d: Point3D, tol=1e-06)[source]¶
Evaluates the parametric coordinates (u, v) of a 3D point (x, y, z).
- Parameters:
point3d (
design3d.Point3D
) – A 3D point to be evaluated.tol (float) – Tolerance to accept the results.
- Returns:
The parametric coordinates (u, v) of the point.
- Return type:
design3d.Point2D
- point3d_to_2d_minimize(point3d, initial_guess, point_inversion_result, tol)[source]¶
Auxiliary function for point3d_to_2d in case the point inversion does not converge.
- point3d_to_2d_with_dimension(point3d: Point3D, grid2d: Grid2D)[source]¶
Compute the point2d of a point3d, on a Bspline surface, in the dimensioned frame.
- point_inversion(x, point3d, tol, maxiter: int = 50)[source]¶
Performs point inversion.
Given a point P = (x, y, z) assumed to lie on the NURBS surface S(u, v), point inversion is the problem of finding the corresponding parameters u, v that S(u, v) = P.
- point_inversion_grid_search(point3d, acceptable_distance, max_iter: int = 15)[source]¶
Find the parameters (u, v) of a 3D point on the BSpline surface using a grid search algorithm.
- classmethod points_approximate_into_bspline_surface(points_3d, size_u, size_v, degree_u, degree_v, name: str = '', **kwargs)[source]¶
Bspline Surface approximate through 3d points.
- classmethod points_fitting_into_bspline_surface(points_3d, size_u, size_v, degree_u, degree_v, name: str = '')[source]¶
Bspline Surface interpolation through 3d points.
- rectangular_cut(u1: float, u2: float, v1: float, v2: float, name: str = '')[source]¶
Deprecated method, Use BSplineFace3D from_surface_rectangular_cut method.
- rotation(center: Vector3D, axis: Vector3D, angle: float)[source]¶
BSplineSurface3D rotation.
- Parameters:
center – rotation center
axis – rotation axis
angle – angle rotation
- Returns:
a new rotated BSplineSurface3D
- property sample_size¶
Sample size for both u- and v-directions.
- Getter:
Gets sample size as a tuple of values corresponding to u- and v-directions
- Setter:
Sets sample size for both u- and v-directions
- Type:
int
- property sample_size_u¶
Sample size for the u-direction.
- Getter:
Gets sample size for the u-direction
- Setter:
Sets sample size for the u-direction
- Type:
int
- property sample_size_v¶
Sample size for the v-direction.
- Getter:
Gets sample size for the v-direction
- Setter:
Sets sample size for the v-direction
- Type:
int
- simplify_surface()[source]¶
Verifies if BSplineSurface3D could be a Plane3D.
- Returns:
A planar surface if possible, otherwise, returns self.
- split_surface_u(u: float)[source]¶
Splits the surface at the input parametric coordinate on the u-direction.
- Parameters:
u (float) – Parametric coordinate u chosen between 0 and 1
- Returns:
Two split surfaces
- Return type:
List[
design3d.faces.BSplineSurface3D
]
- split_surface_v(v: float)[source]¶
Splits the surface at the input parametric coordinate on the v-direction.
- Parameters:
v (float) – Parametric coordinate v chosen between 0 and 1
- Returns:
Two split surfaces
- Return type:
List[
design3d.faces.BSplineSurface3D
]
- split_surface_with_bspline_curve(bspline_curve3d: BSplineCurve3D)[source]¶
Cuts the surface into two pieces with a bspline curve.
- Parameters:
bspline_curve3d (
edges.BSplineCurve3D
) – A BSplineCurve3d used for cutting- Returns:
Two split surfaces
- Return type:
List[
design3d.faces.BSplineSurface3D
]
- property surface_curves¶
Extracts curves from a surface.
- translation(offset: Vector3D)[source]¶
BSplineSurface3D translation.
- Parameters:
offset – translation vector
- Returns:
A new translated BSplineSurface3D
- property u_closed¶
Returns True if the surface is close in any of the u boundaries.
- u_closed_lower(tol: float = 1e-06)[source]¶
Returns True if the surface is close in any of the u boundaries.
- u_closed_upper(tol: float = 1e-06)[source]¶
Returns True if the surface is close in any of the u boundaries.
- property u_domain¶
The parametric domain of the surface in the U direction.
- u_iso(u: float) BSplineCurve3D [source]¶
Returns the u-iso curve of the surface.
- Parameters:
u (float) – The value of u where to extract the curve.
- Returns:
A line 3D
- Return type:
curves.Line3D
- property v_closed¶
Returns True if the surface is close in any of the u boundaries.
- v_closed_lower(tol: float = 1e-06)[source]¶
Returns True if the surface is close in any of the u boundaries.
- v_closed_upper(tol: float = 1e-06)[source]¶
Returns True if the surface is close in any of the u boundaries.
- property v_domain¶
The parametric domain of the surface in the V direction.
- v_iso(v: float) BSplineCurve3D [source]¶
Returns the v-iso curve of the surface.
- Parameters:
v – The value of v where to extract the curve.
- Returns:
A BSpline curve 3D
- Return type:
edges.BSplineCurve3D
- vertices()[source]¶
Evaluated points.
- Getter:
Gets the coordinates of the evaluated points
- Type:
list
- property weights¶
Gets the weights of the BSpline surface.
- wire3d_to_2d_with_dimension(wire3d)[source]¶
Compute the 2d of a wire 3d, on a Bspline surface, in the dimensioned frame.
- property x_periodicity¶
Evaluates the periodicity of the surface in u direction.
- property y_periodicity¶
Evaluates the periodicity of the surface in v direction.
- class design3d.surfaces.BezierSurface3D(degree_u: int, degree_v: int, control_points: List[List[Point3D]], nb_u: int, nb_v: int, name='')[source]¶
Bases:
BSplineSurface3D
A 3D Bezier surface.
- Parameters:
degree_u (int) – The degree of the Bezier surface in the u-direction.
degree_v (int) – The degree of the Bezier surface in the v-direction.
control_points (List[List[design3d.Point3D]]) – A list of lists of control points defining the Bezier surface.
nb_u (int) – The number of control points in the u-direction.
nb_v (int) – The number of control points in the v-direction.
name (str) – (Optional) name for the Bezier surface.
- class design3d.surfaces.ConicalSurface3D(frame: Frame3D, semi_angle: float, ref_radius: float = 0.0, name: str = '')[source]¶
Bases:
UPeriodicalSurface
Describes a cone.
A cone is defined by the half-angle, and is positioned in space by a frame and a reference radius. The main axis of the frame is the axis of revolution of the cone. The plane defined by the origin, the x direction and the y direction of the frame is the plane of the cone. The intersection of the cone with this reference plane is a circle of radius equal to the reference radius. The apex of the cone is on the negative side of the main axis of the frame if the half-angle is positive, and on the positive side if the half-angle is negative. This frame is the “local coordinate system” of the cone. The following apply:
Rotation around its main axis, in the trigonometric sense given by the x direction and the y direction, defines the u parametric direction and the x-axis gives the origin for the u parameter. The z axis defines the v parametric direction of the cone and the origin of the frame is the origin of the v parameter. The parametric range of the two parameters is:
[ 0, 2.*Pi ] for u, and
] -infinity, +infinity [ for v
The parametric equation of the cone is: P(u, v) = O + (R + v*tan(ang)) * (cos(u)*x + sin(u)*y) + v*z where:
O, x, y and z are respectively the origin, the x, y and z direction of the cone’s local coordinate system
ang is the half-angle at the apex of the cone
R is the reference radius.
- Parameters:
frame – Cone’s local coordinate system.
semi_angle – half-angle at the apex of the cone.
ref_radius – radius of the circle formed by the intersection of the cone with the reference plane.
- property apex¶
Computes the apex of the cone.
- It is on the negative side of the axis of revolution of this cone if the half-angle at the apex is positive,
and on the positive side of the “main axis” if the half-angle is negative.
- check_primitives_order(contour)[source]¶
If contours passes at the cone singularity this makes sure that the contour is not in an undefined order.
- circle_intersections(circle: Circle3D)[source]¶
Calculates the intersections between a conical surface and a Circle 3D.
- Parameters:
circle – other circle to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- concurrent_plane_intersection(plane3d: Plane3D)[source]¶
Cone plane intersections when plane’s normal is concurrent with the cone’s axis, but not orthogonal.
- Parameters:
plane3d – intersecting plane.
- Returns:
list of intersecting curves.
- conicalsurface_intersections(conical_surface)[source]¶
Conical Surface intersections with another conical surface.
- Parameters:
conical_surface – intersecting conical surface.
- Returns:
list of intersecting curves.
- contour3d_to_2d(contour3d, return_primitives_mapping: bool = False)[source]¶
Transforms a Contour3D into a Contour2D in the parametric domain of the surface.
- Parameters:
contour3d (
wires.Contour3D
) – The contour to be transformed.return_primitives_mapping (bool) – If True, returns a dictionary containing the correspondence between 2D and 3D primitives
- Returns:
A 2D contour object.
- Return type:
wires.Contour2D
- property domain¶
Returns u and v bounds.
- face_class = 'ConicalFace3D'¶
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes frame_mapping and return a new ConicalSurface3D.
- Parameters:
side – ‘old’ or ‘new’
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a ConicalSurface3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated.
- Returns:
The corresponding ConicalSurface3D object.
- Return type:
design3d.faces.ConicalSurface3D
- get_circle_generatrices(number_circles: int, z1, z2)[source]¶
Get circles generatrix of the cone.
- Parameters:
z1 – Initial height of cone.
z2 – Final height of cone.
number_circles – number of expected circles.
- get_generatrices(number_lines: int = 36, z: float = 1)[source]¶
Gets Conical Surface 3D generatrix lines.
- Parameters:
z – cone’s z height.
number_lines – number of generatrix lines.
- Returns:
- static get_singularity_lines()[source]¶
Return lines that are parallel and coincident with surface singularity at parametric domain.
- is_coincident(surface3d, abs_tol: float = 1e-06)[source]¶
Verifies if two conical surfaces are coincident.
- Parameters:
surface3d – other surface 3d.
abs_tol – tolerance.
- Returns:
True if they are coincident, False otherwise.
- is_singularity_point(point, *args, **kwargs)[source]¶
Verifies if point is on the surface singularity.
- line_intersections(line: Line3D)[source]¶
Calculates the intersections between a conical surface and a Line 3D.
- Parameters:
line – other line to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- linesegment3d_to_2d(linesegment3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- normal_at_point(point: Point3D)[source]¶
Gets normal vector at given point on the surface.
- Parameters:
point – point to be verified.
- Returns:
normal
- parallel_conicalsurface_intersections(conical_surface)[source]¶
Get Conical Surface intersections with another conical surface, when their axis are parallel.
- Parameters:
conical_surface – intersecting conical surface.
- Returns:
list of intersecting curves.
- parallel_plane_intersection(plane3d: Plane3D)[source]¶
Conical plane intersections when plane’s normal is perpendicular with the Cone’s axis.
- Parameters:
plane3d – intersecting plane
- Returns:
list of intersecting curves
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the conical surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the conical surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the conical surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- perpendicular_plane_intersection(plane3d)[source]¶
Cone plane intersections when plane’s normal is parallel with the cone axis.
- Parameters:
plane3d – Intersecting plane.
- Returns:
List of intersecting curves.
- plane_intersections(plane3d)[source]¶
Gets the intersections between a plane 3d and a conical surface 3d.
- Parameters:
plane3d – other plane, to verify intersections.
- Returns:
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), **kwargs)[source]¶
Plots the ConicalSurface3D.
- point2d_to_3d(point2d: Point2D)[source]¶
Coverts a parametric coordinate on the surface into a 3D spatial point (x, y, z).
- Parameters:
point2d (design3d.`Point2D) – Point at the ConicalSuface3D
- point3d_to_2d(point3d: Point3D)[source]¶
Returns the cylindrical coordinates design3d.Point2D(theta, z) of a Cartesian coordinates point (x, y, z).
- Parameters:
point3d (
design3d.`Point3D
) – Point at the CylindricalSuface3D.
- rectangular_cut(theta1: float, theta2: float, param_z1: float, param_z2: float, name: str = '')[source]¶
Deprecated method, Use ConicalFace3D from_surface_rectangular_cut method.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
ConicalSurface3D rotation.
- Parameters:
center – rotation center.
axis – rotation axis.
angle – angle rotation.
- Returns:
a new rotated ConicalSurface3D.
- same_apex_conicalsurface_intersections(conical_surface)[source]¶
Gets Conical Surface intersections with another conical surface, sharing the same apex.
- Parameters:
conical_surface – intersecting conical surface.
- Returns:
list of intersecting curves.
- sphericalsurface_intersections(spherical_surface: SphericalSurface3D)[source]¶
Conical Surface intersections with a Spherical surface.
- Parameters:
spherical_surface – intersecting sphere.
- Returns:
list of intersecting curves.
- to_step(current_id)[source]¶
Converts the object to a STEP representation.
- Parameters:
current_id (int) – The ID of the last written primitive.
- Returns:
The STEP representation of the object and the last ID.
- Return type:
tuple[str, list[int]]
- translation(offset: Vector3D)[source]¶
ConicalSurface3D translation.
- Parameters:
offset – translation vector.
- Returns:
A new translated ConicalSurface3D.
- property u_domain¶
The parametric domain of the surface in the U direction.
- u_iso(u: float) Line3D [source]¶
Returns the u-iso curve of the surface.
- Parameters:
u (float) – The value of u where to extract the curve.
- Returns:
A line 3D
- Return type:
curves.Line3D
- property v_domain¶
The parametric domain of the surface in the V direction.
- v_iso(v: float) Circle3D [source]¶
Returns the v-iso curve of the surface.
- Parameters:
v (float) – The value of u where to extract the curve.
- Returns:
A Circle 3D
- Return type:
curves.Circle3D
- x_periodicity = 6.283185307179586¶
- y_periodicity = None¶
- class design3d.surfaces.CylindricalSurface3D(frame, radius: float, name: str = '')[source]¶
Bases:
UPeriodicalSurface
The local plane is defined by (theta, z).
- Parameters:
frame – frame.w is axis, frame.u is theta=0 frame.v theta=pi/2
frame
radius (float) – Cylinder’s radius
- concurrent_plane_intersection(plane3d: Plane3D)[source]¶
Cylindrical plane intersections when plane’s normal is concurrent with the cone’s axis, but not orthogonal.
- Parameters:
plane3d – intersecting plane.
- Returns:
list of intersecting curves.
- conicalsurface_intersections(conical_surface: ConicalSurface3D)[source]¶
Cylinder Surface intersections with a Conical surface.
- Parameters:
conical_surface – intersecting plane.
- Returns:
list of intersecting curves.
- cylindricalsurface_intersections(cylindricalsurface: CylindricalSurface3D)[source]¶
Gets intersections between two cylindrical surfaces 3d.
- Parameters:
cylindricalsurface – other cylindrical surface.
- Returns:
a list containing the resulting intersections, if there are any.
- face_class = 'CylindricalFace3D'¶
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes frame_mapping and return a new CylindricalSurface3D.
- Parameters:
side – ‘old’ or ‘new’
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a CylindricalSurface3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated
- Returns:
The corresponding CylindricalSurface3D object.
- Return type:
design3d.faces.CylindricalSurface3D
- get_circle_generatrices(number_circles: int = 10, length: float = 1.0)[source]¶
Retrieve circles representing the generatrices of a cylinder.
Generates a specified number of circles along the surface of the cylinder, each representing a generatrix.
- Parameters:
number_circles (int) – The number of generatrices to generate. Default is 10
length (float) – The length of the cylinder along the z-direction. Default is 1.
- Returns:
A list of Circle3D instances representing the generatrices of the cylinder.
- Return type:
List[Circle3D]
- get_generatrices(number_lines: int = 30, length: float = 1)[source]¶
Retrieve line segments representing the generatrices of a cylinder.
Generates a specified number of line segments along the surface of the cylinder, each representing a generatrix.
- Parameters:
number_lines (int) – The number of generatrices to generate. Default is 30
length (float) – The length of the cylinder along the z-direction. Default is 1.
- Returns:
A list of LineSegment3D instances representing the generatrices of the cylinder.
- Return type:
List[LineSegment3D]
- grid3d(grid2d: Grid2D)[source]¶
Generate 3d grid points of a Cylindrical surface, based on a Grid2D.
- is_coincident(surface3d, abs_tol: float = 1e-06)[source]¶
Verifies if two CylindricalSurfaces are coincident.
- Parameters:
surface3d – surface to verify.
abs_tol – tolerance.
- Returns:
True if they are coincident, False otherwise.
- line_intersections(line: Line3D)[source]¶
Gets intersections between a line and a Cylindrical Surface 3D.
- normal_at_point(point: Point3D)[source]¶
Gets normal vector at given point on the surface.
- Parameters:
point – point to be verified.
- Returns:
normal
- parallel_plane_intersection(plane3d)[source]¶
Cylinder plane intersections when plane’s normal is perpendicular with the cylinder axis.
- Parameters:
plane3d – intersecting plane
- Returns:
list of intersecting curves
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the cylindrical surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the cylindrical surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the cylindrical surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- perpendicular_plane_intersection(plane3d)[source]¶
Cylinder plane intersections when plane’s normal is parallel with the cylinder axis.
- Parameters:
plane3d – intersecting plane
- Returns:
list of intersecting curves
- plane_intersections(plane3d)[source]¶
Cylinder intersections with a plane.
- Parameters:
plane3d – intersecting plane.
- Returns:
list of intersecting curves.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), length=None, **kwargs)[source]¶
Plot the cylindrical surface in the local frame normal direction.
- Parameters:
ax (Axes3D or None) – Matplotlib Axes3D object to plot on. If None, create a new figure.
edge_style (EdgeStyle.) – edge styles.
length (float) – plotted length
- Returns:
Matplotlib Axes3D object containing the plotted wire-frame.
- Return type:
Axes3D
- point2d_to_3d(point2d: Point2D)[source]¶
Coverts a parametric coordinate on the surface into a 3D spatial point (x, y, z).
- Parameters:
point2d (design3d.`Point2D) – Point at the ToroidalSuface3D
- point3d_to_2d(point3d)[source]¶
Returns the cylindrical coordinates design3d.Point2D(theta, z) of a Cartesian coordinates point (x, y, z).
- Parameters:
point3d (design3d.`Point3D) – Point at the CylindricalSuface3D
- point_belongs(point3d, abs_tol: float = 1e-05)[source]¶
Verifies if a given point is on the CylindricalSurface3D.
- Parameters:
point3d – Point to verify.
abs_tol – Tolerance.
- Returns:
True if point on surface, False otherwise.
- rectangular_cut(theta1: float, theta2: float, param_z1: float, param_z2: float, name: str = '')[source]¶
Deprecated method, Use CylindricalFace3D from_surface_rectangular_cut method.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
CylindricalFace3D rotation.
- Parameters:
center – rotation center.
axis – rotation axis.
angle – angle rotation.
- Returns:
a new rotated Plane3D.
- sphericalsurface_intersections(spherical_surface: SphericalSurface3D)[source]¶
Cylinder Surface intersections with a Spherical surface.
- Parameters:
spherical_surface – intersecting sphere.
- Returns:
list of intersecting curves.
- to_step(current_id)[source]¶
Converts the object to a STEP representation.
- Parameters:
current_id (int) – The ID of the last written primitive.
- Returns:
The STEP representation of the object and the last ID.
- Return type:
tuple[str, list[int]]
- translation(offset: Vector3D)[source]¶
CylindricalFace3D translation.
- Parameters:
offset – translation vector.
- Returns:
A new translated CylindricalFace3D.
- property u_domain¶
The parametric domain of the surface in the U direction.
- u_iso(u: float) Line3D [source]¶
Returns the u-iso curve of the surface.
- Parameters:
u (float) – The value of u where to extract the curve.
- Returns:
A line 3D
- Return type:
curves.Line3D
- property v_domain¶
The parametric domain of the surface in the V direction.
- v_iso(v: float) Circle3D [source]¶
Returns the v-iso curve of the surface.
- Parameters:
v (float) – The value of u where to extract the curve.
- Returns:
A Circle 3D
- Return type:
curves.Circle3D
- x_periodicity = 6.283185307179586¶
- y_periodicity = None¶
- class design3d.surfaces.ExtrusionSurface3D(edge: FullArcEllipse3D | BSplineCurve3D, direction: Vector3D, name: str = '')[source]¶
Bases:
Surface3D
Defines a surface of extrusion.
An extrusion surface is a surface that is a generic cylindrical surface generated by the linear extrusion of a curve, generally an Ellipse or a B-Spline curve.
- Parameters:
edge (Union[
d3dw.Wire3D
,d3dw.Contour3D
]) – edge.axis_point (
design3d.Point3D
) – Axis placementaxis (
design3d.Vector3D
) – Axis of extrusion
- arc3d_to_2d(arc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- arcellipse3d_to_2d(arcellipse3d)[source]¶
Transformation of an arc-ellipse 3d to 2d, in a cylindrical surface.
- bsplinecurve3d_to_2d(bspline_curve3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- face_class = 'ExtrusionFace3D'¶
- frame_mapping(frame: Frame3D, side: str)[source]¶
Returns a new Extrusion Surface positioned in the specified frame.
- Parameters:
frame (design3d.Frame3D) – Frame of reference
side – ‘old’ or ‘new’
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Creates an extrusion surface from step data.
- fullarcellipse3d_to_2d(fullarcellipse3d)[source]¶
Converts a 3D full elliptical arc to a 2D line segment in the current plane.
This method converts a 3D full elliptical arc to a 2D line segment in the current plane. It first calculates the length of the arc using the length method of the fullarcellipse3d object. Then, it converts the start and end points of the arc to 2D points using the point3d_to_2d method. Additionally, it calculates a point on the arc at a small abscissa value (0.01 * length) and converts it to a 2D point. Based on the relative position of this point, the method determines the start and end points of the line segment in 2D. If the abscissa point is closer to the start point, the line segment starts from (0, start.y) and ends at (length, end.y). If the abscissa point is closer to the end point, the line segment starts from (length, start.y) and ends at (0, end.y). If the abscissa point lies exactly at the midpoint of the arc, a NotImplementedError is raised. The resulting line segment is returned as a list.
- Parameters:
fullarcellipse3d – The 3D full elliptical arc object to convert.
- Returns:
A list containing a 2D line segment representing the converted arc.
- Raises:
NotImplementedError: If the abscissa point lies exactly at the midpoint of the arc.
- linesegment2d_to_3d(linesegment2d)[source]¶
Converts a BREP line segment 2D onto a 3D primitive on the surface.
- linesegment3d_to_2d(linesegment3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the extrusion surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the extrusion surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the extrusion surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), z: float = 0.5, **kwargs)[source]¶
Plot for extrusion surface using matplotlib.
- point2d_to_3d(point2d: Point2D)[source]¶
Transform a parametric (u, v) point into a 3D Cartesian point (x, y, z).
# u = [0, 1] and v = z
- point3d_to_2d(point3d)[source]¶
Transform a 3D Cartesian point (x, y, z) into a parametric (u, v) point.
- rectangular_cut(x1: float = 0.0, x2: float = 1.0, y1: float = 0.0, y2: float = 1.0, name: str = '')[source]¶
Deprecated method, Use ExtrusionFace3D from_surface_rectangular_cut method.
- property u_domain¶
The parametric domain of the surface in the U direction.
- u_iso(u: float) Line3D [source]¶
Returns the u-iso curve of the surface.
- Parameters:
u (float) – The value of u where to extract the curve.
- Returns:
A line 3D
- Return type:
curves.Line3D
- property v_domain¶
The parametric domain of the surface in the V direction.
- v_iso(v: float) Curve [source]¶
Returns the v-iso curve of the surface.
- Parameters:
v (float) – The value of u where to extract the curve.
- Returns:
A Curve
- Return type:
curves.Curve
- property x_periodicity¶
Returns the periodicity in x direction.
- y_periodicity = None¶
- class design3d.surfaces.Plane3D(frame: Frame3D, name: str = '')[source]¶
Bases:
Surface3D
Defines a plane 3d.
- Parameters:
frame – u and v of frame describe the plane, w is the normal
- angle_between_planes(plane2)[source]¶
Get angle between 2 planes.
- Parameters:
plane2 – the second plane.
- Returns:
the angle between the two planes.
- bsplinecurve2d_to_3d(bspline_curve2d)[source]¶
Converts a 2D B-Spline in parametric domain into a 3D B-Spline in spatial domain.
- Parameters:
bspline_curve2d (edges.BSplineCurve2D) – The B-Spline curve to perform the transformation.
- Returns:
A 3D B-Spline.
- Return type:
- bsplinecurve3d_to_2d(bspline_curve3d)[source]¶
Converts a 3D B-Spline in spatial domain into a 2D B-Spline in parametric domain.
- Parameters:
bspline_curve3d (edges.BSplineCurve3D) – The B-Spline curve to perform the transformation.
- Returns:
A 2D B-Spline.
- Return type:
- bsplinecurve_intersections(bspline_curve)[source]¶
Calculates the intersections between a Plane 3D and a Bspline Curve 3D.
- Parameters:
bspline_curve – bspline_curve to verify intersections.
- Returns:
list of intersections: List[design3d.Point3D].
- contour2d_to_3d(contour2d, return_primitives_mapping: bool = False)[source]¶
Transforms a Contour2D in the parametric domain of the surface into a Contour3D in Cartesian coordinate.
- Parameters:
contour2d (
wires.Contour2D
) – The contour to be transformed.return_primitives_mapping (bool) – If True, returns a dictionary containing the correspondence between 2D and 3D primitives
- Returns:
A 3D contour object.
- Return type:
wires.Contour3D
- contour3d_to_2d(contour3d, return_primitives_mapping: bool = False)[source]¶
Transforms a Contour3D into a Contour2D in the parametric domain of the surface.
- Parameters:
contour3d (
wires.Contour3D
) – The contour to be transformed.return_primitives_mapping (bool) – If True, returns a dictionary containing the correspondence between 2D and 3D primitives
- Returns:
A 2D contour object.
- Return type:
wires.Contour2D
- cylindricalsurface_intersections(cylindrical_surface: CylindricalSurface3D)[source]¶
Gets intersections between plane and cylindrical surface.
- Parameters:
cylindrical_surface – cylindrical surface to get intersections with.
- Returns:
List containing all intersections between plane and cylindrical surface.
- face_class = 'PlaneFace3D'¶
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes frame_mapping and return a new Frame3D.
- Parameters:
frame (design3d.Frame3D) – Frame of reference
side – ‘old’ or ‘new’
- classmethod from_normal(point, normal, name: str = '')[source]¶
Creates a Plane 3D form a point and a normal vector.
- classmethod from_plane_vectors(plane_origin: Point3D, plane_x: Vector3D, plane_y: Vector3D, name: str = '')[source]¶
Initializes a 3D plane object with a given plane origin and plane x and y vectors.
- Parameters:
plane_origin – A design3d.Point3D representing the origin of the plane.
plane_x – A design3d.Vector3D representing the x-axis of the plane.
plane_y – A design3d.Vector3D representing the y-axis of the plane.
name – object’s name.
- Returns:
A Plane3D object initialized from the provided plane origin and plane x and y vectors.
- classmethod from_points(points, name: str = '')[source]¶
Returns a 3D plane that goes through the 3 first points on the list.
Why for more than 3 points we only do some check and never raise error?
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a Plane3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated
- Returns:
The corresponding Plane3D object.
- Return type:
design3d.faces.Plane3D
- is_coincident(plane2, abs_tol: float = 1e-06)[source]¶
Verifies if two planes are parallel and coincident.
- line_intersections(line)[source]¶
Find the intersection with a line.
- Parameters:
line (
edges.Line
) – Line to evaluate the intersection- Returns:
ADD DESCRIPTION
- Return type:
List[design3d.Point3D]
- linesegment_intersections(linesegment3d: LineSegment3D, abs_tol: float = 1e-06) List[Point3D] [source]¶
Gets the intersections of a plane a line segment 3d.
- Parameters:
linesegment3d – other line segment.
abs_tol – tolerance allowed.
- Returns:
a list with the intersecting point.
- property normal¶
Gets the plane normal vector.
- normal_at_point(point)[source]¶
Gets Normal vector at a given point on the surface.
- Parameters:
point – point on the surface.
- Returns:
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the plane.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the plane.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the plane in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- classmethod plane_between_two_planes(plane1, plane2, name: str = '')[source]¶
Calculates a plane between two other planes.
- Parameters:
plane1 – plane1.
plane2 – plane2.
name – object’s name.
- Returns:
resulting plane.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), length: float = 1.0, **kwargs)[source]¶
Plot the cylindrical surface in the local frame normal direction.
- Parameters:
ax (Axes3D or None) – Matplotlib Axes3D object to plot on. If None, create a new figure.
edge_style (EdgeStyle.) – edge styles.
length (float) – plotted length
- Returns:
Matplotlib Axes3D object containing the plotted wire-frame.
- Return type:
Axes3D
- point_belongs(point3d, abs_tol: float = 1e-06)[source]¶
Return if the point belongs to the plane at a tolerance of 1e-6.
- point_distance(point3d)[source]¶
Calculates the distance of a point to plane.
- Parameters:
point3d – point to verify distance.
- Returns:
a float, point distance to plane.
- rectangular_cut(x1: float, x2: float, y1: float, y2: float, name: str = '')[source]¶
Deprecated method, Use PlaneFace3D from_surface_rectangular_cut method.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
Plane3D rotation.
- Parameters:
center – rotation center
axis – rotation axis
angle – angle rotation
- Returns:
a new rotated Plane3D
- to_step(current_id)[source]¶
Converts the object to a STEP representation.
- Parameters:
current_id (int) – The ID of the last written primitive.
- Returns:
The STEP representation of the object and the last ID.
- Return type:
tuple[str, list[int]]
- translation(offset: Vector3D)[source]¶
Plane3D translation.
- Parameters:
offset – translation vector
- Returns:
A new translated Plane3D
- class design3d.surfaces.RevolutionSurface3D(edge, axis_point: Point3D, axis: Vector3D, name: str = '')[source]¶
Bases:
UPeriodicalSurface
Defines a surface of revolution.
- Parameters:
edge (edges.Edge) – Edge.
axis_point (
design3d.Point3D
) – Axis placementaxis (
design3d.Vector3D
) – Axis of revolution
- arc3d_to_2d(arc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- property domain¶
Returns u and v bounds.
- face_class = 'RevolutionFace3D'¶
- frame_mapping(frame: Frame3D, side: str)[source]¶
Returns a new Revolution Surface positioned in the specified frame.
- Parameters:
frame (design3d.Frame3D) – Frame of reference
side – ‘old’ or ‘new’
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a RevolutionSurface3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated.
- Returns:
The corresponding RevolutionSurface3D object.
- Return type:
design3d.faces.RevolutionSurface3D
- fullarc3d_to_2d(fullarc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- get_singularity_lines()[source]¶
Return lines that are parallel and coincident with surface singularity at parametric domain.
- is_singularity_point(point, *args, **kwargs)[source]¶
Returns True if the point belongs to the surface singularity and False otherwise.
- linesegment2d_to_3d(linesegment2d)[source]¶
Converts a BREP line segment 2D onto a 3D primitive on the surface.
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the revolution surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the revolution surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the revolution surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), number_curves: int = 20, **kwargs)[source]¶
Plot rotated Revolution surface generatrix.
- Parameters:
number_curves (int) – Number of curves to display.
ax – matplotlib axis.
edge_style – plot edge style.
- point2d_to_3d(point2d: Point2D)[source]¶
Transform a parametric (u, v) point into a 3D Cartesian point (x, y, z).
u = [0, 2pi] and v = [0, 1] into a
- point3d_to_2d(point3d)[source]¶
Transform a 3D Cartesian point (x, y, z) into a parametric (u, v) point.
- rectangular_cut(x1: float, x2: float, y1: float, y2: float, name: str = '')[source]¶
Deprecated method, Use RevolutionFace3D from_surface_rectangular_cut method.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
Revolution Surface 3D rotation.
- Parameters:
center – rotation center
axis – rotation axis
angle – angle rotation
- Returns:
a new rotated Revolution Surface 3D
- translation(offset)[source]¶
Returns a new translated Revolution Surface.
- Parameters:
offset – translation vector.
- property u_domain¶
The parametric domain of the surface in the U direction.
- u_iso(u: float) Curve [source]¶
Returns the u-iso curve of the surface.
- Parameters:
u (float) – The value of u where to extract the curve.
- Returns:
A curve
- Return type:
curves.Curve
- property v_domain¶
The parametric domain of the surface in the V direction.
- v_iso(v: float) Circle3D [source]¶
Returns the v-iso curve of the surface.
- Parameters:
v (float) – The value of u where to extract the curve.
- Returns:
A Circle 3D
- Return type:
curves.Circle3D
- x_periodicity = 6.283185307179586¶
- property y_periodicity¶
Evaluates the periodicity of the surface in v direction.
- class design3d.surfaces.RuledSurface3D(wire1: Wire3D, wire2: Wire3D, name: str = '')[source]¶
Bases:
Surface3D
Defines a ruled surface between two wires.
- Parameters:
wire1 (
d3dw.Wire3D
) – Wirewire2 (
wires.Wire3D
) – Wire
- face_class = 'RuledFace3D'¶
- point2d_to_3d(point2d: Point2D)[source]¶
Coverts a parametric coordinate on the surface into a 3D spatial point (x, y, z).
- Parameters:
point2d (design3d.`Point2D) – Point at the ToroidalSuface3D
- class design3d.surfaces.SphericalSurface3D(frame, radius, name='')[source]¶
Bases:
UVPeriodicalSurface
Defines a spherical surface.
- Parameters:
frame (design3d.Frame3D) – Sphere’s frame to position it
radius (float) – Sphere’s radius
- arc3d_to_2d(arc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- arc3d_to_2d_any_direction(arc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- arc3d_to_2d_any_direction_singularity(arc3d, point_singularity, half_pi)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- arc3d_to_2d_with_singularity(arc3d, start, end, singularity_points)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- arc_intersections(arc: Arc3D)[source]¶
Gets intersections between an arc 3D and a SphericalSurface3D.
- Parameters:
arc – other arc to search intersections with.
- Returns:
list containing the intersection points.
- arcellipse_intersections(arcellipse: ArcEllipse3D)[source]¶
Gets intersections between an arcellipse 3D and a SphericalSurface3D.
- Parameters:
arcellipse – other arcellipse to search intersections with.
- Returns:
list containing the intersection points.
- property bounding_box¶
Bounding Box for Spherical Surface 3D.
- bsplinecurve2d_to_3d(bspline_curve2d)[source]¶
Converts a BREP BSpline curve 2D onto a 3D primitive on the surface.
- bsplinecurve3d_to_2d(bspline_curve3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- check_parametric_contour_end(primitives2d, tol)[source]¶
Helper function to repair_primitives_periodicity.
- circle_intersections(circle: Circle3D)[source]¶
Gets intersections between a circle 3D and a SphericalSurface3D.
- Parameters:
circle – other circle to search intersections with.
- Returns:
list containing the intersection points.
- contour2d_to_3d(contour2d, return_primitives_mapping: bool = False)[source]¶
Transforms a Contour2D in the parametric domain of the surface into a Contour3D in Cartesian coordinate.
- Parameters:
contour2d (
wires.Contour2D
) – The contour to be transformed.return_primitives_mapping (bool) – If True, returns a dictionary containing the correspondence between 2D and 3D primitives
- Returns:
A 3D contour object.
- Return type:
wires.Contour3D
- contour3d_to_2d(contour3d, return_primitives_mapping: bool = False)[source]¶
Transforms a Contour3D into a Contour2D in the parametric domain of the surface.
- Parameters:
contour3d (
wires.Contour3D
) – The contour to be transformed.return_primitives_mapping (bool) – If True, returns a dictionary containing the correspondence between 2D and 3D primitives
- Returns:
A 2D contour object.
- Return type:
wires.Contour2D
- property domain¶
Returns u and v bounds.
- property domain_u¶
The parametric domain of the surface in the U direction.
- property domain_v¶
The parametric domain of the surface in the V direction.
- edge_passes_on_singularity_point(edge)[source]¶
Helper function to verify id edge passes on the sphere singularity point.
- ellipse_intersections(ellipse: Ellipse3D)[source]¶
Gets intersections between an ellipse 3D and a SphericalSurface3D.
- Parameters:
ellipse – other ellipse to search intersections with.
- Returns:
list containing the intersection points.
- face_class = 'SphericalFace3D'¶
- find_edge_start_end_undefined_parametric_points(edge3d, points, points3d)[source]¶
Helper function.
Uses local discretization and line intersection with the tangent line at the point just before the undefined point on the BREP of the 3D edge to find the real value of theta on the sphere parametric domain.
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes Spherical Surface 3D’s frame and return a new Spherical Surface 3D.
- Parameters:
frame (design3d.Frame3D) – Frame of reference
side – ‘old’ or ‘new’
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a SphericalSurface3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated.
- Returns:
The corresponding SphericalSurface3D object.
- Return type:
design3d.faces.SphericalSurface3D
- fullarc3d_to_2d(fullarc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- fullarc_intersections(fullarc: Arc3D)[source]¶
Gets intersections between a fullarc 3D and a SphericalSurface3D.
- Parameters:
fullarc – other fullarc to search intersections with.
- Returns:
list containing the intersection points.
- fullarcellipse_intersections(fullarcellipse: FullArcEllipse3D)[source]¶
Gets intersections between a full arcellipse 3D and a SphericalSurface3D.
- Parameters:
fullarcellipse – other full arcellipse to search intersections with.
- Returns:
list containing the intersection points.
- get_circle_at_z(z_position: float)[source]¶
Gets a circle on the sphere at given z position < radius.
- Parameters:
z_position – circle’s z position.
- Returns:
circle 3D at given z position.
- helper_arc3d_to_2d_with_singularity(arc3d, start, end, point_singularity, half_pi)[source]¶
Helper function to arc3d_to_2d_with_singularity.
- is_lat_long_curve(arc)[source]¶
Checks if a curve defined on the sphere is a latitude/longitude curve.
Returns True if it is, False otherwise.
- is_point2d_on_sphere_singularity(point2d, tol=1e-05)[source]¶
Verifies if point is on the spherical singularity point on parametric domain.
- is_point3d_on_sphere_singularity(point3d)[source]¶
Verifies if point is on the spherical singularity point on parametric domain.
- is_singularity_point(point, *args, **kwargs)[source]¶
Verifies if point is on the surface singularity.
- line_intersections(line: Line3D)[source]¶
Calculates the intersection points between a 3D line and a spherical surface.
The method calculates the intersection points between a 3D line and a sphere using the equation of the line and the equation of the sphere. It returns a list of intersection points, which can be empty if there are no intersections. The intersection points are represented as 3D points using the design3d.Point3D class.
- Parameters:
line – The 3D line object to intersect with the sphere.
:type line:curves.Line3D :return: A list of intersection points between the line and the sphere. The list may be empty if there are no intersections. :rtype: List[design3d.Point3D]
- Example:
>>> from design3d import Point3D, edges, surfaces, OXYZ >>> spherical_surface3d = SphericalSurface3D(OXYZ, 1) >>> line2 = curves.Line3D(Point3D(0, 1, -0.5), Point3D(0, 1, 0.5)) >>> line_intersections2 = spherical_surface3d.line_intersections(line2) #returns [Point3D(0.0, 1.0, 0.0)]
- normal_at_point(point: Point3D)[source]¶
Gets normal vector at given point on the surface.
- Parameters:
point – point to be verified.
- Returns:
normal
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the spherical surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the spherical surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the spherical surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- plane_intersections(plane3d)[source]¶
Sphere intersections with a plane.
- Parameters:
plane3d – intersecting plane.
- Returns:
list of intersecting curves.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), **kwargs)[source]¶
Plot sphere arcs.
- point2d_to_3d(point2d)[source]¶
Coverts a parametric coordinate on the surface into a 3D spatial point (x, y, z).
source: https://mathcurve.com/surfaces/sphere # -pi<theta<pi, -pi/2<phi<pi/2
- Parameters:
point2d (design3d.`Point2D) – Point at the CylindricalSuface3D.
- point3d_to_2d(point3d)[source]¶
Transform a 3D spatial point (x, y, z) into a 2D spherical parametric point (theta, phi).
- rectangular_cut(theta1, theta2, phi1, phi2, name='')[source]¶
Deprecated method, Use ShericalFace3D from_surface_rectangular_cut method.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
Spherical Surface 3D rotation.
- Parameters:
center – rotation center
axis – rotation axis
angle – angle rotation
- Returns:
a new rotated Spherical Surface 3D
- sphericalsurface_intersections(spherical_surface: SphericalSurface3D)[source]¶
Cylinder Surface intersections with a Spherical surface.
- Parameters:
spherical_surface – intersecting sphere.
- Returns:
list of intersecting curves.
- to_step(current_id)[source]¶
Converts the object to a STEP representation.
- Parameters:
current_id (int) – The ID of the last written primitive.
- Returns:
The STEP representation of the object and the last ID.
- Return type:
tuple[str, list[int]]
- translation(offset: Vector3D)[source]¶
Spherical Surface 3D translation.
- Parameters:
offset – translation vector
- Returns:
A new translated Spherical Surface 3D
- u_iso(u: float) Circle3D [source]¶
Returns the u-iso curve of the surface.
- Parameters:
u (float) – The value of u where to extract the curve.
- Returns:
A circle 3D
- Return type:
curves.Circle3D
- v_iso(v: float) Circle3D [source]¶
Returns the v-iso curve of the surface.
- Parameters:
v (float) – The value of u where to extract the curve.
- Returns:
A Circle 3D
- Return type:
curves.Circle3D
- x_periodicity = 6.283185307179586¶
- y_periodicity = 3.141592653589793¶
- class design3d.surfaces.Surface2D(outer_contour: Contour2D, inner_contours: List[Contour2D], name: str = 'name')[source]¶
Bases:
DataEqualityObject
A surface bounded by an outer contour.
- bounding_rectangle()[source]¶
Returns bounding rectangle.
- Returns:
Returns a python object with useful methods
- Return type:
:class:`design3d.core.BoundingRectangle
- center_of_mass()[source]¶
Compute the center of mass of the 2D surface.
- Returns:
The center of mass of the surface.
- Return type:
design3d.Point2D
- cut_by_line(line: Line2D)[source]¶
Returns a list of cut Surface2D by the given line.
- Parameters:
line (
curves.Line2D
) – The line to cut the Surface2D with.- Returns:
A list of 2D surfaces resulting from the cut.
- Return type:
List[
design3d.faces.Surface2D
]
- classmethod from_contours(outer_contour, inner_contours)[source]¶
Create a Surface2D object from an outer contour and a list of inner contours.
- Parameters:
outer_contour (wires.Contour2D) – The outer contour that bounds the surface.
inner_contours – The list of inner contours that define the holes of the surface.
:type inner_contours : List[wires.Contour2D] :return: Surface2D defined by the given contours.
- static get_mesh_lines_with_transfinite_curves(lists_contours, min_points, size)[source]¶
Gets Surface 2d mesh lines with transfinite curves.
- line_crossings(line: Line2D)[source]¶
Find intersection points between a line and the 2D surface.
- Parameters:
line (
curves.Line2D
) – The line to intersect with the shape.- Returns:
A list of intersection points sorted by increasing abscissa along the line. Each intersection point is a tuple (point, primitive) where point is the intersection point and primitive is the intersected primitive.
- Return type:
List[Tuple[
design3d.Point2D
,design3d.core.Primitive2D
]]
- mesh_lines(factor: float, curvature_mesh_size: int = None, min_points: int = None, initial_mesh_size: float = 5)[source]¶
Gets the lines that define mesh parameters for a Surface2D, to be added to a .geo file.
- Parameters:
factor – A float, between 0 and 1, that describes the mesh quality
(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional
- Returns:
A list of lines that describe mesh parameters
- Return type:
List[str]
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=False), **kwargs)[source]¶
Plot surface 2d using Matplotlib.
- point_belongs(point2d: Point2D, include_edge_points: bool = True)[source]¶
Check whether a point belongs to the 2D surface.
- Parameters:
point2d (
design3d.Point2D
) – The point to check.- Returns:
True if the point belongs to the surface, False otherwise.
- Return type:
bool
- random_point_inside()[source]¶
Generate a random point inside the 2D surface.
Taking into account any inner contours (holes) it may have.
- Returns:
A random point inside the surface.
- Return type:
design3d.Point2D
- rotation(center, angle)[source]¶
Surface2D rotation.
- Parameters:
center – rotation center.
angle – angle rotation.
- Returns:
a new rotated Surface2D.
- split_by_lines(lines)[source]¶
Returns a list of cut surfaces given by the lines provided as argument.
- to_msh(file_name: str, mesh_dimension: int, mesh_order: int, factor: float, **kwargs)[source]¶
Gets .msh file for the Surface2D generated by gmsh.
- Parameters:
file_name (str) – The msh. file name
mesh_dimension (int) – The mesh dimension (1: 1D-Edge, 2: 2D-Triangle, 3D-Tetrahedra)
factor – A float, between 0 and 1, that describes the mesh quality
(1 for coarse mesh - 0 for fine mesh) :type factor: float :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature (with curvature_mesh_size elements per 2*Pi radians), defaults to 0 :type curvature_mesh_size: int, optional :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points on that edge), defaults to None :type min_points: int, optional :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5 :type initial_mesh_size: float, optional
- Returns:
A txt file
- Return type:
.txt
- translation(offset: Vector2D)[source]¶
Surface2D translation.
- Parameters:
offset – translation vector.
- Returns:
A new translated Surface2D.
- triangulation(number_points_x: int = 15, number_points_y: int = 15)[source]¶
Triangulates the Surface2D using the Triangle library.
- Parameters:
number_points_x (int) – Number of discretization points in x direction.
number_points_y (int) – Number of discretization points in y direction.
- Returns:
The triangulated surface as a display mesh.
- Return type:
- class design3d.surfaces.Surface3D(frame: Frame3D = None, name: str = '')[source]¶
Bases:
DataEqualityObject
Abstract class.
- arc_intersections(arc3d: Arc3D)[source]¶
Calculates the intersections between a conical surface and an arc 3D.
- Parameters:
arc3d – other arc to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- arcellipse_intersections(arcellipse: ArcEllipse3D)[source]¶
Calculates the intersections between a conical surface and an arcellipse 3D.
- Parameters:
arcellipse – other arcellipse to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- brep_connectivity_check(brep: Contour2D, tol: float = 1e-06) bool [source]¶
Checks the topology of 2D BREP in 3D space.
- check_parametric_contour_end(primitives2d, tol)[source]¶
Helper function to repair_primitives_periodicity.
- circle_intersections(circle: Circle3D)[source]¶
Calculates the intersections between a surface 3d and a Circle 3D.
- Parameters:
circle – other circle to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- connect_contours(outer_contour, inner_contours)[source]¶
Abstract method. Repair 2D contours of a face on the parametric domain.
- Parameters:
outer_contour – Outer contour 2D.
inner_contours (list) – List of 2D contours.
- Returns:
NotImplementedError: If the method is not implemented in the subclass.
- contour2d_to_3d(contour2d, return_primitives_mapping: bool = False)[source]¶
Transforms a Contour2D in the parametric domain of the surface into a Contour3D in Cartesian coordinate.
- Parameters:
contour2d (
wires.Contour2D
) – The contour to be transformed.return_primitives_mapping (bool) – If True, returns a dictionary containing the correspondence between 2D and 3D primitives
- Returns:
A 3D contour object.
- Return type:
wires.Contour3D
- contour3d_to_2d(contour3d, return_primitives_mapping: bool = False)[source]¶
Transforms a Contour3D into a Contour2D in the parametric domain of the surface.
- Parameters:
contour3d (
wires.Contour3D
) – The contour to be transformed.return_primitives_mapping (bool) – If True, returns a dictionary containing the correspondence between 2D and 3D primitives
- Returns:
A 2D contour object.
- Return type:
wires.Contour2D
- contour_intersections(contour3d: Contour3D)[source]¶
Gets intersections between a contour 3D and a Surface 3D.
- Parameters:
contour3d – other contour get intersections with.
- Returns:
list of intersecting points.
- curve_intersections(curve)[source]¶
Calculates the intersections between a conical surface and a curve 3D.
- Parameters:
curve – other circle to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- property domain¶
Returns u and v bounds.
- edge_intersections(edge)[source]¶
Gets intersections between a Surface 3D, and an edge 3D.
- Parameters:
edge – any 3D edge.
- Returns:
list of points.
- ellipse_intersections(ellipse: Ellipse3D)[source]¶
Calculates the intersections between a conical surface and an ellipse 3D.
- Parameters:
ellipse – other ellipse to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- face_class = None¶
- face_from_contours3d(contours3d: List[Contour3D], name: str = '')[source]¶
Deprecated method, ‘Use Face3D from_contours3d method’.
- fullarc_intersections(fullarc: FullArc3D)[source]¶
Calculates the intersections between a conical surface and a full arc 3D.
- Parameters:
fullarc – other fullarc to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- fullarcellipse_intersections(fullarcellipse: FullArcEllipse3D)[source]¶
Calculates the intersections between a conical surface and a fullarcellipse 3D.
- Parameters:
fullarcellipse – other fullarcellipse to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- geodesic_distance(point1_3d: Point3D, point2_3d: Point3D)[source]¶
Approximation of geodesic distance between 2 3D points supposed to be on the surface.
- geodesic_distance_from_points2d(point1_2d: Point2D, point2_2d: Point2D, number_points: int = 50)[source]¶
Approximation of geodesic distance via line segments length sum in 3D.
- hyperbola_intersections(hyperbola: Hyperbola3D)[source]¶
Calculates the intersections between a conical surface and a hyperbola 3D.
- Parameters:
hyperbola – other hyperbola to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- is_degenerated_brep(*args)[source]¶
An edge is said to be degenerated when it corresponds to a single 3D point.
- static is_undefined_brep(*args)[source]¶
Verifies if the edge is contained within the periodicity boundary.
- linesegment3d_to_2d(linesegment3d)[source]¶
A line segment on a surface will be in any case a line in 2D?.
- linesegment_intersections(linesegment3d: LineSegment3D, abs_tol: float = 1e-06)[source]¶
Calculates the intersection points between a 3D line segment and a surface 3D.
The method calculates the intersection points between a 3D line segment and a 3d Surface by first finding the intersection points between the infinite line containing the line segment and the Surface, and then filtering out the points that are not within the line segment. It returns a list of intersection points, which can be empty if there are no intersections. The intersection points are represented as 3D points using the design3d.Point3D class. Note: The method assumes that the line segment and the Surface are in the same coordinate system.
- Parameters:
linesegment3d (edges.LineSegment3D.) – The 3D line segment object to intersect with the Surface.
abs_tol (float.) – tolerance.
- Returns:
A list of intersection points between the line segment and the Surface.
The list may be empty if there are no intersections. :rtype: List[design3d.Point3D]:
- normal_from_point2d(point2d)[source]¶
Evaluates the normal vector of the bspline surface at this 2D point.
- normal_from_point3d(point3d)[source]¶
Evaluates the normal vector of the bspline surface at this 3D point.
- parabola_intersections(parabola: Parabola3D)[source]¶
Calculates the intersections between a conical surface and a parabola 3D.
- Parameters:
parabola – other parabola to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), **kwargs)[source]¶
Abstract method.
- point3d_to_2d(point3d)[source]¶
Abstract method. Convert a 3D point to a 2D parametric point.
- Parameters:
point3d (design3d.Point3D) – The 3D point to convert, represented by 3 coordinates (x, y, z).
- Returns:
NotImplementedError: If the method is not implemented in the subclass.
- point_belongs(point3d, abs_tol: float = 1e-06)[source]¶
Verifies if point is on Toroidal Surface 3D.
- Parameters:
point3d – other point.
abs_tol – tolerance.
- Returns:
True or False.
- point_distance(point3d: Point3D)[source]¶
Calculates the minimal distance from a given point and the surface.
- Parameters:
point3d (design3d.Point3D) – point to verify distance.
- Returns:
point distance to the surface.
- Return type:
float
- point_projection(point3d)[source]¶
Returns the projection of the point on the surface.
- Parameters:
point3d (design3d.Point3D) – Point to project.
- Returns:
A point on the surface
- Return type:
design3d.Point3D
- primitives3d_to_2d(primitives3d)[source]¶
Helper function to perform conversion of 3D primitives into B-Rep primitives.
- Parameters:
primitives3d (List[edges.Edge]) – List of 3D primitives from a 3D contour.
- Returns:
A list of 2D primitives on parametric domain.
- Return type:
List[edges.Edge]
- repair_primitives_periodicity(primitives2d, primitives_mapping)[source]¶
Repairs the continuity of the 2D contour while using contour3d_to_2d on periodic surfaces.
- Parameters:
primitives2d (list) – The primitives in parametric surface domain.
primitives_mapping (dict) – It is a dictionary that stores the correspondence between primitives in the parametric domain with their equivalent primitive in 3D space.
- Returns:
A list of primitives.
- Return type:
list
- static repair_reverse(primitives2d, primitives_mapping, i)[source]¶
Helper function to repair_primitives_periodicity.
- static repair_singularity(primitives2d, i, previous_primitive)[source]¶
Helper function to repair_primitives_periodicity.
- static repair_translation(primitives2d, primitives_mapping, i, delta)[source]¶
Helper function to repair_primitives_periodicity.
- surface_intersections(other_surface: Surface3D)[source]¶
Gets intersections between two surfaces.
- Parameters:
other_surface – other surface to get intersections with.
- Returns:
a list containing all intersections between the two surfaces 3d.
- property u_domain¶
The parametric domain of the surface in the U direction.
- static update_primitives_mapping(primitives_mapping, primitives, primitive3d)[source]¶
Helper function to contour3d_to_2d.
- property v_domain¶
The parametric domain of the surface in the V direction.
- x_periodicity = None¶
- y_periodicity = None¶
- class design3d.surfaces.ToroidalSurface3D(frame: Frame3D, major_radius: float, minor_radius: float, name: str = '')[source]¶
Bases:
UVPeriodicalSurface
The local plane is defined by (theta, phi).
Theta is the angle around the big (R) circle and phi around the small (r).
- Parameters:
frame – Tore’s frame: origin is the center, u is pointing at theta=0.
major_radius – Tore’s radius.
r – Circle to revolute radius.
See Also Definitions of R and r according to https://en.wikipedia.org/wiki/Torus.
- arc3d_to_2d(arc3d)[source]¶
Converts the arc from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- property bounding_box¶
Returns the surface bounding box.
- bsplinecurve2d_to_3d(bspline_curve2d)[source]¶
Converts the parametric boundary representation into a 3D primitive.
- bsplinecurve3d_to_2d(bspline_curve3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- circle_intersections(circle: Circle3D)[source]¶
Calculates the intersections between a toroidal surface 3d and a Circle 3D.
- Parameters:
circle – other circle to verify intersections.
- Returns:
a list of intersection points, if there exists any.
- concurrent_plane_intersection(plane3d, number_curves: int = None)[source]¶
Toroidal plane intersections when plane’s normal is concurrent with the cone’s axis, but not orthogonal.
- Parameters:
plane3d – intersecting plane.
number_curves – the number of resulting curves, if known.
- Returns:
list of intersecting curves.
- conicalsurface_intersections(conical_surface: ConicalSurface3D)[source]¶
Gets the intersections between a toroidal surface and cylindrical surface.
- Parameters:
conical_surface – other Conical Surface 3d.
- Returns:
List os curves intersecting Torus.
- cylindricalsurface_intersections(cylindrical_surface: CylindricalSurface3D)[source]¶
Gets the intersections between a toroidal surface and cylindrical surface.
- Parameters:
cylindrical_surface – other cylindrical surface.
- Returns:
List os curves intersecting Torus.
- classmethod dict_to_object(dict_, **kwargs) ToroidalSurface3D [source]¶
Creates a ToroidalSurface3D from a dictionary.
- face_class = 'ToroidalFace3D'¶
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes frame_mapping and return a new ToroidalSurface3D.
- Parameters:
frame (`design3d.Frame3D) – The new frame to map to.
side (str) – Indicates whether the frame should be mapped to the ‘old’ or ‘new’ frame. Acceptable values are ‘old’ or ‘new’.
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a ToroidalSurface3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated.
- Returns:
The corresponding ToroidalSurface3D object.
- Return type:
design3d.faces.ToroidalSurface3D
- fullarc3d_to_2d(fullarc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- get_villarceau_circles(plane3d)[source]¶
The concurrent intersecting plane touches the torus in two isolated points.
- Parameters:
plane3d – concurrent plane.
- Returns:
two circles.
- property inner_radius¶
Get torus inner radius.
- is_coincident(surface3d, abs_tol: float = 1e-06)[source]¶
Verifies if two ToroidalSurfaces are coincident.
- Parameters:
surface3d – surface to verify.
abs_tol – tolerance.
- Returns:
True if they are coincident, False otherwise.
- line_intersections(line: Line3D)[source]¶
Calculates the intersections between the toroidal surface and an infinite line.
- Parameters:
line – other line.
- Returns:
intersections.
- normal_at_point(point: Point3D)[source]¶
Gets normal vector at given point on the surface.
- Parameters:
point – point to be verified.
- Returns:
normal
- property outer_radius¶
Get torus outer radius.
- outer_radius_tangent_inner_radius_toroidalsurface_intersections(toroidal_surface)[source]¶
Calculates the intersections between two toroidal surfaces.
Case where the outer radius of one toroidal surface is touching inner radius of the other toroidal surface.
- Parameters:
toroidal_surface – other toroidal surface.
- Returns:
- parallel_plane_intersection(plane3d: Plane3D)[source]¶
Toroidal plane intersections when plane’s normal is perpendicular with the cylinder axis.
- Parameters:
plane3d – intersecting plane.
- Returns:
list of intersecting curves.
- parametric_points_to_3d(points: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] [source]¶
Transform parametric coordinates to 3D points on the toroidal surface.
Given a set of parametric coordinates (u, v) representing points on the surface, this method returns the corresponding 3D points on the toroidal surface.
- Parameters:
points (numpy.ndarray[np.float64]) – Parametric coordinates in the form of a numpy array with shape (n, 2), where n is the number of points, and each row corresponds to (u, v).
- Returns:
Array of 3D points representing the toroidal surface in Cartesian coordinates.
- Return type:
numpy.ndarray[np.float64]
- perpendicular_plane_intersection(plane3d)[source]¶
Toroidal plane intersections when plane’s normal is parallel with the cylinder axis.
- Parameters:
plane3d – intersecting plane.
- Returns:
list of intersecting curves.
- plane_intersections(plane3d)[source]¶
Toroidal intersections with a plane.
- Parameters:
plane3d – intersecting plane.
- Returns:
list of intersecting curves.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='grey', alpha=0.5, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), **kwargs)[source]¶
Plot torus arcs.
- point2d_to_3d(point2d: Point2D)[source]¶
Coverts a parametric coordinate on the surface into a 3D spatial point (x, y, z).
- Parameters:
point2d (design3d.`Point2D) – Point at the ToroidalSuface3D
- point3d_to_2d(point3d)[source]¶
Transform a 3D spatial point (x, y, z) into a 2D spherical parametric point (theta, phi).
- point_projection(point3d)[source]¶
Returns the projection of the point on the toroidal surface.
- Parameters:
point3d (design3d.Point3D) – Point to project.
- Returns:
A point on the surface
- Return type:
design3d.Point3D
- rectangular_cut(theta1: float, theta2: float, phi1: float, phi2: float, name: str = '')[source]¶
Deprecated method, Use ToroidalFace3D from_surface_rectangular_cut method.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
ToroidalSurface3D rotation.
- Parameters:
center – rotation center.
axis – rotation axis.
angle – angle rotation.
- Returns:
a new rotated ToroidalSurface3D.
- sphericalsurface_intersections(spherical_surface: SphericalSurface3D)[source]¶
Gets the intersections between a toroidal surface and spherical surface.
- Parameters:
spherical_surface – other spherical Surface 3d.
- Returns:
List os curves intersecting Torus.
- to_step(current_id)[source]¶
Converts the object to a STEP representation.
- Parameters:
current_id (int) – The ID of the last written primitive.
- Returns:
The STEP representation of the object and the last ID.
- Return type:
tuple[str, list[int]]
- toroidalsurface_intersections(toroidal_surface)[source]¶
Gets the intersections between two toroidal surface.
- Parameters:
toroidal_surface – other toroidal Surface 3d.
- Returns:
List os curves intersecting Torus.
- toroidalsurface_intersections_profile_profile(toroidal_surface)[source]¶
Get intersections between two parallel toroidal surfaces, if there are any.
- Parameters:
toroidal_surface – other toroidal surface.
- Returns:
- torus_arcs(number_arcs: int = 50)[source]¶
Retrieve torus arcs representing the generatrices of a Torus.
- Parameters:
number_arcs (int) – The number of generatrices to generate. Default is 30
- Returns:
A list of Circle3D instances representing the generatrices of the torus.
- Return type:
List[Circle3D]
- translation(offset: Vector3D)[source]¶
ToroidalSurface3D translation.
- Parameters:
offset – translation vector
- Returns:
A new translated ToroidalSurface3D
- property u_domain¶
The parametric domain of the surface in the U direction.
- u_iso(u: float) Circle3D [source]¶
Returns the u-iso curve of the surface.
- Parameters:
u (float) – The value of u where to extract the curve.
- Returns:
A circle 3D
- Return type:
curves.Circle3D
- property v_domain¶
The parametric domain of the surface in the V direction.
- v_iso(v: float) Circle3D [source]¶
Returns the v-iso curve of the surface.
- Parameters:
v (float) – The value of u where to extract the curve.
- Returns:
A Circle 3D
- Return type:
curves.Circle3D
- x_periodicity = 6.283185307179586¶
- y_periodicity = 6.283185307179586¶
- class design3d.surfaces.UPeriodicalSurface(frame: Frame3D = None, name: str = '')[source]¶
Bases:
Surface3D
Abstract class for surfaces with two-pi periodicity that creates some problems.
- arc3d_to_2d(arc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
The BREP of an arc of circle on a cylindrical or a conical surface is a horizontal line segment.
- arcellipse3d_to_2d(arcellipse3d)[source]¶
Transformation of a 3D arc of ellipse to a 2D primitive in a cylindrical surface.
- bsplinecurve3d_to_2d(bspline_curve3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
- connect_contours(outer_contour, inner_contours)[source]¶
Repair contours on parametric domain.
- Parameters:
outer_contour – Outer contour 2D.
inner_contours (list) – List of 2D contours.
- fix_undefined_brep_with_neighbors(edge, previous_edge, next_edge)[source]¶
Uses neighbors edges to fix edge contained within the periodicity boundary.
- fullarc3d_to_2d(fullarc3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
The BREP of a circle on a cylindrical or a conical surface is a horizontal line segment with length of two pi.
- fullarcellipse3d_to_2d(fullarcellipse3d)[source]¶
Transformation of a 3D arc ellipse to 2D, in a cylindrical surface.
- is_degenerated_brep(*args)[source]¶
An edge is said to be degenerated when it corresponds to a single 3D point.
- static is_undefined_brep(edge)[source]¶
Returns True if the edge is contained within the periodicity boundary.
- linesegment2d_to_3d(linesegment2d)[source]¶
Converts a BREP line segment 2D onto a 3D primitive on the surface.
- linesegment3d_to_2d(linesegment3d)[source]¶
Converts the primitive from 3D spatial coordinates to its equivalent 2D primitive in the parametric space.
For cylindrical or conical surfaces, a line segment in 3D space is typically projected onto the 2D parametric space as a vertical line segment. This is because a 3D line that lies on a cylindrical or conical surface corresponds to a generatrix of the surface, and it extends along the height of the surface without bending or deviating in the other directions. Therefore, the BREP of a line segment on cylindrical or conical surface is a vertical line segment.
- class design3d.surfaces.UVPeriodicalSurface(frame: Frame3D = None, name: str = '')[source]¶
Bases:
UPeriodicalSurface
Abstract class for surfaces with two-pi periodicity in both u and v parametric directions.
- linesegment2d_to_3d(linesegment2d)[source]¶
Converts the parametric boundary representation into a 3D primitive.