Geometry#
Classes for defining hull geometry and vessel structure.
Hull#
- class Hull(file_path)#
A hull geometry loaded from an STL file.
- Parameters:
file_path (str) – Path to the STL file
- static from_box(length, breadth, depth)#
Create a box hull.
- get_bounds()#
Returns the bounding box of the hull.
- thickness: float or None#
The hull plate thickness in meters. If set, it adds volume to the hydrostatic calculations based on the wetted surface area.
- transform(translation, rotation, pivot)#
Applies a transformation to the hull.
- Parameters:
translation – (dx, dy, dz) translation vector
rotation – (rx, ry, rz) rotation angles in degrees
pivot – (px, py, pz) pivot point for rotation
- scale(factor)#
Scales the hull uniformly.
- Parameters:
factor – Scale factor
- scale_xyz(sx, sy, sz)#
Scales the hull non-uniformly along each axis.
- Parameters:
sx – Scale factor along X axis
sy – Scale factor along Y axis
sz – Scale factor along Z axis
- simplify(target_count)#
Simplifies the hull mesh to a target number of triangles (in-place).
- Parameters:
target_count (int) – Target number of triangles
- to_simplified(target_count)#
Returns a simplified copy of the hull.
- export_stl(file_path)#
Exports the hull to an STL file.
- Parameters:
file_path – Output file path
- get_vertices()#
Returns the vertices of the hull mesh.
Vessel#
- class Vessel(hull)#
A vessel containing one or more hulls, tanks, and silhouettes.
- Parameters:
hull (Hull) – The hull geometry
- get_bounds()#
Returns the combined bounding box of all hulls.
- compute_contact_surfaces()#
Pre-compute contact surfaces between all hull pairs.
Uses an adaptive distance threshold based on the average cell size in the overlap zone between each hull pair. This makes the detection scale-independent.
Note: This is automatically called when creating a vessel from multiple hulls via
from_hulls(). Calling it again will refresh the contact surfaces (e.g. after transforming hulls).
- get_contact_surfaces()#
Get all pre-computed contact surfaces.
- Returns:
List of ContactSurface objects
- Return type:
- clear_contact_surfaces()#
Removes all pre-computed contact surfaces.
- get_hull_thickness(index)#
Returns the hull plate thickness for a specific hull by index.
- set_hull_thickness(index, thickness)#
Sets the hull plate thickness for a specific hull by index.
- num_hulls()#
Returns the number of hulls.
- num_tanks()#
Returns the number of tanks.
- get_total_tanks_mass()#
Returns the total mass of all tank fluids in kg.
- get_tanks_center_of_gravity()#
Returns the combined CoG of all tank fluids [x, y, z].
- add_silhouette(silhouette)#
Adds a silhouette profile to the vessel.
- Parameters:
silhouette (Silhouette) – Silhouette to add
- clear_silhouettes()#
Removes all silhouettes from the vessel.
- get_total_emerged_area(waterline_z)#
Returns the total emerged area from all silhouettes (m²).
- get_combined_emerged_centroid(waterline_z)#
Returns the combined centroid of all emerged areas [x, z].
- add_opening(opening)#
Adds a downflooding opening to the vessel.
- Parameters:
opening (DownfloodingOpening) – Opening to add
- clear_openings()#
Removes all downflooding openings from the vessel.
- get_silhouettes()#
Get all silhouettes in the vessel.
- Returns:
List of Silhouette objects
- Return type:
- get_openings()#
Get all downflooding openings in the vessel.
- Returns:
List of DownfloodingOpening objects
- Return type:
- add_appendage(appendage)#
Add an appendage to the vessel.
- Parameters:
appendage (Appendage) – Appendage to add
- clear_appendages()#
Removes all appendages.
- get_total_appendage_wetted_surface()#
Returns the total appendage wetted surface in m².
- Return type:
- add_deck_edge(deck_edge)#
Add a deck edge to the vessel.
- Parameters:
deck_edge (DeckEdge) – Deck edge to add
- clear_deck_edges()#
Removes all deck edges.
- get_min_freeboard(heel, trim, waterline_z)#
Calculate minimum freeboard across all deck edges.
ContactSurface#
- class ContactSurface#
A pre-computed contact surface between two hulls safely ignoring overlap internally.
Pre-computed during vessel construction for multi-hull vessels. Avoids expensive O(N×M) face-to-face contact detection at each hydrostatic/stability calculation.
- get_face_indices_i()#
Returns the face indices of hull i that are in contact.
Silhouette#
- class Silhouette(file_path)#
A 2D silhouette profile in the X-Z plane for wind heeling calculations.
Used for calculating wind heeling moments per IMO 2008 IS Code (MSC.267).
- Parameters:
file_path (str) – Path to the geometry file (DXF, VTK, VTP, CSV, TXT)
- static from_points(points, name)#
Create a silhouette from a list of (x, z) points.
- get_points()#
Returns the points as a list of (x, y, z) tuples.
- get_bounds()#
Returns the bounding box (x_min, x_max, z_min, z_max).
- get_emerged_area(waterline_z)#
Returns the emerged area above waterline (m²).
OpeningType#
DownfloodingOpening#
- class DownfloodingOpening#
A downflooding opening point or contour for θf calculation.
Per IMO 2008 IS Code, used to determine when non-weathertight openings become submerged during heel.
- static from_point(name, position, opening_type)#
Create opening from a single point.
- Parameters:
- Returns:
DownfloodingOpening object
- Return type:
- static from_contour(name, points, opening_type)#
Create opening from a contour (polyline boundary).
- Parameters:
- Returns:
DownfloodingOpening object
- Return type:
- static from_file(file_path, default_type, name=None)#
Load openings from a file (DXF or VTK).
If
nameis provided: - Single opening: sets logic name toname- Multiple openings: sets names to{name}_{i+1}- Parameters:
file_path (str) – Path to the geometry file (DXF, VTK, VTP)
default_type (OpeningType) – Default OpeningType for loaded openings
name (str or None) – Optional base name for loaded openings
- set_active(active)#
Set opening active state.
- Parameters:
active (bool) – True to include in calculations
- get_points()#
Returns points as list of (x, y, z) tuples.
- is_submerged(heel, trim, pivot, waterline_z)#
Check if opening is submerged at given conditions.
Appendage#
- class Appendage#
An appendage (additional volume element) attached to the vessel.
Appendages represent volume contributions from items like keels, rudders, bulbous bows, etc. that are not part of the main hull geometry.
- static from_point(name, center, volume)#
Create an appendage from a point (fixed volume at position).
- static from_file(name, file_path)#
Create an appendage from an STL or VTK file.
- static from_box(name, xmin, xmax, ymin, ymax, zmin, zmax)#
Create an appendage from a box (parallelepiped).
- static from_cube(name, center, volume)#
Create an appendage from a cube (center and volume).
- static from_sphere(name, center, volume)#
Create an appendage from a sphere (center and volume).
- wetted_surface: float or None#
Wetted surface area in m², or None if not set.
- bounds: tuple[float, float, float, float, float, float] or None#
Returns bounds (xmin, xmax, ymin, ymax, zmin, zmax) or None if not applicable (Point).
DeckEdge#
- class DeckEdgeSide#
Side of the deck edge (Port, Starboard, or Both).
- static port()#
Port side.
- static starboard()#
Starboard side.
- static both()#
Both sides (mirrored).
- class DeckEdge#
A deck edge contour (livet) for freeboard calculation.
- static from_points(name, points, side)#
Create a deck edge from a list of 3D points.
- static from_file(name, file_path)#
Load a deck edge from a DXF or VTK file.
- get_points()#
Returns points as list of (x, y, z) tuples.
- get_freeboard(heel, trim, pivot, waterline_z)#
Calculate freeboard at given conditions.