Tessellation

The tessellate module provides tessellation algorithms for surfaces. The following example illustrates the usage scenario of the tessellation algorithms with surfaces.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from geomdl import NURBS
from geomdl import tessellate

# Create a surface instance
surf = NURBS.Surface()

# Set tessellation algorithm (you can use another algorithm)
surf.tessellator = tessellate.TriangularTessellate()

# Tessellate surface
surf.tessellate()

NURBS-Python uses TriangularTessellate class for surface tessellation by default.

Note

To get better results with the surface trimming, you need to use a relatively smaller evaluation delta or a bigger sample size value. Recommended evaluation delta is d = 0.01.

Class Reference

Abstract Tessellator

class geomdl.tessellate.AbstractTessellate(**kwargs)

Bases: object

Abstract base class for tessellation algorithms.

arguments

Arguments passed to the tessellation function.

This property allows customization of the tessellation algorithm, and mainly designed to allow users to pass additional arguments to the tessellation function or change the behavior of the algorithm at runtime. This property can be thought as a way to input and store extra data for the tessellation functionality.

Getter:Gets the tessellation arguments (as a dict)
Setter:Sets the tessellation arguments (as a dict)
faces

Objects generated after tessellation.

Getter:Gets the faces
Type:elements.AbstractEntity
is_tessellated()

Checks if vertices and faces are generated.

Returns:tessellation status
Return type:bool
reset()

Clears stored vertices and faces.

tessellate(points, **kwargs)

Abstract method for the implementation of the tessellation algorithm.

This algorithm should update vertices and faces properties.

Note

This is an abstract method and it must be implemented in the subclass.

Parameters:points – points to be tessellated
vertices

Vertex objects generated after tessellation.

Getter:Gets the vertices
Type:elements.AbstractEntity

Triangular Tessellator

class geomdl.tessellate.TriangularTessellate(**kwargs)

Bases: geomdl.tessellate.AbstractTessellate

Triangular tessellation algorithm for surfaces.

arguments

Arguments passed to the tessellation function.

This property allows customization of the tessellation algorithm, and mainly designed to allow users to pass additional arguments to the tessellation function or change the behavior of the algorithm at runtime. This property can be thought as a way to input and store extra data for the tessellation functionality.

Getter:Gets the tessellation arguments (as a dict)
Setter:Sets the tessellation arguments (as a dict)
faces

Objects generated after tessellation.

Getter:Gets the faces
Type:elements.AbstractEntity
is_tessellated()

Checks if vertices and faces are generated.

Returns:tessellation status
Return type:bool
reset()

Clears stored vertices and faces.

tessellate(points, **kwargs)

Applies triangular tessellation.

This function does not check if the points have already been tessellated.

Keyword Arguments:
  • size_u: number of points on the u-direction
  • size_v: number of points on the v-direction
Parameters:points (list, tuple) – array of points
vertices

Vertex objects generated after tessellation.

Getter:Gets the vertices
Type:elements.AbstractEntity

Trim Tessellator

New in version 5.0.

class geomdl.tessellate.TrimTessellate(**kwargs)

Bases: geomdl.tessellate.AbstractTessellate

Triangular tessellation algorithm for trimmed surfaces.

arguments

Arguments passed to the tessellation function.

This property allows customization of the tessellation algorithm, and mainly designed to allow users to pass additional arguments to the tessellation function or change the behavior of the algorithm at runtime. This property can be thought as a way to input and store extra data for the tessellation functionality.

Getter:Gets the tessellation arguments (as a dict)
Setter:Sets the tessellation arguments (as a dict)
faces

Objects generated after tessellation.

Getter:Gets the faces
Type:elements.AbstractEntity
is_tessellated()

Checks if vertices and faces are generated.

Returns:tessellation status
Return type:bool
reset()

Clears stored vertices and faces.

tessellate(points, **kwargs)

Applies triangular tessellation w/ trimming curves.

Keyword Arguments:
  • size_u: number of points on the u-direction
  • size_v: number of points on the v-direction
Parameters:points (list, tuple) – array of points
vertices

Vertex objects generated after tessellation.

Getter:Gets the vertices
Type:elements.AbstractEntity

Quadrilateral Tessellator

New in version 5.2.

class geomdl.tessellate.QuadTessellate(**kwargs)

Bases: geomdl.tessellate.AbstractTessellate

Quadrilateral tessellation algorithm for surfaces.

arguments

Arguments passed to the tessellation function.

This property allows customization of the tessellation algorithm, and mainly designed to allow users to pass additional arguments to the tessellation function or change the behavior of the algorithm at runtime. This property can be thought as a way to input and store extra data for the tessellation functionality.

