Skip to content
brep-conformancegithub

mesh

Queries · api.md § mesh · all operations

mesh(s: Solid, tolerance: Length) -> {positions: list<Point3>, triangles: list<Index[3]>}

Covers the solid's boundary with triangles. No triangle lies farther than tolerance from the boundary. tolerance must be positive.

The mesh is closed. When positions within 10·ε of each other are read as one vertex, every edge between two triangles is used once each way round. The triangles, which are counter-clockwise seen from outside, therefore all face outward. Because positions within 10·ε of each other are read as one vertex, a kernel that meshes each face on its own may repeat the vertices along an edge, once for each face. The volume that the mesh bounds differs from the solid's volume by at most tolerance times the solid's area.

Example. Solid 1 is a 10 × 20 × 30 mm box with one corner at the origin.

> {"cmd": "mesh", "s": 1, "tolerance": 0.5}
< {"ok": {"positions": [[0.0, 0.0, 0.0], [10.0, 0.0, 0.0], [10.0, 20.0, 0.0], [0.0, 20.0, 0.0],
   [0.0, 0.0, 30.0], [10.0, 0.0, 30.0], [10.0, 20.0, 30.0], [0.0, 20.0, 30.0]],
   "triangles": [[2, 1, 0], [3, 2, 0], [6, 4, 5], [4, 6, 7], [5, 0, 1], [0, 5, 4], … 6 more]}}
FunctionFieldsReturns
volumesVolume
areasArea
classifys, pointslist<"in" or "on" or "out">
closests, pointslist<Point3>
normals, pointslist<Vector3 or null>
curvatures, pointslist<Number[2] or null>
checkslist<string>
centroidsPoint3 or null
inertiasNumber[3][3]
distancea, bLength
interferencea, b{volume: Volume, gap: Length}
bettisCount[3]
section_areas, origin, normalArea
sections, origin, normal, tolerancelist<list<Point3>>
projects, direction, tolerance{visible: list<list<Point2>>, hidden: list<list<Point2>>}
bounding_boxsPoint3[2]
splits, origin, normalSolid[2]
meshs, tolerance{positions: list<Point3>, triangles: list<Index[3]>}
displays, tolerance{faces: list<Face>, edges: list<list<Point3>>}
raycasts, origin, direction; or s, rayslist<Length>; or list<list<Length>>