rsqsim_api.io.tsurf

Reader and writer for GOCAD TSurf triangulated surface files.

Classes

tsurf

Read, create, and write GOCAD TSurf triangulated surface files.

Module Contents

class rsqsim_api.io.tsurf.tsurf(*args, **kwargs)[source]

Bases: object

Read, create, and write GOCAD TSurf triangulated surface files.

Supports construction from a .ts file path or from raw coordinate and connectivity arrays. Provides access to the triangulated mesh via the triangles property and can export back to the GOCAD TSurf format.

Parameters:
  • *args – Either a single filename string (reads from file), or four positional arguments x, y, z, cells (constructs from arrays).

  • solid_color (tuple of float, optional) – RGBA colour tuple for visualisation. Defaults to cyan (0,1,1,1).

  • visible (str, optional) – GOCAD visibility flag string. Defaults to "false".

  • name (str, optional) – Surface name stored in the TSurf header. Defaults to "Undefined".

  • NAME (str, optional) – GOCAD coordinate system NAME field. Defaults to "Default".

  • AXIS_NAME (str, optional) – GOCAD coordinate system AXIS_NAME field. Defaults to '"X" "Y" "Z"'.

  • AXIS_UNIT (str, optional) – GOCAD coordinate system AXIS_UNIT field. Defaults to '"m" "m" "m"'.

  • ZPOSITIVE (str, optional) – GOCAD coordinate system ZPOSITIVE field. Defaults to "Elevation".

mesh

Internal mesh representation holding points and cells.

Type:

meshio.Mesh

x, y, z

Sequences of point coordinates.

header

GOCAD header key-value pairs.

Type:

dict

csInfo

GOCAD coordinate system key-value pairs.

Type:

dict

name

Surface name.

Type:

str

solid_color

RGBA visualisation colour.

Type:

tuple

visible

Visibility flag.

Type:

str

Raises:
  • ValueError – If the number of positional arguments is not 1 or 4.

  • IOError – If a filename is supplied that does not start with GOCAD TSurf.

default_name = 'Undefined'[source]
default_solid_color = (0, 1, 1, 1.0)[source]
default_visible = 'false'[source]
default_NAME = 'Default'[source]
default_AXIS_NAME = '"X" "Y" "Z"'[source]
default_AXIS_UNIT = '"m" "m" "m"'[source]
default_ZPOSITIVE = 'Elevation'[source]
property triangles[source]

Triangle vertex coordinates as a deduplicated array.

Builds a lookup dictionary from vertex index to coordinate, then assembles each triangle’s three corners into a row of 9 values [x1,y1,z1, x2,y2,z2, x3,y3,z3].

Returns:

Unique triangles, sorted lexicographically by numpy.unique.

Return type:

numpy.ndarray of shape (n_unique_triangles, 9)

write(outname)[source]

Write the tsurf to a GOCAD TSurf .ts file.

Writes the HEADER block, GOCAD_ORIGINAL_COORDINATE_SYSTEM block, TFACE data (VRTX lines followed by TRGL lines), and the END marker.

Parameters:

outname – Output file path for the TSurf file.

Notes

Triangle connectivity is written with 1-based vertex indices as required by the GOCAD TSurf format specification. Only the first cell block is written; multi-block meshes are not supported.