display
Queries · api.md § display · all operations
definition
display(s: Solid, tolerance: Length) -> {faces: list<{positions: list<Point3>, normals: list<Vector3>, triangles: list<Index[3]>}>, edges: list<list<Point3>>}
Draws the solid as a viewer shows it: each face meshed on its own, and its edges as polylines.
Each face has its own vertices, so shading is smooth within a face and sharp where two faces meet. Every vertex lies on the face's surface, and normals gives the surface's outward unit normal at each vertex. The triangles are counter-clockwise seen from outside, and no triangle lies farther than tolerance from the face. Together the faces close the solid, as mesh does.
edges holds each edge between two faces, whether they meet at an angle or smoothly, as where a fillet meets the face it rounds into. Each edge is given as a polyline whose every vertex lies on the edge and whose every chord lies within tolerance of the edge. A seam, where a face meets itself, is not drawn, and neither is an edge between two faces on one surface: neither marks a change in the shape.
The suite's runner draws the files it exports with display (formats.md).
Example. Solid 1 is a 10 × 20 × 30 mm box with one corner at the origin. One face and one edge of each are shown.
> {"cmd": "display", "s": 1, "tolerance": 0.1}
< {"ok": {"faces": [{"positions": [[10.0, 20.0, 0.0], [10.0, 0.0, 0.0], [0.0, 0.0, 0.0],
[0.0, 20.0, 0.0]], "normals": [[-0.0, -0.0, -1.0], [-0.0, -0.0, -1.0], [-0.0, -0.0, -1.0],
[-0.0, -0.0, -1.0]], "triangles": [[0, 1, 2], [3, 0, 2]]}, … 5 more], "edges": [[[0.0, 0.0, 0.0],
[10.0, 0.0, 0.0]], … 11 more]}}common to queries
| Function | Fields | Returns |
|---|---|---|
volume | s | Volume |
area | s | Area |
classify | s, points | list<"in" or "on" or "out"> |
closest | s, points | list<Point3> |
normal | s, points | list<Vector3 or null> |
curvature | s, points | list<Number[2] or null> |
check | s | list<string> |
centroid | s | Point3 or null |
inertia | s | Number[3][3] |
distance | a, b | Length |
interference | a, b | {volume: Volume, gap: Length} |
betti | s | Count[3] |
section_area | s, origin, normal | Area |
section | s, origin, normal, tolerance | list<list<Point3>> |
project | s, direction, tolerance | {visible: list<list<Point2>>, hidden: list<list<Point2>>} |
bounding_box | s | Point3[2] |
split | s, origin, normal | Solid[2] |
mesh | s, tolerance | {positions: list<Point3>, triangles: list<Index[3]>} |
display | s, tolerance | {faces: list<Face>, edges: list<list<Point3>>} |
raycast | s, origin, direction; or s, rays | list<Length>; or list<list<Length>> |