scheme - Annotation functionalities

This module provides annotation functions to quickly measure and show things on meshes

This is more to be considered as a rendering feature, rather than a proper measuring system. Everything is built on the class Scheme that provide a very versatile way to structure and render simple but animated schematics

Those functions are designed to be very simple to use, (sometimes even minimalistic)

>>> mesh = brick(width=vec3(3,2,1))
>>> show([
...     mesh,
...     note_distance_planes(mesh.group(4), mesh.group(2)),
...     note_leading(mesh.group(3), text='truc'),
...     ])

Schematics system

class Scheme(vertices=None, spaces=None, primitives=None, **kwargs)[source]

An object containing schematics.

This is a buffer object, it isnot intended to be useful to modify a scheme.

spaces

a space is any function giving a mat4 to position a point on the screen (openGL convensions as used)

Type:list
vertices

a vertex is a tuple

(space id, position, normal, color, layer, track, flags)

Type:list
primitives

list of buffers (of point indices, edges, triangles, depending on the exact primitive type), associaded to each supported shader in the scheem

currently supported shaders are:

  • 'line' uniform opaque/transparent lines
  • 'fill' uniform opaque/transparent triangles
  • 'ghost' triangles of surface that fade when its normal is close to the view
Type:list
components

objects to display setting their local space to one of the spaces

Type:list
current

last vertex definition, implicitely reused for convenience

Type:dict
set(*args, **kwargs)[source]

Change the specified attributes in the current default vertex definition

add(obj, **kwargs)[source]

Add an object to the scheme. If it is a mesh, it’s merged in the current buffers. Else it is added as a component to the current space.

component(obj, **kwargs)[source]

Add an object as component associated to the current space

__add__(other)[source]

Return the union of the two schemes.

The current settings are those from first scheme

The following functions are commonly used spaces in madcad schematics

view[source]
screen[source]
world[source]
halo_world(position)[source]
halo_view(position)[source]
halo_screen(position)[source]
scale_screen(center)[source]
scale_view(center)[source]

Annotation functions

note_leading(placement, offset=None, text='here')[source]

Place a leading note at given position

placement can be any of Mesh, Web, Wire, axis, vec3

../_images/note_leading.png
note_floating(position, text, align=(0, 0))[source]

place a floating note at given position

../_images/note_floating.png
note_distance(a, b, offset=0, project=None, d=None, tol=None, text=None, side=False)[source]

Place a distance quotation between 2 points, the distance can be evaluated along vector project if specified

../_images/note_distance.png
note_distance_planes(s0, s1, offset=None, d=None, tol=None, text=None)[source]

Place a distance quotation between 2 meshes

s0 and s1 can be any of Mesh, Web, Wire

../_images/note_distance_planes.png
note_distance_set(s0, s1, offset=0, d=None, tol=None, text=None)[source]

Place a distance quotation between 2 objects. This is the distance between the closest elements of both sets

s0 and s1 can be any of Mesh, Web, Wire, vec3

../_images/note_distance_set.png
note_bounds(obj)[source]

Create dimension annotations on the boundingbox of an object

../_images/note_bounds.png
note_radius(mesh, offset=None, d=None, tol=None, text=None, propagate=2)[source]

Place a curvature radius quotation. This will be the minimal curvature radius observed in the mesh As a mesh is generally speaking an approximation of the desired shape, the radius may be approximative as well

../_images/note_radius.png
note_angle(a0, a1, offset=0, d=None, tol=None, text=None, unit='deg', side=False)[source]

Place an angle quotation between 2 axis

../_images/note_angle.png
note_angle_planes(s0, s1, offset=0, d=None, tol=None, text=None, unit='deg')[source]

Place an angle quotation between 2 meshes considered to be plane (surface) or straight (curve)

s0 and s1 can be any of Mesh, Web, Wire, Axis

note_angle_edge(part, edge, offset=0, d=None, tol=None, text=None, unit='deg')[source]

Place an angle quotation around a mesh edge

../_images/note_angle_edge.png
note_label(placement, offset=None, text='!', style='rect')[source]

Place a text label upon an object

placement can be any of Mesh, Web, Wire, axis, vec3

../_images/note_label.png

Measuring tools

mesh_curvature_radius(mesh, conn=None, normals=None, propagate=2)[source]

Find the minimum curvature radius of a mesh.

Parameters:
  • mesh – the surface/line to search
  • conn – a point-to-point connectivity (computed if not provided)
  • normals – the vertex normals (computed if not provided)
  • propagate (int) – the maximum propagation rank for points to pick for the regression

Return: (distance: float, point: int) where primitives varies according to the input mesh dimension

mesh_curvatures(mesh, conn=None, normals=None, propagate=2)[source]

Compute the curvature around a point in a mesh/web/wire

Parameters:
  • mesh – the surface/line to search
  • conn – a point-to-point connectivity (computed if not provided)
  • normals – the vertex normals (computed if not provided)
  • propagate (int) – the maximum propagation rank for points to pick for the regression
Returns:

[(tuple, mat3)]

where the tuple contains the curvature in each of the column directions in the mat3. The mat3 has the principal directions of curvature