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

get_bounds()#

Returns the bounding box of the hull.

Returns:

(xmin, xmax, ymin, ymax, zmin, zmax)

Return type:

tuple[float, float, float, float, float, float]

num_triangles()#

Returns the number of triangles in the mesh.

Return type:

int

num_vertices()#

Returns the number of vertices in the mesh.

Return type:

int

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

export_stl(file_path)#

Exports the hull to an STL file.

Parameters:

file_path – Output file path

Vessel#

class Vessel(hull)#

A vessel containing one or more hulls, tanks, and silhouettes.

Parameters:

hull (Hull) – The hull geometry

ap: float#

Aft Perpendicular position (x-coordinate).

fp: float#

Forward Perpendicular position (x-coordinate).

lbp: float#

Length Between Perpendiculars.

get_bounds()#

Returns the combined bounding box of all hulls.

num_hulls()#

Returns the number of hulls.

num_tanks()#

Returns the number of tanks.

add_tank(tank)#

Adds a tank to the vessel.

Parameters:

tank (Tank) – Tank to add

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

num_silhouettes()#

Returns the number of silhouettes.

Return type:

int

has_silhouettes()#

Returns True if any silhouettes are defined.

Return type:

bool

clear_silhouettes()#

Removes all silhouettes from the vessel.

get_total_emerged_area(waterline_z)#

Returns the total emerged area from all silhouettes (m²).

Parameters:

waterline_z (float) – Waterline Z coordinate

Return type:

float

get_combined_emerged_centroid(waterline_z)#

Returns the combined centroid of all emerged areas [x, z].

Parameters:

waterline_z (float) – Waterline Z coordinate

Return type:

list[float]

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 a DXF file

static from_vtk(file_path)#

Load a silhouette from a VTK file (.vtk or .vtp polyline).

Parameters:

file_path (str) – Path to the VTK file

Returns:

Silhouette object

Return type:

Silhouette

static from_points(points, name)#

Create a silhouette from a list of (x, z) points.

Parameters:
  • points (list[tuple[float, float]]) – List of (x, z) tuples defining the contour

  • name (str) – Silhouette name

Returns:

Silhouette object

Return type:

Silhouette

name: str#

Silhouette name (from filename or user-defined).

num_points()#

Returns the number of points in the contour.

Return type:

int

is_closed()#

Returns True if the contour is closed (first == last point).

Return type:

bool

get_points()#

Returns the points as a list of (x, y, z) tuples.

Return type:

list[tuple[float, float, float]]

get_area()#

Returns the total lateral area (m²).

Return type:

float

get_centroid()#

Returns the centroid [x, z].

Return type:

list[float]

get_bounds()#

Returns the bounding box (x_min, x_max, z_min, z_max).

Return type:

tuple[float, float, float, float]

get_emerged_area(waterline_z)#

Returns the emerged area above waterline (m²).

Parameters:

waterline_z (float) – Waterline Z coordinate

Return type:

float

get_emerged_centroid(waterline_z)#

Returns the centroid of the emerged area [x, z].

Parameters:

waterline_z (float) – Waterline Z coordinate

Return type:

list[float]

OpeningType#

class OpeningType#

Type of opening that can cause downflooding.

static vent()#

Ventilator opening.

static air_pipe()#

Air pipe without automatic closing device.

static hatch()#

Hatch or manhole.

static door()#

Weathertight door (kept open for operation).

static window()#

Non-weathertight window.

static other(name)#

Custom opening type.

Parameters:

name (str) – Opening type name

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:

DownfloodingOpening

static from_contour(name, points, opening_type)#

Create opening from a contour (polyline boundary).

Parameters:
Returns:

DownfloodingOpening object

Return type:

DownfloodingOpening

name: str#

Opening name.

is_active: bool#

Whether opening is active in calculations.

set_active(active)#

Set opening active state.

Parameters:

active (bool) – True to include in calculations

num_points()#

Returns the number of points defining the opening.

Return type:

int

get_points()#

Returns points as list of (x, y, z) tuples.

Return type:

list[tuple[float, float, float]]

is_submerged(heel, trim, pivot, waterline_z)#

Check if opening is submerged at given conditions.

Parameters:
  • heel (float) – Heel angle in degrees

  • trim (float) – Trim angle in degrees

  • pivot (tuple[float, float, float]) – Rotation pivot (x, y, z)

  • waterline_z (float) – Waterline Z coordinate

Return type:

bool