rsqsim_api.io.tsurf
Reader and writer for GOCAD TSurf triangulated surface files.
Classes
Read, create, and write GOCAD TSurf triangulated surface files. |
Module Contents
- class rsqsim_api.io.tsurf.tsurf(*args, **kwargs)[source]
Bases:
objectRead, create, and write GOCAD TSurf triangulated surface files.
Supports construction from a
.tsfile path or from raw coordinate and connectivity arrays. Provides access to the triangulated mesh via thetrianglesproperty and can export back to the GOCAD TSurf format.- Parameters:
*args – Either a single
filenamestring (reads from file), or four positional argumentsx, 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
NAMEfield. Defaults to"Default".AXIS_NAME (str, optional) – GOCAD coordinate system
AXIS_NAMEfield. Defaults to'"X" "Y" "Z"'.AXIS_UNIT (str, optional) – GOCAD coordinate system
AXIS_UNITfield. Defaults to'"m" "m" "m"'.ZPOSITIVE (str, optional) – GOCAD coordinate system
ZPOSITIVEfield. Defaults to"Elevation".
- mesh
Internal mesh representation holding
pointsandcells.- 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.
- 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
.tsfile.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.