Getter:Gets the tessellation arguments (as a dict)
Setter:Sets the tessellation arguments (as a dict)
faces

Objects generated after tessellation.

Getter:Gets the faces
Type:elements.AbstractEntity
is_tessellated()

Checks if vertices and faces are generated.

Returns:tessellation status
Return type:bool
reset()

Clears stored vertices and faces.

tessellate(points, **kwargs)

Applies quadrilateral tessellation.

This function does not check if the points have already been tessellated.

Keyword Arguments:
  • size_u: number of points on the u-direction
  • size_v: number of points on the v-direction
Parameters:points (list, tuple) – array of points
vertices

Vertex objects generated after tessellation.

Getter:Gets the vertices
Type:elements.AbstractEntity

Function Reference

geomdl.tessellate.make_triangle_mesh(points, size_u, size_v, **kwargs)

Generates a triangular mesh from an array of points.

This function generates a triangular mesh for a NURBS or B-Spline surface on its parametric space. The input is the surface points and the number of points on the parametric dimensions u and v, indicated as row and column sizes in the function signature. This function should operate correctly if row and column sizes are input correctly, no matter what the points are v-ordered or u-ordered. Please see the documentation of ctrlpts and ctrlpts2d properties of the Surface class for more details on point ordering for the surfaces.

This function accepts the following keyword arguments:

  • vertex_spacing: Defines the size of the triangles via setting the jump value between points
  • trims: List of trim curves passed to the tessellation function
  • tessellate_func: Function called for tessellation. Default: tessellate.surface_tessellate()
  • tessellate_args: Arguments passed to the tessellation function (as a dict)

The tessellation function is designed to generate triangles from 4 vertices. It takes 4 Vertex objects, index values for setting the triangle and vertex IDs and additional parameters as its function arguments. It returns a tuple of Vertex and Triangle object lists generated from the input vertices. A default triangle generator is provided as a prototype for implementation in the source code.

The return value of this function is a tuple containing two lists. First one is the list of vertices and the second one is the list of triangles.

Parameters:
  • points (list, tuple) – input points
  • size_u (int) – number of elements on the u-direction
  • size_v (int) – number of elements on the v-direction
Returns:

a tuple containing lists of vertices and triangles

Return type:

tuple

geomdl.tessellate.polygon_triangulate(tri_idx, *args)

Triangulates a monotone polygon defined by a list of vertices.

The input vertices must form a convex polygon and must be arranged in counter-clockwise order.

Parameters:
  • tri_idx (int) – triangle numbering start value
  • args (Vertex) – list of Vertex objects
Returns:

list of Triangle objects

Return type:

list

geomdl.tessellate.make_quad_mesh(points, size_u, size_v)

Generates a mesh of quadrilateral elements.

Parameters:
  • points (list, tuple) – list of points
  • size_u (int) – number of points on the u-direction (column)
  • size_v (int) – number of points on the v-direction (row)
Returns:

a tuple containing lists of vertices and quads

Return type:

tuple

Helper Functions

geomdl.tessellate.surface_tessellate(v1, v2, v3, v4, vidx, tidx, trim_curves, tessellate_args)

Triangular tessellation algorithm for surfaces with no trims.

This function can be directly used as an input to make_triangle_mesh() using tessellate_func keyword argument.

Parameters:
  • v1 (Vertex) – vertex 1
  • v2 (Vertex) – vertex 2
  • v3 (Vertex) – vertex 3
  • v4 (Vertex) – vertex 4
  • vidx (int) – vertex numbering start value
  • tidx (int) – triangle numbering start value
  • trim_curves – trim curves
  • tessellate_args (dict) – tessellation arguments
Type:

list, tuple

Returns:

lists of vertex and triangle objects in (vertex_list, triangle_list) format

Type:

tuple

geomdl.tessellate.surface_trim_tessellate(v1, v2, v3, v4, vidx, tidx, trims, tessellate_args)

Triangular tessellation algorithm for trimmed surfaces.

This function can be directly used as an input to make_triangle_mesh() using tessellate_func keyword argument.

Parameters:
  • v1 (Vertex) – vertex 1
  • v2 (Vertex) – vertex 2
  • v3 (Vertex) – vertex 3
  • v4 (Vertex) – vertex 4
  • vidx (int) – vertex numbering start value
  • tidx (int) – triangle numbering start value
  • trims (list, tuple) – trim curves
  • tessellate_args (dict) – tessellation arguments
Returns:

lists of vertex and triangle objects in (vertex_list, triangle_list) format

Type:

tuple