microgen.shape package
Shape (microgen.shape
)
- class microgen.shape.Box(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), dim_x: float = 1, dim_y: float = 1, dim_z: float = 1)
Bases:
BasicGeometry
Class to generate a box
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(level=0, quads=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- class microgen.shape.Capsule(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), height: float = 1, radius: float = 0.5)
Bases:
BasicGeometry
Class to generate a capsule (cylinder with hemispherical ends)
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(resolution=100, theta_resolution=50, phi_resolution=50, capping=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- class microgen.shape.Cylinder(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), height: float = 1, radius: float = 0.5)
Bases:
BasicGeometry
Class to generate a cylinder
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(resolution=100, capping=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- class microgen.shape.CylindricalTpms(radius: float, surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], offset: float | Callable[[ndarray, ndarray, ndarray], ndarray] = 0.0, phase_shift: Sequence[float] = (0.0, 0.0, 0.0), cell_size: float | Sequence[float] = 1.0, repeat_cell: int | Sequence[int] = 1, center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), resolution: int = 20, density: float | None = None)
Bases:
Tpms
Class used to generate cylindrical TPMS geometries (sheet or skeletals parts).
- class microgen.shape.Ellipsoid(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), a_x: float = 1, a_y: float = 0.5, a_z: float = 0.25)
Bases:
BasicGeometry
Class to generate an ellipsoid
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk() PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- class microgen.shape.ExtrudedPolygon(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), listCorners: Sequence[Tuple[float, float]] = [(1, 0), (0.5, 0.8660254037844386), (-0.5, 0.8660254037844386), (-1, 0), (-0.5, -0.8660254037844386), (0.5, -0.8660254037844386), (1, 0)], height: float = 1)
Bases:
BasicGeometry
Class to generate an extruded polygon with a given list of points and a thickness
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(capping=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- class microgen.shape.Polyhedron(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), dic: Dict[str, list] = {'faces': [{'vertices': [0, 1, 2]}, {'vertices': [0, 3, 1]}, {'vertices': [0, 2, 3]}, {'vertices': [1, 2, 3]}], 'vertices': [(1.0, 1.0, 1.0), (1.0, -1.0, -1.0), (-1.0, 1.0, -1.0), (-1.0, -1.0, 1.0)]})
Bases:
BasicGeometry
Class to generate a Polyhedron with a given set of faces and vertices
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk() PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- class microgen.shape.Sphere(center: Tuple[float, float, float] = (0, 0, 0), radius: float = 1)
Bases:
BasicGeometry
Class to generate a sphere
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(theta_resolution=50, phi_resolution=50) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- class microgen.shape.SphericalTpms(radius: float, surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], offset: float | Callable[[ndarray, ndarray, ndarray], ndarray] = 0.0, phase_shift: Sequence[float] = (0.0, 0.0, 0.0), cell_size: float | Sequence[float] = 1.0, repeat_cell: int | Sequence[int] = 1, center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), resolution: int = 20, density: float | None = None)
Bases:
Tpms
Class used to generate spherical TPMS geometries (sheet or skeletals parts).
- class microgen.shape.Tpms(surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], offset: float | Callable[[ndarray, ndarray, ndarray], ndarray] = 0.0, phase_shift: Sequence[float] = (0.0, 0.0, 0.0), cell_size: float | Sequence[float] = 1.0, repeat_cell: int | Sequence[int] = 1, resolution: int = 20, center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), density: float | None = None)
Bases:
BasicGeometry
Class to generate Triply Periodical Minimal Surfaces (TPMS) geometry from a given mathematical function, with given offset
- functions available :
- generate(type_part: Literal['sheet', 'lower skeletal', 'upper skeletal', 'surface'] = 'sheet', smoothing: int = 0, verbose: bool = True, algo_resolution: int | None = None) Shape
- Parameters:
type_part – part of the TPMS desired (‘sheet’, ‘lower skeletal’, ‘upper skeletal’ or ‘surface’)
smoothing – smoothing loop iterations
verbose – display progressbar of the conversion to CadQuery object
algo_resolution – if offset must be computed to fit density, resolution of the temporary TPMS used to compute the offset
- Returns:
CadQuery Shape object of the required TPMS part
- generateVtk(type_part: Literal['sheet', 'lower skeletal', 'upper skeletal', 'surface'], algo_resolution: int | None = None) PolyData
- Parameters:
type_part – part of the TPMS desireds
algo_resolution – if offset must be computed to fit density, resolution of the temporary TPMS used to compute the offset
- Returns:
VTK PolyData object of the required TPMS part
- property lower_skeletal: PolyData
Returns lower skeletal part
- classmethod offset_from_density(surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], part_type: Literal['sheet', 'lower skeletal', 'upper skeletal'], density: float | Literal['max'] = 'max', resolution: int = 20) float
Returns the offset corresponding to the required density for the specified part of the given surface_function.
- Parameters:
surface_function – tpms function
part_type – type of the part (sheet, lower skeletal or upper skeletal)
density – Required density, 0.5 for 50%
resolution – resolution of the tpms used to compute the offset
- Returns:
corresponding offset value
- property sheet: PolyData
Returns sheet part
- property skeletals: Tuple[PolyData, PolyData]
Returns both skeletal parts
- property surface: PolyData
Returns isosurface f(x, y, z) = 0
- property upper_skeletal: PolyData
Returns upper skeletal part
- vtk_lower_skeletal() PolyData
- vtk_sheet() PolyData
- vtk_upper_skeletal() PolyData
- microgen.shape.newGeometry(shape: str, param_geom: Dict[str, Any], center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0)) BasicGeometry
Creates a new basic geometry with given shape and geometrical parameters
- Parameters:
shape – name of the geometry
param_geom – dictionary with required geometrical parameters
center – center
orientation – orientation
- Return geometry:
BasicGeometry
Basic Geometry (microgen.shape.basicGeometry
)
- class microgen.shape.basicGeometry.BasicGeometry(shape: str, center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0))
Bases:
object
BasicGeometry class to manage shapes
- Parameters:
shape – name of the shape
center – center
orientation – orientation
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk() PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- numInstances = 0
Box (microgen.shape.box
)
- class microgen.shape.box.Box(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), dim_x: float = 1, dim_y: float = 1, dim_z: float = 1)
Bases:
BasicGeometry
Class to generate a box
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(level=0, quads=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
Capsule (microgen.shape.capsule
)
- class microgen.shape.capsule.Capsule(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), height: float = 1, radius: float = 0.5)
Bases:
BasicGeometry
Class to generate a capsule (cylinder with hemispherical ends)
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(resolution=100, theta_resolution=50, phi_resolution=50, capping=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
Cylinder (microgen.shape.cylinder
)
- class microgen.shape.cylinder.Cylinder(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), height: float = 1, radius: float = 0.5)
Bases:
BasicGeometry
Class to generate a cylinder
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(resolution=100, capping=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
Ellipsoid (microgen.shape.ellipsoid
)
- class microgen.shape.ellipsoid.Ellipsoid(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), a_x: float = 1, a_y: float = 0.5, a_z: float = 0.25)
Bases:
BasicGeometry
Class to generate an ellipsoid
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk() PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
Extruded Polygon (microgen.shape.extrudedPolygon
)
- class microgen.shape.extrudedPolygon.ExtrudedPolygon(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), listCorners: Sequence[Tuple[float, float]] = [(1, 0), (0.5, 0.8660254037844386), (-0.5, 0.8660254037844386), (-1, 0), (-0.5, -0.8660254037844386), (0.5, -0.8660254037844386), (1, 0)], height: float = 1)
Bases:
BasicGeometry
Class to generate an extruded polygon with a given list of points and a thickness
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(capping=True) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
Polyhedron (microgen.shape.polyhedron
)
- class microgen.shape.polyhedron.Polyhedron(center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), dic: Dict[str, list] = {'faces': [{'vertices': [0, 1, 2]}, {'vertices': [0, 3, 1]}, {'vertices': [0, 2, 3]}, {'vertices': [1, 2, 3]}], 'vertices': [(1.0, 1.0, 1.0), (1.0, -1.0, -1.0), (-1.0, 1.0, -1.0), (-1.0, -1.0, 1.0)]})
Bases:
BasicGeometry
Class to generate a Polyhedron with a given set of faces and vertices
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk() PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
- microgen.shape.polyhedron.read_obj(filename: str)
Reads vertices and faces from obj format file for polyhedron
Sphere (microgen.shape.sphere
)
- class microgen.shape.sphere.Sphere(center: Tuple[float, float, float] = (0, 0, 0), radius: float = 1)
Bases:
BasicGeometry
Class to generate a sphere
- generate() Shape
Generates the CAD shape
- Returns:
cq.Shape
- generateVtk(theta_resolution=50, phi_resolution=50) PolyData
Generates the vtk mesh of the shape
- Returns:
pv.PolyData
TPMS (microgen.shape.tpms
)
- class microgen.shape.tpms.CylindricalTpms(radius: float, surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], offset: float | Callable[[ndarray, ndarray, ndarray], ndarray] = 0.0, phase_shift: Sequence[float] = (0.0, 0.0, 0.0), cell_size: float | Sequence[float] = 1.0, repeat_cell: int | Sequence[int] = 1, center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), resolution: int = 20, density: float | None = None)
Bases:
Tpms
Class used to generate cylindrical TPMS geometries (sheet or skeletals parts).
- class microgen.shape.tpms.SphericalTpms(radius: float, surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], offset: float | Callable[[ndarray, ndarray, ndarray], ndarray] = 0.0, phase_shift: Sequence[float] = (0.0, 0.0, 0.0), cell_size: float | Sequence[float] = 1.0, repeat_cell: int | Sequence[int] = 1, center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), resolution: int = 20, density: float | None = None)
Bases:
Tpms
Class used to generate spherical TPMS geometries (sheet or skeletals parts).
- class microgen.shape.tpms.Tpms(surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], offset: float | Callable[[ndarray, ndarray, ndarray], ndarray] = 0.0, phase_shift: Sequence[float] = (0.0, 0.0, 0.0), cell_size: float | Sequence[float] = 1.0, repeat_cell: int | Sequence[int] = 1, resolution: int = 20, center: Tuple[float, float, float] = (0, 0, 0), orientation: Tuple[float, float, float] = (0, 0, 0), density: float | None = None)
Bases:
BasicGeometry
Class to generate Triply Periodical Minimal Surfaces (TPMS) geometry from a given mathematical function, with given offset
- functions available :
- generate(type_part: Literal['sheet', 'lower skeletal', 'upper skeletal', 'surface'] = 'sheet', smoothing: int = 0, verbose: bool = True, algo_resolution: int | None = None) Shape
- Parameters:
type_part – part of the TPMS desired (‘sheet’, ‘lower skeletal’, ‘upper skeletal’ or ‘surface’)
smoothing – smoothing loop iterations
verbose – display progressbar of the conversion to CadQuery object
algo_resolution – if offset must be computed to fit density, resolution of the temporary TPMS used to compute the offset
- Returns:
CadQuery Shape object of the required TPMS part
- generateVtk(type_part: Literal['sheet', 'lower skeletal', 'upper skeletal', 'surface'], algo_resolution: int | None = None) PolyData
- Parameters:
type_part – part of the TPMS desireds
algo_resolution – if offset must be computed to fit density, resolution of the temporary TPMS used to compute the offset
- Returns:
VTK PolyData object of the required TPMS part
- property lower_skeletal: PolyData
Returns lower skeletal part
- classmethod offset_from_density(surface_function: Callable[[ndarray, ndarray, ndarray], ndarray], part_type: Literal['sheet', 'lower skeletal', 'upper skeletal'], density: float | Literal['max'] = 'max', resolution: int = 20) float
Returns the offset corresponding to the required density for the specified part of the given surface_function.
- Parameters:
surface_function – tpms function
part_type – type of the part (sheet, lower skeletal or upper skeletal)
density – Required density, 0.5 for 50%
resolution – resolution of the tpms used to compute the offset
- Returns:
corresponding offset value
- property sheet: PolyData
Returns sheet part
- property skeletals: Tuple[PolyData, PolyData]
Returns both skeletal parts
- property surface: PolyData
Returns isosurface f(x, y, z) = 0
- property upper_skeletal: PolyData
Returns upper skeletal part
- vtk_lower_skeletal() PolyData
- vtk_sheet() PolyData
- vtk_upper_skeletal() PolyData
- microgen.shape.surface_functions.fischerKochS(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[cos(2 x) sin(y) cos(z) + cos(x) cos(2 y) sin(z) + sin(x) cos(y) cos(2 z) = 0\]
- microgen.shape.surface_functions.gyroid(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[sin(x) cos(y) + sin(y) cos(z) + sin(z) cos(x) = 0\]
- microgen.shape.surface_functions.honeycomb(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[sin(x) cos(y) + sin(y) + cos(z) = 0\]
- microgen.shape.surface_functions.honeycomb_gyroid(x: float, y: float, z: float) float
- \[sin(x) cos(y) + sin(y) + cos(x) = 0\]
- microgen.shape.surface_functions.honeycomb_lidinoid(x: float, y: float, z: float) float
- \[1.1 (sin(2 x) cos(y) + sin(2 y) sin(x) + cos(x) sin(y)) - (cos(2 x) cos(2 y) + cos(2 y) + cos(2 x)) = 0\]
- microgen.shape.surface_functions.honeycomb_schoenIWP(x: float, y: float, z: float) float
- \[cos(x) cos(y) + cos(y) + cos(x) = 0\]
- microgen.shape.surface_functions.honeycomb_schwarzD(x: float, y: float, z: float) float
- \[cos(x) cos(y) + sin(x) sin(y) + sin(x) cos(y) + cos(x) sin(y) = 0\]
- microgen.shape.surface_functions.honeycomb_schwarzP(x: float, y: float, z: float) float
- \[cos(x) + cos(y) = 0\]
- microgen.shape.surface_functions.lidinoid(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[0.5 (sin(2 x) cos(y) sin(z) + sin(2 y) cos(z) sin(x) + sin(2 z) cos(x) sin(y)) - 0.5 (cos(2 x) cos(2 y) + cos(2 y) cos(2 z) + cos(2 z) cos(2 x)) + 0.3 = 0\]
- microgen.shape.surface_functions.neovius(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[3 cos(x) + cos(y) + cos(z) + 4 cos(x) cos(y) cos(z) = 0\]
- microgen.shape.surface_functions.pmy(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[2 cos(x) cos(y) cos(z) + sin(2 x) sin(y) + sin(x) sin(2 z) + sin(2 y) sin(z) = 0\]
- microgen.shape.surface_functions.schoenFRD(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[4 cos(x) cos(y) cos(z) - (cos(2 x) cos(2 y) + cos(2 y) cos(2 z) + cos(2 z) cos(2 x)) = 0\]
- microgen.shape.surface_functions.schoenIWP(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[2 (cos(x) cos(y) + cos(y) cos(z) + cos(z) cos(x)) - (cos(2 x) + cos(2 y) + cos(2 z)) = 0\]
- microgen.shape.surface_functions.schwarzD(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[sin(x) sin(y) sin(z) + sin(x) cos(y) cos(z) + cos(x) sin(y) cos(z) + cos(x) cos(y) sin(z) = 0\]
- microgen.shape.surface_functions.schwarzP(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[cos(x) + cos(y) + cos(z) = 0\]
- microgen.shape.surface_functions.split_p(x: ndarray, y: ndarray, z: ndarray) ndarray
- \[1.1 (sin(2 x) cos(y) sin(z) + sin(2 y) cos(z) sin(x) + sin(2 z) cos(x) sin(y)) - 0.2 (cos(2 x) cos(2 y) + cos(2 y) cos(2 z) + cos(2 z) cos(2 x)) - 0.4 (cos(2 x) + cos(2 y) + cos(2 z)) = 0\]