shore.shapes
3D body STL builders backed by trimesh.
This module produces trimesh.Trimesh objects (and writes .stl files via the standard mesh.export(path) call). Two families:
Analytic primitives for testing and quick CFD studies: :func:
sphere, :func:cylinder, :func:torus, :func:box, :func:capsule. Thin wrappers overtrimesh.creation.Section extrusion: :func:
extrude_sectiontakes a 2D Selig-ordered profile (e.g. from :mod:shore.profiles) plus span / taper / sweep / twist parameters and produces a wing STL.
For the Selig 2D format that :func:extrude_section consumes, see :mod:shore.profiles.
box function
box(extents: tuple[float, float, float] = (1.0, 1.0, 1.0)) -> trimesh.TrimeshAxis-aligned rectangular box centred at the origin.
Parameters
extents—(dx, dy, dz)total side lengths. All must be positive.
Returns
trimesh.Trimesh— 12-triangle watertight box.
capsule function
capsule(radius: float = 0.5, height: float = 1.0, sections: int = 16) -> trimesh.TrimeshCapsule (cylinder with hemispherical caps), axis along z.
Parameters
radius— Hemispherical cap radius and cylinder radius.height— Length of the cylindrical middle section (caps add2 * radiusto total length).sections— Segments around the circumference; the same value is used for both circumferential and meridional resolution on the caps.
Returns
trimesh.Trimesh— Watertight capsule.
cylinder function
cylinder(
radius: float = 1.0,
height: float = 1.0,
sections: int = 32,
) -> trimesh.TrimeshRight circular cylinder centred at the origin, axis along z.
Parameters
radius— Cylinder radius. Must be positive.height— Total length along the z-axis (the cylinder spans[-height/2, +height/2]).sections— Number of segments around the circumference. Higher = smoother.
Returns
trimesh.Trimesh— Watertight cylinder with circular caps.
extrude_section function
extrude_section(
section_2d: np.ndarray,
*,
span: float,
n_stations: int,
taper: float = 1.0,
sweep_deg: float = 0.0,
twist_deg: float = 0.0,
span_axis: str = 'z',
end_caps: bool = False,
) -> trimesh.TrimeshExtrude a 2D section along a span axis into a 3D wing.
Parameters
section_2d—(N, 2)Selig-ordered closed-or-open section polyline. For closed sections (sharp TE)section_2d[0]andsection_2d[-1]should coincide; for open / blunt TE they differ. No reordering is applied.span— Total wing span (length alongspan_axis). Must be positive.n_stations— Number of span stations including root and tip.>= 2.taper— Tip-to-root chord ratio.1.0(default) = constant chord;0.5= tip chord half the root chord.sweep_deg— Sweep angle of the leading edge, in degrees, about the thickness axis. Positive = sweepback.0.0(default).twist_deg— Geometric twist (washout / washin) at the tip, in degrees, about the LE-thickness axis. Linearly interpolated from0.0at the root. Positive = nose-up.span_axis—"x","y", or"z". Default"z".end_caps— IfTrue, add a centroid-fan cap at each span end so the wing is watertight. DefaultFalse— the SHORE C-grid topology relies on open ends to slice cleanly.
Returns
trimesh.Trimesh— Wing STL.
Raises
ParameterError— On invalid arguments.
sphere function
sphere(radius: float = 1.0, subdivisions: int = 3) -> trimesh.TrimeshIcosahedral sphere centred at the origin.
Parameters
radius— Sphere radius. Must be positive.subdivisions— Icosphere subdivision level.0= 20 triangles (raw icosahedron);3(default) = 1280 triangles; each level quadruples the count.4is dense enough for most CFD wraps.
Returns
trimesh.Trimesh— Watertight icosahedral sphere.
torus function
torus(
r_major: float = 1.0,
r_minor: float = 0.25,
major_sections: int = 32,
minor_sections: int = 32,
) -> trimesh.TrimeshTorus centred at the origin, axis of revolution = z.
Parameters
r_major— Major radius (centre of the tube to centre of the torus).r_minor— Minor radius (tube radius). Must be smaller thanr_majorfor a self-non-intersecting torus.major_sections— Segments around the major circle.minor_sections— Segments around the tube (minor circle).
Returns
trimesh.Trimesh— Watertight ring torus (genus-1 surface).