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
The following functions are commonly used spaces in madcad schematics
Annotation functions
note_leading
(placement, offset=None, text='here')[source]Place a leading note at given position
placement
can be any ofMesh, Web, Wire, axis, vec3
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
note_distance_planes
(s0, s1, offset=None, d=None, tol=None, text=None)[source]Place a distance quotation between 2 meshes
s0
ands1
can be any ofMesh, Web, Wire
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
ands1
can be any ofMesh, Web, Wire, vec3
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
note_angle
(a0, a1, offset=0, d=None, tol=None, text=None, unit='deg', side=False)[source]Place an angle quotation between 2 axis
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
ands1
can be any ofMesh, Web, Wire, Axis
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 themat3
. Themat3
has the principal directions of curvature