Skip to content

Triangulated Surface🍋

Surface 🍋

Bases: GeoRefObject

Object representing a 3D triangulated surface.

Parameters:

Name Type Description Default
name str

object name.

required
xyz Optional[Data]

geometry data, respectively X, Y and Z.

None
triangles Optional[Data]

topological data, one triangle per element, matching geometry index.

None

Raises:

Type Description
ValueError

A point is not part of a triangle.

Example

import geolime as geo
import numpy as np
xyz = np.array([
    [1., 1., 0.3],
    [1., 2., 0.5],
    [2., 1., 0.7],
    [2., 2., 0.9]
])
trgls = np.array([
    [0, 1, 2],
    [1, 2, 3]
])
surf = geo.Surface("MySurf", xyz, trgls)

faces: np.ndarray property 🍋

The faces of the mesh.

Returns:

Type Description
ndarray

Triangles which refer to vertices.

Example

import geolime as geo
import numpy as np
xyz = np.array([
    [1., 1., 0.3],
    [1., 2., 0.5],
    [2., 1., 0.7],
    [2., 2., 0.9]
])
trgls = np.array([
    [0, 1, 2],
    [1, 2, 3]
])
surf = geo.Surface("MySurf", xyz, trgls)
surf.faces
Output
array([[0, 1, 2],
    [1, 2, 3]])

mesh: trimesh.base.Trimesh property 🍋

Trimesh Mesh allowing complex computations.

Returns:

Type Description
Trimesh

Trimesh object.

Example

import geolime as geo
import numpy as np
xyz = np.array([
    [1., 1., 0.3],
    [1., 2., 0.5],
    [2., 1., 0.7],
    [2., 2., 0.9]
])
trgls = np.array([
    [0, 1, 2],
    [1, 2, 3]
])
surf = geo.Surface("MySurf", xyz, trgls)
surf.mesh
Output
<trimesh.Trimesh(vertices.shape=(4, 3), faces.shape=(2, 3))>

vertices: np.ndarray property 🍋

The vertices of the mesh.

Returns:

Type Description
ndarray

Point coordinates referenced by faces.

Example

import geolime as geo
import numpy as np
xyz = np.array([
    [1., 1., 0.3],
    [1., 2., 0.5],
    [2., 1., 0.7],
    [2., 2., 0.9]
])
trgls = np.array([
    [0, 1, 2],
    [1, 2, 3]
])
surf = geo.Surface("MySurf", xyz, trgls)
surf.vertices
Output
array([[1. , 1. , 0.3],
    [1. , 2. , 0.5],
    [2. , 1. , 0.7],
    [2. , 2. , 0.9]])

compute_mesh() 🍋

Trimesh Mesh allowing complex computations.

Returns:

Type Description
None

Trimesh object.

delete_triangles(region) 🍋

Delete triangles in region.

Parameters:

Name Type Description Default
region str

Region or condition to select triangles.

required

element_count() 🍋

Return the number of triangles in the surface.

Returns:

Type Description
int

Number of triangles.

Example

import geolime as geo
import numpy as np
xyz = np.array([
    [1., 1., 0.3],
    [1., 2., 0.5],
    [2., 1., 0.7],
    [2., 2., 0.9]
])
trgls = np.array([
    [0, 1, 2],
    [1, 2, 3]
])
surf = geo.Surface("MySurf", xyz, trgls)
surf.element_count()
Output
2

keep_only_triangles(region) 🍋

Keep triangles in region.

Parameters:

Name Type Description Default
region str

Region or condition to select triangles.

required

sample_count() 🍋

Return the number of vertex in the surface.

Returns:

Type Description
int

Number of points.

Example

import geolime as geo
import numpy as np
xyz = np.array([
    [1., 1., 0.3],
    [1., 2., 0.5],
    [2., 1., 0.7],
    [2., 2., 0.9]
])
trgls = np.array([
    [0, 1, 2],
    [1, 2, 3]
])
surf = geo.Surface("MySurf", xyz, trgls)
surf.sample_count()
Output
4

to_dxf(filename) 🍋

Export Solid to DXF file.

Parameters:

Name Type Description Default
filename str

path to export the file to.

required

to_pyvista() 🍋

Export Solid to Pyvista PolyData.

Returns:

Type Description
PolyData

PolyData object.

translate_by(coord, expr, region=None) 🍋

Shift the given existing X, Y or Z coordinate by the given expression or value. The mesh is necessarily invalidated and will be recomputed on request.

Parameters:

Name Type Description Default
coord Union[Attribute, Coord]

coordinate property.

required
expr str

expression use to compute the property values. Use backquotes when attribute names contains whitespace.

required
region Optional[str]

region or condition in which to set the property data.

None

Raises:

Type Description
ValueError

Coordinate doesn't exist.


Last update: 2022-03-01