VNF meshes¶
- class bosl2.vnf.VNF(vertices=(), faces=())[source]¶
Bases:
objectA VNF surface:
vertices(3-D points) plusfaces(index polygons into vertices).Renders to PythonSCAD’s native
polyhedronviapolyhedron(). Build one from a rectangular grid of sample points withvertex_array(), and merge several withjoin().- Parameters:
vertices – list of [x, y, z] points
faces – list of index lists (each polygon into vertices)
Examples
Meshing a bumpy grid of sample points into a surface and rendering it as a polyhedron:
grid = [[[x, y, 4 * math.sin(x / 6) * math.cos(y / 6)] for y in range(0, 60, 4)] for x in range(0, 60, 4)] VNF.vertex_array(grid).polyhedron().show()
- reverse()[source]¶
A copy with every face wound the other way (flips the surface normals).
- Return type:
- volume()[source]¶
Signed enclosed volume (BOSL2 vnf_volume()); negative when the faces wind inward.
Used to detect and fix inverted meshes (a swept/skinned surface whose winding came out inside-out):
vnf if vnf.volume() >= 0 else vnf.reverse().- Return type:
float
- static join(vnfs)[source]¶
Merge a list of VNFs into one, offsetting each VNF’s face indices (BOSL2 vnf_join()).
- Return type:
- classmethod vertex_array(points, caps=None, cap1=None, cap2=None, col_wrap=False, row_wrap=False, reverse=False, style='default')[source]¶
Build a VNF from a rectangular grid of 3-D points (BOSL2 vnf_vertex_array()).
Each grid cell becomes triangles (or a quad) chosen by style: “default”, “alt”, “min_edge”, “min_area”, “convex”, “concave”, “quincunx”, “quad”, “flip1”, “flip2”. col_wrap/row_wrap close the grid into a tube/torus; caps/cap1/cap2 close the column-wrapped ends; reverse flips face winding. Degenerate (zero-area) faces are dropped.
- Parameters:
col_wrap (bool)
row_wrap (bool)
reverse (bool)
style (str)
- Return type:
- classmethod tri_array(points, caps=None, cap1=None, cap2=None, col_wrap=False, row_wrap=False, reverse=False, limit_bunching=True)[source]¶
Build a VNF from an array of rows whose lengths may differ (BOSL2 vnf_tri_array()).
Triangulates between adjacent rows by repeatedly adding the shortest new edge, so it meshes triangular / irregular point arrays (what the degenerate bezier patches produce).
- Parameters:
col_wrap (bool)
row_wrap (bool)
reverse (bool)
limit_bunching (bool)
- Return type:
- geometry()[source]¶
Alias of
polyhedron(), matching Path/Region’s geometry() surface.