generation - Functions to generate mesh surfaces from lines or meshes

The functions here generare meshes from simpler objects (like lower dimension meshes, or simple primitives). You won’t find here iterative methods, nor adaptative geometry operations, nor mesh modification operations. The functions here may eventually be complex but will always feel predictable and simple from a human perspective.

Based on extrusion/transformation of a Web

extrans(section, transformations, links=None) Mesh[source]

Create a surface by extruding and transforming the given outline.

Parameters:
  • section – a Web or a Mesh
  • transformations – iterable of mat4, one each section
  • link

    iterable of tuples (a,b,t) with: (a,b) the sections to link (indices of values returned by transformation). t the group number of that link, to combine with the section groups

    if links is not specified, it will link each transformed section to the previous one. This is equivalent to giving links (i, i+1, 0)

extrusion(trans, line: Web, alignment: float = 0) Mesh[source]

Create a surface by extruding the given outline by a transformation

Parameters:
  • line – a line (Web or Wire) or a surface (Mesh) to extrude
  • trans – any transformation object accepted by mathutils.transform
  • alignment – when > 0 the line is extruded both sides (the transformation is linearly interpoled)
../_images/generation-extrusion.png
revolution(angle: float, axis: Axis, profile: Web, resolution=None) Mesh[source]

Create a revolution surface by extruding the given outline steps is the number of steps between the start and the end of the extrusion

Parameters:
  • angle – angle of rotation between the given profile and the final produced profile
  • axis – the axis to rotate around
  • profile – the shape to extrude
  • resolution – resolution setting for the biggest produced circle, such as for primitives
../_images/generation-revolution.png
saddle(web1: Web, web2: Web) Mesh[source]

Create a surface by extruding outine1 translating each instance to the next point of outline2

../_images/generation-saddle.png
tube(outline: Web, path: Wire, end=True, section=True) Mesh[source]

Create a tube surface by extruding the outline along the path if section is True, there is a correction of the segments to keep the section rigid by the curve

../_images/generation-tube.png

Generation of common meshes

regon(axis: Axis, radius, n, alignment=None) Wire[source]

Create a regular n-gon Wire, the same way we create a Circle

../_images/generation-regon.png
square(axis: Axis, width: float) Mesh[source]

Return a simple square with the given normal axis and square width. Useful to quickly create a cutplane

../_images/generation-square.png
brick(*args, **kwargs) Mesh[source]

A simple brick with rectangular axis-aligned sides

It can be constructed in the following ways:

  • brick(Box)
  • brick(min, max)
  • brick(center=vec3(0), width=vec3(-inf))
Parameters:
  • min – the corner with minimal coordinates
  • max – the corner with maximal coordinates
  • center – the center of the box
  • width – the all positive diagonal of the box
../_images/generation-brick.png
parallelogram(*directions, origin=dvec3(0, 0, 0), align=dvec3(0, 0, 0), fill=True) Mesh[source]

Create a parallelogram or parallelepiped depending on the number of directions given

Parameters:
  • directions – list of 1-3 directions, they must for a right handed base for the face normals to be oriented outward
  • origin – origin the resulting shape, the shape will placed relatively to that point
  • align – relative position of the origin in the shape: 0 means at start of each direction, 1 means at the tip of each direction
  • fill
    • if True, a mesh will be generated (forming a surface with 2 directions, or an envelope with 3 directions)
    • if False, a Web will be generated
../_images/generation-parallelogram.png
cylinder(bottom: dvec3, top: dvec3, radius: float, fill=True) Mesh[source]

Create a revolution cylinder, with the given radius

Parameters:
  • bottom (vec3) – the cylinder extremities centers
  • top (vec3) – the cylinder extremities centers
  • fill (bool) – whether to put faces at both extremities
../_images/generation-cylinder.png
cone(summit: dvec3, base: dvec3, radius: float, fill=True) Mesh[source]

Create a revolution cone, with a base of the given radius

Parameters:
  • summit (vec3) – The point at the top of the cone
  • base (vec3) – the center point of the base
  • fill (bool) – whether to put a face at the base
../_images/generation-cone.png
pyramid(summit: dvec3, base) Mesh[source]

Create a pyramid with the given summit point and the given base

Parameters:
  • summit (vec3) – the top (summit) of the cone, not necessarity in the center of the shape
  • base – (Mesh,Web,Wire): the base shape
../_images/generation-pyramid.png
icosahedron(center: dvec3, radius: float) Mesh[source]

A simple icosahedron (see https://en.wikipedia.org/wiki/Icosahedron)

../_images/generation-icosahedron.png
icosphere(center: dvec3, radius: float, resolution=None) Mesh[source]

A simple icosphere with an arbitrary resolution (see https://en.wikipedia.org/wiki/Geodesic_polyhedron).

Points are obtained from a subdivided icosahedron and reprojected on the desired radius.

../_images/generation-icosphere.png
uvsphere(center: dvec3, radius: float, alignment=dvec3(0, 0, 1), resolution=None) Mesh[source]

A simple uvsphere (simple sphere obtained with a revolution of an arc)

../_images/generation-uvsphere.png

Offsetting

inflate_offsets(surface: Mesh, offset: float, method='face') [vec3][source]

Displacements vectors for points of a surface we want to inflate.

Parameters:
  • offset – the distance from the surface to the offset surface. Its meaning depends on method
  • method – determines if the distance is from the old to the new faces, edges or points possible values: 'face', 'edge', 'point'
inflate(surface: Mesh, offset: float, method='face') Mesh[source]

Move all points of the surface to make a new one at a certain distance of the last one

Parameters:
  • offset – the distance from the surface to the offseted surface. its meaning depends on method
  • method – determines if the distance is from the old to the new faces, edges or points
../_images/generation-inflate.png
thicken(surface: Mesh, thickness: float, alignment: float = 0, method='face') Mesh[source]

Thicken a surface by extruding it, points displacements are made along normal.

Parameters:
  • thickness – determines the distance between the two surfaces (can be negative to go the opposite direction to the normal).
  • alignment – specifies which side is the given surface: 0 is for the first, 1 for the second side, 0.5 thicken all apart the given surface.
  • method – determines if the thickness is from the old to the new faces, edges or points
../_images/generation-thicken.png
expand(surface: Mesh, offset: float, collapse=True) Mesh[source]

Generate a surface expanding the input mesh on the tangent of the ouline neighboring faces

Parameters:
  • offset – distance from the outline point to the expanded outline points
  • collapse – if True, expanded points leading to crossing edges will collapse into one
../_images/generation-expand.png

Others

flatsurface(outline, normal=None) Mesh[source]

Generates a surface for a flat outline using the prefered triangulation method .

if normal is specified, it must be the normal vector to the plane, and will be used to orient the face.

../_images/generation-flatsurface.png
icosurface(pts, ptangents, resolution=None) Mesh[source]

Generate a surface ICO (a subdivided triangle) with its points interpolated using interpol2tri.

  • If normals are given instead of point tangents (for ptangents), the surface will fit a sphere.
  • Else ptangents must be a list of couples (2 edge tangents each point).
subdivide(mesh, div=1) Mesh[source]

Subdivide all faces by the number of cuts

repeat(pattern, n: int, transform)[source]

Create a mesh duplicating n times the given pattern, each time applying the given transform.

Parameters:
  • pattern – can either be a Mesh, Web or Wire the return type will depend on the input type
  • n – the number of repetitions
  • transform – is the transformation between each duplicate