75. plugins.gts_itf — Operations on triangulated surfaces using GTS functions.

This module provides access to GTS from inside pyFormex.

75.1. Functions defined in module plugins.gts_itf

plugins.gts_itf.read_intersectioncurve(fn)[source]

Read the intersection curve of a boolean operation

Parameters:

fn (path_like) – The name of a file containing an intersection curve produced by gtsset().

Returns:

Mesh – A Mesh of eltype Line2 containing the line segments on the intersection curve.

plugins.gts_itf.gtsset(surf1, surf2, op, filt='', ext='', curve=False, check=False, verbose=False)[source]

Perform boolean/intersection methods on TriSurfaces.

Boolean operations between two surfaces are a basic operation in free surface modeling. Both surfaces should be closed orientable non-intersecting manifolds. This means they represent an enclosed volume. TriSurface.check() can be used to find out if the surface is ok.

The boolean operations are set operations on the enclosed volumes: union(‘+’), difference(‘-’) or intersection(‘*’).

This uses the external program gtsset to do the actual computation.

Parameters:
  • surf1 (TriSurface) – The first TriSurface (should be a closed orientable non-intersecting manifold).

  • surf2 (TriSurface) – The second TriSurface (should be a closed orientable non-intersecting manifold).

  • op ('+', '-', '*' or 'a') – The boolean operation to perform: union(‘+’), difference(‘-‘) or intersection(‘*’), or ‘a’ to compute all parts of the intersection, allowing to compose different results.

  • filt (str) – A filter command to be executed on the gtsset output. The string should start with a ‘|’, and the filter will be run as a pipe on the gtsset output and should produce the filtered output on stdout.

  • ext (str) – The extension to be added on the result file.

  • curve (bool) – If True, an intersection curve is computed, else a new surface.

Returns:

TriSurface | dict | Mesh | None

  • if curve is False and op is one of ‘+’, ‘-’ or ‘*’: the resulting TriSurface;

  • if curve is False and op is ‘a’: a dict with four keys, each having a TriSurface as value:

    • ’s1in2’: the part of surf1 that is inside surf2,

    • ’s1out2’: the part of surf1 that is outside surf2,

    • ’s2in1’: the part of surf2 that is inside surf1,

    • ’s2out1’: the part of surf2 that is outside surf1;

  • if curve is True: a Mesh of eltype Line2, containing the intersection curve(s);

  • if surf1 and surf2 do not intersect: None.

Note

The prefered way to invoke this function is by usint the TriSurface methods: TriSurface.gts_set(), TriSurface.boolean and :meth:`TriSurface.intersection().

plugins.gts_itf.gtsinside(surf, pts, dir, keep=False)[source]

Test whether points are inside a closed surface.

This tests whether a point is inside a closed surface by shooting a ray from the point in a certain direction and tests whether the number of intersections with the surface is odd (inside) or even (outside). Shooting directions are limited to one of the global axes directions.

Parameters:
  • surf (TriSurface) – The TriSurface (should be a closed orientable non-intersecting manifold).

  • pts (coords_like) – A Coords with shape (npts, 3)

  • dir (int) – The global axis that will be used as shooting direction.

Returns:

array – An int array with the indices of the points that are inside the surface.

Note

This function is not intended to be used directly. False negatives or positives may occur when the ray passes precisely through the edge of triangles. Use inside() instead.

plugins.gts_itf.inside(surf, pts, atol='auto', multi=True, keep=False)[source]

Test which of the points pts are inside the surface.

This uses the ray shooting technique of gtsinside, but avoids (most of) the false negatives/positives. It does this by shooting in three directions (the three global axis directions) and returning the majority vote of the three outcomes.

Parameters:
  • surf (TriSurface) – The TriSurface (should be a closed orientable non-intersecting manifold).

  • pts (coords_like) – A Coords with shape (npts, 3) or Formex with shape (npts, 1, 3).

  • atol (float) – Tolerance used in restricting the points set to the surface’s bounding box.

  • multi (bool) – If True (default), rund the three shooting directions n parallel. This reduces the total processing time.

  • keep (bool) – If True, the temporary directory with intermediate results is not erased. This may be useful for debugging purposes.

Returns:

array – An int array with the indices of the points that are inside the surface.

See also

TriSurface.inside

the prefered way to call this function