CAD Deformation¶
Module for generic deformation for CAD file.
- class CADDeformation(u_knots_to_add=0, v_knots_to_add=0, t_knots_to_add=0, tolerance=0.0001)[source]
Bases:
object
Base class for applting deformation to CAD geometries.
- Parameters
u_knots_to_add (int) – the number of knots to add to the NURBS surfaces along u direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.
v_knots_to_add (int) – the number of knots to add to the NURBS surfaces along v direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.
t_knots_to_add (int) – the number of knots to add to the NURBS curves before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.
tolerance (float) – the tolerance involved in several internal operations of the procedure (joining wires in a single curve before deformation and placing new poles on curves and surfaces). Change the default value only if the input file scale is significantly different form mm, making some of the aforementioned operations fail. Default is 0.0001.
- Variables
u_knots_to_add (int) – the number of knots to add to the NURBS surfaces along u direction before the deformation.
v_knots_to_add (int) – the number of knots to add to the NURBS surfaces along v direction before the deformation.
t_knots_to_add (int) – the number of knots to add to the NURBS curves before the deformation.
tolerance (float) – the tolerance involved in several internal operations of the procedure (joining wires in a single curve before deformation and placing new poles on curves and surfaces).
- static read_shape(filename)[source]
Static method to load the topoDS_Shape from a file. Supported extensions are: “.iges”, “.step”.
- Parameters
filename (str) – the name of the file containing the geometry.
Example:
>>> from pygem.cad import CADDeformation as CAD >>> shape = CAD.read_shape('example.iges')
- static write_shape(filename, shape)[source]
Static method to save a topoDS_Shape object to a file. Supported extensions are: “.iges”, “.step”.
- Parameters
filename (str) – the name of the file where the shape will be saved.
Example:
>>> from pygem.cad import CADDeformation as CAD >>> CAD.read_shape('example.step', my_shape)
- _bspline_surface_from_face(face)[source]
Private method that takes a TopoDS_Face and transforms it into a Bspline_Surface.
- Parameters
face (TopoDS_Face) – the TopoDS_Face to be converted
- Return type
Geom_BSplineSurface
- _bspline_curve_from_wire(wire)[source]
Private method that takes a TopoDS_Wire and transforms it into a Bspline_Curve.
- Parameters
wire (TopoDS_Wire) – the TopoDS_Face to be converted
- Return type
Geom_BSplineSurface
- _enrich_curve_knots(bsp_curve)[source]
Private method that adds self.t_knots_to_add poles to the passed curve.
- Parameters
bsp_curve (Geom_BSplineCurve) – the NURBS curve to enrich
- _enrich_surface_knots(bsp_surface)[source]
Private method that adds self.u_knots_to_add and self.v_knots_to_add knots to the input surface bsp_surface, in u and v direction respectively.
- Parameters
bsp_surface (Geom_BSplineCurve) – the NURBS surface to enrich
- _pole_get_components(pole)[source]
Extract component from gp_Pnt
- _pole_set_components(components)[source]
Return a gp_Pnt with the passed components
- _deform_bspline_curve(bsp_curve)[source]
Private method that deforms the control points of bsp_curve using the inherited method. All the changes are performed in place.
- Parameters
bsp_curve (Geom_Bspline_Curve) – the curve to deform
- _deform_bspline_surface(bsp_surface)[source]
Private method that deforms the control points of surface using the inherited method. All the changes are performed in place.
- Parameters
bsp_surface (Geom_Bspline_Surface) – the surface to deform
- __call__(obj, dst=None)[source]
This method performs the deformation on the CAD geometry. If obj is a TopoDS_Shape, the method returns a TopoDS_Shape containing the deformed geometry. If obj is a filename, the method deforms the geometry contained in the file and writes the deformed shape to dst (which has to be set).