C API
Four headers over two shared libraries: cadaclysm.h (reading, meshing, writing) and cadaclysm_blacksmith.h (the modelling kernel) over the cadaclysm library, with cadaclysm_flavour.h saying which of its four flavours it is, and cadaclysm_view.h over cadaclysm_view, the viewer drawn into a window of your own. Plain C, callable from C++ and from any language with a foreign-function interface.
How every call behaves
- Handles.
cadaclysm_openreturns aCadaclysmScene *, freed bycadaclysm_close; the kernel's solids, profiles, paths and sweep paths each have a…_free. A null handle is a failure. - Errors. A call that fails returns null,
false, zero orCADACLYSM_NONEand leaves its reason incadaclysm_last_error()(cadaclysm_blacksmith_last_error()): per thread, valid until the next call on that thread. - Borrowed memory. Strings, meshes and polylines the reader returns point into the scene and live until
cadaclysm_close; copy what must outlive it. The kernel's meshes live in the solid's cache until it is freed or meshed at another tolerance; a held tessellation (cadaclysm_blacksmith_tessellation) lends the same arrays independently of the solid, until the tessellation itself is freed, whatever happens to the solid meanwhile. The one string the caller frees is the kernel's STEP text, withcadaclysm_blacksmith_string_free. - Sized buffers. Where the caller provides the memory, as
cadaclysm_querydoes, call once with a null buffer to learn the count, then again with room for it. - Nodes are indices. A node is a
uint32_tinto its scene,CADACLYSM_NONEfor none; a placement likewise. - Options. Fill a
CadaclysmOpenOptionswithcadaclysm_open_options_initbefore setting fields, so a library newer than your code still reads a valid struct. - The view.
cadaclysm_view_createreturns aCadaclysmView *, freed bycadaclysm_view_destroybefore its window goes; its errors are incadaclysm_view_last_error(). Its structs start with asizefield: set it tosizeofthe struct, so a newer library reads only what your code filled. A view is driven from the thread that owns its window.
The headers are in the SDK's include/; every other language on these pages is a wrapper over exactly these calls. This page is generated from the headers' own comments.
cadaclysm.h
Library and licence
cadaclysm_last_error
const char *cadaclysm_last_error(void);
Why the last call failed, or null if none has.
Borrowed, and good until the next call on this thread.
cadaclysm_version
const char *cadaclysm_version(void);
The library's version, as "0.1.0". Static; never freed.
cadaclysm_license_set
bool cadaclysm_license_set(const char *text_or_path);
Load a license from text_or_path: the certificate text itself, or the path of a file holding it. Replaces the one in use. Null forgets the one in use, so the next call resolves from the environment and the search paths again. Returns false without changing anything when the text does not verify, with the reason at cadaclysm_last_error.
cadaclysm_license_info
const char *cadaclysm_license_info(void);
The license in use, as one line — customer=Acme Ltd expiry=2027-09-15 scope=server plan=startup servers=1 — or, without one, unlicensed (unlicensed -- <reason> when a license was found but did not verify). Never null. Borrowed, and good until the next call on this thread.
cadaclysm_license_notice_count
uint64_t cadaclysm_license_notice_count(void);
How many unlicensed notices this library has printed in this process; an application can show its own banner instead of the stderr line.
cadaclysm_build_date
const char *cadaclysm_build_date(void);
The date this library was built, "YYYY-MM-DD". A paid license is good for every build dated on or before the day its updates end. Static; never freed.
Colour
cadaclysm_parse_colour
bool cadaclysm_parse_colour(const char *text, double *out);
A colour's text as r, g, b in 0..1, into out[0..3]: "#rgb", "#rrggbb" (the # optional) or one of the 148 CSS colour names, any case. The one parser every wrapper hands colour text to, so the forms are the same in each. False, with cadaclysm_last_error saying why, for anything else.
Opening and closing
cadaclysm_open
struct CadaclysmScene *cadaclysm_open(const char *path,
const struct CadaclysmOpenOptions *options);
Open a CAD file, or a .zip, .stpZ or .gz holding one.
path names the model. schema names the EXPRESS schema (.exp) it conforms to, which only STEP and IFC need — they name one and cannot be read without it. An IGES file, a .brep and a .3dm all say what they mean in themselves, so pass null for those.
A .zip opens its shallowest readable member, or the one options->pick names, with the rest of the archive standing in for the file's own directory — an include <lib/box.scad> inside the archive finds the archive's own lib/box.scad. cadaclysm_source_name says which member was chosen. A .stpZ (STEP-Z: the STEP file, zipped) is a zip.
cadaclysm_open_memory
struct CadaclysmScene *cadaclysm_open_memory(const uint8_t *bytes,
size_t length,
const char *format,
const struct CadaclysmOpenOptions *options);
Open a CAD file already in memory, or a .zip, .stpZ or .gz holding one.
format names the kind as an extension would — "step", "ifc", "igs", "brep", "3dm", "scad", "sat", "zip", "stpz", "step.gz" — since there is no file name to take it from. A leading dot is allowed and ignored.
Those are examples rather than the whole list, which depends on the readers this build was compiled with: cadaclysm_format_extensions is what it actually reads, and the error returned when format is missing names every one of them. Prefer either to a list written out by hand — this doc comment carried one for a while that had gone stale.
cadaclysm_open_options_init
void cadaclysm_open_options_init(struct CadaclysmOpenOptions *options);
Fill options with its size and every default.
The alternative is a caller zeroing the struct themselves and setting size by hand, which works and is one more thing to get wrong.
cadaclysm_close
void cadaclysm_close(struct CadaclysmScene *scene);
Give a scene back. Null is accepted and does nothing.
Everything borrowed from it — names, meshes, attribute text — is invalid afterwards.
cadaclysm_source_name
const char *cadaclysm_source_name(const struct CadaclysmScene *scene);
The archive member a scene was read from, or null for a plain file.
What a viewer titles its window with: cadaclysm_open on a zip chose one member, and this is the only way to learn which. Borrowed from the scene, valid until cadaclysm_close.
The scene
cadaclysm_node_count
uint32_t cadaclysm_node_count(const struct CadaclysmScene *scene);
How many parts it has, geometry or not.
cadaclysm_root_count
uint32_t cadaclysm_root_count(const struct CadaclysmScene *scene);
How many parts nothing else contains.
cadaclysm_root
uint32_t cadaclysm_root(const struct CadaclysmScene *scene, uint32_t index);
One of them, or CADACLYSM_NONE past the end.
cadaclysm_schema
const char *cadaclysm_schema(const struct CadaclysmScene *scene);
The schema the file named, or "" for a format that names none.
cadaclysm_schema_read
const char *cadaclysm_schema_read(const struct CadaclysmScene *scene);
What one length in the file is worth in metres, or 1 where it did not say.
cadaclysm_metres_per_unit
double cadaclysm_metres_per_unit(const struct CadaclysmScene *scene);
What one length unit in the file is worth in metres; 1 where the file did not say.
cadaclysm_tolerances
bool cadaclysm_tolerances(const struct CadaclysmScene *scene,
double *absolute,
double *angular);
What the file declares about its own precision: its absolute tolerance (a length in the file's own unit, beside cadaclysm_metres_per_unit, whatever convention the scene was opened into) into *absolute and its angular one (radians) into *angular, NaN for one it does not declare — a 3dm's units and tolerances, STEP's uncertainty, SAT's resabs, IGES's resolution; other formats declare nothing. Each body read from the file carries a copy, which the kernel's verbs given a tolerance of 0 or NaN work from. Either pointer may be null. False, with nothing written, for a null scene.
cadaclysm_bounds
struct CadaclysmBounds cadaclysm_bounds(const struct CadaclysmScene *scene);
Everything the model covers, in world coordinates.
The one figure here that is not in a part's own frame, because a bounding box over the whole model has no other frame to be in. It is the union of exactly what iterating the parts would draw: every part cadaclysm_node_can_mesh answers true for, its extent carried through its own transform — the eight corners, since a rotated box's corners are what reach furthest.
This meshes all of it, being the only way to know how far it reaches. A caller that has not the time should frame from the parts it has built.
cadaclysm_bounds64
struct CadaclysmBounds64 cadaclysm_bounds64(const struct CadaclysmScene *scene);
cadaclysm_bounds in double: the same union box, unnarrowed.
This meshes all of it, being the only way to know how far it reaches. A caller that has not the time should frame from the parts it has built.
cadaclysm_query
uint32_t cadaclysm_query(const struct CadaclysmScene *scene,
const char *filter,
uint32_t *out,
uint32_t capacity);
The nodes matching filter, as indices into the scene's node list.
Returns the total number of matches and writes up to capacity of them into out. Call once with capacity = 0 and a null out to learn the size, then again to fill a buffer. A filter that will not parse returns 0 with the reason at cadaclysm_last_error.
A 0 is ambiguous unless you check the error, errno-style. Zero matches is the common, legitimate outcome of a search — a typo'd filter must not look the same as a filter that correctly found nothing, which is the one failure mode this function exists to avoid. So this call — and only this one, not every entry point in this library — clears cadaclysm_last_error to null before it does anything else. With a valid scene, a 0 return paired with a null error is a real empty result, and a 0 paired with a non-null error is a parse failure. A null scene is the one case that does not fit this: like every other accessor here, it is silently neutral rather than an error, so it too returns 0 with a null error — that reflects a null handle, not a filter that matched nothing, and is the caller's own bug to find rather than this function's to report.
cadaclysm_diagnostic_count
uint32_t cadaclysm_diagnostic_count(const struct CadaclysmScene *scene);
How many things this file held that the reader could not build.
cadaclysm_diagnostic
const char *cadaclysm_diagnostic(const struct CadaclysmScene *scene, uint32_t index);
One of them, or null past the end. Borrows from the scene.
cadaclysm_geometry_diagnostic_count
uint32_t cadaclysm_geometry_diagnostic_count(const struct CadaclysmScene *scene);
How many things meshing has complained about so far.
cadaclysm_diagnostic answers for the *parse*: a fixed list, settled the moment the file was read, of what the reader could not build. This answers for the tessellation, which is a different question asked of a different stage — a face whose boundary encloses no region is perfectly well parsed and simply cannot be meshed.
It reports on what has been meshed, and meshing is lazy, so this is empty until something has asked for geometry and grows as more is asked for. Call it after cadaclysm_realize_all, or after meshing whatever parts matter; calling it straight after cadaclysm_open is asking what meshing found before any has happened, and the honest answer to that is none.
cadaclysm_geometry_diagnostic
const char *cadaclysm_geometry_diagnostic(const struct CadaclysmScene *scene, uint32_t index);
One of them, or null past the end.
Borrows from the scene, and only until the next cadaclysm_geometry_diagnostic_count — see there.
cadaclysm_pose_diagnostic_count
uint32_t cadaclysm_pose_diagnostic_count(const struct CadaclysmPose *pose);
How many things the pose's couplings could not solve, or found disagreeing, in file order (drives spec §12a); 0 for a null pose. Each reads, word for word: - coupling '<name>': both '<a>' and '<b>' are given and disagree by <d>; - coupling '<name>' cannot be solved: <why>.
cadaclysm_pose_diagnostic
const char *cadaclysm_pose_diagnostic(const struct CadaclysmPose *pose, uint32_t index);
The index-th of them, UTF-8; null for a null pose or out of range. Borrowed, lives as long as the pose.
cadaclysm_surface_matrix
void cadaclysm_surface_matrix(const struct CadaclysmScene *scene, float *out);
The matrix that takes cadaclysm_node_surfaces into the space everything else is already in, written to out as sixteen floats, column-major.
Only the surfaces need it. Meshes, polylines and Bézier curves arrive in the convention the document was opened with; the surfaces do not, because converting a surface means converting its parameter space too — a cylinder's v is a length and scales, a sphere's is an angle and does not — and getting that wrong moves the trim loops off the face they trim. Handing over the matrix leaves the one product that is unconverted plainly unconverted, rather than converted in a way that is wrong for two of the eight kinds.
Compose it on the left of a node's placement. For a document opened NATIVE at the file's own units this is the identity, and a caller may skip it.
cadaclysm_scene_save
bool cadaclysm_scene_save(const struct CadaclysmScene *scene,
const char *path,
const char *format);
Write the whole scene — every placement of every shape, named and placed as the document's tree is, with a material per colour — to path as glTF, OBJ, OpenUSD, 3MF, PLY, an OCCT .brep or a Rhino .3dm. False on failure, with cadaclysm_last_error saying why.
format is "glb" (binary, one file), "gltf" (JSON with the vertex buffer embedded, also one file) or "obj" (Wavefront text, every placement baked to its own named object, with a .mtl written beside it under the same stem when anything has a colour). "usda" is an OpenUSD text layer: each shape's triangles once, every placement a prim referencing them with its world matrix, a UsdPreviewSurface per colour, and a node's MaterialX or MDL material (its ExternalStyle.* or MaterialReference.* properties) bound in its own format — cadaclysm_usd says exactly what it carries. The layer's upAxis and metersPerUnit are the space the scene was opened into. "3mf" is a 3MF package: each shape an object once, every placement a build item with its world matrix, a colour per object from the placing node or its shape (cadaclysm_3mf::to_document_3mf_with). "ply" (binary little-endian) and "ply-ascii" write PLY, which has no tree: every placement baked through its world matrix into one body, a colour a vertex where anything has one (cadaclysm_ply::to_document_ply_with). These hold a scene where the cadaclysm_mesh_format rows write one node's mesh; the same names there are the one-mesh forms. "brep" writes what the readers kept of the exact geometry rather than the mesh: every face's surface whole, bounded by the polylines its trims were flattened to, each body once with a location for each place it stands (cadaclysm_brep_file::write_document says exactly what that carries). A scene with no exact geometry at all — an STL, a mesh-only file — is refused as such. "3dm" writes a Rhino file (version 8, which Rhino 8 and 9 open): each body as its exact brep where the reader kept one and as its mesh otherwise, curves and points as themselves; a shape drawn in several places once, as a block with a reference at each, and a .3dm's own blocks kept as they were; a .3dm's own layers, or for any other file layers named after the assemblies above each object; names, colours, visibility and text or number properties as user text (cadaclysm_rhino3dm::write::write_scene says exactly what it carries). It is written in the file's own units and axes, so it needs a scene opened CADACLYSM_NATIVE and refuses one opened into another space. On success, cadaclysm_last_error lists what was written as a mesh or left out, one line each, or is null where nothing was. Any other name is refused.
A mechanism goes into a USD layer as UsdPhysics: a rigid body per link, with its mass and inertia from its parts' declared densities (water's where none is declared) and convex colliders, and a joint prim per pair, for a simulator (Isaac Sim, Omniverse).
cadaclysm_svg_options_init
void cadaclysm_svg_options_init(struct CadaclysmSvgOptions *options);
The defaults: the viewer's iso, orthographic, a 1000-square page, black edges one unit wide on nothing, and each body's outline beside them.
cadaclysm_scene_svg_text
const char *cadaclysm_scene_svg_text(const struct CadaclysmScene *scene,
const struct CadaclysmSvgOptions *options);
The scene's drawing: every visible placement of every shape, a <g> per placement (id="placement-<i>", data-node, data-name), the line sets flags name, from the camera the words describe. A placement whose node, or any ancestor of it, the file marks hidden (cadaclysm_node_visible) is left out, as a viewer leaves it out; i counts every placement, hidden ones too, so an id names the same placement whatever is shown. The text belongs to the scene and is replaced by the next cadaclysm_scene_svg_text or cadaclysm_node_svg_text on it; null and cadaclysm_last_error on a refused option or no scene given.
The pointer's lifetime is the scene's, not the calling thread's — unlike cadaclysm_last_error, which is per thread. Two threads calling *_svg_text on one scene free each other's text: callers sharing a scene across threads serialise their svg_text calls (and the reads of what they return) themselves, or write files with cadaclysm_scene_svg, which never touches the slot.
A scene with nothing to draw is not an error: a placement whose shape has no curves in the line sets flags names gets no group at all (there is nothing to fit a camera to, let alone draw), and a scene where every placement is like that still returns a valid <svg> with no groups in it — an empty page, not a null pointer.
cadaclysm_scene_svg
bool cadaclysm_scene_svg(const struct CadaclysmScene *scene,
const char *path,
const struct CadaclysmSvgOptions *options);
cadaclysm_scene_svg_text's drawing written to path, replacing any file there — straight to the file, leaving the scene's svg_text text (and any pointer to it) alone. False and last_error on failure, the file's included.
Nodes
cadaclysm_node_parent
uint32_t cadaclysm_node_parent(const struct CadaclysmScene *scene, uint32_t node);
The part containing this one, or CADACLYSM_NONE for a root.
cadaclysm_node_child_count
uint32_t cadaclysm_node_child_count(const struct CadaclysmScene *scene, uint32_t node);
How many parts this one contains directly.
cadaclysm_node_child
uint32_t cadaclysm_node_child(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t index);
One of them, or CADACLYSM_NONE past the end.
cadaclysm_node_depth
uint32_t cadaclysm_node_depth(const struct CadaclysmScene *scene, uint32_t node);
How far down the tree it sits, a root being zero. For indenting.
Walked from the parent chain rather than stored — CadDocument keeps the links and not the depth, and the answer is the same. The step count is bounded by the node count, so a malformed cycle cannot spin here.
cadaclysm_node_name
const char *cadaclysm_node_name(const struct CadaclysmScene *scene, uint32_t node);
Its name, or null past the end.
cadaclysm_node_kind
const char *cadaclysm_node_kind(const struct CadaclysmScene *scene, uint32_t node);
What the file calls it — an IFC type, an openNURBS class, a shape kind. Null past the end.
cadaclysm_node_id
const char *cadaclysm_node_id(const struct CadaclysmScene *scene, uint32_t node);
What the file calls it — a STEP #N, an IFC GlobalId, a Rhino UUID — or its position for a format with no such notion. Null past the end.
A string rather than a number, because that is what the formats carry: a .3dm object is named by a UUID and an IFC product by a 22-character GlobalId, neither of which fits in a uint64_t. A caller matching ids compares the text.
cadaclysm_node_color
bool cadaclysm_node_color(const struct CadaclysmScene *scene, uint32_t node, float *rgba);
Its colour into rgba, returning whether the file gave one.
Where it did not, rgba is left alone and the caller should use its own — which is the honest answer, most STEP files carrying no colour at all.
Its own colour where it has one, and the colour of the shape it draws otherwise. Both halves matter: an occurrence that overrides its shape's colour — the same window type in white on one storey and grey on the next — must keep the override, while one that says nothing about colour should be drawn in the colour of the geometry it actually puts on screen rather than falling back to the caller's default beside identical parts that are coloured. This is the same CadaclysmScene::shape_of hop cadaclysm_node_mesh follows.
cadaclysm_node_own_color
bool cadaclysm_node_own_color(const struct CadaclysmScene *scene, uint32_t node, float *rgba);
This node's own colour, and nothing inherited: true only where the node itself carries one. cadaclysm_node_color answers "own, else the shape's" — the colour to draw — and so cannot say which of the two it was. A renderer that treats a part with no colour of its own differently (a mesh's per-vertex alpha is honoured only there) asks this.
cadaclysm_node_transform
void cadaclysm_node_transform(const struct CadaclysmScene *scene, uint32_t node, double *out);
Where this part's geometry sits, as a 4x4 column-major matrix.
A mesh is in its part's own frame; this carries it to world. Doubles, while the mesh is floats, on purpose: a building at UTM coordinates baked into f32 world positions loses millimetres, where an f32 mesh about its own origin under an f64 transform does not. It is also what lets one mesh be drawn at many placements instead of being copied per placement.
cadaclysm_node_attribute_count
uint32_t cadaclysm_node_attribute_count(const struct CadaclysmScene *scene, uint32_t node);
How many things the file said about this part.
cadaclysm_node_attribute
struct CadaclysmAttribute cadaclysm_node_attribute(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t index);
One of them, or an all-zero one past the end.
cadaclysm_node_can_mesh
bool cadaclysm_node_can_mesh(const struct CadaclysmScene *scene, uint32_t node);
Whether this part is drawn — whether it has geometry of its own to show.
Asks for nothing to be built, and says nothing about whether it has been. Most parts of a model are structure — an assembly, a storey, a layer — and answer false.
Geometry, not triangles: a part drawn as a *curve* — a .3dm curve object, a STEP geometrically-bounded curve — answers true and gives an empty cadaclysm_node_mesh, having no surface to triangulate. A caller drawing solids alone can pass over an empty mesh; one that wants the wireframe reads cadaclysm_node_curves.
cadaclysm_node_visible
bool cadaclysm_node_visible(const struct CadaclysmScene *scene, uint32_t node);
Whether the file says this node should be shown when it is opened.
The file's opening state, not a live switch. A caller that wants to open a document the way its author left it hides what this reports false for; from then on, what is shown is the caller's business. Nothing here changes, and nothing else in this ABI consults it — a hidden node still meshes, still has bounds, and is still drawn by anything that ignores this.
True where the format says nothing, which is most of them. Today only IGES (an entity's blank status) and Rhino .3dm (an object or a layer switched off) report otherwise; STEP's invisibility and IFC's IfcPresentationLayerWithStyle.LayerOn are not read yet, so their documents answer true throughout.
cadaclysm_node_instance_of
uint32_t cadaclysm_node_instance_of(const struct CadaclysmScene *scene, uint32_t node);
The part whose geometry this one is a placement of, or CADACLYSM_NONE.
The point of handing meshes over in their own frame: a shell placed seventy- four times is one mesh and seventy-four transforms, and this is how a caller knows to upload the buffer once.
cadaclysm_node_select_as
uint32_t cadaclysm_node_select_as(const struct CadaclysmScene *scene, uint32_t node);
What a click on this part's geometry should select — itself, usually.
A format that hangs geometry on a child of the object it belongs to (IFC: a representation item under its product) points the child back at the object, so picking the shape selects the thing while the shape stays a part of its own to inspect.
cadaclysm_node_generator
const char *cadaclysm_node_generator(const struct CadaclysmScene *scene, uint32_t node);
What this part's geometry was before it was triangles — "brep", "mesh", "csg". A .3dm holds several kinds side by side and a native mesh calling itself a brep is a plain lie, so this is per part rather than per file.
Null for a part that draws nothing, since there is then no geometry to have come from anything, exactly as cadaclysm_node_mesh is empty there.
cadaclysm_node_save_mesh
bool cadaclysm_node_save_mesh(const struct CadaclysmScene *scene,
uint32_t node,
const char *path,
const char *format);
Write one node's mesh to path in the named format. False on failure, with cadaclysm_last_error saying why.
format is one of the names cadaclysm_mesh_format reports. A node that draws nothing — an assembly, a layer, an empty definition — is a failure rather than an empty file, since a caller asking to export it has almost certainly clicked the wrong row.
The mesh is the node's own, in the space the scene was opened into, and carries no placement: a node instanced six times exports once, where it is defined. Exporting where a *drawing* sits is a different question and this is not it.
Placements
cadaclysm_placement_count
uint32_t cadaclysm_placement_count(const struct CadaclysmScene *scene);
How many drawings this document asks for.
So a renderer walks these, and asks cadaclysm_placement_geometry which part's mesh each one draws and cadaclysm_placement_transform where to put it. Parts remain what a *tree* is built from — names, properties, hierarchy, selection.
cadaclysm_placement_geometry
uint32_t cadaclysm_placement_geometry(const struct CadaclysmScene *scene, uint32_t placement);
Which part's geometry this drawing draws.
Ask that part for its mesh, edges or curves as usual. Two drawings of one shape name the same part and so hand back the same pointers, which is what lets a caller upload it once and draw it at both transforms.
CADACLYSM_NONE for an index past cadaclysm_placement_count.
cadaclysm_placement_select
uint32_t cadaclysm_placement_select(const struct CadaclysmScene *scene, uint32_t placement);
What a click on this drawing should select.
The placement rather than the shape it draws: the shape is somewhere else and is shared with every sibling copy, so selecting it would light them all up.
CADACLYSM_NONE for an index past cadaclysm_placement_count.
cadaclysm_placement_transform
void cadaclysm_placement_transform(const struct CadaclysmScene *scene,
uint32_t placement,
double *out);
Where this drawing sits, as a 4x4 column-major matrix.
Already composed through every frame between the document's root and the drawing, so a caller multiplies nothing itself. Doubles for the reason cadaclysm_node_transform gives.
Links, joints, pairs, states and sequences
cadaclysm_link_count
uint32_t cadaclysm_link_count(const struct CadaclysmScene *scene);
How many kinematic links the file describes: rigid bodies of a mechanism, each moving the nodes cadaclysm_link_node lists. 0 for a file that records no mechanism, which is every format but STEP today.
cadaclysm_link_name
const char *cadaclysm_link_name(const struct CadaclysmScene *scene, uint32_t link);
A link's name as the file gives it, or null past the end. Borrows from the scene.
cadaclysm_link_node_count
uint32_t cadaclysm_link_node_count(const struct CadaclysmScene *scene, uint32_t link);
How many nodes a link moves: the topmost node of each subtree it owns, so moving them moves everything under them. 0 past the end.
cadaclysm_link_node
uint32_t cadaclysm_link_node(const struct CadaclysmScene *scene, uint32_t link, uint32_t index);
One of them, in ascending node order, or CADACLYSM_NONE past either end.
cadaclysm_joint_count
uint32_t cadaclysm_joint_count(const struct CadaclysmScene *scene);
How many joints the file's mechanism has: connections between two links. Topology only; how a joint moves is not read yet.
cadaclysm_joint_name
const char *cadaclysm_joint_name(const struct CadaclysmScene *scene, uint32_t joint);
A joint's name as the file gives it, or null past the end. Borrows from the scene.
cadaclysm_joint_start
uint32_t cadaclysm_joint_start(const struct CadaclysmScene *scene, uint32_t joint);
The link a joint starts at, as an index for cadaclysm_link_name and cadaclysm_link_node, or CADACLYSM_NONE past the end. The file's order, not parent and child: a mechanism may be a network with loops.
cadaclysm_joint_end
uint32_t cadaclysm_joint_end(const struct CadaclysmScene *scene, uint32_t joint);
The link a joint ends at, as cadaclysm_joint_start gives its other end.
cadaclysm_joint_pair_kind
int32_t cadaclysm_joint_pair_kind(const struct CadaclysmScene *scene, uint32_t joint);
The joint's pair kind (a CadaclysmPairKind value), or -1 when the joint has no pair or the index is out of range.
cadaclysm_joint_pair_type
const char *cadaclysm_joint_pair_type(const struct CadaclysmScene *scene, uint32_t joint);
For CadaclysmPairKind::CADACLYSM_PAIR_OTHER: the pair's entity type name ("CAM_PAIR"; "GEAR_PAIR" and "RACK_AND_PINION_PAIR" for a gear and a rack and pinion, which read as other here — cadaclysm_joint_pair_kind_name tells them apart by name); null otherwise. Borrowed, lives as long as the scene.
cadaclysm_joint_pair_kind_name
const char *cadaclysm_joint_pair_kind_name(const struct CadaclysmScene *scene, uint32_t joint);
The pair's kind by name, the kind table's own ("revolute", ..., "gear", "rack_and_pinion"; "low_order" and "other" for the two kinds with no table name): finer than cadaclysm_joint_pair_kind, which reads a gear and a rack and pinion as CADACLYSM_PAIR_OTHER and is unchanged. Null when the joint has no pair or the index is out of range. Borrowed, lives as long as the scene.
cadaclysm_joint_pair_parameters
size_t cadaclysm_joint_pair_parameters(const struct CadaclysmScene *scene,
uint32_t joint,
double *out,
size_t capacity);
The pair's own parameters, in the order pair_with takes them: screw its pitch (1 value), rack_and_pinion its pinion radius (1), gear its first radius, second radius, signed ratio (second over first), bevel and helical angle (always 5, the last two 0 where pair_with was given only the first three); no other kind has any. Returns how many the pair has — 0 for a joint with no pair or a bad index — and writes at most capacity of them to out, so a capacity of 0 (with out null) just asks the count.
cadaclysm_joint_pair_pitch
double cadaclysm_joint_pair_pitch(const struct CadaclysmScene *scene, uint32_t joint);
For CadaclysmPairKind::CADACLYSM_PAIR_SCREW: its pitch (length per revolution, in the scene's units); NaN otherwise.
cadaclysm_joint_pair_frames
bool cadaclysm_joint_pair_frames(const struct CadaclysmScene *scene,
uint32_t joint,
double *out_start,
double *out_end);
The pair's two contact frames as sixteen column-major doubles each (cadaclysm_node_transform's layout). False, writing nothing, when the joint has no pair. Either out pointer may be null.
cadaclysm_joint_freedom_count
uint32_t cadaclysm_joint_freedom_count(const struct CadaclysmScene *scene, uint32_t joint);
How many degrees of freedom the joint's pair has. 0 for a joint with no pair.
cadaclysm_joint_freedom
bool cadaclysm_joint_freedom(const struct CadaclysmScene *scene,
uint32_t joint,
uint32_t index,
struct CadaclysmFreedom *out);
One of a pair's freedoms, in the reader's per-kind order. False when out is null or the index is out of range.
cadaclysm_state_count
uint32_t cadaclysm_state_count(const struct CadaclysmScene *scene);
How many named mechanism states the file records. 0 for a file with no mechanism.
cadaclysm_state_name
const char *cadaclysm_state_name(const struct CadaclysmScene *scene, uint32_t state);
A state's name as the file gives it, or null past the end. Borrowed, lives as long as the scene.
cadaclysm_state_value_count
uint32_t cadaclysm_state_value_count(const struct CadaclysmScene *scene, uint32_t state);
How many rows (joints set) the state has.
cadaclysm_state_value
uint32_t cadaclysm_state_value(const struct CadaclysmScene *scene,
uint32_t state,
uint32_t row,
uint32_t *joint,
double *values,
uint32_t capacity);
Row row of state state: writes its joint index to *joint (CADACLYSM_NONE out of range), writes up to capacity values to values, and returns how many values the row has. Pass capacity 0 to ask the count.
cadaclysm_sequence_count
uint32_t cadaclysm_sequence_count(const struct CadaclysmScene *scene);
How many motion sequences (INTERPOLATED_CONFIGURATION_SEQUENCE) the file records. 0 for a file with none.
cadaclysm_sequence_name
const char *cadaclysm_sequence_name(const struct CadaclysmScene *scene, uint32_t sequence);
A sequence's name — its representation's, name #2 and on for a representation's further sequences — or null past the end. Borrowed, lives as long as the scene.
cadaclysm_sequence_closed
bool cadaclysm_sequence_closed(const struct CadaclysmScene *scene, uint32_t sequence);
Whether the sequence returns to its first segment (its last segment is not discontinuous). False past the end.
cadaclysm_sequence_seconds_per_unit
double cadaclysm_sequence_seconds_per_unit(const struct CadaclysmScene *scene,
uint32_t sequence);
Seconds per unit of the sequence's parameter where the file states a time unit; 0 where it states none (read the parameter as seconds) and past the end.
cadaclysm_sequence_segment_count
uint32_t cadaclysm_sequence_segment_count(const struct CadaclysmScene *scene,
uint32_t sequence);
How many segments the sequence has (at least two). 0 past the end.
cadaclysm_sequence_segment
bool cadaclysm_sequence_segment(const struct CadaclysmScene *scene,
uint32_t sequence,
uint32_t segment,
uint32_t *state,
double *t,
uint32_t *interpolation);
Segment segment of sequence sequence: its state's index into the scene's states, its parameter, and how the motion leaves it (a CadaclysmInterpolation). Each out pointer may be null. False, with nothing written, past the end.
Work schedules
cadaclysm_schedule_count
uint32_t cadaclysm_schedule_count(const struct CadaclysmScene *scene);
How many work schedules (IfcWorkSchedule) the file records. 0 for a file with none.
cadaclysm_schedule_name
const char *cadaclysm_schedule_name(const struct CadaclysmScene *scene, uint32_t s);
A schedule's name (else its identification, else schedule #k), or null past the end. Borrowed, lives as long as the scene.
cadaclysm_schedule_identification
const char *cadaclysm_schedule_identification(const struct CadaclysmScene *scene, uint32_t s);
A schedule's identification ("" where none), or null past the end. Borrowed, lives as long as the scene.
cadaclysm_schedule_kind
uint32_t cadaclysm_schedule_kind(const struct CadaclysmScene *scene, uint32_t s);
A schedule's kind, a CadaclysmScheduleKind. CADACLYSM_SCHEDULE_NOTDEFINED past the end.
cadaclysm_schedule_kind_name
const char *cadaclysm_schedule_kind_name(const struct CadaclysmScene *scene, uint32_t s);
The text of a user-defined schedule kind (CADACLYSM_SCHEDULE_OTHER); "" for every other kind; null past the end. Borrowed, lives as long as the scene.
cadaclysm_schedule_start
bool cadaclysm_schedule_start(const struct CadaclysmScene *scene, uint32_t s, double *out);
The schedule's start, in seconds since 1970-01-01T00:00, written to out. False, with nothing written, where the file gives none or past the end.
cadaclysm_schedule_finish
bool cadaclysm_schedule_finish(const struct CadaclysmScene *scene, uint32_t s, double *out);
The schedule's finish, as cadaclysm_schedule_start.
cadaclysm_task_count
uint32_t cadaclysm_task_count(const struct CadaclysmScene *scene, uint32_t s);
How many tasks schedule s has, in file order. 0 past the end.
cadaclysm_task_name
const char *cadaclysm_task_name(const struct CadaclysmScene *scene, uint32_t s, uint32_t t);
A task's name, or null past the end. Borrowed, lives as long as the scene.
cadaclysm_task_identification
const char *cadaclysm_task_identification(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t);
A task's identification ("" where none), or null past the end. Borrowed, lives as long as the scene.
cadaclysm_task_kind
uint32_t cadaclysm_task_kind(const struct CadaclysmScene *scene, uint32_t s, uint32_t t);
A task's kind, a CadaclysmTaskKind. CADACLYSM_TASK_NOTDEFINED past the end.
cadaclysm_task_kind_name
const char *cadaclysm_task_kind_name(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t);
The text of a user-defined task kind (CADACLYSM_TASK_OTHER); "" for every other kind; null past the end. Borrowed, lives as long as the scene.
cadaclysm_task_status
const char *cadaclysm_task_status(const struct CadaclysmScene *scene, uint32_t s, uint32_t t);
A task's status as the file writes it ("" where none), or null past the end. Borrowed, lives as long as the scene.
cadaclysm_task_milestone
bool cadaclysm_task_milestone(const struct CadaclysmScene *scene, uint32_t s, uint32_t t);
Whether the task is a milestone. False past the end.
cadaclysm_task_parent
bool cadaclysm_task_parent(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t,
uint32_t *out);
The summary task nesting task t, an index into the same schedule's tasks, written to out. False, with nothing written, for a top-level task or past the end.
cadaclysm_task_time
bool cadaclysm_task_time(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t,
struct CadaclysmTaskTime *out);
Every date of a task. False, with nothing written, past the end; nothing written when out is NULL.
cadaclysm_task_node_count
uint32_t cadaclysm_task_node_count(const struct CadaclysmScene *scene, uint32_t s, uint32_t t);
How many nodes task t builds or removes. 0 past the end.
cadaclysm_task_nodes
uint32_t cadaclysm_task_nodes(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t,
uint32_t *out,
uint32_t capacity);
The nodes task t builds or removes (sorted, no repeats), written to out. Returns the full count; writes min(count, capacity) of them, and nothing when out is NULL. 0 past the end.
cadaclysm_task_link_count
uint32_t cadaclysm_task_link_count(const struct CadaclysmScene *scene, uint32_t s);
How many task links (IfcRelSequence) schedule s has, in file order. 0 past the end.
cadaclysm_task_link
bool cadaclysm_task_link(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t l,
uint32_t *from,
uint32_t *to,
uint32_t *kind,
double *lag,
bool *has_lag);
Link l of schedule s: the predecessor and successor (indices into the schedule's tasks), its kind (a CadaclysmLinkKind) and its time lag in seconds, has_lag saying whether the file gives one. Each out pointer may be null. False, with nothing written, past the end.
cadaclysm_task_link_kind_name
const char *cadaclysm_task_link_kind_name(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t l);
The text of a user-defined link kind (CADACLYSM_LINK_OTHER); "" for every other kind; null past the end. Borrowed, lives as long as the scene.
cadaclysm_schedule_at
int64_t cadaclysm_schedule_at(const struct CadaclysmScene *scene,
uint32_t s,
double date,
uint32_t dates,
struct CadaclysmElementState *out,
uint32_t capacity);
What each element schedule s names is doing on date (seconds since 1970-01-01T00:00) under dates (a CadaclysmDates), in node order. Returns the full count; writes min(count, capacity) states, and nothing when out is NULL. Returns -1, with cadaclysm_last_error set, for no such schedule, a date that is not finite or any other dates.
cadaclysm_task_calendar
bool cadaclysm_task_calendar(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t,
uint32_t *out);
The work calendar task t works on, an index for the cadaclysm_calendar_* calls, written to out. False, with nothing written, for a task with no calendar or past the end.
cadaclysm_task_duration_kind
uint32_t cadaclysm_task_duration_kind(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t);
Whether a task's duration is elapsed or working time, a CadaclysmDurationKind. CADACLYSM_DURATION_UNSET where the file gives none, and past the end.
cadaclysm_task_work_duration
bool cadaclysm_task_work_duration(const struct CadaclysmScene *scene,
uint32_t s,
uint32_t t,
double *days,
double *seconds);
A task's duration in working time: days working days, then seconds of working time. Each out pointer may be null. False, with nothing written, where the task has none (an IFC2X3 task, or no duration) or past the end.
Work calendars
cadaclysm_calendar_count
uint32_t cadaclysm_calendar_count(const struct CadaclysmScene *scene);
How many work calendars (IfcWorkCalendar) the file records, in file order. 0 for a file with none.
cadaclysm_calendar_name
const char *cadaclysm_calendar_name(const struct CadaclysmScene *scene, uint32_t c);
A calendar's name (else its identification, else calendar #k), or null past the end. Borrowed, lives as long as the scene.
cadaclysm_calendar_identification
const char *cadaclysm_calendar_identification(const struct CadaclysmScene *scene, uint32_t c);
A calendar's identification ("" where none), or null past the end. Borrowed, lives as long as the scene.
cadaclysm_calendar_kind
uint32_t cadaclysm_calendar_kind(const struct CadaclysmScene *scene, uint32_t c);
A calendar's kind, a CadaclysmCalendarKind. CADACLYSM_CALENDAR_NOTDEFINED past the end.
cadaclysm_calendar_kind_name
const char *cadaclysm_calendar_kind_name(const struct CadaclysmScene *scene, uint32_t c);
The text of a user-defined calendar kind (CADACLYSM_CALENDAR_OTHER, the calendar's ObjectType); "" for every other kind; null past the end. Borrowed, lives as long as the scene.
cadaclysm_calendar_working_count
uint32_t cadaclysm_calendar_working_count(const struct CadaclysmScene *scene, uint32_t c);
How many working times calendar c has, in file order. 0 past the end.
cadaclysm_calendar_exception_count
uint32_t cadaclysm_calendar_exception_count(const struct CadaclysmScene *scene, uint32_t c);
How many exception (non-working) times calendar c has, in file order. 0 past the end.
cadaclysm_calendar_work_time
bool cadaclysm_calendar_work_time(const struct CadaclysmScene *scene,
uint32_t c,
bool exception,
uint32_t w,
struct CadaclysmWorkTime *out);
Work time w of calendar c: one of its exceptions when exception, else one of its working times. False, with nothing written, past the end; nothing written when out is NULL.
cadaclysm_calendar_work_time_name
const char *cadaclysm_calendar_work_time_name(const struct CadaclysmScene *scene,
uint32_t c,
bool exception,
uint32_t w);
A work time's name ("" where none), or null past the end. exception picks the list as cadaclysm_calendar_work_time does. Borrowed, lives as long as the scene.
cadaclysm_calendar_work_time_days
uint32_t cadaclysm_calendar_work_time_days(const struct CadaclysmScene *scene,
uint32_t c,
bool exception,
uint32_t w,
uint8_t *out,
uint32_t capacity);
A work time's pattern's days of the month (1..=31, sorted), written to out. Returns the full count; writes min(count, capacity) of them, and nothing when out is NULL. 0 past the end or without a pattern.
cadaclysm_calendar_work_time_weekdays
uint32_t cadaclysm_calendar_work_time_weekdays(const struct CadaclysmScene *scene,
uint32_t c,
bool exception,
uint32_t w,
uint8_t *out,
uint32_t capacity);
A work time's pattern's weekdays (1 = Monday ..= 7 = Sunday, sorted), as cadaclysm_calendar_work_time_days.
cadaclysm_calendar_work_time_months
uint32_t cadaclysm_calendar_work_time_months(const struct CadaclysmScene *scene,
uint32_t c,
bool exception,
uint32_t w,
uint8_t *out,
uint32_t capacity);
A work time's pattern's months (1..=12, sorted), as cadaclysm_calendar_work_time_days.
cadaclysm_calendar_work_time_periods
uint32_t cadaclysm_calendar_work_time_periods(const struct CadaclysmScene *scene,
uint32_t c,
bool exception,
uint32_t w,
double *out,
uint32_t capacity);
A work time's pattern's time periods, each a (start, end) pair in seconds after midnight, in file order, written to out as [start0, end0, start1, ...]. Returns the full count of pairs; writes min(count, capacity) pairs, and nothing when out is NULL. 0 past the end, without a pattern, or for an all-day pattern.
cadaclysm_calendar_working_periods
uint32_t cadaclysm_calendar_working_periods(const struct CadaclysmScene *scene,
uint32_t c,
double from,
double to,
double *out,
uint32_t capacity,
uint32_t *count);
Calendar c's working periods overlapping from ..= to (seconds since 1970-01-01T00:00), clipped to it, sorted and merged, written to out as [start0, end0, start1, ...]. Writes min(count, capacity) pairs (nothing when out is NULL) and the full count of pairs to count, where not null. Returns a CadaclysmCalendarStatus: _OK, _NOT_FINITE, _REVERSED (from after to), _TOO_LONG (more than 100 years apart) or _NO_SUCH_CALENDAR (a null scene, or past the end); nothing is written unless _OK.
cadaclysm_calendar_working_seconds
uint32_t cadaclysm_calendar_working_seconds(const struct CadaclysmScene *scene,
uint32_t c,
double from,
double to,
double *out);
Calendar c's working seconds in from ..= to, written to out where not null. Returns a CadaclysmCalendarStatus as cadaclysm_calendar_working_periods does.
cadaclysm_calendar_add_work
uint32_t cadaclysm_calendar_add_work(const struct CadaclysmScene *scene,
uint32_t c,
double from,
double days,
double seconds,
double *out);
The date days working days and then seconds of working time after from (before it, when negative) on calendar c, written to out where not null. A forward result at the start of a working day is reported as the end of the previous one; days = 0 adds working seconds alone. Returns a CadaclysmCalendarStatus: _OK, _NOT_FINITE, _NO_WORKING_TIME (none within 100 years) or _NO_SUCH_CALENDAR.
cadaclysm_calendar_error_message
const char *cadaclysm_calendar_error_message(uint32_t status);
The text of a CadaclysmCalendarStatus: "from and to must be finite", "from must not be after to", "no working time within 100 years", "no such calendar", "from and to must lie within 100 years of each other", and "" for _OK or a value no status names. Static: never null, never freed.
Posing
cadaclysm_pose
struct CadaclysmPose *cadaclysm_pose(const struct CadaclysmScene *scene,
const uint32_t *joints,
const uint32_t *counts,
const double *values,
uint32_t row_count,
uint32_t ground);
The mechanism posed by row_count rows: row i sets joint joints[i] to counts[i] values, taken consecutively from values (so values holds the sum of counts). ground: a link index, or CADACLYSM_NONE for the default ground. NULL on error, with the reason on cadaclysm_last_error: a null scene, a null joints/counts with row_count > 0, a null values with a non-zero sum of counts, or any PoseError (its Display text). Free with cadaclysm_pose_free.
cadaclysm_pose_state
struct CadaclysmPose *cadaclysm_pose_state(const struct CadaclysmScene *scene,
uint32_t state,
uint32_t ground);
The mechanism posed by the scene's state state. NULL on error, as cadaclysm_pose.
cadaclysm_pose_sequence
struct CadaclysmPose *cadaclysm_pose_sequence(const struct CadaclysmScene *scene,
uint32_t sequence,
double t,
uint32_t ground);
The mechanism posed by sequence sequence at parameter t (the file's own parameter; see cadaclysm_sequence_seconds_per_unit for seconds). NULL on error — no such sequence, a t that is not finite — as cadaclysm_pose.
cadaclysm_pose_free
void cadaclysm_pose_free(struct CadaclysmPose *pose);
Frees a pose made by cadaclysm_pose, cadaclysm_pose_state or cadaclysm_pose_sequence. Null is fine.
cadaclysm_pose_ground
uint32_t cadaclysm_pose_ground(const struct CadaclysmPose *pose);
The link held fixed; CADACLYSM_NONE for a null pose.
cadaclysm_pose_node_count
uint32_t cadaclysm_pose_node_count(const struct CadaclysmPose *pose);
How many node transforms the pose holds (the scene's node count); 0 for a null pose.
cadaclysm_pose_node_transform
void cadaclysm_pose_node_transform(const struct CadaclysmPose *pose,
uint32_t node,
double *out);
16 column-major doubles, cadaclysm_node_transform's layout; the identity for a null pose or a bad index; nothing written when out is NULL.
cadaclysm_pose_unsolved_count
uint32_t cadaclysm_pose_unsolved_count(const struct CadaclysmPose *pose);
How many joints close a loop and were not honoured; 0 for a null pose.
cadaclysm_pose_unsolved
uint32_t cadaclysm_pose_unsolved(const struct CadaclysmPose *pose, uint32_t index);
The index-th loop-closing joint not honoured; CADACLYSM_NONE out of range.
cadaclysm_pose_out_of_range_count
uint32_t cadaclysm_pose_out_of_range_count(const struct CadaclysmPose *pose);
How many given values fell outside their freedom's range; 0 for a null pose.
cadaclysm_pose_out_of_range
bool cadaclysm_pose_out_of_range(const struct CadaclysmPose *pose,
uint32_t index,
uint32_t *joint,
uint32_t *freedom,
double *value);
The index-th value used outside its freedom's range. False, writing nothing, out of range. Each out pointer may be NULL.
cadaclysm_kinematics_base
uint32_t cadaclysm_kinematics_base(const struct CadaclysmScene *scene);
The link the file declares as the mechanism's base; CADACLYSM_NONE when it declares none or the scene is null.
FEM meshes
cadaclysm_fem_options_init
void cadaclysm_fem_options_init(struct CadaclysmFemOptions *options);
Fill options with size set and every default in place: a chordal tolerance and no size ceiling, exactly as FemOptions::default() states them — the numbers are not restated here, so the two cannot drift.
This is the one call the size rule does not protect. cadaclysm_node_fem_mesh reads only the fields size says are there, so a caller built against an older header is safe against a newer library. This function has no such input to read: it writes sizeof(CadaclysmFemOptions) bytes as this library knows that type, and a caller compiled against an older, shorter header has only that many bytes of stack local to receive them into. Its header must be at least as new as the library it links.
cadaclysm_node_fem_mesh
struct CadaclysmFemMesh *cadaclysm_node_fem_mesh(const struct CadaclysmScene *scene,
uint32_t node,
const double *placement,
const struct CadaclysmFemOptions *options);
One node's mesh for a solver: nodes welded by bits, triangles wound outward, each node tagged with the lowest-dimension B-rep entity it lies on, and every crack reported rather than closed.
placement is null (the identity) or sixteen doubles, column-major, as cadaclysm_node_bounds_placed takes them; it is applied in f64 throughout. options is null (every default) or a struct filled by cadaclysm_fem_options_init — whose max_size bounds the boundary segments and merely targets the interior, and one small enough beside the body to reach the mesher's own piece and station ceilings is not honoured at all: CadaclysmFemMeshView::longest_edge is what the mesh actually came to, and the figure a caller that asked for an element size checks to find out whether it got one. tolerance alone decides how closely the boundary follows the geometry. (Also on CadaclysmFemOptions::max_size and CadaclysmFemMeshView::longest_edge, and stated here because a C reader meets a struct member's own comment nowhere but the header itself — the docs pages carry a struct as its declaration alone.)
The space is the body's, not the scene's, for a B-rep — and the scene's for a mesh. A B-rep body's FEM mesh is in the file's own units and axes, whatever convention the scene was opened with, because it is taken off the brep cadaclysm_node_brep hands over and that brep is in the file's own units and axes for the reason stated there: a convention converts what is drawn, and converting a brep would mean rebuilding it. A node with no brep falls back to the scene's own mesh, which is converted, so it comes back in the scene's convention. CadaclysmFemMeshView::from_mesh is the flag that says which one a caller got, and under a non-NATIVE convention the two are different spaces: a caller mixing these nodes with cadaclysm_node_transform on a Y-up scene gets a rotated part unless it reads that flag.
cadaclysm_fem_mesh_view
bool cadaclysm_fem_mesh_view(const struct CadaclysmFemMesh *m,
struct CadaclysmFemMeshView *out);
The flat arrays and the summary of one FEM mesh, into out.
false, with cadaclysm_last_error, for a null handle or a null out; nothing is written in that case.
cadaclysm_fem_mesh_edge
bool cadaclysm_fem_mesh_edge(const struct CadaclysmFemMesh *m,
uint32_t i,
struct CadaclysmFemEdge *out);
B-rep edge i of a FEM mesh, into out.
false, with cadaclysm_last_error, for a null handle, a null out, or an i at or past CadaclysmFemMeshView::edge_count; nothing is written in that case.
cadaclysm_fem_mesh_vertex
bool cadaclysm_fem_mesh_vertex(const struct CadaclysmFemMesh *m,
uint32_t i,
struct CadaclysmFemVertex *out);
B-rep vertex i of a FEM mesh, into out.
false, with cadaclysm_last_error, for a null handle, a null out, or an i at or past CadaclysmFemMeshView::vertex_count; nothing is written in that case. A vertex with no node and no position is not a failure: it comes back true with node == CADACLYSM_NONE and has_position == false.
cadaclysm_fem_mesh_open_edge
bool cadaclysm_fem_mesh_open_edge(const struct CadaclysmFemMesh *m,
uint32_t i,
uint32_t *a,
uint32_t *b,
uint32_t *brep_edge);
Crack i: a directed mesh edge (a, b) with no (b, a), and the B-rep edge both nodes lie on or CADACLYSM_NONE where they share none.
false, with cadaclysm_last_error, for a null handle, a null out-pointer, or an i at or past CadaclysmFemMeshView::open_edge_count.
Empty unless the body's topology is closed — for a B-rep body. A mesh-only body (CadaclysmFemMeshView::from_mesh) carries no topology to say whether it ought to close, so its census always runs over the welded triangles, and an empty one there really does mean "nothing found". CadaclysmFemMeshView::watertight states both contracts and which of them a caller is holding.
cadaclysm_fem_mesh_folded_edge
bool cadaclysm_fem_mesh_folded_edge(const struct CadaclysmFemMesh *m,
uint32_t i,
uint32_t *a,
uint32_t *b,
uint32_t *brep_edge);
Fold i: a directed mesh edge used by more than one triangle, with its B-rep edge as cadaclysm_fem_mesh_open_edge reports one.
A body can be folded without being open, and the closure census's own pinned rows are folds: a caller that checks only open_edge_count calls such a body sound. false, with cadaclysm_last_error, for a null handle, a null out-pointer, or an i at or past CadaclysmFemMeshView::folded_edge_count.
cadaclysm_fem_mesh_crossing_count
uint32_t cadaclysm_fem_mesh_crossing_count(const struct CadaclysmFemMesh *m);
How many pairs of this mesh's triangles pass through each other: the rows cadaclysm_fem_mesh_crossing reads. 0, with cadaclysm_last_error, for a null handle.
In its own function because CadaclysmFemMeshView cannot grow: callers allocate the view, and a new member would have this library write past the end of every v0.7 caller's.
A mesh is ready for a volume mesher when CadaclysmFemMeshView::watertight is true and this is 0: the census the view reports is topological, and cannot see a surface passing through itself.
cadaclysm_fem_mesh_crossing
bool cadaclysm_fem_mesh_crossing(const struct CadaclysmFemMesh *m,
uint32_t i,
uint32_t *a,
uint32_t *b);
Crossing i: the triangles a < b that pass through each other — an edge of one through the other's interior. Their B-rep faces are triangle_face[a] and triangle_face[b].
false, with cadaclysm_last_error, for a null handle, a null out-pointer, or an i at or past cadaclysm_fem_mesh_crossing_count; nothing is written then.
cadaclysm_fem_mesh_save_msh
bool cadaclysm_fem_mesh_save_msh(const struct CadaclysmFemMesh *m, const char *path);
Write the mesh to path as a Gmsh 4.1 ASCII .msh: an entity per B-rep vertex, edge and face, a volume where the body closes, and a physical group naming each.
The same bytes cadaclysm_fem_mesh_msh_text returns, from the same writer — the text goes straight to the file rather than through the handle's slot, so a _msh_text call on the same handle from another thread cannot free it under the write.
false, with cadaclysm_last_error, for a null handle, no path, a mesh the writer refuses, or a file it cannot write.
cadaclysm_fem_mesh_msh_text
const char *cadaclysm_fem_mesh_msh_text(const struct CadaclysmFemMesh *m);
The mesh as Gmsh 4.1 ASCII .msh text, borrowed from the handle.
The text belongs to the handle and is replaced by the next call on it: the previous text is freed under the lock, so the pointer that dies is the one a previous call returned, never one this call hands out. It dies for good with cadaclysm_fem_mesh_free. A caller that wants to keep it copies it.
One handle, one slot — not one per scene as cadaclysm_scene_svg_text's is, so two threads working on two handles never free each other's text. Two calls on one handle still race, as any two writes to one slot do: a caller that asks twice reads the first answer before it asks again, or writes files with cadaclysm_fem_mesh_save_msh, which never touches the slot.
cadaclysm_fem_mesh_free
void cadaclysm_fem_mesh_free(struct CadaclysmFemMesh *m);
Release a FEM mesh, and with it every pointer any accessor handed out and the .msh text. Null is a no-op.
Geometry
cadaclysm_node_mesh
struct CadaclysmMesh cadaclysm_node_mesh(const struct CadaclysmScene *scene, uint32_t node);
Its triangles, in their own frame and built now if they have not been.
cadaclysm_node_transform says where that frame sits in the world, and it is always *this* part's transform — the one that places the triangles below.
Where the part instances another, these are the instanced part's triangles, in the instanced part's frame. Two occurrences of one shape therefore hand back the same pointers and two different transforms, which is what lets a caller upload the mesh once. Asking the shared shape itself for its mesh gives the same answer again.
cadaclysm_node_mesh_lightmap_uvs
const float *cadaclysm_node_mesh_lightmap_uvs(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t *out_vertex_count);
This part's lightmap coordinates: two floats a vertex, in 0..1, aligned with cadaclysm_node_mesh's vertices — the same count, the same order, the same instancing (two occurrences of one shape hand back the same pointer). A second texture coordinate set for baking light: one chart per B-rep face, packed without overlap, two texels apart at the resolution asked for.
Null, with *out_vertex_count set to 0, unless the scene was opened with a non-zero CadaclysmOpenOptions.lightmap_resolution *and* this part's mesh came from a B-rep the reader charts (STEP today); a part that arrived as triangles has no faces to chart. Null for a B-rep part means its charts did not fit at that resolution. out_vertex_count may be null.
Not a field of CadaclysmMesh because that struct is returned by value: a field added to it moves its layout under every caller already compiled.
cadaclysm_node_mesh_anchored
struct CadaclysmMesh cadaclysm_node_mesh_anchored(const struct CadaclysmScene *scene,
uint32_t node,
double *out_anchor);
cadaclysm_node_mesh, with its positions taken about a point near the part rather than about the file's origin, and that point written to out_anchor as three doubles.
A position far from the origin does not survive float. The float's step is 0.06 at a million and a quarter of a unit at a survey grid's 2.6 million, so a building on its site in metres, handed over in file coordinates, arrives with every vertex snapped to that grid. Taken about a point near the part the same triangles round at the part's own size instead: each position is the mesh's less the anchor, subtracted in double before it is rounded. Normals, texture coordinates, colours and indices are not positions and are exactly cadaclysm_node_mesh's; the coarser index lists over these same vertices come from cadaclysm_node_mesh_lod_anchored.
The anchor is the centre of the mesh's own box, in the same frame as the triangles (the instanced part's, where the part instances another), so a caller puts it back as a translation composed in double — the part's point is anchor + p — and what reaches the GPU stays small. Two occurrences of one shape hand back the same pointers and the same anchor.
cadaclysm_node_mesh64
struct CadaclysmMesh64 cadaclysm_node_mesh64(const struct CadaclysmScene *scene, uint32_t node);
This part's triangles in double: cadaclysm_node_mesh's own mesh, lent rather than narrowed — see CadaclysmMesh64, and its note on forgetting. In the part's own frame, built now if it has not been; an instance lends the mesh of the shape it instances, the same pointers. All-null for a part with nothing to mesh.
cadaclysm_node_triangle_estimate
int64_t cadaclysm_node_triangle_estimate(const struct CadaclysmScene *scene, uint32_t node);
About how many triangles cadaclysm_node_mesh would give for this part, without building it — for a caller sizing a budget before it meshes: what to skip, what to take at a coarser level, how much memory a scene will want. Follows the same CadaclysmScene::shape_of hop the mesh does, so an instance answers for what it draws.
An estimate, from the reader's own knowledge of the part. A b-rep (STEP, ACIS, OCCT .brep, an IGES trimmed surface, a Rhino brep without a render mesh) is counted the way its mesher will count it — the same trims, the same grid stations — and lands within a few tens of percent of the mesh; an untrimmed IGES patch is its grid, exact; a stored or already-evaluated mesh (a .brep file's triangulation, a Rhino mesh or render mesh, an OpenSCAD model, a mesh built by an earlier call) is exact; an IFC product is exact for its extrusions and within a weld for its faceted parts. -1 where the reader cannot say without doing the work — a Rhino extrusion or SubD — and for a node that draws nothing. A caller summing a document treats -1 as unknown, not as zero.
Cheap next to meshing but not free: a STEP body is built as a b-rep to be counted, a tenth or so of meshing it.
cadaclysm_node_surface_proxy_mesh
struct CadaclysmMesh cadaclysm_node_surface_proxy_mesh(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t cells);
A coarse mesh over this part's surfaces, for the things that need triangles and not a picture. All five pointers borrow from the scene.
What it is for. A part drawn from its surfaces — see cadaclysm_realize_meshes — has no triangles, and under ray tracing it is simply absent: it casts no traced shadow, does not occlude or bounce Lumen's light, and has no distance field. Everything that traces wants triangles, and nothing that traces wants *good* ones. This grids each face cells by cells over its trim window, keeps a cell whose centre lies inside the trims, and lays two triangles across it — no welding, no chord error, a hole smaller than a cell vanishes. Never drawn; a consumer feeds it to its acceleration structure and its distance field and leaves the picture to cadaclysm_node_surfaces.
In the space everything else is in, like cadaclysm_node_mesh — a mesh converts like any other, where the surfaces it came from do not.
cadaclysm_node_bounds
struct CadaclysmBounds cadaclysm_node_bounds(const struct CadaclysmScene *scene, uint32_t node);
The extent of the geometry this part draws, in that geometry's own frame, building it if it has not been built. Carry it through cadaclysm_node_transform for world coordinates, exactly as with the mesh it bounds — and through the same indirection, so a part that instances another is bounded by what it actually draws.
cadaclysm_node_bounds64
struct CadaclysmBounds64 cadaclysm_node_bounds64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_bounds in double.
cadaclysm_node_bounds_placed
struct CadaclysmBounds cadaclysm_node_bounds_placed(const struct CadaclysmScene *scene,
uint32_t node,
const double *placement);
The extent of what this part draws under a placement, for a part drawn from its surfaces: every sample the bounds are taken from is carried through the document's convention and then placement — sixteen doubles, column-major, as cadaclysm_placement_transform writes them — before it is boxed. The box of the placed surfaces, in the placement's target frame: the same space the placed mesh would be in, the convention included, since the surfaces alone are handed over unconverted (see cadaclysm_surface_matrix) and a placement acts on converted points.
Not the placed box of the surfaces. A caller with only cadaclysm_node_bounds carries its eight corners through the placement, and the box of a rotated box is bigger than the box of the rotated points: by 8% on an assembly of rotated parts, with the centre off by 4% of the diagonal, against the box the mesh path finds from its placed vertices. This closes that gap for the surface path.
Builds the surfaces if they are not built, which a part drawn from them already has. All zeros for a part with no surfaces — a caller then places the corners of cadaclysm_node_bounds as before.
cadaclysm_node_bounds_placed64
struct CadaclysmBounds64 cadaclysm_node_bounds_placed64(const struct CadaclysmScene *scene,
uint32_t node,
const double *placement);
cadaclysm_node_bounds_placed in double.
cadaclysm_node_collision
bool cadaclysm_node_collision(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t hull_budget,
struct CadaclysmCollision *out);
The collision body for what this node draws, building its mesh if it has not been built — the same cost cadaclysm_node_bounds already carries.
hull_budget is the most triangles a hull may have; zero asks for CADACLYSM_UNITY_HULL_LIMIT. It is not clamped to it: how closely a hull should follow its part is a trade against simulation cost and belongs to whoever is building the game — Unreal's FKConvexElem has no cap at all. A hull above the limit cannot be used as a Unity convex MeshCollider, which hard-fails there.
Set out->size to sizeof(CadaclysmCollision) before calling. Returns false, writing nothing, for a null scene, an unknown node, one that draws nothing, or an out too small to hold the fields this build writes.
cadaclysm_node_collision_hull
struct CadaclysmCollisionHull cadaclysm_node_collision_hull(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t hull_budget);
The convex hull for what this node draws, or all nulls where its shape is not a hull. Builds the node's mesh if it has not been built.
The pointers borrow from the scene and are good until it is closed or until this node is asked for a different hull_budget, which refits it and frees what the previous call returned. A caller that holds hulls should hold one budget.
cadaclysm_lod_levels
uint32_t cadaclysm_lod_levels(void);
The same, as a function, for a caller that binds to symbols rather than to a header.
cadaclysm_node_mesh_lod
struct CadaclysmMesh cadaclysm_node_mesh_lod(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t level);
A part's triangles at a coarser level of detail.
level 0 is the mesh itself and gives exactly what cadaclysm_node_mesh does; 1 up to CADACLYSM_LOD_LEVELS are progressively coarser, each about a quarter of the triangles of the one before. Past that is an empty mesh.
Every level shares the level-0 vertices. positions, normals and uvs are the same pointers and the same vertex_count at every level — only indices and index_count differ. A caller uploads the vertices once and switches level by drawing a different range, which is what the levels are built the way they are to allow: see cadaclysm-lod, which collapses each edge onto an endpoint it already had rather than to a new point.
cadaclysm_node_mesh_lod_anchored
struct CadaclysmMesh cadaclysm_node_mesh_lod_anchored(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t level,
double *out_anchor);
cadaclysm_node_mesh_lod over the vertices of cadaclysm_node_mesh_anchored: the same index lists, addressing positions taken about a point near the part, and that point written to out_anchor as three doubles. Level 0 is cadaclysm_node_mesh_anchored itself.
For a caller that draws the anchored vertices and switches level by index range. Asking the plain cadaclysm_node_mesh_lod for the index lists would narrow the file-frame positions as well, only to hand back a pointer to them the caller never reads — a second copy of every vertex, held until the scene closes.
Empty, and writing three zeros, wherever cadaclysm_node_mesh_lod is empty. out_anchor may be null.
cadaclysm_node_lod_error
float cadaclysm_node_lod_error(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t level);
How far a level moved the surface, in the scene's own units — 0 at level 0, and 0 for a level that does not exist.
This is what a renderer should choose levels by, rather than by how large a part is on screen. Size says nothing about whether coarsening would show: a smooth cylinder loses three quarters of its triangles without moving its surface a thousandth of its radius, and a part covered in small features cannot lose one without it being visible. Projected through the view, this number is how many pixels wrong the level would look — which is the question actually being asked.
Measured on a radius-10 sphere: 0.027 at the first level, 0.203 at the second, 1.606 at the third.
cadaclysm_node_edges
struct CadaclysmPolylines cadaclysm_node_edges(const struct CadaclysmScene *scene,
uint32_t node);
This part's feature edges, as polylines to draw an overlay from.
Flattened by the document at the part's own scale — capi does not choose a tolerance, here or anywhere. Built on first ask and kept; both pointers borrow from the scene.
Where the part instances another, these are the instanced part's edges, the same indirection cadaclysm_node_mesh follows — an occurrence carries no geometry of its own, so its edges are the shape's it instances.
cadaclysm_node_edge_colors
struct CadaclysmEdgeColors cadaclysm_node_edge_colors(const struct CadaclysmScene *scene,
uint32_t node);
This part's edge colours, one per polyline of cadaclysm_node_edges — see CadaclysmEdgeColors. Built with the edges, in the same cache.
cadaclysm_node_surface_edges
struct CadaclysmPolylines cadaclysm_node_surface_edges(const struct CadaclysmScene *scene,
uint32_t node);
This part's face boundaries, taken from its trimmed surfaces. Both pointers borrow from the scene.
The outline that costs no tessellation, and the reason it exists. Both other edge products mesh the part: cadaclysm_node_edges hands back the chords the mesher walked, and cadaclysm_node_edge_beziers resolves the mesh too, because a B-rep reader gives one builder that produces triangles and edges together. So a caller that carefully skipped meshing a body — see cadaclysm_realize_meshes — gets every triangle back the moment it draws an outline, and the memory with them.
These are the same trim loops cadaclysm_node_surfaces hands to a shader, evaluated through their surfaces, so the outline sits on the surface actually being drawn. Against triangles it is the wrong product and cadaclysm_node_edges is the right one: the surface is not where the triangles are, and an outline drawn on it z-fights them. That is the choice, and it belongs to whoever knows which of the two is on screen.
cadaclysm_node_surface_edge_beziers
struct CadaclysmBeziers cadaclysm_node_surface_edge_beziers(const struct CadaclysmScene *scene,
uint32_t node);
This part's edges as the exact curves, where the reader has them without meshing — and empty everywhere else, so a caller drawing from surfaces tries this first and falls back to cadaclysm_node_surface_edges. Borrowed from the scene until it is closed.
When not empty, the same segments cadaclysm_node_edge_beziers returns, in the same convention — not the surfaces' own frame the trims are in, so they take no cadaclysm_surface_matrix. Asking never meshes the part.
cadaclysm_node_surface_edge_colors
struct CadaclysmEdgeColors cadaclysm_node_surface_edge_colors(const struct CadaclysmScene *scene,
uint32_t node);
This part's surface edge colours, one per polyline of cadaclysm_node_surface_edges — see CadaclysmEdgeColors. Built with the surface edges, in the same cache.
cadaclysm_node_surface_isocurves
struct CadaclysmPolylines cadaclysm_node_surface_isocurves(const struct CadaclysmScene *scene,
uint32_t node);
This part's isocurves, taken from its trimmed surfaces and clipped to the trims. Both pointers borrow from the scene.
These are the surface's own isoparametric curves: lines at its bend lines where it has them — a NURBS's interior knots, a swept profile's breakpoints — and an even spread where it has none, so a cylinder is not left blank. A flat face gets none: an isocurve across a plane says nothing its boundary has not.
Each line is broken wherever it leaves the trims, so a line crossing a hole comes back as two runs rather than one line straight over it.
cadaclysm_node_edge_beziers
struct CadaclysmBeziers cadaclysm_node_edge_beziers(const struct CadaclysmScene *scene,
uint32_t node);
This part's feature edges as Bézier segments — the exact curves the polylines from cadaclysm_node_edges were flattened from.
cadaclysm_node_edge_beziers64
struct CadaclysmBeziers64 cadaclysm_node_edge_beziers64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_edge_beziers in double: the same segments, unnarrowed — see CadaclysmBeziers64. Borrowed from the scene until it is closed.
cadaclysm_node_surfaces
struct CadaclysmSurfaces cadaclysm_node_surfaces(const struct CadaclysmScene *scene,
uint32_t node);
This part's faces as surfaces and trims — see CadaclysmSurfaces.
The parametric product, and the trimmed one. A face carries the surface it sits on and the loops that cut it, both in that surface's own (u, v), so a caller evaluates the surface at whatever density its view needs and tests the point it already has against the loops. Nothing here was flattened to triangles.
In the file's own frame — see cadaclysm_surface_matrix.
cadaclysm_node_gpu_surfaces
struct CadaclysmGpuSurfaces *cadaclysm_node_gpu_surfaces(const struct CadaclysmScene *scene,
uint32_t node,
double tolerance);
This part's exact faces packed for a GPU surface evaluator, and its exact edges: the records a viewer uploads to draw the part from its surfaces rather than its triangles, positions about the faces' own centre. tolerance (model units, positive) sets the trims and the edges — a viewer takes it from the part's size.
Owned by the caller, unlike the borrowed arrays elsewhere here: free it with cadaclysm_gpu_surfaces_free. It is built on every call, because the answer depends on the tolerance. Where the part instances another, these are the instanced part's faces, the same indirection cadaclysm_node_mesh follows.
NULL, with the reason at cadaclysm_last_error, for a null scene, a node out of range, a tolerance that is not a positive finite number, or a part with no exact faces (every mesh-only format, and a B-rep this path cannot express).
cadaclysm_gpu_surfaces_free
void cadaclysm_gpu_surfaces_free(struct CadaclysmGpuSurfaces *surfaces);
Frees what cadaclysm_node_gpu_surfaces handed out. NULL is allowed.
cadaclysm_node_surfaces_anchored
struct CadaclysmSurfaces cadaclysm_node_surfaces_anchored(const struct CadaclysmScene *scene,
uint32_t node,
double *out_anchor);
cadaclysm_node_surfaces, packed about a point near the part rather than about the file's origin, and that point written to out_anchor as three doubles.
A position far from the origin does not survive float. The float's step is 0.06 at a million and a quarter of a unit at a survey grid's 2.6 million, so a building on its site in metres, handed over in file coordinates, arrives with every frame origin and control point snapped to that grid: a lopsided dome, crumpled column caps, a leaning tower. Taken about a point near the part the same data rounds at the part's own size instead. Every position — a frame's origin, a revolution's axis point, a sum's base, a swept profile's samples, a NURBS net — is the file's position less the anchor, subtracted in double before it is rounded; directions, radii, angles and the trims' (u, v) are not positions and are as cadaclysm_node_surfaces gives them.
The anchor is the centre of the part's surface bounds, in the same frame as the faces (the file's — see cadaclysm_surface_matrix), so a caller puts it back as a translation composed in double: the file's point is anchor + p, and what reaches the GPU stays small. A caller that draws a far part this way loses nothing it had.
cadaclysm_node_surface_pick
bool cadaclysm_node_surface_pick(const struct CadaclysmScene *scene,
uint32_t node,
const double *from,
const double *to,
double *out_point);
Where a segment first meets one part's surfaces, written to out_point as three doubles. False, writing nothing, where it meets none — or for a null scene, an unknown node, or a part with no surfaces.
Why a caller wants this at all. A part drawn from its surfaces has no triangles to trace against, because cadaclysm_realize_meshes never built them. And a part that does have them is traced only as accurately as it was meshed, so the rim of a hole picks to the mesher's chord error. This answers from the surface itself and tests the trims at the answer's own (u, v), which is exact.
In the surfaces' own frame, like cadaclysm_node_surfaces and for the same reason — see cadaclysm_surface_matrix. A caller holding a ray in the space everything else is in carries it through that matrix's inverse first. That is deliberately its job rather than this function's: a renderer drawing these already built the matrix to draw them with, and a pick that agrees with the picture must use the very same one rather than a second copy composed here.
cadaclysm_node_curve_beziers
struct CadaclysmBeziers cadaclysm_node_curve_beziers(const struct CadaclysmScene *scene,
uint32_t node);
This part's free curves as Bézier segments — see cadaclysm_node_edge_beziers.
cadaclysm_node_curve_beziers64
struct CadaclysmBeziers64 cadaclysm_node_curve_beziers64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_edge_beziers64 for this part's free curves — see cadaclysm_node_curve_beziers.
cadaclysm_node_isocurve_beziers
struct CadaclysmBeziers cadaclysm_node_isocurve_beziers(const struct CadaclysmScene *scene,
uint32_t node);
This part's isocurves as Bézier segments — see cadaclysm_node_edge_beziers, and cadaclysm_node_isocurves for what an isocurve is.
cadaclysm_node_isocurve_beziers64
struct CadaclysmBeziers64 cadaclysm_node_isocurve_beziers64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_edge_beziers64 for this part's isocurves — see cadaclysm_node_isocurve_beziers.
cadaclysm_node_curves
struct CadaclysmPolylines cadaclysm_node_curves(const struct CadaclysmScene *scene,
uint32_t node);
This part's free curves, as polylines — see cadaclysm_node_edges, which this differs from only in which document method it asks.
cadaclysm_node_isocurves
struct CadaclysmPolylines cadaclysm_node_isocurves(const struct CadaclysmScene *scene,
uint32_t node);
This part's isocurves, as polylines — see cadaclysm_node_edges, which this differs from only in which document method it asks.
An isocurve is one of the interior isoparametric lines across a curved face — a cylinder's mid-height ring, a sphere's meridian — not its boundary. A flat face has none of its own, but where the source format gives no isocurves directly, the document falls back to slicing them from the mesh, and that fallback draws a flat face's own outline rather than nothing — so an empty result here is not guaranteed just because a face is planar.
cadaclysm_node_surface_edges64
struct CadaclysmPolylines64 cadaclysm_node_surface_edges64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_surface_edges in double: the outline drawn from the trims, without its per-edge colours (see cadaclysm_node_surface_edge_colors, which are the same runs in the same order). Borrowed from the scene.
For a caller drawing a far part's outline. A site on its survey grid, handed over in float, has its outline snapped to a quarter unit there: the edges wander off faces the surface path draws exactly. In double a caller takes them about a point near the part first, as it does the faces (see cadaclysm_node_surfaces_anchored).
cadaclysm_node_surface_edge_beziers64
struct CadaclysmBeziers64 cadaclysm_node_surface_edge_beziers64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_surface_edge_beziers in double: the same exact edges, unnarrowed — see CadaclysmBeziers64, and cadaclysm_node_surface_edges64 for why. Empty where cadaclysm_node_surface_edge_beziers is. Borrowed from the scene.
cadaclysm_node_surface_isocurves64
struct CadaclysmPolylines64 cadaclysm_node_surface_isocurves64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_surface_isocurves in double — see cadaclysm_node_surface_edges64 for why. Borrowed from the scene.
cadaclysm_node_edges64
struct CadaclysmPolylines64 cadaclysm_node_edges64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_edges in double. The document's feature edges exactly as it flattens them for drawing (get_edges_as_polylines), without their per-edge colours — see cadaclysm_node_edge_colors for those. Borrowed from the scene.
cadaclysm_node_curves64
struct CadaclysmPolylines64 cadaclysm_node_curves64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_curves in double. Borrowed from the scene.
cadaclysm_node_isocurves64
struct CadaclysmPolylines64 cadaclysm_node_isocurves64(const struct CadaclysmScene *scene,
uint32_t node);
cadaclysm_node_isocurves in double. Borrowed from the scene.
cadaclysm_node_is_meshed
bool cadaclysm_node_is_meshed(const struct CadaclysmScene *scene, uint32_t node);
Whether this part's mesh has been built and is held, by cadaclysm_realize_all, by an ask for it, or by anything else that needed it — the edge overlay, say. A consumer drawing the part from its surfaces, and meaning never to pay for its triangles, checks it did not. False for a null scene or an unknown part; through the same indirection as the mesh, so a part that instances another answers for what it draws.
cadaclysm_node_brep
const struct CadaclysmBrep *cadaclysm_node_brep(const struct CadaclysmScene *scene,
uint32_t node);
The part's exact brep, for the blacksmith library to operate on (cadaclysm_blacksmith_from_brep): a reference of the caller's own on the scene's brep, not a copy, given back with cadaclysm_brep_release. Good past cadaclysm_close: the brep lives until its last holder lets go. Asking twice gives the same pointer and two references.
In the part's own frame, as cadaclysm_node_mesh is — cadaclysm_node_transform places it — and following the same hop from an instance to the shape it draws. In the file's own units and axes, whatever convention the scene was opened with, as cadaclysm_node_surfaces is: a convention converts what is drawn, and converting a brep would mean rebuilding it.
Null, with cadaclysm_last_error saying why, where the part is not a B-rep: a mesh, a curve, a CSG or tessellated body, a mesh-only part (an open OpenSCAD polyhedron, or an OpenSCAD file read without the kernel). The B-rep readers are STEP (AP203/214/242), ACIS, Rhino, OCCT .brep, IGES (each surface a one-face sheet), IFC (a product's solids, openings cut, as one brep) and OpenSCAD (each region's solid, where the kernel is linked). Built on first ask where the reader had not built it already (STEP, IGES, IFC).
cadaclysm_node_svg_text
const char *cadaclysm_node_svg_text(const struct CadaclysmScene *scene,
uint32_t node,
const struct CadaclysmSvgOptions *options);
One shape in its own frame, no placement: one <g id="node-<index>">. Otherwise as cadaclysm_scene_svg_text, the text in the same per-scene slot with the same lifetime — one slot serves both entry points, so the same serialising applies to callers sharing a scene across threads.
cadaclysm_node_svg
bool cadaclysm_node_svg(const struct CadaclysmScene *scene,
uint32_t node,
const char *path,
const struct CadaclysmSvgOptions *options);
cadaclysm_node_svg_text's drawing written to path, as cadaclysm_scene_svg — the scene's svg_text slot untouched.
cadaclysm_node_silhouette_beziers
struct CadaclysmBeziers64 cadaclysm_node_silhouette_beziers(const struct CadaclysmScene *scene,
uint32_t node,
const struct CadaclysmSvgOptions *options);
This part's silhouette curves as Bézier segments — the curves where its surfaces turn away from the eye, which no edge of the body lies on.
The eye is the options' own view words (up, azimuth, elevation, fov), so the same options that draw a picture ask about the same eye. tolerance and width are read together, as a page tolerance turned into a world one (width is how the page fraction tolerance / width is read off, so it is read, not ignored, despite naming a page dimension). size is checked (as every struct here is) but names no camera word. height, margin, stroke*, background and flags are unread — flags in particular: a silhouette query asks for an eye and a tolerance, never a line set, so flags = 0 (no line set at all, which a drawing refuses) is accepted here same as any other value of it.
The arrays borrow from the scene and are valid until the next silhouette call on this scene, like cadaclysm_node_svg_text's string and unlike the edge accessors, which can cache per node because they take no eye — one slot serves every node, so a different node's call replaces this one's too. A refused call leaves the slot, and any pointer a caller already holds from it, untouched. Two threads calling this on one scene free each other's arrays: callers sharing a scene across threads serialise their silhouette calls (and the reads of what they return) themselves, the same contract cadaclysm_scene_svg_text documents for svg_text.
cadaclysm_node_mesh_faces
const uint32_t *cadaclysm_node_mesh_faces(const struct CadaclysmScene *scene,
uint32_t node,
uint32_t *count);
One B-rep face index per triangle of cadaclysm_node_mesh, numbered as cadaclysm_node_surfaces numbers faces (face f is surfaces.faces[f]), and the triangle count written to count.
A triangle whose face has no entry in surfaces.faces — a zero-area face the surface build skips, so the list is packed and the faces after it move down one — holds CADACLYSM_NONE (UINT32_MAX) instead of a face number. Every other entry is below surfaces.face_count.
NULL, with *count 0, for a part with no B-rep behind its triangles: a mesh the file carried, a CSG body, a reader that does not track faces. Meshes the part if it has not been. The pointer borrows from the scene like the mesh's own and is good until the scene is closed or cadaclysm_forget_meshes is called. Instances answer for the shape they instance, as cadaclysm_node_mesh does.
cadaclysm_node_mesh_deviation
double cadaclysm_node_mesh_deviation(const struct CadaclysmScene *scene, uint32_t node);
The worst distance, in the part's own frame and units, from this part's display mesh to the exact surfaces it was meshed from: measured once, against the face cadaclysm_node_mesh_faces names for each triangle, and kept. Negative when it cannot be known — no B-rep, no face list. What a ray tracer offsets a ray by when it starts on an exact surface and tests against these triangles.
Closed form on the analytic faces (planes, cylinders, cones, spheres, tori), at every triangle's three edge midpoints and its centroid (a flat triangle on a doubly curved face sags deepest inside); exact on spheres, where the deepest point of the triangle is used. Where any triangle is on a freeform face (NURBS, revolutions, extrusions), or names no face, the figure is no less than the mesher's own sag at default quality, the part's largest bounding-box axis over 217 — an overstatement, the safe side for a ray offset.
Building everything
cadaclysm_forget_meshes
void cadaclysm_forget_meshes(struct CadaclysmScene *scene);
Drop every mesh built so far, keeping the document and its node tree.
For a caller that is done with the geometry but not with the file. Names, properties, the shape of the assembly and cadaclysm_query all keep working afterwards; what goes is the built geometry this library was holding beside the copy the caller has already taken. A viewer that has uploaded its meshes to the GPU, or an engine plugin that has copied them into its own buffers, is otherwise paying for two of everything for as long as it keeps the scene open to ask questions of it.
Nothing breaks. A node asked for again simply meshes again — the cache is an optimisation, and this trades time later for memory now. Bounds are kept, being a box per node against a mesh of millions of triangles, and re-deriving one would mean building that mesh again just to cull it. The one exception: the pointers cadaclysm_node_mesh64 handed out are the document's own mesh (see CadaclysmMesh64), and are freed by this call along with it; the float mesh's pointers and the f64 Béziers' survive, each a separate cache this call does not touch.
cadaclysm_realize_all
uint32_t cadaclysm_realize_all(const struct CadaclysmScene *scene);
Build every mesh in the document now, rather than as each is asked for.
Reading is lazy so a caller can put the tree on screen while the shapes are still to come. A caller that would rather pay it all up front — one honest progress bar, or an exporter that needs the lot anyway — calls this. Returns how many parts were realized.
Threaded inside. Call it on one thread and watch it with cadaclysm_realized from another, or stop it with cadaclysm_cancel.
cadaclysm_realize_meshes
uint32_t cadaclysm_realize_meshes(const struct CadaclysmScene *scene, uint32_t skip_surfaced);
As cadaclysm_realize_all, leaving alone every node that carries surfaces where skip_surfaced is non-zero.
What makes surfaces cheaper rather than dearer. A body's mesh is built on demand and cached, so a caller who never asks for it never pays — but cadaclysm_realize_all asks for every node, which is right when triangles are what will be drawn and exactly wrong when they are not. A renderer drawing a part from its surfaces passes a one here, takes that part's bounds from cadaclysm_node_bounds (which falls back to the surfaces), and never asks for its mesh at all.
Nodes without surfaces are realized as usual: a part the reader could not express is drawn from triangles and still needs them.
cadaclysm_realized
uint32_t cadaclysm_realized(const struct CadaclysmScene *scene);
How many parts cadaclysm_realize_all has finished with. Safe to read from another thread while it runs.
cadaclysm_realize_total
uint32_t cadaclysm_realize_total(const struct CadaclysmScene *scene);
How many there will be in all — zero until cadaclysm_realize_all starts.
cadaclysm_cancel
void cadaclysm_cancel(const struct CadaclysmScene *scene);
Ask a running cadaclysm_realize_all to stop.
It stops between parts, so this is prompt without abandoning half a mesh. What was already built is kept, and the scene still answers one part at a time afterwards — cancelling gives up on the batch, not on the document.
One-way, and for the life of the scene. Nothing clears the flag, so every later cadaclysm_realize_all on this scene returns 0 at once. A UI that offers "Cancel" and then "Load anyway" cannot do the second on the same handle: it must close the scene and open the file again. (Clearing the flag when realize_all starts is not the fix — it would race a cancel arriving from another thread just as the batch begins, and swallow it.) Meshes stay available one part at a time either way, so a caller that only wants the model on screen need not reopen.
Formats and dialogs
cadaclysm_mesh_format_count
uint32_t cadaclysm_mesh_format_count(void);
How many formats cadaclysm_node_save_mesh accepts.
A caller builds its export menu from this and its neighbours — cadaclysm_mesh_format_label for what to show, cadaclysm_mesh_format for what to pass back — rather than from a list of its own, so a format added to the library appears in every client that already asks.
cadaclysm_mesh_format
const char *cadaclysm_mesh_format(uint32_t index);
The name of one format, or null past the end.
An identifier, not display text: this is the exact string cadaclysm_node_save_mesh's format parameter accepts back ("stl", "stl-ascii", "msh") — it would read poorly in a menu, which is what cadaclysm_mesh_format_label is for. The pointer is static and stays valid for the life of the process.
cadaclysm_mesh_format_extension
const char *cadaclysm_mesh_format_extension(uint32_t index);
The file extension one format should be written with, without the dot, or null past the end.
Not the format name: stl-ascii writes a .stl. A client naming an output file asks for this rather than deriving it, which is the difference between a format whose name and extension differ working everywhere and working nowhere.
The pointer is static and stays valid for the life of the process.
cadaclysm_mesh_format_label
const char *cadaclysm_mesh_format_label(uint32_t index);
The name a person should see for one format in a save dialog or export menu — "STL (binary)", "STL (ASCII)", "Gmsh" — or null past the end.
Display text, not an identifier: unlike cadaclysm_mesh_format, the string this returns cannot be passed back into cadaclysm_node_save_mesh's format parameter — pass the value from cadaclysm_mesh_format at the same index for that. The two exist side by side because they answer different questions ("what do I show?" vs. "what do I pass back?"), the same split cadaclysm_format_name and cadaclysm_format_extensions have on the read side.
The pointer is static and stays valid for the life of the process.
cadaclysm_format_count
uint32_t cadaclysm_format_count(void);
How many input formats this build can read.
The counterpart to cadaclysm_mesh_format_count, which answers for writing. A host builds a file dialog, an import menu or a drag-and-drop test from these rather than hardcoding extensions, so adding a reader updates it for free.
This is what the build can read, and with the schemas built in it is also what opens: a STEP or IFC file needs an extra schema only where it names one the project does not ship.
cadaclysm_format_name
const char *cadaclysm_format_name(uint32_t index);
The name of one input format — "STEP", "Rhino 3DM". Static; never freed. Null if index is past the end.
Display text, not an identifier: this is for showing to a person, the same kind of string cadaclysm_mesh_format_label returns on the write side — unlike cadaclysm_mesh_format, nothing accepts this string back as input. A reader is chosen by file extension, not by this name, which is why there is no read-side counterpart to format in cadaclysm_node_save_mesh.
cadaclysm_format_extensions
const char *cadaclysm_format_extensions(uint32_t index);
That format's extensions, semicolon-separated and without dots — "step;stp".
Semicolons because that is the separator every platform dialog wants, and because a caller who needs them apart can split more easily than one holding an array can join.
These are exactly the strings cadaclysm_open_memory's format argument accepts, split on ; — a host that recognises .step from this list already knows the value to pass there.
cadaclysm_pick_file
const char *cadaclysm_pick_file(const struct CadaclysmWindow *parent);
Ask the user for a file to open, filtered to what this build can read.
Blocks the calling thread until the user picks or cancels — what a modal dialog is. On macOS, call it from the main thread: a non-windowed process cannot open a dialog off it at all, and the symptom is a hang, not an error.
Returns a UTF-8 path that must not be freed and must not be kept past the next picker call on this thread — the same rule as cadaclysm_last_error. Copy it if it needs to outlive that. NULL means the user cancelled, no dialog was available, or this build has no picker; the reason is at cadaclysm_last_error for the last two, and nothing for the first.
cadaclysm_pick_save
const char *cadaclysm_pick_save(const struct CadaclysmWindow *parent,
const char *suggested_name);
Ask the user where to save, offering the formats this build can write.
Same blocking, threading and lifetime rules as cadaclysm_pick_file.
Meshlets
cadaclysm_meshlets_build
struct CadaclysmMeshlets *cadaclysm_meshlets_build(const float *positions,
const float *normals,
size_t vertex_count,
const uint32_t *indices,
size_t index_count,
uint32_t max_triangles,
uint32_t max_vertices,
int32_t levels);
Split a mesh into meshlets, optionally with the coarser levels above them.
positions and normals are three floats a vertex; normals may be null. indices is three per triangle.
max_triangles and max_vertices are the consumer's own limits, and there is no default, because a meshlet built for one consumer cannot be handed to another: Nanite packs a triangle count in 7 bits and a vertex count in 8, so its limits are 128 and 256, while a mesh-shader pipeline caps at 124 and 64. The vertex cap is the one that bites, since vertices are shared and a meshlet can sit well under its triangle limit while walking past its vertex limit.
cadaclysm_meshlets_count
uint32_t cadaclysm_meshlets_count(const struct CadaclysmMeshlets *handle);
How many meshlets a build came to, over every level.
cadaclysm_meshlet_triangle_count
uint32_t cadaclysm_meshlet_triangle_count(const struct CadaclysmMeshlets *handle,
uint32_t index);
How many triangles one meshlet holds.
cadaclysm_meshlet_vertex_count
uint32_t cadaclysm_meshlet_vertex_count(const struct CadaclysmMeshlets *handle, uint32_t index);
How many vertices one meshlet holds.
cadaclysm_meshlet_level
uint32_t cadaclysm_meshlet_level(const struct CadaclysmMeshlets *handle, uint32_t index);
Which level a meshlet belongs to; 0 is full detail.
cadaclysm_meshlet_group
uint32_t cadaclysm_meshlet_group(const struct CadaclysmMeshlets *handle, uint32_t index);
Which group of its level a meshlet belongs to.
Groups are simplified together, and the boundary between them is what must not move.
cadaclysm_meshlet_error
float cadaclysm_meshlet_error(const struct CadaclysmMeshlets *handle, uint32_t index);
How far a meshlet's geometry may sit from the original, in the mesh's own units.
cadaclysm_meshlet_child_count
uint32_t cadaclysm_meshlet_child_count(const struct CadaclysmMeshlets *handle, uint32_t index);
How many meshlets one stands in for. Zero at level 0.
cadaclysm_meshlet_positions
void cadaclysm_meshlet_positions(const struct CadaclysmMeshlets *handle,
uint32_t index,
float *out);
Three floats a vertex.
cadaclysm_meshlet_normals
void cadaclysm_meshlet_normals(const struct CadaclysmMeshlets *handle,
uint32_t index,
float *out);
Three floats a vertex, or nothing where the mesh carried no normals.
cadaclysm_meshlet_indices
void cadaclysm_meshlet_indices(const struct CadaclysmMeshlets *handle,
uint32_t index,
uint32_t *out);
Three indices a triangle, into this meshlet's own vertices.
cadaclysm_meshlet_children
void cadaclysm_meshlet_children(const struct CadaclysmMeshlets *handle,
uint32_t index,
uint32_t *out);
The meshlets this one stands in for, as indices into the same build.
cadaclysm_meshlets_free
void cadaclysm_meshlets_free(struct CadaclysmMeshlets *handle);
Release a build.
Exact B-reps
cadaclysm_brep_layout_id
const char *cadaclysm_brep_layout_id(void);
This library's brep layout: the compiler, target, profile and source it was built from, as one string. Pass it beside a brep to cadaclysm_blacksmith_from_brep, which refuses a brep laid out by any other build. Static; never freed.
cadaclysm_brep_release
void cadaclysm_brep_release(const struct CadaclysmBrep *brep);
Give back a reference cadaclysm_node_brep handed out. The last holder's release frees the brep. Null is a no-op.
cadaclysm_brep_manifold
bool cadaclysm_brep_manifold(const struct CadaclysmBrep *brep, uint32_t *out);
Whether the brep's faces make a manifold, read off its topology — the edges and loops the file gave it — rather than a mesh: nothing is tessellated. Eight counts into out, in order: faces, edges, vertices, boundary edges (bordered by one face), non-manifold edges (by three or more), non-manifold vertices (where the faces round a point make more than one fan: two solids touching at a corner), then 1 if it is a manifold (no non-manifold edge or vertex) and 1 if it is also closed (no boundary edge: it encloses a solid), else 0.
The answer is about the topology the file wrote. Faces that name no shared edge — an IGES body, each surface its own sheet; an IFC face given as one closed polygon; STEP CURVE_BOUNDED_SURFACEs — read as open, every edge a boundary, however well they meet in space. Orientation is not asked. false (and cadaclysm_last_error) on a null argument.
cadaclysm_brep_sew
const struct CadaclysmBrep *cadaclysm_brep_sew(const struct CadaclysmBrep *brep,
double tolerance,
double vertex,
uint32_t *out,
double *gaps);
The brep with its free edges sewn: every pair of free edges whose two ends coincide within vertex and whose curves lie within tolerance of each other becomes one shared edge (TrimmedBrep::sewed). A new brep, released with cadaclysm_brep_release; brep itself is untouched. Nothing moves: only which faces share an edge, and how loose an edge is said to be, change.
NaN for either tolerance takes its default: vertex the rounding cadaclysm_brep_manifold merges vertices at, tolerance equal to vertex, so only edges that are one curve to a rounding are sewn. A value outside the legal range takes the default too (vertex not finite or not positive, tolerance negative; +inf tolerance is legal), and the figures in gaps show what was used. Four counts into out — edges joined, free edges before, free edges after, groups refused (two or more free edges between the same two vertices left free: too far apart, or more than two) — and three figures into gaps: the widest gap sewn, then the tolerance and vertex used. Either may be NULL. NULL (and cadaclysm_last_error) for a NULL brep.
cadaclysm_brep_health
struct CadaclysmHealth *cadaclysm_brep_health(const struct CadaclysmBrep *brep,
double tolerance,
bool mesh);
Diagnose a brep: its free edges and the wires they chain into, the features smaller than tolerance, what a dry-run sew would do, and (with mesh) the cracks of its mesh. brep is left as it was. NaN or tolerance <= 0 takes the default, 1e-4 times the diagonal of the body's edge points; the report's sizes[0] says what was used. With mesh the body is also meshed at that tolerance, which costs time on a large body.
A report handle, read with the cadaclysm_brep_health_* accessors and freed with cadaclysm_brep_health_free; null (and cadaclysm_last_error) on a null brep or a panic inside the diagnosis (the message starts panicked:).
cadaclysm_brep_health_free
void cadaclysm_brep_health_free(struct CadaclysmHealth *health);
Free a report. Null is a no-op.
cadaclysm_brep_health_summary
bool cadaclysm_brep_health_summary(const struct CadaclysmHealth *health,
uint32_t *counts,
double *sizes);
The report's figures. counts, eighteen uint32_t, in order: free edges, wires, closed wires, small features, short edges, collapsed edges, sliver faces, tiny faces, tiny body, loose edges, sew pairs, sew refused, meshed, watertight, open, folded, crossings, crack edges (the last six are 0 unless the report was made with mesh, and meshed is 1 then). sizes, eight double: tolerance used, rounding, extent, worst free-edge gap (largest finite, 0 if none), worst loose edge, sew worst gap, shortest edge, narrowest face (0 if none). Either output may be null; not both. false (and cadaclysm_last_error) on a null health or both outputs null.
cadaclysm_brep_health_free_edges
uint32_t cadaclysm_brep_health_free_edges(const struct CadaclysmHealth *health,
uint32_t *ids,
double *sizes);
The free edges (the sides one face bounds), one row each: ids, six uint32_t per edge — trim, edge, face, wire, partner, shared ends (edge and partner are UINT32_MAX where there is none); sizes, two double per edge — length, gap to its partner (+inf with none). Returns the count; with both buffers null it writes nothing, so call it twice: once to size the buffers, once to fill them. A non-null buffer must hold the whole count. Zero (and cadaclysm_last_error) on a null health.
cadaclysm_brep_health_wires
uint32_t cadaclysm_brep_health_wires(const struct CadaclysmHealth *health,
uint32_t *runs,
double *sizes);
The free wires (the free edges chained end to end), one row each: runs, three uint32_t per wire — first, count, closed (the free-edge rows it covers); sizes, two double — length, widest gap. Returns the count, with the two-call convention of cadaclysm_brep_health_free_edges.
cadaclysm_brep_health_small
uint32_t cadaclysm_brep_health_small(const struct CadaclysmHealth *health,
uint32_t *items,
double *sizes);
The features below the tolerance, one row each: items, two uint32_t — kind (0 short edge, 1 collapsed edge, 2 sliver face, 3 tiny face, 4 tiny body, 5 small hole), index (a hole's is its loop); sizes, one double — its size. Returns the count, with the two-call convention of cadaclysm_brep_health_free_edges.
cadaclysm_brep_health_crack_edges
uint32_t cadaclysm_brep_health_crack_edges(const struct CadaclysmHealth *health, uint32_t *ids);
The edge ids the mesh cracks along (none unless the report was made with mesh). Returns the count, with the two-call convention of cadaclysm_brep_health_free_edges.
cadaclysm_brep_healed
struct CadaclysmHeal *cadaclysm_brep_healed(const struct CadaclysmBrep *brep,
double tolerance,
uint32_t flags);
Remove the features smaller than tolerance that cadaclysm_brep_health lists as small: short and collapsed edges, sliver and tiny faces, small holes. Every fix is a vertex merge; each edge moved records how far as its tolerance (cadaclysm_brep_edge_tolerance). A guard compares the result's health with the input's and refuses fixes that made it worse (the summary's guarded). brep is left as it was. NaN or tolerance <= 0 takes the default, 1e-4 times the diagonal of the body's edge points; the summary's sizes[0] says what was used. flags picks what is fixed: 1 edges, 2 faces, 4 holes, 7 all; a kind switched off is refused as toggled.
A report handle, read with the cadaclysm_brep_heal_* accessors and freed with cadaclysm_brep_heal_free; null (and cadaclysm_last_error) on a null brep or a flag bit other than those three, or a panic inside the heal (the message starts panicked:).
cadaclysm_brep_heal_body
const struct CadaclysmBrep *cadaclysm_brep_heal_body(const struct CadaclysmHeal *h);
The healed body: a new reference the caller releases with cadaclysm_brep_release. It outlives the report. Null (and cadaclysm_last_error) on a null h.
cadaclysm_brep_heal_free
void cadaclysm_brep_heal_free(struct CadaclysmHeal *h);
Free a report. Null is a no-op. A body taken with cadaclysm_brep_heal_body stays good.
cadaclysm_brep_heal_summary
bool cadaclysm_brep_heal_summary(const struct CadaclysmHeal *h,
uint32_t *counts,
double *sizes);
The report's figures. counts, eleven uint32_t, in order: fixes, refused, guarded, small before, small after, free edges before, free edges after, closed before, closed after, non-manifold edges before, non-manifold edges after (before and after are the input's and the result's health at the tolerance used). sizes, two double: the tolerance used, the furthest any trim moved. Either output may be null; not both. false (and cadaclysm_last_error) on a null h or both outputs null.
cadaclysm_brep_heal_fixes
uint32_t cadaclysm_brep_heal_fixes(const struct CadaclysmHeal *h,
uint32_t *items,
double *sizes);
The features removed, in the order they were, one row each: items, two uint32_t — kind (0 short edge, 1 collapsed edge, 2 sliver face, 3 tiny face, 4 tiny body, 5 small hole), index (as in cadaclysm_brep_health_small, of the input); sizes, two double — its size, the furthest a vertex it merged moved. Returns the count; with both buffers null it writes nothing, so call it twice: once to size the buffers, once to fill them. A non-null buffer must hold the whole count. Zero (and cadaclysm_last_error) on a null h.
cadaclysm_brep_heal_refused
uint32_t cadaclysm_brep_heal_refused(const struct CadaclysmHeal *h,
uint32_t *items,
double *sizes);
The small features left, one row each: items, three uint32_t — kind (as in cadaclysm_brep_heal_fixes), index, why (0 would empty its loop, 1 closed, 2 seam, 3 chain wider than the tolerance, 4 a sliver's neighbours part, 5 uneven sliver sides, 6 non-manifold, 7 has holes, 8 the body guard, 9 toggled off by flags, 10 unsupported); sizes, one double — the why's figure (a chain's width, the neighbours' gap, else 0). Returns the count, with the two-call convention of cadaclysm_brep_heal_fixes.
cadaclysm_brep_edge_tolerance
double cadaclysm_brep_edge_tolerance(const struct CadaclysmBrep *brep, uint32_t edge);
How far edge edge may lie off its curve: 0 for an exact edge, the distance healing (or sewing) moved it where that is recorded, NaN when no trim of a face's loop names the id (an edge healing removed), brep is null or the lookup panicked (with cadaclysm_last_error set). The edges' map is built on the first call for a brep and kept while the same brep is asked about, so walking a body's edges is one pass over its trims, not one per call.
cadaclysm_brep_recognized
struct CadaclysmRecognize *cadaclysm_brep_recognized(const struct CadaclysmBrep *brep,
double tolerance);
Give the brep's free-form surfaces and edge curves their analytic kind: a NURBS (or revolved, extruded or swept) surface that is a plane, cylinder, cone, sphere or torus within tolerance of every sample of its faces and every point of their edges becomes exactly that, and an edge curve that is a line, circle or ellipse within it likewise, over the same stretch run the same way — so a file that stored its analytic faces as NURBS (a .3dm especially) comes back as they were made. Faces and edges keep their numbers. brep is left as it was. NaN or tolerance <= 0 takes the default, 1e-6 times the body's extent — not the file's declared tolerance, at which a fillet's blend reads as a torus; the summary's sizes[0] says what was used.
A report handle, read with the cadaclysm_brep_recognize_* accessors and freed with cadaclysm_brep_recognize_free; null (and cadaclysm_last_error) on a null brep or a panic inside recognition (the message starts panicked:).
cadaclysm_brep_recognize_body
const struct CadaclysmBrep *cadaclysm_brep_recognize_body(const struct CadaclysmRecognize *r);
The recognised body: a new reference the caller releases with cadaclysm_brep_release. It outlives the report. Null (and cadaclysm_last_error) on a null r.
cadaclysm_brep_recognize_free
void cadaclysm_brep_recognize_free(struct CadaclysmRecognize *r);
Free a report. Null is a no-op. A body taken with cadaclysm_brep_recognize_body stays good.
cadaclysm_brep_recognize_summary
bool cadaclysm_brep_recognize_summary(const struct CadaclysmRecognize *r,
uint32_t *counts,
double *sizes);
The report's figures. counts, ten uint32_t, in order: faces taken as planes, cylinders, cones, spheres, tori; faces left free-form; edges taken as lines, circles, ellipses; edges left free-form. sizes, three double: the tolerance used, the worst face deviation, the worst edge deviation (0 where none was taken). Either output may be null; not both. false (and cadaclysm_last_error) on a null r or both outputs null.
cadaclysm_brep_recognize_faces
uint32_t cadaclysm_brep_recognize_faces(const struct CadaclysmRecognize *r,
uint32_t *items,
double *sizes);
The faces taken, one row each: items, two uint32_t — the face's index (unchanged by recognition), its kind (0 plane, 1 cylinder, 2 cone, 3 sphere, 4 torus); sizes, one double — the furthest any sample of it lies from the analytic surface. Returns the count; with both buffers null it writes nothing, so call it twice: once to size the buffers, once to fill them. A non-null buffer must hold the whole count. Zero (and cadaclysm_last_error) on a null r.
cadaclysm_brep_recognize_refused
uint32_t cadaclysm_brep_recognize_refused(const struct CadaclysmRecognize *r,
uint32_t *items,
double *sizes);
The free-form faces left, one row each: items, two uint32_t — the face's index, why (0 no kind fits within the tolerance, 1 its normals point both ways, 2 a parameter trim cannot be lifted, 3 too few samples); sizes, one double — for "no kind", the closest kind's deviation, else NaN. Returns the count, with the two-call convention of cadaclysm_brep_recognize_faces.
cadaclysm_brep_recognize_edges
uint32_t cadaclysm_brep_recognize_edges(const struct CadaclysmRecognize *r,
uint32_t *items,
double *sizes);
The edges whose curve was taken, one row each, in edge order: items, two uint32_t — the brep edge id (as cadaclysm_brep_edge_tolerance takes one), its kind (0 line, 1 circle, 2 ellipse); sizes, one double — the furthest any point of the curve or its edges lies from the analytic curve. Returns the count, with the two-call convention of cadaclysm_brep_recognize_faces.
Types
CadaclysmAxis
typedef enum CadaclysmAxis {
CADACLYSM_AXIS_X = 0,
CADACLYSM_AXIS_Y = 1,
CADACLYSM_AXIS_Z = 2,
CADACLYSM_AXIS_NEG_X = 3,
CADACLYSM_AXIS_NEG_Y = 4,
CADACLYSM_AXIS_NEG_Z = 5,
} CadaclysmAxis;
One of the six directions an axis can land on, for CadaclysmConventionSpec. Spelled the way the header spells its other constants, for the same reason CadaclysmConvention is.
CadaclysmWinding
typedef enum CadaclysmWinding {
CADACLYSM_WINDING_COUNTER_CLOCKWISE = 0,
CADACLYSM_WINDING_CLOCKWISE = 1,
} CadaclysmWinding;
Which way round the target's renderer wants a front-facing triangle wound, about the outward normal, in the target's own coordinates — the cross-product sense, not the on-screen one. In a left-handed world the two disagree: Unity's manual says clockwise, meaning on the screen, and its mirrored view makes that counter-clockwise here; Unreal's manual says the same word and means clockwise here. Read the engine's rule off which way (b - a) x (c - a) points on a front face, never off the word.
CadaclysmValueKind
typedef enum CadaclysmValueKind {
CadaclysmValueNone = 0,
CadaclysmValueText = 1,
CadaclysmValueInteger = 2,
CadaclysmValueReal = 3,
CadaclysmValueBoolean = 4,
CadaclysmValueList = 5,
CadaclysmValueReference = 6,
} CadaclysmValueKind;
What kind of value an attribute holds.
CadaclysmConvention
typedef enum CadaclysmConvention {
CADACLYSM_NATIVE = 0,
CADACLYSM_UNREAL = 1,
CADACLYSM_UNITY = 2,
CADACLYSM_Y_UP = 3,
CADACLYSM_BLENDER = 4,
} CadaclysmConvention;
A target coordinate space, named the way cadaclysm::Convention's presets are — cadaclysm_open and cadaclysm_open_memory take one of these as a uint32_t, optionally OR'd with CADACLYSM_FILE_UNITS.
CadaclysmMeshUvs
typedef enum CadaclysmMeshUvs {
CADACLYSM_UV_NONE = 0,
CADACLYSM_UV_WORLD_SCALE = 1,
} CadaclysmMeshUvs;
Whether meshes carry texture coordinates, and of what kind.
Off by default and deliberately: a (u, v) is eight bytes a vertex, and on a ten-million-triangle assembly that is not a cost to impose on a caller who never asked. What world scale is good for, and what it is not, is on CadaclysmMesh::uvs.
CadaclysmMeshColors
typedef enum CadaclysmMeshColors {
CADACLYSM_COLORS_NONE = 0,
CADACLYSM_COLORS_PER_FACE = 1,
} CadaclysmMeshColors;
Whether meshes carry a colour per vertex.
See CadaclysmMesh::colors for when an array actually arrives.
CadaclysmPairKind
typedef enum CadaclysmPairKind {
CADACLYSM_PAIR_REVOLUTE = 0,
CADACLYSM_PAIR_PRISMATIC = 1,
CADACLYSM_PAIR_CYLINDRICAL = 2,
CADACLYSM_PAIR_SPHERICAL = 3,
CADACLYSM_PAIR_SPHERICAL_WITH_PIN = 4,
CADACLYSM_PAIR_PLANAR = 5,
CADACLYSM_PAIR_UNIVERSAL = 6,
CADACLYSM_PAIR_HOMOKINETIC = 7,
CADACLYSM_PAIR_SCREW = 8,
CADACLYSM_PAIR_FULLY_CONSTRAINED = 9,
CADACLYSM_PAIR_UNCONSTRAINED = 10,
CADACLYSM_PAIR_LOW_ORDER = 11,
CADACLYSM_PAIR_OTHER = 12,
} CadaclysmPairKind;
A cadaclysm::PairKind value, for cadaclysm_joint_pair_kind. Struct fields and returns carry this as a uint32_t rather than the enum itself — the module doc's note on CadaclysmConvention gives the reason — so this exists to be documented and named from C, not to appear in any signature.
CadaclysmMotion
typedef enum CadaclysmMotion {
CADACLYSM_MOTION_ROTATION = 0,
CADACLYSM_MOTION_TRANSLATION = 1,
} CadaclysmMotion;
A cadaclysm::Motion value, for CadaclysmFreedom::motion. Carried as a uint32_t, as CadaclysmPairKind is.
CadaclysmFreedomAxis
typedef enum CadaclysmFreedomAxis {
CADACLYSM_FREEDOM_X = 0,
CADACLYSM_FREEDOM_Y = 1,
CADACLYSM_FREEDOM_Z = 2,
} CadaclysmFreedomAxis;
A cadaclysm::FreedomAxis value, for CadaclysmFreedom::axis. Carried as a uint32_t, as CadaclysmPairKind is.
CadaclysmInterpolation
typedef enum CadaclysmInterpolation {
CADACLYSM_INTERPOLATION_UNDEFINED = 0,
CADACLYSM_INTERPOLATION_DISCONTINUOUS = 1,
CADACLYSM_INTERPOLATION_SYNCHRONOUS = 2,
CADACLYSM_INTERPOLATION_LINEAR = 3,
} CadaclysmInterpolation;
A cadaclysm::Interpolation value, for cadaclysm_sequence_segment's interpolation. Carried as a uint32_t, as CadaclysmMotion is.
CadaclysmScheduleKind
typedef enum CadaclysmScheduleKind {
CADACLYSM_SCHEDULE_PLANNED = 0,
CADACLYSM_SCHEDULE_ACTUAL = 1,
CADACLYSM_SCHEDULE_BASELINE = 2,
CADACLYSM_SCHEDULE_NOTDEFINED = 3,
CADACLYSM_SCHEDULE_OTHER = 4,
} CadaclysmScheduleKind;
A cadaclysm::ScheduleKind value, for cadaclysm_schedule_kind. Carried as a uint32_t. CADACLYSM_SCHEDULE_OTHER's text is cadaclysm_schedule_kind_name.
CadaclysmTaskKind
typedef enum CadaclysmTaskKind {
CADACLYSM_TASK_ATTENDANCE = 0,
CADACLYSM_TASK_CONSTRUCTION = 1,
CADACLYSM_TASK_DEMOLITION = 2,
CADACLYSM_TASK_DISMANTLE = 3,
CADACLYSM_TASK_DISPOSAL = 4,
CADACLYSM_TASK_INSTALLATION = 5,
CADACLYSM_TASK_LOGISTIC = 6,
CADACLYSM_TASK_MAINTENANCE = 7,
CADACLYSM_TASK_MOVE = 8,
CADACLYSM_TASK_OPERATION = 9,
CADACLYSM_TASK_REMOVAL = 10,
CADACLYSM_TASK_RENOVATION = 11,
CADACLYSM_TASK_NOTDEFINED = 12,
CADACLYSM_TASK_OTHER = 13,
} CadaclysmTaskKind;
A cadaclysm::TaskKind value, for cadaclysm_task_kind. Carried as a uint32_t. CADACLYSM_TASK_OTHER's text is cadaclysm_task_kind_name.
CadaclysmLinkKind
typedef enum CadaclysmLinkKind {
CADACLYSM_LINK_FINISH_START = 0,
CADACLYSM_LINK_START_START = 1,
CADACLYSM_LINK_FINISH_FINISH = 2,
CADACLYSM_LINK_START_FINISH = 3,
CADACLYSM_LINK_NOTDEFINED = 4,
CADACLYSM_LINK_OTHER = 5,
} CadaclysmLinkKind;
A cadaclysm::LinkKind value, for cadaclysm_task_link. Carried as a uint32_t. CADACLYSM_LINK_OTHER's text is cadaclysm_task_link_kind_name.
CadaclysmDates
typedef enum CadaclysmDates {
CADACLYSM_DATES_SCHEDULED = 0,
CADACLYSM_DATES_ACTUAL = 1,
} CadaclysmDates;
Which dates cadaclysm_schedule_at plays. Carried as a uint32_t.
CadaclysmPhase
typedef enum CadaclysmPhase {
CADACLYSM_PHASE_UNBUILT = 0,
CADACLYSM_PHASE_BUILDING = 1,
CADACLYSM_PHASE_BUILT = 2,
CADACLYSM_PHASE_DEMOLISHING = 3,
CADACLYSM_PHASE_DEMOLISHED = 4,
} CadaclysmPhase;
What an element is doing on a date: CadaclysmElementState's phase, a uint32_t.
CadaclysmCalendarKind
typedef enum CadaclysmCalendarKind {
CADACLYSM_CALENDAR_FIRSTSHIFT = 0,
CADACLYSM_CALENDAR_SECONDSHIFT = 1,
CADACLYSM_CALENDAR_THIRDSHIFT = 2,
CADACLYSM_CALENDAR_NOTDEFINED = 3,
CADACLYSM_CALENDAR_OTHER = 4,
} CadaclysmCalendarKind;
A cadaclysm::CalendarKind value, for cadaclysm_calendar_kind. Carried as a uint32_t. CADACLYSM_CALENDAR_OTHER's text is cadaclysm_calendar_kind_name.
CadaclysmRecurrenceKind
typedef enum CadaclysmRecurrenceKind {
CADACLYSM_RECURRENCE_DAILY = 0,
CADACLYSM_RECURRENCE_WEEKLY = 1,
CADACLYSM_RECURRENCE_MONTHLY_BY_DAY_OF_MONTH = 2,
CADACLYSM_RECURRENCE_MONTHLY_BY_POSITION = 3,
CADACLYSM_RECURRENCE_BY_DAY_COUNT = 4,
CADACLYSM_RECURRENCE_BY_WEEKDAY_COUNT = 5,
CADACLYSM_RECURRENCE_YEARLY_BY_DAY_OF_MONTH = 6,
CADACLYSM_RECURRENCE_YEARLY_BY_POSITION = 7,
} CadaclysmRecurrenceKind;
A cadaclysm::RecurrenceKind value, in IfcRecurrenceTypeEnum's order: the kind of a CadaclysmWorkTime's pattern. Carried as a uint32_t.
CadaclysmDurationKind
typedef enum CadaclysmDurationKind {
CADACLYSM_DURATION_ELAPSED = 0,
CADACLYSM_DURATION_WORK = 1,
CADACLYSM_DURATION_NOTDEFINED = 2,
CADACLYSM_DURATION_UNSET = 3,
} CadaclysmDurationKind;
A cadaclysm::DurationKind value, for cadaclysm_task_duration_kind: whether a task's duration is elapsed or working time. CADACLYSM_DURATION_UNSET where the file gives none. Carried as a uint32_t.
CadaclysmCalendarStatus
typedef enum CadaclysmCalendarStatus {
CADACLYSM_CALENDAR_STATUS_OK = 0,
CADACLYSM_CALENDAR_STATUS_NOT_FINITE = 1,
CADACLYSM_CALENDAR_STATUS_REVERSED = 2,
CADACLYSM_CALENDAR_STATUS_NO_WORKING_TIME = 3,
CADACLYSM_CALENDAR_STATUS_NO_SUCH_CALENDAR = 4,
CADACLYSM_CALENDAR_STATUS_TOO_LONG = 5,
} CadaclysmCalendarStatus;
What a working-time query on a calendar returns: cadaclysm_calendar_working_periods, cadaclysm_calendar_working_seconds and cadaclysm_calendar_add_work. Carried as a uint32_t; cadaclysm_calendar_error_message gives each one's text.
CadaclysmConventionSpec
typedef struct CadaclysmConventionSpec {
enum CadaclysmAxis x;
enum CadaclysmAxis y;
enum CadaclysmAxis z;
double units_per_metre;
bool file_units;
enum CadaclysmWinding winding;
} CadaclysmConventionSpec;
A target space spelled out in full, for a host none of the presets names.
Everything cadaclysm::Convention carries, so a caller can describe a renderer this library has never heard of rather than waiting for a preset. Passed to cadaclysm_open_custom and cadaclysm_open_memory_custom; the preset entry points are unchanged and remain the shorter way to say one of the five common answers.
CadaclysmCandidate
typedef struct CadaclysmCandidate {
const char *name;
const char *format;
size_t depth;
} CadaclysmCandidate;
One member of a zip that this build has a reader for, as offered to a CadaclysmPick. Both strings are valid only for the duration of the call.
CadaclysmPick
typedef size_t (*CadaclysmPick)(const struct CadaclysmCandidate *candidates,
size_t count,
void *user);
A caller's say in which member of a zip opens. Called once, with every readable member in archive order; returns the index to open. Anything >= count declines the archive, and the open fails with that reason.
CadaclysmOpenOptions
typedef struct CadaclysmOpenOptions {
size_t size;
uint32_t convention;
const struct CadaclysmConventionSpec *spec;
bool file_units;
uint32_t uvs;
uint32_t colors;
double source_meters_per_unit;
const char *const *schemas;
size_t schema_count;
const uint8_t *schema_text;
size_t schema_length;
CadaclysmPick pick;
void *pick_user;
uint32_t lightmap_resolution;
} CadaclysmOpenOptions;
Everything an open takes beyond where the bytes come from.
Zero it, set size, then set what you care about — cadaclysm_open_options_init does the first two. A null pointer where one of these is expected means every default, so cadaclysm_open("part.step", NULL) is the short way in.
CadaclysmBounds
typedef struct CadaclysmBounds {
float min[3];
float max[3];
} CadaclysmBounds;
An axis-aligned box, or all zeros where there is nothing to bound.
CadaclysmBounds64
typedef struct CadaclysmBounds64 {
double min[3];
double max[3];
} CadaclysmBounds64;
CadaclysmBounds in double: the same box, unnarrowed. All zeros where there is nothing to bound.
CadaclysmAttribute
typedef struct CadaclysmAttribute {
const char *name;
enum CadaclysmValueKind kind;
const char *text;
int64_t integer;
double real;
bool boolean;
} CadaclysmAttribute;
One thing a file said about a part.
kind says which of the fields below it means; the rest are zero. text borrows from the scene like every other string here.
CadaclysmMesh
typedef struct CadaclysmMesh {
const float *positions;
const float *normals;
const float *uvs;
const float *colors;
const uint32_t *indices;
uint32_t vertex_count;
uint32_t index_count;
} CadaclysmMesh;
A part's triangles. All five pointers borrow from the scene.
positions and normals each hold vertex_count * 3 floats, uvs holds vertex_count * 2, colors holds vertex_count * 4, and indices holds index_count of them, three to a triangle. A part with no geometry gives all-null and all-zero. normals, uvs and colors are each handed over only when they hold exactly that many floats for positions' own vertex count; empty or mismatched both read as "not there" (null), so a caller reading vertex_count entries from a non-null pointer never reads past what is actually there — the same rule CadaclysmMesh64 uses for its own fields.
CadaclysmMesh64
typedef struct CadaclysmMesh64 {
const double *positions;
const double *normals;
const double *uvs;
const float *colors;
const uint32_t *indices;
uint32_t vertex_count;
uint32_t index_count;
} CadaclysmMesh64;
CadaclysmMesh in double: the document's own mesh, lent as it is, where cadaclysm_node_mesh hands a float copy of it. The same triangles and indices; the float positions are exactly these narrowed. For a caller that uses the mesh as geometry (an exporter, a measurement, a solver) and wants the file's own coordinates, which float cannot hold far from the origin.
Colours stay float (RGBA in 0..1 needs no more). Null where CadaclysmMesh's field would be: normals, uvs and colors are handed over only when each is the same length as positions (empty or mismatched both read as "not there"), so a caller reading vertex_count entries from a non-null pointer never reads past what is actually there.
CadaclysmCollision
typedef struct CadaclysmCollision {
uint32_t size;
uint32_t shape;
uint32_t confidence;
uint32_t axis;
double frame[16];
double half_extent[3];
double radius;
double height;
double error;
uint32_t hull_vertex_count;
uint32_t hull_index_count;
} CadaclysmCollision;
What a node turned out to be, and the body an engine can simulate for it.
half_extent and frame are always the true oriented box and are always usable, whatever shape says, so a consumer that only wants boxes can ignore shape entirely. The fields a given shape does not use are written zero rather than left as the caller had them.
CadaclysmCollisionHull
typedef struct CadaclysmCollisionHull {
const float *positions;
const uint32_t *indices;
uint32_t vertex_count;
uint32_t index_count;
} CadaclysmCollisionHull;
A node's convex hull, borrowed from the scene.
CadaclysmFreedom
typedef struct CadaclysmFreedom {
uint32_t motion;
uint32_t axis;
bool has_lower;
double lower;
bool has_upper;
double upper;
} CadaclysmFreedom;
One of a pair's degrees of freedom: which motion, about or along which contact-frame axis, and its optional range.
CadaclysmTaskTime
typedef struct CadaclysmTaskTime {
bool has_schedule_start;
double schedule_start;
bool has_schedule_finish;
double schedule_finish;
bool has_early_start;
double early_start;
bool has_early_finish;
double early_finish;
bool has_late_start;
double late_start;
bool has_late_finish;
double late_finish;
bool has_actual_start;
double actual_start;
bool has_actual_finish;
double actual_finish;
bool has_duration;
double duration;
} CadaclysmTaskTime;
Every date pair of a task, in seconds since 1970-01-01T00:00; each has_* says whether its value is given. duration is in seconds.
CadaclysmElementState
typedef struct CadaclysmElementState {
uint32_t node;
uint32_t phase;
double progress;
bool has_variance;
double variance;
} CadaclysmElementState;
One element's state on a date, from cadaclysm_schedule_at: the node, its phase (a CadaclysmPhase), progress 0..1 through the window that governs the phase, and variance — seconds late (positive) or early (negative) — where has_variance.
CadaclysmWorkTime
typedef struct CadaclysmWorkTime {
bool has_start;
double start;
bool has_finish;
double finish;
bool has_pattern;
uint32_t kind;
bool has_position;
int32_t position;
bool has_interval;
uint32_t interval;
bool has_occurrences;
uint32_t occurrences;
} CadaclysmWorkTime;
One work time of a calendar, from cadaclysm_calendar_work_time. Dates are midnight of the day, in seconds since 1970-01-01T00:00; each has_* says whether its value is given. Without a pattern (has_pattern false) the work time covers every day of its validity, all day, and the fields after has_pattern are 0. kind is a CadaclysmRecurrenceKind. The pattern's lists come from cadaclysm_calendar_work_time_days, _weekdays, _months and _periods.
CadaclysmPolylines
typedef struct CadaclysmPolylines {
const float *positions;
const uint32_t *counts;
uint32_t polyline_count;
uint32_t vertex_count;
} CadaclysmPolylines;
A set of polylines. Both pointers borrow from the scene.
positions holds vertex_count * 3 floats, run together end to end; counts holds polyline_count vertex counts — how many points each run has, not where it ends, so a body of twelve two-point edges reads 2, 2, 2, ... and a caller walks the runs by adding them up. A part with none gives all-null and all-zero.
CadaclysmEdgeColors
typedef struct CadaclysmEdgeColors {
const float *rgba;
uint32_t count;
} CadaclysmEdgeColors;
A part's per-polyline edge colours: four floats per polyline of the matching CadaclysmPolylines (cadaclysm_node_edges / cadaclysm_node_surface_edges), in its order, -1, -1, -1, -1 for an edge the file does not style. {NULL, 0} when nothing on the part is styled. Borrows from the scene.
CadaclysmBeziers
typedef struct CadaclysmBeziers {
const float *points;
const float *weights;
uint32_t count;
} CadaclysmBeziers;
A set of rational cubic Bézier segments. Both pointers borrow from the scene.
points holds count * 4 * 3 floats — four control points to a segment, three floats to a point — and weights holds count * 4 beside them. A part with no curves of this kind gives all-null and zero.
CadaclysmBeziers64
typedef struct CadaclysmBeziers64 {
const double *points;
const double *weights;
uint32_t count;
} CadaclysmBeziers64;
CadaclysmBeziers in double: four control points (xyz) and four weights a segment. The same segments, in the same order; the float ones are these narrowed.
CadaclysmFace
typedef struct CadaclysmFace {
uint32_t kind;
uint32_t reversed;
uint32_t transposed;
uint32_t reserved;
float origin[4];
float ax[4];
float ay[4];
float az[4];
float domain[4];
float scalars[4];
uint32_t loop_start;
uint32_t loop_count;
uint32_t profile_start;
uint32_t profile_count;
uint32_t profile2_start;
uint32_t profile2_count;
uint32_t nurbs_start;
uint32_t nurbs_count;
} CadaclysmFace;
One trimmed face as the surface it actually is, for a caller that evaluates surfaces rather than triangles.
A cylinder stays a cylinder: a frame, a radius, and a (u, v) window. That costs the caller an evaluator with a branch per kind, and buys the trims — because the loops are in the surface's own (u, v), which is the space they were computed in, so testing a point against them is a point-in-polygon at coordinates the evaluator already has.
CadaclysmSurfaces
typedef struct CadaclysmSurfaces {
const struct CadaclysmFace *faces;
uint32_t face_count;
const uint32_t *loops;
uint32_t loop_count;
const float *points;
uint32_t point_count;
const float *profiles;
uint32_t profile_count;
const float *nurbs;
uint32_t nurbs_count;
const uint32_t *shared;
uint32_t shared_count;
const uint32_t *duplicate;
uint32_t duplicate_count;
} CadaclysmSurfaces;
Every face of one part as surfaces and trims — see CadaclysmFace.
Five borrowed arrays the faces share: a face names a slice of each rather than carrying its own copy, which keeps a part with two hundred faces to one allocation apiece.
CadaclysmGpuSurfaces
typedef struct CadaclysmGpuSurfaces {
const struct CadaclysmFace *faces;
uint32_t face_count;
uint32_t surface_count;
const uint32_t *loops;
uint32_t loops_len;
const float *points;
uint32_t points_len;
const float *profiles;
uint32_t profiles_len;
const float *nurbs;
uint32_t nurbs_len;
const uint32_t *shared;
uint32_t shared_len;
const uint32_t *tiles;
uint32_t tiles_len;
const float *tile_domains;
uint32_t tile_domains_len;
const float *tile_samples;
uint32_t tile_samples_len;
const float *tile_boxes;
uint32_t tile_boxes_len;
const float *edges;
uint32_t edges_len;
double bounds[6];
double about[3];
} CadaclysmGpuSurfaces;
A part's exact faces packed for a GPU surface evaluator, and its exact edges — see cadaclysm_node_gpu_surfaces. Every array's length is in its own scalars (u32 or float): faces is face_count records (CadaclysmFace); loops two words a loop; points two floats a point; profiles four a sample; tiles two words a face (the tile grid nu, nv); tile_domains four floats a tile; tile_samples the density samples, three floats a point; tile_boxes six floats a tile; edges sixteen floats a rational cubic (four xyz points, four weights). Positions are about about; bounds (min xyz, max xyz) alone is in the part's own coordinates. surface_count is the faces packed, one colour slot each.
CadaclysmPolylines64
typedef struct CadaclysmPolylines64 {
const double *positions;
const uint32_t *counts;
uint32_t polyline_count;
uint32_t vertex_count;
} CadaclysmPolylines64;
CadaclysmPolylines in double: the same polylines, unnarrowed, for geometry far from the origin. positions holds vertex_count * 3 doubles; counts says how many points each run has, as in CadaclysmPolylines. A part with none gives all-null and all-zero.
CadaclysmWindow
typedef struct CadaclysmWindow {
uint32_t kind;
void *handle;
void *display;
} CadaclysmWindow;
The host window a dialog should belong to. kind is one of the CADACLYSM_WINDOW_* constants, saying which of handle/display's platform types apply.
Those constants are part of the ABI: hosts compile the numbers in, so they must never be renumbered.
CadaclysmSvgOptions
typedef struct CadaclysmSvgOptions {
uint32_t size;
uint32_t up;
double azimuth;
double elevation;
double fov;
double width;
double height;
double margin;
double tolerance;
double stroke_width;
uint32_t stroke;
uint32_t background;
uint32_t flags;
} CadaclysmSvgOptions;
How a drawing is made: the camera in the viewer's words, the page, the pen and which line sets. size is sizeof(CadaclysmSvgOptions), the struct's growth room, as in CadaclysmOpenOptions. Fill it with cadaclysm_svg_options_init and change what you need.
CadaclysmFemOptions
typedef struct CadaclysmFemOptions {
size_t size;
double tolerance;
double max_size;
} CadaclysmFemOptions;
What a FEM mesh is meshed to.
Zero it, set size, then set what you care about — cadaclysm_fem_options_init does the first two. A null pointer where one of these is expected means every default, so cadaclysm_node_fem_mesh(scene, node, NULL, NULL) is the short way in.
CadaclysmFemMeshView
typedef struct CadaclysmFemMeshView {
const double *nodes;
uint32_t node_count;
const uint32_t *triangles;
uint32_t triangle_count;
const uint32_t *triangle_face;
const uint32_t *node_kind;
const uint32_t *node_entity;
uint32_t face_count;
uint32_t edge_count;
uint32_t vertex_count;
uint32_t open_edge_count;
uint32_t folded_edge_count;
bool watertight;
bool from_mesh;
double min_angle;
uint32_t worst_triangle;
double longest_edge;
} CadaclysmFemMeshView;
The flat arrays of one FEM mesh, and its summary.
Every pointer is borrowed from the handle and good until cadaclysm_fem_mesh_free; none of them is a copy, and none of them is built by the call that hands it over.
CadaclysmFemEdge
typedef struct CadaclysmFemEdge {
uint32_t id;
const uint32_t *nodes;
uint32_t node_count;
const uint32_t *runs;
uint32_t run_count;
uint32_t face_a;
uint32_t face_b;
uint32_t end_a;
uint32_t end_b;
bool closed;
bool seam;
} CadaclysmFemEdge;
One B-rep edge of a FEM mesh: the chain of nodes along it, and where that chain breaks.
CadaclysmFemVertex
typedef struct CadaclysmFemVertex {
uint32_t node;
double point[3];
bool has_position;
} CadaclysmFemVertex;
One B-rep vertex of a FEM mesh: the node the mesh put there, if any, and where the topology says it is, if that is known.
One struct rather than three out-parameters: it matches the fill-an-out-struct-return- bool shape of every sibling accessor here, it gives the header and every wrapper a named type to pin a layout against, and it puts node's sentinel beside has_position where a caller reads both at once.
cadaclysm_blacksmith.h
Library and licence
cadaclysm_blacksmith_last_error
const char *cadaclysm_blacksmith_last_error(void);
Why the last call failed, or null if it succeeded.
Borrowed, and good until the next call on this thread.
cadaclysm_blacksmith_version
const char *cadaclysm_blacksmith_version(void);
The library's version, as "0.1.0". Static; never freed.
cadaclysm_blacksmith_license_set
bool cadaclysm_blacksmith_license_set(const char *text_or_path);
Load a license from text_or_path: the certificate text itself, or the path of a file holding it. Replaces the one in use. Null forgets the one in use, so the next call resolves from the environment and the search paths again. Returns false without changing anything when the text does not verify, with the reason at cadaclysm_blacksmith_last_error.
cadaclysm_blacksmith_license_info
const char *cadaclysm_blacksmith_license_info(void);
The license in use, as one line — customer=Acme Ltd expiry=2027-09-15 scope=server plan=startup servers=1 — or, without one, unlicensed (unlicensed -- <reason> when a license was found but did not verify). Never null. Borrowed, and good until the next call on this thread.
cadaclysm_blacksmith_license_notice_count
uint64_t cadaclysm_blacksmith_license_notice_count(void);
How many unlicensed notices this library has printed in this process; an application can show its own banner instead of the stderr line.
cadaclysm_blacksmith_build_date
const char *cadaclysm_blacksmith_build_date(void);
The date this library was built, "YYYY-MM-DD". A paid license is good for every build dated on or before the day its updates end. Static; never freed.
cadaclysm_blacksmith_build
const char *cadaclysm_blacksmith_build(void);
This library's build, as JSON: {"branch": "master", "commit": "7e4b5058e", "date": "2026-11-14", "time": "2026-11-14T10:22:31Z", "version": "0.14.2"} — the version, the commit and branch it was built from ("unknown" built from no checkout), when (a release pins its date), and the build date licenses compare. What an app shows as the cadaclysm it runs on. Static; never freed.
cadaclysm_blacksmith_string_free
void cadaclysm_blacksmith_string_free(char *s);
Release a string this library handed over as owned (cadaclysm_blacksmith_step, cadaclysm_blacksmith_step_assembly, cadaclysm_blacksmith_sat_text, cadaclysm_blacksmith_brep_text, cadaclysm_blacksmith_svg_text, cadaclysm_blacksmith_drawing_svg_text, cadaclysm_blacksmith_fem_mesh_msh_text, cadaclysm_blacksmith_assembly_place_solid, cadaclysm_blacksmith_assembly_place_assembly, cadaclysm_blacksmith_assembly_step, and every text cadaclysm_blacksmith_document_* returns: _save, _apply, _preview, _end_preview, _batch_end, _batch_abort, _undo, _redo, _params, _evaluate, _result_kind, _value, _errors, _kinds, _branch_new, _branch_switch, _tips, _branch_list, _log). Null is a no-op. A .3dm's bytes are not a string: cadaclysm_blacksmith_bytes_free releases those.
This list is the whole of it, and it is where a caller comes to find out whether a pointer is theirs to free. A text from anywhere else in this library is borrowed and must not be passed here — and the reverse mistake costs just as much: the reader library's cadaclysm_fem_mesh_msh_text borrows from its handle, so a caller holding both libraries frees the kernel's .msh text and not the reader's.
Kernel options
cadaclysm_blacksmith_option_set
bool cadaclysm_blacksmith_option_set(const char *name, double value);
Sets a kernel option, by its name, for the whole process from the next call on. The options are numbers under stable names ("boolean.mesh_budget", "boolean.finest_tolerance", "profile_boolean.point_budget", "measure.default_accuracy", "tolerance.relative", "tolerance.angular", "step.validation_properties", "step.validation_accuracy"; the error for a wrong value says what each takes; the two tolerance options are explained at cadaclysm_blacksmith_effective_tolerance): one call for all of them, so an option added later needs no new entry point — which is how cadaclysm_blacksmith_step's validation properties reach every language without one. False — and nothing changed — for a name that is not an option or a value it does not take, with cadaclysm_blacksmith_last_error saying which and what it takes.
cadaclysm_blacksmith_option_get
bool cadaclysm_blacksmith_option_get(const char *name, double *out);
A kernel option's value, by its name, into *out: what was last set, else its default. False for a name that is not an option, with cadaclysm_blacksmith_last_error listing the ones there are.
Tolerances
cadaclysm_blacksmith_effective_tolerance
double cadaclysm_blacksmith_effective_tolerance(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count);
The tolerance a verb given none works at over count solids.
# Tolerances
A solid declares how precise it is: an absolute tolerance (a length, in the model's own units) and an angular one (radians), each read from the file it came from (a 3dm's units and tolerances, STEP's uncertainty, SAT's resabs, IGES's resolution), carried by every verb's result as the loosest of its inputs', scaled with the solid by a transform, and set by cadaclysm_blacksmith_solid_with_tolerances. cadaclysm_blacksmith_solid_tolerances reads it back, NaN where the source said nothing.
cadaclysm_blacksmith_solid_tolerances
bool cadaclysm_blacksmith_solid_tolerances(const struct CadaclysmBlacksmithSolid *solid,
double *absolute,
double *angular);
What solid declares about its own precision (see the tolerances section at cadaclysm_blacksmith_effective_tolerance): its absolute tolerance into *absolute and its angular one (radians) into *angular, NaN for one it does not declare. Either pointer may be null. False, with last_error, for a null solid.
cadaclysm_blacksmith_solid_with_tolerances
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_solid_with_tolerances(const struct CadaclysmBlacksmithSolid *solid,
double absolute,
double angular);
A new solid: solid declaring absolute (a length) and angular (radians) instead of what it declared, its name, paint and marks kept. NaN or 0 declares nothing for that field. The caller frees it with cadaclysm_blacksmith_solid_free. Null, with last_error, for a null solid or a negative or infinite value.
cadaclysm_blacksmith_vertex_tolerance
double cadaclysm_blacksmith_vertex_tolerance(const struct CadaclysmBlacksmithSolid *solid,
double x,
double y,
double z);
How loose the vertex of solid at (x, y, z) is, where its producer said (an OCCT .brep records one per vertex): the tolerance of the nearest recorded vertex within its own tolerance of the point. NaN where none is recorded there or the point is not finite, and (with last_error) for a null solid.
Colour
cadaclysm_blacksmith_parse_colour
bool cadaclysm_blacksmith_parse_colour(const char *text, double *out);
A colour's text as r, g, b in 0..1, into out[0..3]: "#rgb", "#rrggbb" (the # optional) or one of the 148 CSS colour names, any case. The one parser every wrapper hands colour text to, so the forms are the same in each. False, with cadaclysm_blacksmith_last_error saying why, for anything else.
cadaclysm_blacksmith_edge_polyline_colours
struct CadaclysmBlacksmithColours cadaclysm_blacksmith_edge_polyline_colours(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
A colour per polyline of cadaclysm_blacksmith_edge_polylines at the same tolerance: count equals that call's polyline_count, and polyline i draws in rgb[3 * i .. 3 * i + 3] (r, g, b in 0..1, or -1, -1, -1 for a polyline on no coloured edge). A solid with no edge paint gives count 0 and a null rgb: nothing to colour, not an error. The same empty struct comes back on a bad tolerance or argument, with last_error set — a caller tells "no paint" from "error" by last_error, exactly as it tells an empty cadaclysm_blacksmith_edge_polylines from a failed one. Same cache and lifetime rule as the mesh.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_gpu_edge_colours
struct CadaclysmBlacksmithColours cadaclysm_blacksmith_gpu_edge_colours(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
A colour per exact edge of cadaclysm_blacksmith_gpu_surfaces at the same tolerance: count equals that record's Bezier count (edges_len / 16), and Bezier i draws in rgb[3 * i .. 3 * i + 3] — its edge's own colour, else the solid's edge colour, else -1, -1, -1 (none: the viewer's own). What a viewer drawing the exact edges paints them with, as it paints cadaclysm_blacksmith_edge_polylines with cadaclysm_blacksmith_edge_polyline_colours. No edge paint, a bad tolerance or argument: as that call. Same cache and lifetime rule as the mesh.
cadaclysm_blacksmith_profile_coloured
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_coloured(const struct CadaclysmBlacksmithProfile *profile,
double r,
double g,
double b);
profile coloured (r, g, b), each in 0..1: how its outline is drawn. The verbs that make a profile from one carry it; a solid made from it takes nothing (colour a solid with cadaclysm_blacksmith_coloured).
cadaclysm_blacksmith_profile_colour
bool cadaclysm_blacksmith_profile_colour(const struct CadaclysmBlacksmithProfile *profile,
double *out);
profile's colour as three doubles into out. false where it has none, and, with last_error set, on a null argument.
cadaclysm_blacksmith_colour
bool cadaclysm_blacksmith_colour(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double *out);
The solid's colour, or with face not CADACLYSM_BLACKSMITH_NONE that face's as drawn (its own, else the solid's), as three doubles into out. false where there is none — and, with last_error set, on a bad face or a null argument.
cadaclysm_blacksmith_edge_colour
bool cadaclysm_blacksmith_edge_colour(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
double *out);
Edge edge's colour as drawn — its own, else the solid's edge colour — as three doubles into out. false where there is none, and, with last_error set, on a bad edge or a null argument.
cadaclysm_blacksmith_coloured
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_coloured(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double r,
double g,
double b);
solid coloured (r, g, b), each in 0..1: the whole solid, or with face not CADACLYSM_BLACKSMITH_NONE just that face, whose colour then wins over the solid's. What is made from a coloured solid inherits: a rigid move keeps every colour, and a boolean, fillet, chamfer or shell gives each face the colour of the input face it lies on — a cut's bore the tool's — and a new face (a round, a shell's inner wall) the solid's.
cadaclysm_blacksmith_edges_coloured
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_edges_coloured(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double r,
double g,
double b);
solid with its edges coloured (r, g, b), each in 0..1: every edge when edges is null, else the count edges listed (the indices cadaclysm_blacksmith_edge and cadaclysm_blacksmith_fillet use), whose colour then wins over the all-edges one. Null and empty differ: a null edges colours every edge, a non-null edges with count 0 colours none (the list is read as fillet reads its own), so a wrapper keeps "none" and "empty" distinct. A rigid move keeps every edge colour; a boolean, fillet, chamfer or shell gives each edge the colour of the input edge it lies on, and a new edge (a cut's rim, a round's edges) the all-edges colour. Read back with cadaclysm_blacksmith_edge_colour.
Point, edge and face queries
cadaclysm_blacksmith_face_point
int32_t cadaclysm_blacksmith_face_point(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *p,
double tolerance,
struct CadaclysmBlacksmithFacePoint *out);
Where p (3 doubles) lies against face face of solid, into out: its nearest point of the face (exact, trimmed) and where 0 inside, 1 on the boundary, 2 off. Returns 1 where the point is on the face (inside or on its boundary), 0 where it is off — out filled either way — and -1 on a refusal (negative: test < 0), with last_error set and out untouched, for a null solid, p or out, a face out of range, a non-finite point, a tolerance negative or infinite, or a face that gives no nearest point. Fusion's isPointOnFace, Rhino's IsPointOnFace.
tolerance 0 or NaN: the solid's effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_face_inner_point
bool cadaclysm_blacksmith_face_inner_point(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
struct CadaclysmBlacksmithFacePoint *out);
A point strictly inside face face of solid's trims, on its surface, into out (where 0, distance 0): the centre of the largest circle inside one of the face's measuring-mesh triangles that reads inside. Fusion's pointOnFace. False (and last_error), out untouched, for a null solid or out, a face out of range, or a face where no point inside is found.
cadaclysm_blacksmith_edge_point
int32_t cadaclysm_blacksmith_edge_point(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
const double *p,
double tolerance,
struct CadaclysmBlacksmithEdgePoint *out);
The nearest point to p (3 doubles) of edge edge of solid on its own curve over its range, into out, on where it is within tolerance. Returns 1 where the point is on the edge, 0 where it is not — out filled either way — and -1 on a refusal (negative: test < 0), with last_error set and out untouched, for a null solid, p or out, an edge out of range, a non-finite point, or a tolerance negative or infinite.
tolerance 0 or NaN: the solid's effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_edge_inner_point
bool cadaclysm_blacksmith_edge_inner_point(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
struct CadaclysmBlacksmithEdgePoint *out);
A point on edge edge of solid, into out (on true, distance 0): its curve at the middle of its range (a whole circle half a turn from where its range starts). Fusion's pointOnEdge. False (and last_error), out untouched, for a null solid or out or an edge out of range.
cadaclysm_blacksmith_face_size
bool cadaclysm_blacksmith_face_size(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double *out);
The width and height of the rectangle face face of solid would flatten to, into out (2 doubles): over the uv box the face's trims span, the longest of the u-isocurves at five evenly spaced v is the width, the longest v-isocurve at five u the height. Rhino's GetSurfaceSize. False (and last_error), out untouched, for a null solid or out, a face out of range or one whose trims cannot be read.
cadaclysm_blacksmith_edge_convexity
bool cadaclysm_blacksmith_edge_convexity(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
double angular_tolerance,
uint32_t samples,
struct CadaclysmBlacksmithEdgeConvexity *out);
How edge edge of solid's two faces meet along it, at samples points (16 at fewest), into out — see CadaclysmBlacksmithEdgeConvexity. A sample within angular_tolerance of tangent is smooth. False (and last_error), out untouched, for a null solid or out, an edge out of range, a bad angular tolerance, or an edge whose faces' sides cannot be told.
angular_tolerance 0 or NaN: the angle the solid declares, else the tolerance.angular option, 1 degree.
cadaclysm_blacksmith_edges_convexity
bool cadaclysm_blacksmith_edges_convexity(const struct CadaclysmBlacksmithSolid *solid,
double angular_tolerance,
uint32_t *out);
The convexity kind (0 smooth, 1 convex, 2 concave, 3 mixed, 4 open) of every edge of solid, in the edge list's order at 16 samples each, into out (room for cadaclysm_blacksmith_edge_count uint32_ts). Fusion's concaveEdges/convexEdges are the edges reading 2 and 1. False (and last_error), out untouched, for a null solid or out, a bad angular tolerance, or an edge whose faces' sides cannot be told.
angular_tolerance 0 or NaN: the angle the solid declares, else the tolerance.angular option, 1 degree.
cadaclysm_blacksmith_tangent_faces
int32_t cadaclysm_blacksmith_tangent_faces(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double angular_tolerance,
uint32_t *out);
Face face of solid and every face reached from it across edges whose faces meet smoothly (cadaclysm_blacksmith_edge_convexity kind 0 at angular_tolerance), into out: breadth first, the face first, then each face's new neighbours in ascending index. Fusion's tangentiallyConnectedFaces. Returns how many faces were written (at least 1), or -1 on a refusal (negative: test < 0), with last_error set and out untouched, for a null solid or out, a face out of range, a bad angular tolerance, or an edge whose convexity cannot be read.
angular_tolerance 0 or NaN: the angle the solid declares, else the tolerance.angular option, 1 degree.
cadaclysm_blacksmith_tangent_edges
int32_t cadaclysm_blacksmith_tangent_edges(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
double angular_tolerance,
uint32_t *out);
Edge edge of solid and every edge reached from it through vertices where two edges' curves run on with the same tangent (their tangents away from the vertex opposite within angular_tolerance), into out, in the order found (the edge first). Any curve kind; a whole closed curve has no ends and chains to nothing. Fusion's tangentiallyConnectedEdges. Returns how many edges were written (at least 1), or -1 on a refusal (negative: test < 0), with last_error set and out untouched, for a null solid or out, an edge out of range or a bad angular tolerance.
angular_tolerance 0 or NaN: the angle the solid declares, else the tolerance.angular option, 1 degree.
cadaclysm_blacksmith_tangent_face_groups
int32_t cadaclysm_blacksmith_tangent_face_groups(const struct CadaclysmBlacksmithSolid *solid,
double angular_tolerance,
uint32_t *out);
For every face of solid, the index of its group of faces joined smoothly (as cadaclysm_blacksmith_tangent_faces), into out (room for cadaclysm_blacksmith_face_count uint32_ts), the groups numbered in the order of their lowest face (face 0's group is 0). Rhino's GetTangentConnectedComponents, as face groups. Returns the number of groups, or -1 on a refusal (negative: test < 0), with last_error set and out untouched, for a null solid or out, a bad angular tolerance, or an edge whose convexity cannot be read.
angular_tolerance 0 or NaN: the angle the solid declares, else the tolerance.angular option, 1 degree.
cadaclysm_blacksmith_angle_points
bool cadaclysm_blacksmith_angle_points(const double *a,
const double *vertex,
const double *b,
double *out);
The angle at vertex between the arms to a and to b (3 doubles each), in radians 0 to pi, into out. False (and last_error), out untouched, for a null point or out, a non-finite point, or an arm no longer than 1e-12 of the largest coordinate magnitude of the three.
cadaclysm_blacksmith_angle_between
bool cadaclysm_blacksmith_angle_between(const struct CadaclysmBlacksmithSolid *a,
uint32_t kind_a,
uint32_t index_a,
const struct CadaclysmBlacksmithSolid *b,
uint32_t kind_b,
uint32_t index_b,
struct CadaclysmBlacksmithAngle *out);
The angle between entity index_a of a and index_b of b (the same solid may be passed twice), into out — see CadaclysmBlacksmithAngle. kind_a, kind_b: 0 a face, 1 an edge. A planar face is read as its plane (outward normal); a cylinder's, cone's or revolved face as its axis; a straight edge as its line (start to end); a circular edge as its circle's plane. at_a, at_b are a face's or an edge's inner point, or for an axis its point nearest the face's. Fusion's measureAngle. False (and last_error), out untouched, for a null solid or out, a kind not 0 or 1, an index out of range, a face neither planar nor with an axis, or an edge neither straight nor circular.
cadaclysm_blacksmith_face_minimum_radius
bool cadaclysm_blacksmith_face_minimum_radius(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
uint32_t samples,
struct CadaclysmBlacksmithMinimumRadius *out);
The smallest radius of curvature over face face of solid, into out — see CadaclysmBlacksmithMinimumRadius. Planes, cylinders, cones, spheres and tori in closed form where the minimising parameter is on the face; otherwise, and for every other surface, a grid of samples steps each way (16 at fewest) over the face's trimmed uv box, the tightest samples polished. Fusion's MinimumRadiusAnalyses. False (and last_error), out untouched, for a null solid or out, a face out of range, trims that cannot be read, or a face where no sample has a normal.
cadaclysm_blacksmith_profile_area_properties
bool cadaclysm_blacksmith_profile_area_properties(const struct CadaclysmBlacksmithProfile *profile,
double accuracy,
struct CadaclysmBlacksmithAreaProperties *out);
profile's area properties in its own plane, into out — see CadaclysmBlacksmithAreaProperties: the outer loop's region less its holes, whatever their winding; lines and arcs in closed form, polynomial splines exactly, rational ones (conics, weighted NURBS) adaptively to accuracy relative to the profile's size. Fusion's Profile.areaProperties, Rhino's AreaMassProperties of closed planar curves. False (and last_error), out untouched, for a null profile or out, an accuracy outside (0, 1), a hole with holes of its own, or a segment that cannot be measured.
accuracy 0 or NaN: 1e-9.
Profiles and paths
cadaclysm_blacksmith_profile_free
void cadaclysm_blacksmith_profile_free(struct CadaclysmBlacksmithProfile *profile);
Release a profile. Null is a no-op.
cadaclysm_blacksmith_profile_point_at_length
bool cadaclysm_blacksmith_profile_point_at_length(const struct CadaclysmBlacksmithProfile *profile,
double s,
double accuracy,
struct CadaclysmBlacksmithAt *out);
The point at arc length s along profile's outer loop from its start, into out; segment names the side it lies on. false and last_error for a null profile or out, an s outside [0, perimeter], and an accuracy that is NaN, infinite, or 1 or more.
cadaclysm_blacksmith_profile_divide_by_count
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_profile_divide_by_count(const struct CadaclysmBlacksmithProfile *profile,
uint32_t n,
double accuracy);
profile's outer loop in n pieces of equal arc length: n samples from its start, the loop being closed. Null and last_error for a null profile, an n of 0 or above 1 000 000, and an accuracy that is NaN, infinite, or 1 or more.
cadaclysm_blacksmith_profile_divide_by_length
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_profile_divide_by_length(const struct CadaclysmBlacksmithProfile *profile,
double step,
double accuracy);
Samples of profile's outer loop every step of arc length from its start, the last piece whatever is left over and the start never repeated. Null and last_error for a null profile, a step not positive and finite or giving more than 1 000 000 samples, and an accuracy that is NaN, infinite, or 1 or more.
cadaclysm_blacksmith_profile_gear_involute
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_gear_involute(double module,
uint32_t teeth,
double pressure_angle,
double shift,
double addendum,
double dedendum,
double root_fillet,
double backlash,
double tolerance,
struct CadaclysmBlacksmithGearReport *report_out);
An involute spur gear of teeth teeth of module, tooth 0 centred on +X: its flanks NURBS within tolerance of the involute, its tips, fillets and root arcs exact. NaN defaults: pressure_angle 20 degrees, shift 0, addendum 1 and dedendum 1.25 (factors of the module), root_fillet 0.38 module, backlash 0 (taken off this gear's tooth), tolerance 1e-4 module. The report goes to report_out (null: not wanted). Null (and last_error), the report untouched, for fewer than 4 or more than 10 000 teeth, a module not positive, a pressure angle outside (0, pi/4), a pointed tooth, or a root fillet that does not fit.
cadaclysm_blacksmith_profile_gear_wheel_cycloidal
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_gear_wheel_cycloidal(double module,
uint32_t teeth,
uint32_t pinion_leaves,
double thickness,
double addendum,
double dedendum,
double root_fillet,
double tolerance,
struct CadaclysmBlacksmithGearReport *report_out);
A cycloidal clock wheel of teeth teeth of module driving a pinion of pinion_leaves, tooth 0 centred on +X: epicycloidal addendum flanks within tolerance, radial dedendum flanks. NaN defaults: thickness pi module / 2, addendum up to the flanks' crossing with the point rounded, dedendum 1.57 (a factor of the module), root_fillet 0.25 module, tolerance 1e-4 module. The report goes to report_out (null: not wanted). Null (and last_error), the report untouched, for a pinion under 6 leaves, a wheel no larger than its pinion, more than 10 000 teeth, a size not positive, or a fillet that does not fit.
cadaclysm_blacksmith_profile_gear_pinion_cycloidal
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_gear_pinion_cycloidal(double module,
uint32_t leaves,
uint32_t wheel_teeth,
double thickness,
uint32_t tip,
double clearance,
double root_fillet,
double tolerance,
struct CadaclysmBlacksmithGearReport *report_out);
A cycloidal clock pinion of leaves leaves of module driven by a wheel of wheel_teeth, leaf 0 centred on +X: radial flanks inside the pitch circle, tip CADACLYSM_BLACKSMITH_GEAR_TIP_ROUND or CADACLYSM_BLACKSMITH_GEAR_TIP_OGIVE. NaN defaults: thickness 1.05 module (6 to 10 leaves) or 1.25 module, clearance 0.4 module, root_fillet 0.25 module, tolerance 1e-4 module. The report goes to report_out (null: not wanted). Null (and last_error), the report untouched, for under 6 or over 10 000 leaves, a wheel no larger than the pinion, another tip, a size not positive, a negative clearance, or a fillet that does not fit.
cadaclysm_blacksmith_gear_centre_distance_involute
double cadaclysm_blacksmith_gear_centre_distance_involute(double module,
uint32_t teeth_first,
uint32_t teeth_second,
double shift_first,
double shift_second,
double pressure_angle);
The centre distance of two involute gears of module, teeth_first and teeth_second teeth, in mesh without backlash: m (z1 + z2) / 2 cos(alpha) / cos(alpha_w). NaN defaults: shifts 0, pressure_angle 20 degrees. NaN (and last_error) for a module not positive, fewer than 4 teeth, a pressure angle outside (0, pi/4), or shifts that leave no working pressure angle.
cadaclysm_blacksmith_profile_hits
struct CadaclysmBlacksmithHits *cadaclysm_blacksmith_profile_hits(const struct CadaclysmBlacksmithProfile *a,
const struct CadaclysmBlacksmithProfile *b,
double tolerance);
Where a's curves cross, touch or run along b's, both read in one plane: runs where two sides (lines, arcs or splines) stay within tolerance of each other for longer than it, parting only where one of them ends or the stretch is flat — one curve following the other, offset within tolerance or tilted by under about half of it, even where it leaves mid-both — and points, merged within tolerance, ordered along a. An end within tolerance of the other curve meets it. A loop is its segments alone — one that stops short of its start is an open chain. Null (and last_error) for a null profile, a tolerance negative or infinite, or a spline segment that does not evaluate. No hits at all is a handle with a count of 0.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_hits_free
void cadaclysm_blacksmith_hits_free(struct CadaclysmBlacksmithHits *hits);
Release hits. Null is a no-op.
cadaclysm_blacksmith_hit_count
uint32_t cadaclysm_blacksmith_hit_count(const struct CadaclysmBlacksmithHits *hits);
How many hits. 0 (and last_error) for null.
cadaclysm_blacksmith_hit
bool cadaclysm_blacksmith_hit(const struct CadaclysmBlacksmithHits *hits,
uint32_t i,
struct CadaclysmBlacksmithHit *out);
Hit i into out. false (and last_error) for null hits, a null out, or i out of range.
cadaclysm_blacksmith_solid_profile_hits
struct CadaclysmBlacksmithHits *cadaclysm_blacksmith_solid_profile_hits(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
Where profile, placed on frame (twelve doubles), pierces solid's faces, and the pieces its loops cut into: points where a segment crosses a face's exact surface, within tolerance and inside its trim, touch at a graze; runs where a segment lies on a face, from where it enters to where it leaves; merged within tolerance of each other (a hit at a segment join reported once). inside for a piece is by its midpoint's winding number over solid's own mesh — only reported for a closed body (its own manifold/closed report): an open sheet's pieces is always empty, read with cadaclysm_blacksmith_hits_piece_count alone. A loop no hit cuts is one closed piece, all inside or all outside as the winding number says. No hits at all is still such a handle, never null.
Reports its phases — "mesh", "cull", "hits", "pieces" — to progress if not null, as the booleans do.
Null (and last_error) for a null solid ("solid_profile_hits: null solid"), a null profile ("... null profile"), a null frame ("... null frame"), a tolerance negative or infinite, a solid with no faces or that meshes to nothing, a profile with no segments, or a free-form segment that does not evaluate to a NURBS curve.
cadaclysm_blacksmith_hits_piece_count
uint32_t cadaclysm_blacksmith_hits_piece_count(const struct CadaclysmBlacksmithHits *hits);
How many pieces hits (from cadaclysm_blacksmith_solid_profile_hits) cut the profile's loops into. 0 for a hits read from cadaclysm_blacksmith_profile_hits instead (profile x profile has no solid to be inside of), for an open sheet, and (and last_error) for null.
cadaclysm_blacksmith_hits_piece
bool cadaclysm_blacksmith_hits_piece(const struct CadaclysmBlacksmithHits *hits,
uint32_t i,
bool *inside,
struct CadaclysmBlacksmithSpot *start,
struct CadaclysmBlacksmithSpot *end);
Piece i (below cadaclysm_blacksmith_hits_piece_count): *inside true where the piece's midpoint winds inside solid, false outside (true too where the piece lies flat on the solid's surface); *start and *end the profile spots it runs between, in loop order, covering every loop exactly — a loop no hit cuts is one whole piece round the loop whose start and end are both (0, t=0); an open chain's own first and last pieces run from its own start and to its own end. false (and last_error) for null hits, a null inside, start or end, or i out of range.
cadaclysm_blacksmith_hits_piece_profile
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_hits_piece_profile(const struct CadaclysmBlacksmithHits *hits,
uint32_t i);
Piece i's own profile, as a handle of its own: the loop cut down to that piece alone, running along its segments with no holes — what cadaclysm_blacksmith_sweep_path_along(.., open: true) sweeps. Free it with cadaclysm_blacksmith_profile_free. Null (and last_error) for null hits or i out of range.
cadaclysm_blacksmith_profile_length
bool cadaclysm_blacksmith_profile_length(const struct CadaclysmBlacksmithProfile *profile,
double accuracy,
struct CadaclysmBlacksmithLength *out);
The perimeter of profile's outer loop — holes are not counted — to a relative accuracy in (0, 1) (0 or less asks for the default, measure.default_accuracy). false and last_error for a null profile, a null out, and an accuracy that is NaN, infinite, or 1 or more (refused rather than clamped).
cadaclysm_blacksmith_profile_polylines
struct CadaclysmBlacksmithPolylines cadaclysm_blacksmith_profile_polylines(const struct CadaclysmBlacksmithProfile *profile,
double tolerance);
The outline, then each hole, as polylines at z = 0, within tolerance of its arcs and splines: a closed loop repeats its first point at the end; an open chain (a profile ended open) is the segments it has. What a viewer draws a profile with. The arrays belong to the profile and stay valid until it is freed: each tolerance asked is flattened once and kept, so asking again at another tolerance — on this thread or any other — never moves or frees arrays already handed out. Safe to call on one profile from several threads at once; a profile asked at many distinct tolerances holds that many copies of its outline until it is freed.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_rect
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_rect(double w, double h);
A rectangle w by h centred on the origin. Null (and last_error) unless both are positive and finite.
cadaclysm_blacksmith_profile_circle
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_circle(double r);
A circle of radius r about the origin: two semicircular arcs, so an extrusion of it is two exact cylinder walls.
cadaclysm_blacksmith_profile_slot
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_slot(double cx,
double cy,
double length,
double r);
A stadium: a length-long slot of end radius r, centred at (cx, cy), running along x. length must exceed 2 * r.
cadaclysm_blacksmith_profile_polygon
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_polygon(const double *xy,
size_t count);
A closed polygon through count points, xy holding two doubles each, in order, with a side back to the first as its last segment. At least three points.
cadaclysm_blacksmith_profile_regular_polygon
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_regular_polygon(double cx,
double cy,
double radius,
uint32_t sides,
double angle);
A regular polygon of sides sides (3 to 1000000) on the circle of radius about (cx, cy), its first corner at angle radians from the sketch's x axis, the rest counter-clockwise; its side back to the first corner a segment of its own.
cadaclysm_blacksmith_profile_circumscribed_polygon
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_circumscribed_polygon(double cx,
double cy,
double radius,
uint32_t sides,
double angle);
A regular polygon of sides sides (3 to 1000000) whose sides touch the circle of radius about (cx, cy) — the polygon across flats, a nut's hex: its corners on the circle of radius / cos(π / sides), the first at angle radians from the sketch's x axis, the rest counter-clockwise, on the same rays as cadaclysm_blacksmith_profile_regular_polygon's corners with the same angle; each side's midpoint on the circle of radius.
cadaclysm_blacksmith_profile_star
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_star(double cx,
double cy,
double outer,
double inner,
uint32_t points,
double angle);
A star of points tips (3 to 1000000) on the circle of outer about (cx, cy), its inner corners on the circle of inner (positive, under outer), alternating: the first tip at angle radians from the sketch's x axis, the rest counter-clockwise, each inner corner half a step on from the tip before it — 2 * points straight sides.
cadaclysm_blacksmith_profile_spline
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_spline(const double *xy,
size_t count,
uint32_t degree,
const double *weights,
bool closed);
A spline of degree through the control polygon xy (count points), weights null or one per point. Open, it is clamped — it starts on the first point and ends on the last, an open chain; closed, it is periodic, smooth through its own start, a closed profile. The degree is lowered to fit the points. Refused for a degree of zero, too few points (two open, three closed), a point or weight not finite, a weight not positive.
cadaclysm_blacksmith_profile_round
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_round(const struct CadaclysmBlacksmithProfile *profile,
double radius,
const uint32_t *corners,
size_t count,
bool open);
profile with its corners rounded by radius, as a new profile: both segments cut back — lines, arcs and splines alike, each staying the curve it was — and an exact tangent arc put between them. A corner the two run straight on through is no corner. corners null rounds every corner, the holes' too; otherwise its count indices pick the corners of the boundary to round — corner k is where segment k ends — and a picked corner that runs straight on is refused. open treats the profile as an open chain, its two ends kept square; closed, the corner where the last segment meets the first (across the closing side, drawn or implicit) is rounded too. Refused where the radius does not fit.
cadaclysm_blacksmith_profile_chain
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_chain(const struct CadaclysmBlacksmithProfile *const *pieces,
size_t count,
double tolerance);
count open profiles joined end to end into one new profile, the kernel's merge: in any order and either way round, each next piece the first of the rest with an end within tolerance of either end of the chain so far, reversed where that makes it meet. Every segment is kept exactly; a joint is the chain's own point. Where the chain's two ends meet within tolerance the result is closed (its last segment landing on its start), otherwise an open chain. Refused (null, last_error "chain: ...") for no pieces, a negative or infinite tolerance, a piece empty, with holes or closed on its own, or a piece that meets none of the others — named by its index. The pieces are untouched.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_piece_count
uint32_t cadaclysm_blacksmith_profile_piece_count(const struct CadaclysmBlacksmithProfile *profile,
const struct CadaclysmBlacksmithProfile *const *cutters,
size_t count,
double tolerance);
How many pieces profile is cut into where the cutters (count profiles) cross, touch or run along it — the sketch trim's pieces: 1 where nothing cuts it. tolerance is how close two curves must come to meet; cuts closer than it to each other fold onto one. 0 and last_error for a null or empty profile. Piece index is cadaclysm_blacksmith_profile_piece.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_piece
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_piece(const struct CadaclysmBlacksmithProfile *profile,
const struct CadaclysmBlacksmithProfile *const *cutters,
size_t count,
uint32_t index,
double tolerance);
Piece index of profile cut by the cutters (see cadaclysm_blacksmith_profile_piece_count) as a new open profile: portions of the profile's own segments — a line's stretch a line, an arc's an arc, a spline's the same spline over part of its domain — in order along the curve from its start; a closed curve's piece round its start is one piece. Null and last_error for an index past the pieces.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_trim_count
uint32_t cadaclysm_blacksmith_profile_trim_count(const struct CadaclysmBlacksmithProfile *profile,
const struct CadaclysmBlacksmithProfile *const *cutters,
size_t count,
uint32_t piece,
double tolerance);
How many chains profile is left in with piece piece (of cadaclysm_blacksmith_profile_piece_count) taken away — the sketch trim: 1 for a closed curve, 1 or 2 for an open one, 0 where the piece was the whole curve. 0 and last_error for a piece the curve does not have — tell the two apart by last_error being set. Chain index is cadaclysm_blacksmith_profile_trim_chain.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_trim_chain
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_trim_chain(const struct CadaclysmBlacksmithProfile *profile,
const struct CadaclysmBlacksmithProfile *const *cutters,
size_t count,
uint32_t piece,
uint32_t index,
double tolerance);
Chain index of what is left of profile with piece piece taken away (see cadaclysm_blacksmith_profile_trim_count) as a new open profile: a closed curve's one chain starts where the removed piece ended and runs round to where it began; an open curve's are the stretches before and after. Null and last_error for an index past the chains.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_from_loops
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_from_loops(const struct CadaclysmBlacksmithProfile *const *loops,
size_t count);
loops (count closed profiles, no holes of their own) as one profile: the loop enclosing the most area its boundary, every other a hole in it, in the order given. Refused — null, with the reason in last_error, naming loops by their index — for a loop that is open, empty or of no area, loops that cross or touch, a hole outside the boundary or inside another.
cadaclysm_blacksmith_profile_close_loop
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_close_loop(const struct CadaclysmBlacksmithProfile *profile);
profile closed, as a new profile — the forge's sketch "close": where its last segment stops short of its start, a straight segment back to it; where it already comes back within 1e-9 of its extent, its last segment made to land on the start exactly. A closed profile comes back as it is. Holes are closed the same way.
cadaclysm_blacksmith_profile_from_pieces
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_from_pieces(const char *json,
bool closed,
double tolerance);
A profile from piece definitions: json a list in curve.polycurve's pieces grammar ({"kind": "line", "x0", "y0", "x1", "y1"}, "arc" through xm, ym, "circle", "ellipse", "rect", "polygon", "polyline", "spline"), each made exact, put in chain order and turned to run on, joined where ends meet within tolerance (0 or NaN: the pieces' effective tolerance). Closed where the chain's ends meet, or with a closing side when closed asks. Null and last_error (naming the piece by index) for a piece it cannot read or pieces that do not chain.
cadaclysm_blacksmith_profile_pieces_json
char *cadaclysm_blacksmith_profile_pieces_json(const struct CadaclysmBlacksmithProfile *profile);
profile's outline as piece definitions, JSON text, one per segment in order from its start: a line {x0, y0, x1, y1}; an arc {x0, y0, xm, ym, x1, y1} through its middle (a whole circle as two halves); anything else a cubic "spline" piece per Bézier (points four, degree 3, weights four). What cadaclysm_blacksmith_profile_from_pieces reads back to the same profile. Owned: release with cadaclysm_blacksmith_string_free. Null and last_error for a profile with holes.
cadaclysm_blacksmith_profile_fillet_corner
char *cadaclysm_blacksmith_profile_fillet_corner(const struct CadaclysmBlacksmithProfile *a,
const struct CadaclysmBlacksmithProfile *b,
double radius,
double tolerance);
A sketch fillet between two open profiles that meet at an end (within tolerance; 0 or NaN their effective tolerance): JSON text {"a": pieces, "b": pieces, "arc": piece}, a and b cut back to the tangent points, each running the way it ran, the arc from a's side to b's. Owned: release with cadaclysm_blacksmith_string_free. Null and last_error where they do not meet at an end, run straight on or fold back (lines, arcs and splines alike), or the radius does not fit.
cadaclysm_blacksmith_profile_bounds
bool cadaclysm_blacksmith_profile_bounds(const struct CadaclysmBlacksmithProfile *profile,
double *out);
The exact box of profile in its sketch into out — min x, min y, max x, max y — over the outline and the holes: the curves' own extremes, not their control points.
cadaclysm_blacksmith_profile_reversed
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_reversed(const struct CadaclysmBlacksmithProfile *profile);
profile walked the other way, as a new profile: its end the new start, its segments in reverse order, each turned round; each hole turned round in place. Twice is the profile.
cadaclysm_blacksmith_profile_polyline
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_polyline(const double *xy,
size_t count,
bool closed);
A polyline through count points (xy, two doubles each) in order, a straight segment per side: an open chain, or closed with a side from the last point back to the first. A side of no length is kept, so a corner dragged onto its neighbour still draws. Refused for fewer than two points (three closed) or a coordinate not finite.
cadaclysm_blacksmith_profile_arc
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_arc(double cx,
double cy,
double r,
double a0,
double a1);
An arc of radius r about (cx, cy) from angle a0 counter-clockwise to a1 (radians from the sketch's x axis), as one exact arc, open: the sweep is taken the counter-clockwise way round, a1 brought past a0 when it is not. Equal angles are the whole circle, closed, starting at a0. Refused for a radius not positive and finite, or a centre or angle not finite.
cadaclysm_blacksmith_profile_arc_through
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_arc_through(double x0,
double y0,
double xm,
double ym,
double x1,
double y1);
The arc from (x0, y0) through (xm, ym) to (x1, y1), as one exact arc leaving the start, open: the circle through the three points, swept the way round that passes the middle one. Refused when the three are in a line (two of them together included) or a coordinate is not finite.
cadaclysm_blacksmith_profile_ellipse
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_ellipse(double cx,
double cy,
double rx,
double ry);
An ellipse about (cx, cy) with semi-axes rx along x and ry along y, closed: four exact quarter conics counter-clockwise from (cx + rx, cy). Refused for a semi-axis not positive and finite or a centre not finite.
cadaclysm_blacksmith_profile_from_beziers
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_from_beziers(const double *beziers,
size_t count,
bool recognise);
count rational cubic Béziers end to end as one open profile, the first one's start its start: beziers holds sixteen doubles each, x y z w per control point (the point Cartesian, z ignored, its weight beside it) — the record cadaclysm_blacksmith_profile_beziers writes. recognise: a straight Bézier becomes an exact line and a circular one an exact arc (consecutive pieces of one circle merged into one arc), the rest kept as curves — what a trim, an extrusion or a fillet wants; otherwise every Bézier is kept as the exact rational cubic it is, so a chain or a close hands the same Béziers back. Refused for no Béziers, a number not finite or a weight not positive.
cadaclysm_blacksmith_profile_bezier_count
uint32_t cadaclysm_blacksmith_profile_bezier_count(const struct CadaclysmBlacksmithProfile *profile);
How many Béziers cadaclysm_blacksmith_profile_beziers writes for profile. 0 and last_error for a null profile.
cadaclysm_blacksmith_profile_beziers
bool cadaclysm_blacksmith_profile_beziers(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
double *out);
profile as rational cubic Béziers into out, sixteen doubles each — x y z w per control point, the point Cartesian and its weight beside it: a line one straight Bézier, an arc exact conic pieces of a quarter turn or less, a Bézier itself, a conic or a spline its own decomposition; the outline from its start, then each hole's. frame null: on the sketch plane, z = 0; otherwise a frame's twelve doubles — origin, x, y, z, as every call taking a frame reads them — and every point carried onto its plane (x normalised, y squared against it, z not read). Size out from cadaclysm_blacksmith_profile_bezier_count. false and last_error for a null argument or a frame whose directions are parallel, zero or not finite.
cadaclysm_blacksmith_profile_loops
bool cadaclysm_blacksmith_profile_loops(const struct CadaclysmBlacksmithProfile *const *pieces,
size_t count,
double tolerance,
uint32_t *out);
The closed loops among count profiles (pieces), each read by its outline's two ends — its start and where its last segment lands — the way a CAD sketch finds them: ends meet within tolerance; a loop is a chain of pieces through corners where exactly two ends meet (a corner of three or more is ambiguous, and no loop runs through it; a corner of one is an open end); a piece whose own two ends meet, a closed one included, is a loop of its own. Each piece is in at most one loop. Written into out flattened, exactly 2 * count values: per loop its length, then its pieces' indices in the order the loop runs, starting from its lowest index, the loops ordered by that index; then zeros — a length of 0 ends the list, so out[0] == 0 is no loop at all. false and last_error for a refusal (a null argument, a piece with holes or nothing drawn).
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_chain_order
bool cadaclysm_blacksmith_profile_chain_order(const struct CadaclysmBlacksmithProfile *const *pieces,
size_t count,
double tolerance,
uint32_t *out);
The order cadaclysm_blacksmith_profile_chain takes count profiles in, into out: for each piece from the chain's start to its end, its index, then 1 where it was turned round to meet the chain, else 0 — 2 * count values. Refused (false, last_error "chain: ...") as the chain is.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_with_hole
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_with_hole(const struct CadaclysmBlacksmithProfile *outer,
const struct CadaclysmBlacksmithProfile *hole);
outer with hole cut from it, as a new profile; both inputs are untouched. A hole must lie inside the outer boundary and clear of other holes — this does not check, the sweep that consumes it reports.
cadaclysm_blacksmith_path_begin
struct CadaclysmBlacksmithPath *cadaclysm_blacksmith_path_begin(double x, double y);
Start an outline at (x, y). Free it with cadaclysm_blacksmith_path_free if it is never ended.
cadaclysm_blacksmith_path_line_to
bool cadaclysm_blacksmith_path_line_to(struct CadaclysmBlacksmithPath *p, double x, double y);
A straight segment to (x, y).
cadaclysm_blacksmith_path_arc_to
bool cadaclysm_blacksmith_path_arc_to(struct CadaclysmBlacksmithPath *p,
double x,
double y,
double cx,
double cy,
bool ccw);
A circular arc to (x, y) about (cx, cy), counter-clockwise if ccw. The centre must be equidistant from the current point and the end; the sweep that consumes the profile reports one that is not.
cadaclysm_blacksmith_path_bezier_to
bool cadaclysm_blacksmith_path_bezier_to(struct CadaclysmBlacksmithPath *p,
double c1x,
double c1y,
double c2x,
double c2y,
double x,
double y);
A cubic Bezier to (x, y) with interior control points c1 and c2; the first control point is the current point.
cadaclysm_blacksmith_path_conic_to
bool cadaclysm_blacksmith_path_conic_to(struct CadaclysmBlacksmithPath *p,
double x,
double y,
double cx,
double cy,
double weight);
A conic arc to (x, y) through the control point (cx, cy) with middle weight weight: under 1 an elliptical arc, 1 a parabola, over 1 a hyperbola — the rational quadratic Bezier, kept exact. Refused for a weight not positive and finite, an end on the current point, or a control point on the chord.
cadaclysm_blacksmith_path_parabola_by_vertex
bool cadaclysm_blacksmith_path_parabola_by_vertex(struct CadaclysmBlacksmithPath *p,
double x,
double y,
double vx,
double vy);
The parabolic arc to (x, y) whose vertex is (vx, vy): the axis and focal length are solved from the two ends. Refused when the vertex lies on the chord or no parabola with that vertex passes through both ends (the vertex must be the arc's extreme point).
cadaclysm_blacksmith_path_parabola_by_focus
bool cadaclysm_blacksmith_path_parabola_by_focus(struct CadaclysmBlacksmithPath *p,
double x,
double y,
double fx,
double fy);
The parabolic arc to (x, y) whose focus is (fx, fy); of the two parabolas through the ends with that focus, the one whose vertex lies between the ends' projections, then the one whose arc cups the focus (the focus between the arc and its chord), then the more symmetric; with the focus beyond the chord that is the arch over the ends, not the shallow dish — draw that one with cadaclysm_blacksmith_path_parabola. Refused when the focus lies on the chord or is an end.
cadaclysm_blacksmith_path_parabola
struct CadaclysmBlacksmithPath *cadaclysm_blacksmith_path_parabola(double vx,
double vy,
double ax,
double ay,
double focal,
double from,
double to);
Start an outline on the arc of the parabola with vertex (vx, vy), axis direction (ax, ay) and focal length focal, over the across-axis coordinates from..to (from < to): the path begins at the arc's first point and holds the arc as one conic segment — a reflector from rim to rim. Null (and last_error) for a zero axis, a focal length not positive and finite, or from >= to. Free it with cadaclysm_blacksmith_path_free if it is never ended.
cadaclysm_blacksmith_path_nurbs_to
bool cadaclysm_blacksmith_path_nurbs_to(struct CadaclysmBlacksmithPath *p,
const double *control_xy,
size_t control_count,
const double *weights,
const double *knots,
size_t knot_count,
uint32_t degree);
A NURBS segment. control_xy holds every control point after the current point, the endpoint last (control_count of them, two doubles each); weights, if not null, one per control point *including* the current point (control_count + 1); knots the full repeated knot vector, knot_count = control_count + 1 + degree + 1. This is Segment::Nurbs's own rule.
cadaclysm_blacksmith_path_end
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_path_end(struct CadaclysmBlacksmithPath *p);
Close the path into a profile, consuming the builder (it is invalid after this call whether or not it succeeds). Fails unless the last segment ends at the start point, within 1e-9 of the outline's own extent.
cadaclysm_blacksmith_path_end_open
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_path_end_open(struct CadaclysmBlacksmithPath *p);
The path as it stands, open, as a profile — consuming the builder as path_end does, but without asking the last segment to reach the start. An open sweep (extrude_open, extrude_open_tapered, sweep_open, loft_open) draws its segments' walls and nothing across the gap; a closed one closes the gap with a straight side, as it closes every profile.
cadaclysm_blacksmith_path_free
void cadaclysm_blacksmith_path_free(struct CadaclysmBlacksmithPath *p);
Release a path that was never ended. Null is a no-op.
cadaclysm_blacksmith_profile_text
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_text(const char *text,
double size,
const char *font,
const uint8_t *font_bytes,
size_t font_len,
const char *halign,
const char *valign,
double spacing,
const char *direction);
text (UTF-8) set in a font, one profile per closed shape — a letter with its counters as holes (o one, 8 two; i is two profiles) — on the sketch plane, the baseline along x from the origin, each outline counter-clockwise and its holes clockwise, a curved side the font's own cubic Bezier kept exactly. size is roughly the height of a capital. font is a family, optionally with a style ("Liberation Sans:style=Bold"), a font file's path, or null/empty for the bundled Liberation Sans Regular, which also serves when the family is not found; font_bytes (font_len of them, or null) a font file's bytes, used instead of font when given. halign is "left", "center" or "right" (null: left); valign "baseline", "bottom", "center" or "top" (null: baseline); spacing multiplies the gap between glyphs (1 as the font has it); direction "ltr" or "rtl" (null: ltr). Empty text is a list with a count of 0. Null (and last_error) for null text, a size or spacing not positive and finite, an alignment or direction not one of those words, font bytes that are not a font.
cadaclysm_blacksmith_profile_common
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_common(const struct CadaclysmBlacksmithProfile *a,
const struct CadaclysmBlacksmithProfile *b,
double tolerance);
The region a and b share: zero or more profiles, each outer loop counter-clockwise and each hole clockwise, arcs and splines kept exact. An arc kept from an input can still come out split at that input's own seam point (two circles' lens is four arcs, one pair per circle) — exact, not an approximation. Two loops of a result may touch at a point (two holes whose corners meet, one from each input): a right point set that the verbs needing simple loops — extrude, a boolean taking it as an input — refuse. Both must be closed and simple. Null (and last_error) for a null profile, a tolerance negative or infinite, an open or self-crossing profile, a tolerance too fine for these profiles (following their arcs and splines to a tenth of it would take more than 8 million points, about 128 MB), and, as a defect rather than an outcome, a result that fails to close. No shared area is a list with a count of 0.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_to_arcs
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_to_arcs(const struct CadaclysmBlacksmithProfile *p,
double tolerance);
p with every free-form side (a Bezier, a conic, a NURBS) replaced by lines and arcs within tolerance of it both ways round — what a G-code writer can say. Lines and arcs pass through as they are, every loop closes on itself exactly, holes are converted the same way. Null (and last_error) for a null profile, a tolerance negative or infinite, a spline that does not evaluate.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_offset
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_offset(const struct CadaclysmBlacksmithProfile *p,
double distance,
double tolerance);
p grown by distance (shrunk where it is negative): zero or more profiles, all lines and arcs, outward corners rounded by |distance|, holes moving against the boundary. Free-form sides are fitted to tolerance first (cadaclysm_blacksmith_profile_to_arcs). A shrink that eats the whole profile is a list with a count of 0. Null (and last_error) for a null profile, a distance not finite, a tolerance negative or infinite, a loop with no sides, loops that cross or touch.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_list_count
uint32_t cadaclysm_blacksmith_profile_list_count(const struct CadaclysmBlacksmithProfileList *list);
How many profiles. 0 (and last_error) for null.
cadaclysm_blacksmith_profile_list_get
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_list_get(const struct CadaclysmBlacksmithProfileList *list,
uint32_t i);
Profile i, as a handle of its own: free it with cadaclysm_blacksmith_profile_free. Null (and last_error) when i is out of range.
cadaclysm_blacksmith_profile_list_free
void cadaclysm_blacksmith_profile_list_free(struct CadaclysmBlacksmithProfileList *list);
Release a list. Null is a no-op. Profiles taken from it with profile_list_get are independent and outlive it.
cadaclysm_blacksmith_profile_union
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_union(const struct CadaclysmBlacksmithProfile *a,
const struct CadaclysmBlacksmithProfile *b,
double tolerance);
The region a or b covers, exactly: zero or more profiles wound boundary counter-clockwise and holes clockwise, every side a piece of a side of an input, the same kind of curve — a profile list (read it with profile_list_count / profile_list_get, free it with profile_list_free). Null (and last_error) for a null profile, an input open or crossing itself, a negative or infinite tolerance.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_profile_difference
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_difference(const struct CadaclysmBlacksmithProfile *a,
const struct CadaclysmBlacksmithProfile *b,
double tolerance);
The region of a that b does not cover, exactly, as a profile list — see cadaclysm_blacksmith_profile_union for the terms.
cadaclysm_blacksmith_profile_regions
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_regions(const struct CadaclysmBlacksmithProfile *const *profiles,
size_t count,
double tolerance);
Every region the count closed profiles at profiles split the plane into, each once, as a profile list: each next profile splits every region so far into the part inside it and the part outside, and what of it no region covers is a region of its own — exact booleans throughout. Which inputs hold a region: those cadaclysm_blacksmith_profile_relationship calls A_INSIDE_B or EQUAL. Null (and last_error) for a null array or profile, the boolean refusals (named by the input's index). tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_profile_contains
int32_t cadaclysm_blacksmith_profile_contains(const struct CadaclysmBlacksmithProfile *p,
double x,
double y,
double tolerance);
Where (x, y) lies against the closed profile p: CADACLYSM_BLACKSMITH_CONTAINS_ON within tolerance of any loop (holes included; the distance exact to lines, arcs and splines), else _INSIDE or _OUTSIDE by the even-odd rule. An open chain is read closed by its implicit side. -1 (and last_error) for a null profile, a profile with no segments, a point not finite, a negative or infinite tolerance. tolerance 0 or NaN: the profile's effective tolerance.
cadaclysm_blacksmith_profile_relationship
int32_t cadaclysm_blacksmith_profile_relationship(const struct CadaclysmBlacksmithProfile *a,
const struct CadaclysmBlacksmithProfile *b,
double tolerance);
How the regions of the closed profiles a and b stand to each other: a CADACLYSM_BLACKSMITH_RELATION_* code, from the area of their exact common region against each one's area (slack: tolerance times the shorter perimeter) and whether their boundaries meet. -1 (and last_error) for a null profile, an input open or crossing itself, a negative or infinite tolerance. tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_profile_deviation
bool cadaclysm_blacksmith_profile_deviation(const struct CadaclysmBlacksmithProfile *a,
const struct CadaclysmBlacksmithProfile *b,
double tolerance,
double *out10);
The largest and smallest distance between the outlines (every loop) of a and b, both ways round, written to out10: the largest distance, its point on a (x, y), its point on b (x, y), then the smallest distance and its two points the same way. Every figure within tolerance of the true one. False (and last_error) for a null profile or out10, a profile with no segments, a negative or infinite tolerance, a spline that does not evaluate. tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_profile_offset_corner
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_offset_corner(const struct CadaclysmBlacksmithProfile *p,
double distance,
double tolerance,
uint32_t corner);
p grown by distance (shrunk where negative) as cadaclysm_blacksmith_profile_offset does, with every corner where the moved sides part styled corner (CADACLYSM_BLACKSMITH_OFFSET_ROUND, _SHARP, _SMOOTH, _CHAMFER): round is profile_offset itself; for the others each round join that came through whole is replaced, by an exact boolean, with the styled curve. A profile list. Null (and last_error) for the profile_offset refusals and an unknown style.
cadaclysm_blacksmith_profile_offset_open
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_offset_open(const struct CadaclysmBlacksmithProfile *p,
double distance,
double tolerance,
uint32_t corner,
uint32_t end);
p read as an open chain (its implicit closing side and holes ignored) and offset by distance, as a profile list. end CADACLYSM_BLACKSMITH_OFFSET_END_NONE: the one-sided offset, distance to the right of travel (negative, the left), open chains with the overlaps at inside corners trimmed. _FLAT / _ROUND: the closed outline both sides at |distance|, each end capped by a line across or a half circle. corner styles the joins as in cadaclysm_blacksmith_profile_offset_corner. Null (and last_error) for a null profile, a distance not finite (or 0 with ends), a negative or infinite tolerance, an unknown style, a chain with no sides.
cadaclysm_blacksmith_profile_reduce_segments
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_reduce_segments(const struct CadaclysmBlacksmithProfile *p,
double tolerance,
bool open);
p with every run of consecutive straight segments simplified by Douglas–Peucker within tolerance (a vertex goes where the run stays within tolerance of it), as a new profile. Arcs and splines, and the ends of every run, are kept. open reads p as an open chain; closed, it is closed by its implicit side first. Null (and last_error) for a null profile, a negative or infinite tolerance. tolerance 0 or NaN: the profile's effective tolerance.
cadaclysm_blacksmith_profile_merge_colinear
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_merge_colinear(const struct CadaclysmBlacksmithProfile *p,
double angle_tolerance,
bool open,
bool include_seam);
p with neighbouring segments that are one curve made one, as a new profile: two lines turning less than angle_tolerance radians, two arcs on one circle turning one way (unless together they would close it). include_seam merges a closed loop's last and first segments too. Null (and last_error) for a null profile or an angle outside [0, pi).
cadaclysm_blacksmith_profile_break_at_kinks
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_profile_break_at_kinks(const struct CadaclysmBlacksmithProfile *p,
double angle,
bool open);
p's outer loop cut into open pieces wherever the direction of travel turns by more than angle radians at a joint, as a profile list. A closed loop (open false) with no kink comes back whole; with kinks, as open pieces starting at its first. Null (and last_error) for a null profile, an angle outside [0, pi], no segments.
cadaclysm_blacksmith_profile_is_convex
int32_t cadaclysm_blacksmith_profile_is_convex(const struct CadaclysmBlacksmithProfile *p,
bool strict);
1 where the closed profile p is convex — no holes, and its outer loop turns one way only (every joint, arc and spline) through one full turn — 0 where not; strict also refuses a joint between two lines that does not turn. -1 (and last_error) for a null profile, no segments, a spline that does not evaluate.
cadaclysm_blacksmith_profile_make_closed
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_make_closed(const struct CadaclysmBlacksmithProfile *p,
double tolerance);
The open chain p closed by moving its end onto its start where the two are within tolerance, as a new profile: a line's end moves, an arc's centre moves onto the bisector of its new chord, a Bézier's end moves with its last inner control point, a spline's last control point moves. Null (and last_error) for a null profile, a gap wider than tolerance, a chain that closed would enclose nothing. tolerance 0 or NaN: the profile's effective tolerance.
cadaclysm_blacksmith_profile_with_seam
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_with_seam(const struct CadaclysmBlacksmithProfile *p,
double x,
double y);
The closed profile p with its outer loop restarted at its point nearest (x, y), as a new profile: the segment there split exactly and the loop rotated; a point at a joint rotates it without a split. Holes kept. Null (and last_error) for a null profile, no segments, a point not finite.
cadaclysm_blacksmith_translate_profile
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_translate_profile(const struct CadaclysmBlacksmithProfile *profile,
double dx,
double dy);
profile shifted by (dx, dy) in its own plane — to push a revolve's profile off the axis, or a hole off centre.
cadaclysm_blacksmith_profile_rotate
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_rotate(const struct CadaclysmBlacksmithProfile *profile,
double cx,
double cy,
double radians);
profile turned radians (counter-clockwise) about (cx, cy), its colour kept.
cadaclysm_blacksmith_profile_scale
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_scale(const struct CadaclysmBlacksmithProfile *profile,
double cx,
double cy,
double sx,
double sy);
profile scaled by sx, sy about (cx, cy): an arc stays an arc where |sx| = |sy|, and becomes exact conics otherwise. A negative factor mirrors; a zero one is refused as singular (NULL and last_error).
cadaclysm_blacksmith_profile_mirror
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_mirror(const struct CadaclysmBlacksmithProfile *profile,
double px,
double py,
double dx,
double dy);
profile reflected across the line through (px, py) along (dx, dy). A zero or non-finite direction is refused (NULL and last_error).
cadaclysm_blacksmith_profile_transform2d
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_profile_transform2d(const struct CadaclysmBlacksmithProfile *profile,
const double *m);
profile under the 2D affine map m (6 doubles, row-major 2×3: x' = m0 x + m1 y + m2, y' = m3 x + m4 y + m5). NULL for a singular map.
Sweep paths and slants
cadaclysm_blacksmith_slant_of_plane
bool cadaclysm_blacksmith_slant_of_plane(const double *frame,
const double *point,
const double *normal,
double *out);
The plane through point square to normal, read as heights over frame and written to out (at, grad.x, grad.y, for cadaclysm_blacksmith_extrude_between). false, with last_error set, when the plane holds the sweep direction itself — normal square to frame's z — so no height is on it.
cadaclysm_blacksmith_sweep_path_begin
struct CadaclysmBlacksmithSweepPath *cadaclysm_blacksmith_sweep_path_begin(double x,
double y,
double z);
Start a sweep path at (x, y, z): where the first piece begins. Free it with cadaclysm_blacksmith_sweep_path_free once done with it — sweeping only borrows a path, so a path built here is never consumed on its own.
cadaclysm_blacksmith_sweep_path_line_to
bool cadaclysm_blacksmith_sweep_path_line_to(struct CadaclysmBlacksmithSweepPath *p,
double x,
double y,
double z);
A straight piece to (x, y, z).
cadaclysm_blacksmith_sweep_path_arc
bool cadaclysm_blacksmith_sweep_path_arc(struct CadaclysmBlacksmithSweepPath *p,
double cx,
double cy,
double cz,
double ax,
double ay,
double az,
double angle);
A circular piece turning angle radians about the axis through (cx, cy, cz) with direction (ax, ay, az) (need not be unit) — the axis's own sense is which way it turns, axis × radial the direction of travel. angle must lie in (0, 2π]; the sweep that reads the path is what checks and reports that, not this call.
cadaclysm_blacksmith_sweep_path_along
struct CadaclysmBlacksmithSweepPath *cadaclysm_blacksmith_sweep_path_along(const struct CadaclysmBlacksmithProfile *curve,
const double *frame,
double tolerance,
bool open);
The sweep path the 2D chain curve draws on frame (twelve doubles): a line a straight piece, an arc a circular one about frame's z, a Bezier or spline fitted with biarcs — pairs of arcs tangent to each other and to the curve — within tolerance, so the path is tangent throughout. open walks the segments as given; closed, the path also runs back to the start along the side a profile leaves implicit. Refused for a chain with holes or no length. Free the path with cadaclysm_blacksmith_sweep_path_free.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_sweep_path_free
void cadaclysm_blacksmith_sweep_path_free(struct CadaclysmBlacksmithSweepPath *p);
Release a sweep path. Null is a no-op. Call this whether or not the path was ever swept — and even after it was swept more than once, since cadaclysm_blacksmith_sweep/cadaclysm_blacksmith_sweep_open never take ownership of it.
Sketches
cadaclysm_blacksmith_sketch_new
struct CadaclysmBlacksmithSketch *cadaclysm_blacksmith_sketch_new(void);
A new, empty sketch. Free it with cadaclysm_blacksmith_sketch_free.
cadaclysm_blacksmith_sketch_free
void cadaclysm_blacksmith_sketch_free(struct CadaclysmBlacksmithSketch *s);
Frees a sketch; null is a no-op.
cadaclysm_blacksmith_sketch_from_profile
struct CadaclysmBlacksmithSketch *cadaclysm_blacksmith_sketch_from_profile(const struct CadaclysmBlacksmithProfile *profile,
bool infer,
double tolerance);
A sketch built from a profile: its lines, arcs and curves become entities joined end to end, holes included. With infer true the obvious constraints (horizontal, vertical, tangent joints, ...) are added too; tolerance is the distance within which ends count as joined. Null on failure.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_sketch_add_point
uint32_t cadaclysm_blacksmith_sketch_add_point(struct CadaclysmBlacksmithSketch *s,
double x,
double y);
A free point at (x, y): its id, or CADACLYSM_BLACKSMITH_NONE (a coordinate that is not finite).
cadaclysm_blacksmith_sketch_add_line
uint32_t cadaclysm_blacksmith_sketch_add_line(struct CadaclysmBlacksmithSketch *s,
uint32_t a,
uint32_t b);
A line between the points a and b: its id, or CADACLYSM_BLACKSMITH_NONE (an unknown id, or a == b).
cadaclysm_blacksmith_sketch_add_circle
uint32_t cadaclysm_blacksmith_sketch_add_circle(struct CadaclysmBlacksmithSketch *s,
uint32_t centre,
double r);
A circle of radius r about the point centre: its id, or CADACLYSM_BLACKSMITH_NONE.
cadaclysm_blacksmith_sketch_add_arc
uint32_t cadaclysm_blacksmith_sketch_add_arc(struct CadaclysmBlacksmithSketch *s,
uint32_t centre,
uint32_t start,
uint32_t end);
A counter-clockwise arc about the point centre from the point start to the point end: its id, or CADACLYSM_BLACKSMITH_NONE.
cadaclysm_blacksmith_sketch_add_bezier
uint32_t cadaclysm_blacksmith_sketch_add_bezier(struct CadaclysmBlacksmithSketch *s,
uint32_t start,
double c1x,
double c1y,
double c2x,
double c2y,
double x,
double y);
A cubic Bezier free curve from the point start through the controls (c1x, c1y) and (c2x, c2y) to a new end point (x, y): its id, or CADACLYSM_BLACKSMITH_NONE. The curve owns its control points.
cadaclysm_blacksmith_sketch_add_conic
uint32_t cadaclysm_blacksmith_sketch_add_conic(struct CadaclysmBlacksmithSketch *s,
uint32_t start,
double cx,
double cy,
double x,
double y,
double weight);
A rational quadratic (conic) free curve from the point start with the control (cx, cy) and weight weight to a new end point (x, y): its id, or CADACLYSM_BLACKSMITH_NONE.
cadaclysm_blacksmith_sketch_add_nurbs
uint32_t cadaclysm_blacksmith_sketch_add_nurbs(struct CadaclysmBlacksmithSketch *s,
uint32_t start,
uint32_t degree,
const double *xy,
size_t count,
const double *weights,
const double *knots,
size_t knot_count);
A NURBS free curve of degree from the point start. xy holds count control points after the start as x, y pairs (2 * count doubles); weights is null for a plain B-spline or holds count + 1 weights (the start's first); knots holds knot_count knot values. The id, or CADACLYSM_BLACKSMITH_NONE.
cadaclysm_blacksmith_sketch_add_rect
const uint32_t *cadaclysm_blacksmith_sketch_add_rect(struct CadaclysmBlacksmithSketch *s,
double x0,
double y0,
double x1,
double y1,
size_t *count);
The rectangle with corners (x0, y0) and (x1, y1): 8 ids, the four corners counter-clockwise from (x0, y0) then the four sides (side i from corner i); borrowed, count set to 8. Null on failure.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_add_polygon
const uint32_t *cadaclysm_blacksmith_sketch_add_polygon(struct CadaclysmBlacksmithSketch *s,
double cx,
double cy,
double vx,
double vy,
uint32_t sides,
size_t *count);
A regular polygon of sides (3 to 1024) about (cx, cy), corner 0 at (vx, vy), sides kept equal and both construction circles about one centre point: 3 + 2 * sides ids, [centre, circumcircle, incircle, corners..., sides...] (side k runs corner k to corner k + 1); borrowed, count set. Dimension either circle to size it. Null on failure.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success.
cadaclysm_blacksmith_sketch_chamfer
const uint32_t *cadaclysm_blacksmith_sketch_chamfer(struct CadaclysmBlacksmithSketch *s,
uint32_t a,
uint32_t b,
double da,
double db,
size_t *count);
Cuts the corner where the lines a and b meet with a new line, da along a and db along b from the corner; the old corner point stays on both lines' extensions as the virtual sharp, dimensioned to the new ends. 6 ids, [line, point_a, point_b, corner, dimension_a, dimension_b]; borrowed, count set to 6. Null on failure (a distance not shorter than its line, parallel lines, a tangent held at that corner, ...); the sketch is then unchanged.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success.
cadaclysm_blacksmith_sketch_chamfer_angle
const uint32_t *cadaclysm_blacksmith_sketch_chamfer_angle(struct CadaclysmBlacksmithSketch *s,
uint32_t a,
uint32_t b,
double da,
double angle,
size_t *count);
As cadaclysm_blacksmith_sketch_chamfer, with angle (radians) the interior angle at the new point on a between a and the chamfer; dimension_b is then that angle (an ANGLE between a and the chamfer line). 6 ids, [line, point_a, point_b, corner, dimension_a, dimension_b]; borrowed, count set to 6. Null on failure.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success.
cadaclysm_blacksmith_sketch_pattern_rectangular
const uint32_t *cadaclysm_blacksmith_sketch_pattern_rectangular(struct CadaclysmBlacksmithSketch *s,
const uint32_t *ids,
size_t n,
double d1x,
double d1y,
uint32_t n1,
double d2x,
double d2y,
uint32_t n2,
size_t *count);
Copies the n entities in ids into an n1 by n2 grid (both counts include the source) along (d1x, d1y) and (d2x, d2y), held by TRANSLATED constraints and driving HORIZONTAL_DISTANCE / VERTICAL_DISTANCE dimensions on the steps. The list is [k, m, s, d, copies..., steps..., dimensions...]: k copies (the source excluded, row-major, fastest along d1) of the m = n entities, k * m ids copy-major (copy j's entity i at 4 + j * m + i), then s step ids (0 here), then d dimension ids (dx1, dy1 where n1 > 1, then dx2, dy2 where n2 > 1); borrowed, count set. Null on failure; the sketch is then unchanged.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success.
cadaclysm_blacksmith_sketch_pattern_circular
const uint32_t *cadaclysm_blacksmith_sketch_pattern_circular(struct CadaclysmBlacksmithSketch *s,
const uint32_t *ids,
size_t n,
uint32_t centre,
uint32_t count,
double step,
size_t *out_count);
Copies the n entities in ids round the point centre: count instances (the source included), each turned step radians counter-clockwise from the last, held by ROTATED constraints, two construction step lines and a driving ANGLE dimension between them. The list is [k, m, s, d, copies..., steps..., dimensions...] as for cadaclysm_blacksmith_sketch_pattern_rectangular: k = count - 1 copies of m = n entities, then the s = 2 step lines, then the d = 1 angle; borrowed, out_count set. Null on failure; the sketch is then unchanged.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success.
cadaclysm_blacksmith_sketch_auto_constrain
const uint32_t *cadaclysm_blacksmith_sketch_auto_constrain(struct CadaclysmBlacksmithSketch *s,
double tolerance,
bool dimensions,
size_t *count);
Adds the constraints the geometry already satisfies within tolerance (coincident ends, horizontal and vertical lines, tangent joints, parallel, perpendicular, concentric, equal, midpoint, point-on), each kept only where it removes a degree of freedom without a redundancy or conflict; with dimensions, driving dimensions at the measured values follow until nothing is free. The new constraint ids, ascending; borrowed, count set. Null on failure.
tolerance 0 or NaN: 1e-6 of the sketch's extent (the diagonal of its points' box).
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_kind
uint32_t cadaclysm_blacksmith_sketch_kind(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
The kind of entity id: one of the CADACLYSM_BLACKSMITH_SKETCH_ENTITY_* codes, or CADACLYSM_BLACKSMITH_NONE for an unknown id.
cadaclysm_blacksmith_sketch_entities
const uint32_t *cadaclysm_blacksmith_sketch_entities(struct CadaclysmBlacksmithSketch *s,
size_t *count);
The live entity ids, ascending; borrowed, count set. Null on failure.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_point
bool cadaclysm_blacksmith_sketch_point(const struct CadaclysmBlacksmithSketch *s,
uint32_t id,
double *out);
Writes the point id's position to out[0], out[1]. False if id is not a point.
cadaclysm_blacksmith_sketch_set_point
bool cadaclysm_blacksmith_sketch_set_point(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
double x,
double y);
Moves the point id to (x, y) without solving. False on failure.
cadaclysm_blacksmith_sketch_radius
double cadaclysm_blacksmith_sketch_radius(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
The radius of the circle or arc id; NaN on failure.
cadaclysm_blacksmith_sketch_set_radius
bool cadaclysm_blacksmith_sketch_set_radius(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
double r);
Sets the radius of the circle id to r without solving. False on failure.
cadaclysm_blacksmith_sketch_centre
uint32_t cadaclysm_blacksmith_sketch_centre(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
The centre point of the circle or arc id, or CADACLYSM_BLACKSMITH_NONE.
cadaclysm_blacksmith_sketch_ends
const uint32_t *cadaclysm_blacksmith_sketch_ends(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
size_t *count);
The points an entity runs between: a line's [a, b], an arc's [start, end], a free curve's [start, controls..., end]; borrowed, count set. Null on failure.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_set_construction
bool cadaclysm_blacksmith_sketch_set_construction(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
bool on);
Marks the entity id as construction geometry (helper geometry kept out of profiles) or back. False on failure.
cadaclysm_blacksmith_sketch_is_construction
bool cadaclysm_blacksmith_sketch_is_construction(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
Whether the entity id is construction geometry; false for an unknown id.
cadaclysm_blacksmith_sketch_is_reference
bool cadaclysm_blacksmith_sketch_is_reference(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
Whether the entity id is a reference copy of another sketch's entity (see cadaclysm_blacksmith_sketch_reference); false for an unknown id.
cadaclysm_blacksmith_sketch_remove_entity
const uint32_t *cadaclysm_blacksmith_sketch_remove_entity(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
size_t *count);
Removes the entity id and the constraints on it; the removed constraint ids come back borrowed, count set (a non-null pointer with count 0 when it held none). Null means refused: a point that lines or circles still use is in use, and cadaclysm_blacksmith_sketch_report_ids names the entities holding it.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty). Null when refused.
cadaclysm_blacksmith_sketch_reference
uint32_t cadaclysm_blacksmith_sketch_reference(struct CadaclysmBlacksmithSketch *s,
const struct CadaclysmBlacksmithSketch *other,
uint32_t entity);
A fixed construction copy of other's entity entity, kept in step with cadaclysm_blacksmith_sketch_update_reference: its id, or CADACLYSM_BLACKSMITH_NONE. other must not be s.
cadaclysm_blacksmith_sketch_update_reference
bool cadaclysm_blacksmith_sketch_update_reference(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
const struct CadaclysmBlacksmithSketch *other,
double *report);
Refreshes the reference id from other and re-solves; report gets {status, iterations, max_residual}. False on failure. other must not be s.
cadaclysm_blacksmith_sketch_constrain
uint32_t cadaclysm_blacksmith_sketch_constrain(struct CadaclysmBlacksmithSketch *s,
uint32_t kind,
const uint32_t *refs,
size_t ref_count,
double value,
bool driving,
uint32_t sense,
uint32_t end);
Adds a constraint of kind (a CADACLYSM_BLACKSMITH_SKETCH_CONSTRAINT_* code, named below without that prefix) on the ref_count entity ids in refs, in the order the kind lists them: COINCIDENT, HORIZONTAL, VERTICAL: point, point; POINT_ON_LINE, MIDPOINT: point, line; POINT_ON_CIRCLE: point, circle-or-arc; PARALLEL, PERPENDICULAR, COLLINEAR, EQUAL_LENGTH: line, line; TANGENT: curve, curve (sense); TANGENT_AT_END: free curve, other (end); CONCENTRIC, EQUAL_RADIUS: round, round; SYMMETRIC: point, point, line; FIX: entity; DISTANCE, HORIZONTAL_DISTANCE, VERTICAL_DISTANCE: point, point; POINT_LINE_DISTANCE: point, line (sense); LINE_DISTANCE: line, line (sense); CIRCLE_LINE_DISTANCE: round, line (sense); CIRCLE_DISTANCE: round, round; LENGTH: line; ANGLE: line, line; RADIUS, DIAMETER: round; SMOOTH: curve, curve; TRANSLATED: point a, point b, from, to; ROTATED: point a, point b, centre, from, to. Dimensions read value and driving (a non-driving dimension only reports); sense is read where listed (CADACLYSM_BLACKSMITH_SKETCH_SENSE_AUTO, _POSITIVE, _NEGATIVE) and end by TANGENT_AT_END (CADACLYSM_BLACKSMITH_SKETCH_END_START or _END_END); the rest are ignored. Returns the constraint id, or CADACLYSM_BLACKSMITH_NONE (a conflicting constraint names the ones it clashes with in cadaclysm_blacksmith_sketch_report_ids).
cadaclysm_blacksmith_sketch_constraints
const uint32_t *cadaclysm_blacksmith_sketch_constraints(struct CadaclysmBlacksmithSketch *s,
size_t *count);
The live constraint ids, ascending; borrowed, count set. Null on failure.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_constraint_kind
uint32_t cadaclysm_blacksmith_sketch_constraint_kind(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
The kind of constraint id (a CADACLYSM_BLACKSMITH_SKETCH_CONSTRAINT_* code), or CADACLYSM_BLACKSMITH_NONE for an unknown id.
cadaclysm_blacksmith_sketch_constraint_refs
const uint32_t *cadaclysm_blacksmith_sketch_constraint_refs(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
size_t *count);
The entity ids constraint id was made on, as passed to constrain; borrowed, count set. Null on failure.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_constraint_value
double cadaclysm_blacksmith_sketch_constraint_value(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
The value of the dimension id. NaN for a constraint that is not a dimension (no error is set) and for an unknown id (with the reason in the last error).
cadaclysm_blacksmith_sketch_constraint_driving
bool cadaclysm_blacksmith_sketch_constraint_driving(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
Whether the dimension id drives the geometry; false for a constraint that is not a dimension or an unknown id.
cadaclysm_blacksmith_sketch_constraint_sense
uint32_t cadaclysm_blacksmith_sketch_constraint_sense(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
The sense (CADACLYSM_BLACKSMITH_SKETCH_SENSE_*) of constraint id; _SENSE_AUTO for a kind without one, CADACLYSM_BLACKSMITH_NONE for an unknown id.
cadaclysm_blacksmith_sketch_constraint_end
uint32_t cadaclysm_blacksmith_sketch_constraint_end(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
The end of the free curve a TANGENT_AT_END constraint id holds: CADACLYSM_BLACKSMITH_SKETCH_END_START or _END_END, as passed to constrain. _END_START for every other kind (it has no end), CADACLYSM_BLACKSMITH_NONE for an unknown id.
cadaclysm_blacksmith_sketch_is_joint_tangent
bool cadaclysm_blacksmith_sketch_is_joint_tangent(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
Whether the tangent constraint id joins two curves end to end; false otherwise.
cadaclysm_blacksmith_sketch_remove
bool cadaclysm_blacksmith_sketch_remove(struct CadaclysmBlacksmithSketch *s, uint32_t id);
Removes the constraint id. False on failure.
cadaclysm_blacksmith_sketch_set_value
bool cadaclysm_blacksmith_sketch_set_value(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
double value,
double *report);
Sets the dimension id to value and re-solves; report gets {status, iterations, max_residual}. False on failure (not a dimension, ...).
cadaclysm_blacksmith_sketch_set_driving
bool cadaclysm_blacksmith_sketch_set_driving(struct CadaclysmBlacksmithSketch *s,
uint32_t id,
bool driving,
double *report);
Makes the dimension id drive the geometry (true) or only report it (false) and re-solves; report gets {status, iterations, max_residual}. False on failure.
cadaclysm_blacksmith_sketch_measure
double cadaclysm_blacksmith_sketch_measure(const struct CadaclysmBlacksmithSketch *s,
uint32_t id);
What the geometry measures for the dimension id right now (the length of a LENGTH, ...); NaN on failure.
cadaclysm_blacksmith_sketch_solve
bool cadaclysm_blacksmith_sketch_solve(struct CadaclysmBlacksmithSketch *s, double *report);
Solves; report gets {status, iterations, max_residual} with the status one of CADACLYSM_BLACKSMITH_SKETCH_STATUS_CONVERGED, _STATUS_CONFLICTING or _STATUS_DIVERGED. False only for a null sketch or report.
cadaclysm_blacksmith_sketch_drag
bool cadaclysm_blacksmith_sketch_drag(struct CadaclysmBlacksmithSketch *s,
const uint32_t *points,
const double *xy,
size_t count,
double *report);
Drags the count points in points towards the targets in xy (x, y pairs) while the constraints hold, as a live gesture would; report gets {status, iterations, max_residual}. False: refused (an id that is not a point, ...); otherwise read the report.
cadaclysm_blacksmith_sketch_report_ids
const uint32_t *cadaclysm_blacksmith_sketch_report_ids(const struct CadaclysmBlacksmithSketch *s,
size_t *count);
The ids the last call that can fail with ids or returns a report named: constrain, remove_entity, set_value, set_driving, update_reference, solve, drag, add_polygon, chamfer, chamfer_angle, pattern_rectangular, pattern_circular and auto_constrain each set it — the constraints a refusal clashes with or a report names, or the entities holding a point for an in-use refusal; empty when that call named none. Every other call leaves it as it was (the readers, the list readers entities, constraints, ends, constraint_refs, dof_list and dof_part_list, diagnose, the other add_* calls, the plain setters), so a refusal's ids survive refreshing the lists — also when one of those calls is refused before it runs (a null report or array, other null or s itself): it is empty then. Borrowed, count set.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_diagnose
bool cadaclysm_blacksmith_sketch_diagnose(struct CadaclysmBlacksmithSketch *s, double *out);
Diagnoses the sketch's degrees of freedom: out gets {free, state, part_count} with the state one of CADACLYSM_BLACKSMITH_SKETCH_STATE_UNDER, _STATE_FULL or _STATE_OVER. The diagnosis is kept for the dof_* calls until the next call that changes the sketch.
cadaclysm_blacksmith_sketch_dof_list
const uint32_t *cadaclysm_blacksmith_sketch_dof_list(struct CadaclysmBlacksmithSketch *s,
uint32_t which,
size_t *count);
A list from the last diagnosis: which is CADACLYSM_BLACKSMITH_SKETCH_DOF_REDUNDANT, _DOF_CONFLICTING (constraint ids) or _DOF_FREE_ENTITIES (entity ids); borrowed, count set. Null if the sketch was not diagnosed ("call sketch_diagnose first") or which is unknown.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_dof_part
bool cadaclysm_blacksmith_sketch_dof_part(const struct CadaclysmBlacksmithSketch *s,
uint32_t part,
double *out);
One independent part of the diagnosed sketch (0 to part_count - 1): out gets {params, free, state}. False if not diagnosed or out of range.
cadaclysm_blacksmith_sketch_dof_part_list
const uint32_t *cadaclysm_blacksmith_sketch_dof_part_list(struct CadaclysmBlacksmithSketch *s,
uint32_t part,
uint32_t which,
size_t *count);
A list of one part of the diagnosed sketch: which is CADACLYSM_BLACKSMITH_SKETCH_PART_CONSTRAINTS, _PART_REDUNDANT, _PART_CONFLICTING (constraint ids) or _PART_FREE_ENTITIES (entity ids); borrowed, count set. Null if not diagnosed, out of range or which is unknown.
Borrowed: valid until the next call on this sketch or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_sketch_profiles
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_sketch_profiles(const struct CadaclysmBlacksmithSketch *s,
double tolerance);
The sketch's closed loops as profiles (nested loops become holes); tolerance joins ends. Construction geometry is left out. Free with cadaclysm_blacksmith_profile_list_free. Null on failure.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_sketch_open_chains
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_sketch_open_chains(const struct CadaclysmBlacksmithSketch *s,
double tolerance);
The sketch's open chains (paths that do not close) as profiles; tolerance joins ends. Free with cadaclysm_blacksmith_profile_list_free. Null on failure.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Garments
cadaclysm_blacksmith_garment_new
struct CadaclysmBlacksmithGarment *cadaclysm_blacksmith_garment_new(void);
A new, empty garment. Free it with cadaclysm_blacksmith_garment_free.
cadaclysm_blacksmith_garment_free
void cadaclysm_blacksmith_garment_free(struct CadaclysmBlacksmithGarment *g);
Frees a garment; null is a no-op. Every borrowed pointer it lent dies with it.
cadaclysm_blacksmith_garment_add_fabric
uint32_t cadaclysm_blacksmith_garment_add_fabric(struct CadaclysmBlacksmithGarment *g,
const char *name,
const double *params);
Adds a fabric called name with CADACLYSM_BLACKSMITH_GARMENT_FABRIC_PARAMS (20) parameters: its id, or CADACLYSM_BLACKSMITH_NONE.
cadaclysm_blacksmith_garment_fabric_params
bool cadaclysm_blacksmith_garment_fabric_params(const struct CadaclysmBlacksmithGarment *g,
uint32_t id,
double *out);
Writes fabric id's 20 parameters to out. False for an unknown id.
cadaclysm_blacksmith_garment_fabric_name
char *cadaclysm_blacksmith_garment_fabric_name(const struct CadaclysmBlacksmithGarment *g,
uint32_t id);
Fabric id's name. Owned: free it with cadaclysm_blacksmith_string_free. Null for an unknown id.
cadaclysm_blacksmith_garment_add_pattern
uint32_t cadaclysm_blacksmith_garment_add_pattern(struct CadaclysmBlacksmithGarment *g,
const char *name,
const struct CadaclysmBlacksmithProfile *outline,
double grain_x,
double grain_y,
uint32_t fabric,
int32_t layer,
const double *allowance,
size_t count);
Adds a pattern called name with the closed outline (its holes are kept), the grain direction (grain_x, grain_y), the fabric id, a layer (stacking order) and the seam allowance: count widths, either 1 (every side) or one per side. Its id, or CADACLYSM_BLACKSMITH_NONE. The pattern starts on the origin, flat.
cadaclysm_blacksmith_garment_pattern_name
char *cadaclysm_blacksmith_garment_pattern_name(const struct CadaclysmBlacksmithGarment *g,
uint32_t id);
Pattern id's name. Owned: free it with cadaclysm_blacksmith_string_free. Null for an unknown id.
cadaclysm_blacksmith_garment_pattern_outline
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_garment_pattern_outline(const struct CadaclysmBlacksmithGarment *g,
uint32_t id);
Pattern id's outline as a new profile: free it with cadaclysm_blacksmith_profile_free. Null for an unknown id.
cadaclysm_blacksmith_garment_pattern_info
bool cadaclysm_blacksmith_garment_pattern_info(const struct CadaclysmBlacksmithGarment *g,
uint32_t id,
double *out);
Writes pattern id's {grain_x, grain_y, fabric, layer} to out[0..4]. False for an unknown id.
cadaclysm_blacksmith_garment_pattern_allowance
const double *cadaclysm_blacksmith_garment_pattern_allowance(struct CadaclysmBlacksmithGarment *g,
uint32_t id,
size_t *count);
Pattern id's seam allowances, one per side; borrowed, count set. Null for an unknown id.
Borrowed: valid until the next call on this garment or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_garment_pattern_set_frame
bool cadaclysm_blacksmith_garment_pattern_set_frame(struct CadaclysmBlacksmithGarment *g,
uint32_t id,
const double *frame);
Places pattern id in space: frame is 12 doubles, the origin then the x, y and z axes. False for an unknown id or a value that is not finite.
cadaclysm_blacksmith_garment_pattern_frame
bool cadaclysm_blacksmith_garment_pattern_frame(const struct CadaclysmBlacksmithGarment *g,
uint32_t id,
double *out);
Writes pattern id's frame (origin, x, y, z axes) to out[0..12]. False for an unknown id.
cadaclysm_blacksmith_garment_pattern_set_wrap
bool cadaclysm_blacksmith_garment_pattern_set_wrap(struct CadaclysmBlacksmithGarment *g,
uint32_t id,
const double *wrap);
Wraps pattern id round a cylinder: wrap is 7 doubles, {ox, oy, oz, dx, dy, dz, radius} (a point on the axis, the axis direction, the radius). Null clears the wrap. False for an unknown id, a radius not above 0 or a zero direction.
cadaclysm_blacksmith_garment_pattern_add_notch
bool cadaclysm_blacksmith_garment_pattern_add_notch(struct CadaclysmBlacksmithGarment *g,
uint32_t id,
double at,
uint32_t kind,
double depth);
Adds a notch to pattern id at arc length at along its outline: kind is one of the CADACLYSM_BLACKSMITH_GARMENT_NOTCH_* codes, depth how far it cuts. False on failure.
cadaclysm_blacksmith_garment_pattern_notches
const double *cadaclysm_blacksmith_garment_pattern_notches(struct CadaclysmBlacksmithGarment *g,
uint32_t id,
size_t *count);
Pattern id's notches as triples {at, kind, depth}; borrowed, count set (a multiple of 3). Null for an unknown id.
Borrowed: valid until the next call on this garment or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_garment_pattern_add_internal
bool cadaclysm_blacksmith_garment_pattern_add_internal(struct CadaclysmBlacksmithGarment *g,
uint32_t id,
uint32_t kind,
const struct CadaclysmBlacksmithProfile *path);
Adds an internal line to pattern id: kind is one of the CADACLYSM_BLACKSMITH_GARMENT_INTERNAL_* codes, path a profile read as an open path: the profile's segments are copied as given (a closed profile keeps its closing segment); holes are ignored. False on failure.
cadaclysm_blacksmith_garment_add_seam
uint32_t cadaclysm_blacksmith_garment_add_seam(struct CadaclysmBlacksmithGarment *g,
uint32_t pa,
double a_from,
double a_to,
uint32_t pb,
double b_from,
double b_to,
bool reversed);
Sews pattern pa between arc lengths a_from and a_to to pattern pb between b_from and b_to; reversed sews them against each other's direction. The seam's id, or CADACLYSM_BLACKSMITH_NONE.
cadaclysm_blacksmith_garment_seam
bool cadaclysm_blacksmith_garment_seam(const struct CadaclysmBlacksmithGarment *g,
uint32_t id,
double *out);
Writes seam id as {pa, a_from, a_to, pb, b_from, b_to, reversed} to out[0..7] (reversed is 0 or 1). False for an unknown id.
cadaclysm_blacksmith_garment_remove_pattern
bool cadaclysm_blacksmith_garment_remove_pattern(struct CadaclysmBlacksmithGarment *g,
uint32_t id);
Removes pattern id and every seam that names it. False for an unknown id.
cadaclysm_blacksmith_garment_remove_seam
bool cadaclysm_blacksmith_garment_remove_seam(struct CadaclysmBlacksmithGarment *g,
uint32_t id);
Removes seam id. False for an unknown id.
cadaclysm_blacksmith_garment_patterns
const uint32_t *cadaclysm_blacksmith_garment_patterns(struct CadaclysmBlacksmithGarment *g,
size_t *count);
The live pattern ids, ascending; borrowed, count set. Null on failure.
Borrowed: valid until the next call on this garment or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_garment_seams
const uint32_t *cadaclysm_blacksmith_garment_seams(struct CadaclysmBlacksmithGarment *g,
size_t *count);
The live seam ids, ascending; borrowed, count set. Null on failure.
Borrowed: valid until the next call on this garment or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_garment_fabrics
const uint32_t *cadaclysm_blacksmith_garment_fabrics(struct CadaclysmBlacksmithGarment *g,
size_t *count);
The live fabric ids, ascending; borrowed, count set. Null on failure.
Borrowed: valid until the next call on this garment or its free; copy it. Never null on success (count 0 when empty).
cadaclysm_blacksmith_garment_validate
uint32_t cadaclysm_blacksmith_garment_validate(struct CadaclysmBlacksmithGarment *g,
double accuracy);
Checks the garment at accuracy (a fraction in (0, 1) that sets how finely outlines are measured) and caches the issues for cadaclysm_blacksmith_garment_issue: the issue count. CADACLYSM_BLACKSMITH_NONE only for a null garment: a bad accuracy becomes an UNMEASURABLE issue, not a failure. Any mutating call clears the cache.
cadaclysm_blacksmith_garment_issue
bool cadaclysm_blacksmith_garment_issue(const struct CadaclysmBlacksmithGarment *g,
uint32_t i,
double *out);
Writes issue i of the last validation as {severity, kind, ratio} to out[0..3]: the CADACLYSM_BLACKSMITH_GARMENT_SEVERITY_* and _ISSUE_* codes, and the seam-length mismatch's length ratio (NaN for every other kind). False, with "call garment_validate first" in last_error, when no validation is cached (any mutating call clears it), or for an i past the issue count.
cadaclysm_blacksmith_garment_issue_message
char *cadaclysm_blacksmith_garment_issue_message(const struct CadaclysmBlacksmithGarment *g,
uint32_t i);
Issue i's message. Owned: free it with cadaclysm_blacksmith_string_free. Null when no validation is cached or i is past the issue count.
cadaclysm_blacksmith_garment_cut_line
const double *cadaclysm_blacksmith_garment_cut_line(struct CadaclysmBlacksmithGarment *g,
uint32_t pattern,
double tolerance,
size_t *count);
A pattern's cut line (its sew line grown by the allowance) as xy pairs, flattened to tolerance; borrowed, count set to the number of doubles (twice the points). Null on failure.
Borrowed: valid until the next call on this garment or its free; copy it.
cadaclysm_blacksmith_garment_range_points
const double *cadaclysm_blacksmith_garment_range_points(struct CadaclysmBlacksmithGarment *g,
uint32_t pattern,
double from,
double to,
double tolerance,
size_t *count);
The part of a pattern's outline between arc lengths from and to as xy pairs, flattened to tolerance; borrowed, count set to the number of doubles. Null on failure.
Borrowed: valid until the next call on this garment or its free; copy it.
cadaclysm_blacksmith_garment_to_aama
char *cadaclysm_blacksmith_garment_to_aama(const struct CadaclysmBlacksmithGarment *g,
double tolerance,
const char *author);
The garment's patterns as an AAMA DXF, curves flattened to tolerance, with author in the header (null or empty for none). AAMA output is written as metric, so a garment from a non-millimetre document must be converted to millimetres first. Owned: free it with cadaclysm_blacksmith_string_free. Null on failure.
cadaclysm_blacksmith_garment_from_aama
struct CadaclysmBlacksmithGarment *cadaclysm_blacksmith_garment_from_aama(const char *text);
A garment read from AAMA DXF text: its patterns over one fabric, id 0, called "imported", with all-zero parameters. Free it with cadaclysm_blacksmith_garment_free. Null on failure.
Cloth
cadaclysm_blacksmith_cloth_new
struct CadaclysmBlacksmithCloth *cadaclysm_blacksmith_cloth_new(const struct CadaclysmBlacksmithGarment *g,
const double *avatar_positions,
size_t position_count,
const uint32_t *avatar_indices,
size_t index_count,
const double *options);
Meshes the garment g and builds a cloth on an avatar mesh: avatar_positions are xyz triples (position_count doubles, a multiple of 3), avatar_indices index triples (index_count, a multiple of 3). Both counts 0 means no avatar, whatever the pointers; exactly one count 0 is refused (positions and indices come together). options is null for the defaults, else CADACLYSM_BLACKSMITH_CLOTH_OPTIONS (20) doubles. The cloth does not keep g. Null and last_error on a refusal; free it with cadaclysm_blacksmith_cloth_free.
cadaclysm_blacksmith_cloth_new_stl
struct CadaclysmBlacksmithCloth *cadaclysm_blacksmith_cloth_new_stl(const struct CadaclysmBlacksmithGarment *g,
const uint8_t *stl,
size_t len,
const double *options);
As cadaclysm_blacksmith_cloth_new, with the avatar read from len bytes of a binary or ASCII STL file.
cadaclysm_blacksmith_cloth_free
void cadaclysm_blacksmith_cloth_free(struct CadaclysmBlacksmithCloth *c);
Frees a cloth; null is a no-op. Every borrowed pointer it lent dies with it.
cadaclysm_blacksmith_cloth_default_options
bool cadaclysm_blacksmith_cloth_default_options(double *out);
Writes the options a new cloth starts with to out (CADACLYSM_BLACKSMITH_CLOTH_OPTIONS doubles).
cadaclysm_blacksmith_cloth_options
bool cadaclysm_blacksmith_cloth_options(const struct CadaclysmBlacksmithCloth *c, double *out);
Writes the cloth's options to out (CADACLYSM_BLACKSMITH_CLOTH_OPTIONS doubles).
cadaclysm_blacksmith_cloth_set_options
bool cadaclysm_blacksmith_cloth_set_options(struct CadaclysmBlacksmithCloth *c,
const double *options);
Sets the cloth's options from 20 doubles. particle_distance must equal the cloth's: the mesh is not rebuilt. False and last_error on a refusal (the options are then unchanged).
cadaclysm_blacksmith_cloth_step
bool cadaclysm_blacksmith_cloth_step(struct CadaclysmBlacksmithCloth *c, uint32_t frames);
Advances the simulation by frames frames (each frame_dt seconds). Borrowed lists lent before the call are no longer valid.
cadaclysm_blacksmith_cloth_status
bool cadaclysm_blacksmith_cloth_status(const struct CadaclysmBlacksmithCloth *c, double *out);
Writes the status to out (CADACLYSM_BLACKSMITH_CLOTH_STATUS doubles): {frame, vertices, triangles, seam_pairs, welded_pairs, non_finite, dropped, max_speed}. seam_pairs is the seam pairs in the sim mesh: sewing is done when welded_pairs == seam_pairs.
cadaclysm_blacksmith_cloth_positions
const float *cadaclysm_blacksmith_cloth_positions(struct CadaclysmBlacksmithCloth *c,
size_t *count);
The current position of every sim vertex, xyz triples in mm: count is the number of floats (3 per vertex). Borrowed: the pointer is valid until the next call on the cloth or its free (callers copy); cadaclysm_blacksmith_cloth_remesh_pattern changes the counts. Null and last_error for a null cloth.
cadaclysm_blacksmith_cloth_triangles
const uint32_t *cadaclysm_blacksmith_cloth_triangles(struct CadaclysmBlacksmithCloth *c,
size_t *count);
The triangles as sim-vertex indices, 3 per triangle: count is the number of indices. Borrowed: valid until the next call on the cloth or its free (callers copy); cadaclysm_blacksmith_cloth_remesh_pattern changes the counts. Null for a null cloth.
cadaclysm_blacksmith_cloth_rest
const float *cadaclysm_blacksmith_cloth_rest(struct CadaclysmBlacksmithCloth *c, size_t *count);
Each sim vertex's arranged start position in 3D, xyz triples in mm: count is the number of floats. Borrowed: valid until the next call on the cloth or its free (callers copy); cadaclysm_blacksmith_cloth_remesh_pattern changes the counts. Null for a null cloth.
cadaclysm_blacksmith_cloth_vertex_patterns
const uint32_t *cadaclysm_blacksmith_cloth_vertex_patterns(struct CadaclysmBlacksmithCloth *c,
size_t *count);
The pattern id each sim vertex belongs to: count is the number of vertices. Borrowed: valid until the next call on the cloth or its free (callers copy); cadaclysm_blacksmith_cloth_remesh_pattern changes the counts. Null for a null cloth.
cadaclysm_blacksmith_cloth_vertex_links
const double *cadaclysm_blacksmith_cloth_vertex_links(struct CadaclysmBlacksmithCloth *c,
size_t *count);
Each sim vertex's exact absolute position on its pattern, (u, v) pairs in mm: count is the number of doubles (2 per vertex). Borrowed: valid until the next call on the cloth or its free (callers copy); cadaclysm_blacksmith_cloth_remesh_pattern changes the counts. Null for a null cloth.
cadaclysm_blacksmith_cloth_vertex_link
bool cadaclysm_blacksmith_cloth_vertex_link(const struct CadaclysmBlacksmithCloth *c,
uint32_t vertex,
double *out);
Writes vertex vertex's link to out: {pattern, u, v}. False for a vertex that is not a sim vertex.
cadaclysm_blacksmith_cloth_pin
bool cadaclysm_blacksmith_cloth_pin(struct CadaclysmBlacksmithCloth *c,
uint32_t vertex,
const double *at);
Pins vertex vertex at at (3 doubles, mm), or where it is now when at is null. False for a vertex that is not a sim vertex.
cadaclysm_blacksmith_cloth_unpin
bool cadaclysm_blacksmith_cloth_unpin(struct CadaclysmBlacksmithCloth *c, uint32_t vertex);
Releases a pin. False for a vertex that is not a sim vertex.
cadaclysm_blacksmith_cloth_drag
bool cadaclysm_blacksmith_cloth_drag(struct CadaclysmBlacksmithCloth *c,
uint32_t vertex,
const double *target);
Drags vertex vertex towards target (3 doubles, mm); a null target releases the drag. False for a vertex that is not a sim vertex.
cadaclysm_blacksmith_cloth_remesh_pattern
bool cadaclysm_blacksmith_cloth_remesh_pattern(struct CadaclysmBlacksmithCloth *c,
const struct CadaclysmBlacksmithGarment *g,
uint32_t pattern);
Re-meshes pattern pattern after its outline changed in garment g. The vertex and triangle counts may change, so every borrowed pointer lent before is dead and callers re-read the lists.
Construction planes
cadaclysm_blacksmith_frame_midplane
bool cadaclysm_blacksmith_frame_midplane(const double *a, const double *b, double *out);
The plane midway between the planes of frames a and b (twelve doubles each), twelve doubles into out: for parallel planes the one halfway between, on a's axes; for planes that meet, the plane bisecting them through the line they meet on, its x along that line. false and last_error for a frame with no normal.
cadaclysm_blacksmith_frame_through
bool cadaclysm_blacksmith_frame_through(const double *p,
const double *q,
const double *r,
double *out);
The plane through the points p, q and r (three doubles each), twelve doubles into out: its origin p, its x towards q, its z the normal the three turn about counter-clockwise. false and last_error for three points on one line.
cadaclysm_blacksmith_frame_fit
bool cadaclysm_blacksmith_frame_fit(const double *xyz,
size_t count,
double *out,
double *deviation_out);
The least-squares plane through count points (xyz, three doubles each) as a frame into out, and the largest distance any point sits off it into deviation_out (NULL when not wanted). z faces world +Z, x by the same rule.
Building solids
cadaclysm_blacksmith_loft_curves
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_loft_curves(const struct CadaclysmBlacksmithNurbsCurve *const *sections,
size_t count,
uint32_t degree,
bool loose,
bool closed);
The sheet lofted through count section curves (loose: shaped by them, passing only the first and last), degree across them (lowered to fit), periodic across them when closed (the last section back to the first). One face on one NURBS surface.
cadaclysm_blacksmith_extrude_to
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude_to(const struct CadaclysmBlacksmithSolid *sheet,
const uint32_t *edges,
size_t count,
const double *direction,
const struct CadaclysmBlacksmithSolid *target,
double tolerance,
bool join,
double *error_out);
Each of the count naked edges of sheet (indices into the list cadaclysm_blacksmith_edge walks) slid along direction (three doubles) until it meets target: every point of the edge travels along the direction to its first hit on target's faces. One wall per edge — the edge's own curve swept straight, bounded by the curve through the hits, fitted within tolerance of every hit (the largest distance to error_out when not NULL). Sewn to sheet when join (the sheet's faces first, then one per edge), else returned alone, sewn to each other. Refused as flange is, and for a direction of no length, a point whose line misses the target (named) and an edge touching it.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_cuboid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_cuboid(double x, double y, double z);
A box x by y by z, centred on the origin. Six planes.
cadaclysm_blacksmith_cylinder
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_cylinder(double r, double h);
A cylinder of radius r, height h, based on z=0 and rising along +z.
cadaclysm_blacksmith_cone
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_cone(double r, double h);
A cone of base radius r and height h, apex up.
cadaclysm_blacksmith_sphere
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sphere(double r);
A sphere of radius r about the origin.
cadaclysm_blacksmith_torus
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_torus(double major, double minor);
A torus of ring radius major and tube radius minor, about z.
cadaclysm_blacksmith_wedge
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_wedge(double x,
double y,
double z,
double top_x);
A wedge: a box x by y by z whose top face is narrowed to top_x along x.
cadaclysm_blacksmith_pyramid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_pyramid(uint32_t sides,
double r,
double h);
A right pyramid of sides sides (at least 3): its base the regular polygon of circumradius r on z=0, its first corner on +x, its tip at (0, 0, h).
cadaclysm_blacksmith_extrude
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
double height);
profile swept height along the frame's z, closed with two caps. The profile's own x/y are the frame's x/y.
cadaclysm_blacksmith_extrude_open
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude_open(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
double height);
cadaclysm_blacksmith_extrude without the caps: an open sheet of walls.
cadaclysm_blacksmith_extrude_between
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude_between(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const double *bottom,
const double *top);
cadaclysm_blacksmith_extrude between two planes instead of two heights: bottom and top are each three doubles — at, grad.x, grad.y — a plane read as its height over the sketch plane at each point, at + grad · p. The profile's walls run from where bottom cuts them to where top does, the caps lying on those planes. With both flat this *is* cadaclysm_blacksmith_extrude (bit for bit: a flat slant's height is its at); with a slope it is the mitred end of a sweep's straight piece. cadaclysm_blacksmith_slant_of_plane builds a slant from a plane through a point.
Refused (null, last_error set "extrude_between: ...") where the top plane comes down to or through the bottom across the profile — a mitre too sharp for the profile's width — besides extrude's own refusals.
cadaclysm_blacksmith_extrude_open_between
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude_open_between(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const double *bottom,
const double *top);
cadaclysm_blacksmith_extrude_between without the caps: an open sheet of walls running from bottom to top, as cadaclysm_blacksmith_extrude_open is to cadaclysm_blacksmith_extrude. The same refusals.
cadaclysm_blacksmith_extrude_tapered
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude_tapered(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
double height,
double taper);
cadaclysm_blacksmith_extrude with a draft: the walls lean out by taper radians as they rise (in, when negative — the profile is walked counter-clockwise, and a positive taper leans to the right of that walk), every wall exact — a plane off a line, a cone off an arc. A taper of zero is extrude itself; one that would close a side before the top is refused.
cadaclysm_blacksmith_extrude_open_tapered
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude_open_tapered(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
double height,
double taper);
cadaclysm_blacksmith_extrude_tapered without the caps: the drafted walls alone, leaning to the right of the curve's walk.
cadaclysm_blacksmith_loft
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_loft(const struct CadaclysmBlacksmithProfile *a,
const double *frame_a,
const struct CadaclysmBlacksmithProfile *b,
const double *frame_b);
The solid between profile a drawn on frame_a and profile b drawn on frame_b: ruled walls between matching sides, capped by the two profiles. The profiles must have the same number of sides and no holes; b is turned to start from the side nearest a's first.
cadaclysm_blacksmith_loft_open
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_loft_open(const struct CadaclysmBlacksmithProfile *a,
const double *frame_a,
const struct CadaclysmBlacksmithProfile *b,
const double *frame_b);
cadaclysm_blacksmith_loft without the caps: the sheet ruled between the two curves.
cadaclysm_blacksmith_loft_through
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_loft_through(const struct CadaclysmBlacksmithProfile *const *profiles,
const double *frames,
size_t count);
The solid smooth through count profiles, each on its frame (frames twelve doubles a profile, in order): every wall interpolates its side across all the profiles — cubic through four or more, quadratic through three, the ruled cadaclysm_blacksmith_loft through two — capped by the first and the last. The profiles must have the same number of sides and no holes.
cadaclysm_blacksmith_loft_through_open
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_loft_through_open(const struct CadaclysmBlacksmithProfile *const *profiles,
const double *frames,
size_t count);
cadaclysm_blacksmith_loft_through without the caps: the sheet through the curves.
cadaclysm_blacksmith_revolve
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_revolve(const struct CadaclysmBlacksmithProfile *profile,
const double *axis,
double angle);
profile swung angle radians about axis (a point and a direction). The profile is read with x as radius and y as height along the axis, so it must lie to one side of the axis.
cadaclysm_blacksmith_coil
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_coil(const struct CadaclysmBlacksmithProfile *profile,
const double *axis,
double pitch,
double turns);
profile coiled about axis (a point and a direction): read like cadaclysm_blacksmith_revolve's — x the distance from the axis, y along it — and turned turns times while climbing pitch along the axis each turn, a spring or a thread. The walls follow the helix to a few millionths of the radius; the two ends are the profile itself, flat. Null and last_error for an open profile or one with holes, one reaching the axis, turns that are not positive, or — from a full turn up — a pitch no taller than the profile.
cadaclysm_blacksmith_revolve_open
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_revolve_open(const struct CadaclysmBlacksmithProfile *profile,
const double *axis,
double angle);
cadaclysm_blacksmith_revolve without the end caps of a partial turn.
cadaclysm_blacksmith_revolve_in_plane
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_revolve_in_plane(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const double *axis,
double angle);
profile, drawn on frame, swung angle radians about the axis through the sketch points (axis[0], axis[1]) and (axis[2], axis[3]), in the frame's own x and y, into a closed solid — the profile and its axis drawn together, as a sketch draws them, rather than the profile in (radius, height) as cadaclysm_blacksmith_revolve reads it. The profile may lie on either side of the axis and touch it, not cross it; the sweep starts where the profile is drawn, turning right-handed about the axis.
cadaclysm_blacksmith_revolve_open_in_plane
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_revolve_open_in_plane(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const double *axis,
double angle);
As revolve_in_plane, for a curve: the profile's own segments swung into a sheet, no caps.
cadaclysm_blacksmith_extrude_faces
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_extrude_faces(const struct CadaclysmBlacksmithSolid *sheet,
double height);
Every face of sheet pushed height along its own normal, walled and closed: the sheet as a solid of that thickness.
cadaclysm_blacksmith_face
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_face(const struct CadaclysmBlacksmithProfile *profile,
const double *frame);
The planar sheet profile bounds on frame (twelve doubles: origin, x, y, z): one face on the plane of frame, its normal frame's z whichever way round the profile was drawn, each hole a hole through it, every edge the exact line, arc or spline its segment is. An open sheet: raise it with cadaclysm_blacksmith_extrude_faces, trim it with cadaclysm_blacksmith_trim. Refused where the profile encloses no area or a hole does not lie inside the boundary.
cadaclysm_blacksmith_sweep
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sweep(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const struct CadaclysmBlacksmithSweepPath *path);
profile, drawn on frame (its x/y the profile's own axes), carried along path into a closed solid: a straight piece of the path is an extrusion of the profile, a circular piece a revolution about the arc's axis — so a circle along an arc is an exact torus wall, a rectangle along a line an exact box, nothing approximated. Two straight pieces may meet at a mitred corner; a corner next to a curved piece may not. Caps close the two ends of an open path; a path that returns to its start with matching tangents (a full circle, a mitred loop) has none. frame's origin must be where path starts, and path must leave square to frame's plane (either face of it). path is only *borrowed* here — it is not consumed, and the same path may be swept again, open or closed, or by another call to this function.
cadaclysm_blacksmith_pipe
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_pipe(const struct CadaclysmBlacksmithSweepPath *path,
double radius,
double thickness);
A circle of radius swept along path, square to its start: a rod, or with a positive thickness a tube whose walls are that thick. path is borrowed, as by cadaclysm_blacksmith_sweep. Null and last_error for a radius that is not positive, a thickness that is negative or reaches the radius, or what the sweep refuses.
cadaclysm_blacksmith_sweep_open
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sweep_open(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const struct CadaclysmBlacksmithSweepPath *path);
cadaclysm_blacksmith_sweep for a curve rather than a face: the profile's own segments carried into a *sheet*, one wall per segment per piece, no caps and no closing wall — the way cadaclysm_blacksmith_extrude_open is to cadaclysm_blacksmith_extrude. The profile need not enclose anything, only have a segment. path is only borrowed, as in sweep.
Placing
cadaclysm_blacksmith_place
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_place(const struct CadaclysmBlacksmithSolid *solid,
const double *frame);
solid, built about the origin, moved onto frame: its origin to the frame's origin, its axes to the frame's. What Workplane::cuboid and ::cylinder do after building the primitive.
cadaclysm_blacksmith_translate
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_translate(const struct CadaclysmBlacksmithSolid *solid,
double dx,
double dy,
double dz);
solid moved by (dx, dy, dz).
cadaclysm_blacksmith_scaled
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_scaled(const struct CadaclysmBlacksmithSolid *solid,
double factor);
solid scaled by factor about the origin: every length times factor, exactly, colours kept: a conic trim on a cylinder or cone is rewritten as the exact NURBS of its stretch. NULL and last_error for a factor that is not positive and finite, or a curve its file could not be read into.
cadaclysm_blacksmith_solid_transform
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_solid_transform(const struct CadaclysmBlacksmithSolid *solid,
const double *matrix,
uint32_t *inexact_out);
solid through the affine map matrix (16 doubles, row-major, bottom row 0 0 0 1), exact, colours and name kept; the trims the map lost written to inexact_out when it is not NULL. A rigid map or a similarity keeps every surface's kind — and a map within 1e-6 of a similarity (AᵀA against k²I, relative to k²; a float32 rotation among them) is applied as the exact similarity nearest it, moving a point p by at most about 1e-6 |A| |p|. Any other map turns the curved surfaces into their exact NURBS and maps those. inexact_out counts the trims lost by this call: a face boundary that survives only as a polyline lifted through the old surface, where no exact curve was left (the one definition is Reparametrised::inexact_trims in cadaclysm-brep). It is per call, not the solid's history, and 0 for a rigid map or a similarity. NULL and last_error for a matrix not affine or not finite, a singular map (it flattens the solid), or a curve its file could not be read into.
cadaclysm_blacksmith_solid_convert_to_nurbs
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_solid_convert_to_nurbs(const struct CadaclysmBlacksmithSolid *solid,
uint32_t level,
uint32_t *inexact_out);
solid with the surfaces level selects (CADACLYSM_BLACKSMITH_NURBS_*) rewritten as their exact NURBS, colours and name kept; the trims lost to inexact_out when it is not NULL, counted as cadaclysm_blacksmith_solid_transform counts them. NULL and last_error for a level not one of the three, a surface or edge curve with no exact NURBS form (a surface has no exact NURBS form), or a curve its file could not be read into.
cadaclysm_blacksmith_rotate
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_rotate(const struct CadaclysmBlacksmithSolid *solid,
const double *axis,
double radians);
solid turned radians about axis (a point and a direction).
cadaclysm_blacksmith_mirror
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_mirror(const struct CadaclysmBlacksmithSolid *solid,
const double *plane);
solid reflected across plane (a frame; its z is the plane's normal).
Transforms and quaternions
cadaclysm_blacksmith_transform_translation
bool cadaclysm_blacksmith_transform_translation(const double *v, double *out);
The translation by v.
cadaclysm_blacksmith_transform_rotation
bool cadaclysm_blacksmith_transform_rotation(const double *axis, double radians, double *out);
A turn of radians about axis (a point and a direction), right-handed.
cadaclysm_blacksmith_transform_mirror
bool cadaclysm_blacksmith_transform_mirror(const double *plane, double *out);
The reflection across plane (a frame; its z the normal). A frame within 1e-6 of right-handed and orthonormal is squared up; anything further is refused.
cadaclysm_blacksmith_transform_scale
bool cadaclysm_blacksmith_transform_scale(const double *centre, double k, double *out);
A uniform scale by k about centre.
cadaclysm_blacksmith_transform_scale_xyz
bool cadaclysm_blacksmith_transform_scale_xyz(const double *frame,
double sx,
double sy,
double sz,
double *out);
A scale by sx, sy, sz along frame's axes, about its origin. A frame within 1e-6 of right-handed and orthonormal is squared up; anything further is refused.
cadaclysm_blacksmith_transform_shear
bool cadaclysm_blacksmith_transform_shear(const double *plane,
const double *dir,
double factor,
double *out);
The shear p + factor ((p - o) . n) d over plane (its z the normal): dir is normalised — factor alone sets the slide — and must lie in the plane. A frame within 1e-6 of right-handed and orthonormal is squared up; anything further is refused.
cadaclysm_blacksmith_transform_plane_to_plane
bool cadaclysm_blacksmith_transform_plane_to_plane(const double *a,
const double *b,
double *out);
The rigid map sending frame a onto frame b. A frame within 1e-6 of right-handed and orthonormal is squared up; anything further is refused.
cadaclysm_blacksmith_transform_change_basis
bool cadaclysm_blacksmith_transform_change_basis(const double *from,
const double *to,
double *out);
Coordinates in frame from to coordinates in frame to: a change of basis. A frame within 1e-6 of right-handed and orthonormal is squared up; anything further is refused.
cadaclysm_blacksmith_transform_planar_projection
bool cadaclysm_blacksmith_transform_planar_projection(const double *plane, double *out);
The orthogonal projection onto plane (singular by design). A frame within 1e-6 of right-handed and orthonormal is squared up; anything further is refused.
cadaclysm_blacksmith_transform_project_along
bool cadaclysm_blacksmith_transform_project_along(const double *plane,
const double *dir,
double *out);
The parallel projection onto plane along dir; false for a dir in the plane. A frame within 1e-6 of right-handed and orthonormal is squared up; anything further is refused.
cadaclysm_blacksmith_transform_compose
bool cadaclysm_blacksmith_transform_compose(const double *a, const double *b, double *out);
a after b.
cadaclysm_blacksmith_transform_inverse
bool cadaclysm_blacksmith_transform_inverse(const double *m, double *out);
The inverse; false for a singular map.
cadaclysm_blacksmith_transform_is_rigid
uint32_t cadaclysm_blacksmith_transform_is_rigid(const double *m, double tolerance);
1 where m's linear part is orthogonal to tolerance (AᵀA = I), 0 where it is not, CADACLYSM_BLACKSMITH_NONE and last_error for a matrix or tolerance refused.
cadaclysm_blacksmith_transform_is_similarity
double cadaclysm_blacksmith_transform_is_similarity(const double *m, double tolerance);
k > 0 where m's linear part is k times an orthogonal one (AᵀA = k²I to tolerance relative to k²), 0 where it is not, NaN and last_error for a matrix or tolerance refused.
cadaclysm_blacksmith_transform_decompose_rigid
bool cadaclysm_blacksmith_transform_decompose_rigid(const double *m,
double tolerance,
double *out);
A rigid map split: the translation (3), then the orthogonal linear part (16). false where the map is not rigid to tolerance.
cadaclysm_blacksmith_transform_decompose_similarity
bool cadaclysm_blacksmith_transform_decompose_similarity(const double *m,
double tolerance,
double *out);
A similarity split: the translation (3), the orthogonal part (16), then k. false where the map is not a similarity to tolerance.
cadaclysm_blacksmith_transform_decompose_affine
bool cadaclysm_blacksmith_transform_decompose_affine(const double *m, double *out);
The polar split of the map: the translation (3), rotation (16, carrying the mirror where det < 0), axes (16, a proper rotation whose columns are the stretch directions), then the three stretches, largest first — the linear part is rotation · axes · diag(stretch) · axesᵀ. false for a singular map, or one stretched past 1e7:1.
cadaclysm_blacksmith_quaternion_from_axis_angle
bool cadaclysm_blacksmith_quaternion_from_axis_angle(const double *dir,
double radians,
double *out);
The turn of radians about dir, w x y z.
cadaclysm_blacksmith_quaternion_from_transform
bool cadaclysm_blacksmith_quaternion_from_transform(const double *m, double *out);
The rotation in m's linear part; false unless it is a proper rotation (orthogonal to 1e-9, determinant positive). That is stricter than cadaclysm_blacksmith_solid_transform, which snaps a map within 1e-6 of a similarity: a rotation rounded to float32 is refused here. Take the rotation of cadaclysm_blacksmith_transform_decompose_affine first — it is orthogonal to rounding — and ask its quaternion.
cadaclysm_blacksmith_quaternion_to_transform
bool cadaclysm_blacksmith_quaternion_to_transform(const double *q,
const double *centre,
double *out);
q's rotation fixing centre. A non-unit quaternion is normalised; a zero or non-finite one is refused.
cadaclysm_blacksmith_quaternion_slerp
bool cadaclysm_blacksmith_quaternion_slerp(const double *a,
const double *b,
double s,
double *out);
From a (s = 0) to b (s = 1) the shorter way. A non-unit quaternion is normalised; a zero or non-finite one is refused.
Value geometry
cadaclysm_blacksmith_value_size
uint32_t cadaclysm_blacksmith_value_size(uint32_t kind);
How many doubles a value of kind is; 0 for an unknown kind. The arrays, frame[12] being origin x y z as every frame in the ABI:
| kind | array | count | |---|---|---| | 0 CADACLYSM_BLACKSMITH_VALUE_LINE | from[3] to[3] | 6 | | 1 CADACLYSM_BLACKSMITH_VALUE_CIRCLE | frame[12] radius | 13 | | 2 CADACLYSM_BLACKSMITH_VALUE_ARC | frame[12] radius t0 t1 | 15 | | 3 CADACLYSM_BLACKSMITH_VALUE_ELLIPSE | frame[12] r1 r2 | 14 | | 4 CADACLYSM_BLACKSMITH_VALUE_SPHERE | frame[12] radius | 13 | | 5 CADACLYSM_BLACKSMITH_VALUE_CYLINDER | frame[12] radius h0 h1 | 15 | | 6 CADACLYSM_BLACKSMITH_VALUE_CONE | frame[12] radius height | 14 | | 7 CADACLYSM_BLACKSMITH_VALUE_TORUS | frame[12] major minor | 14 | | 8 CADACLYSM_BLACKSMITH_VALUE_CUBOID | frame[12] x0 x1 y0 y1 z0 z1 | 18 | | 9 CADACLYSM_BLACKSMITH_VALUE_RECTANGLE | frame[12] x0 x1 y0 y1 | 16 | | 10 CADACLYSM_BLACKSMITH_VALUE_TRIANGLE | a[3] b[3] c[3] | 9 | | 11 CADACLYSM_BLACKSMITH_VALUE_RAY | position[3] direction[3] | 6 |
Curves are kinds 0-3 and 9 (the rectangle's boundary), surfaces 4-7, shapes with a volume 4-8; the rectangle, triangle and ray have calls of their own (rectangle_*, triangle_*, ray_*). A call given a kind outside its family is refused. A frame within 1e-6 of right-handed and orthonormal is squared up, anything further refused; every call checks the whole array (finite, sizes positive, ranges increasing), so cadaclysm_blacksmith_value_check is never a precondition.
cadaclysm_blacksmith_value_check
bool cadaclysm_blacksmith_value_check(uint32_t kind, const double *value, double *out);
value validated and canonical (its frame squared up), per cadaclysm_blacksmith_value_size.
cadaclysm_blacksmith_value_bounds
bool cadaclysm_blacksmith_value_bounds(uint32_t kind, const double *value, double *out);
The world box: min[3] then max[3]; a ray, unbounded, is refused. Layouts per cadaclysm_blacksmith_value_size.
cadaclysm_blacksmith_value_transform
bool cadaclysm_blacksmith_value_transform(uint32_t kind,
const double *value,
const double *matrix,
double *out);
value under matrix (16 doubles, row-major), the same kind. A line takes any map that keeps its ends apart, an ellipse any that keeps it an ellipse, a triangle any that keeps it a triangle, a ray any that keeps its direction (the position as a point, the direction as a vector), a rectangle any that keeps its sides square (no shear in its plane); every other kind only a similarity (a circle under another map: cadaclysm_blacksmith_ellipse_from_circle first).
cadaclysm_blacksmith_curve_value_point_at
bool cadaclysm_blacksmith_curve_value_point_at(uint32_t kind,
const double *value,
double t,
double *out);
A curve's (kinds 0-3 and 9) point at t, per cadaclysm_blacksmith_value_size.
cadaclysm_blacksmith_curve_value_tangent_at
bool cadaclysm_blacksmith_curve_value_tangent_at(uint32_t kind,
const double *value,
double t,
double *out);
A curve's unit tangent at t.
cadaclysm_blacksmith_curve_value_length
bool cadaclysm_blacksmith_curve_value_length(uint32_t kind, const double *value, double *out);
A curve's length (an ellipse's perimeter in closed form) into out.
cadaclysm_blacksmith_curve_value_closest_point
bool cadaclysm_blacksmith_curve_value_closest_point(uint32_t kind,
const double *value,
const double *point,
double *out);
The curve's closest point to point: t x y z unique, unique 1, or 0 where the answer is a fixed pick among equals (a circle's axis, an arc's two equidistant ends).
cadaclysm_blacksmith_curve_value_to_nurbs
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_curve_value_to_nurbs(uint32_t kind,
const double *value);
The curve's exact NURBS form, freed with cadaclysm_blacksmith_nurbs_curve_free; NULL and last_error on a refusal.
cadaclysm_blacksmith_circle_through
bool cadaclysm_blacksmith_circle_through(const double *a,
const double *b,
const double *c,
double *out);
The circle through three points, a kind-1 array: x toward a, the normal so a, b, c run counter-clockwise.
cadaclysm_blacksmith_arc_through
bool cadaclysm_blacksmith_arc_through(const double *a,
const double *b,
const double *c,
double *out);
The arc from a through b to c, a kind-2 array starting at angle 0.
cadaclysm_blacksmith_arc_from_start_tangent_end
bool cadaclysm_blacksmith_arc_from_start_tangent_end(const double *a,
const double *tangent,
const double *c,
double *out);
The arc leaving a along tangent and ending at c, a kind-2 array.
cadaclysm_blacksmith_ellipse_from_circle
bool cadaclysm_blacksmith_ellipse_from_circle(const double *value, double *out);
A circle (kind 1) as the round ellipse (kind 3): how a circle takes a map that is not a similarity.
cadaclysm_blacksmith_surface_value_point_at
bool cadaclysm_blacksmith_surface_value_point_at(uint32_t kind,
const double *value,
double u,
double v,
double *out);
A surface's (kinds 4-7) point at (u, v): u the angle round the axis; v a sphere's latitude, a cylinder's or cone's height along the axis, a torus' angle round the tube.
cadaclysm_blacksmith_surface_value_normal_at
bool cadaclysm_blacksmith_surface_value_normal_at(uint32_t kind,
const double *value,
double u,
double v,
double *out);
A surface's outward unit normal at (u, v).
cadaclysm_blacksmith_surface_value_closest_point
bool cadaclysm_blacksmith_surface_value_closest_point(uint32_t kind,
const double *value,
const double *point,
double *out);
The patch's closest point to point: u v x y z unique, unique 1 or 0.
cadaclysm_blacksmith_surface_value_domain
bool cadaclysm_blacksmith_surface_value_domain(uint32_t kind, const double *value, double *out);
The patch's parameter box: u0 u1 v0 v1.
cadaclysm_blacksmith_surface_value_nurbs_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_surface_value_nurbs_sheet(uint32_t kind,
const double *value);
The whole patch as one open face on its exact NURBS form, freed with cadaclysm_blacksmith_solid_free; NULL and last_error on a refusal.
cadaclysm_blacksmith_solid_value_contains
uint32_t cadaclysm_blacksmith_solid_value_contains(uint32_t kind,
const double *value,
const double *point,
double tolerance);
1 where point lies inside the closed shape (kinds 4-8) or within tolerance of it, 0 where it does not, CADACLYSM_BLACKSMITH_NONE and last_error on a refusal. tolerance NaN is unset, the shape's own effective tolerance (tolerance.relative times its box's diagonal, never finer than its coordinates' rounding); 0 is exact (see the tolerances section at cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_solid_value_area
bool cadaclysm_blacksmith_solid_value_area(uint32_t kind, const double *value, double *out);
The closed shape's boundary area (caps included) into out.
cadaclysm_blacksmith_solid_value_volume
bool cadaclysm_blacksmith_solid_value_volume(uint32_t kind, const double *value, double *out);
The enclosed volume into out.
cadaclysm_blacksmith_solid_value_to_solid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_solid_value_to_solid(uint32_t kind,
const double *value);
The closed B-rep solid the value bounds, freed with cadaclysm_blacksmith_solid_free; NULL and last_error on a refusal.
cadaclysm_blacksmith_cuboid_from_bounds
bool cadaclysm_blacksmith_cuboid_from_bounds(const double *min, const double *max, double *out);
The world-aligned box from min to max, a kind-8 array.
cadaclysm_blacksmith_cuboid_around
bool cadaclysm_blacksmith_cuboid_around(const double *frame,
const double *xyz,
size_t count,
double *out);
The tightest box holding count points (xyz, three doubles each), aligned to frame; a kind-8 array.
cadaclysm_blacksmith_cuboid_corners
bool cadaclysm_blacksmith_cuboid_corners(const double *value, double *out);
A box's eight corners, xyz each: the z0 face counter-clockwise about +z from (x0, y0), then the z1 face in the same order.
cadaclysm_blacksmith_cuboid_point_at
bool cadaclysm_blacksmith_cuboid_point_at(const double *value,
double sx,
double sy,
double sz,
double *out);
The point the fractions sx, sy, sz of the way along a box's ranges (outside 0..1 extrapolates).
cadaclysm_blacksmith_cuboid_closest_point
bool cadaclysm_blacksmith_cuboid_closest_point(const double *value,
const double *point,
double *out);
The solid box's closest point to point (point itself inside).
cadaclysm_blacksmith_rectangle_corners
bool cadaclysm_blacksmith_rectangle_corners(const double *value, double *out);
A rectangle's four corners, xyz each, in Rhino's Corner(i) order: (x0,y0) (x1,y0) (x1,y1) (x0,y1), counter-clockwise about the frame's z.
cadaclysm_blacksmith_rectangle_area
bool cadaclysm_blacksmith_rectangle_area(const double *value, double *out);
The filled rectangle's area into out.
cadaclysm_blacksmith_rectangle_closest_point
bool cadaclysm_blacksmith_rectangle_closest_point(const double *value,
const double *point,
bool include_interior,
double *out);
Rhino's ClosestPoint(p, includeInterior): point projected onto the rectangle's plane and clamped into the filled rectangle when include_interior, else the boundary's closest point (cadaclysm_blacksmith_curve_value_closest_point gives its t and unique too).
cadaclysm_blacksmith_rectangle_contains
uint32_t cadaclysm_blacksmith_rectangle_contains(const double *value,
const double *point,
double tolerance);
Where point, projected onto the rectangle's plane, lies (Rhino's Contains): CADACLYSM_BLACKSMITH_OUTSIDE (0), CADACLYSM_BLACKSMITH_INSIDE (1), or CADACLYSM_BLACKSMITH_ON (2) within tolerance of the boundary; CADACLYSM_BLACKSMITH_NONE and last_error on a refusal. tolerance NaN is unset, the rectangle's own effective tolerance (tolerance.relative times its diagonal, never finer than its coordinates' rounding); 0 is exact (see the tolerances section at cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_rectangle_to_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_rectangle_to_sheet(const double *value);
The filled rectangle as a one-face planar sheet facing the frame's z, freed with cadaclysm_blacksmith_solid_free; NULL and last_error on a refusal.
cadaclysm_blacksmith_triangle_area
bool cadaclysm_blacksmith_triangle_area(const double *value, double *out);
A triangle's area into out.
cadaclysm_blacksmith_triangle_perimeter
bool cadaclysm_blacksmith_triangle_perimeter(const double *value, double *out);
A triangle's perimeter into out.
cadaclysm_blacksmith_triangle_centroid
bool cadaclysm_blacksmith_triangle_centroid(const double *value, double *out);
A triangle's area centroid, the mean of its vertices (Rhino's AreaCenter).
cadaclysm_blacksmith_triangle_circumcircle
bool cadaclysm_blacksmith_triangle_circumcircle(const double *value, double *out);
The circle through a triangle's vertices, a kind-1 array: x toward a, the normal so a, b, c run counter-clockwise.
cadaclysm_blacksmith_triangle_point_at
bool cadaclysm_blacksmith_triangle_point_at(const double *value,
double wa,
double wb,
double wc,
double *out);
The point of barycentric weights wa, wb, wc, used as given (they need not sum to 1).
cadaclysm_blacksmith_triangle_barycentric
bool cadaclysm_blacksmith_triangle_barycentric(const double *value,
const double *point,
double *out);
The barycentric weights wa wb wc (summing to 1) of point projected onto the triangle's plane.
cadaclysm_blacksmith_triangle_closest_point
bool cadaclysm_blacksmith_triangle_closest_point(const double *value,
const double *point,
double *out);
The filled triangle's closest point to point, exact (by Voronoi region).
cadaclysm_blacksmith_triangle_edge
bool cadaclysm_blacksmith_triangle_edge(const double *value, uint32_t index, double *out);
Edge index as a line value (kind 0): 0 a to b, 1 b to c, 2 c to a.
cadaclysm_blacksmith_triangle_to_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_triangle_to_sheet(const double *value);
The filled triangle as a one-face planar sheet, its normal turning a, b, c counter-clockwise, freed with cadaclysm_blacksmith_solid_free; NULL and last_error on a refusal.
cadaclysm_blacksmith_ray_point_at
bool cadaclysm_blacksmith_ray_point_at(const double *value, double t, double *out);
A ray's point position + t * direction, t unbounded (behind the start too).
cadaclysm_blacksmith_ray_closest_point
bool cadaclysm_blacksmith_ray_closest_point(const double *value,
const double *point,
double *out);
The ray's closest point to point: t x y z, t clamped at 0 (a point behind the start answers the start).
Names and assemblies
cadaclysm_blacksmith_named
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_named(const struct CadaclysmBlacksmithSolid *solid,
const char *name);
solid, named name — see cadaclysm_blacksmith_solid_name and, for what a name is used for, cadaclysm-blacksmith-abi's assembly module. Refused (null, last_error) for an empty name; a name cannot contain a NUL, since it is read as a NUL-terminated C string in the first place.
cadaclysm_blacksmith_solid_name
const char *cadaclysm_blacksmith_solid_name(const struct CadaclysmBlacksmithSolid *solid);
solid's name, or null when it has none. Borrowed: good until solid is freed, and must not be freed itself.
cadaclysm_blacksmith_with_material
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_with_material(const struct CadaclysmBlacksmithSolid *solid,
const char *material);
solid made of material: the material's name, written as STEP's MATERIAL_DESIGNATION on the solid's product by cadaclysm_blacksmith_step and cadaclysm_blacksmith_assembly_step (moving the default schema to AP242, as a colour does; dropped under a named schema without it, as a colour is). Kept by moves, booleans and every other operation, as the solid's colour is: a result made from several solids is made of the first's. Refused (null, last_error) for a blank name.
cadaclysm_blacksmith_solid_material
const char *cadaclysm_blacksmith_solid_material(const struct CadaclysmBlacksmithSolid *solid);
solid's material, or null when it has none. Borrowed: good until solid is freed, and must not be freed itself.
cadaclysm_blacksmith_styled
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_styled(const struct CadaclysmBlacksmithSolid *solid,
const char *location,
const char *identification);
solid drawn in a style defined outside the file: identification the style's name in the library at location — a MaterialX or MDL file and a material in it, say. Either may be null, not both. Written as STEP's EXTERNALLY_DEFINED_STYLE beside the solid's colour, which a reader without the library draws instead; needs a schema with it (AP242, AP214 — the default moves to AP242), dropped under one without. Kept by operations as cadaclysm_blacksmith_with_material's material is. Refused (null, last_error) when both are null or blank.
cadaclysm_blacksmith_solid_style_location
const char *cadaclysm_blacksmith_solid_style_location(const struct CadaclysmBlacksmithSolid *solid);
The location of solid's external style (cadaclysm_blacksmith_styled), or null when it has none. Borrowed, as cadaclysm_blacksmith_solid_material's.
cadaclysm_blacksmith_solid_style_identification
const char *cadaclysm_blacksmith_solid_style_identification(const struct CadaclysmBlacksmithSolid *solid);
The identification of solid's external style (cadaclysm_blacksmith_styled), or null when it has none. Borrowed, as cadaclysm_blacksmith_solid_material's.
cadaclysm_blacksmith_assembly_new
struct CadaclysmBlacksmithAssembly *cadaclysm_blacksmith_assembly_new(const char *name);
A new, empty assembly called name. Free it with cadaclysm_blacksmith_assembly_free. Null and last_error for an empty name.
cadaclysm_blacksmith_assembly_free
void cadaclysm_blacksmith_assembly_free(struct CadaclysmBlacksmithAssembly *assembly);
Release an assembly handle. Null is a no-op. Does not free the assembly itself if it is still placed somewhere else (see the handle's own doc) — only this one reference to it.
cadaclysm_blacksmith_assembly_name
const char *cadaclysm_blacksmith_assembly_name(const struct CadaclysmBlacksmithAssembly *assembly);
assembly's name. Borrowed: good until assembly is freed, and must not be freed itself.
cadaclysm_blacksmith_assembly_place_solid
char *cadaclysm_blacksmith_assembly_place_solid(struct CadaclysmBlacksmithAssembly *assembly,
const struct CadaclysmBlacksmithSolid *solid,
const double *frame,
const char *name);
Place solid at frame (twelve doubles, as every frame argument; must be right-handed and orthonormal) in assembly, called name — or, with name null, solid's own name ("part" if it has none), numbered past any already taken in assembly ("bolt", "bolt 2", ...). An explicit name already taken in assembly is refused. Returns the placement's name, owned: free it with cadaclysm_blacksmith_string_free. Null and last_error on failure.
cadaclysm_blacksmith_assembly_place_assembly
char *cadaclysm_blacksmith_assembly_place_assembly(struct CadaclysmBlacksmithAssembly *assembly,
const struct CadaclysmBlacksmithAssembly *placed,
const double *frame,
const char *name);
As cadaclysm_blacksmith_assembly_place_solid, but placing another assembly, placed, rather than a solid — sharing it, not copying it, so a later place on placed (through this parent or another) shows up wherever it is placed. Refused (null, last_error naming the cycle) if placed is assembly itself or anywhere above it in the tree already, since writing that out would never terminate.
cadaclysm_blacksmith_assembly_step
char *cadaclysm_blacksmith_assembly_step(const struct CadaclysmBlacksmithAssembly *assembly,
const char *schema,
uint32_t unit);
assembly, and everything placed under it, as one STEP file: assembly the root product, each sub-assembly and each distinct part (the same solid with the same paint and name) written once, each placement an occurrence named as it was placed. schema and unit as for cadaclysm_blacksmith_step. The text is owned: release it with cadaclysm_blacksmith_string_free. Null and last_error on failure — including an assembly reachable from this one that places nothing, since a reader would never show it.
cadaclysm_blacksmith_assembly_3dm_bytes
uint8_t *cadaclysm_blacksmith_assembly_3dm_bytes(const struct CadaclysmBlacksmithAssembly *assembly,
uint32_t unit,
size_t *len);
assembly, and everything placed under it, as one Rhino .3dm: each distinct part (the same solid with the same paint and name, as cadaclysm_blacksmith_assembly_step counts them) a block holding its body, each sub-assembly a block of references to what it places — so nested assemblies are nested blocks — and this assembly's own placements references at the top of the file, on a layer named after it. Each reference is named as its placement was; block names are the parts' and assemblies' names made ones Rhino takes and numbered past any already taken, regardless of case (bolt, bolt 2). A body is written as cadaclysm_blacksmith_3dm_bytes writes a solid's. unit as for cadaclysm_blacksmith_step.
The bytes are owned, their count written through len: release them with cadaclysm_blacksmith_bytes_free. Null and last_error on failure — including an assembly reachable from this one that places nothing. On success last_error lists what was written as a mesh or left out, one line each, or is null.
cadaclysm_blacksmith_assembly_3dm
bool cadaclysm_blacksmith_assembly_3dm(const struct CadaclysmBlacksmithAssembly *assembly,
const char *path,
uint32_t unit);
cadaclysm_blacksmith_assembly_3dm_bytes written to path, replacing any file there. false and last_error on failure, including the file's; on success last_error says what was written as a mesh or left out, as that call's does.
cadaclysm_blacksmith_assembly_link
bool cadaclysm_blacksmith_assembly_link(struct CadaclysmBlacksmithAssembly *assembly,
const char *name,
const char *const *placements,
size_t placement_count);
Declare a rigid link name over this assembly's placements named in placements (placement_count of them). False, with last_error saying why, when a rule of Assembly.link refuses it; the assembly is then unchanged.
cadaclysm_blacksmith_assembly_joint
bool cadaclysm_blacksmith_assembly_joint(struct CadaclysmBlacksmithAssembly *assembly,
const char *name,
const char *start,
const char *end);
Connect this assembly's links start and end (kept in that order) as a joint called name. False, with last_error saying why, when a rule of Assembly.joint refuses it; the assembly is then unchanged.
cadaclysm_blacksmith_assembly_pair
bool cadaclysm_blacksmith_assembly_pair(struct CadaclysmBlacksmithAssembly *assembly,
const char *joint,
const char *kind,
const double *frame,
const double *end_frame,
const double *lower,
const double *upper,
const bool *has_lower,
const bool *has_upper,
size_t freedom_count,
double pitch);
Gives joint joint its pair — see abi::Assembly::pair for the rules. frame and end_frame are each twelve doubles, as every frame argument; a null end_frame means frame itself. lower/upper hold freedom_count doubles each and has_lower/has_upper freedom_count flags; all four null with freedom_count 0 means no ranges given. pitch is NaN for every kind but screw, which requires a real, non-zero pitch. False, with last_error saying why, when a rule refuses it; the assembly is then unchanged.
cadaclysm_blacksmith_assembly_pair_with
bool cadaclysm_blacksmith_assembly_pair_with(struct CadaclysmBlacksmithAssembly *assembly,
const char *joint,
const char *kind,
const double *frame,
const double *end_frame,
const double *lower,
const double *upper,
const bool *has_lower,
const bool *has_upper,
size_t freedom_count,
const double *params,
size_t param_count);
cadaclysm_blacksmith_assembly_pair with the kind's parameters in place of the pitch — see abi::Assembly::pair_with: screw [pitch]; rack_and_pinion [pinion_radius]; gear [radius_first, radius_second, ratio] or those plus [bevel, helical_angle] (radians), the ratio the second link's rotation over the first's, signed; no parameters (param_count 0, params null) for any other kind. Every other argument reads as in cadaclysm_blacksmith_assembly_pair. False, with last_error saying why, when a rule refuses it — a wrong parameter count among them; the assembly is then unchanged.
cadaclysm_blacksmith_assembly_state
bool cadaclysm_blacksmith_assembly_state(struct CadaclysmBlacksmithAssembly *assembly,
const char *name,
const char *const *joints,
const uint32_t *counts,
const double *values,
size_t row_count);
Adds a named state to assembly — see abi::Assembly::state and the Global Constraints. row_count rows: row i sets joint joints[i] to counts[i] values, taken consecutively from values (the layout of cadaclysm_pose). False, with last_error saying why, when a rule refuses it; the assembly is then unchanged.
cadaclysm_blacksmith_assembly_sequence
bool cadaclysm_blacksmith_assembly_sequence(struct CadaclysmBlacksmithAssembly *assembly,
const char *name,
const char *const *states,
const double *ts,
const char *const *interpolations,
size_t count,
bool seconds);
Adds a named motion sequence over the assembly's states: count segments, segment i reaching state states[i] at parameter ts[i], leaving it by interpolations[i] ("undefined", "discontinuous", "synchronous" or "linear"). seconds writes the parameter's unit as the second. Closed or open is the last segment's interpolation. False, with the reason at the kernel's last error and the assembly unchanged, on any refusal of the kernel's Assembly::sequence.
cadaclysm_blacksmith_assembly_base
bool cadaclysm_blacksmith_assembly_base(struct CadaclysmBlacksmithAssembly *assembly,
const char *link);
Declares assembly's base link — see abi::Assembly::base and the Global Constraints. False, with last_error saying why, when a rule refuses it; the assembly is then unchanged.
cadaclysm_blacksmith_assembly_posed
struct CadaclysmBlacksmithAssembly *cadaclysm_blacksmith_assembly_posed(const struct CadaclysmBlacksmithAssembly *assembly,
const char *const *joints,
const uint32_t *counts,
const double *values,
size_t row_count,
const char *state,
const char *ground);
assembly posed: a new assembly, the caller's to free with cadaclysm_blacksmith_assembly_free — see abi::Assembly::posed. row_count rows: row i gives joint path joints[i] (/ between names, \ escaping / and \ in a name) counts[i] values, taken consecutively from values (the layout of cadaclysm_blacksmith_assembly_state). state a state's path, or null; ground one of assembly's links, or null for its default. Null, with last_error saying why, when a rule refuses it; assembly is unchanged either way.
cadaclysm_blacksmith_assembly_part_count
uint32_t cadaclysm_blacksmith_assembly_part_count(const struct CadaclysmBlacksmithAssembly *assembly);
How many solids are under assembly, at any depth: the length of the list cadaclysm_blacksmith_assembly_part_path reads, and the index the rows of cadaclysm_blacksmith_assembly_swept_clash use. 0 (and last_error) for null.
cadaclysm_blacksmith_assembly_part_path
char *cadaclysm_blacksmith_assembly_part_path(const struct CadaclysmBlacksmithAssembly *assembly,
uint32_t i);
The placement path of solid i under assembly — depth first, placements in order; names joined by /, a / or \ inside a name escaped with \, as cadaclysm_blacksmith_assembly_posed's keys are. Owned: free it with cadaclysm_blacksmith_string_free. Null (and last_error) for a null assembly or i past the last solid.
cadaclysm_blacksmith_assembly_swept_clash
struct CadaclysmBlacksmithSweptClashes *cadaclysm_blacksmith_assembly_swept_clash(const struct CadaclysmBlacksmithAssembly *assembly,
const char *const *joints,
const uint32_t *counts,
size_t joint_count,
const double *values,
uint32_t key_count,
const char *ground,
double tolerance,
double clearance,
double resolution,
uint32_t max_steps,
const uint32_t *allowed,
uint32_t allowed_count,
bool joined);
Every pair of assembly's solids (indexed as cadaclysm_blacksmith_assembly_part_path lists them) that penetrates, touches or comes within clearance anywhere while assembly's own mechanism moves through key_count keyframes (at least 2), with the first time it does and the time ranges it stays in clash — read with the cadaclysm_blacksmith_swept_clashes_* calls. Time runs in keyframe units, keyframe k at time k; between two keyframes each joint value moves linearly, and each link is posed from those values as cadaclysm_blacksmith_assembly_posed poses it, so a link swinging about a joint goes round its arc.
joints names joint_count of this assembly's own joints (a key into a sub-assembly is refused), each with counts[i] values. values is key-major: keyframe 0's values for every joint in order, then keyframe 1's, and so on, key_count * sum(counts) doubles. ground one of assembly's links, held fixed, or null for its default. Each link is a group; a sub-assembly rides the link its placement is in; solids in no link are one more group, held fixed. Pairs on two links a joint joins are not tested unless joined; allowed is allowed_count pairs of part indices (2 * allowed_count numbers, flat) never tested. Parts are meshed at tolerance; resolution and max_steps as cadaclysm_blacksmith_collider_swept_clash. Null (and last_error) for a null assembly, a null joints, counts, values or allowed with a count, and in swept_clash: words for every refusal of abi::Assembly::swept_clash.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_pair_freedom_count
uint32_t cadaclysm_blacksmith_pair_freedom_count(const char *kind);
How many freedoms a pair kind has, so a caller can size its ranges arrays for cadaclysm_blacksmith_assembly_pair. 0 for an unknown name, and for fully_constrained, which has none.
Identity and attributes
cadaclysm_blacksmith_solid_tracked
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_solid_tracked(const struct CadaclysmBlacksmithSolid *solid);
solid tracked: its faces numbered 1..n in face order, its edges 1..m in the edge table's order, each its own origin as operand 0. A tracked solid comes back as it is (a new handle with the same ids). Null and last_error for a null solid.
cadaclysm_blacksmith_solid_is_tracked
bool cadaclysm_blacksmith_solid_is_tracked(const struct CadaclysmBlacksmithSolid *solid);
Whether solid carries face and edge ids. false (and last_error) for null.
cadaclysm_blacksmith_face_id
uint64_t cadaclysm_blacksmith_face_id(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
Face face's id. An id is unique within its solid and never 0; it stays with the face through every verb that keeps the face (a move, a boolean, a fillet of another edge), so it names "the same face, through my edits" within a session. A verb's output face keeps the id of the input face it lies on; a piece split off, a face of a later operand whose id an earlier one already has, and a face on no input get fresh ids above every input's, in face order — the same verbs on the same inputs number the same, run after run. Ids are not written to files: to find a face on a model rebuilt or read again, use cadaclysm_blacksmith_face_ref.
0 where solid is untracked (no last_error); 0 and last_error for a face the solid does not have or a null solid.
cadaclysm_blacksmith_face_with_id
uint32_t cadaclysm_blacksmith_face_with_id(const struct CadaclysmBlacksmithSolid *solid,
uint64_t id);
The face whose id is id, or CADACLYSM_BLACKSMITH_NONE where no face has it (an untracked solid, an id 0, a face a verb deleted) — with no last_error; with it, for a null solid.
cadaclysm_blacksmith_face_origin_count
uint32_t cadaclysm_blacksmith_face_origin_count(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
How many input faces face face came from: 0 for a face the verb generated (a fillet's round, a cut face) or an untracked solid, 1 for most, more for a face merged from several. CADACLYSM_BLACKSMITH_NONE and last_error for a face the solid does not have or a null solid.
cadaclysm_blacksmith_face_origin_at
bool cadaclysm_blacksmith_face_origin_at(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
uint32_t i,
uint32_t *operand,
uint64_t *id);
Origin i of face face: the operand it came from (its index in the verb's operand order, as each verb's doc gives it) into operand, and that input face's id into id. The first origin is the one the face lies on most. false and last_error for a bad face, an i not below the count, or a null argument.
cadaclysm_blacksmith_edge_id
uint64_t cadaclysm_blacksmith_edge_id(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge);
Edge edge's id, edge an index into the edge table (what cadaclysm_blacksmith_edge and fillet take). As cadaclysm_blacksmith_face_id: 0 where untracked; 0 and last_error for an edge past the table or a null solid.
cadaclysm_blacksmith_edge_with_id
uint32_t cadaclysm_blacksmith_edge_with_id(const struct CadaclysmBlacksmithSolid *solid,
uint64_t id);
The edge-table index of the edge whose id is id, or CADACLYSM_BLACKSMITH_NONE, as cadaclysm_blacksmith_face_with_id.
cadaclysm_blacksmith_edge_origin_count
uint32_t cadaclysm_blacksmith_edge_origin_count(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge);
How many input edges edge edge came from: 0 for a new edge, else 1 (edge merges are not seen). As cadaclysm_blacksmith_face_origin_count otherwise.
cadaclysm_blacksmith_edge_origin_at
bool cadaclysm_blacksmith_edge_origin_at(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
uint32_t i,
uint32_t *operand,
uint64_t *id);
Origin i of edge edge, as cadaclysm_blacksmith_face_origin_at.
cadaclysm_blacksmith_origins_through
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_origins_through(const struct CadaclysmBlacksmithSolid *out,
const struct CadaclysmBlacksmithSolid *via);
out, made from via by a verb of one operand, with its face and edge origins read through via's: each origin (0, id) replaced by the origins via's face (edge) id has, in order, each named once. Its ids, attributes and geometry stay out's. Two steps then read as one: cadaclysm_blacksmith_merge_flush after a join, read through the join, names the join's two inputs, as operands 0 and 1, rather than the join's own faces — what cadaclysm_blacksmith_history of the merge against the join's inputs needs.
A new solid; an untracked out comes back as it is. Null and last_error where via is untracked while out is not, where an origin names an operand other than 0 or an id no face (edge) of via has (out was not made from via alone), or for a null argument.
cadaclysm_blacksmith_with_attribute
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_with_attribute(const struct CadaclysmBlacksmithSolid *solid,
const char *key,
const char *value);
solid with attribute key set to value, over any it had: a new solid, tracked if solid was not (an attribute rides with the faces' ids). Attributes are text: keys and values UTF-8, read up to their NUL. A solid's attributes go with it through every verb (a verb's result takes its first operand's), and are written to STEP files as user-defined attributes. Null and last_error for an empty key, text that is not UTF-8, or a null argument.
cadaclysm_blacksmith_without_attribute
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_without_attribute(const struct CadaclysmBlacksmithSolid *solid,
const char *key);
solid without attribute key: a new solid, equal to solid where it had none. Null and last_error for a null argument or a key that is not UTF-8.
cadaclysm_blacksmith_attribute
const char *cadaclysm_blacksmith_attribute(const struct CadaclysmBlacksmithSolid *solid,
const char *key);
solid's attribute key, or null where it has none (no last_error). Borrowed: it lives as long as solid and must not be freed.
cadaclysm_blacksmith_attribute_count
uint32_t cadaclysm_blacksmith_attribute_count(const struct CadaclysmBlacksmithSolid *solid);
How many attributes solid has. 0 (and last_error) for null.
cadaclysm_blacksmith_attribute_key_at
const char *cadaclysm_blacksmith_attribute_key_at(const struct CadaclysmBlacksmithSolid *solid,
uint32_t i);
The key of solid's attribute i, in key order (byte order). Borrowed: it lives as long as solid and must not be freed. Null and last_error for an i not below the count or a null solid.
cadaclysm_blacksmith_attribute_value_at
const char *cadaclysm_blacksmith_attribute_value_at(const struct CadaclysmBlacksmithSolid *solid,
uint32_t i);
The value of solid's attribute i, in key order. Borrowed: it lives as long as solid and must not be freed. As cadaclysm_blacksmith_attribute_key_at otherwise.
cadaclysm_blacksmith_with_face_attribute
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_with_face_attribute(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const char *key,
const char *value);
solid with face face's attribute key set to value: a new solid, tracked if solid was not. A face's attributes follow its id: kept with it through a verb, and copied to every output face that names it as an origin (each piece of a split face has its parent's). They stay in memory: no file carries them. Null and last_error for a face the solid does not have, an empty key, text that is not UTF-8, or a null argument.
cadaclysm_blacksmith_without_face_attribute
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_without_face_attribute(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const char *key);
solid without face face's attribute key: a new solid, equal to solid where the face had none. Null and last_error for a face the solid does not have, a key that is not UTF-8, or a null argument.
cadaclysm_blacksmith_face_attribute
const char *cadaclysm_blacksmith_face_attribute(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const char *key);
Face face's attribute key, or null where it has none (no last_error). Borrowed: it lives as long as solid and must not be freed. Null and last_error for a face the solid does not have or a null argument.
cadaclysm_blacksmith_face_attribute_count
uint32_t cadaclysm_blacksmith_face_attribute_count(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
How many attributes face face has. CADACLYSM_BLACKSMITH_NONE and last_error for a face the solid does not have or a null solid.
cadaclysm_blacksmith_face_attribute_key_at
const char *cadaclysm_blacksmith_face_attribute_key_at(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
uint32_t i);
The key of face face's attribute i, in key order (byte order). Borrowed: it lives as long as solid and must not be freed. Null and last_error for a bad face, an i not below the count, or a null solid.
cadaclysm_blacksmith_face_attribute_value_at
const char *cadaclysm_blacksmith_face_attribute_value_at(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
uint32_t i);
The value of face face's attribute i, in key order. Borrowed: it lives as long as solid and must not be freed. As cadaclysm_blacksmith_face_attribute_key_at otherwise.
cadaclysm_blacksmith_history
struct CadaclysmBlacksmithHistory *cadaclysm_blacksmith_history(const struct CadaclysmBlacksmithSolid *out,
const struct CadaclysmBlacksmithSolid *const *inputs,
size_t count);
The history of out, made by a verb from inputs (count solids, in the verb's operand order, as each verb's "Marks:" line gives it), read off out's ids and origins alone. Inputs are named (operand, id), operand the index into inputs; every list is in (operand, id) order, generated in id order:
- kept: an input that became exactly one output, keeping its id — (input, output id); - modified: an input split (several outputs name it), merged (its output has other origins too) or renumbered (a later operand's id taken, a cut's bore) — (input, outputs); - generated: outputs with no origin (a fillet's round, the faces a split cuts); - deleted: inputs no output names (a cut tool's caps).
Null and last_error where out or an input is untracked ("history: input 1 is not tracked"), an origin names an operand past count, or an argument is null. Free the handle with cadaclysm_blacksmith_history_free.
cadaclysm_blacksmith_edge_history
struct CadaclysmBlacksmithHistory *cadaclysm_blacksmith_edge_history(const struct CadaclysmBlacksmithSolid *out,
const struct CadaclysmBlacksmithSolid *const *inputs,
size_t count);
cadaclysm_blacksmith_history for the edges, by edge id: each output edge has at most one origin, so edge merges are not seen.
cadaclysm_blacksmith_history_free
void cadaclysm_blacksmith_history_free(struct CadaclysmBlacksmithHistory *history);
Release a history. Null is a no-op.
cadaclysm_blacksmith_history_kept_count
uint32_t cadaclysm_blacksmith_history_kept_count(const struct CadaclysmBlacksmithHistory *history);
How many inputs were kept. 0 (and last_error) for null.
cadaclysm_blacksmith_history_kept_at
bool cadaclysm_blacksmith_history_kept_at(const struct CadaclysmBlacksmithHistory *history,
uint32_t i,
uint32_t *operand,
uint64_t *id,
uint64_t *out_id);
Kept input i: its operand and id into operand and id, and the output's id (the same id) into out_id. false and last_error for an i not below the count or a null argument.
cadaclysm_blacksmith_history_modified_count
uint32_t cadaclysm_blacksmith_history_modified_count(const struct CadaclysmBlacksmithHistory *history);
How many inputs were modified. 0 (and last_error) for null.
cadaclysm_blacksmith_history_modified_at
bool cadaclysm_blacksmith_history_modified_at(const struct CadaclysmBlacksmithHistory *history,
uint32_t i,
uint32_t *operand,
uint64_t *id);
Modified input i: its operand and id into operand and id; its outputs through cadaclysm_blacksmith_history_modified_output_count and _output_at. false and last_error for an i not below the count or a null argument.
cadaclysm_blacksmith_history_modified_output_count
uint32_t cadaclysm_blacksmith_history_modified_output_count(const struct CadaclysmBlacksmithHistory *history,
uint32_t i);
How many outputs modified input i became (in output face order: a split's first piece, which keeps the id, first). CADACLYSM_BLACKSMITH_NONE and last_error for an i not below the count or a null history.
cadaclysm_blacksmith_history_modified_output_at
uint64_t cadaclysm_blacksmith_history_modified_output_at(const struct CadaclysmBlacksmithHistory *history,
uint32_t i,
uint32_t j);
The id of output j of modified input i. 0 and last_error for an i or j past its list or a null history.
cadaclysm_blacksmith_history_generated_count
uint32_t cadaclysm_blacksmith_history_generated_count(const struct CadaclysmBlacksmithHistory *history);
How many outputs were generated. 0 (and last_error) for null.
cadaclysm_blacksmith_history_generated_at
uint64_t cadaclysm_blacksmith_history_generated_at(const struct CadaclysmBlacksmithHistory *history,
uint32_t i);
The id of generated output i, in id order. 0 and last_error for an i not below the count or a null history.
cadaclysm_blacksmith_history_deleted_count
uint32_t cadaclysm_blacksmith_history_deleted_count(const struct CadaclysmBlacksmithHistory *history);
How many inputs were deleted. 0 (and last_error) for null.
cadaclysm_blacksmith_history_deleted_at
bool cadaclysm_blacksmith_history_deleted_at(const struct CadaclysmBlacksmithHistory *history,
uint32_t i,
uint32_t *operand,
uint64_t *id);
Deleted input i: its operand and id into operand and id. false and last_error for an i not below the count or a null argument.
cadaclysm_blacksmith_edge_ref
bool cadaclysm_blacksmith_edge_ref(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
double *out);
Edge edge of the edge table (what cadaclysm_blacksmith_edge and fillet index) by what it is, fifteen doubles into out:
| at | what | |---|---| | 0 | the curve's kind: line 0, circle 1, ellipse 2, parabola 3, hyperbola 4, NURBS 5, other 6 | | 1-3 | the point at half its arc length (x y z) | | 4-6 | the unit tangent there (x y z) | | 7 | its length | | 8-10 | the outward normal there of one face meeting on it (x y z) | | 11-13 | the other's (an open sheet's rim: the one face's again; zero where unreadable) | | 14 | its span: how far from the midpoint cadaclysm_blacksmith_find_edge may find it on a resized solid |
A reference a feature made on the edge keeps, to find the edge again when the solid has been rebuilt — as cadaclysm_blacksmith_face_ref is for a face. Take it off the solid before any move you apply to it. false and last_error for an edge past the table, one with no length to measure, or a null argument.
cadaclysm_blacksmith_find_edge
int32_t cadaclysm_blacksmith_find_edge(const struct CadaclysmBlacksmithSolid *solid,
const double *edge_ref,
double tolerance);
The edge-table index of the edge of solid that edge_ref (fifteen doubles, as cadaclysm_blacksmith_edge_ref lays them out) refers to: of the edges of that kind passing within tolerance of the midpoint and running the same way (either sense), the one of nearest length. Where none passes through it (the solid was resized), the edge of that kind running the same way between faces facing the same two ways, the only one or the one clearly nearest the midpoint, and no farther than the span. -1 where the edge is gone (no last_error) — never whatever now sits at the old index; -2 and last_error for a null argument, a malformed reference or a tolerance that is not positive.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_vertex_count
uint32_t cadaclysm_blacksmith_vertex_count(const struct CadaclysmBlacksmithSolid *solid);
How many vertices solid has: its edges' ends, welded, in the order cadaclysm_blacksmith_vertex_ref and cadaclysm_blacksmith_find_vertex index. 0 (and last_error) for null.
cadaclysm_blacksmith_vertex_ref
bool cadaclysm_blacksmith_vertex_ref(const struct CadaclysmBlacksmithSolid *solid,
uint32_t vertex,
double *out);
Vertex vertex by where it is, three doubles (x y z, in the solid's own coordinates) into out. false and last_error for a vertex the solid does not have or a null argument.
cadaclysm_blacksmith_find_vertex
int32_t cadaclysm_blacksmith_find_vertex(const struct CadaclysmBlacksmithSolid *solid,
const double *vertex_ref,
double tolerance);
The vertex of solid nearest vertex_ref (three doubles, x y z) within tolerance. A vertex reference may be any point, a picked one too, so there is no second tier: -1 where no vertex is that near (no last_error); -2 and last_error as cadaclysm_blacksmith_find_edge.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Booleans
cadaclysm_blacksmith_check
struct CadaclysmBlacksmithCheck *cadaclysm_blacksmith_check(const struct CadaclysmBlacksmithSolid *a,
const struct CadaclysmBlacksmithSolid *b,
const char *operation,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
What is wrong with a (and b, if not null) as the arguments of operation, at tolerance: OCCT's BRepAlgoAPI_Check, gathered from what the kernel already measures. Read the findings with cadaclysm_blacksmith_check_count and cadaclysm_blacksmith_check_finding; none at all is a valid pair. A handle, never null, for any pair the check could run on.
Every argument is checked alone, whatever the operation: "no_faces"; the features smaller than tolerance ("short_edge": index the edge, size its length; "collapsed_edge": index the trim; "sliver_face": index the face, size its width; "tiny_face": index the face, size its area; "tiny_body": size its diagonal; "small_hole": index the loop, size its area or width — as cadaclysm_blacksmith_health finds them); "loose_edge" (index the edge, size how far its sides part); "curve_on_surface" (an edge whose 2D trim through the surface, curve or polyline in space leaves a face's surface, or parts from the others there, by more than the larger of tolerance and the edge's recorded tolerance: index the edge — a trim naming none: the trim — other the face, size the largest deviation); "c0_inside" (a crease where the geometry is only C0, sharper than the angular tolerance — the solid's declared one, else the "tolerance.angular" option: inside a face, index the face and other CADACLYSM_BLACKSMITH_NONE; along an edge's own curve, index the edge and other the lowest-numbered face it bounds; size the largest angle in radians; a knot where the two sides meet tangent is none); and where it passes through itself, as cadaclysm_blacksmith_self_intersect finds it ("self_intersection": index and other the two faces, the same face for a fold, size the crossing's length; "self_overlap": index and other two faces lying on one another; "unmeshable" if it could not be meshed to look). operation (null or empty for none) adds what that verb refuses each argument for: "join", "cut" and "common" want both closed ("open": one finding per free edge, index the edge — CADACLYSM_BLACKSMITH_NONE for a trim naming none — other its face, size its length) and holding no region wall ("region_wall", a merge's body); "split_sheet" and "trim" want only the tool (b) closed, neither walled; "merge" wants both closed manifolds ("non_manifold") of planes, cylinders, cones, spheres and tori ("face_kind": index the face); "intersect" wants nothing. With b null and an operation, a is held to what the operation asks of its first argument. A free edge is no finding without an operation that asks for a closed solid: an open sheet is a fine body.
With b, the pair's sub-shapes a boolean would merge or struggle with are found too, whatever the operation, each finding with argument 0, index in a and other in b: "merge_vertex" (a vertex of each further apart than the weld, 1e-6, but within tolerance: the two vertices as cadaclysm_blacksmith_vertex_ref numbers them, size their distance); "merge_edge" (an edge of each running along one another within tolerance and parallel within the angular tolerance over a stretch longer than tolerance, not one edge: the edge ids, size the largest gap); "merge_face" (a face of each lying on one another only within tolerance: the faces, size the largest separation on the shared region's boundary); "tangent_face" (a face of each whose crossing runs where their normals are parallel within the angular tolerance — a cylinder lying on a block: the faces, size the tangent stretch's length). The last two are read off cadaclysm_blacksmith_intersect's answer, so a point contact, which has no crossing chain, is not found. Exactly coincident vertices, edges and faces are none.
cadaclysm_blacksmith_check_free
void cadaclysm_blacksmith_check_free(struct CadaclysmBlacksmithCheck *check);
Release a check result. Null is a no-op.
cadaclysm_blacksmith_check_count
uint32_t cadaclysm_blacksmith_check_count(const struct CadaclysmBlacksmithCheck *check);
How many findings. 0 (and last_error) for null.
cadaclysm_blacksmith_check_finding
bool cadaclysm_blacksmith_check_finding(const struct CadaclysmBlacksmithCheck *check,
uint32_t i,
struct CadaclysmBlacksmithFinding *out);
Finding i into out. false (and last_error) for a null check, a null out, or i out of range.
cadaclysm_blacksmith_intersect
struct CadaclysmBlacksmithIntersection *cadaclysm_blacksmith_intersect(const struct CadaclysmBlacksmithSolid *a,
const struct CadaclysmBlacksmithSolid *b,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
Where the faces of a and b cross or coincide, at tolerance: chains along the curves the faces meet on (cadaclysm_blacksmith_intersection_chain, cadaclysm_blacksmith_intersection_curve) and, where a face pair coincides, the shared region's outline (cadaclysm_blacksmith_intersection_overlap). No crossing is a handle with zero of each, never null.
Each chain's points are within tolerance of both faces' exact surfaces; one chain per face pair per branch — chains are not joined across a face boundary or a closed curve's seam, so a caller joins them by matching ends; tangent is set where the surfaces are near-tangent along the chain or the snap did not settle within tolerance (the points are then the best estimate); a closed chain that does not go once round its own curve — a sliver of mesh noise where two surfaces barely cross — is reported with no curve at all (cadaclysm_blacksmith_intersection_curve then says so by name), tangent still true. An overlap's rings are the shared region's outline, outer first then holes, and may be empty for a partial overlap of curved faces whose outlines cross. Known limit: a crossing narrower than the mesh tolerance — two surfaces passing within tolerance without their meshes crossing — can be missed; near-tangent contact is where this bites.
tolerance is expected well below the solids' extent (the kernel's own suites use a few ten-thousandths of it): it is the mesh tolerance, and at a tolerance comparable to the extent the meshes are a few facets, the chains a few points, and a curve may be attached whose points, all within that tolerance of it, do not run with its parameter.
cadaclysm_blacksmith_self_intersect
struct CadaclysmBlacksmithIntersection *cadaclysm_blacksmith_self_intersect(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
Where solid passes through itself, at tolerance: the same result as cadaclysm_blacksmith_intersect with solid on both sides, read and freed the same way. Never along its own topology — two faces meeting at their shared edges and vertices are not a crossing, so a clean solid is a handle with zero chains and zero overlaps, never null. A chain's face_a and face_b are both faces of solid; where they are the same face, the face folds through itself, and that chain has no curve (has_curve false). An overlap is two faces of the solid lying on one another.
The solid is meshed once and crossed against itself on the mesh; where two faces' meshes cross, the exact face-pair engine refines the chain. The mesh route's known limit holds: a crossing narrower than tolerance — two faces passing within it without their meshes crossing — can be missed. tolerance is the mesh tolerance, expected well below the solid's extent, as intersect's.
Reports its phases to progress if not null: "mesh", "cull", "cross", "snap", "curve".
cadaclysm_blacksmith_intersection_free
void cadaclysm_blacksmith_intersection_free(struct CadaclysmBlacksmithIntersection *intersection);
Release an intersection result. Null is a no-op.
cadaclysm_blacksmith_intersection_chain_count
uint32_t cadaclysm_blacksmith_intersection_chain_count(const struct CadaclysmBlacksmithIntersection *intersection);
How many chains. 0 (and last_error) for null.
cadaclysm_blacksmith_intersection_chain
bool cadaclysm_blacksmith_intersection_chain(const struct CadaclysmBlacksmithIntersection *intersection,
uint32_t i,
struct CadaclysmBlacksmithChain *out);
Chain i into out. false (and last_error) for null intersection, a null out, or i out of range.
cadaclysm_blacksmith_intersection_curve
bool cadaclysm_blacksmith_intersection_curve(const struct CadaclysmBlacksmithIntersection *intersection,
uint32_t i,
struct CadaclysmBlacksmithCurve *out);
Chain i's exact curve into out, over the chain's own span on it — see cadaclysm_blacksmith_edge_curve's doc for what each field means and the range convention. The chain's points run WITH the curve's parameter: the curve at t0 is the chain's first point and at t1 its last (to the tolerance), and the parameter grows from each point to the next, round the period of a closed curve; a closed chain has the curve's whole domain and runs with it from its first point on. false (and last_error) for null intersection, a null out, i out of range, or a chain with no curve (intersection_curve: chain {i} has no curve).
cadaclysm_blacksmith_intersection_overlap_count
uint32_t cadaclysm_blacksmith_intersection_overlap_count(const struct CadaclysmBlacksmithIntersection *intersection);
How many overlaps. 0 (and last_error) for null.
cadaclysm_blacksmith_intersection_overlap
bool cadaclysm_blacksmith_intersection_overlap(const struct CadaclysmBlacksmithIntersection *intersection,
uint32_t i,
struct CadaclysmBlacksmithOverlap *out);
Overlap i into out. false (and last_error) for null intersection, a null out, or i out of range.
cadaclysm_blacksmith_solid_section
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_solid_section(const struct CadaclysmBlacksmithSolid *s,
double z,
double tolerance);
s cut by the plane Z = z: its closed outlines there, in XY, nested into profiles with holes (boundaries counter-clockwise, holes clockwise), a line or a circle crossing kept exact. A plane that misses the solid is a list with a count of 0. Null (and last_error) for a null solid, a z not finite, a tolerance negative or infinite, a face lying in the plane (section a little above or below it), a crossing that does not close.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_join
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_join(const struct CadaclysmBlacksmithSolid *a,
const struct CadaclysmBlacksmithSolid *b,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
a ∪ b, an exact B-rep whose faces are pieces of the inputs' own faces; only the new edges, where the two meet, are found on the meshes at tolerance.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_cut
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_cut(const struct CadaclysmBlacksmithSolid *a,
const struct CadaclysmBlacksmithSolid *b,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
a − b. See cadaclysm_blacksmith_join.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_common
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_common(const struct CadaclysmBlacksmithSolid *a,
const struct CadaclysmBlacksmithSolid *b,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
a ∩ b. See cadaclysm_blacksmith_join.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_split_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_split_sheet(const struct CadaclysmBlacksmithSolid *sheet,
const struct CadaclysmBlacksmithSolid *tool,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
sheet cut along tool's boundary and nothing removed: every face of sheet comes back in its pieces outside tool and its pieces inside, each piece a face. The faces come out in sheet's own face order, each face's outside pieces before its inside pieces, so an index into the result names a piece for as long as sheet and tool stand. sheet may be an open sheet; tool must be a closed solid. What a surface trim starts from — the pieces to throw away are chosen afterwards.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_push_pull
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_push_pull(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double distance,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
Face face of solid pushed out by distance along its outward normal (pulled in, negative) the way a CAD program extrudes a face: the prism over it joined on (cut out) at tolerance, and the result's flush faces merged — a box's top raised is one taller box of six faces. A face on a cylinder, a cone, a sphere or a torus moves out along its normal instead, the surface a step out (a boss fatter, a bore or a countersink narrower, a dome fuller), the planes beside it carried along. Null and last_error for any other curved face, a curved one with anything but a plane it can follow beside it, reaching a cone's apex, pushed to its axis or centre, off a plane beside it or into another edge, a face the solid does not have, a zero or non-finite distance, or what the boolean refuses.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_push_pull_faces
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_push_pull_faces(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *faces,
size_t count,
double distance,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid with the count faces at faces pushed out by distance together (pulled in, negative) — a press-pull on a selection: each face by cadaclysm_blacksmith_push_pull's rule for it, one after another in the order given, each found again by a point inside it after the pushes before it renumbered the faces. A box's top and a side pushed 5 is the box 5 taller and 5 wider. A face on the same curved surface as one before it, and joined to it, moved with that one and is not pushed twice. Null and last_error for no faces, a face an earlier push took away, and whatever cadaclysm_blacksmith_push_pull refuses of a face.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_split
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_split(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithSolid *tool,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid split by tool into bodies. A closed tool gives the part outside it, then the part inside; a flat sheet splits by the whole plane it lies on. Every connected part is a body, and the bodies come back side by side in one solid: take them apart with cadaclysm_blacksmith_lump_count and cadaclysm_blacksmith_lump. Null and last_error for a tool that does not cross the solid, or a curved sheet.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_split_by_plane
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_split_by_plane(const struct CadaclysmBlacksmithSolid *solid,
const double *plane,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid split by the plane through plane's origin square to its z (a frame, twelve doubles): the bodies in front of it, then those behind, side by side in one solid — see cadaclysm_blacksmith_split.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_split_by_profile
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_split_by_profile(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid split by the closed profile drawn on frame (twelve doubles: origin, x, y, z), pushed straight through it along z both ways — a split by a sketch profile: the bodies outside the profile, then inside, side by side in one solid (cadaclysm_blacksmith_lump takes them apart). Where the plane lies along z does not matter. Null and last_error where the profile misses the solid or takes all of it, or encloses nothing.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_lump_count
uint32_t cadaclysm_blacksmith_lump_count(const struct CadaclysmBlacksmithSolid *solid);
How many connected bodies solid is — faces sharing an edge are one body. A split's result is several; a boolean's can be. 0 and last_error for a null solid.
cadaclysm_blacksmith_lump
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_lump(const struct CadaclysmBlacksmithSolid *solid,
uint32_t index);
Body index of solid (see cadaclysm_blacksmith_lump_count) as a solid of its own, its faces in solid's order and colours. Not a verb: each face and edge keeps its id and its origins as solid has them, so the bodies of a split name the split's operands. Null and last_error for an index the solid has no body at.
cadaclysm_blacksmith_merge_flush
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_merge_flush(const struct CadaclysmBlacksmithSolid *solid);
solid with its flush faces merged, as a new solid: planar faces on one plane, facing one way and meeting along their edges, made one face, and every vertex left in the middle of a straight edge taken out — the seams a join leaves where two parts are flush. A solid with nothing to merge comes back as it was.
Faces and sheets
cadaclysm_blacksmith_face_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_face_sheet(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
Face face of solid (an index below cadaclysm_blacksmith_face_count) alone, as an open sheet: its surface, its loops and the exact curves its edges carry, the rest of the solid left behind. What extruding a solid's face starts from.
cadaclysm_blacksmith_drop_faces
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_drop_faces(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *faces,
size_t count);
solid without the faces at faces (count indices; repeats allowed): the rest keep their surfaces, loops and curves, in their order, so an index into the result is the input's with the dropped ones closed up. Refused for an index the solid has no face at, or where nothing would be left.
cadaclysm_blacksmith_trim
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_trim(const struct CadaclysmBlacksmithSolid *sheet,
const struct CadaclysmBlacksmithSolid *tool,
bool keep_inside,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
sheet cut along the closed tool's boundary and the pieces on one side thrown away — cadaclysm_blacksmith_split_sheet and cadaclysm_blacksmith_drop_faces in one: keep_inside false keeps what lies outside the tool (a hole punched through the sheet), true what lies inside it (the sheet cut to the tool's outline). The kept pieces come out in sheet's face order. Refused where nothing lies on the kept side, and as the split refuses.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Edges and finishing
cadaclysm_blacksmith_edge_point_at_length
bool cadaclysm_blacksmith_edge_point_at_length(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
double s,
double accuracy,
struct CadaclysmBlacksmithAt *out);
The point at arc length s along edge edge of solid (the index cadaclysm_blacksmith_edge_length takes), from the start of the range its edge_curve row reports, into out. s lies in [0, length]; past either end by no more than the length's error is that end.
false and last_error for a null solid or out, an edge past the end of the table or with no exact curve, an s outside the edge, and an accuracy that is NaN, infinite, or 1 or more.
cadaclysm_blacksmith_edge_divide_by_count
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_edge_divide_by_count(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
uint32_t n,
double accuracy);
Edge edge of solid in n pieces of equal arc length: n + 1 samples from its start to its end, or n for an edge that closes on itself (its range is its curve's whole closed loop: a whole circle or ellipse, a closed spline's whole domain), whose end is its start again. The first sample is exactly the range's start.
Null and last_error for a null solid, an edge past the end or with no exact curve, an n of 0 or above 1 000 000, and an accuracy that is NaN, infinite, or 1 or more.
cadaclysm_blacksmith_edge_divide_by_length
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_edge_divide_by_length(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
double step,
double accuracy);
Samples of edge edge of solid every step of arc length from its start; the last piece is whatever is left over, the end a sample only where a step lands on it, and an edge that closes on itself never repeats its start.
Null and last_error for a null solid, an edge past the end or with no exact curve, a step not positive and finite or giving more than 1 000 000 samples, and an accuracy that is NaN, infinite, or 1 or more.
cadaclysm_blacksmith_edge_bezier_count
uint32_t cadaclysm_blacksmith_edge_bezier_count(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
How many Béziers cadaclysm_blacksmith_edge_beziers writes for solid at tolerance. 0 and last_error for a null solid or a tolerance negative or infinite.
cadaclysm_blacksmith_edge_beziers
bool cadaclysm_blacksmith_edge_beziers(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
double *out);
solid's edges as rational cubic Béziers into out, sixteen doubles each — x y z w per control point, the point Cartesian and its weight beside it, the record cadaclysm_blacksmith_profile_from_beziers reads: what a viewer draws the solid's edges by. Exact where an edge's curve has a Bézier form (a line one Bézier, a circle quarter-turn conics, a spline its own pieces), flattened within tolerance where it has none, and an edge known only as a polyline (a join's new edge, a shell's inner skin) drawn as the straight pieces it is. Size out from cadaclysm_blacksmith_edge_bezier_count at the same tolerance. false and last_error for a null argument or a tolerance negative or infinite.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_edge_tolerance
double cadaclysm_blacksmith_edge_tolerance(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge);
How far edge edge (a brep edge id, as a fix's index names one) may lie off its curve: 0 for an exact edge, the distance healing (or sewing) moved it where that is recorded, NaN when no trim of a face's loop names the id (an edge healing removed) or (with last_error) solid is null.
cadaclysm_blacksmith_edge_length
bool cadaclysm_blacksmith_edge_length(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
double accuracy,
struct CadaclysmBlacksmithLength *out);
The length of edge edge of solid (the index cadaclysm_blacksmith_edge and fillet use), over the parameter range its edge_curve row reports, to a relative accuracy in (0, 1) (0 or less asks for the default, measure.default_accuracy).
false and last_error for a null solid or a null out; an index past the end of the table (cadaclysm_blacksmith_edge_count), which leaves out the edges with no exact curve, so a body read with 2D-only trims, as from Rhino or IGES, may list none; an edge with no exact curve; and an accuracy that is NaN, infinite, or 1 or more (outside the length contract, refused rather than clamped).
cadaclysm_blacksmith_edge_closest_point
int32_t cadaclysm_blacksmith_edge_closest_point(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
const double *p,
double *out);
The nearest point to p (3 doubles) of edge edge — a row of the list cadaclysm_blacksmith_edge walks, the number edge_length and fillet take and a CadaclysmBlacksmithPointFoot's edge — on its own curve over its range, as five doubles into out: t x y z distance, t the parameter edge_curve and edge_point_at_length use. Exact, no mesh. Returns 1, or -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null solid, p or out, a row out of range, one with no exact curve, or a non-finite point.
cadaclysm_blacksmith_edge_surface
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_edge_surface(const struct CadaclysmBlacksmithNurbsCurve *const *curves,
size_t count,
double tolerance,
double *error_out);
The Coons sheet of 2, 3 or 4 boundary curves meeting end to end (in order round the boundary, each either way round) within tolerance; exact for non-rational boundaries, rational ones fitted first (that error to error_out when not NULL).
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_edge_continuity
bool cadaclysm_blacksmith_edge_continuity(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
uint32_t samples,
struct CadaclysmBlacksmithContinuity *out);
How well the two faces of edge edge of solid (the index cadaclysm_blacksmith_edge_curve takes) meet along it, into out: samples points along the edge (16 at fewest), each projected onto both faces, and the largest gap between the two feet, angle between the faces' normals (each turned the way its face faces: a square crease reads pi/2, a fold back near pi) and difference of their normal curvatures square to the edge. Any two faces of one body, any kind of surface: a NURBS face's curvature is exact, another's differenced at a ten-thousandth of the edge's length. Refused for an edge that does not bound exactly two faces.
cadaclysm_blacksmith_edge_polylines
struct CadaclysmBlacksmithPolylines cadaclysm_blacksmith_edge_polylines(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
The feature edges the mesher locked at tolerance, as polylines that lie on the mesh cadaclysm_blacksmith_mesh gives at the same tolerance. Same cache and lifetime rule as the mesh. For arrays that must outlive a re-mesh or the solid, hold the tessellation: cadaclysm_blacksmith_tessellation.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_edge_count
uint32_t cadaclysm_blacksmith_edge_count(const struct CadaclysmBlacksmithSolid *solid);
Edges in a stable order (by each edge's first trim), computed on first ask. An index into this list is what cadaclysm_blacksmith_fillet takes. Edges without an exact curve — a boolean's edge on surfaces the intersection module does not know — are not listed.
cadaclysm_blacksmith_edge
bool cadaclysm_blacksmith_edge(const struct CadaclysmBlacksmithSolid *solid,
uint32_t i,
struct CadaclysmBlacksmithEdge *out);
Edge i into out. false (and last_error) if i is out of range.
cadaclysm_blacksmith_edge_curve
bool cadaclysm_blacksmith_edge_curve(const struct CadaclysmBlacksmithSolid *solid,
uint32_t i,
struct CadaclysmBlacksmithCurve *out);
Edge i's exact curve, borrowed from the solid: valid until it is freed (the solid caches its curve table on first ask, like CadaclysmBlacksmithEdge does its own table).
The range convention: t0..t1 is the edge's parameter range on its own curve — a line's fraction (0..1 over origin -> origin + x, where x is the full to - from, NOT unit, so point(t) = origin + x*t); a circle's or ellipse's angle in radians about origin in the x, y plane (point(t) = origin + x*radius*cos(t) + y*radius2*sin(t), radius2 == radius for a circle); a parabola's own parameter with radius its focal length F (point(t) = origin + x*F*t*t + y*2*F*t, radius2 0); a hyperbola's with radius, radius2 its semi-axes a, b (point(t) = origin + x*a*cosh(t) + y*b*sinh(t)); a NURBS's knot parameter (knots[degree] <= t0 < t1 <= knots[n]). Frame vectors x, y, z are unit for a conic; for a line x is the direction with length equal to the line's own length and y, z are zero. Always t0 < t1: an edge whose segments run against its curve's own parameter reports the same range — read the direction from the edge's segments, not from the range.
kind is one of "line", "circle", "ellipse", "parabola", "hyperbola" or "nurbs" — static, never freed. For a conic or a line degree is 0 and knots, poles, weights are null with zero counts; for a NURBS origin, x, y, z are zero and radius, radius2 are 0. poles is three doubles per control point; weights is null for a non-rational (plain B-spline) curve, otherwise one weight per pole.
cadaclysm_blacksmith_solid_offset
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_solid_offset(const struct CadaclysmBlacksmithSolid *solid,
double distance,
double tolerance);
solid offset by distance — every face moved along its outward normal, positive outward, negative inward, the faces' new neighbours meeting at sharp joins (OCCT's BRepOffsetAPI_MakeOffsetShape by join, intersection mode). A closed solid grows or shrinks to the solid its moved skin bounds; an open sheet moves to its twin, its rims open. Each face keeps the colour, id and attributes of the face it was moved from, however far it moved (its one origin that face); edges are matched by position. A face the offset uses up is gone. Null and last_error (prefixed solid_offset: ) for a distance that is 0, NaN or infinite, a face that folds over (a wall used up), or a skin the offset leaves open.
tolerance 0 or NaN: the input's effective tolerance.
cadaclysm_blacksmith_solid_offset_face
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_solid_offset_face(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double distance,
double tolerance);
Face face of solid (an index below cadaclysm_blacksmith_face_count) alone, as an open sheet moved distance along its outward normal, still facing the source's way. A face closed on itself (a sphere's only face) gives a closed solid. Null and last_error (prefixed solid_offset_face: ) for a face the solid has not, a distance that is 0, NaN or infinite, or an offset that folds over.
tolerance 0 or NaN: the input's effective tolerance.
cadaclysm_blacksmith_fillet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_fillet(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double radius,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid with the edges at edges (indices into the list cadaclysm_blacksmith_edge walks) rounded to radius. A spline edge — the crease between two faces on NURBS surfaces, from one free edge of the shell to another — is rounded by a ball rolled along it, in a call of its own (not with straight or circular edges); tolerance is then the fillet surface's fit, floored at a millionth of the body.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_fillet_varying
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_fillet_varying(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double radius_start,
double radius_end,
double tolerance);
cadaclysm_blacksmith_fillet with the radius running linearly from radius_start to radius_end in arc length along each edge, radius_start at the end where the edge's curve starts. Spline edges only — the crease between two faces on NURBS surfaces, running from one free edge of the shell to another (a straight or circular edge is refused). tolerance is the fillet surface's fit, floored at a millionth of the body, as it is for a spline edge given to cadaclysm_blacksmith_fillet.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_fillet_each
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_fillet_each(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
const double *radii,
size_t count,
double tolerance);
cadaclysm_blacksmith_fillet with a radius for each picked edge, radii[i] for edges[i]: spline edges only, as for cadaclysm_blacksmith_fillet_varying. The creases meeting at a corner of the shell (three or more, every one picked) are rounded in one call, each at its own size, and the corner between their fillets is filled by an N-sided patch meeting them tangent.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_fillet_law
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_fillet_law(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
const double *shares,
const double *radii,
size_t station_count,
double tolerance);
cadaclysm_blacksmith_fillet along a chain of spline edges with the radius following a law: radii[i] at shares[i] of the chain's arc length from its start (0 to 1), run through smoothly by a monotone cubic — the radius never swings past its stations — and held flat before the first station and after the last. The count edges must run end to end into one open chain, each running on tangent into the next; the chain runs the way edges[0]'s curve does. Where the faces either side change from one edge to the next they must meet smooth along a seam through the vertex between. One edge is a chain of one. tolerance is the fillet surfaces' fit, as for cadaclysm_blacksmith_fillet_varying.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_chamfer
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_chamfer(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double distance,
double tolerance);
cadaclysm_blacksmith_fillet with a flat bevel instead of a ball: every picked edge cut back by distance along both its faces, the cut a plane (a cone round a circular edge). The same edges, the same refusals.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_refillet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_refillet(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double radius,
double tolerance);
solid with the round face face belongs to made again at radius — the fillet's bands, balls and rim bands joined to that face taken back to the sharp edges they replaced and those rounded again, as a press-pull on a fillet face. Null and last_error for a face that is not a round of straight edges between planes or of circular rims, or a radius that does not fit.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_unfillet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_unfillet(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
solid with the round face face belongs to taken off, the faces beside it made sharp again — the delete of a fillet face. The same refusals as cadaclysm_blacksmith_refillet.
cadaclysm_blacksmith_rechamfer
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_rechamfer(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double distance,
double tolerance);
solid with the chamfer face face belongs to cut again at distance — its bevels (flat between two planes, cones round rims) and the corner triangles joined to that face taken back to the sharp edges they cut and those bevelled again, as a press-pull on a chamfer face. Null and last_error for a face that is not a chamfer's bevel, or a distance that does not fit.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_unchamfer
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_unchamfer(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
solid with the chamfer face face belongs to taken off, the faces beside it made sharp again. The same refusals as cadaclysm_blacksmith_rechamfer.
cadaclysm_blacksmith_shell
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_shell(const struct CadaclysmBlacksmithSolid *solid,
double thickness,
const uint32_t *open_faces,
size_t count,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid hollowed to a wall thickness thick (inward for a positive thickness, outward — the solid becoming the cavity — for a negative one), with the faces at open_faces removed so the hollow is reachable.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_thicken
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_thicken(const struct CadaclysmBlacksmithSolid *solid,
double thickness,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid, a sheet, made a solid thickness thick: its faces, their twins moved thickness along the faces' normals (against them for a negative thickness), and a wall round every open edge. Two faces of a folded sheet meet on their offsets' mitre; a closed sheet thickens to a hollow. Free-form (NURBS) faces offset by a fit held to tolerance. Null and last_error for a thickness a face cannot take (a radius used up, a free-form offset folding over).
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Asking
cadaclysm_blacksmith_samples_count
uint32_t cadaclysm_blacksmith_samples_count(const struct CadaclysmBlacksmithSamples *samples);
How many samples. 0 (and last_error) for null.
cadaclysm_blacksmith_samples_at
bool cadaclysm_blacksmith_samples_at(const struct CadaclysmBlacksmithSamples *samples,
uint32_t i,
struct CadaclysmBlacksmithAt *out);
Sample i into out. false (and last_error) for a null samples, a null out, or i not below the count.
cadaclysm_blacksmith_samples_free
void cadaclysm_blacksmith_samples_free(struct CadaclysmBlacksmithSamples *samples);
Release a samples list. Null is a no-op.
cadaclysm_blacksmith_face_round_radius
double cadaclysm_blacksmith_face_round_radius(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
The radius of the round face face belongs to — a fillet's face that cadaclysm_blacksmith_unfillet can take back — 0 where it is none: only cylinders, spheres and tori a fillet made are asked. face in the solid's own face order. NaN and last_error for a null solid or a face past the end.
cadaclysm_blacksmith_face_chamfer_distance
double cadaclysm_blacksmith_face_chamfer_distance(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
The distance of the chamfer face face belongs to — a bevel cadaclysm_blacksmith_unchamfer can take back — 0 where it is none: only the planes and cones a chamfer made are asked. NaN and last_error for a null solid or a face past the end.
cadaclysm_blacksmith_isocurve_bezier_count
uint32_t cadaclysm_blacksmith_isocurve_bezier_count(const struct CadaclysmBlacksmithSolid *solid,
uint32_t density,
double tolerance);
How many Béziers cadaclysm_blacksmith_isocurve_beziers writes for solid at density and tolerance. 0 and last_error for a null solid or a tolerance negative or infinite.
cadaclysm_blacksmith_isocurve_beziers
bool cadaclysm_blacksmith_isocurve_beziers(const struct CadaclysmBlacksmithSolid *solid,
uint32_t density,
double tolerance,
double *out);
solid's isoparametric curves as rational cubic Béziers into out, sixteen doubles each as cadaclysm_blacksmith_edge_beziers writes them: density interior lines each way on every curved face, clipped to the face, plus the lines at the ends of the face's parameter span; a flat face draws none. Exact where the surface has a closed form for the line (a cylinder's rings are circles), flattened within tolerance elsewhere. Size out from cadaclysm_blacksmith_isocurve_bezier_count with the same arguments. false and last_error for a null argument or a tolerance negative or infinite.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_classifier_new
struct CadaclysmBlacksmithClassifier *cadaclysm_blacksmith_classifier_new(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
A classifier for the closed solid at the absolute tolerance (positive and finite, or unset). Null (and last_error) for a null solid, a tolerance that is negative or infinite, an open body (its inside means nothing) or a body that meshes to nothing.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_classifier_contains
bool cadaclysm_blacksmith_classifier_contains(const struct CadaclysmBlacksmithClassifier *classifier,
const double *point,
uint32_t *out);
Where point (3 doubles) is relative to the classifier's body, into out: one of the CADACLYSM_BLACKSMITH_OUTSIDE/_INSIDE/_ON codes. false (and last_error) for a null classifier, point or out, or a point that is not finite; out is untouched then.
cadaclysm_blacksmith_classifier_free
void cadaclysm_blacksmith_classifier_free(struct CadaclysmBlacksmithClassifier *classifier);
Release a classifier. Null is a no-op.
cadaclysm_blacksmith_contains
bool cadaclysm_blacksmith_contains(const struct CadaclysmBlacksmithSolid *solid,
const double *point,
double tolerance,
uint32_t *out);
Where point (3 doubles) is relative to the closed solid, to the absolute tolerance (positive and finite, or unset), into out — a classifier built and asked once, so the body is meshed every call: build a CadaclysmBlacksmithClassifier for more than a few points. false (and last_error) for a null solid, point or out, a point that is not finite, or what cadaclysm_blacksmith_classifier_new refuses.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_mass_properties
bool cadaclysm_blacksmith_mass_properties(const struct CadaclysmBlacksmithSolid *solid,
double accuracy,
struct CadaclysmBlacksmithMassProperties *out);
Measure solid to a relative accuracy, into out. false and last_error if it cannot be measured; accuracy of 0 or less asks for the default, a part in ten million.
The body need not be one we built: cadaclysm_blacksmith_from_brep takes the brep a read file hands out through cadaclysm_node_brep, so anything the reader opens can be measured here.
cadaclysm_blacksmith_oriented_box
bool cadaclysm_blacksmith_oriented_box(const struct CadaclysmBlacksmithSolid *solid,
double accuracy,
struct CadaclysmBlacksmithOrientedBox *out);
solid's box on its principal axes, to a relative accuracy, into out. false and last_error for an open body, which has no principal axes, a NaN or infinite accuracy, a null solid or a null out.
0 or less asks for the box's own default, 1e-5 — not measure.default_accuracy. The box costs a mass-properties integration at its accuracy, tens of seconds at 1e-7 on free-form bodies read from files, and a finer accuracy buys little box for it: the half extents are grown by diag · max(accuracy, τ/16), τ the tolerance the integration settled on, which starts at 5e-4 · diag — so a body that settles at once (planes, cylinders, cones) is grown by about 3.1e-5 · diag however fine the accuracy asked.
cadaclysm_blacksmith_closest
bool cadaclysm_blacksmith_closest(const struct CadaclysmBlacksmithSolid *a,
const struct CadaclysmBlacksmithSolid *b,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user,
struct CadaclysmBlacksmithClosest *out);
The closest points between the boundaries of a and b, to the absolute tolerance (positive and finite, or unset), into out — see CadaclysmBlacksmithClosest for what the figures promise. false and last_error for a null solid or out, a tolerance that is negative or infinite, or a body that meshes to nothing; out is untouched then.
Reports meshing, pruning and refining to progress if not null. Curved bodies about equally far apart everywhere (a ball nested in a ball) cost seconds at a tolerance of 1e-3, and quadratically less at a coarser one.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_closest_point
int32_t cadaclysm_blacksmith_closest_point(const struct CadaclysmBlacksmithSolid *solid,
const double *p,
double max_distance,
double tolerance,
struct CadaclysmBlacksmithPointFoot *out);
The nearest point of solid's boundary to p (3 doubles), into out — see CadaclysmBlacksmithPointFoot for what the figures promise. Returns 1 with out filled; 0, out untouched, where the nearest point is beyond max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null solid, p or out, a non-finite point, a negative max_distance, a tolerance that is negative or infinite, or a body that meshes to nothing.
max_distance NaN or +inf is no limit. Only a nearest point *beyond* it answers 0: one a rounding error past it is not beyond, so max_distance 0 finds a point that lies on the body and answers 0 for one off it.
tolerance sizes the mesh search: a refined 0 answer is within [d - 2/3 tolerance, d + tolerance] of the true distance d.
cadaclysm_blacksmith_projector_new
struct CadaclysmBlacksmithProjector *cadaclysm_blacksmith_projector_new(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
A projector for solid at the absolute tolerance (positive and finite, or unset). Null (and last_error) for a null solid, a tolerance that is negative or infinite, or a body that meshes to nothing. Open bodies and sheets are accepted.
tolerance sizes the mesh search: a refined 0 answer is within [d - 2/3 tolerance, d + tolerance] of the true distance d.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_projector_closest_point
int32_t cadaclysm_blacksmith_projector_closest_point(const struct CadaclysmBlacksmithProjector *projector,
const double *p,
double max_distance,
struct CadaclysmBlacksmithPointFoot *out);
The nearest point of the projector's body to p (3 doubles), into out, answered as cadaclysm_blacksmith_closest_point answers it, max_distance included: 1 found, 0 (out untouched) beyond max_distance, and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null projector, p or out, a non-finite point or a negative max_distance.
cadaclysm_blacksmith_projector_free
void cadaclysm_blacksmith_projector_free(struct CadaclysmBlacksmithProjector *projector);
Release a projector. Null is a no-op.
cadaclysm_blacksmith_face_closest_point
int32_t cadaclysm_blacksmith_face_closest_point(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *p,
struct CadaclysmBlacksmithPointFoot *out);
The nearest point to p (3 doubles) of face face of solid alone, inside its trims or on its boundary, into out: exact, no mesh, refined 1. Returns 1 with out filled, or -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null solid, p or out, a face out of range, a non-finite point or a face that gives no point.
cadaclysm_blacksmith_curve_closest_points
int32_t cadaclysm_blacksmith_curve_closest_points(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithNurbsCurve *curve,
double max_distance,
double tolerance,
struct CadaclysmBlacksmithCurveBodyFoot *out);
The nearest points of curve and solid's boundary, into out — see CadaclysmBlacksmithCurveBodyFoot (read body.edge for the public edge number). Returns 1 with out filled; 0, out untouched, where the body is farther than max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null solid, curve or out, a curve that is not valid, a negative max_distance, a tolerance that is negative or infinite, a body that meshes to nothing, or a curve too long for the tolerance.
max_distance NaN or +inf is no limit; only a distance *beyond* it answers 0.
tolerance sizes the march along the curve and the mesh search: a body.refined 0 answer is within [d - 2/3 tolerance, d + tolerance] of the true distance d.
cadaclysm_blacksmith_projector_curve_closest_points
int32_t cadaclysm_blacksmith_projector_curve_closest_points(const struct CadaclysmBlacksmithProjector *projector,
const struct CadaclysmBlacksmithNurbsCurve *curve,
double max_distance,
struct CadaclysmBlacksmithCurveBodyFoot *out);
The nearest points of curve and the projector's body, into out, answered as cadaclysm_blacksmith_curve_closest_points answers them at the projector's tolerance, max_distance included: 1 found, 0 (out untouched) beyond max_distance, and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null projector, curve or out, a curve that is not valid, a negative max_distance, or a curve too long for the tolerance.
cadaclysm_blacksmith_face_iso_intervals
uint32_t cadaclysm_blacksmith_face_iso_intervals(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
bool along_u,
double at,
double *out,
uint32_t capacity);
The intervals of the swept parameter along which face face's isocurve lies inside its trims (Rhino's TrimAwareIsoIntervals), ascending, as (start, end) pairs: the count of pairs is returned and min(count, capacity) pairs written to out (2 * capacity doubles; NULL with a capacity of 0 asks for the count alone). 0 (and last_error) for a null solid, a face past the end, an at not finite.
cadaclysm_blacksmith_bounds
bool cadaclysm_blacksmith_bounds(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
double *min,
double *max);
The solid's axis-aligned bounds, over the positions of the solid's cached tessellation at tolerance (so curved faces are within that of the truth) — the same cache cadaclysm_blacksmith_mesh fills and reuses, so a second call at the same tolerance costs nothing extra. false on a null solid or a non-positive, non-finite tolerance.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_bounds64
bool cadaclysm_blacksmith_bounds64(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
double *min,
double *max);
cadaclysm_blacksmith_bounds in double, from the same tessellation's unnarrowed positions: exact far from the origin, where bounds' widened f32 positions are not. false on a null solid or a non-positive, non-finite tolerance.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_box
bool cadaclysm_blacksmith_box(const struct CadaclysmBlacksmithSolid *solid,
double *min,
double *max);
The solid's axis-aligned box, in double, at a cost that does not grow with the solid's size: its mesh at a tolerance of a thousandth of its own extent, so the box is inside the exact one and short of it by at most that. What a wrapper's bounds reads. cadaclysm_blacksmith_bounds meshes at a tolerance the caller names — an absolute one, which on a part tens of metres long in millimetres is millions of triangles. Worked out once per solid, and apart from the tessellation mesh and bounds share: asking it never invalidates their arrays. false on a null solid or null output.
cadaclysm_blacksmith_face_count
uint32_t cadaclysm_blacksmith_face_count(const struct CadaclysmBlacksmithSolid *solid);
Faces in the solid's own order; indices into this are what cadaclysm_blacksmith_select_face returns and shell takes.
cadaclysm_blacksmith_select_face
uint32_t cadaclysm_blacksmith_select_face(const struct CadaclysmBlacksmithSolid *solid,
uint32_t kind,
const double *v,
uint32_t index);
The face a selector picks, or CADACLYSM_BLACKSMITH_NONE (and last_error) if none does. kind 0 = the face furthest along axis index (0 x, 1 y, 2 z); 1 = furthest against it; 2 = the face whose outward normal is nearest the direction in v (three doubles, need not be unit); 3 = the face at index. v is read only for kind 2, index only for kinds 0, 1 and 3.
cadaclysm_blacksmith_face_frame
bool cadaclysm_blacksmith_face_frame(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double *out);
The workplane on a face, twelve doubles into out: origin at the face's boundary centroid, z its outward normal, x world X laid onto the face (world Y on a face facing close to X) — what Workplane::workplane adopts. false if the face's boundary or normal cannot be read.
cadaclysm_blacksmith_face_ref
bool cadaclysm_blacksmith_face_ref(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double *out);
Face face by what it is, eight doubles into out: the surface's kind (plane 0, cylinder 1, cone 2, sphere 3, torus 4, NURBS 5, revolution 6, extrusion 7, sum 8), a point on the surface at the face's middle (x y z), the outward normal there (x y z), and the face's extent — a reference a feature made on the face keeps, to find the face again with cadaclysm_blacksmith_find_face when the solid has been rebuilt with its faces moved, split or renumbered. Take it off the solid before any move you apply to it, and look it up on the unmoved one. false and last_error for a face the solid does not have, or with nothing to read.
cadaclysm_blacksmith_find_face
int32_t cadaclysm_blacksmith_find_face(const struct CadaclysmBlacksmithSolid *solid,
const double *face_ref,
int32_t hint,
double tolerance);
The face of solid that face_ref (eight doubles, as cadaclysm_blacksmith_face_ref lays them out) refers to: among the faces of that kind whose surface passes through the point, facing the same way, the one the point lies in — or, where it lies in none (the face shrank away, a hole opened under it), the one whose boundary comes nearest. Where no surface of that kind passes through the point (the solid was resized), the faces of that kind facing the same way at its projection: the only one, or the one clearly nearest the point. hint is the index the face had, preferred among faces that fit equally well (negative for none); tolerance how far the point may sit off a surface to still be on it. -1 where the face is gone (no last_error); -2 and last_error for a null solid or a malformed reference.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_face_kind
const char *cadaclysm_blacksmith_face_kind(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
The face's surface kind: "plane", "cylinder", "cone", "sphere", "torus", "nurbs", "revolution", "extrusion", "other", or "none" for a face without a surface. Static; never freed. Null (and last_error) for a face out of range.
cadaclysm_blacksmith_leaked_edges
uint32_t cadaclysm_blacksmith_leaked_edges(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
How many edges of the solid's mesh at tolerance are bound by anything other than exactly two triangles — zero for a closed solid. The mesh is the one cadaclysm_blacksmith_mesh and cadaclysm_blacksmith_mesh_face_triangles hand out at that tolerance, read at its double-precision positions rather than the f32 arrays (whose precision falls off with a coordinate's magnitude, so a solid far from the origin could weld a shared edge wrongly there). It comes from the cache where that is at tolerance, and is meshed the same way where it is not, without replacing the cache: arrays already lent out stay valid.
It was once a full-quality mesh of its own, and the two can disagree: a 64-section terrain loft meshed closed that way at 838,932 triangles, while the mesh handed out came to 1,040,670 — past the body's ceiling of a million — with its last five faces left empty and 3,672 open edges, reported as none. A face the ceiling leaves empty opens every edge it shares with a face that meshed; a whole shell left empty opens none, and shows only as zeros among the face triangle counts.
A hole (one triangle on an edge), a fold, and a seam two solids share along a line (four triangles meeting on it) all count here; cadaclysm_blacksmith_unpaired_edges is the check that lets the seam pass. CADACLYSM_BLACKSMITH_NONE (and last_error) on a null solid or a non-positive, non-finite tolerance.
cadaclysm_blacksmith_unpaired_edges
uint32_t cadaclysm_blacksmith_unpaired_edges(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
How many edges of a fresh mesh of the solid at tolerance have directed triangle uses that do not pair off — zero for a closed, consistently oriented solid. Where cadaclysm_blacksmith_leaked_edges asks for exactly two triangles on an edge, this asks that they run opposite ways and cancel: the seam two solids share along a line pairs off (two triangles each way) and is *not* counted here even though four triangles meet there, while a fold — two triangles running the same way — is. The question a boolean's operands must answer, since inside and outside are as well defined either side of such a seam as of any other edge. Asked of the same mesh, at the same precision, as cadaclysm_blacksmith_leaked_edges. Same failure shape as cadaclysm_blacksmith_leaked_edges.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_manifold
bool cadaclysm_blacksmith_manifold(const struct CadaclysmBlacksmithSolid *solid, uint32_t *out);
Whether the solid's faces make a manifold, read off its topology — the edges and loops it is made of — rather than a mesh: nothing is tessellated, so it takes no tolerance. Eight counts into out, in order: faces, edges, vertices, boundary edges (bordered by one face), non-manifold edges (by three or more), non-manifold vertices (where the faces round a point make more than one fan: two solids touching at a corner), then 1 if it is a manifold (no non-manifold edge or vertex) and 1 if it is also closed (no boundary edge: it encloses a solid), else 0. A sheet is a manifold that is not closed.
Orientation is not asked — whether the faces all face out is cadaclysm_blacksmith_unpaired_edges's question, on a mesh. false (and last_error) on a null argument.
Health report
cadaclysm_blacksmith_health
struct CadaclysmBlacksmithHealth *cadaclysm_blacksmith_health(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
bool mesh);
Diagnose a solid's body: its free edges and the wires they chain into, the features smaller than tolerance, what a dry-run sew would do, and (with mesh) the cracks of its mesh. solid is left as it was. NaN or tolerance <= 0 takes the default, 1e-4 times the diagonal of the body's edge points — or, where the solid declares an absolute tolerance, the larger of that declaration and tolerance.relative times the same diagonal, as cadaclysm_blacksmith_healed heals; the report's sizes[0] says what was used. With mesh the body is also meshed at that tolerance, which costs time on a large body.
A report handle, read with the cadaclysm_blacksmith_health_* accessors and freed with cadaclysm_blacksmith_health_free; null (and last_error) on a null solid.
cadaclysm_blacksmith_health_free
void cadaclysm_blacksmith_health_free(struct CadaclysmBlacksmithHealth *health);
Free a report. Null is a no-op.
cadaclysm_blacksmith_health_summary
bool cadaclysm_blacksmith_health_summary(const struct CadaclysmBlacksmithHealth *health,
uint32_t *counts,
double *sizes);
The report's figures. counts, eighteen uint32_t, in order: free edges, wires, closed wires, small features, short edges, collapsed edges, sliver faces, tiny faces, tiny body, loose edges, sew pairs, sew refused, meshed, watertight, open, folded, crossings, crack edges (the last six are 0 unless the report was made with mesh, and meshed is 1 then). sizes, eight double: tolerance used, rounding, extent, worst free-edge gap (largest finite, 0 if none), worst loose edge, sew worst gap, shortest edge, narrowest face (0 if none). Either output may be null; not both. false (and last_error) on a null health or both outputs null.
cadaclysm_blacksmith_health_free_edges
uint32_t cadaclysm_blacksmith_health_free_edges(const struct CadaclysmBlacksmithHealth *health,
uint32_t *ids,
double *sizes);
The free edges (the sides one face bounds), one row each: ids, six uint32_t per edge — trim, edge, face, wire, partner, shared ends (edge and partner are UINT32_MAX where there is none); sizes, two double per edge — length, gap to its partner (+inf with none). Returns the count; with both buffers null it writes nothing, so call it twice: once to size the buffers, once to fill them. A non-null buffer must hold the whole count. Zero (and last_error) on a null health.
cadaclysm_blacksmith_health_wires
uint32_t cadaclysm_blacksmith_health_wires(const struct CadaclysmBlacksmithHealth *health,
uint32_t *runs,
double *sizes);
The free wires (the free edges chained end to end), one row each: runs, three uint32_t per wire — first, count, closed (the free-edge rows it covers); sizes, two double — length, widest gap. Returns the count, with the two-call convention of cadaclysm_blacksmith_health_free_edges.
cadaclysm_blacksmith_health_small
uint32_t cadaclysm_blacksmith_health_small(const struct CadaclysmBlacksmithHealth *health,
uint32_t *items,
double *sizes);
The features below the tolerance, one row each: items, two uint32_t — kind (0 short edge, 1 collapsed edge, 2 sliver face, 3 tiny face, 4 tiny body, 5 small hole), index (a hole's is its loop); sizes, one double — its size. Returns the count, with the two-call convention of cadaclysm_blacksmith_health_free_edges.
cadaclysm_blacksmith_health_crack_edges
uint32_t cadaclysm_blacksmith_health_crack_edges(const struct CadaclysmBlacksmithHealth *health,
uint32_t *ids);
The edge ids the mesh cracks along (none unless the report was made with mesh). Returns the count, with the two-call convention of cadaclysm_blacksmith_health_free_edges.
Healing
cadaclysm_blacksmith_healed
struct CadaclysmBlacksmithHeal *cadaclysm_blacksmith_healed(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
uint32_t flags);
Remove the features smaller than tolerance that cadaclysm_blacksmith_health lists as small: short and collapsed edges, sliver and tiny faces, small holes. Every fix is a vertex merge; each edge moved records how far as its tolerance (cadaclysm_blacksmith_edge_tolerance). A guard compares the result's health with the input's and refuses fixes that made it worse (the summary's guarded). solid is left as it was; the healed solid keeps its name and colours. NaN or tolerance <= 0 takes the default, 1e-4 times the diagonal of the body's edge points — or, where the solid declares an absolute tolerance, the larger of that declaration and tolerance.relative times the same diagonal (see cadaclysm_blacksmith_effective_tolerance); the summary's sizes[0] says what was used. flags picks what is fixed: 1 edges, 2 faces, 4 holes, 7 all; a kind switched off is refused as toggled.
A report handle, read with the cadaclysm_blacksmith_heal_* accessors and freed with cadaclysm_blacksmith_heal_free; null (and last_error) on a null solid or a flag bit other than those three.
cadaclysm_blacksmith_heal_body
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_heal_body(const struct CadaclysmBlacksmithHeal *h);
The healed solid: a new solid the caller frees with cadaclysm_blacksmith_solid_free, each call a solid of its own (sharing the body, not copying it). It outlives the report. Null (and last_error) on a null h.
cadaclysm_blacksmith_heal_free
void cadaclysm_blacksmith_heal_free(struct CadaclysmBlacksmithHeal *h);
Free a report. Null is a no-op. A solid taken with cadaclysm_blacksmith_heal_body stays good.
cadaclysm_blacksmith_heal_summary
bool cadaclysm_blacksmith_heal_summary(const struct CadaclysmBlacksmithHeal *h,
uint32_t *counts,
double *sizes);
The report's figures. counts, eleven uint32_t, in order: fixes, refused, guarded, small before, small after, free edges before, free edges after, closed before, closed after, non-manifold edges before, non-manifold edges after (before and after are the input's and the result's health at the tolerance used). sizes, two double: the tolerance used, the furthest any trim moved. Either output may be null; not both. false (and last_error) on a null h or both outputs null.
cadaclysm_blacksmith_heal_fixes
uint32_t cadaclysm_blacksmith_heal_fixes(const struct CadaclysmBlacksmithHeal *h,
uint32_t *items,
double *sizes);
The features removed, in the order they were, one row each: items, two uint32_t — kind (0 short edge, 1 collapsed edge, 2 sliver face, 3 tiny face, 4 tiny body, 5 small hole), index (as in cadaclysm_blacksmith_health_small, of the input); sizes, two double — its size, the furthest a vertex it merged moved. Returns the count; with both buffers null it writes nothing, so call it twice: once to size the buffers, once to fill them. A non-null buffer must hold the whole count. Zero (and last_error) on a null h.
cadaclysm_blacksmith_heal_refused
uint32_t cadaclysm_blacksmith_heal_refused(const struct CadaclysmBlacksmithHeal *h,
uint32_t *items,
double *sizes);
The small features left, one row each: items, three uint32_t — kind (as in cadaclysm_blacksmith_heal_fixes), index, why (0 would empty its loop, 1 closed, 2 seam, 3 chain wider than the tolerance, 4 a sliver's neighbours part, 5 uneven sliver sides, 6 non-manifold, 7 has holes, 8 the body guard, 9 toggled off by flags, 10 unsupported); sizes, one double — the why's figure (a chain's width, the neighbours' gap, else 0). Returns the count, with the two-call convention of cadaclysm_blacksmith_heal_fixes.
Recognition
cadaclysm_blacksmith_recognized
struct CadaclysmBlacksmithRecognize *cadaclysm_blacksmith_recognized(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
Give the solid's free-form surfaces and edge curves their analytic kind: a NURBS (or revolved, extruded or swept) surface that is a plane, cylinder, cone, sphere or torus within tolerance of every sample of its faces and every point of their edges becomes exactly that, and an edge curve that is a line, circle or ellipse within it likewise, over the same stretch run the same way. Faces and edges keep their numbers. solid is left as it was; the new solid keeps its name and colours. NaN or tolerance <= 0 takes the default, 1e-6 times the body's extent — not the file's declared tolerance, at which a fillet's blend reads as a torus; the summary's sizes[0] says what was used.
A report handle, read with the cadaclysm_blacksmith_recognize_* accessors and freed with cadaclysm_blacksmith_recognize_free; null (and last_error) on a null solid.
cadaclysm_blacksmith_recognize_body
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_recognize_body(const struct CadaclysmBlacksmithRecognize *r);
The recognised solid: a new solid the caller frees with cadaclysm_blacksmith_solid_free, each call a solid of its own (sharing the body, not copying it). It outlives the report. Null (and last_error) on a null r.
cadaclysm_blacksmith_recognize_free
void cadaclysm_blacksmith_recognize_free(struct CadaclysmBlacksmithRecognize *r);
Free a report. Null is a no-op. A solid taken with cadaclysm_blacksmith_recognize_body stays good.
cadaclysm_blacksmith_recognize_summary
bool cadaclysm_blacksmith_recognize_summary(const struct CadaclysmBlacksmithRecognize *r,
uint32_t *counts,
double *sizes);
The report's figures. counts, ten uint32_t, in order: faces taken as planes, cylinders, cones, spheres, tori; faces left free-form; edges taken as lines, circles, ellipses; edges left free-form. sizes, three double: the tolerance used, the worst face deviation, the worst edge deviation (0 where none was taken). Either output may be null; not both. false (and last_error) on a null r or both outputs null.
cadaclysm_blacksmith_recognize_faces
uint32_t cadaclysm_blacksmith_recognize_faces(const struct CadaclysmBlacksmithRecognize *r,
uint32_t *items,
double *sizes);
The faces taken, one row each: items, two uint32_t — the face's index (unchanged by recognition), its kind (0 plane, 1 cylinder, 2 cone, 3 sphere, 4 torus); sizes, one double — the furthest any sample of it lies from the analytic surface. Returns the count; with both buffers null it writes nothing, so call it twice: once to size the buffers, once to fill them. A non-null buffer must hold the whole count. Zero (and last_error) on a null r.
cadaclysm_blacksmith_recognize_refused
uint32_t cadaclysm_blacksmith_recognize_refused(const struct CadaclysmBlacksmithRecognize *r,
uint32_t *items,
double *sizes);
The free-form faces left, one row each: items, two uint32_t — the face's index, why (0 no kind fits within the tolerance, 1 its normals point both ways, 2 a parameter trim cannot be lifted, 3 too few samples); sizes, one double — for "no kind", the closest kind's deviation, else NaN. Returns the count, with the two-call convention of cadaclysm_blacksmith_recognize_faces.
cadaclysm_blacksmith_recognize_edges
uint32_t cadaclysm_blacksmith_recognize_edges(const struct CadaclysmBlacksmithRecognize *r,
uint32_t *items,
double *sizes);
The edges whose curve was taken, one row each, in edge order: items, two uint32_t — the brep edge id (as cadaclysm_blacksmith_edge_tolerance takes one), its kind (0 line, 1 circle, 2 ellipse); sizes, one double — the furthest any point of the curve or its edges lies from the analytic curve. Returns the count, with the two-call convention of cadaclysm_blacksmith_recognize_faces.
Draft
cadaclysm_blacksmith_draft
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_draft(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *faces,
size_t count,
const double *plane,
double angle,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid with the count faces at faces drafted to angle (radians) against the pull direction plane's z, about the neutral plane through plane's origin square to it (plane a frame, twelve doubles, as cadaclysm_blacksmith_split_by_plane takes): each face's new draft angle, absolute, in (-pi/2, pi/2). A plane turns about the line where it crosses the neutral plane, which stays fixed; a cylinder along the pull becomes the cone through the circle it cuts in the neutral plane (a cone along the pull the same from its own circle there), narrowing towards +z for an outer wall drafted positive and widening for a hole. The faces beside a drafted one follow it: every vertex moves onto the drafted faces and the planes it lay on, a vertex in the neutral plane not at all. The faces keep their order, their colours and their marks.
Null and last_error (starting draft: ) for no faces, a face the solid does not have or named twice, an angle not finite or not inside (-pi/2, pi/2), a neutral plane with no direction, a solid a reader made whose faces cannot be built again, a face parallel to the neutral plane, a cylinder or cone across the pull, a sphere, torus or free-form face, a curved face beside a drafted one that is not drafted with it, a hole through a drafted plane, a drafted plane and a drafted cylinder meeting at a sharp edge, a face that turns inside out or collapses at the angle asked, and a result that does not close.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance). progress is accepted for the shape of the other verbs; a draft reports nothing yet.
cadaclysm_blacksmith_draft_two_sided
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_draft_two_sided(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *faces,
size_t count,
const double *plane,
double above,
double below,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
solid with the count faces at faces drafted both ways from the neutral plane through plane's origin square to its z (a frame, twelve doubles) — a parting line: above it (along +z) to above against +z, below it to below against -z, so for positive angles both halves narrow away from the plane. above == below is a symmetric draft. A face wholly on one side is drafted as cadaclysm_blacksmith_draft drafts it; otherwise the solid is split by the plane, each side drafted and the halves joined back, the faces the plane cut in two made one again. The faces come back in the join's order; each keeps its colour and marks, a drafted half its face's.
Null and last_error (starting draft: ) for what cadaclysm_blacksmith_draft refuses, and a split that gives no piece on one side of the plane.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_draft_angle_at
bool cadaclysm_blacksmith_draft_angle_at(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *point,
const double *pull,
struct CadaclysmBlacksmithDraftPoint *out);
The point of face face of solid nearest point (3 doubles) and the draft angle there against pull (3 doubles, normalised here), into out — Rhino's DraftAnglePoint. A point on the face's boundary reads the face's own normal there, not the mean of the faces meeting. false and last_error (starting draft_angle_at: ), out untouched, for a null solid, point, pull or out, a face out of range, a point not finite, or a pull zero or not finite.
cadaclysm_blacksmith_draft_analysis
struct CadaclysmBlacksmithDraftAnalysis *cadaclysm_blacksmith_draft_analysis(const struct CadaclysmBlacksmithSolid *solid,
const double *pull,
double threshold,
double tolerance);
Every face of solid's draft against pull (3 doubles, normalised here), one row per face in face order (Fusion's draft analysis): the body meshed at tolerance, each triangle's angle read exactly at its centre and its area banded by threshold (radians, in [0, pi/2); Fusion's default is 1 degree), a triangle drafting either way casting a ray along the way it releases — one that meets the body is undercut. Null and last_error (starting draft_analysis: ) for a null solid or pull, a pull zero or not finite, a threshold out of range, a tolerance negative or infinite, and a body with no faces.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_draft_analysis_count
uint32_t cadaclysm_blacksmith_draft_analysis_count(const struct CadaclysmBlacksmithDraftAnalysis *analysis);
How many faces. 0 (and last_error) for null.
cadaclysm_blacksmith_draft_analysis_face
bool cadaclysm_blacksmith_draft_analysis_face(const struct CadaclysmBlacksmithDraftAnalysis *analysis,
uint32_t i,
struct CadaclysmBlacksmithFaceDraft *out);
Face row i into out. false (and last_error) for a null analysis, a null out, or i out of range; out is untouched then.
cadaclysm_blacksmith_draft_analysis_free
void cadaclysm_blacksmith_draft_analysis_free(struct CadaclysmBlacksmithDraftAnalysis *analysis);
Release a draft analysis. Null is a no-op.
Sheet metal and unroll
cadaclysm_blacksmith_sheet_rule_default
bool cadaclysm_blacksmith_sheet_rule_default(double thickness,
struct CadaclysmBlacksmithSheetRule *out);
The default rule for sheet thickness thick into out: bend radius the thickness, K-factor 0.44, rectangular bend reliefs, round corner reliefs, every size from the thickness. false and last_error (starting sheet_rule_default: ), out untouched, for a null out and a thickness not positive and finite.
cadaclysm_blacksmith_sheet_base
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_base(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
The base flange: profile as a flat sheet under frame (twelve doubles), its top in the frame's plane, the sheet below it. Null and last_error (starting sheet_base: ) for a null input, a bad rule (a code out of range, a length negative) and a profile that does not extrude.
cadaclysm_blacksmith_sheet_contour
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_contour(const double *path,
size_t point_count,
const double *frame,
double width,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
A contour flange: the open path of point_count points at path (x, y pairs in frame's plane: the sheet seen from its side), width deep along the frame's z, each corner a bend of the rule's radius. Null and last_error (starting sheet_contour: ) for fewer than two points, a segment too short for its bends and a bad rule.
cadaclysm_blacksmith_sheet_lofted_flange
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_lofted_flange(const double *a,
size_t a_count,
const double *b,
size_t b_count,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
A lofted flange between two open polylines: a_count points at a and b_count at b (x, y, z triples, at least two each), the sheet's top face. The strip between them is cut into facets (neighbours in one plane merged) and every crease is a bend of the rule's radius, so the part unfolds like any other; an arc is sampled by the caller, one facet per chord. The sheet lies under the facets' normal, along a x towards b (reverse both profiles to put it on the other side). Null and last_error (starting sheet_lofted_flange: ) for fewer than two points, a repeated point, a facet with no area, a facet its bends' set-backs leave nothing of, and a bad rule.
cadaclysm_blacksmith_sheet_flange
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_flange(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double angle,
double length,
const double *offsets,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
Edge flanges on the count edges at edges (indices into the list cadaclysm_blacksmith_edge walks: edges of a broad face of a sheet body), each turned angle (> 0 up, towards the side the edge's face looks) and length high outside. offsets null for flanges the full length of their edges, else two doubles: how far in each flange starts from its edge's two ends (bend reliefs are cut). Two flanges meeting at a corner are mitred with the rule's gap. Null and last_error (starting sheet_flange: ) for no edges, an edge that is not on a broad face's rim, a solid that is not sheet metal, an angle not in (0, 1.75 pi] either way, and a length shorter than the bend.
cadaclysm_blacksmith_sheet_hem
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_hem(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
uint32_t kind,
double length,
double gap,
double angle,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
Hems on the count edges at edges: kind one of CADACLYSM_BLACKSMITH_HEM_*, length the lip (flat, open, teardrop, double), gap the gap inside (0: the thickness; a rope hem's rod), angle a rolled hem's turn (0: 1.5 pi). Null and last_error (starting sheet_hem: ) for a kind out of range and what cadaclysm_blacksmith_sheet_flange refuses.
cadaclysm_blacksmith_sheet_fold
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_fold(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *line,
double angle,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
A bend on the line through two points (line, six doubles) across flat broad face face of a sheet body: the material on the line's left (seen from the face's outside) turned angle. Null and last_error (starting sheet_fold: ) for a face that is not a flat broad face, a line that does not cross it, a fold through another bend and a fold that collides with the part.
cadaclysm_blacksmith_sheet_rip
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_rip(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double gap,
double tolerance);
Rips along the count edges at edges (sharp edges between two walls of a shelled solid): a slot gap wide (0: a tenth of the shell's thickness) through the wall, so cadaclysm_blacksmith_sheet_convert can lay it flat. Null and last_error (starting sheet_rip: ) for an edge that is not sharp between two flat faces of constant thickness.
cadaclysm_blacksmith_sheet_convert
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_convert(const struct CadaclysmBlacksmithSolid *solid,
uint32_t fixed_face,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
A shelled solid of constant thickness made sheet metal from face fixed_face: every sharp edge between two flat broad faces a bend of the rule's radius, the outside kept. Null and last_error (starting sheet_convert: ) for a solid not of one thickness, a closed loop of walls that needs a rip, and a rule thickness not the solid's.
cadaclysm_blacksmith_sheet_corner_relief
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_corner_relief(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
The rule's corner relief cut at every corner where two bend zones end close together. Null and last_error (starting sheet_corner_relief: ) for a solid that is not sheet metal.
cadaclysm_blacksmith_sheet_rip_points
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_rip_points(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *points,
double gap,
double tolerance);
A rip between two points (points, six doubles) on flat broad face face: a slot gap wide (0: a tenth of the thickness) through that wall only. An end on the face's outline breaks through it; an end inside the face stops there. Null and last_error (starting sheet_rip_points: ) for a face that is not a flat broad face and a point off it.
cadaclysm_blacksmith_sheet_rip_face
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_rip_face(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double tolerance);
The wall under broad face face (flat or a bend) removed through the thickness. Null and last_error (starting sheet_rip_face: ) for a face that is not a broad face and a rip that leaves nothing.
cadaclysm_blacksmith_sheet_join
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_join(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge_a,
uint32_t edge_b,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
Two walls joined by a bend of the rule's radius: edge_a and edge_b are outline edges where each wall's broad face meets its square end, parallel and of one extent. Each wall runs on to the other's far face and the corner gets the bend, the outer mould line kept; walls in one plane are joined flat. Null and last_error (starting sheet_join: ) for edges that are not wall ends, not parallel or of different extent, and walls that overlap or lie parallel in two planes.
cadaclysm_blacksmith_sheet_fillet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_fillet(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double radius,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
Rounds of radius on the count thickness edges at edges (across the sheet at a corner of its outline, on a flat region): each corner of the flat pattern rounded (cut on a convex corner, filled on a concave one) and the part folded again. Null and last_error (starting sheet_fillet: ) for an edge that is not a thickness edge and a round that runs past the sides beside it.
cadaclysm_blacksmith_sheet_chamfer
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sheet_chamfer(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *edges,
size_t count,
double distance,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
Chamfers distance along both sides on the count thickness edges at edges: see cadaclysm_blacksmith_sheet_fillet. Null and last_error (starting sheet_chamfer: ).
cadaclysm_blacksmith_is_sheet_metal
bool cadaclysm_blacksmith_is_sheet_metal(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
Whether solid is sheet metal: two broad sides of constant thickness, flat faces and cylindrical bends, side faces one thickness wide. false for null.
cadaclysm_blacksmith_sheet_bend_faces
int32_t cadaclysm_blacksmith_sheet_bend_faces(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
uint32_t *out);
The faces of every bend of a sheet body (two a bend, inner and outer) into out. Returns how many, or -1 (and last_error, starting sheet_bend_faces: , out untouched) for a null input or a solid that is not sheet metal.
cadaclysm_blacksmith_sheet_info
bool cadaclysm_blacksmith_sheet_info(const struct CadaclysmBlacksmithSolid *solid,
uint32_t fixed_face,
double tolerance,
struct CadaclysmBlacksmithSheetInfo *out);
solid read as sheet metal from fixed_face (CADACLYSM_BLACKSMITH_NONE: its largest flat broad face) into out. false and last_error (starting sheet_info: ), out untouched, for a null input and a solid that is not sheet metal.
cadaclysm_blacksmith_sheet_bends
int32_t cadaclysm_blacksmith_sheet_bends(const struct CadaclysmBlacksmithSolid *solid,
uint32_t fixed_face,
double tolerance,
struct CadaclysmBlacksmithBendInfo *out);
Every bend of solid read from fixed_face (as cadaclysm_blacksmith_sheet_info) into out. Returns how many, or -1 (and last_error, starting sheet_bends: , out untouched) for what sheet_info refuses.
cadaclysm_blacksmith_flat_pattern
struct CadaclysmBlacksmithFlatPattern *cadaclysm_blacksmith_flat_pattern(const struct CadaclysmBlacksmithSolid *solid,
uint32_t fixed_face,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
solid unfolded from flat broad face fixed_face under rule: every bend laid flat at its allowance. Null and last_error (starting flat_pattern: ) for a solid that is not sheet metal, a face that is not a flat broad face, a rule whose thickness is not the solid's, and a flat that overlaps itself.
cadaclysm_blacksmith_flat_pattern_body
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_flat_pattern_body(const struct CadaclysmBlacksmithFlatPattern *fp);
The flat body: the outline extruded the thickness down from the frame. A new solid; null (and last_error) for null.
cadaclysm_blacksmith_flat_pattern_profile
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_flat_pattern_profile(const struct CadaclysmBlacksmithFlatPattern *fp);
The flat's outline, in the frame's plane. A new profile; null (and last_error) for null.
cadaclysm_blacksmith_flat_pattern_frame
bool cadaclysm_blacksmith_flat_pattern_frame(const struct CadaclysmBlacksmithFlatPattern *fp,
double *out);
The flat's frame (twelve doubles: origin, x, y, z) into out; the sheet lies below its plane. false (and last_error) for a null input.
cadaclysm_blacksmith_flat_pattern_bend_count
uint32_t cadaclysm_blacksmith_flat_pattern_bend_count(const struct CadaclysmBlacksmithFlatPattern *fp);
How many bend zones the flat pattern draws. 0 (and last_error) for null.
cadaclysm_blacksmith_flat_pattern_bend
bool cadaclysm_blacksmith_flat_pattern_bend(const struct CadaclysmBlacksmithFlatPattern *fp,
uint32_t i,
struct CadaclysmBlacksmithFlatBend *out);
Bend zone i into out. false (and last_error, out untouched) for a null input or i out of range.
cadaclysm_blacksmith_flat_pattern_fold_bend_count
uint32_t cadaclysm_blacksmith_flat_pattern_fold_bend_count(const struct CadaclysmBlacksmithFlatPattern *fp);
How many bends the part has, as cadaclysm_blacksmith_fold_flat takes them (a bend cut in two by a hole is one bend and two zones). 0 (and last_error) for null.
cadaclysm_blacksmith_flat_pattern_fold_bend
bool cadaclysm_blacksmith_flat_pattern_fold_bend(const struct CadaclysmBlacksmithFlatPattern *fp,
uint32_t i,
struct CadaclysmBlacksmithBend *out);
The part's bend i into out. false (and last_error, out untouched) for a null input or i out of range.
cadaclysm_blacksmith_flat_pattern_dxf
char *cadaclysm_blacksmith_flat_pattern_dxf(const struct CadaclysmBlacksmithFlatPattern *fp,
uint32_t units,
uint32_t flags);
The flat pattern alone on a page in units (as cadaclysm_blacksmith_page_new), as DXF R2000 text: what cadaclysm_blacksmith_page_add_flat_pattern draws at the origin. Free with cadaclysm_blacksmith_string_free. Null (and last_error, starting flat_pattern_dxf: ) for a null input, units unknown and flags out of range.
cadaclysm_blacksmith_flat_pattern_free
void cadaclysm_blacksmith_flat_pattern_free(struct CadaclysmBlacksmithFlatPattern *fp);
Release a flat pattern. Null is a no-op.
cadaclysm_blacksmith_fold_flat
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_fold_flat(const struct CadaclysmBlacksmithProfile *profile,
const double *frame,
const struct CadaclysmBlacksmithBend *bends,
size_t count,
const struct CadaclysmBlacksmithSheetRule *rule,
double tolerance);
A flat outline folded: profile under frame (twelve doubles), each of the count bends at bends a bend, under rule — a flat pattern edited and folded again. Null and last_error (starting fold_flat: ) for a bend line that does not cross the outline, two bends that cross or overlap, and a fold that collides with itself.
cadaclysm_blacksmith_page_add_flat_pattern
int32_t cadaclysm_blacksmith_page_add_flat_pattern(struct CadaclysmBlacksmithPage *page,
const struct CadaclysmBlacksmithFlatPattern *fp,
double x,
double y,
uint32_t flags);
The flat pattern drawn on page at (x, y), 1:1: its outline on layer OUTLINE, each bend line on BEND_UP (green) or BEND_DOWN (red) in the centre linetype; flags (CADACLYSM_BLACKSMITH_FLAT_*) add the zones' edges on BEND_EXTENT, a ruled table of the bends under the outline on BEND_TABLE, a label on each bend line, a bend note under each on BEND_NOTE, the overall width and height dimensioned on DIMENSION, and the folded part's front view (looking along the flat frame's y, its z up) right of the flat on FOLDED and FOLDED_HIDDEN. Returns how many entities were added, or -1 (and last_error, starting page_add_flat_pattern: ) for a null input, a position not finite and flags out of range.
cadaclysm_blacksmith_unroll
struct CadaclysmBlacksmithUnrolled *cadaclysm_blacksmith_unroll(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *faces,
size_t face_count,
const struct CadaclysmBlacksmithNurbsCurve *const *curves,
size_t curve_count,
const double *points,
size_t point_count,
bool explode,
double tolerance);
The face_count faces at faces of solid (none: all) laid flat in the xy plane — Rhino's Unroller. Planes, cylinders and cones unroll exactly; any other surface whose curvature vanishes within tolerance by its own flattening. Faces sharing an edge stay joined unless joined they would overlap (or explode), the largest face placed first; the edges between faces laid apart are reported cut. The curve_count curves at curves follow onto the flat (pieces where they cross a cut), the point_count points at points (x, y, z triples) to their spots. A face that is not developable is left out and reported. Null and last_error (starting unroll: ) for a face out of range and no developable face.
cadaclysm_blacksmith_unrolled_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_unrolled_sheet(const struct CadaclysmBlacksmithUnrolled *u);
The flat sheet: an open shell in the xy plane. A new solid; null (and last_error) for null.
cadaclysm_blacksmith_unrolled_face_count
uint32_t cadaclysm_blacksmith_unrolled_face_count(const struct CadaclysmBlacksmithUnrolled *u);
How many faces the sheet has. 0 (and last_error) for null.
cadaclysm_blacksmith_unrolled_faces
bool cadaclysm_blacksmith_unrolled_faces(const struct CadaclysmBlacksmithUnrolled *u,
uint32_t *out);
The source face of each sheet face, in the sheet's face order, into out. false (and last_error) for a null input.
cadaclysm_blacksmith_unrolled_curve_piece_count
uint32_t cadaclysm_blacksmith_unrolled_curve_piece_count(const struct CadaclysmBlacksmithUnrolled *u,
uint32_t curve);
How many pieces curve curve (in the order given to unroll) came out in: 0 where it missed every face. 0 (and last_error) for a null input or a curve out of range.
cadaclysm_blacksmith_unrolled_curve_piece
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_unrolled_curve_piece(const struct CadaclysmBlacksmithUnrolled *u,
uint32_t curve,
uint32_t piece);
Piece piece of curve curve on the flat. A new curve; null (and last_error) for a null input or an index out of range.
cadaclysm_blacksmith_unrolled_point
int32_t cadaclysm_blacksmith_unrolled_point(const struct CadaclysmBlacksmithUnrolled *u,
uint32_t i,
double *out);
Point i (in the order given to unroll) on the flat, into out (three doubles). Returns 1 where it landed, 0 where it is on no face laid flat (out untouched), -1 (and last_error) for a null input or i out of range.
cadaclysm_blacksmith_unrolled_not_developable_count
uint32_t cadaclysm_blacksmith_unrolled_not_developable_count(const struct CadaclysmBlacksmithUnrolled *u);
How many of the faces asked for are not developable (left out). 0 (and last_error) for null.
cadaclysm_blacksmith_unrolled_not_developable
bool cadaclysm_blacksmith_unrolled_not_developable(const struct CadaclysmBlacksmithUnrolled *u,
uint32_t *out);
The faces not developable, into out. false (and last_error) for a null input.
cadaclysm_blacksmith_unrolled_cut_count
uint32_t cadaclysm_blacksmith_unrolled_cut_count(const struct CadaclysmBlacksmithUnrolled *u);
How many shared edges were cut (their two faces laid apart). 0 (and last_error) for null.
cadaclysm_blacksmith_unrolled_cuts
bool cadaclysm_blacksmith_unrolled_cuts(const struct CadaclysmBlacksmithUnrolled *u,
uint32_t *out);
The cuts as pairs of source faces, into out (two uint32_ts a cut). false (and last_error) for a null input.
cadaclysm_blacksmith_unrolled_free
void cadaclysm_blacksmith_unrolled_free(struct CadaclysmBlacksmithUnrolled *u);
Release an unrolled result. Null is a no-op.
cadaclysm_blacksmith_squish
struct CadaclysmBlacksmithSquished *cadaclysm_blacksmith_squish(const struct CadaclysmBlacksmithSolid *solid,
const uint32_t *faces,
size_t face_count,
const struct CadaclysmBlacksmithNurbsCurve *const *curves,
size_t curve_count,
const double *points,
size_t point_count,
bool explode,
uint32_t deformation,
bool preserve_boundary,
double tolerance);
The face_count faces at faces of solid (none: all) laid flat in the xy plane with the least distortion — Rhino's Squisher. Faces sharing an edge flatten together (unless explode); a group of faces that are all developable is laid exactly as unroll lays it. deformation one of CADACLYSM_BLACKSMITH_SQUISH_*; preserve_boundary keeps the outline's length. The curve_count curves at curves follow onto the flat (pieces where they leave the faces), the point_count points at points (x, y, z triples) to their spots. Null and last_error (starting squish: ) for a face out of range, a bad deformation, and faces that close on themselves (no boundary to open from).
cadaclysm_blacksmith_squished_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_squished_sheet(const struct CadaclysmBlacksmithSquished *q);
The flat sheet: an open shell in the xy plane. A new solid; null (and last_error) for null.
cadaclysm_blacksmith_squished_face_count
uint32_t cadaclysm_blacksmith_squished_face_count(const struct CadaclysmBlacksmithSquished *q);
How many faces the sheet has. 0 (and last_error) for null.
cadaclysm_blacksmith_squished_faces
bool cadaclysm_blacksmith_squished_faces(const struct CadaclysmBlacksmithSquished *q,
uint32_t *out);
The source face of each sheet face, in the sheet's face order, into out. false (and last_error) for a null input.
cadaclysm_blacksmith_squished_distortion
bool cadaclysm_blacksmith_squished_distortion(const struct CadaclysmBlacksmithSquished *q,
double *out);
Each sheet face's distortion, in the sheet's face order, into out: six doubles a face — the flat over 3D area per mesh triangle (min, max, mean weighted by area), then the flat over 3D length per mesh edge (min, max, mean weighted by length). false (and last_error) for a null input.
cadaclysm_blacksmith_squished_exact_count
uint32_t cadaclysm_blacksmith_squished_exact_count(const struct CadaclysmBlacksmithSquished *q);
How many source faces were laid exactly (their group all developable). 0 (and last_error) for null.
cadaclysm_blacksmith_squished_exact
bool cadaclysm_blacksmith_squished_exact(const struct CadaclysmBlacksmithSquished *q,
uint32_t *out);
The source faces laid exactly, into out. false (and last_error) for a null input.
cadaclysm_blacksmith_squished_curve_piece_count
uint32_t cadaclysm_blacksmith_squished_curve_piece_count(const struct CadaclysmBlacksmithSquished *q,
uint32_t curve);
How many pieces curve curve (in the order given to squish) came out in: 0 where it missed every face. 0 (and last_error) for a null input or a curve out of range.
cadaclysm_blacksmith_squished_curve_piece
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_squished_curve_piece(const struct CadaclysmBlacksmithSquished *q,
uint32_t curve,
uint32_t piece);
Piece piece of curve curve on the flat. A new curve; null (and last_error) for a null input or an index out of range.
cadaclysm_blacksmith_squished_point
int32_t cadaclysm_blacksmith_squished_point(const struct CadaclysmBlacksmithSquished *q,
uint32_t i,
double *out);
Point i (in the order given to squish) on the flat, into out (three doubles). Returns 1 where it landed, 0 where it is on no squished face (out untouched), -1 (and last_error) for a null input or i out of range.
cadaclysm_blacksmith_squished_free
void cadaclysm_blacksmith_squished_free(struct CadaclysmBlacksmithSquished *q);
Release a squished result. Null is a no-op.
From files
cadaclysm_blacksmith_from_mesh
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_from_mesh(const double *positions,
uint32_t vertex_count,
const uint32_t *indices,
uint32_t triangle_count,
double weld_tolerance,
double angle_tolerance,
double distance_tolerance,
bool merge_planes,
uint32_t *report);
The mesh of positions (vertex_count vertices, 3 doubles each) and indices (triangle_count triangles, 3 vertex indices each) made a B-rep solid. Points within weld_tolerance are welded into one vertex and degenerate triangles dropped; the triangles are then oriented consistently with their neighbours, and each closed component turned outward (a component inside another inward, as a void).
* merge_planes false (level 1, faceted): one planar face per triangle, one edge per unique triangle edge. * merge_planes true (level 2, merged planes): coplanar neighbouring triangles — each normal within angle_tolerance (radians) of its region's, each vertex within distance_tolerance of its plane — become one planar face bounded by their outline (inner loops for holes), and collinear outline points are dropped, so a straight run is one line edge: a CAD box's mesh comes back as 6 faces and 12 edges. Curved regions stay faceted.
A tolerance of 0 or NaN is its default: weld_tolerance 1e-6 x the bounding-box diagonal, angle_tolerance 1 degree, distance_tolerance 1e-5 x the diagonal. A weld_tolerance given is what the solid declares as its absolute tolerance.
cadaclysm_blacksmith_brep_layout_id
const char *cadaclysm_blacksmith_brep_layout_id(void);
This library's brep layout: the compiler, target, profile and source it was built from, as one string. Equal to the reader library's cadaclysm_brep_layout_id() exactly when the two can share a brep. Static; never freed.
cadaclysm_blacksmith_from_brep
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_from_brep(const void *brep,
const char *layout_id);
A solid over an imported body's exact brep, shared with the reader, not copied: brep is what the reader library's cadaclysm_node_brep returned, layout_id what its cadaclysm_brep_layout_id returns.
The solid takes a reference of its own; the caller's is still the caller's, to give back with cadaclysm_brep_release whether this succeeded or not. The scene the brep came from may be closed before or after the solid is freed — the brep lives until the last holder lets go of it.
Also refused: a null brep or layout_id, and a brep with no faces. What a solid from a file can then do depends on its geometry: fillet and chamfer want line and circle edges; booleans take any surface, but the new edges they trace on a free-form (NURBS) face are not always writable back to STEP; and every verb meshes its operands at its tolerance first, so its cost scales with the body's face count.
Collision
cadaclysm_blacksmith_collider_clash
struct CadaclysmBlacksmithClashes *cadaclysm_blacksmith_collider_clash(struct CadaclysmBlacksmithCollider *collider,
const double *frames,
uint32_t frame_count,
double clearance,
uint32_t share_k,
uint32_t share_n);
Every pair of collider's parts that penetrates, touches or lies within clearance of the other with each group placed at its frame in frames (12 doubles a frame, frame_count of them, in group order), in pair order. clearance is zero or more; a pair farther apart than the collider's tolerance but within it is "too_close", within the tolerance "touching". share_n 0: every pair is decided now; otherwise only those whose index is share_k modulo share_n. Frames are read as cadaclysm_blacksmith_collider_check reads them (a float32 pose within 1e-6 of rigid is squared up). Null (and last_error) for a null collider, a null frames with a frame_count, frame_count not the collider's group count, a bad frame, share_k >= share_n when share_n is not 0, or a clearance that is negative or not finite. The collider keeps each measured part's closest mesh for its lifetime.
cadaclysm_blacksmith_clash
struct CadaclysmBlacksmithClashes *cadaclysm_blacksmith_clash(const struct CadaclysmBlacksmithSolid *const *a,
uint32_t a_count,
const struct CadaclysmBlacksmithSolid *const *b,
uint32_t b_count,
double tolerance,
double clearance,
const uint32_t *allowed,
uint32_t allowed_count);
The pairs of solids that penetrate, touch or lie within clearance of one another, at rest, meshed at tolerance (positive and finite, or unset): a (a_count solids) against itself when b is null with b_count 0, else against b (b_count solids; only pairs across the two, and a row's b indexes b). allowed is allowed_count pairs of indices (2 * allowed_count numbers, flat; an a index then a b index for two sets) never tested — designed contacts. Null (and last_error) for a null a or b with a count, a null solid in either, an empty set, an allowed pair out of range, a part that is not a closed solid, a bad tolerance, or a clearance that is negative or not finite.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_clashes_free
void cadaclysm_blacksmith_clashes_free(struct CadaclysmBlacksmithClashes *clashes);
Release a clashes handle. Null is a no-op.
cadaclysm_blacksmith_clashes_count
uint32_t cadaclysm_blacksmith_clashes_count(const struct CadaclysmBlacksmithClashes *clashes);
How many pairs. 0 (and last_error) for null.
cadaclysm_blacksmith_clashes_at
bool cadaclysm_blacksmith_clashes_at(const struct CadaclysmBlacksmithClashes *clashes,
uint32_t i,
struct CadaclysmBlacksmithClash *out);
Pair i into out; its strings borrow from the handle. false (and last_error) for null clashes, a null out, or i out of range; out is untouched then.
cadaclysm_blacksmith_clashes_solid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_clashes_solid(const struct CadaclysmBlacksmithClashes *clashes,
uint32_t i);
The volume pair i's two parts share, at the frames it was found at, as a new solid. Null (and last_error) for a null clashes, i out of range, or a pair that is not "penetrating".
cadaclysm_blacksmith_clashes_intersect
struct CadaclysmBlacksmithIntersection *cadaclysm_blacksmith_clashes_intersect(const struct CadaclysmBlacksmithClashes *clashes,
uint32_t i);
Where pair i's two parts cross or coincide, at the frames it was found at and the list's tolerance: the chains and overlap regions cadaclysm_blacksmith_intersect reports, read with the cadaclysm_blacksmith_intersection_* calls and freed with cadaclysm_blacksmith_intersection_free. Any pair but a refused one has one (a touching pair of boxes face to face has the shared face as an overlap region). Null (and last_error) for a null clashes, i out of range, or a refused pair.
cadaclysm_blacksmith_collider_swept_clash
struct CadaclysmBlacksmithSweptClashes *cadaclysm_blacksmith_collider_swept_clash(struct CadaclysmBlacksmithCollider *collider,
const double *poses,
uint32_t pose_count,
uint32_t frame_count,
double clearance,
double resolution,
uint32_t max_steps,
uint32_t share_k,
uint32_t share_n);
Every pair of collider's parts that penetrates, touches or comes within clearance anywhere on the path through poses, with the first time it does and the time ranges it stays in clash, in pair order. poses is pose_count poses (at least 2) of frame_count frames each (one per group, in group order), 12 doubles a frame, read as cadaclysm_blacksmith_collider_check reads them. resolution (in (0, 1], a fraction of a segment; 1e-3 is the usual) is how closely an interval's end is found; max_steps (at least 1; 100000 is the usual) the pose-wise tests one pair may take — a pair that needs more is a refused row. share_n 0: every pair; otherwise only the pairs whose swept boxes meet numbered share_k modulo share_n. Null (and last_error) for a null collider, a null poses with a count, fewer than 2 poses, frame_count not the collider's group count, a bad frame, a clearance that is negative or not finite, a resolution outside (0, 1], max_steps 0, or share_k >= share_n when share_n is not 0. The collider's pose caches are neither read nor filled.
cadaclysm_blacksmith_swept_clash
struct CadaclysmBlacksmithSweptClashes *cadaclysm_blacksmith_swept_clash(const struct CadaclysmBlacksmithSolid *const *a,
uint32_t a_count,
const double *poses_a,
const struct CadaclysmBlacksmithSolid *const *b,
uint32_t b_count,
const double *poses_b,
uint32_t pose_count,
double tolerance,
double clearance,
double resolution,
uint32_t max_steps,
const uint32_t *allowed,
uint32_t allowed_count);
The pairs of solids that penetrate, touch or come within clearance of one another anywhere on a path of pose_count poses (at least 2), meshed at tolerance (positive and finite, or unset), each part its own group: a (a_count solids) against itself when b is null with b_count 0, else against b (b_count solids; only pairs across the two, and a row's b indexes b). poses_a is pose_count poses of a_count frames (12 doubles a frame, pose by pose), placing a's parts; poses_b likewise pose_count poses of b_count frames, null with b. allowed is allowed_count pairs of indices (2 * allowed_count numbers, flat; an a index then a b index for two sets) never tested. resolution and max_steps as cadaclysm_blacksmith_collider_swept_clash. Null (and last_error) for a null a, b, poses_a, poses_b or allowed with a count, a null solid in either set, an empty set, fewer than 2 poses, an allowed pair out of range, a part that is not a closed solid, a bad frame, tolerance, clearance or resolution, or max_steps 0.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_swept_clashes_free
void cadaclysm_blacksmith_swept_clashes_free(struct CadaclysmBlacksmithSweptClashes *swept);
Release a swept clashes handle. Null is a no-op.
cadaclysm_blacksmith_swept_clashes_count
uint32_t cadaclysm_blacksmith_swept_clashes_count(const struct CadaclysmBlacksmithSweptClashes *swept);
How many pairs. 0 (and last_error) for null.
cadaclysm_blacksmith_swept_clashes_at
bool cadaclysm_blacksmith_swept_clashes_at(const struct CadaclysmBlacksmithSweptClashes *swept,
uint32_t i,
struct CadaclysmBlacksmithSweptClash *out);
Pair i into out. false (and last_error) for null swept, a null out, or i out of range; out is untouched then.
cadaclysm_blacksmith_swept_clashes_interval
bool cadaclysm_blacksmith_swept_clashes_interval(const struct CadaclysmBlacksmithSweptClashes *swept,
uint32_t i,
uint32_t k,
double *out);
Interval k of pair i into out[0] (its start) and out[1] (its end), in pose units. false (and last_error) for null swept, a null out, i or k out of range; out is untouched then.
cadaclysm_blacksmith_swept_clashes_firsts
struct CadaclysmBlacksmithClashes *cadaclysm_blacksmith_swept_clashes_firsts(const struct CadaclysmBlacksmithSweptClashes *swept);
The first rows as a new clashes list, one row per pair in the same order: row i is pair i's pose-wise clash at its first time (kind, distance, points, features, depth, text), at the frames the motion places the parts there, so cadaclysm_blacksmith_clashes_solid and cadaclysm_blacksmith_clashes_intersect rebuild the contact at that time. Every cadaclysm_blacksmith_clashes_* call works on it; free it with cadaclysm_blacksmith_clashes_free, independently of swept. Null (and last_error) for null swept.
cadaclysm_blacksmith_solid_bounds_box
bool cadaclysm_blacksmith_solid_bounds_box(const struct CadaclysmBlacksmithSolid *solid,
double tolerance,
struct CadaclysmBlacksmithBox *out);
solid's box at tolerance: its boolean mesh, padded by twice that. false (and last_error) for a null solid, a null out, a tolerance negative or infinite, or a solid that meshes to nothing.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_box_moved
bool cadaclysm_blacksmith_box_moved(const struct CadaclysmBlacksmithBox *box_,
const double *frame,
struct CadaclysmBlacksmithBox *out);
box moved by frame (12 doubles: origin, x, y, z), boxed again on the world axes. false (and last_error) for a null box, a null frame, a null out, or a frame that is not 12 finite numbers or not rigid.
cadaclysm_blacksmith_box_overlaps
bool cadaclysm_blacksmith_box_overlaps(const struct CadaclysmBlacksmithBox *a,
const struct CadaclysmBlacksmithBox *b);
Whether the two boxes share a point (touching counts). false for a null a or b too (with last_error set), not just for boxes that do not overlap — check last_error to tell the two apart.
cadaclysm_blacksmith_boxes_apart
bool cadaclysm_blacksmith_boxes_apart(const struct CadaclysmBlacksmithBox *a,
const double *frame_a,
const struct CadaclysmBlacksmithBox *b,
const double *frame_b,
bool *apart);
True only if box a at frame_a and box b at frame_b cannot touch — a separating axis among the boxes' face normals and edge-direction crosses; touching is not apart. false (and last_error) for a null a, b, frame_a, frame_b or apart, or a frame that is not 12 finite numbers or not rigid.
cadaclysm_blacksmith_collider_new
struct CadaclysmBlacksmithCollider *cadaclysm_blacksmith_collider_new(const struct CadaclysmBlacksmithSolid *const *solids,
uint32_t count,
double tolerance,
const uint32_t *groups,
const uint32_t *allowed,
uint32_t allowed_count);
solids, count of them, at rest, meshed at tolerance; groups (count entries, or null for each part its own group); allowed (2 * allowed_count part indices, pairs never tested — designed contacts). Null (and last_error) for a null solids, a null entry in it, count zero, or the kernel's own refusal (a tolerance negative or infinite, groups the wrong length, an allowed pair out of range, or a part that is not a closed solid).
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_collider_free
void cadaclysm_blacksmith_collider_free(struct CadaclysmBlacksmithCollider *collider);
Release a collider. Null is a no-op.
cadaclysm_blacksmith_collider_group_count
uint32_t cadaclysm_blacksmith_collider_group_count(const struct CadaclysmBlacksmithCollider *collider);
How many groups collider has. 0 (and last_error) for null.
cadaclysm_blacksmith_collider_stats
bool cadaclysm_blacksmith_collider_stats(const struct CadaclysmBlacksmithCollider *collider,
struct CadaclysmBlacksmithColliderStats *out);
Counts of the last cadaclysm_blacksmith_collider_check (all zero before the first call, and for a null collider or out).
cadaclysm_blacksmith_collider_check
struct CadaclysmBlacksmithCollisions *cadaclysm_blacksmith_collider_check(struct CadaclysmBlacksmithCollider *collider,
const double *frames,
uint32_t frame_count,
uint32_t share_k,
uint32_t share_n);
The pairs that interfere, or could not be decided, with each group placed at its frame in frames (12 doubles a frame, frame_count of them, in group order). share_n 0: every pair past the box filters is decided now; otherwise only those whose index is share_k modulo share_n (the shares of one pose are disjoint and cover it). Null (and last_error) for a null collider, a null frames, frame_count not the collider's own group count, a frame that is not 12 finite numbers or not rigid, or share_k >= share_n when share_n is not 0. A frame whose axes are within 1e-6 of unit length and of square (a float32 pose) is squared up first (Gram-Schmidt: x normalised, y made square to x, z = x cross y, keeping its handedness); one further off, or mirrored, is refused.
cadaclysm_blacksmith_collisions_free
void cadaclysm_blacksmith_collisions_free(struct CadaclysmBlacksmithCollisions *collisions);
Release a collisions handle. Null is a no-op.
cadaclysm_blacksmith_collisions_count
uint32_t cadaclysm_blacksmith_collisions_count(const struct CadaclysmBlacksmithCollisions *collisions);
How many collisions. 0 (and last_error) for null.
cadaclysm_blacksmith_collisions_hit
bool cadaclysm_blacksmith_collisions_hit(const struct CadaclysmBlacksmithCollisions *collisions,
uint32_t i,
struct CadaclysmBlacksmithCollisionHit *out);
Collision i into out. false (and last_error) for null collisions, a null out, or i out of range.
cadaclysm_blacksmith_collisions_solid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_collisions_solid(const struct CadaclysmBlacksmithCollisions *collisions,
uint32_t i);
The exact overlap of collision i's two parts at the frames it was found at, as a new solid. Null (and last_error) for a null collisions, i out of range, or a collision that was refused (not an overlap).
Wall thickness
cadaclysm_blacksmith_thickness_gauge_new
struct CadaclysmBlacksmithThicknessGauge *cadaclysm_blacksmith_thickness_gauge_new(const struct CadaclysmBlacksmithSolid *const *solids,
uint32_t count,
double tolerance);
The count solids measured against each other, meshed at tolerance (positive and finite, or unset). Null (and last_error) for a null solids, a null solid in it, or a bad tolerance. solids must not be null, even with count 0 (pass any non-null pointer for an empty gauge).
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_thickness_gauge_free
void cadaclysm_blacksmith_thickness_gauge_free(struct CadaclysmBlacksmithThicknessGauge *gauge);
Release a thickness gauge. Null is a no-op.
cadaclysm_blacksmith_thickness_gauge_body_count
uint32_t cadaclysm_blacksmith_thickness_gauge_body_count(const struct CadaclysmBlacksmithThicknessGauge *gauge);
How many bodies the gauge measures. 0 (and last_error) for null.
cadaclysm_blacksmith_thickness_gauge_tolerance
double cadaclysm_blacksmith_thickness_gauge_tolerance(const struct CadaclysmBlacksmithThicknessGauge *gauge);
The tolerance the gauge meshed its bodies at. NaN (and last_error) for null.
cadaclysm_blacksmith_thickness_gauge_mesh
bool cadaclysm_blacksmith_thickness_gauge_mesh(const struct CadaclysmBlacksmithThicknessGauge *gauge,
uint32_t body,
struct CadaclysmBlacksmithThicknessMesh *out);
Body body's measuring mesh into out, borrowed from the gauge. false (and last_error) for a null gauge or out, or a body past the end; out is untouched then.
cadaclysm_blacksmith_thickness_gauge_measure
struct CadaclysmBlacksmithThicknesses *cadaclysm_blacksmith_thickness_gauge_measure(const struct CadaclysmBlacksmithThicknessGauge *gauge,
double maximum,
double sharp_angle);
One reading per measuring-mesh vertex that has one within maximum (positive and finite), by body then vertex; vertices whose interior angle is under sharp_angle radians (zero or more, finite) are knife edges. Null (and last_error) for a null gauge or a bad limit.
cadaclysm_blacksmith_thickness_gauge_at
struct CadaclysmBlacksmithThicknesses *cadaclysm_blacksmith_thickness_gauge_at(const struct CadaclysmBlacksmithThicknessGauge *gauge,
uint32_t body,
uint32_t face,
const double *point,
double maximum,
double sharp_angle);
The reading at point's foot on face face of body body (three doubles): a list of one row, its vertex CADACLYSM_BLACKSMITH_NONE, or of none where the foot lies off the face or the wall is thicker than maximum. Null (and last_error) for a null gauge or point, a body or face past the end, a point that is not finite, or a bad limit.
cadaclysm_blacksmith_thickness_gauge_face
bool cadaclysm_blacksmith_thickness_gauge_face(const struct CadaclysmBlacksmithThicknessGauge *gauge,
uint32_t body,
uint32_t face,
const double *at,
double maximum,
struct CadaclysmBlacksmithFaceThickness *out);
One thickness for face face of body body into out: measured at at's foot on the face (at three doubles) or, with at null, over the face's vertices; the other bodies are measured with it. found false where nothing reads under maximum. false (and last_error) for a null gauge or out, a body or face past the end, an at that is not finite, or a bad maximum; out is untouched then.
cadaclysm_blacksmith_thicknesses_free
void cadaclysm_blacksmith_thicknesses_free(struct CadaclysmBlacksmithThicknesses *list);
Release a thicknesses list. Null is a no-op.
cadaclysm_blacksmith_thicknesses_count
uint32_t cadaclysm_blacksmith_thicknesses_count(const struct CadaclysmBlacksmithThicknesses *list);
How many readings. 0 (and last_error) for null.
cadaclysm_blacksmith_thicknesses_at
bool cadaclysm_blacksmith_thicknesses_at(const struct CadaclysmBlacksmithThicknesses *list,
uint32_t i,
struct CadaclysmBlacksmithThickness *out);
Reading i into out. false (and last_error) for a null list or out, or i out of range; out is untouched then.
cadaclysm_blacksmith_mesh_thickness
struct CadaclysmBlacksmithMeshThicknesses *cadaclysm_blacksmith_mesh_thickness(const double *positions,
const uint32_t *vertex_counts,
const uint32_t *indices,
const uint32_t *triangle_counts,
uint32_t mesh_count,
double maximum,
double sharp_angle);
The nearest-opposing-wall rule on mesh_count meshes laid end to end, measured against each other: mesh m's vertices are the next vertex_counts[m] triples of positions, its triangles the next triangle_counts[m] triples of indices, indexing its own vertices. One reading per vertex that has one within maximum (positive and finite), by mesh then vertex; sharp_angle (radians, zero or more) as _thickness_gauge_measure. Null (and last_error) for a null array with a count, a triangle past its mesh, a position that is not finite, or a bad limit.
cadaclysm_blacksmith_mesh_thicknesses_free
void cadaclysm_blacksmith_mesh_thicknesses_free(struct CadaclysmBlacksmithMeshThicknesses *list);
Release a mesh thicknesses list. Null is a no-op.
cadaclysm_blacksmith_mesh_thicknesses_count
uint32_t cadaclysm_blacksmith_mesh_thicknesses_count(const struct CadaclysmBlacksmithMeshThicknesses *list);
How many readings. 0 (and last_error) for null.
cadaclysm_blacksmith_mesh_thicknesses_at
bool cadaclysm_blacksmith_mesh_thicknesses_at(const struct CadaclysmBlacksmithMeshThicknesses *list,
uint32_t i,
struct CadaclysmBlacksmithMeshThickness *out);
Reading i into out. false (and last_error) for a null list or out, or i out of range; out is untouched then.
Spatial index
cadaclysm_blacksmith_rtree_new
struct CadaclysmBlacksmithRTree *cadaclysm_blacksmith_rtree_new(void);
An empty tree. Never null.
cadaclysm_blacksmith_rtree_from_boxes
struct CadaclysmBlacksmithRTree *cadaclysm_blacksmith_rtree_from_boxes(const uint32_t *ids,
const double *boxes,
uint32_t n);
A tree over n entries at once, packed (sort-tile-recursive): fuller and faster to build than the same entries inserted one by one. Entry i is ids[i] with the box boxes[6 i..6 i + 6]. n = 0 (the pointers may then be null) is an empty tree.
Null and last_error for a null ids or boxes with n above 0, and the first entry whose box is not a box, by index.
cadaclysm_blacksmith_rtree_from_points
struct CadaclysmBlacksmithRTree *cadaclysm_blacksmith_rtree_from_points(const double *xyz,
uint32_t n);
A tree over n points (xyz, 3 doubles each), each a zero box whose id is its index. n = 0 (xyz may then be null) is an empty tree.
Null and last_error for a null xyz with n above 0, and the first point with a NaN or infinite coordinate, by index.
cadaclysm_blacksmith_rtree_from_triangles
struct CadaclysmBlacksmithRTree *cadaclysm_blacksmith_rtree_from_triangles(const double *xyz,
uint32_t n_points,
const uint32_t *indices,
uint32_t n_triangles);
A tree over a mesh's n_triangles triangles, indices 3 a triangle into the n_points points xyz (3 doubles each): one entry per triangle, its id the triangle's index, its box its three corners' box. n_triangles = 0 (the pointers may then be null) is an empty tree.
Null and last_error for a null xyz with n_points above 0 or a null indices with n_triangles above 0, then the first corner past the points ("rtree_from_triangles: triangle 1 names point 9 of 4") or at a point with a NaN or infinite coordinate, by triangle and point. Points no triangle uses are not checked.
cadaclysm_blacksmith_solid_face_tree
struct CadaclysmBlacksmithRTree *cadaclysm_blacksmith_solid_face_tree(const struct CadaclysmBlacksmithSolid *solid);
A tree over solid's faces: one entry per face, its id the face index the other face calls use, its box holding the face (the box the boolean's broad phase pairs faces by, grown by a thousandth of the solid's extent). A solid with no faces gives an empty tree.
Null and last_error for a null solid, or a face that cannot be boxed.
cadaclysm_blacksmith_rtree_insert
bool cadaclysm_blacksmith_rtree_insert(struct CadaclysmBlacksmithRTree *tree,
uint32_t id,
const double *box_);
Add the entry (id, box). false and last_error for a null tree or box, or a box that is not a box; the tree is then left as it was.
cadaclysm_blacksmith_rtree_insert_point
bool cadaclysm_blacksmith_rtree_insert_point(struct CadaclysmBlacksmithRTree *tree,
uint32_t id,
const double *p);
Add the entry (id, p), the point as a zero box. false and last_error for a null tree or point, or a point with a NaN or infinite coordinate.
cadaclysm_blacksmith_rtree_remove
bool cadaclysm_blacksmith_rtree_remove(struct CadaclysmBlacksmithRTree *tree,
uint32_t id,
const double *box_);
Take out one entry equal to (id, box) — the box it was inserted with, compared per coordinate (a point's is its zero box) — and say whether there was one. With duplicates, one goes per call.
false with no error when there is no such entry; false and last_error for a null tree or box, or a box that is not a box.
cadaclysm_blacksmith_rtree_count
uint32_t cadaclysm_blacksmith_rtree_count(const struct CadaclysmBlacksmithRTree *tree);
How many entries tree holds. 0 (and last_error) for null.
cadaclysm_blacksmith_rtree_bounds
bool cadaclysm_blacksmith_rtree_bounds(const struct CadaclysmBlacksmithRTree *tree,
double *out);
The union of every entry's box into out (6 doubles). false and last_error for a null tree or out, and for an empty tree, which has no bounds.
cadaclysm_blacksmith_rtree_free
void cadaclysm_blacksmith_rtree_free(struct CadaclysmBlacksmithRTree *tree);
Release a tree. Null is a no-op.
cadaclysm_blacksmith_rtree_search
struct CadaclysmBlacksmithRTreeHits *cadaclysm_blacksmith_rtree_search(const struct CadaclysmBlacksmithRTree *tree,
const double *box_);
The ids of every entry whose box meets box (touching counts), ascending, each with distance 0. Null and last_error for a null tree or box, or a box that is not a box.
cadaclysm_blacksmith_rtree_within
struct CadaclysmBlacksmithRTreeHits *cadaclysm_blacksmith_rtree_within(const struct CadaclysmBlacksmithRTree *tree,
const double *p,
double r);
Every entry whose box is within r of p (Euclidean, 0 inside the box; r = 0 finds the boxes holding p), by distance then id. Null and last_error for a null tree or point, a point with a NaN or infinite coordinate, and a negative or NaN r.
cadaclysm_blacksmith_rtree_nearest
struct CadaclysmBlacksmithRTreeHits *cadaclysm_blacksmith_rtree_nearest(const struct CadaclysmBlacksmithRTree *tree,
const double *p,
uint32_t k);
The k entries whose boxes are nearest p, by distance then id (at equal distance the smaller ids win): all of them when k is over the count, none for k = 0. Null and last_error for a null tree or point, a point with a NaN or infinite coordinate, and k above 1 000 000.
cadaclysm_blacksmith_rtree_ray
struct CadaclysmBlacksmithRTreeHits *cadaclysm_blacksmith_rtree_ray(const struct CadaclysmBlacksmithRTree *tree,
const double *origin,
const double *direction,
double max_t);
Every entry whose box the ray origin + t direction, 0 <= t <= max_t, meets, as hits whose distance is the t where the ray enters the box (0 when origin is inside it), by t then id. Touching counts: a ray grazing a face or an edge meets the box. t is in units of direction's length (it is not normalised); max_t may be INFINITY.
Null and last_error for a null tree, origin or direction, an origin or direction with a NaN or infinite coordinate, a zero direction ("rtree_ray: direction (0, 0, 0) is not a direction"), and a NaN or negative max_t ("rtree_ray: max_t -1 is not a distance").
cadaclysm_blacksmith_rtree_hits_count
uint32_t cadaclysm_blacksmith_rtree_hits_count(const struct CadaclysmBlacksmithRTreeHits *hits);
How many hits. 0 (and last_error) for null.
cadaclysm_blacksmith_rtree_hits_at
bool cadaclysm_blacksmith_rtree_hits_at(const struct CadaclysmBlacksmithRTreeHits *hits,
uint32_t i,
struct CadaclysmBlacksmithRTreeHit *out);
Hit i into out. false (and last_error) for a null hits, a null out, or i not below the count.
cadaclysm_blacksmith_rtree_hits_free
void cadaclysm_blacksmith_rtree_hits_free(struct CadaclysmBlacksmithRTreeHits *hits);
Release a hits list. Null is a no-op.
cadaclysm_blacksmith_rtree_overlaps
struct CadaclysmBlacksmithRTreePairs *cadaclysm_blacksmith_rtree_overlaps(const struct CadaclysmBlacksmithRTree *a,
const struct CadaclysmBlacksmithRTree *b,
double slack);
Every pair (a, b) of an entry of a and one of b whose boxes are at most slack apart on every axis — they meet once each is grown by slack / 2 on every side, so slack = 0 is touching — ascending. a and b may be the same tree. Null and last_error for a null tree and a negative or NaN slack.
cadaclysm_blacksmith_rtree_self_overlaps
struct CadaclysmBlacksmithRTreePairs *cadaclysm_blacksmith_rtree_self_overlaps(const struct CadaclysmBlacksmithRTree *tree,
double slack);
Every unordered pair of distinct entries of tree at most slack apart (as cadaclysm_blacksmith_rtree_overlaps), once each as (smaller id, larger id), ascending; an id pairs with itself only where two entries share it. Null and last_error for a null tree and a negative or NaN slack.
cadaclysm_blacksmith_rtree_pairs_count
uint32_t cadaclysm_blacksmith_rtree_pairs_count(const struct CadaclysmBlacksmithRTreePairs *pairs);
How many pairs. 0 (and last_error) for null.
cadaclysm_blacksmith_rtree_pairs_at
bool cadaclysm_blacksmith_rtree_pairs_at(const struct CadaclysmBlacksmithRTreePairs *pairs,
uint32_t i,
struct CadaclysmBlacksmithRTreePair *out);
Pair i into out. false (and last_error) for a null pairs, a null out, or i not below the count.
cadaclysm_blacksmith_rtree_pairs_free
void cadaclysm_blacksmith_rtree_pairs_free(struct CadaclysmBlacksmithRTreePairs *pairs);
Release a pairs list. Null is a no-op.
Triangle meshes
cadaclysm_blacksmith_triangle_mesh_new
struct CadaclysmBlacksmithTriangleMesh *cadaclysm_blacksmith_triangle_mesh_new(const double *positions,
uint32_t vertex_count,
const uint32_t *indices,
uint32_t triangle_count);
The mesh of positions (vertex_count vertices, 3 doubles each) and indices (triangle_count triangles, 3 vertex indices each, any winding); both are copied. Null (and last_error, prefixed triangle_mesh_new: ) for a null array behind a non-zero count, no triangles, an index past the vertex count, or a coordinate that is not finite.
cadaclysm_blacksmith_solid_triangle_mesh
struct CadaclysmBlacksmithTriangleMesh *cadaclysm_blacksmith_solid_triangle_mesh(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
The triangle mesh of solid that the measuring queries search: its measuring tessellation, within a third of tolerance of the surface — finer than the display mesh cadaclysm_blacksmith_mesh gives at the same tolerance. The answers against it are exact for the mesh, not for the body. Null (and last_error, prefixed solid_triangle_mesh: ) for a null solid, a tolerance that is negative or infinite, or a body that meshes to nothing.
tolerance 0 or NaN: the solid's effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_triangle_mesh_free
void cadaclysm_blacksmith_triangle_mesh_free(struct CadaclysmBlacksmithTriangleMesh *mesh);
Release a triangle mesh. Null is a no-op.
cadaclysm_blacksmith_triangle_mesh_vertex_count
uint32_t cadaclysm_blacksmith_triangle_mesh_vertex_count(const struct CadaclysmBlacksmithTriangleMesh *mesh);
How many vertices the mesh holds; 0 for a null mesh.
cadaclysm_blacksmith_triangle_mesh_triangle_count
uint32_t cadaclysm_blacksmith_triangle_mesh_triangle_count(const struct CadaclysmBlacksmithTriangleMesh *mesh);
How many triangles the mesh holds; 0 for a null mesh.
cadaclysm_blacksmith_triangle_mesh_bounds
bool cadaclysm_blacksmith_triangle_mesh_bounds(const struct CadaclysmBlacksmithTriangleMesh *mesh,
double *out);
The box of every vertex, into out as min x, min y, min z, max x, max y, max z. False (and last_error, out untouched) for a null mesh or out.
cadaclysm_blacksmith_triangle_mesh_closest_point
int32_t cadaclysm_blacksmith_triangle_mesh_closest_point(const struct CadaclysmBlacksmithTriangleMesh *mesh,
const double *p,
double max_distance,
struct CadaclysmBlacksmithMeshPoint *out);
The nearest point of the mesh to p (3 doubles), into out — see CadaclysmBlacksmithMeshPoint: exact, the lower triangle where several share the point, its unused vertices slots UINT32_MAX. Returns 1 with out filled; 0, out untouched, where the nearest point is beyond max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null mesh, p or out, a point that is not finite, or a negative max_distance.
max_distance NaN or +inf is no limit. Only a nearest point *beyond* it answers 0: one a rounding error past it is not beyond, so max_distance 0 finds a point that lies on the mesh.
cadaclysm_blacksmith_triangle_mesh_curve_closest_points
int32_t cadaclysm_blacksmith_triangle_mesh_curve_closest_points(const struct CadaclysmBlacksmithTriangleMesh *mesh,
const struct CadaclysmBlacksmithNurbsCurve *curve,
double max_distance,
struct CadaclysmBlacksmithCurveMeshFoot *out);
The nearest points of curve and the mesh, into out — see CadaclysmBlacksmithCurveMeshFoot: exact, crossing 1 and distance 0 at the earliest crossing in t, the lower triangle and then the lower t among equal distances. Returns 1 with out filled; 0, out untouched, where the mesh is farther than max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null mesh, curve or out, a curve that is not valid, or a negative max_distance.
max_distance NaN or +inf is no limit; only a distance *beyond* it answers 0.
NURBS surfaces
cadaclysm_blacksmith_nurbs_surface_new
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_new(const double *points,
uint32_t n_u,
uint32_t n_v,
uint32_t degree_u,
uint32_t degree_v,
const double *weights,
const double *knots_u,
uint32_t n_knots_u,
const double *knots_v,
uint32_t n_knots_v);
The surface of the control net points (n_u rows of n_v points, three doubles each: row i, point j at 3 * (i * n_v + j); rows run along u), of degrees degree_u and degree_v (1 to 7 each), with weights (n_u * n_v, positive and finite; NULL for a plain B-spline) and the full knot vectors knots_u (n_knots_u = n_u + degree_u + 1 values, finite, non-decreasing and clamped: the first and the last degree_u + 1 equal) and knots_v likewise (NULL for clamped and uniform over [0, 1]; the count is then not read). Everything is copied. Null (and last_error, prefixed nurbs_surface_new: ) for a null points behind a non-zero count, a degree out of range, too few points for a degree, a point that is not finite, a bad weight, knots of the wrong count, decreasing, not clamped or leaving no domain, counts too large to address, or a surface the queries cannot search.
cadaclysm_blacksmith_solid_face_surface
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_solid_face_surface(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face);
The surface of face face (its row in the solid's face table) of solid, its trims ignored, as an exact NURBS: a NURBS face as it is (clamped if it came unclamped); a cylinder, cone, sphere or torus in its exact rational form over a parameter range that covers the face (never smaller, but for a rare holed tube face); a plane as the bilinear patch over the rectangle its trims span. (u, v) are the NURBS's own parameters. Null (and last_error, prefixed solid_face_surface: ) for a null solid, a face out of range, a face with no exact NURBS form, and a surface the queries cannot search.
cadaclysm_blacksmith_nurbs_surface_free
void cadaclysm_blacksmith_nurbs_surface_free(struct CadaclysmBlacksmithNurbsSurface *surface);
Release a surface. Null is a no-op.
cadaclysm_blacksmith_nurbs_surface_degrees
bool cadaclysm_blacksmith_nurbs_surface_degrees(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t *out);
The degrees, into out as degree_u, degree_v. False (and last_error, out untouched) for a null surface or out.
cadaclysm_blacksmith_nurbs_surface_counts
bool cadaclysm_blacksmith_nurbs_surface_counts(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t *out);
The control-point counts, into out as n_u, n_v. False (and last_error, out untouched) for a null surface or out.
cadaclysm_blacksmith_nurbs_surface_domain
bool cadaclysm_blacksmith_nurbs_surface_domain(const struct CadaclysmBlacksmithNurbsSurface *surface,
double *out);
The parameter domain, into out as u0, u1, v0, v1. False (and last_error, out untouched) for a null surface or out.
cadaclysm_blacksmith_nurbs_surface_point_at
bool cadaclysm_blacksmith_nurbs_surface_point_at(const struct CadaclysmBlacksmithNurbsSurface *surface,
double u,
double v,
double *out);
The point at (u, v), into out (3 doubles). False (and last_error, prefixed nurbs_surface_point_at: , out untouched) for a null surface or out, or a parameter outside the domain or not finite.
cadaclysm_blacksmith_nurbs_surface_normal_at
bool cadaclysm_blacksmith_nurbs_surface_normal_at(const struct CadaclysmBlacksmithNurbsSurface *surface,
double u,
double v,
double *out);
The unit normal at (u, v) (dS/du x dS/dv, normalised), into out (3 doubles). False (and last_error, prefixed nurbs_surface_normal_at: , out untouched) for a null surface or out, a parameter outside the domain or not finite, or a place where the partials are parallel (a pole) — exactly where a closest point's normal is zero.
cadaclysm_blacksmith_nurbs_surface_to_sheet
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_nurbs_surface_to_sheet(const struct CadaclysmBlacksmithNurbsSurface *surface);
The whole surface as an open one-face sheet. The sheet's face is the same surface reparametrised over [0, 1] x [0, 1]: its face surface (cadaclysm_blacksmith_solid_face_surface) has domain [0, 1]^2, not this one's. Null (and last_error, prefixed nurbs_surface_to_sheet: ) for a null surface or one the sheet cannot be built from (a side that is not a curve, or no size).
cadaclysm_blacksmith_nurbs_surface_closest_point
int32_t cadaclysm_blacksmith_nurbs_surface_closest_point(const struct CadaclysmBlacksmithNurbsSurface *surface,
const double *p,
double max_distance,
struct CadaclysmBlacksmithSurfacePoint *out);
The nearest point of the surface to p (3 doubles), into out — see CadaclysmBlacksmithSurfacePoint: exact, the lower u and then the lower v among equal distances. Returns 1 with out filled; 0, out untouched, where the nearest point is beyond max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null surface, p or out, a point that is not finite, or a negative max_distance.
max_distance NaN or +inf is no limit. Only a nearest point *beyond* it answers 0: one a rounding error past it is not beyond, so max_distance 0 finds a point that lies on the surface.
cadaclysm_blacksmith_nurbs_surface_curve_closest_points
int32_t cadaclysm_blacksmith_nurbs_surface_curve_closest_points(const struct CadaclysmBlacksmithNurbsSurface *surface,
const struct CadaclysmBlacksmithNurbsCurve *curve,
double max_distance,
struct CadaclysmBlacksmithCurveSurfaceFoot *out);
The nearest points of curve and the surface, into out — see CadaclysmBlacksmithCurveSurfaceFoot: exact, crossing 1 and distance 0 at the earliest crossing in t, the lower u, v and then t among equal distances. Returns 1 with out filled; 0, out untouched, where the surface is farther than max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null surface, curve or out, a curve that is not valid, or a negative max_distance.
max_distance NaN or +inf is no limit; only a distance *beyond* it answers 0.
cadaclysm_blacksmith_nurbs_surface_control_points
bool cadaclysm_blacksmith_nurbs_surface_control_points(const struct CadaclysmBlacksmithNurbsSurface *surface,
double *xyz);
The control points into xyz (3 * n_u * n_v doubles, row i along u, point j at 3 * (i * n_v + j), as cadaclysm_blacksmith_nurbs_surface_new takes them). False and last_error for a null surface or xyz.
cadaclysm_blacksmith_nurbs_surface_weights
bool cadaclysm_blacksmith_nurbs_surface_weights(const struct CadaclysmBlacksmithNurbsSurface *surface,
double *w);
The weights into w (n_u * n_v doubles, the control points' order; all 1 for a plain B-spline). False and last_error for a null surface or w.
cadaclysm_blacksmith_nurbs_surface_knots
bool cadaclysm_blacksmith_nurbs_surface_knots(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t dir,
double *k);
The full knot vector along dir (0 u, 1 v) into k: n_u + degree_u + 1 doubles for u, n_v + degree_v + 1 for v. False and last_error for a null surface or k, or another direction.
cadaclysm_blacksmith_nurbs_surface_elevated
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_elevated(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t dir,
uint32_t by);
The same surface raised by degrees along dir (0 u, 1 v; to at most 12) — exactly (Rhino's IncreaseDegreeU/V). Null and last_error (prefixed nurbs_surface_elevated: ) otherwise.
cadaclysm_blacksmith_nurbs_surface_knot_inserted
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_knot_inserted(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t dir,
double t,
uint32_t times);
The knot t inserted times times along dir (0 u, 1 v) — the same surface, exactly. Null and last_error (prefixed nurbs_surface_knot_inserted: ) for a t not strictly inside the domain, a times of 0, or a multiplicity past the degree.
cadaclysm_blacksmith_nurbs_surface_knots_refined
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_knots_refined(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t dir,
const double *knots,
uint32_t count);
All count knots of knots (non-decreasing, each strictly inside the domain, no multiplicity past the degree) inserted along dir — the same surface, exactly. Null and last_error (prefixed nurbs_surface_knots_refined: ) otherwise.
cadaclysm_blacksmith_nurbs_surface_knot_removed
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_knot_removed(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t dir,
double t,
uint32_t times,
double tolerance,
uint32_t *removed);
Up to times copies of the inner knot t along dir removed, each only while every row of the net stays within tolerance (an absolute length; 0 or NaN the net's effective tolerance) of itself; how many went is written to removed (when not NULL) — 0, and an unchanged copy, where none could. Null and last_error (prefixed nurbs_surface_knot_removed: ) for a t that is not an inner knot and a negative or infinite tolerance.
cadaclysm_blacksmith_nurbs_surface_offset
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_offset(const struct CadaclysmBlacksmithNurbsSurface *surface,
double distance,
double tolerance,
double *error_out);
The surface moved distance along its normal (Rhino's Surface.Offset), refitted within tolerance: a plane offsets exactly (error 0). Null and last_error (prefixed nurbs_surface_offset: ) for a distance that is not finite, a surface with no normal somewhere, or an offset that folds over (a curvature radius used up). The fit's bound on the distance from the exact offset goes to error_out when that is not NULL.
tolerance 0 or NaN: the effective tolerance.
cadaclysm_blacksmith_nurbs_surface_extended
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_extended(const struct CadaclysmBlacksmithNurbsSurface *surface,
uint32_t side,
double length);
The surface continued length past one side (0 the u start, 1 the u end, 2 the v start, 3 the v end; Rhino's Surface.Extend) along its own end polynomials — curvature-continuous, every old (u, v) keeping its point, the domain grown on that side. Null and last_error (prefixed nurbs_surface_extended: ) for another side or a length that is not positive and finite.
cadaclysm_blacksmith_nurbs_surface_second_derivatives
bool cadaclysm_blacksmith_nurbs_surface_second_derivatives(const struct CadaclysmBlacksmithNurbsSurface *surface,
double u,
double v,
double *out);
The point and its partial derivatives to second order at (u, v) into out (18 doubles: S, dS/du, dS/dv, d2S/du2, d2S/dudv, d2S/dv2, three each; Rhino's Surface.Evaluate to order 2). False and last_error (prefixed nurbs_surface_second_derivatives: ) for a null surface or out, or a parameter outside the domain or not finite.
cadaclysm_blacksmith_nurbs_surface_curvature
bool cadaclysm_blacksmith_nurbs_surface_curvature(const struct CadaclysmBlacksmithNurbsSurface *surface,
double u,
double v,
struct CadaclysmBlacksmithSurfaceCurvature *out);
The principal, Gaussian and mean curvatures and the principal directions at (u, v) into out (Rhino's Surface.CurvatureAt), from the first and second fundamental forms. False and last_error (prefixed nurbs_surface_curvature: ) for a null surface or out, a parameter outside the domain or not finite, and a place with no normal (a pole).
cadaclysm_blacksmith_nurbs_surface_hermite
struct CadaclysmBlacksmithNurbsSurface *cadaclysm_blacksmith_nurbs_surface_hermite(const double *u,
uint32_t n_u,
const double *v,
uint32_t n_v,
const double *points,
const double *du,
const double *dv,
const double *twists);
The bicubic Hermite surface through an n_u x n_v grid (Rhino's HermiteSurface): u (n_u >= 2) and v (n_v >= 2) the grid's parameters, strictly rising; points, du, dv and twists (each 3 * n_u * n_v doubles, node (i, j) at 3 * (i * n_v + j)) its points, derivatives dS/du and dS/dv, and twists d2S/dudv. Each grid cell is the bicubic Hermite patch of its corners; the surface is cubic both ways with a double knot at every inner grid parameter (C1 across), 2 n_u x 2 n_v control points, over the grid's parameters, through every point with the given derivatives. Null and last_error (prefixed nurbs_surface_hermite: ) for a grid under 2 x 2, parameters not strictly rising, null lists and numbers not finite.
Regions
cadaclysm_blacksmith_merge
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_merge(const struct CadaclysmBlacksmithSolid *a,
const struct CadaclysmBlacksmithSolid *b,
double tolerance,
CadaclysmBlacksmithProgress progress,
void *user);
a and b merged into one solid that keeps every piece: the regions of the result are a less b, a and b together, and b less a (those that are not empty), and the walls between them are faces of both. Faces keep the colours of the faces they are pieces of.
Built exactly, so both solids must be closed and every face a plane, cylinder, cone, sphere or torus; walls of the two that lie on one another in part are a case it refuses. Null and last_error (merge: ...) for those, a null solid, and a tolerance negative or infinite. progress is called as cadaclysm_blacksmith_join calls it.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_regions
struct CadaclysmBlacksmithRegions *cadaclysm_blacksmith_regions(const struct CadaclysmBlacksmithSolid *solid);
The regions of space solid's faces bound, region 0 the infinite one: two for an ordinary solid (outside, inside), one per cell for a merge's. Null and last_error (regions: ...) for a null solid and a body whose regions cannot be read.
cadaclysm_blacksmith_regions_count
uint32_t cadaclysm_blacksmith_regions_count(const struct CadaclysmBlacksmithRegions *regions);
How many regions. 0 (and last_error) for null.
cadaclysm_blacksmith_regions_at
bool cadaclysm_blacksmith_regions_at(const struct CadaclysmBlacksmithRegions *regions,
uint32_t i,
struct CadaclysmBlacksmithRegion *out);
Region i into out. false (and last_error) for a null regions, a null out, or i not below the count.
cadaclysm_blacksmith_regions_side_at
bool cadaclysm_blacksmith_regions_side_at(const struct CadaclysmBlacksmithRegions *regions,
uint32_t i,
uint32_t k,
struct CadaclysmBlacksmithFaceSide *out);
Side k of region i into out, the sides ascending by face then sense (-1 first). false (and last_error) for a null regions, a null out, i not below the count, or k not below the region's sides.
cadaclysm_blacksmith_regions_free
void cadaclysm_blacksmith_regions_free(struct CadaclysmBlacksmithRegions *regions);
Release a regions list. Null is a no-op.
cadaclysm_blacksmith_region_solid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_region_solid(const struct CadaclysmBlacksmithSolid *solid,
uint32_t region);
Finite region region of solid (an index into cadaclysm_blacksmith_regions' list) as a closed solid of its own: the faces bounding it, each turned to point out of it, each keeping its colour. A merge's cells come out one at a time this way, ready for the mass and the booleans. Null and last_error for a null solid, region 0 (region_solid: region 0 is the infinite region) and a region past the count.
Interpolation
cadaclysm_blacksmith_interpolator_new
struct CadaclysmBlacksmithInterpolator *cadaclysm_blacksmith_interpolator_new(const double *samples,
uint32_t count,
uint32_t dimension,
bool cyclic);
An interpolator over count samples of dimension doubles each (samples holds count · dimension doubles, sample k at k · dimension); cyclic wraps t round the list, otherwise it is clamped to the first and last samples.
Null and last_error for no samples (count 0), a dimension of 0, a null samples with count above 0, and a sample with a NaN or infinite number, by its index.
cadaclysm_blacksmith_interpolator_count
uint32_t cadaclysm_blacksmith_interpolator_count(const struct CadaclysmBlacksmithInterpolator *interpolator);
How many samples. 0 (and last_error) for null.
cadaclysm_blacksmith_interpolator_dimension
uint32_t cadaclysm_blacksmith_interpolator_dimension(const struct CadaclysmBlacksmithInterpolator *interpolator);
How many doubles per sample. 0 (and last_error) for null.
cadaclysm_blacksmith_interpolator_cyclic
bool cadaclysm_blacksmith_interpolator_cyclic(const struct CadaclysmBlacksmithInterpolator *interpolator);
Whether t wraps round the list. false (and last_error) for null.
cadaclysm_blacksmith_interpolator_at
bool cadaclysm_blacksmith_interpolator_at(const struct CadaclysmBlacksmithInterpolator *interpolator,
double t,
uint32_t mode,
double *out,
uint32_t out_len);
The value at the fractional index t by mode into out, dimension doubles.
false and last_error, with out untouched, for a null interpolator or out, an out_len under the dimension, a t that is NaN or infinite, and a mode that is not one of the five.
cadaclysm_blacksmith_interpolator_sample
bool cadaclysm_blacksmith_interpolator_sample(const struct CadaclysmBlacksmithInterpolator *interpolator,
const double *ts,
uint32_t n,
uint32_t mode,
double *out,
uint32_t out_len);
The values at the n fractional indices ts by mode into out, flat: value k at k · dimension, n · dimension doubles. n = 0 writes nothing (ts and out may then be null).
false and last_error, with out untouched, for a null interpolator, ts or out, an out_len under n · dimension, a value of t that is NaN or infinite (by its index), a mode that is not one of the five, and n above 1 000 000.
cadaclysm_blacksmith_interpolator_free
void cadaclysm_blacksmith_interpolator_free(struct CadaclysmBlacksmithInterpolator *interpolator);
Release an interpolator. Null is a no-op.
Animation
cadaclysm_blacksmith_animation_new
struct CadaclysmBlacksmithAnimation *cadaclysm_blacksmith_animation_new(void);
An animation with no tracks. Null (and last_error) only if the library panicked making it.
cadaclysm_blacksmith_animation_clone
struct CadaclysmBlacksmithAnimation *cadaclysm_blacksmith_animation_clone(const struct CadaclysmBlacksmithAnimation *animation);
A copy of animation, with names of its own: freeing either leaves the other's borrowed names valid. Null (and last_error) for null.
cadaclysm_blacksmith_animation_add_track
int32_t cadaclysm_blacksmith_animation_add_track(struct CadaclysmBlacksmithAnimation *animation,
const char *target,
uint32_t channel,
uint32_t mode,
const double *times,
const double *values,
uint32_t count,
uint32_t dimension);
Adds a track driving channel of target: count keys at times (seconds), each with dimension doubles of values (flat, key k at k * dimension), read by mode. Answers the new track's index; a target named for the first time becomes the next target.
-1 and last_error, the animation left as it was, for a null animation or target, a target that is empty or not UTF-8, a channel that is not one of the seven, a mode that is not one of the five, a dimension other than the channel's (or 0 for a value track), no keys (count 0), more than 1 000 000 keys, a null times or values with keys to read, a time NaN, infinite, negative or not after the one before (by its key), and a value NaN or infinite (by its key).
cadaclysm_blacksmith_animation_set_pivot
bool cadaclysm_blacksmith_animation_set_pivot(struct CadaclysmBlacksmithAnimation *animation,
uint32_t track,
const double *pivot3,
const double *axis3);
Sets the point rotate or scale track track works about (pivot3) and a rotate's axis (axis3, normalised when read; a scale keeps it but never reads it). Until set, the origin and +Z.
false and last_error, the track left as it was, for a null animation, pivot3 or axis3, a track out of range, a track that is not rotate or scale, an entry NaN or infinite, and a rotate axis shorter than 1e-12.
cadaclysm_blacksmith_animation_track_count
uint32_t cadaclysm_blacksmith_animation_track_count(const struct CadaclysmBlacksmithAnimation *animation);
How many tracks. 0 (and last_error) for null.
cadaclysm_blacksmith_animation_target_count
uint32_t cadaclysm_blacksmith_animation_target_count(const struct CadaclysmBlacksmithAnimation *animation);
How many targets (each name once). 0 (and last_error) for null.
cadaclysm_blacksmith_animation_duration
double cadaclysm_blacksmith_animation_duration(const struct CadaclysmBlacksmithAnimation *animation);
The latest key time over every track, in seconds; 0 with no tracks. 0 (and last_error) for null.
cadaclysm_blacksmith_animation_target
const char *cadaclysm_blacksmith_animation_target(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t i);
Target i's name. Borrowed: valid until the animation is freed, and must not be freed itself.
Null and last_error for a null animation and a target out of range.
cadaclysm_blacksmith_animation_track_target
const char *cadaclysm_blacksmith_animation_track_target(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track);
Track track's target name. Borrowed: valid until the animation is freed, and must not be freed itself.
Null and last_error for a null animation and a track out of range.
cadaclysm_blacksmith_animation_track_channel
uint32_t cadaclysm_blacksmith_animation_track_channel(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track);
Track track's channel, a CADACLYSM_BLACKSMITH_CHANNEL_* constant.
UINT32_MAX (0 is a channel) and last_error for a null animation and a track out of range.
cadaclysm_blacksmith_animation_track_mode
uint32_t cadaclysm_blacksmith_animation_track_mode(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track);
Track track's mode as given, a CADACLYSM_BLACKSMITH_INTERPOLATE_* constant (visible and ghost read as nearest whatever this says).
0 and last_error for a null animation and a track out of range.
cadaclysm_blacksmith_animation_track_count_keys
uint32_t cadaclysm_blacksmith_animation_track_count_keys(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track);
How many keys track track has.
0 and last_error for a null animation and a track out of range.
cadaclysm_blacksmith_animation_track_dimension
uint32_t cadaclysm_blacksmith_animation_track_dimension(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track);
How many doubles a key of track track has.
0 and last_error for a null animation and a track out of range.
cadaclysm_blacksmith_animation_track_pivot
bool cadaclysm_blacksmith_animation_track_pivot(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track,
double *out6);
Track track's pivot then axis into out6 (the origin and +Z unless set; any track has them, only rotate and scale read them).
false and last_error, with out6 untouched, for a null animation or out6 and a track out of range.
cadaclysm_blacksmith_animation_track_keys
bool cadaclysm_blacksmith_animation_track_keys(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track,
double *times,
uint32_t times_len,
double *values,
uint32_t values_len);
Track track's keys as given: count times into times and count * dimension doubles into values (key k at k * dimension).
false and last_error, with both untouched, for a null animation, times or values, a track out of range, a times_len under the key count, and a values_len under count * dimension.
cadaclysm_blacksmith_animation_track_value_at
bool cadaclysm_blacksmith_animation_track_value_at(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t track,
double t,
double *out,
uint32_t out_len);
Track track's value at t seconds into out, dimension doubles.
false and last_error, with out untouched, for a null animation or out, a track out of range, an out_len under the track's dimension, and a t that is NaN or infinite.
cadaclysm_blacksmith_animation_values_size
uint32_t cadaclysm_blacksmith_animation_values_size(const struct CadaclysmBlacksmithAnimation *animation);
The sum of every track's dimension: how many doubles _values_at writes. 0 (and last_error) for null.
cadaclysm_blacksmith_animation_values_at
bool cadaclysm_blacksmith_animation_values_at(const struct CadaclysmBlacksmithAnimation *animation,
double t,
double *out,
uint32_t out_len);
Every track's value at t seconds into out, the tracks in order, flat: _values_size doubles (none, and out may be null, with no tracks).
false and last_error, with out untouched, for a null animation or out, an out_len under _values_size, and a t that is NaN or infinite.
cadaclysm_blacksmith_animation_placement_at
bool cadaclysm_blacksmith_animation_placement_at(const struct CadaclysmBlacksmithAnimation *animation,
uint32_t target,
double t,
double *out16);
Target target's placement at t seconds into out16: its scale, rotate and translate tracks composed (T_n ... T_1 * R_m ... R_1 * S_k ... S_1, the first-added of each kind applied first), column-major out16[col * 4 + row] with the translation in entries 12, 13 and 14 — the layout the View's placement takes. A target with no such track answers the identity.
false and last_error, with out16 untouched, for a null animation or out16, a target out of range, and a t that is NaN or infinite.
cadaclysm_blacksmith_animation_free
void cadaclysm_blacksmith_animation_free(struct CadaclysmBlacksmithAnimation *animation);
Release an animation, and with it every name it lent. Null is a no-op.
Documents
cadaclysm_blacksmith_document_new
struct CadaclysmBlacksmithDocument *cadaclysm_blacksmith_document_new(const char *units);
A new, empty document counting lengths in units (mm, cm, m, in or ft; null or empty is mm). Free it with cadaclysm_blacksmith_document_free.
cadaclysm_blacksmith_document_load
struct CadaclysmBlacksmithDocument *cadaclysm_blacksmith_document_load(const char *text);
A document read from text, as cadaclysm_blacksmith_document_save writes it: its nodes, parameters, history and branches. Null and last_error for text that is not a document.
cadaclysm_blacksmith_document_save
char *cadaclysm_blacksmith_document_save(const struct CadaclysmBlacksmithDocument *doc);
The document as canonical JSON text. Owned: release it with cadaclysm_blacksmith_string_free. An open batch or preview is not in it.
cadaclysm_blacksmith_document_apply
char *cadaclysm_blacksmith_document_apply(struct CadaclysmBlacksmithDocument *doc,
const char *op,
const char *message);
Applies one op (op, JSON: {"op": "add", "node": {...}} and the rest) and records it as one commit, with message (null or empty: none). The changed set as JSON, {"added": [ids], "changed": [ids], "removed": [ids], "params": [names], "variants": bool, "components": [names], "meta": [apps]}: owned, release it with cadaclysm_blacksmith_string_free. Null and last_error (the reason) when the op is refused; the document is unchanged.
cadaclysm_blacksmith_document_preview
char *cadaclysm_blacksmith_document_preview(struct CadaclysmBlacksmithDocument *doc,
const char *op);
One drag frame: applies op without recording it, after taking back the last frame. The changed set, relative to the state before the preview, as cadaclysm_blacksmith_document_apply. Owned. Null and last_error when refused.
cadaclysm_blacksmith_document_preview_begin
bool cadaclysm_blacksmith_document_preview_begin(struct CadaclysmBlacksmithDocument *doc);
Opens a preview that lasts until cadaclysm_blacksmith_document_end_preview: later applies are previewed, never recorded. False and last_error while a batch or a preview is open.
cadaclysm_blacksmith_document_end_preview
char *cadaclysm_blacksmith_document_end_preview(struct CadaclysmBlacksmithDocument *doc);
Takes back an open preview; the changed set of doing so. Owned.
cadaclysm_blacksmith_document_batch_begin
bool cadaclysm_blacksmith_document_batch_begin(struct CadaclysmBlacksmithDocument *doc,
const char *message);
Opens a batch: later applies are applied live and recorded as one commit by cadaclysm_blacksmith_document_batch_end, with message (null or empty: none). False and last_error while a batch or a preview is open.
cadaclysm_blacksmith_document_batch_end
char *cadaclysm_blacksmith_document_batch_end(struct CadaclysmBlacksmithDocument *doc);
Records the open batch as one commit (nothing if it holds no ops); the changed set, owned. Null and last_error when no batch is open.
cadaclysm_blacksmith_document_batch_abort
char *cadaclysm_blacksmith_document_batch_abort(struct CadaclysmBlacksmithDocument *doc);
Reverts every op of the open batch; the changed set, owned.
cadaclysm_blacksmith_document_undo
char *cadaclysm_blacksmith_document_undo(struct CadaclysmBlacksmithDocument *doc);
Takes back the head commit. The changed set as JSON, owned; the text null when there was nothing to undo. Null pointer and last_error for a real refusal (a batch or a preview is open).
cadaclysm_blacksmith_document_redo
char *cadaclysm_blacksmith_document_redo(struct CadaclysmBlacksmithDocument *doc);
Puts back the commit cadaclysm_blacksmith_document_undo took back, as it does: the changed set, the text null for nothing to redo, a null pointer for a refusal.
cadaclysm_blacksmith_document_params
char *cadaclysm_blacksmith_document_params(const struct CadaclysmBlacksmithDocument *doc);
The parameters as a JSON object, name to value. Owned.
cadaclysm_blacksmith_document_evaluate
char *cadaclysm_blacksmith_document_evaluate(struct CadaclysmBlacksmithDocument *doc,
bool cheap_only);
Evaluates the nodes that are stale (only the cheap ones when cheap_only). The status of every node as JSON, [{"id", "state": "ok"|"error"|"blocked"|"pending", "key", "error"?, "by"?, "hash"?}]. Owned.
cadaclysm_blacksmith_document_evaluate_with
char *cadaclysm_blacksmith_document_evaluate_with(struct CadaclysmBlacksmithDocument *doc,
bool cheap_only,
CadaclysmBlacksmithDocumentProgress progress,
void *user);
cadaclysm_blacksmith_document_evaluate, every kernel call's progress heard by progress with the id of the node it is for: a progress bar, or a note of which node was being built when the host died (a crash quarantine). The same statuses as the plain evaluate, owned; the callback only listens, so what is evaluated is the same without it. A cheap-only pass reports nothing.
cadaclysm_blacksmith_document_result_kind
char *cadaclysm_blacksmith_document_result_kind(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
What node id evaluated to: "solid", "sheet", "profile", "profiles" (a profile list, or a sketch's outlines), "nurbs", "subd", "curve", "list" (a list holding geometry, as a laced node gives: its items are id#0, id#1, ..., read by every result call, and cadaclysm_blacksmith_document_value counts them), "value" (a number, text, point, record and the like: read it with cadaclysm_blacksmith_document_value), or "none" (no such node, or not evaluated yet or failed). Owned.
cadaclysm_blacksmith_document_result_solid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_document_result_solid(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
Node id's solid or sheet as a new handle: free it with cadaclysm_blacksmith_solid_free. Null and last_error when id is not an evaluated solid or sheet. id#i reads item i of a node whose value is a list (a laced node), id#i#j an item of that.
cadaclysm_blacksmith_document_result_garment
struct CadaclysmBlacksmithGarment *cadaclysm_blacksmith_document_result_garment(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
Node id's garment as a new handle, a copy you can keep editing: free it with cadaclysm_blacksmith_garment_free. Lengths are in the document's units (millimetres for a millimetre document), so convert a garment from a non-millimetre document to millimetres before cadaclysm_blacksmith_garment_to_aama, which writes metric. Null and last_error when id is not an evaluated garment. id#i reads item i of a node whose value is a list.
cadaclysm_blacksmith_document_result_profile
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_document_result_profile(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
Node id's profile as a new handle: free it with cadaclysm_blacksmith_profile_free. id#i reads item i of a node whose value is a list (a laced node), id#i#j an item of that.
cadaclysm_blacksmith_document_result_profile_count
uint32_t cadaclysm_blacksmith_document_result_profile_count(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
How many profiles node id holds, when it is a profile list (or a sketch). UINT32_MAX and last_error otherwise. id#i reads item i of a node whose value is a list (a laced node), id#i#j an item of that.
cadaclysm_blacksmith_document_result_profile_at
struct CadaclysmBlacksmithProfile *cadaclysm_blacksmith_document_result_profile_at(const struct CadaclysmBlacksmithDocument *doc,
const char *id,
uint32_t i);
Profile i of node id's list, as a new handle: free it with cadaclysm_blacksmith_profile_free. Null and last_error past the end. id#i reads item i of a node whose value is a list (a laced node), id#i#j an item of that.
cadaclysm_blacksmith_document_result_nurbs_curve
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_document_result_nurbs_curve(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
Node id's NURBS curve as a new handle: free it with cadaclysm_blacksmith_nurbs_curve_free. id#i reads item i of a node whose value is a list (a laced node), id#i#j an item of that.
cadaclysm_blacksmith_document_result_subd
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_document_result_subd(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
Node id's subdivision cage as a new handle: free it with cadaclysm_blacksmith_subd_free. id#i reads item i of a node whose value is a list (a laced node), id#i#j an item of that.
cadaclysm_blacksmith_document_value
char *cadaclysm_blacksmith_document_value(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
Node id's value as JSON (a number, record, list, text, ...). Owned. Null and last_error (the node's error, or that it has not been evaluated) when it has none.
cadaclysm_blacksmith_document_errors
char *cadaclysm_blacksmith_document_errors(const struct CadaclysmBlacksmithDocument *doc);
The nodes the last evaluate left in error or blocked, [{"id", "state", "message"}]. Owned.
cadaclysm_blacksmith_document_kinds
char *cadaclysm_blacksmith_document_kinds(void);
Every node kind the library knows, as a JSON array of rows (name, inputs, output, cost, help). Needs no document. Owned.
cadaclysm_blacksmith_document_solid_body
char *cadaclysm_blacksmith_document_solid_body(const struct CadaclysmBlacksmithSolid *solid);
solid as the body field of a solid.body (or sheet.body) node holds it: the kernel's own B-rep as JSON, every table and number as they are, and its colours (the solid's, each face's, every edge's and each edge's), so the node gives back exactly this body as it is drawn. How a solid the caller already has goes into a document. Needs no document. Owned. Null and last_error where the solid holds a curve the kernel could not read.
cadaclysm_blacksmith_document_profile_path
char *cadaclysm_blacksmith_document_profile_path(const struct CadaclysmBlacksmithProfile *profile);
profile as the path field of a profile.path node holds it: its exact segments (lines, arcs, Beziers, conics, NURBS), holes and colour as JSON, {"start", "segments", "holes", "colour"}. How a profile the caller already has goes into a document, drawn as it was. Needs no document. Owned.
cadaclysm_blacksmith_document_branch_new
char *cadaclysm_blacksmith_document_branch_new(struct CadaclysmBlacksmithDocument *doc,
const char *name,
const char *at);
A new branch name at commit at (null or empty: the head, and the document switches onto it). The changed set, owned. Null and last_error when refused.
cadaclysm_blacksmith_document_branch_switch
char *cadaclysm_blacksmith_document_branch_switch(struct CadaclysmBlacksmithDocument *doc,
const char *name_or_commit_id);
Moves the head to the branch name_or_commit_id (a branch name first, else a commit id, which detaches the head). The changed set, owned. Null and last_error when refused.
cadaclysm_blacksmith_document_tips
char *cadaclysm_blacksmith_document_tips(const struct CadaclysmBlacksmithDocument *doc);
The tips of lines no branch names, each a whole commit as cadaclysm_blacksmith_document_log writes it, [{"id", "parents", "message"?, "author"?, "time"?, "ops"}]. Owned.
cadaclysm_blacksmith_document_branch_rename
bool cadaclysm_blacksmith_document_branch_rename(struct CadaclysmBlacksmithDocument *doc,
const char *old,
const char *new_);
Renames branch old to new. False and last_error when refused.
cadaclysm_blacksmith_document_branch_delete
bool cadaclysm_blacksmith_document_branch_delete(struct CadaclysmBlacksmithDocument *doc,
const char *name);
Deletes branch name. False and last_error when refused.
cadaclysm_blacksmith_document_branch_list
char *cadaclysm_blacksmith_document_branch_list(const struct CadaclysmBlacksmithDocument *doc);
The branches as JSON, {"branches": {name: commit}, "branch": name|null, "head": commit, "unnamed": [commit]}, plus "can_undo" and "can_redo". Owned.
cadaclysm_blacksmith_document_log
char *cadaclysm_blacksmith_document_log(const struct CadaclysmBlacksmithDocument *doc,
const char *branch);
The commits of branch's line (null or empty: the line from the head to the root), newest first, [{"id", "parents", "message"?, "author"?, "time"?, "ops"}]. Owned. Null and last_error for a branch that does not exist.
cadaclysm_blacksmith_document_revision
uint64_t cadaclysm_blacksmith_document_revision(const struct CadaclysmBlacksmithDocument *doc);
A counter that moves once with every change to the document's state: an apply, undo or redo, a branch made, switched to or deleted, a preview frame or its end, a batch's end or abort. Never with an evaluation, a save or a read. A new or loaded document starts at 1; 0 is a null document. A page keys what it read on it.
cadaclysm_blacksmith_document_nodes
char *cadaclysm_blacksmith_document_nodes(const struct CadaclysmBlacksmithDocument *doc,
const char *ids);
The nodes as cadaclysm_blacksmith_document_save writes them, as a JSON list: all of them in document order (ids null or empty), or the nodes a JSON list of ids names, in that order. The live state: an open batch's or preview's applies are in it. Owned. Null and last_error for an unknown id, naming it.
cadaclysm_blacksmith_document_inputs
char *cadaclysm_blacksmith_document_inputs(const struct CadaclysmBlacksmithDocument *doc,
const char *id,
bool transitive);
The nodes node id reads, as a JSON list of ids in document order: those its fields name (frame fields included), or with transitive everything those read too, however far, each once. Parameters are walked through, not listed. Owned. Null and last_error for an unknown id.
cadaclysm_blacksmith_document_readers
char *cadaclysm_blacksmith_document_readers(const struct CadaclysmBlacksmithDocument *doc,
const char *id,
bool transitive);
The mirror of cadaclysm_blacksmith_document_inputs: the nodes that read node id, directly or, with transitive, however far (what deleting it would break). Owned. Null and last_error for an unknown id.
cadaclysm_blacksmith_document_probe
char *cadaclysm_blacksmith_document_probe(struct CadaclysmBlacksmithDocument *doc,
const char *op,
const char *ids);
Tries op (JSON, as cadaclysm_blacksmith_document_apply takes) on a scratch copy of the document and evaluates only the nodes ids (a JSON list) names and what they read, however far. The statuses as cadaclysm_blacksmith_document_evaluate gives them: owned. Until cadaclysm_blacksmith_document_probe_end, those nodes' results (document_result_*, document_value) are the probe's; every other node's stay the document's. The document's state, cache, history and revision are untouched. Null and last_error while a batch, a preview or another probe is open, for an op the scratch copy refuses, or an unknown id. While a probe is open, every call that changes the document is refused.
cadaclysm_blacksmith_document_probe_end
void cadaclysm_blacksmith_document_probe_end(struct CadaclysmBlacksmithDocument *doc);
Ends an open probe: every result is the document's again. No probe open, or a null document, is a no-op.
cadaclysm_blacksmith_document_result_bezier_count
uint32_t cadaclysm_blacksmith_document_result_bezier_count(const struct CadaclysmBlacksmithDocument *doc,
const char *id);
How many Béziers cadaclysm_blacksmith_document_result_beziers writes for node id. 0 and last_error when id has no curve or profiles (a solid, a value, no result).
cadaclysm_blacksmith_document_result_beziers
bool cadaclysm_blacksmith_document_result_beziers(const struct CadaclysmBlacksmithDocument *doc,
const char *id,
const double *frame,
double *out);
Node id's sketch curve or profiles as rational cubic Béziers into out, sixteen doubles each (x y z w per control point, the point Cartesian, its weight beside it). A sketch curve is carried onto its own frame (the world), or onto frame; a profile, a profile list or a sketch gives every loop, outline then holes, on the sketch plane (z = 0), or on frame. frame null, or twelve doubles: origin, x, y, z (x normalised, y squared against it, z not read). An open probe's value is read for a node it evaluated. Size out from cadaclysm_blacksmith_document_result_bezier_count. false and last_error when id has none, or for a frame whose directions are parallel, zero or not finite.
cadaclysm_blacksmith_document_meta
char *cadaclysm_blacksmith_document_meta(const struct CadaclysmBlacksmithDocument *doc,
const char *app);
App app's own data about the document as JSON text: what the last {"op": "meta", "app": ..., "value": ...} set (undone and saved with the rest, never read by evaluation). Owned. Null when the app keeps none, with last_error empty: that is no failure. Null and last_error for a null argument.
cadaclysm_blacksmith_document_free
void cadaclysm_blacksmith_document_free(struct CadaclysmBlacksmithDocument *doc);
Release a document. Null is a no-op.
BIM documents
cadaclysm_bim_document_new
struct CadaclysmBlacksmithDocument *cadaclysm_bim_document_new(const char *units);
A new building document counting lengths in units (mm, cm, m, in or ft; null or empty is mm): the blacksmith kinds and the bim.* ones, holding one hidden bim.project node with a random guid, the seed of every IFC GlobalId it exports (added as one commit). Free it with cadaclysm_blacksmith_document_free. Null and last_error for unknown units.
cadaclysm_bim_document_load
struct CadaclysmBlacksmithDocument *cadaclysm_bim_document_load(const char *text);
A building document read from text, as cadaclysm_blacksmith_document_save writes it, opened with the bim.* kinds. Free it with cadaclysm_blacksmith_document_free. Null and last_error for text that is not a document.
cadaclysm_bim_kinds
char *cadaclysm_bim_kinds(void);
Every node kind a building document knows, the blacksmith's and the bim.* ones, as cadaclysm_blacksmith_document_kinds lists them. Owned: release it with cadaclysm_blacksmith_string_free.
cadaclysm_bim_document_export_ifc
char *cadaclysm_bim_document_export_ifc(struct CadaclysmBlacksmithDocument *doc,
const char *options_json);
The building as IFC text. options_json (null or empty: every default) is {"schema": "IFC4" | "IFC2X3", "geometry": "parametric" | "exact", "timestamp": <Unix seconds>, "name": <IfcProject name>}, every key optional (IFC4, parametric, the current time, no name; an explicit "timestamp": 0 is the epoch, for byte-stable files). The document is evaluated first if it is not. Owned: release it with cadaclysm_blacksmith_string_free.
Null and last_error for a document not opened as a building document, for bad options, and for a refused export, whose reason is every refusal at once as JSON, bim_document_export_ifc: {"refusals": [{"node": <id> | null, "reason": <text>}]}: nothing is written then.
cadaclysm_bim_sheet_svg
char *cadaclysm_bim_sheet_svg(struct CadaclysmBlacksmithDocument *doc, const char *id);
Sheet id (a bim.sheet node) as SVG text sized in paper millimetres: its frame, title block and viewports (plans, sections, elevations, schedules and 3D views; a 3D view is drawn as its visible lines; a picture-style one, which only the web editor renders, as a box reading "3D view not rendered"). The document is evaluated first if it is not. Owned: release it with cadaclysm_blacksmith_string_free. Null and last_error for a node that is missing, not a sheet, or a sheet that did not build.
cadaclysm_bim_sheet_pdf
uint8_t *cadaclysm_bim_sheet_pdf(struct CadaclysmBlacksmithDocument *doc,
const char *id,
size_t *len);
Sheet id (a bim.sheet node) as a one-page PDF the size of its paper, with a bookmark naming it ("A-101 Plans"). A 3D view is drawn as its visible lines; a picture-style one, which only the web editor renders, as a box reading "3D view not rendered". The document is evaluated first if it is not. The bytes are owned, their count written through len: release them with cadaclysm_blacksmith_bytes_free, passing that len back. Null and last_error for a null len, or a node that is missing, not a sheet, or a sheet that did not build.
cadaclysm_bim_sheets_pdf
uint8_t *cadaclysm_bim_sheets_pdf(struct CadaclysmBlacksmithDocument *doc,
const char *ids_json,
size_t *len);
Sheets ids_json (a JSON list of bim.sheet ids, ["a101","a201"]) as one PDF: a page each in that order, each its paper's size, a bookmark a page. A 3D view is drawn as its visible lines; a picture-style one, which only the web editor renders, as a box reading "3D view not rendered". The document is evaluated first if it is not. Owned bytes as cadaclysm_bim_sheet_pdf's. Null and last_error for a null len, an empty list, ids that are not a JSON list of strings, or any sheet that call would refuse.
Bench documents
cadaclysm_parts_catalog_load
bool cadaclysm_parts_catalog_load(const char *dir);
Replaces the catalogue parts.catalog builds from with the one in directory dir: its index.json and every family file it lists (the robot bench's catalog/). False and last_error for a directory that is not a catalogue.
cadaclysm_parts_document_new
struct CadaclysmBlacksmithDocument *cadaclysm_parts_document_new(void);
A new, empty bench document, in mm: the blacksmith kinds (assembly.* among them) and parts.*. Free it with cadaclysm_blacksmith_document_free.
cadaclysm_parts_document_load
struct CadaclysmBlacksmithDocument *cadaclysm_parts_document_load(const char *text);
A bench document read from text, as cadaclysm_blacksmith_document_save writes it, opened with the parts.* kinds. Free it with cadaclysm_blacksmith_document_free. Null and last_error for text that is not a document ("This is not a cadaclysm-blacksmith document", naming an old robot bench project when it is one).
cadaclysm_parts_kinds
char *cadaclysm_parts_kinds(void);
Every node kind a bench document knows, the blacksmith's and the parts.* ones, as cadaclysm_blacksmith_document_kinds lists them. Owned: release it with cadaclysm_blacksmith_string_free.
Curves in space
cadaclysm_blacksmith_nurbs_curve_closest_point
int32_t cadaclysm_blacksmith_nurbs_curve_closest_point(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *p,
double *out);
The nearest point of curve to p (3 doubles) over its whole domain, as five doubles into out: t x y z unique, unique 1 where no other point of the curve is as near and 0 where one is (a point on a circle's axis). Returns 1, or -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null curve, p or out, or a non-finite point.
cadaclysm_blacksmith_nurbs_curve_closest_point_within
int32_t cadaclysm_blacksmith_nurbs_curve_closest_point_within(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *p,
double max_distance,
double *out);
The nearest point of curve to p (3 doubles) over its whole domain, as five doubles into out — t x y z unique, as cadaclysm_blacksmith_nurbs_curve_closest_point answers them, to the bit — where it is within max_distance. Returns 1 with out filled; 0, out untouched, where the nearest point is beyond max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null curve, p or out, a curve that is not valid, a non-finite point or a negative max_distance.
max_distance NaN or +inf is no limit. Only a nearest point *beyond* it answers 0: one a rounding error past it is not beyond.
cadaclysm_blacksmith_nurbs_curve_closest_points
int32_t cadaclysm_blacksmith_nurbs_curve_closest_points(const struct CadaclysmBlacksmithNurbsCurve *a,
const struct CadaclysmBlacksmithNurbsCurve *b,
double max_distance,
struct CadaclysmBlacksmithCurvePair *out);
The closest points of curves a and b, into out (t_a/point_a on a) — see CadaclysmBlacksmithCurvePair. Returns 1 with out filled; 0, out untouched, where they are farther apart than max_distance; and -1 on a refusal (negative: test < 0; the bits of CADACLYSM_BLACKSMITH_NONE), with last_error set and out untouched, for a null curve or out, a curve that is not valid, or a negative max_distance.
max_distance NaN or +inf is no limit; only a distance *beyond* it answers 0.
cadaclysm_blacksmith_nurbs_curve_closest_object
int32_t cadaclysm_blacksmith_nurbs_curve_closest_object(const struct CadaclysmBlacksmithNurbsCurve *curve,
const uint8_t *kinds,
uint32_t count,
const struct CadaclysmBlacksmithSolid *const *solids,
uint32_t n_solids,
const struct CadaclysmBlacksmithNurbsCurve *const *curves,
uint32_t n_curves,
const double *points,
uint32_t n_points,
const struct CadaclysmBlacksmithProjector *const *projectors,
uint32_t n_projectors,
const struct CadaclysmBlacksmithTriangleMesh *const *meshes,
uint32_t n_meshes,
const struct CadaclysmBlacksmithNurbsSurface *const *surfaces,
uint32_t n_surfaces,
double max_distance,
double tolerance,
struct CadaclysmBlacksmithNearestObject *out);
The item of a set nearest to curve, into out — see CadaclysmBlacksmithNearestObject.
The set is count kinds, kinds[i] 0 a solid, 1 a curve, 2 a point, 3 a projector, 4 a triangle mesh or 5 an untrimmed NURBS surface, each taking the next item of that kind's array in order: solids (n_solids handles), curves (n_curves), points (3 doubles per point, n_points points), projectors (n_projectors), meshes (n_meshes) and surfaces (n_surfaces). The values 0 to 4 are unchanged from before surfaces joined the set; a caller with no meshes passes meshes NULL and n_meshes 0, and one with no surfaces surfaces NULL and n_surfaces 0. Each count must be how many kinds name. which indexes kinds. An array whose count is 0 may be null; count 0 is an empty set, which answers 0.
Items are asked in order, each with the best distance so far as its limit, and once one touches the curve no later item is asked; equal distances go to the earlier item. A mesh is answered exactly, as cadaclysm_blacksmith_triangle_mesh_curve_closest_points answers it (answer_kind 3), and a surface exactly, as cadaclysm_blacksmith_nurbs_surface_curve_closest_points answers it (answer_kind 4).
cadaclysm_blacksmith_nurbs_curve_new
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_new(const double *xyz,
size_t count,
const double *weights,
uint32_t degree,
const double *knots,
size_t knot_count);
A curve from count control points (xyz, three doubles each) of degree (1 to 7), with weights (one per point, positive; NULL for a plain B-spline) and the full knot vector (knot_count = count + degree + 1 values, non-decreasing; NULL for clamped and uniform).
cadaclysm_blacksmith_nurbs_curve_through
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_through(const double *xyz,
size_t count,
uint32_t degree,
bool closed,
const double *start,
const double *end);
The curve of degree (1 to 7) through count points in order, chord-length parametrised. closed closes it back to the first point, smooth across the seam (C^(degree-1)); an open curve may leave along start and arrive along end (directions, any length; NULL for free).
cadaclysm_blacksmith_nurbs_curve_fit
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_fit(const double *xyz,
size_t count,
uint32_t degree,
double tolerance,
double *error_out);
A curve of degree within tolerance of count points, through the first and the last (least squares); the largest distance from a point to it is written to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_fair
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_fair(const double *xyz,
size_t count,
uint32_t degree,
double tolerance,
bool no_inflection,
double span_from,
double span_to,
double *error_out);
The smoothest curve of degree (3 to 7) within tolerance of count points, through the first and the last: least squares plus the curvature's derivative squared, weighed as heavily as the tolerance allows — where cadaclysm_blacksmith_nurbs_curve_fit follows the points' noise, this spends the tolerance on a calm curvature comb. With no_inflection, the curvature does not turn over between points span_from and span_to (point indices, fractions between points; a NaN end is the curve's own end, so NaN, NaN is the whole curve), and the call is refused where no such curve is within the tolerance. The largest distance from a point to the curve is written to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_faired
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_faired(const struct CadaclysmBlacksmithNurbsCurve *curve,
uint32_t degree,
double tolerance,
bool no_inflection,
double span_from,
double span_to,
double *error_out);
curve faired: the smoothest curve of degree (3 to 7) within tolerance of it (read at even parameters along it), from its start to its end, as cadaclysm_blacksmith_nurbs_curve_fair makes one from points; span_from and span_to are curve's own parameters here. The largest distance found between the two curves is written to error_out when that is not NULL.
tolerance 0 or NaN: the curve's effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_from_edge
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_from_edge(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge);
Edge edge of solid (the index cadaclysm_blacksmith_edge_curve takes) as an exact NURBS over the edge's own span of its curve, running the way the edge's segments run.
cadaclysm_blacksmith_nurbs_curve_from_face_isocurve
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_from_face_isocurve(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
bool along_u,
double at);
The isocurve of face face of solid's surface: along u at v = at when along_u, else along v at u = at. NURBS faces only.
cadaclysm_blacksmith_nurbs_curve_blend
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_blend(const struct CadaclysmBlacksmithNurbsCurve *a,
bool a_end,
const struct CadaclysmBlacksmithNurbsCurve *b,
bool b_end,
uint32_t continuity,
double bulge);
The curve bridging a (at its end when a_end, else its start) to b (at its end when b_end, else its start): continuity 1 matches position and tangent (a cubic), 2 also the curvature (a quintic). bulge (positive; 1 is usual) scales how far the tangents reach.
cadaclysm_blacksmith_nurbs_curve_projected_to_plane
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_projected_to_plane(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *origin,
const double *normal,
const double *direction);
curve projected onto the plane through origin with normal, along direction (NULL: the normal). Exact: the control points move, the weights stay.
cadaclysm_blacksmith_nurbs_curve_projected_to_face
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_projected_to_face(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *direction,
double tolerance,
double *error_out);
curve projected along direction onto face face of solid (its whole surface), fitted within tolerance; the largest distance between the result and the surface goes to error_out when that is not NULL. Refused where a point's ray misses the surface.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_offset_on_sheet
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_offset_on_sheet(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
double distance,
double tolerance,
double *error_out);
curve, lying on solid (a sheet: any of its faces, within ten times tolerance), offset distance measured along the sheet square to it — to the left of its run seen from the side the faces' normals point to for positive, to the right for negative — walked along the surface across shared edges and fitted within tolerance; where it crosses a crease between two faces, fitted each side and joined there. The largest distance between the result and the sheet goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_pulled_back
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_pulled_back(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double tolerance,
double *error_out);
curve, lying on face face of solid within tolerance, read back into the face's surface parameters (Rhino's Pullback): a uv curve — a curve in the z = 0 plane whose x is u and y is v — over curve's own domain, its point at t paired with curve's at t. The face is its whole surface (its trims are not read). Exact where the curve runs along a parameter line and for a curve in a plane; otherwise fitted. Across a periodic surface's seam the uv curve runs on rather than jumping a period, and it starts inside the domain. Where the curve ends at a pole (a sphere's, a cone's apex) the uv curve meets the pole line square; where it passes over one, the uv curve gains a run along the pole line there, so past that point its parameter no longer pairs with curve's. Refused (NULL) where the curve stands off the surface past tolerance, naming where and how far. The deviation reached goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_pushed_up
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_pushed_up(const struct CadaclysmBlacksmithNurbsCurve *uv,
const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double tolerance,
double *error_out);
The uv curve uv (a curve in the z = 0 plane: x is u, y is v) carried out through face face's surface of solid (Rhino's Pushup): a 3D curve over uv's domain within tolerance of the surface's points along it. Exact on a plane and along a parameter line (the surface's own isocurve: a circle, a ruling, a patch's isocurve); otherwise fitted. Refused where uv is not in the z = 0 plane or leaves a patch's domain on an axis that does not wrap. The deviation reached goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_nurbs_curve_fitted_to_face
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_fitted_to_face(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *direction,
const double *knots,
size_t knot_count,
double tolerance,
double *error_out);
curve carried onto face face of solid and fitted to the face's surface parameter it crosses (Rhino's FitCurveToSurface). The curve is projected onto the face's surface along direction (three doubles), or pulled — each point to its nearest — where direction is NULL or zero; that trace must cross the face's parameter rectangle (the box its trims span in its surface's parameters) from one side to the opposite one. The result is parametrised by the parameter it crosses — at t it is over u = t (or v = t), running with it rising — on the surface's own knots in that direction plus the knot_count doubles knots (each strictly inside the range), at the surface's degree there, at least 3: knot-compatible with the surface's isocurves. Where it is farther than tolerance from the trace, knots are added halfway along the spans still off; it is never refused for the tolerance alone. Refused where the trace does not cross, turns back, or a knot lies outside the range. A bound on the distance from the exact trace (the projection's, the read-back's and the fit's deviations added) goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_nurbs_curve_offset
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_offset(const struct CadaclysmBlacksmithNurbsCurve *curve,
double distance,
const double *direction,
double tolerance,
double *error_out);
curve moved distance in space, square to its tangent and to direction (three doubles; Rhino's OffsetCurve): to the right of the run seen from the tip of direction for a positive distance, to the left for a negative one. A line or an arc in a plane square to direction offsets exactly (error 0); anything else is fitted within tolerance. Distance 0 is a copy. Null and last_error (prefixed nurbs_curve_offset: ) for a NULL or zero direction, a distance that is not finite, a corner (a kink the offset would tear at), or an offset that folds over (an arc's radius used up, a turn tighter than distance). The fit's bound on the distance from the exact offset goes to error_out when that is not NULL.
tolerance 0 or NaN: the effective tolerance.
cadaclysm_blacksmith_nurbs_curve_offset_normal_to_sheet
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_offset_normal_to_sheet(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
double distance,
double tolerance,
double *error_out);
curve, lying on the sheet solid (within ten times tolerance), moved distance along the sheet's normal at each point — off the sheet, the way its faces face for a positive distance. Fitted within tolerance. Null and last_error (prefixed nurbs_curve_offset_normal_to_sheet: ) for a curve off the sheet, one crossing a crease (faces whose normals differ by more than a degree), a distance that is not finite, or an offset that folds over. The fit's bound on the distance from the exact offset goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_nurbs_curve_offset_tangent_to_sheet
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_offset_tangent_to_sheet(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
double distance,
double tolerance,
double *error_out);
curve, lying on the sheet solid (within ten times tolerance), moved distance in the sheet's tangent plane, square to the curve: along N x C' (the sheet's normal crossed with the curve's tangent) for a positive distance. Fitted within tolerance. Null and last_error (prefixed nurbs_curve_offset_tangent_to_sheet: ) as for cadaclysm_blacksmith_nurbs_curve_offset_normal_to_sheet. The fit's bound on the distance from the exact offset goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_nurbs_curve_through_on_face
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_through_on_face(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *xyz,
size_t count,
bool closed,
double tolerance,
double *error_out);
A smooth curve through count points xyz lying on face face of solid (Rhino's InterpolatedCurveOnSurface): each point's nearest foot on the face's surface — a point farther than tolerance from it is refused, naming its index — interpolated in the surface's parameters (cubic, chord-length) and carried out through the surface. closed runs back to the first point, smooth across the join; a closed ring round a periodic surface (a cylinder) closes. The deviation reached goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_nurbs_curve_through_uv_on_face
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_through_uv_on_face(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *uv,
size_t count,
bool closed,
double tolerance,
double *error_out);
A smooth curve through count surface parameters uv (two doubles each: u, v) of face face of solid (Rhino's InterpolatedCurveOnSurfaceUV): interpolated in the parameters (cubic, chord-length) and carried out through the surface, within tolerance. closed runs back to the first point; a ring whose last point is a whole period short of the first on a periodic surface winds round it and closes. A ring winding both parameters is refused. The deviation reached goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_nurbs_curve_short_path_on_face
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_short_path_on_face(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const double *a,
const double *b,
double tolerance,
double *error_out);
The shortest path on face face's surface of solid from surface parameters a to b (two doubles each: u, v; Rhino's ShortPath), within tolerance: a geodesic, the straight run between them relaxed until its length settles, tried a period either way round a periodic surface and the shortest kept. It is the shortest path among those starts — the quadrics' and a gentle patch's shortest path; a surface with a hill between the points may hide a shorter way round. The face's trims are not read. The deviation reached goes to error_out when that is not NULL.
tolerance 0 or NaN: the inputs' effective tolerance.
cadaclysm_blacksmith_nurbs_curve_pulled_to_face
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_pulled_to_face(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double tolerance,
double *error_out);
curve pulled onto face face of solid (its whole surface): every point to its nearest surface point, fitted within tolerance; the error to error_out as for the projection.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_reversed
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_reversed(const struct CadaclysmBlacksmithNurbsCurve *curve);
curve run the other way over the same domain.
cadaclysm_blacksmith_nurbs_curve_trimmed
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_trimmed(const struct CadaclysmBlacksmithNurbsCurve *curve,
double t0,
double t1);
The part of curve from t0 to t1 (t0 < t1, both inside its domain), over t0..t1.
cadaclysm_blacksmith_nurbs_curve_extended
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_extended(const struct CadaclysmBlacksmithNurbsCurve *curve,
bool at_start,
double length);
curve continued length past its start (at_start) or end along its own end polynomial — position, tangent and curvature there unchanged; every old parameter keeps its point.
cadaclysm_blacksmith_nurbs_curve_elevated
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_elevated(const struct CadaclysmBlacksmithNurbsCurve *curve,
uint32_t by);
The same curve at degree degree + by (the result's degree at most 12).
cadaclysm_blacksmith_nurbs_curve_joined
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_joined(const struct CadaclysmBlacksmithNurbsCurve *const *curves,
size_t count,
double tolerance);
count curves joined end to end into one (Rhino's JoinCurves): in the order given, each turned where needed so its start meets the previous one's end (the first too, when only its start meets the second) within tolerance, the joint placed at the midpoint of the two ends. All are raised to the highest degree among them and each runs over [k, k + 1], joined C0 (a corner stays a corner); a rational curve keeps its points. One curve gives a copy; none, or a gap past tolerance (named in last_error), gives NULL.
cadaclysm_blacksmith_nurbs_curve_tween
bool cadaclysm_blacksmith_nurbs_curve_tween(const struct CadaclysmBlacksmithNurbsCurve *a,
const struct CadaclysmBlacksmithNurbsCurve *b,
uint32_t count,
uint32_t method,
uint32_t samples,
bool align,
double tolerance,
struct CadaclysmBlacksmithNurbsCurve **out);
count curves blending evenly from a to b (Rhino's CreateTweenCurves family), tween i at the fraction (i + 1) / (count + 1), written to out[i] (owned: free each with cadaclysm_blacksmith_nurbs_curve_free). method 0 is plain: control point by control point, the curves of one structure (degree, control-point count, knots) or refused. 1 is matching: made compatible exactly (degree elevation, knot merging), blended in homogeneous coordinates. 2 is sampling: both divided by arc length into samples pieces (read only here), a cubic interpolated through the blended samples. align turns b, and moves a closed one's seam, to line it up with a first (Rhino's calls leave that to the caller).
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
false and last_error for a null curve or out, a count of 0, an unknown method, one curve closed and the other open, plain on curves that are not compatible, and too few samples; nothing is written to out then.
cadaclysm_blacksmith_nurbs_curve_transformed
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_transformed(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *matrix);
curve through the affine map matrix (16 doubles, row-major): its control points mapped, its weights and knots kept — exact. A singular map is allowed (a curve flattened onto a plane is still a curve).
cadaclysm_blacksmith_nurbs_curve_clone
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_clone(const struct CadaclysmBlacksmithNurbsCurve *curve);
A copy of curve, freed on its own.
cadaclysm_blacksmith_nurbs_curve_free
void cadaclysm_blacksmith_nurbs_curve_free(struct CadaclysmBlacksmithNurbsCurve *curve);
Release a curve. NULL is a no-op.
cadaclysm_blacksmith_nurbs_curve_degree
uint32_t cadaclysm_blacksmith_nurbs_curve_degree(const struct CadaclysmBlacksmithNurbsCurve *curve);
The curve's degree; 0 (and last_error) for a NULL curve.
cadaclysm_blacksmith_nurbs_curve_control_count
uint32_t cadaclysm_blacksmith_nurbs_curve_control_count(const struct CadaclysmBlacksmithNurbsCurve *curve);
How many control points the curve has; 0 (and last_error) for a NULL curve.
cadaclysm_blacksmith_nurbs_curve_knot_count
uint32_t cadaclysm_blacksmith_nurbs_curve_knot_count(const struct CadaclysmBlacksmithNurbsCurve *curve);
How many knots the curve's full knot vector has (control_count + degree + 1).
cadaclysm_blacksmith_nurbs_curve_control_points
bool cadaclysm_blacksmith_nurbs_curve_control_points(const struct CadaclysmBlacksmithNurbsCurve *curve,
double *xyz);
The control points into xyz (3 * control_count doubles).
cadaclysm_blacksmith_nurbs_curve_weights
bool cadaclysm_blacksmith_nurbs_curve_weights(const struct CadaclysmBlacksmithNurbsCurve *curve,
double *w);
The weights into w (control_count doubles; all 1 for a plain B-spline).
cadaclysm_blacksmith_nurbs_curve_knots
bool cadaclysm_blacksmith_nurbs_curve_knots(const struct CadaclysmBlacksmithNurbsCurve *curve,
double *k);
The full knot vector into k (knot_count doubles).
cadaclysm_blacksmith_nurbs_curve_is_rational
bool cadaclysm_blacksmith_nurbs_curve_is_rational(const struct CadaclysmBlacksmithNurbsCurve *curve);
Whether the curve's weights differ (a true NURBS rather than a plain B-spline).
cadaclysm_blacksmith_nurbs_curve_is_closed
bool cadaclysm_blacksmith_nurbs_curve_is_closed(const struct CadaclysmBlacksmithNurbsCurve *curve);
Whether the curve ends where it starts (to 1e-10 of its size).
cadaclysm_blacksmith_nurbs_curve_domain
bool cadaclysm_blacksmith_nurbs_curve_domain(const struct CadaclysmBlacksmithNurbsCurve *curve,
double *out);
The parameter domain into out[0..2].
cadaclysm_blacksmith_nurbs_curve_point
bool cadaclysm_blacksmith_nurbs_curve_point(const struct CadaclysmBlacksmithNurbsCurve *curve,
double t,
double *out);
The point at parameter t (inside the domain) into out[0..3].
cadaclysm_blacksmith_nurbs_curve_derivatives
bool cadaclysm_blacksmith_nurbs_curve_derivatives(const struct CadaclysmBlacksmithNurbsCurve *curve,
double t,
uint32_t order,
double *out);
The point and its derivatives at t up to order (at most 8) into out: C, C', C'', ..., three doubles each (3 * (order + 1) in all).
cadaclysm_blacksmith_nurbs_curve_curvature
bool cadaclysm_blacksmith_nurbs_curve_curvature(const struct CadaclysmBlacksmithNurbsCurve *curve,
double t,
struct CadaclysmBlacksmithCurvature *out);
The curvature and Frenet frame at t into out. Refused where the curve has no tangent.
cadaclysm_blacksmith_nurbs_curve_length
bool cadaclysm_blacksmith_nurbs_curve_length(const struct CadaclysmBlacksmithNurbsCurve *curve,
double accuracy,
struct CadaclysmBlacksmithLength *out);
The curve's length to a relative accuracy (0 or less: the default) into out.
cadaclysm_blacksmith_nurbs_curve_point_at_length
bool cadaclysm_blacksmith_nurbs_curve_point_at_length(const struct CadaclysmBlacksmithNurbsCurve *curve,
double s,
double accuracy,
struct CadaclysmBlacksmithAt *out);
The point at arc length s from the curve's start into out (segment NONE).
cadaclysm_blacksmith_nurbs_curve_divide_by_count
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_divide_by_count(const struct CadaclysmBlacksmithNurbsCurve *curve,
uint32_t n,
double accuracy);
The curve in n pieces of equal arc length: n + 1 samples, or n for a closed curve.
cadaclysm_blacksmith_nurbs_curve_divide_by_length
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_divide_by_length(const struct CadaclysmBlacksmithNurbsCurve *curve,
double step,
double accuracy);
Samples every step of arc length from the curve's start; a closed curve never repeats it.
cadaclysm_blacksmith_nurbs_curve_plane_hits
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_plane_hits(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *origin,
const double *normal);
Where the curve crosses the plane through origin with normal, in parameter order: each an At (point, unit tangent, parameter; error the point's distance from the plane). Refused for a curve lying in the plane; a touch that does not cross is not listed.
cadaclysm_blacksmith_nurbs_curve_inflections
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_inflections(const struct CadaclysmBlacksmithNurbsCurve *curve);
Where the curve's curvature turns from one side to the other, in parameter order, as a list of At (point, unit tangent, parameter; error zero): the points where C' x C'' passes through zero and comes back reversed. A straight stretch between two opposite bends is one inflection; a knot where the curvature flips without passing through zero is one, at the knot. An empty list is a curve that bends one way only — what a test of a design line asks for.
cadaclysm_blacksmith_nurbs_curve_knot_continuity
bool cadaclysm_blacksmith_nurbs_curve_knot_continuity(const struct CadaclysmBlacksmithNurbsCurve *curve,
struct CadaclysmBlacksmithKnotContinuity *out);
How smoothly the curve runs through its own knots, into out: the largest turn of its tangent and jump of its curvature vector, with where each is.
cadaclysm_blacksmith_nurbs_curve_face_hits
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_face_hits(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double tolerance);
Where the curve crosses face face of solid (its whole surface), within tolerance of it, in parameter order (error each point's distance from the surface). A touch that does not cross is not listed.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_nurbs_curve_knot_inserted
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_knot_inserted(const struct CadaclysmBlacksmithNurbsCurve *curve,
double t,
uint32_t times);
curve with the knot t (strictly inside the domain) inserted times times — the same curve, exactly (Boehm insertion; Rhino's Knots.InsertKnot). Null and last_error (prefixed nurbs_curve_knot_inserted: ) for a t outside the domain, a times of 0, or a multiplicity past the degree.
cadaclysm_blacksmith_nurbs_curve_knots_refined
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_knots_refined(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *knots,
uint32_t count);
curve with all count knots of knots inserted (non-decreasing, each strictly inside the domain, no multiplicity past the degree) — the same curve, exactly (knot refinement). Null and last_error (prefixed nurbs_curve_knots_refined: ) otherwise.
cadaclysm_blacksmith_nurbs_curve_knot_removed
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_knot_removed(const struct CadaclysmBlacksmithNurbsCurve *curve,
double t,
uint32_t times,
double tolerance,
uint32_t *removed);
curve with up to times copies of its inner knot t removed (Rhino's Knots.RemoveKnots), each only while the curve stays within tolerance of itself; how many went is written to removed (when not NULL) — 0, and an unchanged copy, where none could go. tolerance 0 or NaN: the curve's effective tolerance. Null and last_error (prefixed nurbs_curve_knot_removed: ) for a t that is not an inner knot and a negative or infinite tolerance.
cadaclysm_blacksmith_nurbs_curve_compatible
bool cadaclysm_blacksmith_nurbs_curve_compatible(const struct CadaclysmBlacksmithNurbsCurve *const *curves,
size_t count,
struct CadaclysmBlacksmithNurbsCurve **out);
count curves made compatible (Rhino's MakeCompatible): each reparametrised to [0, 1], raised to the highest degree among them and refined with every other's knots, so all share one degree, one knot vector and one control-point count — each still the same point set. Rational curves stay exact. Written to out[i] (owned: free each). false and last_error (prefixed nurbs_curve_compatible: ) for no curves, a null curve or out; nothing is written then.
cadaclysm_blacksmith_nurbs_curve_reparametrized
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_reparametrized(const struct CadaclysmBlacksmithNurbsCurve *curve,
double lo,
double hi);
curve over the domain [lo, hi] (Rhino's Reparameterize / setting Domain): the same points, the parameter mapped affinely. Null and last_error for lo >= hi or a bound that is not finite.
cadaclysm_blacksmith_nurbs_curve_uniform
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_uniform(const struct CadaclysmBlacksmithNurbsCurve *curve);
curve's control points and weights over evenly spaced knots on its domain (Rhino's MakeUniform): clamped where it was clamped, a periodic curve kept periodic. The shape moves unless the knots were uniform already.
cadaclysm_blacksmith_nurbs_curve_non_rational
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_non_rational(const struct CadaclysmBlacksmithNurbsCurve *curve);
curve with every weight 1 and its control points where they were (Rhino's MakeNonRational): exact where the weights were all equal, otherwise a plain B-spline through the same control polygon. (Every curve here is already a NURBS, so Rhino's MakeRational has nothing to do.)
cadaclysm_blacksmith_nurbs_curve_greville
bool cadaclysm_blacksmith_nurbs_curve_greville(const struct CadaclysmBlacksmithNurbsCurve *curve,
double *params,
double *xyz);
The Greville abscissae (each control point's parameter, the mean of the degree knots after its first) into params and the curve's points there into xyz, one per control point (control_count doubles and 3 * control_count doubles); either may be NULL to skip it. False and last_error for a null curve.
cadaclysm_blacksmith_nurbs_curve_periodic
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_periodic(const struct CadaclysmBlacksmithNurbsCurve *curve,
bool smooth);
A periodic curve (seamless, C^(degree-1) all round) of the same degree from curve (Rhino's CreatePeriodicCurve); a closed curve's repeated last control point is dropped first, and a curve already periodic comes back as it is. smooth false keeps the control points and weights and rewrites only the knots: the polygon wrapped over uniform knots on [0, m] for m points (the curve no longer reaches the old ends). smooth true keeps close to the curve instead: a plain periodic curve through its Greville points, on [0, 1] by chord length. Null and last_error (prefixed nurbs_curve_periodic: ) for fewer than degree + 1 distinct control points.
cadaclysm_blacksmith_nurbs_curve_mean
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_mean(const struct CadaclysmBlacksmithNurbsCurve *a,
const struct CadaclysmBlacksmithNurbsCurve *b,
double tolerance);
The curve halfway between a and b (Rhino's CreateMeanCurve): b lined up with a first (turned, a closed one's seam moved), the two made compatible exactly and averaged in homogeneous coordinates — two arcs about one centre give the arc of the mean radius. The matching tween at 1/2. tolerance 0 or NaN: the curves' effective tolerance (how far apart a curve's ends may be and still close it). Null and last_error (prefixed nurbs_curve_mean: ) for one curve closed and the other open.
cadaclysm_blacksmith_nurbs_curve_lined_up
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_lined_up(const struct CadaclysmBlacksmithNurbsCurve *a,
const struct CadaclysmBlacksmithNurbsCurve *b,
double tolerance);
b lined up with a: an open b turned where its ends lie crosswise to a's, a closed one turned where it runs the other way round and its seam moved to the point that lies, from its centre, the way a's start lies from a's — the same point set either way. b as it is where one is closed and the other open. tolerance 0 or NaN: the curves' effective tolerance (for closing).
cadaclysm_blacksmith_nurbs_curve_directions_match
int32_t cadaclysm_blacksmith_nurbs_curve_directions_match(const struct CadaclysmBlacksmithNurbsCurve *a,
const struct CadaclysmBlacksmithNurbsCurve *b,
double tolerance);
Whether b runs the same way as a (Rhino's DoDirectionsMatch): two closed curves going round the same way (their area vectors on one side), otherwise b's ends lying along a's rather than crosswise — exactly where cadaclysm_blacksmith_nurbs_curve_lined_up would not turn b. 1 yes, 0 no, -1 and last_error for a null curve, a curve with no domain, or a closed curve with no area. tolerance as lined_up's.
cadaclysm_blacksmith_nurbs_curve_conic_type
int32_t cadaclysm_blacksmith_nurbs_curve_conic_type(const struct CadaclysmBlacksmithNurbsCurve *curve,
double tolerance);
Which conic curve is, read from its points within tolerance (Rhino's GetConicSectionType): CADACLYSM_BLACKSMITH_CONIC_NONE (0) for a curve that is not one (straight, two lines through a corner, not planar, or off every conic by more than tolerance), _CIRCLE (1), _ELLIPSE (2), _HYPERBOLA (3) or _PARABOLA (4). Any exact form reads the same: a circle elevated to degree 5 is a circle. tolerance 0 or NaN: the curve's effective tolerance. -1 and last_error for a null curve or a negative tolerance.
cadaclysm_blacksmith_curve_list_count
uint32_t cadaclysm_blacksmith_curve_list_count(const struct CadaclysmBlacksmithCurveList *list);
How many curves list holds; 0 (and last_error) for a null list.
cadaclysm_blacksmith_curve_list_curve
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_curve_list_curve(const struct CadaclysmBlacksmithCurveList *list,
uint32_t i);
A copy of curve i of list, owned by the caller (free it with cadaclysm_blacksmith_nurbs_curve_free). Null (and last_error) for a null list or i past the count.
cadaclysm_blacksmith_curve_list_info
bool cadaclysm_blacksmith_curve_list_info(const struct CadaclysmBlacksmithCurveList *list,
uint32_t i,
struct CadaclysmBlacksmithCurveInfo *out);
Curve i's facts into out. false (and last_error) for a null list or out, or i past the count.
cadaclysm_blacksmith_curve_list_free
void cadaclysm_blacksmith_curve_list_free(struct CadaclysmBlacksmithCurveList *list);
Release list; null is a no-op.
cadaclysm_blacksmith_nurbs_curve_spiral
struct CadaclysmBlacksmithNurbsCurve *cadaclysm_blacksmith_nurbs_curve_spiral(const double *axis,
const double *start,
double pitch,
double turns,
double end_radius,
double *error_out);
A helix or spiral as a curve (Rhino's NurbsCurve.CreateSpiral): about axis (a point on it and its direction, six doubles; the direction need not be unit) from start, turning the right-hand way about the direction and climbing pitch along it each turn (negative climbs the other way, 0 is flat) for turns turns, its radius running linearly with the angle from start's distance from the axis to end_radius — NaN or negative: the same, a helix. A start on the axis takes revolve's reference direction. A C2 quintic, 16 spans a turn, through the exact spiral at every span end and over the angle in radians; its largest distance from the exact spiral (about 8e-8 of the radius on a helix) goes to error_out when that is not NULL. Null (and last_error) for an axis direction zero or not finite, turns not positive and finite, pitch not finite, both radii zero.
cadaclysm_blacksmith_nurbs_curve_length_between
bool cadaclysm_blacksmith_nurbs_curve_length_between(const struct CadaclysmBlacksmithNurbsCurve *curve,
double t0,
double t1,
double accuracy,
struct CadaclysmBlacksmithLength *out);
The length of curve over [t0, t1] of its parameter (Rhino's GetLength(subdomain)) to a relative accuracy (0 or less: the default) into out. Refused for a range running backwards or outside the domain.
cadaclysm_blacksmith_nurbs_curve_point_at_normalized_length
bool cadaclysm_blacksmith_nurbs_curve_point_at_normalized_length(const struct CadaclysmBlacksmithNurbsCurve *curve,
double f,
double accuracy,
struct CadaclysmBlacksmithAt *out);
The point at the fraction f of curve's length, f in [0, 1] (Rhino's PointAtNormalizedLength; the At's parameter is NormalizedLengthParameter's answer) into out (segment NONE). 0 is the start and 1 the end exactly.
cadaclysm_blacksmith_nurbs_curve_points_at_normalized_lengths
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_points_at_normalized_lengths(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *f,
uint32_t n,
double accuracy);
The points at each of the n fractions f of curve's length, in the order given, over one measure of it (Rhino's NormalizedLengthParameters).
cadaclysm_blacksmith_nurbs_curve_divide_equidistant
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_divide_equidistant(const struct CadaclysmBlacksmithNurbsCurve *curve,
double distance);
Points along curve each distance in a straight line from the one before (Rhino's DivideEquidistant): the first the curve's start, each next the first point further on that is distance from the last, until none is; a closed curve does not wrap. Each sample's error is how far its chord is from distance.
cadaclysm_blacksmith_nurbs_curve_divide_as_contour
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_nurbs_curve_divide_as_contour(const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *from,
const double *to,
double interval);
Where curve crosses the planes square to to - from through from and every interval on towards to (Rhino's DivideAsContour), in the curve's parameter order; a plane the curve lies in gives none. Each sample's error is its distance from its plane.
cadaclysm_blacksmith_nurbs_curve_mass
bool cadaclysm_blacksmith_nurbs_curve_mass(const struct CadaclysmBlacksmithNurbsCurve *curve,
double accuracy,
struct CadaclysmBlacksmithLengthMass *out);
curve's length mass properties to a relative accuracy (0 or less: the default) into out: see CadaclysmBlacksmithLengthMass.
cadaclysm_blacksmith_nurbs_curve_face_isocurves
struct CadaclysmBlacksmithCurveList *cadaclysm_blacksmith_nurbs_curve_face_isocurves(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
bool along_u,
double at,
double tolerance);
The pieces of face face's isocurve that lie inside its trims (Rhino's TrimAwareIsoCurve), in order along it: along u at v = at when along_u, else along v at u = at. Exact on every surface kind (a sampled profile's falls back to a fit at tolerance); each piece's ends are polished onto the edges they meet, and its error is the larger of its fit error and those ends' distance from their edges. A periodic seam is crossed in one piece. An at the face never reaches gives an empty list.
tolerance 0 or NaN: the solid's effective tolerance.
cadaclysm_blacksmith_nurbs_curve_is_isoparametric
int32_t cadaclysm_blacksmith_nurbs_curve_is_isoparametric(const struct CadaclysmBlacksmithNurbsCurve *curve,
const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double tolerance,
double *at_out);
Whether curve runs along one of face face's isocurves (Rhino's IsIsoparametric): 1 along u (v held, its value to at_out), 2 along v (u held), 0 neither or not on the face, -1 (and last_error) refused. Read back into the face's parameters at tolerance, the curve is an isocurve where its parameter spread across the held direction is within tolerance in space.
tolerance 0 or NaN: the solid's effective tolerance.
cadaclysm_blacksmith_solid_section_curves
struct CadaclysmBlacksmithCurveList *cadaclysm_blacksmith_solid_section_curves(const struct CadaclysmBlacksmithSolid *solid,
const double *origin,
const double *normal,
double tolerance);
solid cut by the plane through origin square to normal, as curves in space (Rhino's Intersection.BrepPlane): each closed section loop one closed curve, an open sheet's crossing one open curve. A crossing on a line, circle, ellipse or NURBS is that curve exactly; any other a cubic fitted at tolerance (its error says how far). A face lying in the plane gives its own edges, exactly, as the section there. A plane missing the solid gives an empty list.
tolerance 0 or NaN: the solid's effective tolerance.
cadaclysm_blacksmith_solid_contour_curves
struct CadaclysmBlacksmithCurveList *cadaclysm_blacksmith_solid_contour_curves(const struct CadaclysmBlacksmithSolid *solid,
const double *from,
const double *to,
double interval,
double tolerance);
solid cut by the planes square to to - from through from and every interval on towards to (Rhino's Brep.CreateContourCurves), as cadaclysm_blacksmith_solid_section_curves cuts by one: every plane's curves in plane order, each one's plane its index. Refused for from and to the same point, an interval not positive and finite, more than 10,000 planes.
tolerance 0 or NaN: the solid's effective tolerance.
Surfaces from curves
cadaclysm_blacksmith_sweep_rail
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sweep_rail(const struct CadaclysmBlacksmithNurbsCurve *rail,
const struct CadaclysmBlacksmithNurbsCurve *const *sections,
size_t count,
uint32_t frame,
const double *up,
double tolerance,
double *error_out);
count sections swept along rail, each carried by the rail's frame from the rail point nearest its centre and blended between: frame 0 rotation-minimising, 1 keeping up (three doubles) upright. Fitted within tolerance; the error reached to error_out when not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_sweep_two_rails
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_sweep_two_rails(const struct CadaclysmBlacksmithNurbsCurve *rail_a,
const struct CadaclysmBlacksmithNurbsCurve *rail_b,
const struct CadaclysmBlacksmithNurbsCurve *const *sections,
size_t count,
double tolerance,
double *error_out);
count sections swept between rail_a and rail_b: each section's first end on rail a and last on rail b, carried by the rotation and uniform scale that keep them there, the rails matched by arc length. Fitted within tolerance; the error to error_out when not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_network_surface
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_network_surface(const struct CadaclysmBlacksmithNurbsCurve *const *u_curves,
size_t u_count,
const struct CadaclysmBlacksmithNurbsCurve *const *v_curves,
size_t v_count,
double tolerance,
double *error_out);
The Gordon sheet of a curve network: u_count curves along u (in order across v) and v_count along v, every u curve crossing every v curve within tolerance. The largest distance from the sheet to the curves to error_out when not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Continuity
cadaclysm_blacksmith_continuity
bool cadaclysm_blacksmith_continuity(const struct CadaclysmBlacksmithSolid *a,
uint32_t face_a,
uint32_t side_a,
const struct CadaclysmBlacksmithSolid *b,
uint32_t face_b,
uint32_t side_b,
uint32_t samples,
struct CadaclysmBlacksmithContinuity *out);
How well face face_a of a meets face face_b of b along their sides (a side: 0 the face's u = 0 isocurve, 1 u = 1, 2 v = 0, 3 v = 1), from samples points along side a (16 at fewest), into out. Both faces NURBS.
cadaclysm_blacksmith_surface_faired
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_surface_faired(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double tolerance,
uint32_t degree,
uint32_t controls_u,
uint32_t controls_v,
const int32_t *keep,
uint32_t no_inflection,
double *error_out);
Face face of solid faired, as a sheet of its own: the smoothest surface within tolerance of its NURBS surface — least squares plus the third derivatives squared across it (a zebra's ripple), weighed as heavily as the tolerance allows. Where a sheet lofted through traced sections wobbles between them, this spends the tolerance on smoothness.
controls_u and controls_v both 0 fair on the face's own net, its degree raised to degree (3 to 7) and its spans split to a dozen at least each way: a kept side is then kept exactly. Otherwise the fair is a uniform B-spline of degree with that many control points each way, its kept sides within the tolerance. keep holds four ints, one per side (0 the face's u = 0 isocurve, 1 u = 1, 2 v = 0, 3 v = 1): -1 the side is free to move, 0 its position is kept, 1 the tangent plane across it too, 2 the curvature across it too — what cadaclysm_blacksmith_match_side gave it with a neighbour. NULL keeps every side at 2. no_inflection bit 1 holds the isocurves along u from turning their curvature over (each bends to the side it bends to most), bit 2 those along v: the surface form of cadaclysm_blacksmith_nurbs_curve_fair's span, what turns a sheet lofted through wobbly sections into a dome. The largest distance found between the two surfaces (both ways) is written to error_out when that is not NULL. Refused where even the least smoothing — held, where asked — is not within the tolerance.
tolerance 0 or NaN: the solid's effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_curvature_turns
bool cadaclysm_blacksmith_curvature_turns(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
uint32_t samples,
struct CadaclysmBlacksmithCurvatureTurns *out);
Where face face of solid's Gaussian and mean curvature change sign, on a grid of samples steps each way over its surface's domain (8 at fewest), into out. Any kind of surface: a NURBS face's curvature is exact, another's differenced.
cadaclysm_blacksmith_curvature_turn_points
struct CadaclysmBlacksmithSamples *cadaclysm_blacksmith_curvature_turn_points(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
uint32_t samples,
bool mean);
The points cadaclysm_blacksmith_curvature_turns finds between the signs of face face's Gaussian curvature (mean false) or mean curvature (mean true), as a list of At: one at every pair of neighbouring samples of opposite sign, on the line between them — the point, the face's unit normal there as tangent, the face's u there as parameter (error zero). An empty list is a face whose curvature keeps one sign.
cadaclysm_blacksmith_highlight_kink
bool cadaclysm_blacksmith_highlight_kink(const struct CadaclysmBlacksmithSolid *solid,
uint32_t edge,
uint32_t samples,
struct CadaclysmBlacksmithHighlightKink *out);
The worst kink of the highlight lines crossing edge edge of solid (the index cadaclysm_blacksmith_edge_curve takes), at samples points along it (16 at fewest), into out. The highlight lines are those of straight light tubes parallel to the surface a body's size away (its box's diagonal), every tube direction tried at every point: they run on through an edge where the two faces' curvatures agree (G2) and kink where the curvature jumps — a fillet's seam with a flat face among them, where an isophote would read nothing on the flat side. Beside cadaclysm_blacksmith_edge_continuity's curvature jump, this is the number a zebra shows. Refused for an edge that does not bound exactly two faces.
cadaclysm_blacksmith_match_side
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_match_side(const struct CadaclysmBlacksmithSolid *a,
uint32_t face_a,
uint32_t side_a,
const struct CadaclysmBlacksmithSolid *b,
uint32_t face_b,
uint32_t side_b,
uint32_t level);
Face face_a of a, its side bent to meet face face_b of b's side at Glevel (0 position, 1 tangent plane, 2 curvature), as a sheet of its own; the opposite side stays where it was. Both faces non-rational NURBS.
cadaclysm_blacksmith_blend_sides
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_blend_sides(const struct CadaclysmBlacksmithSolid *a,
uint32_t face_a,
uint32_t side_a,
const struct CadaclysmBlacksmithSolid *b,
uint32_t face_b,
uint32_t side_b,
uint32_t level,
double bulge);
A sheet spanning from face face_a of a's side to face face_b of b's, meeting each at Glevel (1 or 2); bulge (positive, 1 usual) scales how far it leaves each edge along its neighbour's tangent. Both faces non-rational NURBS.
cadaclysm_blacksmith_n_sided_patch
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_n_sided_patch(const struct CadaclysmBlacksmithPatchBoundary *boundaries,
size_t count,
double bulge,
double tolerance,
struct CadaclysmBlacksmithPatchReport *report_out);
The N-sided patch filling the hole count (3 or more) boundaries bound, meeting end to end within tolerance: N four-sided NURBS faces round a central point, one sheet, face i meeting boundary i's second half along its v = 0 side and boundary i + 1's first half along its u = 1 side, the faces G1 or G2 to each other. bulge (positive, 1 usual) scales how far the patch leaves each neighbour along the neighbour's own tangent. The report to report_out when not NULL. The patch declares the loosest tolerances its sheets declare.
tolerance 0 or NaN: the sheets' effective tolerance (see cadaclysm_blacksmith_effective_tolerance), or the curves' when every boundary is a curve.
cadaclysm_blacksmith_fillet_surfaces
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_fillet_surfaces(const struct CadaclysmBlacksmithSolid *a,
uint32_t face_a,
const struct CadaclysmBlacksmithSolid *b,
uint32_t face_b,
double radius_start,
double radius_end,
bool flip_a,
bool flip_b,
double tolerance,
struct CadaclysmBlacksmithNurbsCurve **rail_a,
struct CadaclysmBlacksmithNurbsCurve **rail_b,
double *error_out);
The rolling-ball fillet between face face_a of a and face face_b of b (their whole NURBS surfaces): the ball on the side of each face's normal (flip_*: the other side), its radius radius_start at the fillet's first end running linearly to radius_end at its last, fitted within tolerance. Returns the fillet sheet; the contact curves on each face are written to rail_a / rail_b when those are not NULL (owned: free with cadaclysm_blacksmith_nurbs_curve_free), the error reached to error_out when not NULL.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Trim by a curve, join sheets, recess an opening, mirror a half
cadaclysm_blacksmith_split_by_curve
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_split_by_curve(const struct CadaclysmBlacksmithSolid *sheet,
const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *direction,
double tolerance);
sheet cut along curve and nothing removed: every face comes back in its pieces outside the cutter, then its pieces inside, each piece a face, in sheet's face order. The cutter is curve run along direction (three doubles; NULL for the mean of the sheet's normals along the curve) through the whole sheet: a closed curve's inside is the island it bounds, an open curve's the side left of its run seen from where direction points. An open curve is run on straight past both ends, so it should cross the sheet's boundary or point at it. Where the cut lies on curve (a curve drawn on the sheet) the rim is one edge carrying the curve's own span exactly, its ends on the curve, which another sheet's edge along the curve sews to. tolerance is the split's meshing tolerance.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_split_along_curve
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_split_along_curve(const struct CadaclysmBlacksmithSolid *sheet,
const struct CadaclysmBlacksmithNurbsCurve *curve,
double tolerance);
sheet split along curve, a curve lying on it, with no direction to cut along: each face is cut in its own parameters where the curve crosses it, so a cut across a sheet that rolls away from any one view never glances off it. Nothing is removed: every face comes back as its pieces, face by face, those left of the curve's run (seen from the faces' outward side) first. A closed curve cuts an island; an open one must run off the sheet — one stopping short is carried on along the sheet along its end tangent. Where the cut lies on curve the rim is one edge carrying the curve's own span exactly (a closed curve round on one face, two), which another sheet's edge along the curve sews to. Refused where the curve stands off the sheet by more than ten times tolerance, or a face of the sheet closes round on itself.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_panel_gap
bool cadaclysm_blacksmith_panel_gap(const struct CadaclysmBlacksmithSolid *sheet,
const struct CadaclysmBlacksmithNurbsCurve *curve,
double gap,
double flange,
double tolerance,
struct CadaclysmBlacksmithSolid **out);
sheet cut along curve (lying on it) into two panels with a shut line between them — a car body's panel gap: each panel trimmed back gap / 2 from the curve, measured along the sheet, and given a flange on the edges it was cut back to (not the sheet's own edges): a ruled face from the edge to the edge moved flange along the faces' outward normals, negative turning it under for a sheet whose normals face out, 0 for none. Where the curve runs off the sheet each flange ends square at its panel's corner. The panel left of the curve's run (seen from the faces' outward side) goes to out[0], the right one to out[1]; a loop run counter-clockwise from that side has the island on its left. Works across the faces of a joined sheet. true on success; false and last_error otherwise, nothing written to out.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_trim_by_curve
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_trim_by_curve(const struct CadaclysmBlacksmithSolid *sheet,
const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *direction,
bool keep_inside,
double tolerance);
sheet cut along curve and one side thrown away: keep_inside true keeps the island a closed curve bounds (the side left of an open curve's run), false the rest — a hole cut, or the other side. See cadaclysm_blacksmith_split_by_curve. Refused where nothing of the sheet lies on the kept side.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_recess
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_recess(const struct CadaclysmBlacksmithSolid *sheet,
const struct CadaclysmBlacksmithNurbsCurve *outline,
double depth,
double draft,
double fillet,
bool pane,
double tolerance,
uint32_t *faces_out);
sheet with an opening recessed into it — a window, a lamp, a grille or an intake set into a panel. outline is a closed curve on the sheet (one face or several joined); each of its points is found on the sheet, so it may stand a little off it. The sheet is cut along it and walls run back depth along the sheet's own normal at every point of the rim (positive behind the face, against its normal; negative in front), leaning in toward the opening by draft radians as they go (negative: out; within 75 degrees), the walls meeting on the mitre at the outline's corners. fillet above 0 rounds the rim between the sheet and the walls with a ball of that radius (the outline must then be smooth, and the fillet shallower than the walls). pane closes the back with one patch whose four sides end where the outline turns most — a rectangle's corners, the middle of a rounded rectangle's corner arcs — so it does not twist. Every piece is sewn to the next: one body, its faces in order — the sheet's, the fillet's, the walls', the pane's — with only the sheet's own boundary naked, and the walls' foot without a pane. faces_out, when not NULL, gets those four face counts. tolerance is the fits', the cut's and the sewing's. Refused for an outline that is not closed, a corner with a fillet, a fillet deeper than the walls, and a sheet the outline cannot be found on.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_mirror_join
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_mirror_join(const struct CadaclysmBlacksmithSolid *half,
const double *plane,
double snap,
double tolerance,
double *report_out);
half and its reflection across plane joined into one symmetric body — half a car, a hull or a bottle modelled once and mirrored, with no crease on the plane. plane is a frame (twelve doubles: origin, x, y, z), its z the plane's normal. With snap above 0, every NURBS face of the half that is its whole surface and has a side whose control points all lie within snap of the plane is squared to it first: that side pulled onto the plane and the next row of control points stood straight off it along the normal, keeping its distance from the plane, so the surface crosses the plane at 90 degrees and meets its mirror tangent and curvature continuous; nothing past that row moves. snap 0 mirrors the half as it is. The half and its mirror are then sewn within tolerance, the half's faces first. report_out, when not NULL, gets seven doubles: the seam edges (one face from each half), the faces squared, the furthest a control point moved, the seam's worst gap, angle between the faces' normals (radians) and difference of their normal curvatures across it, and the naked edges left on the body. Refused for a half lying on both sides of the plane, no edge of it on the plane (none sewn to its mirror), and a face that cannot be squared: its next row on the plane or past it, or rational with weights across the side not in one ratio.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_join_sheets
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_join_sheets(const struct CadaclysmBlacksmithSolid *const *sheets,
size_t count,
double tolerance,
struct CadaclysmBlacksmithJoinReport *report);
count sheets joined into one body, their faces in order: every two naked edges whose ends and curves agree within tolerance (0 or NaN: a rounding of the body's size, or the loosest absolute tolerance the sheets declare where that is larger) sewn into one edge — a gap closed is kept as that edge's own tolerance — the faces turned to agree across their edges, and a closed result turned to face out, a solid the booleans, the measures and the writers take. Edges that carry exact curves are compared to the tolerance however coarsely each was sampled. What was done is written to report when it is not NULL. At a tolerance above 0 a T-junction is sewn too: one sheet's edge along part of another's is first cut where the other's corner lies on it, and its pieces are sewn. Refused for no sheets, a negative or infinite tolerance, and faces that cannot be turned to agree (a one-sided surface).
Walls from a sheet's edges
cadaclysm_blacksmith_flange
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_flange(const struct CadaclysmBlacksmithSolid *sheet,
const uint32_t *edges,
size_t count,
const struct CadaclysmBlacksmithNurbsCurve *section,
double tolerance,
bool join,
double *error_out);
section swept along each of the count naked edges of sheet (indices into the list cadaclysm_blacksmith_edge walks) on the face's own frame: at every point of the edge the section's x runs outward from the face (square to the edge, in the face's tangent plane) and its y along the face's normal, so (0, 0) -> (0, -10) turns the edge under by 10 all along it however the face curves. section is a curve in the plane z = 0 starting at the origin. The sweeps are sewn to sheet when join (the sheet's faces first, then one per edge), else returned alone, sewn to each other. Each sweep is fitted within tolerance; the largest error to error_out when not NULL. Refused for no edges, an edge given twice, out of range, bordered by two faces or without an exact curve, a section not starting at the origin, and sweeps the join did not sew on.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Holes, ribs and webs, patterns
cadaclysm_blacksmith_pattern_rectangular
uint32_t cadaclysm_blacksmith_pattern_rectangular(const double *direction1,
uint32_t count1,
double spacing1,
const double *direction2,
uint32_t count2,
double spacing2,
bool symmetric,
const uint32_t *skip,
uint32_t skip_count,
double *out);
A rectangular pattern's placements: count1 instances spacing1 apart along direction1 (three doubles, normalised), times count2 spacing2 apart along direction2 — or one row when direction2 is NULL (count2 then 1). Row-major, direction 1 fastest, instance 0 the identity. symmetric puts count on each side of the original along each direction (2 count - 1, at offsets 0, +s, -s, +2s, -2s, ...). skip, skip_count indices, leaves instances out (Fusion's suppressed instances), 0 included.
Returns the count of placements, writing 16 doubles each to out; with out NULL it writes nothing, so call it twice: once to size the buffer, once to fill it. A non-null out must hold the whole count. 0 (and last_error) when refused: a count of 0, a spacing not finite, a zero direction, a skip past the count, every instance skipped, more than 100000 instances.
cadaclysm_blacksmith_pattern_circular
uint32_t cadaclysm_blacksmith_pattern_circular(const double *axis,
uint32_t count,
double angle,
bool symmetric,
const uint32_t *skip,
uint32_t skip_count,
double *out);
A circular pattern's placements about axis (six doubles: a point, a direction): a full turn (angle 2 pi) spaces count evenly; less than a full turn spreads count over angle with both ends occupied. symmetric spreads count over angle on each side (2 count - 1, at 0, +a, -a, +2a, ...), refused with a full turn, which has no sides. Angles in radians, right-handed about the direction. skip as in cadaclysm_blacksmith_pattern_rectangular.
Returns the count, with the two-call convention of cadaclysm_blacksmith_pattern_rectangular; 0 (and last_error) when refused: count 0, a zero axis, an angle not in (0, 2 pi], the skips, more than 100000 instances.
cadaclysm_blacksmith_pattern_along
uint32_t cadaclysm_blacksmith_pattern_along(const struct CadaclysmBlacksmithNurbsCurve *curve,
uint32_t count,
double spacing,
uint32_t orient,
const uint32_t *skip,
uint32_t skip_count,
double *out);
A pattern's placements along curve: count instances by arc length from its start, spacing apart — or, with spacing NaN, spread over the curve's whole length with both ends occupied. Each moves the original by its point less the start; orient CADACLYSM_BLACKSMITH_ORIENT_PATH also turns it by the curve's rotation-minimising frame from the first instance's (CADACLYSM_BLACKSMITH_ORIENT_FIXED translates only). skip as in cadaclysm_blacksmith_pattern_rectangular.
Returns the count, with the two-call convention of cadaclysm_blacksmith_pattern_rectangular; 0 (and last_error) when refused: count 0, a spacing not positive, count - 1 spacings past the curve's length, a curve of zero length, an unknown orient, the skips, more than 100000 instances.
cadaclysm_blacksmith_pattern
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_pattern(const struct CadaclysmBlacksmithSolid *solid,
const double *transforms,
uint32_t count,
double tolerance,
double *report_out);
solid and its copies at count placements (transforms, 16 doubles each, rigid) as one body — a pattern of bodies. Copies apart from each other are put together with no boolean at all; copies that overlap are joined, one boolean a group. report_out, when not NULL, gets three doubles: the instances placed, the booleans run, and 0 (no copy of a body misses). Refused: no transforms, one not rigid.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_pattern_feature
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_pattern_feature(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithSolid *tool,
uint32_t op,
const double *transforms,
uint32_t count,
double tolerance,
double *report_out);
tool (any closed solid, typically a _tool call's result) placed at each of count placements and applied to solid by op — CADACLYSM_BLACKSMITH_FEATURE_CUT or CADACLYSM_BLACKSMITH_FEATURE_JOIN — a pattern of features. Copies apart from each other go into one multi-lump tool and one boolean; overlapping copies fall into a few groups. A copy that shares no volume with the body is missed: dropped for a cut, kept as a body of its own for a join. A cut where every copy misses returns the body unchanged, with 0 booleans. report_out, when not NULL, gets three doubles: instances, booleans, missed. Refused: no transforms, one not rigid, a tool that is not closed, an unknown op.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_hole
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_hole(const struct CadaclysmBlacksmithSolid *solid,
const double *points,
uint32_t count,
double diameter,
const double *direction,
uint32_t extent,
double depth,
double tip_angle,
uint32_t face,
uint32_t head,
double head_diameter,
double head_depth,
double head_angle,
double tolerance,
double *report_out,
double *bottoms_out);
solid drilled at each of count points (points, three doubles each) with one hole, all in one cut. The bore is an exact cylinder of diameter; direction (three doubles, into the material, shared by every point) or, when NULL, each point's face's inward normal there — each point must then lie on a face (on an edge, the lowest-numbered face's normal).
extent: CADACLYSM_BLACKSMITH_HOLE_THROUGH through everything ahead; CADACLYSM_BLACKSMITH_HOLE_BLIND depth of full bore from the point, then a drill point of included angle tip_angle (0 or pi: a flat bottom); CADACLYSM_BLACKSMITH_HOLE_TO_FACE until the axis first meets face face, the bore ending on it; CADACLYSM_BLACKSMITH_HOLE_TO_NEXT until the bore first leaves the material. depth is NaN (or 0) and face CADACLYSM_BLACKSMITH_NONE unless their extent asks for them.
head: CADACLYSM_BLACKSMITH_HOLE_SIMPLE; CADACLYSM_BLACKSMITH_HOLE_COUNTERBORE, a bore head_diameter across and head_depth deep; CADACLYSM_BLACKSMITH_HOLE_COUNTERSINK, a cone head_diameter across at the point of included angle head_angle — measured from the point. Angles in radians.
cadaclysm_blacksmith_hole_tool
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_hole_tool(const struct CadaclysmBlacksmithSolid *solid,
const double *points,
uint32_t count,
double diameter,
const double *direction,
uint32_t extent,
double depth,
double tip_angle,
uint32_t face,
uint32_t head,
double head_diameter,
double head_depth,
double head_angle,
double tolerance);
The tool cadaclysm_blacksmith_hole cuts with, from the same arguments: a closed solid, one lump a point, each the hole's half section revolved — for cadaclysm_blacksmith_pattern_feature or a boolean of the caller's own. Refused as cadaclysm_blacksmith_hole is, but for a hole that removes nothing.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_rib
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_rib(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *plane,
double thickness,
uint32_t side,
const double *toward,
double tolerance);
solid with a rib along curve — an open curve lying in plane (a frame, twelve doubles: origin, x, y, z). The rib fills the region of the plane between the curve and the body on the toward side (three doubles, a direction in the plane; NULL: from the curve's midpoint toward the body's nearest point), the curve's ends carried on along their tangents to the body, thickened thickness along the plane's normal: side CADACLYSM_BLACKSMITH_RIB_BOTH half each side, CADACLYSM_BLACKSMITH_RIB_FRONT on +z, CADACLYSM_BLACKSMITH_RIB_BACK on -z. One join. Refused: the curve closed or not in the plane; a thickness not positive; an unknown side; the slab meeting nothing; a region not closed by the body on the toward side.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_rib_tool
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_rib_tool(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *plane,
double thickness,
uint32_t side,
const double *toward,
double tolerance);
The slab cadaclysm_blacksmith_rib joins, alone, from the same arguments.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_rib_revolved
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_rib_revolved(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *axis,
double angle,
const double *toward,
double tolerance);
solid with a revolved rib: the region cadaclysm_blacksmith_rib would fill, drawn in the plane holding axis (six doubles: a point and a direction) and curve (open, in that plane), clipped to the curve's side of the axis and swung angle radians about it, symmetric about the curve's plane. toward as cadaclysm_blacksmith_rib's. One join. Refused: an angle not in (0, 2 pi); the axis's direction zero; the curve closed or not in one plane with the axis; the slab meeting nothing; a region not closed by the body on the toward side.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_rib_revolved_tool
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_rib_revolved_tool(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithNurbsCurve *curve,
const double *axis,
double angle,
const double *toward,
double tolerance);
The solid cadaclysm_blacksmith_rib_revolved joins, alone, from the same arguments.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_web
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_web(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithNurbsCurve *const *curves,
uint32_t count,
const double *plane,
double thickness,
uint32_t side,
double depth,
bool both_ways,
double tolerance);
solid with a web along each of count curves — open curves lying in plane (a frame, twelve doubles). Each is offset in the plane to thickness: side CADACLYSM_BLACKSMITH_WEB_BOTH half each side, CADACLYSM_BLACKSMITH_WEB_LEFT or CADACLYSM_BLACKSMITH_WEB_RIGHT of the curve's run (the plane's normal up); its ends carried along their tangents to the body; its walls run along the plane's normal until they meet the body (depth NaN) or for depth, one way (the normal's) or both when both_ways. All the webs are one tool and one join; crossing curves make a network. Refused: no curves; one closed or not in the plane; a thickness not positive; an unknown side; walls meeting nothing, or not closed by the body.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_web_tool
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_web_tool(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithNurbsCurve *const *curves,
uint32_t count,
const double *plane,
double thickness,
uint32_t side,
double depth,
bool both_ways,
double tolerance);
The walls cadaclysm_blacksmith_web joins, alone, from the same arguments.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Threads
cadaclysm_blacksmith_thread_size_count
uint32_t cadaclysm_blacksmith_thread_size_count(void);
How many rows the thread size table has: ISO metric coarse M1 .. M64, ISO metric fine M8x1 .. M64x4, UNC #1 .. 1-1/2", UNF #0 .. 1-1/2", in that order, each by ascending major.
cadaclysm_blacksmith_thread_size_at
const char *cadaclysm_blacksmith_thread_size_at(uint32_t index, double *out);
Row index of the thread size table: its designation ("M10", "M10x1.25", "1/4-20 UNC"), static and NUL-terminated, for the library's life — never freed. out, when not NULL, gets nine doubles: the family (CADACLYSM_BLACKSMITH_THREAD_ISO_METRIC_COARSE .. CADACLYSM_BLACKSMITH_THREAD_UNF), the major diameter, the pitch, the basic minor diameter D - 1.082532 P, the pitch diameter D - 0.649519 P, the tap drill D - P (the ~75 % engagement rule, not a drill chart), and ISO 273's fine, medium and coarse clearance holes (0 for a UN row or a size ISO 273 has no row for). Millimetres throughout. NULL (and last_error) past the end.
cadaclysm_blacksmith_thread_size_size
const char *cadaclysm_blacksmith_thread_size_size(uint32_t index);
Row index's size ("M10", "1/4", "#10"), static as cadaclysm_blacksmith_thread_size_at's designation. NULL (and last_error) past the end.
cadaclysm_blacksmith_thread_size_find
int32_t cadaclysm_blacksmith_thread_size_find(const char *designation);
The index of the row designation names: the exact designation first, then forgiven — case and spaces ignored, "M10" the coarse row, "M10x1.25" / "M10 x 1.25" the fine one, "1/4-20" the UNC or UNF row of that TPI. -1 (and last_error) when no row matches or designation is NULL.
cadaclysm_blacksmith_thread
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_thread(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const char *designation,
double pitch,
double diameter,
double angle,
double length,
double offset,
uint32_t flags,
double tolerance,
double *report_out);
solid with a screw thread cut into cylindrical face face — an exact cylinder, or a free-form face recognised as one at the tolerance. The face's normal says the kind: away from the axis an external thread (a rod), toward it an internal one (a bore). The cutter is one coil of a closed section of the basic ISO 68-1 profile at angle (the included flank angle, radians; NaN 60 degrees), cut in one boolean.
The form: designation, a size in the table (cadaclysm_blacksmith_thread_size_find's forgiving lookup), with pitch and diameter NaN; or designation NULL, pitch > 0 and diameter the major (NaN: the face's diameter for an external thread, the face as the basic minor for an internal one). The face must lie in the thread's band — external [D2, D + P/8], internal [D1 - P/8, D2].
The span runs along the axis from the face's open end (air past it: a rod's tip, a bore's mouth) — or, both or neither open, the end lower along the face cylinder's axis; CADACLYSM_BLACKSMITH_THREAD_REVERSE the other — after offset, for length (NaN: the rest of the face). Where it ends at an open end the groove runs out through it; elsewhere the coil stops on its own cap, under a pitch short. CADACLYSM_BLACKSMITH_THREAD_LEFT_HANDED climbs the other way.
cadaclysm_blacksmith_thread_tool
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_thread_tool(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const char *designation,
double pitch,
double diameter,
double angle,
double length,
double offset,
uint32_t flags,
double tolerance);
The cutter cadaclysm_blacksmith_thread cuts with, from the same arguments: one closed coil, for a boolean of the caller's own. Refused as cadaclysm_blacksmith_thread is, but for a cut that removes nothing.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_cosmetic_thread
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_cosmetic_thread(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
const char *designation,
double pitch,
double diameter,
double length,
double offset,
uint32_t flags,
double tolerance);
solid unchanged but for a cosmetic thread on face face: the thread validated as cadaclysm_blacksmith_thread validates it (a cylindrical face, the band, the span; the angle 60 degrees), its figures written as the face's attributes thread.designation (the row's, "" for an explicit form), thread.major, thread.pitch, thread.length, thread.offset (shortest round-trip decimal text), thread.internal, thread.left_handed, thread.reverse ("1" or "0"). Verbs carry face attributes to the faces of their results; cadaclysm_blacksmith_thread_record reads them back. Refused as cadaclysm_blacksmith_thread is, CADACLYSM_BLACKSMITH_THREAD_COSMETIC included.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_thread_record
bool cadaclysm_blacksmith_thread_record(const struct CadaclysmBlacksmithSolid *solid,
uint32_t face,
double *out,
const char **designation_out);
Whether face face carries a complete cosmetic thread record (every key of cadaclysm_blacksmith_cosmetic_thread present and parsable); false, with no last_error, when it does not. When it does, out (when not NULL) gets seven doubles — major, pitch, length, offset, internal, left_handed, reverse (the last three 1 or 0) — and designation_out (when not NULL) the designation, "" for an explicit form: borrowed, it lives as long as solid and must not be freed. False and last_error for a face the solid does not have or a NULL solid.
cadaclysm_blacksmith_hole_threaded
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_hole_threaded(const struct CadaclysmBlacksmithSolid *solid,
const double *points,
uint32_t count,
double diameter,
const double *direction,
uint32_t extent,
double depth,
double tip_angle,
uint32_t face,
uint32_t head,
double head_diameter,
double head_depth,
double head_angle,
const char *designation,
double thread_depth,
uint32_t flags,
double tolerance,
double *report_out,
double *bottoms_out,
double *thread_depths_out);
cadaclysm_blacksmith_hole tapped: its arguments up to tolerance, then the thread — designation a size in the table, thread_depth its length from where it starts (NaN: the bore's whole length), flags CADACLYSM_BLACKSMITH_THREAD_LEFT_HANDED and CADACLYSM_BLACKSMITH_THREAD_COSMETIC. A diameter of 0 is the tap drill major - pitch; a given one must lie in the internal band [D1 - P/8, D2]; a head must be wider than the major. The thread starts at the point (a counterbore's floor). Modelled, every hole's thread coil is cut in one more boolean after the holes; with CADACLYSM_BLACKSMITH_THREAD_COSMETIC the bore alone, each hole's bore face carrying a cosmetic thread record (cadaclysm_blacksmith_thread_record).
report_out and bottoms_out as cadaclysm_blacksmith_hole's; thread_depths_out, when not NULL, gets count doubles: per hole, the thread's length. Refused as cadaclysm_blacksmith_hole is, and: a NULL designation or one not in the table; an unknown flag, or CADACLYSM_BLACKSMITH_THREAD_REVERSE (a tapped hole starts at its point); a thread depth not positive or past the bore.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_hole_threaded_tool
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_hole_threaded_tool(const struct CadaclysmBlacksmithSolid *solid,
const double *points,
uint32_t count,
double diameter,
const double *direction,
uint32_t extent,
double depth,
double tip_angle,
uint32_t face,
uint32_t head,
double head_diameter,
double head_depth,
double head_angle,
const char *designation,
double thread_depth,
uint32_t flags,
double tolerance);
The tool cadaclysm_blacksmith_hole_threaded cuts with, from the same arguments: the holes' lumps, a modelled thread's coils joined into them (one more boolean, the tool's alone); with CADACLYSM_BLACKSMITH_THREAD_COSMETIC the bores alone.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
Subdivision cages
cadaclysm_blacksmith_subd_cuboid
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_cuboid(double sx,
double sy,
double sz,
uint32_t nx,
uint32_t ny,
uint32_t nz);
A box of sx x sy x sz, centred on the origin, with nx, ny, nz quads along each axis. Null (and last_error) for a size not finite and positive, or a count of 0 or over 1024.
cadaclysm_blacksmith_subd_cylinder
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_cylinder(double radius,
double height,
uint32_t sides,
uint32_t rings,
bool creased_rims);
A cylinder along +Z of radius and height: one n-gon cap per end with sides sides and rings bands of quads between them; with creased_rims the two rim loops are creased, so the caps stay flat. Null (and last_error) for a size not finite and positive, or a count out of range.
cadaclysm_blacksmith_subd_sphere
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_sphere(double radius,
uint32_t segments);
A quad ball of radius: a cube grid with segments quads per edge, each vertex pushed out to the radius. Null (and last_error) for a radius not finite and positive, or segments out of range.
cadaclysm_blacksmith_subd_torus
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_torus(double major,
double minor,
uint32_t around,
uint32_t tube);
A torus around +Z: around steps about the axis at major, tube steps round the tube of minor, all quads. Null (and last_error) for sizes not finite and positive, or counts out of range.
cadaclysm_blacksmith_subd_from_parts
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_from_parts(const double *positions,
uint32_t vertex_count,
const uint32_t *face_sizes,
uint32_t face_count,
const uint32_t *face_indices,
uint32_t index_count,
const uint32_t *creases,
uint32_t crease_count,
const uint32_t *pins,
uint32_t pin_count,
int32_t symmetry_axis,
double symmetry_tolerance);
A cage from its parts, the lossless inverse of cadaclysm_blacksmith_subd_parts (see CadaclysmBlacksmithSubdParts for each array's shape): a saved cage, a mirrored half included, loads back equal. symmetry_tolerance is ignored when symmetry_axis is -1. The new handle selects nothing. Null (and last_error, naming the parameter) for vertex_count 0, a null array with a positive count, face_sizes that do not sum to index_count, or symmetry_axis not -1, 0, 1 or 2; null with the kernel's own words for a cage it refuses (an index out of range, a face of fewer than three vertices, a non-manifold edge, a crease that is not an edge, a half that does not weld to its reflection).
cadaclysm_blacksmith_subd_parts
bool cadaclysm_blacksmith_subd_parts(const struct CadaclysmBlacksmithSubd *subd,
struct CadaclysmBlacksmithSubdParts *out);
subd's parts into out, as views valid until subd is freed. false (and last_error) for a null subd or out.
cadaclysm_blacksmith_subd_free
void cadaclysm_blacksmith_subd_free(struct CadaclysmBlacksmithSubd *subd);
Release a cage. Null is a no-op. Views from cadaclysm_blacksmith_subd_parts and cadaclysm_blacksmith_subd_smooth_mesh die with it.
cadaclysm_blacksmith_subd_transform
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_transform(const struct CadaclysmBlacksmithSubd *subd,
uint32_t kind,
const uint32_t *ids,
uint32_t id_count,
const double *matrix);
A new cage with the selected elements moved by matrix (16 doubles, column-major; a rotation about a point is baked in by the caller). kind is 0 vertices, 1 edges, 2 faces; ids is id_count elements, an edge selection 2 * id_count vertex ids. The new handle selects the same elements. Null (and last_error) for a null subd or matrix, a null ids with a positive count, a kind out of range, or the kernel's refusal (an id not in the cage, a matrix not finite or mirroring).
cadaclysm_blacksmith_subd_set_crease
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_set_crease(const struct CadaclysmBlacksmithSubd *subd,
const uint32_t *edges,
uint32_t edge_count,
bool on);
A new cage with the edge_count edges at edges (2 * edge_count vertex ids) creased, or un-creased when on is false; the new handle selects them. Null (and last_error) for a null subd, a null edges with a positive count, or the kernel's refusal (an empty selection, a pair that is not an edge).
cadaclysm_blacksmith_subd_set_pin
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_set_pin(const struct CadaclysmBlacksmithSubd *subd,
const uint32_t *vertices,
uint32_t vertex_count,
bool on);
A new cage with the vertex_count vertices at vertices pinned (they refine as corners and stay put), or released when on is false; the new handle selects them. Null (and last_error) for a null subd, a null vertices with a positive count, or the kernel's refusal (an empty selection, a vertex not in the cage).
cadaclysm_blacksmith_subd_extrude
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_extrude(const struct CadaclysmBlacksmithSubd *subd,
const uint32_t *faces,
uint32_t face_count,
double distance);
A new cage with the face_count faces at faces pushed out by distance along each connected region's average normal, a quad wall on each boundary edge; the moved faces keep their ids and the new handle selects them. Null (and last_error) for a null subd, a null faces with a positive count, or the kernel's refusal.
cadaclysm_blacksmith_subd_inset
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_inset(const struct CadaclysmBlacksmithSubd *subd,
const uint32_t *faces,
uint32_t face_count,
double amount,
bool individual);
A new cage with the face_count faces at faces shrunk by amount, in (0, 1), within their surface and a ring of quads round each region (each face, with individual); the new handle selects the inner faces. Null (and last_error) for a null subd, a null faces with a positive count, or the kernel's refusal.
cadaclysm_blacksmith_subd_subdivide
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_subdivide(const struct CadaclysmBlacksmithSubd *subd,
const uint32_t *faces,
uint32_t face_count);
A new cage with the face_count faces at faces (the whole cage when face_count is 0) subdivided once by the Catmull-Clark rules: each becomes quads round a new point, and an unpicked face beside them takes the new edge points as corners. The whole cage keeps its smooth surface exactly. The new handle selects the new faces. Null (and last_error) for a null subd, a null faces with a positive count, or the kernel's refusal.
cadaclysm_blacksmith_subd_insert_loop
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_insert_loop(const struct CadaclysmBlacksmithSubd *subd,
uint32_t a,
uint32_t b,
double at);
A new cage with a loop of edges cut across the ring of quads through edge (a, b), at a + at * (b - a) with at in (0, 1); the new handle selects the new loop's edges. Null (and last_error) for a null subd, or the kernel's refusal (not an edge, at out of range, a ring that folds back on itself).
cadaclysm_blacksmith_subd_mirror_on
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_mirror_on(const struct CadaclysmBlacksmithSubd *subd,
uint32_t axis);
The positive half of the cage across the plane perpendicular to axis (0 X, 1 Y, 2 Z) as a mirrored cage: every later edit keeps it symmetric. Selects nothing. Null (and last_error) for a null subd, an axis out of range, or the kernel's refusal (a face crossing the plane, nothing on the positive side, a half that would not weld).
cadaclysm_blacksmith_subd_mirror_off
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_mirror_off(const struct CadaclysmBlacksmithSubd *subd);
The mirror baked: the whole cage as an ordinary one, no longer mirrored (symmetry_axis -1). Selects nothing. Null (and last_error) for a null subd.
cadaclysm_blacksmith_subd_full
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_full(const struct CadaclysmBlacksmithSubd *subd);
The whole cage of a mirrored half — the half's vertices first, then the reflections of those off the plane — or a copy of an ordinary cage. Selects nothing. Null (and last_error) for a null subd.
cadaclysm_blacksmith_subd_edge_loop
struct CadaclysmBlacksmithSubd *cadaclysm_blacksmith_subd_edge_loop(const struct CadaclysmBlacksmithSubd *subd,
uint32_t a,
uint32_t b);
The loop of edges through edge (a, b), straight across each valence-four vertex, written into the returned handle's selection (kind 1, the picked edge first, each smaller id first); the cage itself unchanged. An empty selection when (a, b) is not an edge. Null (and last_error) for a null subd.
cadaclysm_blacksmith_subd_smooth_mesh
bool cadaclysm_blacksmith_subd_smooth_mesh(const struct CadaclysmBlacksmithSubd *subd,
uint32_t levels,
struct CadaclysmBlacksmithSubdMesh *out);
The smooth surface refined levels times (1 to 6) into out: see CadaclysmBlacksmithSubdMesh. Cached on the handle per level — the same levels again hands back the same arrays, and every view stays valid until cadaclysm_blacksmith_subd_free, whatever levels are asked for after it. false (and last_error) for a null subd or out, or levels out of range.
cadaclysm_blacksmith_subd_pick
bool cadaclysm_blacksmith_subd_pick(const struct CadaclysmBlacksmithSubd *subd,
const double *point,
uint32_t kind,
uint32_t *out);
The cage element of kind (0 vertex, 1 edge, 2 face) under point (3 doubles), a point on or near the smooth surface: its id into out[0], and for an edge its second vertex into out[1] (smaller id first; 0 otherwise, so both are always written). On a mirrored half, the half's own ids whichever side the point is on. false with an empty last_error when nothing is within 0.05 of the full cage's diagonal; false with last_error saying why for a null subd, point or out, a kind out of range, or a point that is not finite.
cadaclysm_blacksmith_subd_to_solid
struct CadaclysmBlacksmithSolid *cadaclysm_blacksmith_subd_to_solid(const struct CadaclysmBlacksmithSubd *subd,
double tolerance,
double g1_angle_deg,
uint32_t max_levels,
struct CadaclysmBlacksmithSubdReport *report);
The cage as an exact solid, one NURBS face per patch of its conversion, that every solid call takes; report, when not null, says what the conversion did and how close it came. tolerance <= 0, g1_angle_deg <= 0 and max_levels 0 take the defaults (1e-4 of the diagonal, 0.1 degrees, 6 levels). Null (and last_error) for a null subd, options out of range (max_levels from 2 to 6, a NaN), or a cage the conversion cannot hold within them, refused with the figures it measured (subd: outside tolerance after ... levels: deviation ..., tangent break ... deg).
FEM meshes
cadaclysm_blacksmith_fem_options_init
void cadaclysm_blacksmith_fem_options_init(struct CadaclysmBlacksmithFemOptions *options);
Fill options with size set and every default in place: a chordal tolerance and no size ceiling, exactly as FemOptions::default() states them — the numbers are not restated here, so the two cannot drift.
This is the one call the size rule does not protect. cadaclysm_blacksmith_fem_mesh reads only the fields size says are there, so a caller built against an older header is safe against a newer library. This function has no such input to read: it writes sizeof(CadaclysmBlacksmithFemOptions) bytes as this library knows that type, and a caller compiled against an older, shorter header has only that many bytes of stack local to receive them into. Its header must be at least as new as the library it links.
cadaclysm_blacksmith_fem_mesh
struct CadaclysmBlacksmithFemMesh *cadaclysm_blacksmith_fem_mesh(const struct CadaclysmBlacksmithSolid *solid,
const double *placement,
const struct CadaclysmBlacksmithFemOptions *options,
CadaclysmBlacksmithProgress progress,
void *user);
One solid's mesh for a solver: nodes welded by bits, triangles wound outward, each node tagged with the lowest-dimension B-rep entity it lies on, and every crack reported rather than closed.
placement is null (the identity) or twelve doubles — origin, x, y, z, as every frame argument in this library; right-handed and orthonormal — and is applied in f64 throughout. It is the one frame argument here that may be null, because a body meshed in its own coordinates is the common case where a sweep without a frame is nothing at all. The reader library's cadaclysm_node_fem_mesh takes sixteen, column-major, as everything on that side does; a caller moving between the two reformats the placement.
options is null (every default) or a struct filled by cadaclysm_blacksmith_fem_options_init — whose max_size bounds the boundary segments and merely targets the interior, and one small enough beside the body to reach the mesher's own piece and station ceilings is not honoured at all: CadaclysmBlacksmithFemMeshView::longest_edge is what the mesh actually came to, and the figure a caller that asked for an element size checks to find out whether it got one. tolerance alone decides how closely the boundary follows the geometry. (Also on CadaclysmBlacksmithFemOptions::max_size and CadaclysmBlacksmithFemMeshView::longest_edge, and stated here because a C reader meets a struct member's own comment nowhere but the header itself — the docs pages carry a struct as its declaration alone.)
cadaclysm_blacksmith_fem_mesh_free
void cadaclysm_blacksmith_fem_mesh_free(struct CadaclysmBlacksmithFemMesh *m);
Release a FEM mesh, and with it every pointer any accessor handed out. Null is a no-op. The .msh texts are not freed with it: each is the caller's, and each outlives this.
cadaclysm_blacksmith_fem_mesh_view
bool cadaclysm_blacksmith_fem_mesh_view(const struct CadaclysmBlacksmithFemMesh *m,
struct CadaclysmBlacksmithFemMeshView *out);
The flat arrays and the summary of one FEM mesh, into out.
false (and last_error) for a null handle or a null out; nothing is written then.
cadaclysm_blacksmith_fem_mesh_edge
bool cadaclysm_blacksmith_fem_mesh_edge(const struct CadaclysmBlacksmithFemMesh *m,
uint32_t i,
struct CadaclysmBlacksmithFemEdge *out);
B-rep edge i of a FEM mesh, into out.
false (and last_error) for a null handle, a null out, or an i at or past CadaclysmBlacksmithFemMeshView::edge_count; nothing is written then.
cadaclysm_blacksmith_fem_mesh_vertex
bool cadaclysm_blacksmith_fem_mesh_vertex(const struct CadaclysmBlacksmithFemMesh *m,
uint32_t i,
struct CadaclysmBlacksmithFemVertex *out);
B-rep vertex i of a FEM mesh, into out.
false (and last_error) for a null handle, a null out, or an i at or past CadaclysmBlacksmithFemMeshView::vertex_count; nothing is written then. A vertex with no node and no position is not a failure: it comes back true with node == CADACLYSM_BLACKSMITH_NONE and has_position == false.
cadaclysm_blacksmith_fem_mesh_open_edge
bool cadaclysm_blacksmith_fem_mesh_open_edge(const struct CadaclysmBlacksmithFemMesh *m,
uint32_t i,
uint32_t *a,
uint32_t *b,
uint32_t *brep_edge);
Crack i: a directed mesh edge (a, b) with no (b, a), and the B-rep edge both nodes lie on or CADACLYSM_BLACKSMITH_NONE where they share none.
false (and last_error) for a null handle, a null out-pointer, or an i at or past CadaclysmBlacksmithFemMeshView::open_edge_count.
Empty unless the solid's topology is closed — see CadaclysmBlacksmithFemMeshView::watertight, which explains what an empty census does and does not mean.
cadaclysm_blacksmith_fem_mesh_folded_edge
bool cadaclysm_blacksmith_fem_mesh_folded_edge(const struct CadaclysmBlacksmithFemMesh *m,
uint32_t i,
uint32_t *a,
uint32_t *b,
uint32_t *brep_edge);
Fold i: a directed mesh edge used by more than one triangle, with its B-rep edge as cadaclysm_blacksmith_fem_mesh_open_edge reports one.
A body can be folded without being open, and the closure census's own pinned rows are folds: a caller that checks only open_edge_count calls such a body sound. false (and last_error) for a null handle, a null out-pointer, or an i at or past CadaclysmBlacksmithFemMeshView::folded_edge_count.
cadaclysm_blacksmith_fem_mesh_crossing_count
uint32_t cadaclysm_blacksmith_fem_mesh_crossing_count(const struct CadaclysmBlacksmithFemMesh *m);
How many pairs of this mesh's triangles pass through each other: the rows cadaclysm_blacksmith_fem_mesh_crossing reads. 0 (and last_error) for a null handle.
In its own function because CadaclysmBlacksmithFemMeshView cannot grow: callers allocate the view. A mesh is ready for a volume mesher when watertight is true and this is 0.
cadaclysm_blacksmith_fem_mesh_crossing
bool cadaclysm_blacksmith_fem_mesh_crossing(const struct CadaclysmBlacksmithFemMesh *m,
uint32_t i,
uint32_t *a,
uint32_t *b);
Crossing i: the triangles a < b that pass through each other. false (and last_error) for a null handle, a null out-pointer, or an i at or past cadaclysm_blacksmith_fem_mesh_crossing_count; nothing written then.
cadaclysm_blacksmith_fem_mesh_msh_text
char *cadaclysm_blacksmith_fem_mesh_msh_text(const struct CadaclysmBlacksmithFemMesh *m);
The mesh as Gmsh 4.1 ASCII .msh text: an entity per B-rep vertex, edge and face, a volume where the body closes, and a physical group naming each.
The text is owned: release it with cadaclysm_blacksmith_string_free, as every other text this library hands over. Two asks give two texts, each independent of the other and of the handle: a text stays good after cadaclysm_blacksmith_fem_mesh_free. (The reader library's cadaclysm_fem_mesh_msh_text borrows from a slot on its own handle instead and must not be freed — see this module's own documentation.)
Null (and last_error) for a null handle or a mesh the writer refuses — the writer states a field it cannot honour, and that refusal arrives here as a message, not as a crash.
cadaclysm_blacksmith_fem_mesh_save_msh
bool cadaclysm_blacksmith_fem_mesh_save_msh(const struct CadaclysmBlacksmithFemMesh *m,
const char *path);
cadaclysm_blacksmith_fem_mesh_msh_text written to path, replacing any file there: the same bytes, from the same writer, straight to the file rather than through a string.
false (and last_error) for a null handle, no path, a mesh the writer refuses, or a file it cannot write.
Held tessellations
cadaclysm_blacksmith_tessellation
struct CadaclysmBlacksmithTessellation *cadaclysm_blacksmith_tessellation(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
The solid meshed at tolerance, held: the same mesh cadaclysm_blacksmith_mesh lends at that tolerance (the very same arrays while the solid's cache holds it), owned by the handle rather than lent by the solid. Where the solid's own arrays last until it is freed or meshed again at another tolerance, these last until cadaclysm_blacksmith_tessellation_free, whatever happens to the solid. The solid still keeps one tessellation: a replaced one lives exactly as long as a handle holds it. Null, with cadaclysm_blacksmith_last_error saying why, for a null solid or a tolerance that is negative or infinite.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_tessellation_free
void cadaclysm_blacksmith_tessellation_free(struct CadaclysmBlacksmithTessellation *tessellation);
Free a held tessellation, and with it every array lent from it. Null is a no-op.
cadaclysm_blacksmith_tessellation_mesh
struct CadaclysmBlacksmithMesh cadaclysm_blacksmith_tessellation_mesh(const struct CadaclysmBlacksmithTessellation *tessellation);
The held mesh's triangles, as cadaclysm_blacksmith_mesh gives them, borrowed from the handle and good until cadaclysm_blacksmith_tessellation_free. All-null and last_error for a null handle.
cadaclysm_blacksmith_tessellation_mesh64
struct CadaclysmBlacksmithMesh64 cadaclysm_blacksmith_tessellation_mesh64(const struct CadaclysmBlacksmithTessellation *tessellation);
The held mesh's triangles in double, as cadaclysm_blacksmith_mesh64 gives them, borrowed from the handle and good until cadaclysm_blacksmith_tessellation_free. All-null and last_error for a null handle.
cadaclysm_blacksmith_tessellation_face_triangles
struct CadaclysmBlacksmithFaceTriangles cadaclysm_blacksmith_tessellation_face_triangles(const struct CadaclysmBlacksmithTessellation *tessellation);
The held mesh's per-face triangle counts, as cadaclysm_blacksmith_mesh_face_triangles gives them, borrowed from the handle and good until cadaclysm_blacksmith_tessellation_free. Null counts and last_error for a null handle.
cadaclysm_blacksmith_tessellation_edge_polylines
struct CadaclysmBlacksmithPolylines cadaclysm_blacksmith_tessellation_edge_polylines(const struct CadaclysmBlacksmithTessellation *tessellation);
The held mesh's feature-edge polylines, as cadaclysm_blacksmith_edge_polylines gives them, borrowed from the handle and good until cadaclysm_blacksmith_tessellation_free. All-null and last_error for a null handle.
Output and freeing
cadaclysm_blacksmith_solid_free
void cadaclysm_blacksmith_solid_free(struct CadaclysmBlacksmithSolid *solid);
Release a solid. Null is a no-op.
cadaclysm_blacksmith_mesh_file
uint8_t *cadaclysm_blacksmith_mesh_file(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
const char *format,
const char *const *names,
const double *looks,
double tolerance,
size_t *len);
count solids meshed at tolerance — each the mesh cadaclysm_blacksmith_mesh hands out — written to one file in format:
- "stl": binary STL, every solid's triangles in one body; - "stl-ascii": ASCII STL, one body named as the first solid; - "obj": Wavefront OBJ, one named object a solid, no material library; - "glb", "gltf": glTF 2.0, one named node a solid in a material of its own — the binary .glb, or the .gltf JSON with its buffer embedded; - "3mf": a 3MF package, one named object and build item a solid, in millimetres; - "ply", "ply-ascii": PLY, binary little-endian or ASCII, every solid's triangles in one body.
3MF and PLY carry the solids' colours: each face its own where it was coloured, else the solid's — 3MF a colour a triangle, PLY a colour a vertex. A file where no solid is coloured carries none.
cadaclysm_blacksmith_mesh
struct CadaclysmBlacksmithMesh cadaclysm_blacksmith_mesh(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
Tessellate at tolerance (chordal deviation, in the solid's own units) — or hand back the tessellation already made at exactly this tolerance. The pointers borrow from the solid and stay valid until it is freed or meshed again at a *different* tolerance, by this thread or any other: callers on several threads at one tolerance share one mesh, meshed once. Faces are meshed watertight, vertices welded by position. All-null and last_error on failure. For arrays that must outlive a re-mesh or the solid, hold the tessellation: cadaclysm_blacksmith_tessellation.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_mesh64
struct CadaclysmBlacksmithMesh64 cadaclysm_blacksmith_mesh64(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
cadaclysm_blacksmith_mesh in double, from the same cache, under the same rule: valid until the solid is freed or meshed again at a different tolerance. For arrays that must outlive a re-mesh or the solid, hold the tessellation: cadaclysm_blacksmith_tessellation.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_mesh_face_triangles
struct CadaclysmBlacksmithFaceTriangles cadaclysm_blacksmith_mesh_face_triangles(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
The triangles each face contributed to the mesh cadaclysm_blacksmith_mesh gives at the same tolerance: one count per face in face order, summing to that mesh's index_count / 3. The mesher writes a face's triangles together and the faces in order, so face f's triangles are the counts[f] that follow the first sum(counts[..f]); a face that meshed to nothing counts zero. What a viewer colours a face by. Same cache and lifetime rule as the mesh. Null counts and last_error on failure. For arrays that must outlive a re-mesh or the solid, hold the tessellation: cadaclysm_blacksmith_tessellation.
tolerance 0 or NaN: the inputs' effective tolerance (see cadaclysm_blacksmith_effective_tolerance).
cadaclysm_blacksmith_step
char *cadaclysm_blacksmith_step(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
const char *schema,
uint32_t unit);
count solids as one STEP part file, each its own MANIFOLD_SOLID_BREP, through cadaclysm_step_ap::write_breps_coloured. schema is NULL for the built-in AP203 (CONFIG_CONTROL_DESIGN) — or AP242 when any solid, face or edge is coloured, since AP203's first edition has no entity to state a colour with — the name of a built-in schema (AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF, …; case-insensitive) — a built-in schema must carry every entity the writer emits, as AP203 and AP242 do and AP214's AUTOMOTIVE_DESIGN does not — or the EXPRESS source text of a custom schema. A solid's, its faces' and its edges' colours are written as STEP styling (STYLED_ITEM over COLOUR_RGB) under a schema that has it, and left out under a named one that does not. unit 0 = metre, 1 = millimetre, 2 = inch, and says what the solids' lengths are. The text is owned: release it with cadaclysm_blacksmith_string_free. Null and last_error on failure.
Set the kernel option step.validation_properties to 1 (cadaclysm_blacksmith_option_set) and every body also carries its geometric validation properties: the surface area, the volume and the centroid this kernel measures for it, stated in the file so the kernel that reads it can check the transfer against its own measurement of the same geometry. They are measured at step.validation_accuracy (1e-5) and stated in the file's own length unit, and the file keeps everything it would otherwise carry — its product name, its attributes, its colours, its material. With no schema named the default moves to AP242 then, as a colour moves it; a named schema that cannot state the properties is refused rather than written without the figures asked for. A body whose measurement is refused is written without properties and the file is still written: this call returns one string and has no room for a per-body report, so a caller who needs to know which bodies were measured asks cadaclysm_blacksmith_mass_properties itself. The figures are as good as the accuracy asked for and no better — STEP has no field for an error bound.
cadaclysm_blacksmith_step_assembly
char *cadaclysm_blacksmith_step_assembly(const struct CadaclysmBlacksmithSolid *const *solids,
const char *const *names,
size_t part_count,
const uint32_t *parts_of,
const double *frames,
size_t placement_count,
const char *schema,
uint32_t unit);
An assembly as one STEP file, through cadaclysm_step_ap::write_assembly: each of the part_count parts — solids[i], named names[i] — written once as its own product, in its own coordinates; each of the placement_count placements an occurrence of part parts_of[k] at the frame frames[12 * k ..] (origin, x, y, z, as every frame argument; right-handed and orthonormal), all under one root product, assembly. A reader tessellates a part once however many times it is placed. A part no placement names is not written. schema and unit as for cadaclysm_blacksmith_step. The text is owned: release it with cadaclysm_blacksmith_string_free. Null and last_error on failure — a placement naming no part or at a frame a STEP placement cannot state included.
The option step.validation_properties does nothing here: an assembly file carries no validation properties however it is set. OpenCascade states even a single solid's figures on a SHAPE_ASPECT of that body's own shape rather than on the PRODUCT_DEFINITION a part's material hangs from, so assemblies are deferred to a follow-up rather than half-written; stamp a part file (cadaclysm_blacksmith_step) to get them.
cadaclysm_blacksmith_sat_text
char *cadaclysm_blacksmith_sat_text(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
uint32_t unit);
count solids as one ACIS SAT file, each its own body, through cadaclysm_acis::write_breps: the analytic surfaces as their own records, spline surfaces (and the swept surfaces SAT has no plain record for) as exact NURBS blobs. unit is as for cadaclysm_blacksmith_step and goes into the header as millimetres per unit. The text is owned: release it with cadaclysm_blacksmith_string_free. Null and last_error on failure.
cadaclysm_blacksmith_sat
bool cadaclysm_blacksmith_sat(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
const char *path,
uint32_t unit);
cadaclysm_blacksmith_sat_text written to path, replacing any file there. false and last_error on failure, including the file's.
cadaclysm_blacksmith_3dm_bytes
uint8_t *cadaclysm_blacksmith_3dm_bytes(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
uint32_t unit,
size_t *len);
count solids as one Rhino .3dm (version 8, which Rhino 8 and 9 open), one object each, through cadaclysm_rhino3dm::write: each an ON_Brep with its exact surfaces and trims, or — where a body has no exact form there — its mesh. Each object is named as its solid is, coloured with the solid's own colour (a face's or an edge's own colour has no place in a .3dm object and is left out), and carries the solid's attributes as user text. unit is as for cadaclysm_blacksmith_step and is the file's unit: the numbers written are the numbers held.
The bytes are owned, their count written through len: release them with cadaclysm_blacksmith_bytes_free, passing the same len back. Null and last_error on failure. On success last_error lists, one line each, what was written as a mesh or left out (solid 1: written as a mesh: ...), or is null where everything was written as itself.
cadaclysm_blacksmith_3dm
bool cadaclysm_blacksmith_3dm(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
const char *path,
uint32_t unit);
cadaclysm_blacksmith_3dm_bytes written to path, replacing any file there. false and last_error on failure, including the file's; on success last_error says what was written as a mesh or left out, as that call's does.
cadaclysm_blacksmith_bytes_free
void cadaclysm_blacksmith_bytes_free(uint8_t *bytes, size_t len);
Release bytes this library handed over as owned (cadaclysm_blacksmith_3dm_bytes, cadaclysm_blacksmith_assembly_3dm_bytes, cadaclysm_blacksmith_mesh_file, cadaclysm_bim_sheet_pdf, cadaclysm_bim_sheets_pdf). Null is a no-op. len must be the length that same call wrote through its own len — the bytes carry no NUL or length of their own to read it back from.
cadaclysm_blacksmith_brep_text
char *cadaclysm_blacksmith_brep_text(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count);
count solids as one OCCT .brep file, each its own solid under one compound (a single solid is the file's root), through cadaclysm_brep_file::write_breps: the exact surfaces and curves, with a curve in each face's own parameters for every edge, so BRepTools::Read gives a shape BRepCheck_Analyzer finds valid. No unit is declared: a .brep carries none, and the numbers written are the numbers held. The text is owned: release it with cadaclysm_blacksmith_string_free. Null and last_error on failure.
cadaclysm_blacksmith_svg_options_init
void cadaclysm_blacksmith_svg_options_init(struct CadaclysmBlacksmithSvgOptions *options);
The defaults: the viewer's iso, orthographic, a 1000-square page, black edges one unit wide on nothing, and each solid's outline beside them.
cadaclysm_blacksmith_svg_text
char *cadaclysm_blacksmith_svg_text(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
const struct CadaclysmBlacksmithSvgOptions *options);
abi::svg of count solids: the wireframe as SVG from the camera the options' words describe. The text is owned: release it with cadaclysm_blacksmith_string_free. Null and last_error on failure.
cadaclysm_blacksmith_brep
bool cadaclysm_blacksmith_brep(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
const char *path);
cadaclysm_blacksmith_brep_text written to path. False and last_error on failure, which includes the file not being writable.
cadaclysm_blacksmith_svg
bool cadaclysm_blacksmith_svg(const struct CadaclysmBlacksmithSolid *const *solids,
size_t count,
const char *path,
const struct CadaclysmBlacksmithSvgOptions *options);
cadaclysm_blacksmith_svg_text written to path, replacing any file there. false and last_error on failure, including the file's.
cadaclysm_blacksmith_drawing_svg_text
char *cadaclysm_blacksmith_drawing_svg_text(const struct CadaclysmBlacksmithSolid *const *solids,
size_t solid_count,
const struct CadaclysmBlacksmithProfile *const *profiles,
size_t profile_count,
const struct CadaclysmBlacksmithSvgOptions *options);
solid_count solids and profile_count profiles as one SVG wireframe: a <g id="solid-<i>"> per solid then a <g id="profile-<i>"> per profile, on one page, each stroked in its own colour where it carries one and in the options' stroke otherwise. Either count may be 0 — a drawing of solids alone is cadaclysm_blacksmith_svg_text, which is this with no profiles — and both 0 is refused. The text is owned: release it with cadaclysm_blacksmith_string_free. Null and last_error on failure.
cadaclysm_blacksmith_drawing_svg
bool cadaclysm_blacksmith_drawing_svg(const struct CadaclysmBlacksmithSolid *const *solids,
size_t solid_count,
const struct CadaclysmBlacksmithProfile *const *profiles,
size_t profile_count,
const char *path,
const struct CadaclysmBlacksmithSvgOptions *options);
cadaclysm_blacksmith_drawing_svg_text written to path, replacing any file there. false and last_error on failure, the file's included.
cadaclysm_blacksmith_silhouette_beziers
double *cadaclysm_blacksmith_silhouette_beziers(const struct CadaclysmBlacksmithSolid *solid,
const struct CadaclysmBlacksmithSvgOptions *options,
uint32_t *count);
A solid's silhouette curves as rational cubic Béziers, flattened to an owned buffer of doubles: per segment, its four control points' x, y, z (12 numbers) then its four weights (4 numbers) — *count * 16 doubles in all. count is written through the out-parameter either way (0 on a refusal or on an answer with none).
The eye comes from the same options cadaclysm_blacksmith_svg_text draws with (up, azimuth, elevation, fov, and tolerance/width read together as a world tolerance), so a caller drawing a picture and asking for its outline gets one eye, not two. A body with no silhouette — every face planar, like a cube's, since a plane never turns away from any eye — is not an error: null, count 0, and an empty last_error. Every call that runs under this library's guard — which is every call that builds, reads or writes geometry — clears the error slot before it does anything else, and this one does too, except for a null count: that is refused (silhouette: null count, nothing allocated) before the guard runs, so it sets its message without clearing first. Past that check, null with an empty slot is the empty answer and null with a message is a refusal, whatever an earlier call left behind. The calls that do not run under the guard, and so never clear the slot, are the frees (..._free), the struct-fill initialisers (..._svg_options_init, ..._fem_options_init), the pure accessors (..._version, ..._license_info, ..._license_notice_count, ..._build_date, ..._brep_layout_id), ..._license_set (which sets a message of its own on a refusal) and the error getter itself.
Owned, unlike the reader library's borrowed cadaclysm_node_silhouette_beziers: every handle this library hands out is already the caller's to free (see the module doc, "Handles are immutable"), so this follows that convention rather than the reader's borrowed slot. Free a non-null result with cadaclysm_blacksmith_silhouette_beziers_free, passing back the same count this call wrote — the buffer carries no length of its own, unlike a string's NUL.
cadaclysm_blacksmith_silhouette_beziers_free
void cadaclysm_blacksmith_silhouette_beziers_free(double *data, uint32_t count);
Release what cadaclysm_blacksmith_silhouette_beziers handed out. Null is a no-op. count must be the value that same call wrote through its own out-parameter — unlike the strings cadaclysm_blacksmith_string_free releases, this buffer carries no NUL or length of its own to read it back from.
Exact faces for the GPU
cadaclysm_blacksmith_gpu_edge_normals
struct CadaclysmBlacksmithEdgeNormals cadaclysm_blacksmith_gpu_edge_normals(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
The two faces' outward normals at the ends of each exact edge of cadaclysm_blacksmith_gpu_surfaces at the same tolerance: count equals that record's Bezier count (edges_len / 16), and Bezier i's are normals[12 * i .. 12 * i + 12] — the face of the trim it was traced from at its first and its last point, then the other face along the same edge at the same two, x, y, z each, unit length; zeros for a face the edge lacks or a normal that could not be found, and zeros throughout for a body that is not closed (a sheet), whose faces turned away hide nothing. What a viewer culls an exact edge by: on a closed body a point whose two faces both turn away from the eye is hidden. A bad tolerance or argument: count 0, normals NULL, with last_error. Same cache and lifetime rule as the mesh.
cadaclysm_blacksmith_gpu_surfaces
struct CadaclysmBlacksmithGpuSurfaces *cadaclysm_blacksmith_gpu_surfaces(const struct CadaclysmBlacksmithSolid *solid,
double tolerance);
A solid's exact faces packed for a GPU surface evaluator, and its exact edges: the record the reader's cadaclysm_node_gpu_surfaces hands out for a part, for this solid.
faces is the faces this GPU path can express, in the solid's face order — the order cadaclysm_blacksmith_mesh_face_triangles counts in, but not necessarily every one of them: a face with no area is left out, so face_count can be below cadaclysm_blacksmith_face_count's answer for the same solid. A caller pairing this record with mesh_face_triangles' per-face counts must check the two counts agree before zipping them by index; they need not, and a mismatch means some faces were dropped, not reordered.
Free with cadaclysm_blacksmith_gpu_surfaces_free. NULL, with last_error, for a null solid, a tolerance that is not a positive finite number, or a solid with no exact faces.
cadaclysm_blacksmith_gpu_surfaces_free
void cadaclysm_blacksmith_gpu_surfaces_free(struct CadaclysmBlacksmithGpuSurfaces *surfaces);
Frees what cadaclysm_blacksmith_gpu_surfaces handed out. NULL is allowed.
Machining
cadaclysm_blacksmith_tool_flat
struct CadaclysmBlacksmithTool *cadaclysm_blacksmith_tool_flat(uint32_t number,
double diameter,
double flute_length,
double feed,
double plunge,
double rpm);
A flat end mill: Grbl tool number (at least 1), diameter and flute_length in mm, feed and plunge in mm/min, rpm its spindle speed. It ramps into its cuts at 3 degrees (cadaclysm_blacksmith_tool_with_ramp_angle changes that). Null (and last_error) for a number of 0 or above 255, or a size, feed or speed not positive and finite.
cadaclysm_blacksmith_tool_ball
struct CadaclysmBlacksmithTool *cadaclysm_blacksmith_tool_ball(uint32_t number,
double diameter,
double flute_length,
double feed,
double plunge,
double rpm);
A ball end mill: as cadaclysm_blacksmith_tool_flat, its tip a half sphere of the diameter.
cadaclysm_blacksmith_tool_drill
struct CadaclysmBlacksmithTool *cadaclysm_blacksmith_tool_drill(uint32_t number,
double diameter,
double flute_length,
double feed,
double rpm);
A drill: as cadaclysm_blacksmith_tool_flat, plunging at feed. A drill only drills — a job refuses it for any other operation.
cadaclysm_blacksmith_tool_with_ramp_angle
struct CadaclysmBlacksmithTool *cadaclysm_blacksmith_tool_with_ramp_angle(const struct CadaclysmBlacksmithTool *t,
double degrees);
A new tool: t, ramping into its cuts at degrees from the horizontal. t is left as it was. Null (and last_error) for a null tool or an angle outside (0, 90].
cadaclysm_blacksmith_tool_free
void cadaclysm_blacksmith_tool_free(struct CadaclysmBlacksmithTool *t);
Release a tool. Null is a no-op. A job it was used in keeps its own copy.
cadaclysm_blacksmith_tool_number
uint32_t cadaclysm_blacksmith_tool_number(const struct CadaclysmBlacksmithTool *t);
The tool's Grbl number, 1 to 255. UINT32_MAX (and last_error) for null.
cadaclysm_blacksmith_tool_shape
const char *cadaclysm_blacksmith_tool_shape(const struct CadaclysmBlacksmithTool *t);
The tool's shape: "flat", "ball", "drill", "vbit" or "bullnose", a static string the caller never frees. Null (and last_error) for null.
cadaclysm_blacksmith_tool_diameter
double cadaclysm_blacksmith_tool_diameter(const struct CadaclysmBlacksmithTool *t);
The tool's cutting diameter, in mm. NaN (and last_error) for null.
cadaclysm_blacksmith_tool_flute_length
double cadaclysm_blacksmith_tool_flute_length(const struct CadaclysmBlacksmithTool *t);
How far up the tool's cutting edge reaches from the tip, in mm. NaN (and last_error) for null.
cadaclysm_blacksmith_tool_angle
double cadaclysm_blacksmith_tool_angle(const struct CadaclysmBlacksmithTool *t);
A V-bit's included angle, in degrees. NaN for every other shape (check cadaclysm_blacksmith_tool_shape first), and NaN with last_error for null.
cadaclysm_blacksmith_tool_corner_radius
double cadaclysm_blacksmith_tool_corner_radius(const struct CadaclysmBlacksmithTool *t);
A bull-nose's corner radius, in mm. NaN for every other shape (check cadaclysm_blacksmith_tool_shape first), and NaN with last_error for null.
cadaclysm_blacksmith_job_stock
bool cadaclysm_blacksmith_job_stock(const struct CadaclysmBlacksmithJob *j,
double *min,
double *max);
The job's stock box: x, y, z of its lowest corner to min[0..3], of its highest to max[0..3] — what stock_box was given, or what stock_around worked out. false (and last_error) for a null job or a null output.
cadaclysm_blacksmith_stock_box
struct CadaclysmBlacksmithStock *cadaclysm_blacksmith_stock_box(double min_x,
double min_y,
double min_z,
double max_x,
double max_y,
double max_z);
The box of material from (min_x, min_y, min_z) to (max_x, max_y, max_z). Null (and last_error) unless every min is below its max and all six are finite.
cadaclysm_blacksmith_stock_around
struct CadaclysmBlacksmithStock *cadaclysm_blacksmith_stock_around(const struct CadaclysmBlacksmithSolid *s,
double margin);
s's bounding box grown by margin sideways and on top (the bottom stays on the part's own). Null (and last_error) for a null solid or a margin that is negative or not finite.
cadaclysm_blacksmith_stock_free
void cadaclysm_blacksmith_stock_free(struct CadaclysmBlacksmithStock *s);
Release a stock. Null is a no-op. A job made on it keeps its own copy.
cadaclysm_blacksmith_job_new
struct CadaclysmBlacksmithJob *cadaclysm_blacksmith_job_new(const struct CadaclysmBlacksmithStock *stock,
double safe_z);
An empty job on stock, rapids at safe_z (above the stock's top), named "job", with a clearance of 1, a tolerance of 0.01, a spindle dwell of 2 s and a CAMotics resolution of 0.1 until a job_set_* call changes them. Null (and last_error) for a null stock or a safe_z not above its top.
cadaclysm_blacksmith_job_set_clearance
bool cadaclysm_blacksmith_job_set_clearance(struct CadaclysmBlacksmithJob *j, double clearance);
How far above an operation's top it enters and leaves its passes. In place; false (and last_error, the job unchanged) for a null job or a clearance not positive and finite.
cadaclysm_blacksmith_job_set_tolerance
bool cadaclysm_blacksmith_job_set_tolerance(struct CadaclysmBlacksmithJob *j, double tolerance);
The tolerance free-form sides are fitted and offsets computed to. In place; false (and last_error, the job unchanged) for a null job or a tolerance not positive and finite.
cadaclysm_blacksmith_job_set_spindle_dwell
bool cadaclysm_blacksmith_job_set_spindle_dwell(struct CadaclysmBlacksmithJob *j,
double seconds);
The seconds every program waits (G4) after starting the spindle; 0 writes no wait. In place; false (and last_error, the job unchanged) for a null job or a dwell negative or not finite.
cadaclysm_blacksmith_job_set_name
bool cadaclysm_blacksmith_job_set_name(struct CadaclysmBlacksmithJob *j, const char *name);
The name programs are called after (<name>-T<n>) and written into their header comment. In place; false (and last_error, the job unchanged) for a null job, a null or non-UTF-8 name, or a name the job refuses.
cadaclysm_blacksmith_job_set_resolution
bool cadaclysm_blacksmith_job_set_resolution(struct CadaclysmBlacksmithJob *j,
double resolution);
The voxel size, in mm, of the CAMotics project cadaclysm_blacksmith_job_camotics writes. In place; false (and last_error, the job unchanged) for a null job or a resolution not positive and finite.
cadaclysm_blacksmith_job_face
bool cadaclysm_blacksmith_job_face(struct CadaclysmBlacksmithJob *j,
const struct CadaclysmBlacksmithTool *t,
double z,
double stepover,
double stepdown);
Face the stock's top down to z, in rows stepover apart and passes at most stepdown deep, with t. Added to the job in place; false (and last_error, the job unchanged) for a null job or tool, or what the job refuses (a drill, a z above the top, a stepover past the diameter, ...).
cadaclysm_blacksmith_job_contour
bool cadaclysm_blacksmith_job_contour(struct CadaclysmBlacksmithJob *j,
const struct CadaclysmBlacksmithTool *t,
const struct CadaclysmBlacksmithProfile *p,
double top,
double bottom,
uint32_t side,
double stepdown,
bool climb,
bool open);
Cut along p from top to bottom in passes at most stepdown deep, with t: side 0 outside the profile, 1 inside it, 2 on its line; climb for climb milling, else conventional; open to cut the outline as an open chain (only on its line, and with no holes). Added in place; false (and last_error, the job unchanged) for a null job, tool or profile, a side past 2, or what the job refuses.
cadaclysm_blacksmith_job_pocket
bool cadaclysm_blacksmith_job_pocket(struct CadaclysmBlacksmithJob *j,
const struct CadaclysmBlacksmithTool *t,
const struct CadaclysmBlacksmithProfile *p,
double top,
double bottom,
double stepover,
double stepdown);
Clear p — its holes left standing as islands — from top to bottom, in rings stepover apart (at most the tool's radius) and passes at most stepdown deep, with t. Added in place; false (and last_error, the job unchanged) for a null job, tool or profile, or what the job refuses.
cadaclysm_blacksmith_job_drill
bool cadaclysm_blacksmith_job_drill(struct CadaclysmBlacksmithJob *j,
const struct CadaclysmBlacksmithTool *t,
const double *xy,
size_t count,
double top,
double bottom,
double peck);
Drill count holes at xy (x0, y0, x1, y1, ... — 2 * count doubles) from top to bottom with t, pecking peck deep at a time, or straight to depth when peck is NaN. Added in place; false (and last_error, the job unchanged) for a null job or tool, a null xy with a count above 0, or what the job refuses.
cadaclysm_blacksmith_job_gcode
struct CadaclysmBlacksmithPrograms *cadaclysm_blacksmith_job_gcode(const struct CadaclysmBlacksmithJob *j);
The job as Grbl 1.1 programs, one per run of consecutive operations sharing a tool, each named <name>-T<n> (or <name>-<k>-T<n> for run k of a tool that runs more than once). Null (and last_error) for a null job or a toolpath the writer refuses; a list of count 0 for a job with no operations.
cadaclysm_blacksmith_job_camotics
struct CadaclysmBlacksmithPrograms *cadaclysm_blacksmith_job_camotics(const struct CadaclysmBlacksmithJob *j,
const char *stem);
Every file of a CAMotics project named stem, in memory and in the order it would be written: each program (<stem>-T<n>.nc, or <stem>-<k>-T<n>.nc for run k of a repeated tool), its simulation copy, and the project (<stem>.camotics, tool 0) last. Each entry's name is the file's name, its text the file's content. Null (and last_error) for a null job, a null or non-UTF-8 stem, a stem that is not a plain file name, or what job_gcode refuses.
cadaclysm_blacksmith_job_free
void cadaclysm_blacksmith_job_free(struct CadaclysmBlacksmithJob *j);
Release a job. Null is a no-op. Lists it wrote are independent and outlive it.
cadaclysm_blacksmith_programs_count
uint32_t cadaclysm_blacksmith_programs_count(const struct CadaclysmBlacksmithPrograms *l);
How many files. UINT32_MAX (and last_error) for null.
cadaclysm_blacksmith_programs_tool
uint32_t cadaclysm_blacksmith_programs_tool(const struct CadaclysmBlacksmithPrograms *l,
uint32_t i);
File i's Grbl tool number; 0 for a CAMotics project file. UINT32_MAX (and last_error) for null or i out of range.
cadaclysm_blacksmith_programs_name
const char *cadaclysm_blacksmith_programs_name(const struct CadaclysmBlacksmithPrograms *l,
uint32_t i);
File i's name: for cadaclysm_blacksmith_job_gcode, the program's name without extension (<name>-T<n>, or <name>-<k>-T<n> for a repeated tool); for cadaclysm_blacksmith_job_camotics, the file's name. Owned by the list and good until cadaclysm_blacksmith_programs_free; never freed by the caller. Null (and last_error) for null or i out of range.
cadaclysm_blacksmith_programs_text
const char *cadaclysm_blacksmith_programs_text(const struct CadaclysmBlacksmithPrograms *l,
uint32_t i);
File i's content: G-code, or a CAMotics project's JSON. Owned by the list and good until cadaclysm_blacksmith_programs_free; never freed by the caller. Null (and last_error) for null or i out of range.
cadaclysm_blacksmith_programs_free
void cadaclysm_blacksmith_programs_free(struct CadaclysmBlacksmithPrograms *l);
Release a list, and every string read out of it. Null is a no-op.
cadaclysm_blacksmith_job_machine
struct CadaclysmBlacksmithReport *cadaclysm_blacksmith_job_machine(struct CadaclysmBlacksmithJob *j,
const struct CadaclysmBlacksmithSolid *part,
const struct CadaclysmBlacksmithTool *end_mill,
const struct CadaclysmBlacksmithTool *const *drills,
size_t drill_count,
double stepover,
double stepdown,
double skin,
double peck);
Recognise part and append the operations that make it to j: NaN stepover/stepdown/peck are the kernel's own defaults; skin is always given. drills is drill_count tool pointers, or null when drill_count is 0. j changes only on success — a refusal leaves it exactly as it was. Null (and last_error) for a null job, part or end mill, a null drill pointer at index i (named "job_machine: null drill <i>"), or what the kernel refuses (a drill as the end mill, ...).
cadaclysm_blacksmith_job_machine_with
struct CadaclysmBlacksmithReport *cadaclysm_blacksmith_job_machine_with(struct CadaclysmBlacksmithJob *j,
const struct CadaclysmBlacksmithSolid *part,
const struct CadaclysmBlacksmithTool *const *end_mills,
size_t end_mill_count,
const struct CadaclysmBlacksmithTool *const *drills,
size_t drill_count,
double stepover,
double stepdown,
double skin,
double peck);
cadaclysm_blacksmith_job_machine with several end mills, largest first: each later one cleans what the earlier ones left — inside corners, regions too narrow for them, holes no drill matches. end_mills is end_mill_count tool pointers; drills as in job_machine. j changes only on success. Null (and last_error) for a null job or part, a null end_mills with a count above 0, a null end mill at index i (named "job_machine_with: null end mill <i>"), a null drill (as job_machine, named "job_machine_with: null drill <i>"), or what the kernel refuses (no end mill, one not smaller than the one before, two sharing a number, a drill, V-bit or bull-nose among them, ...).
cadaclysm_blacksmith_job_machine_relieved
struct CadaclysmBlacksmithReport *cadaclysm_blacksmith_job_machine_relieved(struct CadaclysmBlacksmithJob *j,
const struct CadaclysmBlacksmithSolid *part,
const struct CadaclysmBlacksmithTool *const *end_mills,
size_t end_mill_count,
const struct CadaclysmBlacksmithTool *const *drills,
size_t drill_count,
double stepover,
double stepdown,
double skin,
double peck,
bool corner_relief);
cadaclysm_blacksmith_job_machine_with, relieving every inside corner the smallest end mill leaves with a dog-bone when corner_relief is true: a cut along the corner's bisector until the cutter touches the corner, reported as a relief item in place of the corner item (read through the same report calls). false is job_machine_with exactly. Refusals as job_machine_with's, named "job_machine_relieved: ...".
cadaclysm_blacksmith_report_count
uint32_t cadaclysm_blacksmith_report_count(const struct CadaclysmBlacksmithReport *r);
How many items. UINT32_MAX (and last_error) for null.
cadaclysm_blacksmith_report_kind
const char *cadaclysm_blacksmith_report_kind(const struct CadaclysmBlacksmithReport *r,
uint32_t i);
Item i's kind: "corner", "hole", "slope", "undercut", "too_deep" or "relief" (an inside corner cut beyond the part on purpose, see cadaclysm_blacksmith_job_machine_relieved). Owned by the report and good until cadaclysm_blacksmith_report_free; never freed by the caller. Null (and last_error) for null or i out of range.
cadaclysm_blacksmith_report_at
bool cadaclysm_blacksmith_report_at(const struct CadaclysmBlacksmithReport *r,
uint32_t i,
double *out);
Item i's location: x, y, z written to out[0..3]. false (and last_error) for null, i out of range, or a null out.
cadaclysm_blacksmith_report_size
double cadaclysm_blacksmith_report_size(const struct CadaclysmBlacksmithReport *r, uint32_t i);
Item i's size, per kind. NaN (and last_error) for null or i out of range — unambiguous, since a size is never NaN.
cadaclysm_blacksmith_report_top
double cadaclysm_blacksmith_report_top(const struct CadaclysmBlacksmithReport *r, uint32_t i);
Item i's top: the highest Z it stands at. NaN (and last_error) for null or i out of range.
cadaclysm_blacksmith_report_bottom
double cadaclysm_blacksmith_report_bottom(const struct CadaclysmBlacksmithReport *r,
uint32_t i);
Item i's bottom: the lowest Z it stands down to. NaN (and last_error) for null or i out of range.
cadaclysm_blacksmith_report_reason
const char *cadaclysm_blacksmith_report_reason(const struct CadaclysmBlacksmithReport *r,
uint32_t i);
Item i's reason, in one sentence naming the tool involved. Owned by the report and good until cadaclysm_blacksmith_report_free; never freed by the caller. Null (and last_error) for null or i out of range.
cadaclysm_blacksmith_report_region
struct CadaclysmBlacksmithProfileList *cadaclysm_blacksmith_report_region(const struct CadaclysmBlacksmithReport *r,
uint32_t i);
Item i's XY area, as a new profile list the caller frees with cadaclysm_blacksmith_profile_list_free. Null (and last_error) for null or i out of range.
cadaclysm_blacksmith_report_text
const char *cadaclysm_blacksmith_report_text(const struct CadaclysmBlacksmithReport *r);
The report's own Display: one line per item, or "nothing left uncut". Owned by the report and good until cadaclysm_blacksmith_report_free; never freed by the caller. Null (and last_error) for null.
cadaclysm_blacksmith_report_free
void cadaclysm_blacksmith_report_free(struct CadaclysmBlacksmithReport *r);
Release a report, and every string read out of it. Null is a no-op.
cadaclysm_blacksmith_job_operations
struct CadaclysmBlacksmithOperations *cadaclysm_blacksmith_job_operations(const struct CadaclysmBlacksmithJob *j);
Every operation added to j so far, in order. Null (and last_error) for a null job.
cadaclysm_blacksmith_operations_count
uint32_t cadaclysm_blacksmith_operations_count(const struct CadaclysmBlacksmithOperations *l);
How many operations. UINT32_MAX (and last_error) for null.
cadaclysm_blacksmith_operations_kind
const char *cadaclysm_blacksmith_operations_kind(const struct CadaclysmBlacksmithOperations *l,
uint32_t i);
Operation i's kind: "face", "contour", "pocket" or "drill". Owned by the list and good until cadaclysm_blacksmith_operations_free; never freed by the caller. Null (and last_error) for null or i out of range.
cadaclysm_blacksmith_operations_tool
uint32_t cadaclysm_blacksmith_operations_tool(const struct CadaclysmBlacksmithOperations *l,
uint32_t i);
Operation i's tool number. UINT32_MAX (and last_error) for null or i out of range.
cadaclysm_blacksmith_operations_param_count
uint32_t cadaclysm_blacksmith_operations_param_count(const struct CadaclysmBlacksmithOperations *l,
uint32_t i);
How many params operation i has. UINT32_MAX (and last_error) for null or i out of range.
cadaclysm_blacksmith_operations_param_name
const char *cadaclysm_blacksmith_operations_param_name(const struct CadaclysmBlacksmithOperations *l,
uint32_t i,
uint32_t k);
Operation i's param k's name. Owned by the list and good until cadaclysm_blacksmith_operations_free; never freed by the caller. Null (and last_error) for null, i out of range, or k out of range — a caller checks cadaclysm_blacksmith_operations_param_count first.
cadaclysm_blacksmith_operations_param_value
double cadaclysm_blacksmith_operations_param_value(const struct CadaclysmBlacksmithOperations *l,
uint32_t i,
uint32_t k);
Operation i's param k's value. May legitimately be NaN (a drill's peck when there is none); on a bad index it is also NaN, with last_error set — a caller checks cadaclysm_blacksmith_operations_param_count first, since NaN alone does not say which happened.
cadaclysm_blacksmith_operations_free
void cadaclysm_blacksmith_operations_free(struct CadaclysmBlacksmithOperations *l);
Release a list, and every string read out of it. Null is a no-op.
Types
CadaclysmBlacksmithAt
typedef struct CadaclysmBlacksmithAt {
double point[3];
double tangent[3];
double parameter;
uint32_t segment;
double error;
int32_t from_polyline;
} CadaclysmBlacksmithAt;
A point at arc length: the point, the unit tangent there (zero where the curve stops), the curve's own parameter, and an estimate of how far the arc length to it can be trusted.
segment is CADACLYSM_BLACKSMITH_NONE on a solid's edge; on a profile it is the side the point lies on, its segment index, or the segment count for the implicit closing side, and parameter is that side's own (a line's 0..1, an arc's angle about its centre, a spline's parameter). from_polyline is 1 where the curve was a sampled polyline: exact for its points, not for whatever they were sampled from.
CadaclysmBlacksmithClash
typedef struct CadaclysmBlacksmithClash {
uint32_t a;
uint32_t b;
const char *kind;
double distance;
double on_a[3];
double on_b[3];
const char *kind_a;
uint32_t index_a;
uint32_t edge_a;
const char *kind_b;
uint32_t index_b;
uint32_t edge_b;
int32_t refined;
double depth;
const char *text;
} CadaclysmBlacksmithClash;
A pair that penetrates, touches, lies within the clearance, or could not be decided, borrowed from the clashes handle: valid until it is freed. kind is "penetrating", "touching", "too_close" or "refused". distance is the gap between the two boundaries (0 for penetrating and refused); on_a and on_b are world points — the closest pair, or for a penetrating pair the centre of the overlap's world box (the origin for a refused one). kind_a/index_a/edge_a (and _b) say what each point lies on exactly as CadaclysmBlacksmithClosest does ("face", "edge", "vertex"; index the kernel id; edge the edge-table row, CADACLYSM_BLACKSMITH_NONE for a face, a vertex, and an edge with no row), and are "none" (index 0, no edge) for a penetrating or refused pair. refined is 1 where the distance is measured on the exact surfaces. depth is the thinnest side of a penetrating pair's overlap box (0 otherwise); text says why a pair was refused ("" otherwise). a and b are part indices: for one set or a collider a < b; for two sets a indexes the first and b the second.
CadaclysmBlacksmithGearReport
typedef struct CadaclysmBlacksmithGearReport {
double pitch_radius;
double base_radius;
double tip_radius;
double root_radius;
double thickness;
bool undercut;
} CadaclysmBlacksmithGearReport;
A gear's key circles and thickness, written by the cadaclysm_blacksmith_profile_gear_* calls on success only. base_radius is NaN for cycloidal gearing; tip_radius is the largest radius on the profile and root_radius the smallest; thickness is the tooth (leaf) thickness on the pitch circle, as an arc length; undercut (involute only) says undercut would occur — it is not drawn.
CadaclysmBlacksmithSweptClash
typedef struct CadaclysmBlacksmithSweptClash {
uint32_t a;
uint32_t b;
double first_time;
uint32_t interval_count;
} CadaclysmBlacksmithSweptClash;
A pair that clashes somewhere on the path, or could not be decided. a and b are part indices: for one set or a collider a < b; for two sets a indexes the first and b the second. first_time is the first time the pair came within the clearance, in pose units (for a refused pair, the time it was refused at); the pose-wise row there is row i of cadaclysm_blacksmith_swept_clashes_firsts. interval_count is how many time ranges the pair stays in clash (0 for a refused pair), read with cadaclysm_blacksmith_swept_clashes_interval.
CadaclysmBlacksmithBox
typedef struct CadaclysmBlacksmithBox {
double lo[3];
double hi[3];
} CadaclysmBlacksmithBox;
An axis-aligned box: lo and hi, three doubles each.
CadaclysmBlacksmithColliderStats
typedef struct CadaclysmBlacksmithColliderStats {
uint32_t considered;
uint32_t world_boxes;
uint32_t oriented_boxes;
uint32_t skipped_share;
uint32_t cached;
uint32_t closed_form;
uint32_t meshed;
uint32_t refused;
uint32_t confirmed;
} CadaclysmBlacksmithColliderStats;
Counts of one cadaclysm_blacksmith_collider_check call: the candidate pairs considered, how many of them the world boxes and the oriented boxes cleared, how many the share left to another call, how the rest were answered (cached, closed_form, meshed), and how many were refused. confirmed is the subset of meshed that were thin mesh-path overlaps sent to common itself for a final answer (see the kernel's own doc).
CadaclysmBlacksmithCollisionHit
typedef struct CadaclysmBlacksmithCollisionHit {
uint32_t a;
uint32_t b;
bool overlap;
double depth;
const double *positions;
const double *normals;
const uint32_t *indices;
uint32_t vertex_count;
uint32_t index_count;
const char *text;
} CadaclysmBlacksmithCollisionHit;
A pair that interferes (overlap true), or could not be decided (overlap false; text says why, "" for an overlap). positions and normals are vertex_count world xyz triples, three per triangle (unwelded); indices is index_count entries; all empty (null, counts 0) for a refused pair. depth is the thinnest side of the overlap's world box, 0 for a refused pair.
CadaclysmBlacksmithDocumentProgress
typedef void (*CadaclysmBlacksmithDocumentProgress)(const char *node,
const char *phase,
size_t done,
size_t total,
void *user);
Where cadaclysm_blacksmith_document_evaluate_with reports: node the id of the node being built, phase a short static name ("snap", "clip", ...), done of total steps within it, user whatever was passed in. As CadaclysmBlacksmithProgress: called on the calling thread, often, so a sink that forwards elsewhere throttles itself; it must not call back into this library. The strings are valid for the call only. Null means silent.
CadaclysmBlacksmithProgress
typedef void (*CadaclysmBlacksmithProgress)(const char *phase, size_t done, size_t total, void *user);
Where a long operation reports: phase is a short static name ("snap", "clip", ...), done of total steps within it, user whatever was passed in. Called on the calling thread, often — once per vertex in some phases — so a sink that forwards elsewhere throttles itself. Must not call back into this library. Null means silent.
CadaclysmBlacksmithDraftPoint
typedef struct CadaclysmBlacksmithDraftPoint {
double point[3];
double uv[2];
double normal[3];
double angle;
} CadaclysmBlacksmithDraftPoint;
A point of a face and the draft angle there (cadaclysm_blacksmith_draft_angle_at): the point on the face, the surface parameters the normal was read at (both NaN where there are none), the face's outward unit normal there, and angle, asin(normal . d) in radians.
CadaclysmBlacksmithFaceDraft
typedef struct CadaclysmBlacksmithFaceDraft {
uint32_t face;
double min;
double max;
double area;
double positive;
double negative;
double vertical;
double undercut;
uint32_t kind;
} CadaclysmBlacksmithFaceDraft;
One face's draft over a body (cadaclysm_blacksmith_draft_analysis_face), every angle in radians and every area the face's measuring mesh's: face its index, min and max the least and greatest angle over its samples, area its whole area (0 for a sliver narrower than the mesh), positive the area at least +threshold, negative at most -threshold, vertical within it, undercut the area whose release ray meets the body, and kind one of CADACLYSM_BLACKSMITH_DRAFT_POSITIVE ... _UNDERCUT: undercut where any area is, else the band that holds the whole face, else mixed.
CadaclysmBlacksmithFemOptions
typedef struct CadaclysmBlacksmithFemOptions {
size_t size;
double tolerance;
double max_size;
} CadaclysmBlacksmithFemOptions;
What a FEM mesh is meshed to.
Zero it, set size, then set what you care about — cadaclysm_blacksmith_fem_options_init does the first two. A null pointer where one of these is expected means every default, so cadaclysm_blacksmith_fem_mesh(solid, NULL, NULL, NULL, NULL) is the short way in.
CadaclysmBlacksmithFemMeshView
typedef struct CadaclysmBlacksmithFemMeshView {
const double *nodes;
uint32_t node_count;
const uint32_t *triangles;
uint32_t triangle_count;
const uint32_t *triangle_face;
const uint32_t *node_kind;
const uint32_t *node_entity;
uint32_t face_count;
uint32_t edge_count;
uint32_t vertex_count;
uint32_t open_edge_count;
uint32_t folded_edge_count;
bool watertight;
bool from_mesh;
double min_angle;
uint32_t worst_triangle;
double longest_edge;
} CadaclysmBlacksmithFemMeshView;
The flat arrays of one FEM mesh, and its summary.
Every pointer is borrowed from the handle and good until cadaclysm_blacksmith_fem_mesh_free; none of them is a copy, and none of them is built by the call that hands it over.
CadaclysmBlacksmithFemEdge
typedef struct CadaclysmBlacksmithFemEdge {
uint32_t id;
const uint32_t *nodes;
uint32_t node_count;
const uint32_t *runs;
uint32_t run_count;
uint32_t face_a;
uint32_t face_b;
uint32_t end_a;
uint32_t end_b;
bool closed;
bool seam;
} CadaclysmBlacksmithFemEdge;
One B-rep edge of a FEM mesh: the chain of nodes along it, and where that chain breaks.
CadaclysmBlacksmithFemVertex
typedef struct CadaclysmBlacksmithFemVertex {
uint32_t node;
double point[3];
bool has_position;
} CadaclysmBlacksmithFemVertex;
One B-rep vertex of a FEM mesh: the node the mesh put there, if any, and where the topology says it is, if that is known.
One struct rather than three out-parameters: it matches the fill-an-out-struct-return-bool shape of every sibling accessor here and in intersection.rs, it gives the header and every wrapper a named type to pin a layout against, and it puts node's sentinel beside has_position where a caller reads both at once.
CadaclysmBlacksmithPoint
typedef struct CadaclysmBlacksmithPoint {
double x;
double y;
double z;
} CadaclysmBlacksmithPoint;
A point in model space.
CadaclysmBlacksmithSpot
typedef struct CadaclysmBlacksmithSpot {
uint32_t loop_index;
uint32_t segment;
double t;
uint32_t face;
double u;
double v;
} CadaclysmBlacksmithSpot;
Where a hit lands on one side. On a profile: loop_index (0 the boundary or the open chain, then the holes in the order they were added), segment, and t from 0 to 1 along it, with face NONE. On a solid's face: face and its (u, v), with loop_index and segment NONE.
CadaclysmBlacksmithHit
typedef struct CadaclysmBlacksmithHit {
bool run;
bool touch;
struct CadaclysmBlacksmithPoint start;
struct CadaclysmBlacksmithPoint end;
struct CadaclysmBlacksmithSpot a_start;
struct CadaclysmBlacksmithSpot a_end;
struct CadaclysmBlacksmithSpot b_start;
struct CadaclysmBlacksmithSpot b_end;
} CadaclysmBlacksmithHit;
One hit, copied out. A point (run false): start and end are the same point and each side's end spot is its start spot, touch true where the curves are tangent there rather than crossing (where a side ends there: true if the two continue each other smoothly, false at a corner or an end resting at an angle). A run (run true): the two curves coincide from start to end. A point at the join of two segments is reported once, on either: as segment k at t 1 or as segment k + 1 at t 0.
CadaclysmBlacksmithHlrOptions
typedef struct CadaclysmBlacksmithHlrOptions {
uint32_t size;
uint32_t projection;
double direction[3];
double up[3];
double eye[3];
double target[3];
double tolerance;
double smooth_angle;
double feature_angle;
uint32_t iso;
uint32_t reserved;
} CadaclysmBlacksmithHlrOptions;
How the solids are seen and what is drawn. size is sizeof(CadaclysmBlacksmithHlrOptions); fill it with cadaclysm_blacksmith_hlr_options_init and change what you need.
CadaclysmBlacksmithHlrLine
typedef struct CadaclysmBlacksmithHlrLine {
uint32_t kind;
uint32_t visible;
uint32_t solid;
uint32_t source_kind;
uint32_t source;
uint32_t source2;
uint32_t bezier_count;
uint32_t reserved;
double length2d;
double length3d;
} CadaclysmBlacksmithHlrLine;
One line of a view: what it is, whether it is seen, what it is a span of, and how many Béziers draw it. Read with cadaclysm_blacksmith_hlr_line.
CadaclysmBlacksmithHlrReport
typedef struct CadaclysmBlacksmithHlrReport {
uint32_t candidates;
uint32_t segments;
uint32_t crossings;
uint32_t pieces;
uint32_t degenerate;
uint32_t rays;
uint32_t mesh_hits;
uint32_t rejected;
uint32_t grazes;
uint32_t unsettled;
uint32_t mesh_only;
uint32_t fallback_edges;
uint32_t failed_solids;
uint32_t reserved;
double candidate_length;
double degenerate_length;
double tolerance;
} CadaclysmBlacksmithHlrReport;
What a view's hidden-line removal did. Read with cadaclysm_blacksmith_hlr_report.
CadaclysmBlacksmithFinding
typedef struct CadaclysmBlacksmithFinding {
const char *kind;
uint32_t argument;
uint32_t index;
uint32_t other;
double size;
} CadaclysmBlacksmithFinding;
One thing wrong with one argument, copied out of a check result. kind names it (a static string, valid for the library's life): "no_faces", "open", "region_wall", "non_manifold", "face_kind", "short_edge", "collapsed_edge", "sliver_face", "tiny_face", "tiny_body", "small_hole", "loose_edge", "curve_on_surface", "c0_inside", "self_intersection", "self_overlap", "unmeshable", "merge_vertex", "merge_edge", "merge_face" or "tangent_face". argument is 0 for the first solid, 1 for the second (0 for the four kinds on the pair). index, other and size are what the kind gives — see cadaclysm_blacksmith_check — and CADACLYSM_BLACKSMITH_NONE, CADACLYSM_BLACKSMITH_NONE and 0 where it gives none.
CadaclysmBlacksmithChain
typedef struct CadaclysmBlacksmithChain {
const double *points;
uint32_t point_count;
uint32_t face_a;
uint32_t face_b;
bool closed;
bool tangent;
bool has_curve;
} CadaclysmBlacksmithChain;
One branch of one face pair's crossing, borrowed from the intersection result: valid until it is freed. points is point_count xyz triples, in walk order (a closed chain does not repeat its first point); has_curve says whether cadaclysm_blacksmith_intersection_curve has anything for this chain — a tangent closed chain may have none (a closed chain that does not go once round its curve is reported without one, tangent still true, the points kept at their best estimate).
CadaclysmBlacksmithCurve
typedef struct CadaclysmBlacksmithCurve {
const char *kind;
struct CadaclysmBlacksmithPoint origin;
struct CadaclysmBlacksmithPoint x;
struct CadaclysmBlacksmithPoint y;
struct CadaclysmBlacksmithPoint z;
double radius;
double radius2;
double t0;
double t1;
uint32_t degree;
const double *knots;
uint32_t knot_count;
const double *poles;
uint32_t pole_count;
const double *weights;
} CadaclysmBlacksmithCurve;
One edge's exact curve, borrowed from the solid: valid until it is freed. See cadaclysm_blacksmith_edge_curve's doc for the range convention and what each field means for each kind.
CadaclysmBlacksmithOverlap
typedef struct CadaclysmBlacksmithOverlap {
uint32_t face_a;
uint32_t face_b;
const double *points;
const uint32_t *loop_offsets;
uint32_t point_count;
uint32_t loop_count;
} CadaclysmBlacksmithOverlap;
A region where a face of a and a face of b coincide, borrowed from the intersection result: valid until it is freed. points is point_count xyz triples, every ring back to back (outer first, holes after; two planes' common region once, curved faces' a's rings then b's), each ring closed but not repeating its first point; loop_offsets is loop_count starting indices into points counted in points, not doubles, so ring i is points[loop_offsets[i] .. loop_offsets[i + 1]] and the last ring runs to point_count. May carry zero rings (a partial overlap of curved faces whose outlines cross).
CadaclysmBlacksmithFacePoint
typedef struct CadaclysmBlacksmithFacePoint {
double point[3];
double uv[2];
double distance;
uint32_t where;
} CadaclysmBlacksmithFacePoint;
Where a point lies against a face: point its nearest point of the face (inside the trims or on their boundary), uv that point's parameters on the face's surface, distance from the asked point to it, and where 0 inside, 1 on the boundary (on an edge or a vertex of the face, or within the tolerance of one), 2 off (farther than the tolerance).
CadaclysmBlacksmithEdgePoint
typedef struct CadaclysmBlacksmithEdgePoint {
double point[3];
double t;
double distance;
bool on;
} CadaclysmBlacksmithEdgePoint;
The nearest point of an edge's curve over its range: point, t the curve's own parameter there (the one edge_curve and edge_closest_point use), distance from the asked point, and on where that is within the tolerance.
CadaclysmBlacksmithEdgeConvexity
typedef struct CadaclysmBlacksmithEdgeConvexity {
uint32_t kind;
double angle_min;
double angle_max;
double at_min[3];
double at_max[3];
uint32_t samples;
} CadaclysmBlacksmithEdgeConvexity;
How an edge's two faces meet along it: kind 0 smooth (within the angular tolerance of tangent everywhere), 1 convex (a ridge), 2 concave (a valley), 3 mixed (both along it), 4 open (one face, or three and more nowhere two at a time); the smallest and largest signed turn between the faces' outward normals found (radians: positive convex, negative concave) and where; the points asked (0 for an open edge or a closed surface's seam).
CadaclysmBlacksmithAngle
typedef struct CadaclysmBlacksmithAngle {
double angle;
double at_a[3];
double at_b[3];
uint32_t kind;
} CadaclysmBlacksmithAngle;
The angle between two entities (radians), a point on each where it is read, and kind what they were read as: 0 two planes (the angle between the outward normals, 0 to pi), 1 two lines (between the directions, 0 to pi), 2 a line and a plane (the line's angle to the plane, 0 to pi/2).
CadaclysmBlacksmithMinimumRadius
typedef struct CadaclysmBlacksmithMinimumRadius {
double radius;
double curvature;
double at[3];
double uv[2];
double direction[3];
uint32_t samples;
} CadaclysmBlacksmithMinimumRadius;
A face's smallest radius of curvature, 1 / max(|k1|, |k2|) (+inf for a plane); curvature that principal curvature signed about the face's outward normal (positive where the face bends away from it: a boss's side; negative toward it: a bore's wall); at and uv where; direction its unit principal direction; samples the grid stations read inside the trims (0 where a closed form answered).
CadaclysmBlacksmithAreaProperties
typedef struct CadaclysmBlacksmithAreaProperties {
double area;
double area_error;
double perimeter;
double centroid[2];
double centroid_error;
double second_moments[3];
double moments_error;
double principal_moments[2];
double principal_axes[4];
bool accuracy_met;
} CadaclysmBlacksmithAreaProperties;
A profile's area properties, in the profile's own plane: the area, its perimeter (every loop), the centroid; second_moments [Ixx, Iyy, Ixy] about the centroid — Ixx about the axis parallel to x, and Ixy the product integral (x - cx)(y - cy) dA itself, not negated (unlike cadaclysm_blacksmith_mass_properties' inertia, which negates products); principal_moments ascending, principal_axes their two unit axes [x0, y0, x1, y1] (the second the first turned +90 degrees); each *_error the bound the integration reached, and accuracy_met whether every bound is within the accuracy asked.
CadaclysmBlacksmithMassProperties
typedef struct CadaclysmBlacksmithMassProperties {
int32_t closed;
int32_t inverted;
int32_t accuracy_met;
int32_t from_mesh;
double area;
double area_error;
double volume;
double volume_error;
double centroid[3];
double centroid_error;
double inertia[9];
double inertia_error;
double principal_moments[3];
double principal_axes[9];
} CadaclysmBlacksmithMassProperties;
A solid's mass properties, per unit density, each figure beside a bound on its own error.
closed, inverted, accuracy_met and from_mesh are 1 or 0. The volume, the centroid and the inertia are meaningful only where closed is 1; they are left at zero otherwise, and the area is measured either way. Where accuracy_met is 0 the refinement gave up before reaching the accuracy asked for: the figures are still honest, they are simply less certain than requested, and the errors say by how much.
CadaclysmBlacksmithOrientedBox
typedef struct CadaclysmBlacksmithOrientedBox {
double centre[3];
double axes[9];
double half[3];
} CadaclysmBlacksmithOrientedBox;
A solid's box on its principal axes, per cadaclysm_blacksmith_oriented_box.
axes is row-major, unit and right-handed, row i the direction of the extent half[i]; centre is the middle of the box, which is not the centroid. The box is not minimal: it is the tightest box aligned with the principal axes of inertia, and where two moments are equal (a sphere, a cube) those axes are a free choice, so the box is one of many. The half extents are grown by the tolerance the measurement settled on, so they may exceed the body's own extent by about that much.
CadaclysmBlacksmithLength
typedef struct CadaclysmBlacksmithLength {
double length;
double error;
int32_t accuracy_met;
int32_t from_polyline;
} CadaclysmBlacksmithLength;
A measured length beside the error it carries.
error is an estimate of the difference from the true length, not a proof; where accuracy_met is 1 it bounds the error in practice, and where it is 0 the refinement stopped at its depth limit and the figure is less certain than was asked. from_polyline is 1 where the curve was a sampled polyline: exact for its points, not for whatever they were sampled from.
CadaclysmBlacksmithClosest
typedef struct CadaclysmBlacksmithClosest {
double distance;
double on_a[3];
double on_b[3];
const char *kind_a;
uint32_t index_a;
uint32_t edge_a;
const char *kind_b;
uint32_t index_b;
uint32_t edge_b;
int32_t refined;
} CadaclysmBlacksmithClosest;
The closest points between two solids' boundaries, and what each lies on.
distance is |on_a - on_b|. The boundaries are measured: a body wholly inside another without touching it is the gap between their boundaries, not 0 (whether two solids overlap is a different question), and boundaries that cross are 0 apart. Open bodies and sheets are accepted.
CadaclysmBlacksmithPointFoot
typedef struct CadaclysmBlacksmithPointFoot {
double distance;
double point[3];
const char *kind;
uint32_t index;
uint32_t edge;
double uv[2];
double normal[3];
int32_t refined;
} CadaclysmBlacksmithPointFoot;
The nearest point of a solid (or of one face) to a query point, and what it lies on.
distance is |point - p|; point lies on the body's boundary (a point inside a closed body is answered by its nearest boundary point, not 0). kind is a static string, "face", "edge" or "vertex" (never freed). index is the kernel id: the face index, the edge id (a FemEdge id) or the topology vertex index. edge is, for an edge, the index into the list cadaclysm_blacksmith_edge walks — what edge_length, fillet, chamfer and edge_closest_point take, so read edge, not index, for the public edge number — and CADACLYSM_BLACKSMITH_NONE for a face, a vertex, and an edge with no row there (one the brep holds without an exact curve).
CadaclysmBlacksmithCurvePair
typedef struct CadaclysmBlacksmithCurvePair {
double distance;
double t_a;
double point_a[3];
double t_b;
double point_b[3];
} CadaclysmBlacksmithCurvePair;
The closest points of two curves: t_a/point_a on the curve asked (the first argument), t_b/point_b on the other, distance between them (0 where they cross). Among equal distances the smallest t_a, then t_b, answers.
CadaclysmBlacksmithCurveBodyFoot
typedef struct CadaclysmBlacksmithCurveBodyFoot {
double distance;
double t;
double point_on_curve[3];
struct CadaclysmBlacksmithPointFoot body;
int32_t crossing;
} CadaclysmBlacksmithCurveBodyFoot;
The nearest points of a curve and a solid's boundary: t and point_on_curve on the curve, distance from there to the body, and body the point query's foot at point_on_curve, worded exactly as cadaclysm_blacksmith_closest_point words it (kind, index the kernel id, read body.edge for the public edge number, uv, normal, and refined — this answer's: 0 means distance is within [d - 2/3 tolerance, d + tolerance] of the true minimum d).
crossing is 1 where the curve passes through the boundary: distance is then exactly 0, the earliest crossing in t answers, and body.distance is the point query's own figure there (about 1e-12). 0 otherwise.
CadaclysmBlacksmithMeshPoint
typedef struct CadaclysmBlacksmithMeshPoint {
double point[3];
double distance;
uint32_t triangle;
uint32_t kind;
double barycentric[3];
uint32_t vertices[2];
} CadaclysmBlacksmithMeshPoint;
The nearest point of a triangle mesh (cadaclysm_blacksmith_triangle_mesh_closest_point): point on the mesh, distance to it, and triangle the lowest-numbered triangle holding the point — where it lies on an edge or a vertex several triangles share, the lower triangle answers.
kind is the feature the point lies on: 0 a face (inside triangle), 1 an edge, 2 a vertex. vertices names it: an edge's two vertex indices ascending (kind 1), the vertex and then UINT32_MAX (kind 2); UINT32_MAX marks an unused slot, so a face's are both UINT32_MAX. barycentric are the point's weights on triangle's three corners in index order, summing to 1.
CadaclysmBlacksmithCurveMeshFoot
typedef struct CadaclysmBlacksmithCurveMeshFoot {
double distance;
double t;
double point_on_curve[3];
struct CadaclysmBlacksmithMeshPoint mesh;
int32_t crossing;
} CadaclysmBlacksmithCurveMeshFoot;
The nearest points of a curve and a triangle mesh (cadaclysm_blacksmith_triangle_mesh_curve_closest_points): t and point_on_curve on the curve, mesh the foot on the mesh, worded as CadaclysmBlacksmithMeshPoint words it, and distance between them. Exact: no tolerance, no refined figure.
crossing is 1 where the curve passes through the mesh: distance is then exactly 0 and the earliest crossing in t answers. Among equal distances the lower triangle, then the lower t, answers. 0 otherwise.
CadaclysmBlacksmithSurfacePoint
typedef struct CadaclysmBlacksmithSurfacePoint {
double point[3];
double distance;
double u;
double v;
double normal[3];
int32_t boundary;
} CadaclysmBlacksmithSurfacePoint;
The nearest point of an untrimmed NURBS surface (cadaclysm_blacksmith_nurbs_surface_closest_point): point on the surface, distance to it, and u, v its parameters. Exact: no tolerance, no refined figure. Among equal distances the lower u, then the lower v, answers.
normal is the surface's unit normal at (u, v) (dS/du x dS/dv), all zeros where the partials are parallel (a pole). boundary is 1 where the point lies on an edge of the patch (u or v at an end of the domain) and the way to the query point is not along the normal — the edge, not the surface's interior, is what is nearest; 0 otherwise.
CadaclysmBlacksmithCurveSurfaceFoot
typedef struct CadaclysmBlacksmithCurveSurfaceFoot {
double distance;
double t;
double point_on_curve[3];
struct CadaclysmBlacksmithSurfacePoint surface;
int32_t crossing;
} CadaclysmBlacksmithCurveSurfaceFoot;
The nearest points of a curve and an untrimmed NURBS surface (cadaclysm_blacksmith_nurbs_surface_curve_closest_points): t and point_on_curve on the curve, surface the foot on the surface, worded as CadaclysmBlacksmithSurfacePoint words it (its distance is this one's), and distance between them. Exact: no tolerance, no refined figure.
crossing is 1 where the curve passes through the surface: distance is then exactly 0 and the earliest meeting in t answers. A curve that touches the surface without passing through it answers distance 0 and crossing 0. Among equal distances the lower u, then the lower v, then the lower t answers.
CadaclysmBlacksmithNearestObject
typedef struct CadaclysmBlacksmithNearestObject {
uint32_t which;
int32_t answer_kind;
double distance;
double t;
double point_on_curve[3];
double point_on_item[3];
struct CadaclysmBlacksmithCurveBodyFoot body;
struct CadaclysmBlacksmithCurvePair pair;
struct CadaclysmBlacksmithCurveMeshFoot mesh;
struct CadaclysmBlacksmithCurveSurfaceFoot surface;
} CadaclysmBlacksmithNearestObject;
The nearest item of a set to a curve (cadaclysm_blacksmith_nurbs_curve_closest_object): which its index into kinds, distance, the curve's t and point_on_curve, and the nearest point_on_item.
answer_kind says which member carries the item's own answer: 0 a body (a solid or a projector) — body is filled as cadaclysm_blacksmith_curve_closest_points fills it (read body.body.edge for the public edge number); 1 a curve — pair is filled as cadaclysm_blacksmith_nurbs_curve_closest_points(curve, item) fills it, t_a/point_a on the curve asked; 2 a point — neither; 3 a triangle mesh — mesh is filled as cadaclysm_blacksmith_triangle_mesh_curve_closest_points fills it; 4 an untrimmed NURBS surface — surface is filled as cadaclysm_blacksmith_nurbs_surface_curve_closest_points fills it. The values 0 to 3 are unchanged from before surfaces joined the set. Every field of a member answer_kind does not name is zero (body.body.kind null, and mesh.mesh.vertices 0 rather than UINT32_MAX).
CadaclysmBlacksmithSurfaceCurvature
typedef struct CadaclysmBlacksmithSurfaceCurvature {
double k1;
double k2;
double dir1[3];
double dir2[3];
double gaussian;
double mean;
double normal[3];
} CadaclysmBlacksmithSurfaceCurvature;
A surface's bending at a point (cadaclysm_blacksmith_nurbs_surface_curvature), signed about normal (dS/du x dS/dv, unit): a curvature is positive where the surface bends toward the normal. k1 >= k2 are the principal curvatures, dir1 and dir2 their unit tangent directions (any orthonormal pair at an umbilic), gaussian = k1 * k2, mean = (k1 + k2) / 2.
CadaclysmBlacksmithRegion
typedef struct CadaclysmBlacksmithRegion {
int32_t finite;
double min[3];
double max[3];
uint32_t sides;
uint32_t shells;
} CadaclysmBlacksmithRegion;
One region of a solid: finite 0 for region 0, the infinite one, and 1 for every other; min / max the box round the faces bounding it; sides how many face sides bound it (read them with cadaclysm_blacksmith_regions_side_at); shells how many connected boundaries it has: 1, plus one per void inside it.
CadaclysmBlacksmithFaceSide
typedef struct CadaclysmBlacksmithFaceSide {
uint32_t face;
int32_t sense;
} CadaclysmBlacksmithFaceSide;
One side of one face bounding a region: face the face's index in the solid, sense +1 where the region is the side the face's normal points to, -1 where it is the other side. A solid's own inside is bounded by its faces at -1.
CadaclysmBlacksmithCurvature
typedef struct CadaclysmBlacksmithCurvature {
double kappa;
double tangent[3];
double normal[3];
double binormal[3];
double centre[3];
int32_t has_centre;
} CadaclysmBlacksmithCurvature;
A curve's bending at a parameter: kappa (1 / radius), the unit tangent, the unit normal toward the centre and the binormal (tangent × normal), and the centre of the osculating circle. On a straight piece kappa is 0, normal and binormal are zero and has_centre is 0.
CadaclysmBlacksmithKnotContinuity
typedef struct CadaclysmBlacksmithKnotContinuity {
double angle;
double angle_parameter;
double angle_at[3];
double curvature;
double curvature_parameter;
double curvature_at[3];
} CadaclysmBlacksmithKnotContinuity;
How smoothly a curve runs through its own knots (a closed curve's seam among them): the largest turn of its tangent in radians (angle) and the largest jump of its curvature vector kappa * normal (curvature), each with the parameter and the point it was found at. A curve with no inner knot reads zero at its start.
CadaclysmBlacksmithContinuity
typedef struct CadaclysmBlacksmithContinuity {
double gap;
double gap_at[3];
double angle;
double angle_at[3];
double curvature;
double curvature_at[3];
uint32_t samples;
} CadaclysmBlacksmithContinuity;
How well two faces meet along their sides: the largest distance between the sides (gap), the largest angle between their normals in radians, which way each faces aside (angle), the largest difference of normal curvature square to the edge (curvature), each with where it was found, and how many points along the first side were asked.
CadaclysmBlacksmithCurvatureTurns
typedef struct CadaclysmBlacksmithCurvatureTurns {
uint32_t gaussian_positive;
uint32_t gaussian_negative;
uint32_t gaussian_turns;
uint32_t mean_positive;
uint32_t mean_negative;
uint32_t mean_turns;
uint32_t samples;
} CadaclysmBlacksmithCurvatureTurns;
Where a face's Gaussian and mean curvature change sign: how many separate areas of each sign the sample grid finds for each, how many points it found between opposite signs (cadaclysm_blacksmith_curvature_turn_points lists them), and the grid's steps each way. A dome or a saddle reads one area of one sign and no turn; a sheet whose sections wobble reads several areas and the turns between them. A sample within a millionth of the face's size of flat counts as neither sign.
CadaclysmBlacksmithHighlightKink
typedef struct CadaclysmBlacksmithHighlightKink {
double angle;
double at[3];
double light_point[3];
double light_direction[3];
uint32_t samples;
} CadaclysmBlacksmithHighlightKink;
The worst kink of the highlight lines crossing an edge: the angle in radians (0 to pi/2) between a line on one face and the same line on the other where they meet, where along the edge it is, and the light that shows it — a straight tube through light_point along light_direction (unit) — and how many points along the edge were read.
CadaclysmBlacksmithPatchBoundary
typedef struct CadaclysmBlacksmithPatchBoundary {
const struct CadaclysmBlacksmithSolid *sheet;
uint32_t face;
uint32_t side;
double from;
double to;
uint32_t level;
const struct CadaclysmBlacksmithNurbsCurve *curve;
} CadaclysmBlacksmithPatchBoundary;
One side of the hole cadaclysm_blacksmith_n_sided_patch fills: side side (0 the face's u = 0 isocurve, 1 u = 1, 2 v = 0, 3 v = 1) of face face of sheet, over from..to of the side's parameter (0..1 the whole side, 1..0 the whole side backwards), met at Glevel (0, 1 or 2); or, where sheet is NULL, the curve curve, met at G0.
CadaclysmBlacksmithPatchReport
typedef struct CadaclysmBlacksmithPatchReport {
uint32_t faces;
struct CadaclysmBlacksmithContinuity boundary;
struct CadaclysmBlacksmithContinuity internal;
double corner_angle;
} CadaclysmBlacksmithPatchReport;
How well an N-sided patch meets: faces sub-patches; the worst boundary figures against the neighbours (the gap over every side, the angle over those met at G1 or G2, the curvature jump over those at G2) and the worst internal across the patch's own spokes; and the largest corner_angle (radians) a corner of the hole leaves no patch able to meet — zero where the neighbours meet each other at G1 there.
CadaclysmBlacksmithCurveInfo
typedef struct CadaclysmBlacksmithCurveInfo {
uint32_t plane;
int32_t closed;
int32_t exact;
double error;
} CadaclysmBlacksmithCurveInfo;
The facts beside a curve in a CadaclysmBlacksmithCurveList: plane the contour plane it lies in (0 for a single section and for isocurves); closed 1 where it comes back to its start; exact 1 where every piece of it was an exact curve (a chain's line, circle, ellipse or NURBS, a face's edge, a surface's own isocurve); error its fit error, 0 where exact.
CadaclysmBlacksmithLengthMass
typedef struct CadaclysmBlacksmithLengthMass {
double length;
double length_error;
double centroid[3];
double centroid_error;
double inertia[9];
double inertia_error;
double principal_moments[3];
double principal_axes[9];
double radii[3];
int32_t accuracy_met;
int32_t from_polyline;
} CadaclysmBlacksmithLengthMass;
A curve's length mass properties, per unit length density (Rhino's LengthMassProperties), each figure beside an estimate of its own error.
inertia is row-major and symmetric, about the centroid, with the products negated (inertia[1] = -integral (x - gx)(y - gy) ds), as cadaclysm_blacksmith_mass_properties' is. principal_moments ascend; principal_axes is row-major, unit and right-handed, row i the axis of moment i; radii[i] is the radius of gyration about it, sqrt(principal_moments[i] / length). Where two moments agree within inertia_error any orthonormal pair spanning their plane is as right as another. The moments about another point follow by the parallel-axis rule from the centroid's. accuracy_met (1 or 0) says every error is within the accuracy asked of its scale; from_polyline is 1 for a sampled polyline (exact for its points).
CadaclysmBlacksmithJoinReport
typedef struct CadaclysmBlacksmithJoinReport {
uint32_t sewn;
uint32_t naked_before;
uint32_t naked_after;
uint32_t refused;
uint32_t turned;
double worst_gap;
int32_t closed;
} CadaclysmBlacksmithJoinReport;
What cadaclysm_blacksmith_join_sheets did. sewn: edges sewn, each two naked edges become one shared edge. naked_before, naked_after: edges bordered by one face, before the sewing (once the T-junctions are cut, so naked_before - 2 * sewn == naked_after) and after. refused: groups of naked edges that share both ends but were left apart (too far apart, or three or more of them). turned: faces whose sense the join turned. worst_gap: the widest gap between two sewn edges, 0 where every edge met exactly. closed: 1 where every edge is bordered twice and every vertex is one fan — a solid.
CadaclysmBlacksmithMesh
typedef struct CadaclysmBlacksmithMesh {
const float *positions;
const float *normals;
const uint32_t *indices;
uint32_t vertex_count;
uint32_t index_count;
} CadaclysmBlacksmithMesh;
A solid's triangles, borrowed from it.
CadaclysmBlacksmithMesh64
typedef struct CadaclysmBlacksmithMesh64 {
const double *positions;
const double *normals;
const uint32_t *indices;
uint32_t vertex_count;
uint32_t index_count;
} CadaclysmBlacksmithMesh64;
CadaclysmBlacksmithMesh in double: the same tessellation (the index pointer is the very one cadaclysm_blacksmith_mesh gives), positions and normals unnarrowed.
CadaclysmBlacksmithFaceTriangles
typedef struct CadaclysmBlacksmithFaceTriangles {
const uint32_t *counts;
uint32_t face_count;
} CadaclysmBlacksmithFaceTriangles;
How many triangles each face of a solid meshed to, borrowed from it.
CadaclysmBlacksmithPolylines
typedef struct CadaclysmBlacksmithPolylines {
const float *points;
const uint32_t *offsets;
uint32_t point_count;
uint32_t polyline_count;
} CadaclysmBlacksmithPolylines;
Polylines borrowed from a solid (its feature edges) or a profile (its outline): polyline i is points[offsets[i] .. offsets[i + 1]], three floats a point.
CadaclysmBlacksmithColours
typedef struct CadaclysmBlacksmithColours {
const double *rgb;
uint32_t count;
} CadaclysmBlacksmithColours;
Colours borrowed from a solid, one per polyline of its feature edges: rgb[3 * i .. 3 * i + 3] is polyline i's, in 0..1, or -1, -1, -1 for a polyline on no coloured edge. count is 0 (and rgb null) where the solid has no edge paint at all.
CadaclysmBlacksmithEdgeNormals
typedef struct CadaclysmBlacksmithEdgeNormals {
const float *normals;
uint32_t count;
} CadaclysmBlacksmithEdgeNormals;
cadaclysm_blacksmith_gpu_edge_normals' answer: twelve floats a Bezier, borrowed from the solid's cache.
CadaclysmBlacksmithSvgOptions
typedef struct CadaclysmBlacksmithSvgOptions {
uint32_t size;
uint32_t up;
double azimuth;
double elevation;
double fov;
double width;
double height;
double margin;
double tolerance;
double stroke_width;
uint32_t stroke;
uint32_t background;
uint32_t flags;
} CadaclysmBlacksmithSvgOptions;
How a solid's wireframe is drawn: the camera in the viewer's words, the page, the pen and which line sets. size is sizeof(CadaclysmBlacksmithSvgOptions), the struct's growth room, as in CadaclysmOpenOptions on the reader library. Fill it with cadaclysm_blacksmith_svg_options_init and change what you need.
CadaclysmBlacksmithGpuFace
typedef struct CadaclysmBlacksmithGpuFace {
uint32_t kind;
uint32_t reversed;
uint32_t transposed;
uint32_t reserved;
float origin[4];
float ax[4];
float ay[4];
float az[4];
float domain[4];
float scalars[4];
uint32_t loop_start;
uint32_t loop_count;
uint32_t profile_start;
uint32_t profile_count;
uint32_t profile2_start;
uint32_t profile2_count;
uint32_t nurbs_start;
uint32_t nurbs_count;
} CadaclysmBlacksmithGpuFace;
One trimmed face as the surface it actually is — the fields of CadaclysmFace (cadaclysm-capi), same order and layout: cadaclysm_brep_gpu::ffi::RawFace (cadaclysm::gpu_pack::Face) byte for byte. See that struct's doc for what each field means; it is not repeated here so the two never drift apart in prose while their layouts are pinned in code below.
CadaclysmBlacksmithGpuSurfaces
typedef struct CadaclysmBlacksmithGpuSurfaces {
const struct CadaclysmBlacksmithGpuFace *faces;
uint32_t face_count;
uint32_t surface_count;
const uint32_t *loops;
uint32_t loops_len;
const float *points;
uint32_t points_len;
const float *profiles;
uint32_t profiles_len;
const float *nurbs;
uint32_t nurbs_len;
const uint32_t *shared;
uint32_t shared_len;
const uint32_t *tiles;
uint32_t tiles_len;
const float *tile_domains;
uint32_t tile_domains_len;
const float *tile_samples;
uint32_t tile_samples_len;
const float *tile_boxes;
uint32_t tile_boxes_len;
const float *edges;
uint32_t edges_len;
double bounds[6];
double about[3];
} CadaclysmBlacksmithGpuSurfaces;
A solid's exact faces packed for a GPU surface evaluator, and its exact edges: the record the reader's cadaclysm_node_gpu_surfaces hands out for a part, for this solid. Every array's length is in its own scalars (u32 or float): faces is face_count records (CadaclysmBlacksmithGpuFace); loops two words a loop; points two floats a point; profiles four a sample; tiles two words a face (the tile grid nu, nv); tile_domains four floats a tile; tile_samples the density samples, three floats a point; tile_boxes six floats a tile; edges sixteen floats a rational cubic (four xyz points, four weights). Positions are about about; bounds (min xyz, max xyz) alone is in the solid's own coordinates. surface_count is the faces packed, one colour slot each.
CadaclysmBlacksmithEdge
typedef struct CadaclysmBlacksmithEdge {
const char *kind;
const uint32_t *faces;
uint32_t face_count;
const double *segments;
uint32_t segment_count;
} CadaclysmBlacksmithEdge;
One edge of a solid, borrowed from it: valid until the solid is freed.
CadaclysmBlacksmithRTreeHit
typedef struct CadaclysmBlacksmithRTreeHit {
uint32_t id;
double distance;
} CadaclysmBlacksmithRTreeHit;
One answer of a search, within or nearest: the entry's id and the distance from the query point to its box (0 inside it, and 0 for every search hit).
CadaclysmBlacksmithRTreePair
typedef struct CadaclysmBlacksmithRTreePair {
uint32_t a;
uint32_t b;
} CadaclysmBlacksmithRTreePair;
One overlapping pair: a and b are entry ids (a from the first tree for cadaclysm_blacksmith_rtree_overlaps, a <= b for ..._self_overlaps).
CadaclysmBlacksmithSheetRule
typedef struct CadaclysmBlacksmithSheetRule {
double thickness;
double bend_radius;
double k_factor;
uint32_t relief;
double relief_width;
double relief_depth;
uint32_t corner;
double corner_size;
double miter_gap;
} CadaclysmBlacksmithSheetRule;
How a sheet-metal part is made: the sheet's thickness, the bends' inner bend_radius (0: a hundredth of the thickness) and k_factor in [0, 1] (the neutral layer K T past the inner face); the bend relief (CADACLYSM_BLACKSMITH_RELIEF_*) cut where a flange is shorter than its edge, its width (0: T) and depth past the zone (0: T / 2); the corner relief (CADACLYSM_BLACKSMITH_CORNER_*) where two bends meet and its size (0: 2 T); the gap left between two flanges meeting at a corner (0: T / 10). cadaclysm_blacksmith_sheet_rule_default fills one.
CadaclysmBlacksmithSheetInfo
typedef struct CadaclysmBlacksmithSheetInfo {
double thickness;
uint32_t fixed_face;
uint32_t bend_count;
} CadaclysmBlacksmithSheetInfo;
A sheet body as cadaclysm_blacksmith_sheet_info reads it: its thickness, the flat face it is laid from, and how many bends it has.
CadaclysmBlacksmithBendInfo
typedef struct CadaclysmBlacksmithBendInfo {
uint32_t a_face;
uint32_t b_face;
double radius;
double angle;
double axis[6];
double line[6];
} CadaclysmBlacksmithBendInfo;
One bend of a sheet body: its face on the fixed face's side (a_face) and its partner (b_face), the inner radius, the signed angle (> 0 when a_face is inside: up from the fixed side), the axis (a point and a unit direction) and the bend's line on the mid-thickness surface (two points).
CadaclysmBlacksmithFlatBend
typedef struct CadaclysmBlacksmithFlatBend {
double centre[4];
double start[4];
double end[4];
double angle;
double radius;
double k_factor;
uint32_t up;
double allowance;
double deduction;
} CadaclysmBlacksmithFlatBend;
One bend zone of a flat pattern, in the flat's own plane: the centre line and the zone's start and end lines (each x0, y0, x1, y1), the signed angle, inner radius, k_factor, up (1 when it bends up, seen from the flat's top), the allowance and the deduction.
CadaclysmBlacksmithBend
typedef struct CadaclysmBlacksmithBend {
double line[4];
double angle;
double radius;
double k_factor;
} CadaclysmBlacksmithBend;
A bend to fold (cadaclysm_blacksmith_fold_flat): its line across the flat (x0, y0, x1, y1), the signed angle (> 0 up), inner radius and k_factor.
CadaclysmBlacksmithSubdParts
typedef struct CadaclysmBlacksmithSubdParts {
const double *positions;
uint32_t vertex_count;
const uint32_t *face_sizes;
uint32_t face_count;
const uint32_t *face_indices;
uint32_t index_count;
const uint32_t *creases;
uint32_t crease_count;
const uint32_t *pins;
uint32_t pin_count;
int32_t symmetry_axis;
double symmetry_tolerance;
uint32_t selection_kind;
const uint32_t *selection;
uint32_t selection_count;
} CadaclysmBlacksmithSubdParts;
A cage's parts, as views into its handle: valid until the handle is freed. positions is 3 * vertex_count doubles; face_sizes is face_count vertex counts and face_indices their loops one after another (index_count, the sum of face_sizes); creases is 2 * crease_count vertex ids, each pair smaller first, sorted; pins is pin_count vertices. symmetry_axis is -1 for none, 0 X, 1 Y, 2 Z, and symmetry_tolerance the on-plane distance of a mirrored half (0 when none). selection_kind is what the edit that made this handle selected (0 vertices, 1 edges, 2 faces, 3 none), and selection its selection_count ids, an edge selection as 2 * selection_count vertex ids.
CadaclysmBlacksmithSubdMesh
typedef struct CadaclysmBlacksmithSubdMesh {
const double *positions;
uint32_t vertex_count;
const double *normals;
const uint32_t *indices;
uint32_t index_count;
const uint32_t *triangle_face;
} CadaclysmBlacksmithSubdMesh;
A cage's smooth surface at one level, as views valid until the handle is freed, from any thread: each level's mesh is made once and kept (at most six), so asking for another level never frees one already lent out. positions and normals are 3 * vertex_count doubles: limit positions and unit outward limit normals. indices is index_count vertex ids, three per triangle, and triangle_face index_count / 3 entries: the face of the *full* cage each triangle lies on (on a mirrored half, face f of the half is f and its reflection f + face_count).
CadaclysmBlacksmithSubdReport
typedef struct CadaclysmBlacksmithSubdReport {
uint32_t regular;
uint32_t refined;
uint32_t steps;
uint32_t levels;
double deviation;
double g1_angle_deg;
double deviation_at[3];
double g1_at[3];
} CadaclysmBlacksmithSubdReport;
What cadaclysm_blacksmith_subd_to_solid did and how close it came: regular patches exact from their own net and refined ones from a refined neighbourhood, the Catmull-Clark steps taken first (1 or 2), and levels, the deepest local refinement a patch took (0 when none was refined). The largest deviation from the limit surface, as a fraction of the cage's bounding-box diagonal, and the largest tangent break g1_angle_deg across a side that is not creased, in degrees, with the world points they were measured at.
CadaclysmBlacksmithThicknessMesh
typedef struct CadaclysmBlacksmithThicknessMesh {
const double *positions;
const double *normals;
const uint32_t *indices;
const uint32_t *faces;
uint32_t vertex_count;
uint32_t triangle_count;
} CadaclysmBlacksmithThicknessMesh;
A body's measuring mesh, borrowed from the gauge (valid until it is freed): vertex_count vertices of three doubles each in positions and normals (unit, outward; no vertex is shared between two B-rep faces), triangle_count triangles of three indices each in indices, and the B-rep face of each triangle in faces. A reading's vertex indexes this mesh.
CadaclysmBlacksmithFaceThickness
typedef struct CadaclysmBlacksmithFaceThickness {
bool found;
double thickness;
double min;
double max;
bool uniform;
} CadaclysmBlacksmithFaceThickness;
One thickness for a face. found false means nothing found (no reading under the maximum, or an at whose foot is off the face): the numbers are then NaN and uniform false. Otherwise thickness is the median of the face's vertex readings (or the reading at at), min and max their extremes, and uniform is max - min within the tolerance.
CadaclysmBlacksmithThickness
typedef struct CadaclysmBlacksmithThickness {
uint32_t body;
uint32_t vertex;
uint32_t face;
double point[3];
double thickness;
double opposite[3];
uint32_t opposite_body;
uint32_t opposite_face;
bool knife;
double exact_thickness;
double exact_opposite[3];
double sphere;
} CadaclysmBlacksmithThickness;
One reading on a solid. point lies on face face of body body (a vertex of its measuring mesh, vertex; CADACLYSM_BLACKSMITH_NONE for a reading at a point, _thickness_gauge_at). thickness is the nearest-opposing-wall rule (the nearest triangle that faces against one of the vertex's own faces, with the vertex behind it) on the measuring mesh, to opposite on face opposite_face of body opposite_body; knife marks a knife edge (thickness 0, opposite = point). exact_opposite is opposite moved onto its exact face where its foot lies within the tolerance and inside the face's trims, exact_thickness the distance to it. sphere is the diameter of the largest ball tangent at point that holds none of the surfaces, NaN where none under the maximum does (0 on a knife edge).
CadaclysmBlacksmithMeshThickness
typedef struct CadaclysmBlacksmithMeshThickness {
uint32_t mesh;
uint32_t vertex;
double thickness;
double point[3];
double opposite[3];
uint32_t opposite_mesh;
uint32_t opposite_triangle;
bool knife;
} CadaclysmBlacksmithMeshThickness;
One reading on a plain mesh: vertex vertex of mesh mesh, at point, reads thickness to opposite on triangle opposite_triangle of mesh opposite_mesh (both indices within that mesh). knife: a knife edge, thickness 0 and opposite = point.
cadaclysm_view.h
Version and errors
cadaclysm_view_abi_version
uint32_t cadaclysm_view_abi_version(void);
(CADACLYSM_VIEW_ABI_MAJOR << 16) | CADACLYSM_VIEW_ABI_MINOR of this library.
cadaclysm_view_last_error
const char *cadaclysm_view_last_error(void);
Why this thread's last call failed; "" after one that did not. Valid until this thread's next call.
cadaclysm_view_name
const char *cadaclysm_view_name(void);
Which library this is, and its version: "cadaclysm-view <version>" (this library, wgpu) or "cadaclysm-terminal <version>" (the terminal's), so a wrapper knows what it loaded (1.3). Static; never NULL.
The view and its window
cadaclysm_view_create
struct CadaclysmView *cadaclysm_view_create(const struct CadaclysmViewWindow *window,
const struct CadaclysmViewOptions *options);
A view drawing into window. A view needs no reader: a scene needs cadaclysm_capi loaded when it is shown. NULL on failure, with the reason: no adapter of the asked backend for the window, a bad struct. options NULL: every default. On AppKit, create the view and draw it on the main thread. Create it once the window is mapped at its final size: on Qt, that is the first paintEvent, not showEvent.
window NULL: the library opens a window of its own (1.2), titled and sized by options, and cadaclysm_view_pump keeps it answering. Refused with "no display for a window of the view's own" where none is reachable. On Linux with no DISPLAY or WAYLAND_DISPLAY (a console) the window is the whole display instead, through KMS (1.17): the first connected output at its preferred mode, title, width and height unused, the keyboards and mice read from /dev/input (the user in the input group) and grabbed — the console under it gets none of their keys — and an arrow on the display's cursor plane. Escape or Ctrl+C closes it and gives the console back. It is refused, with that phrase and the console's reason, where the display has another master (a compositor) or no keyboard or mouse can be read, and while another such view is open; CADACLYSM_VIEW_CONSOLE=0 keeps to the plain refusal. Refused with "own windows belong to the thread that made the first one" on any thread but the one whose windowless create came first; on macOS, that is the main thread. Refused with "another event loop already exists in this process" where the host or another library has already made the process's one window event loop. The terminal library (cadaclysm_terminal) draws only to the process's own terminal: a window is refused ("the terminal draws only to its own output"), and window NULL probes the terminal once (its graphics protocol and cell size). A width of 0 is the terminal's width; a height of 0 is 1280 x 800's aspect of the width, capped (the width scaled with it) so the picture, its caption and a spare row fit the screen. title is the picture's caption (NULL: "Cadaclysm"); the environment variable CADACLYSM_TERMINAL_GRAPHICS forces sixel, kitty or blocks.
With options->offscreen 1 (1.4) and window NULL: a view with no window, width x height (0: 1280 x 800), needing no display — drawn with cadaclysm_view_draw and read with cadaclysm_view_image; run and pump refuse it. The terminal library refuses it.
cadaclysm_view_destroy
void cadaclysm_view_destroy(struct CadaclysmView *view);
Frees the view, and closes its own window if it has one. NULL is allowed. A view with a window of its own is freed only on the thread that made it; elsewhere it is kept, with the reason.
view must be NULL or from cadaclysm_view_create, and is not used again.
cadaclysm_view_pump
uint32_t cadaclysm_view_pump(struct CadaclysmView *view, uint32_t timeout_ms);
Handles pending events for every open window of a view's own, draws what is owed, and waits at most timeout_ms for events. CADACLYSM_VIEW_OPEN, or CADACLYSM_VIEW_CLOSED once this view's window is closed (Escape or its close button); 0 on a refusal: only a view with a window of its own is pumped, and only on the thread that made it. A closed view's pump still handles the other own windows and waits, then answers CLOSED.
The terminal library: one live picture at the bottom of the output, redrawn in place when the view needs a draw — unless something was written after it (a script's print, a still, another view), which then keeps it and gets a fresh picture below. Raw mode and mouse reporting are on only during the call, and the cursor reports it asks for are read inside it, so a script's own output and input() between pumps behave normally; a terminal that does not answer them is drawn over in place, with no mouse. The bytes read go through the gesture handler. CADACLYSM_VIEW_OPEN, or CADACLYSM_VIEW_CLOSED after q or Escape; a closed view's pump reads and writes nothing. Where stdout is not a terminal (piped, CI), one still is printed and the answer is CADACLYSM_VIEW_CLOSED. Only a view made with no window is pumped.
Picks, the host's and the window's own clicks alike, land as the pump draws; each answer waits for cadaclysm_view_pick_result (a newer one replaces it). A double click's answer says clicks 2; it frames what it hit as it lands only after cadaclysm_view_set_double_click_frames(view, true). The thread that makes the first own window must outlive them: once it has exited, own windows are unavailable for the rest of the process.
cadaclysm_view_run
bool cadaclysm_view_run(struct CadaclysmView *view,
struct CadaclysmViewCamera *camera_out,
struct CadaclysmViewPick *pick_out);
Blocks until the user closes the view's window (sharing the loop this view's window pumps with every other own window), drawing on demand and waiting otherwise. Then fills camera_out with the camera the view ended on (eye, target, up, orthographic) and pick_out with the last pick that landed while this call ran (item 0, the rest 0, for none), taking it — a later cadaclysm_view_pick_result or run does not report it again. A pick still in flight when the window closes (a click, then Escape before the next frame) is waited for briefly — at most a quarter of a second — and reported if it lands. With snapping on (1.22) the mouse hovering the window snaps and shows the marker, as cadaclysm_view_input describes; the last snap answer stays for cadaclysm_view_snap_result. Either out may be NULL, and neither out's own size is ever changed — only the fields after it — so a host reusing the same struct across calls (a REPL's run in a loop) keeps reading back the size it put there. Only for a view made with no window; false with the reason on a refusal, as cadaclysm_view_pump's — including "the window is closed" for a view whose window closed before this call. Can be called again later in the same process, also after pump.
The terminal library: the alternate screen and the orbit loop, through the gesture handler — drag orbits, right or Shift drag pans, the wheel zooms, t f r i the standard views, Space frames all, o orthographic, e edges, s saves cadaclysm-view.png, a click picks. q or Escape leaves; the last still is printed into the scrollback and the camera and last pick are returned. The view stays open. Where stdout is not a terminal, one still is printed and the call returns true at once.
view must be NULL or a live view; camera_out must be NULL or point at a CadaclysmViewCamera of at least camera_out->size bytes; pick_out must be NULL or point at a CadaclysmViewPick of at least pick_out->size bytes.
cadaclysm_view_resize
bool cadaclysm_view_resize(struct CadaclysmView *view, uint32_t width, uint32_t height);
The window's new size in physical pixels (a Qt host multiplies its logical size by devicePixelRatio). False for a NULL view or a zero size.
view must be NULL or a live view.
Scenes
cadaclysm_view_show
uint32_t cadaclysm_view_show(struct CadaclysmView *view, const CadaclysmScene *scene);
Shows scene (from cadaclysm_open). The item's id, 0 on failure. Every show keeps its item and leaves the upload to the next frame (cadaclysm_view_draw, cadaclysm_view_image), which uploads every item shown since in one go; a show fails at once only where the items with it would not fit the device's buffers, and a GPU rejecting the upload itself fails that frame instead. The scene must stay open until the item is removed or the view destroyed: exact parts are built from it when the surfaces mode changes. Fails, with the reason, where cadaclysm_capi is not loaded in the process or is a reader too old for this library (it lacks a call the view reads through); a reader loaded later is found by the next call.
view must be NULL or a live view; scene must be NULL or a live scene of the loaded reader.
cadaclysm_view_remove
bool cadaclysm_view_remove(struct CadaclysmView *view, uint32_t item);
Takes an item away. False where it is not shown, or where uploading what remains failed (the item is gone all the same). A machining (1.7) goes with its track off the timeline. An overlay (1.24) goes with no upload.
view must be NULL or a live view.
Items of your own
cadaclysm_view_set_item_layer
bool cadaclysm_view_set_item_layer(struct CadaclysmView *view, uint32_t item, uint32_t layer);
Puts item item on user layer layer, 0..31 (1.16); every item starts on 0. It draws where the layer is on (cadaclysm_view_set_user_layer) and, with viewports set, in those whose layer_mask has bit layer. False for an item not shown or a layer past 31. The terminal library accepts it too: with its one viewport, a mask lacking the item's layer hides it.
An overlay too (1.24): it draws while its layer is on, in every viewport — an overlay is the window's, drawn once over them all, so no viewport's layer_mask applies to it.
view must be NULL or a live view.
cadaclysm_view_set_occluded_style
bool cadaclysm_view_set_occluded_style(struct CadaclysmView *view,
const struct CadaclysmViewOccludedStyle *style);
How every CADACLYSM_VIEW_OCCLUDED_DASHED item's hidden lines and points look (1.20): the dash and gap in points, the share of coverage kept, and optionally one colour for all of them, ahead of every other line colour. NULL, or a struct of zeroes, is the default: 6 points on, 4 off, half the coverage, each line's own colour. Never applies to SOLID or OFF. Kept across uploads, removes and surface switches. No upload. The terminal library and render-view keep it and draw as before (neither draws DASHED). False, changing nothing, with cadaclysm_view_last_error naming the call and the field, for a size below the 1.20 struct's, a dash, gap or dim negative or not finite, a dim above 1, a dash or gap above 1000 points, or a colour component outside 0..1 where has_colour.
view must be NULL or a live view; style NULL or a CadaclysmViewOccludedStyle of style->size bytes.
cadaclysm_view_occluded_style
bool cadaclysm_view_occluded_style(const struct CadaclysmView *view,
struct CadaclysmViewOccludedStyle *out);
The occluded style in use (1.20), resolved: the defaults as their values (6, 4, 0.5), never zeroes; has_colour 0 or 1. Only out->size bytes are written, and out->size must be at least the 1.20 struct's. False for a NULL view or out.
view must be NULL or a live view; out NULL or a CadaclysmViewOccludedStyle of out->size bytes.
cadaclysm_view_set_line_colour
bool cadaclysm_view_set_line_colour(struct CadaclysmView *view,
uint32_t layer,
const float *rgb,
uint32_t from_part);
The colour of every line on layer (1.23): CADACLYSM_VIEW_LAYER_EDGES (a body's edges), _CURVES (curves and lines items) or _ISOCURVES, in rgb — three floats 0..1 as cadaclysm_view_set_colour takes them (clamped) — or, with from_part nonzero, in each part's own colour (a body's edges brightened so they read over its faces; rgb is kept for when it is turned off). The defaults: edges near-black, curves each part's own, isocurves grey. An item's own line colour (cadaclysm_view_set_item_line_colour) and a kernel solid's edge paint draw over it. No upload. The terminal library draws it too; the render view library keeps it and reads it back but draws its lines as before. False, changing nothing, with cadaclysm_view_last_error naming the call, for any other layer, a NULL rgb or a component not finite.
view must be NULL or a live view; rgb NULL or three floats.
cadaclysm_view_line_colour
bool cadaclysm_view_line_colour(const struct CadaclysmView *view,
uint32_t layer,
float *out_rgb,
uint32_t *out_from_part);
The colour of the lines on layer in use (1.23): its colour into out_rgb (three floats) and whether they take each part's colour into out_from_part (0 or 1); either may be NULL. False for a NULL view or a layer other than EDGES, CURVES and ISOCURVES.
view must be NULL or a live view; out_rgb NULL or room for three floats, out_from_part NULL or one uint32_t.
cadaclysm_view_set_point_state_colours
void cadaclysm_view_set_point_state_colours(struct CadaclysmView *view,
const float *hover,
const float *selected,
const float *first);
The view-wide point state colours (1.28), three floats 0..1 each: what a HOVER, SELECTED and FIRST point draws in (cadaclysm_view_set_point_states). NULL restores that state's default (hover #9CD3FF, selected and first #378ADD). A colour with a value not finite leaves every state as it was and sets the last error.
view must be NULL or a live view; each colour NULL or three readable floats.
cadaclysm_view_show_mesh
uint32_t cadaclysm_view_show_mesh(struct CadaclysmView *view,
const struct CadaclysmViewMesh *mesh);
A mesh of the caller's arrays — positions, optional normals, triangles, optional edge segments — in rgb (NULL: the default colour). The item's id, 0 on failure: a NULL or undersized struct, a count that is not whole, an index past the vertices, a value that is not finite. Copied in; mesh and its arrays are the caller's again when this returns.
view must be NULL or a live view; mesh NULL or a CadaclysmViewMesh whose arrays hold the counts it gives.
cadaclysm_view_show_lines
uint32_t cadaclysm_view_show_lines(struct CadaclysmView *view,
const float *segments,
uint32_t segment_count,
const float *rgb);
Straight segments, six floats each (two xyz points), drawn as one item on the curves layer in rgb (NULL: the curves' colour). They never pick. The item's id, 0 on failure.
view must be NULL or a live view; segments NULL or segment_count * 6 floats; rgb NULL or three floats.
cadaclysm_view_show_points
uint32_t cadaclysm_view_show_points(struct CadaclysmView *view,
const float *positions,
uint32_t point_count,
const float *rgb,
float size_px);
Points, three floats each (x, y, z), drawn as one item: a disc of size_px device pixels across (1 to 64; device pixels at the host's screen density, which hosts that set one — the web View, mobile — scale) in rgb (NULL: the edge colour), at each. They never pick; the item is framed by its points' box. The item's id, 0 on failure — a value not finite, a size out of range.
The terminal library: refuses (0, nothing shown) — it has no way to draw a dot.
view must be NULL or a live view; positions NULL or point_count * 3 floats; rgb NULL or three floats.
cadaclysm_view_show_curves
uint32_t cadaclysm_view_show_curves(struct CadaclysmView *view,
const float *beziers,
uint32_t curve_count,
const float *rgb);
Rational cubic Beziers, sixteen floats each (four control points as x, y, z, weight), drawn as one item on the curves layer in rgb (NULL: the curves' colour): exact curves where the exact pass runs, sampled where it does not. They never pick. The item's id, 0 on failure — a value not finite, a weight not positive.
The terminal library: accepted with a difference — it has no exact pass, so every curve is sampled as a polyline, there or not.
view must be NULL or a live view; beziers NULL or curve_count * 16 floats; rgb NULL or three floats.
cadaclysm_view_show_image
uint32_t cadaclysm_view_show_image(struct CadaclysmView *view,
const struct CadaclysmViewImage *image);
A reference image on a quad in the model: corners bottom-left, bottom-right, top-right, top-left; rgba width * height pixels, rows top first; opacity 0..1 (0 in a zeroed struct is 1). Drawn after the opaque geometry, both sides; never picks. The item's id, 0 on failure.
The terminal library: refuses (0, nothing shown) — it has no way to draw a textured quad.
view must be NULL or a live view; image NULL or a CadaclysmViewImage whose rgba holds width * height * 4 bytes.
cadaclysm_view_set_colour
bool cadaclysm_view_set_colour(struct CadaclysmView *view, uint32_t item, const float *rgb);
Recolours an item in place (no upload): rgb three floats in 0..1. False where the item is not shown or rgb is NULL or not finite.
Overlay text (CADACLYSM_VIEW_TEXT_SCREEN) takes the colour too, its glyphs recoloured in place (its box keeps its own), and so does an overlay shape: its fill where it has one and its stroke where it has one, each keeping its alpha, under the same id and draw order. An overlay image is refused, the reason naming it: it draws its own pixels.
view must be NULL or a live view; rgb NULL or three floats.
cadaclysm_view_set_xray
bool cadaclysm_view_set_xray(struct CadaclysmView *view, uint32_t item, bool on);
Draws the item's triangles after everything else, depth-tested but without writing depth, so an overlay shows through the parts in front of it (on true) — or normally again (false). Kept across uploads, removes of other items and surface switches. Exact surfaces and face picks treat the item as ordinary geometry. Since 1.30 its lines and points (its own edges included) are picked (cadaclysm_view_pick within the aperture, cadaclysm_view_pick_rect) and snapped through whatever covers them. The terminal accepts it and draws the item as ordinary geometry. False where the item is not shown, or is an overlay (it draws over everything already), the reason naming it.
view must be NULL or a live view.
cadaclysm_view_set_occluded
bool cadaclysm_view_set_occluded(struct CadaclysmView *view, uint32_t item, uint32_t mode);
How the item's lines and points draw where a surface is in front of them (1.13): its edges and isocurves, a curves item's curves, a lines item's segments, a points item's points — never its triangles (cadaclysm_view_set_xray). CADACLYSM_VIEW_OCCLUDED_OFF (not drawn, the default), _SOLID (drawn through) or _DASHED (drawn through, dashed and dimmed; a point as a dimmed ring). Kept across uploads, removes of other items and surface switches. An x-ray item's points draw through, solid, whatever this says. The terminal accepts every mode and draws it as OFF. The render view library accepts OFF and refuses SOLID and DASHED: it draws no occluded lines yet. False where the item is not shown, is an overlay (nothing is in front of one), mode is not one of the three, or the render view library refuses it.
view must be NULL or a live view.
cadaclysm_view_set_item_line_colour
bool cadaclysm_view_set_item_line_colour(struct CadaclysmView *view,
uint32_t item,
uint32_t layer,
const float *rgb);
Draws item item's lines on layer (1.23) — CADACLYSM_VIEW_LAYER_EDGES, _CURVES or _ISOCURVES — in rgb (three floats 0..1, clamped), over the view-wide cadaclysm_view_set_line_colour, the item's colour (cadaclysm_view_set_colour) and a kernel solid's own edge paint; NULL takes the view-wide colour again. A DASHED item's hidden lines still take the occluded style's colour where it has one. The exact surfaces' edges and curves too. Kept across uploads, removes of other items, moves and surface switches. No upload. The terminal library draws it too; the render view library accepts NULL and refuses a colour: it draws no item's own line colour yet. False, with cadaclysm_view_last_error naming the call, where the item is not shown, is an overlay (it has none of those lines: an overlay shape's stroke takes cadaclysm_view_set_colour), the layer is not one of the three, a component is not finite, or the render view library refuses it.
view must be NULL or a live view; rgb NULL or three floats.
cadaclysm_view_set_finish
bool cadaclysm_view_set_finish(struct CadaclysmView *view, uint32_t item, uint32_t finish);
The item's finish (1.18): CADACLYSM_VIEW_FINISH_GLOSS (the default), _SATIN or _MATTE, for its triangles and its exact faces. Under CADACLYSM_VIEW_LIGHTING_SHOWROOM gloss is the clear coat mirroring the room, sharp and silver at a grazing angle; satin a weaker, blurred coat; matte no mirror, a faint grey sheen — a black tyre stays black. Under studio lighting, which has no highlight, every finish draws as gloss; under the headlight satin and matte draw a soft and a faint highlight riding the camera. Kept across uploads, removes of other items and surface switches. Uploads the scene again, as a show does: set it on each item as it is shown, not over a finished scene item by item. The terminal accepts every finish and draws it as gloss; the render view library accepts GLOSS and refuses SATIN and MATTE. False where the item is not shown, is an overlay (it is not shaded), finish is not one of the three, or the render view library refuses it.
view must be NULL or a live view.
cadaclysm_view_set_face_colours
bool cadaclysm_view_set_face_colours(struct CadaclysmView *view,
uint32_t item,
const uint32_t *faces,
const float *rgba,
uint32_t count);
Colours faces of an item: faces[i] in rgba[4 * i ..] (alpha unused), count of them; faces NULL clears every face colour. Face numbers are the item's pick numbers. False where the item is not shown, is an overlay (it has no faces), or a value is not finite.
view must be NULL or a live view; faces NULL or count words; rgba 4 * count floats.
cadaclysm_view_set_placement
bool cadaclysm_view_set_placement(struct CadaclysmView *view,
uint32_t item,
const double *matrix);
Moves an item by matrix, sixteen doubles column-major (entry 4 * col + row), kept across uploads; NULL puts it back where it was shown. False where the item is not shown or a number is not finite, and for an overlay, the reason naming it: an overlay hangs from its anchor in screen space; cadaclysm_view_move_overlay moves it.
view must be NULL or a live view; matrix NULL or sixteen doubles.
cadaclysm_view_set_item_visible
bool cadaclysm_view_set_item_visible(struct CadaclysmView *view, uint32_t item, bool visible);
Hides an item whole (visible false) or shows it again (1.27): a hidden item draws nothing — triangles, lines, points, text, exact surfaces — is never picked or snapped, and is left out of cadaclysm_view_frame and every box the camera fits. It shows only where its layer is also shown. Its node switches (cadaclysm_view_set_node_visible) are kept underneath. True where it is shown or hidden now (already so included); false, with "set_item_visible: no item N", where the item is not shown.
view must be NULL or a live view.
cadaclysm_view_set_line_style
bool cadaclysm_view_set_line_style(struct CadaclysmView *view,
uint32_t item,
float dash_pt,
float gap_pt);
Draws item item's lines in its own dash (1.28): dash_pt points on, gap_pt off, laid along its edges, curves, segments, isocurves and exact edges; dash_pt 0 is solid (the default), whatever gap_pt. A hidden line the item draws SOLID (cadaclysm_view_set_occluded) takes the same dash; a DASHED item's hidden stretch keeps the view-wide occluded style. Kept across uploads, removes of other items and surface switches. The terminal accepts any pattern and draws solid. The render view library accepts 0 and refuses a dash: it draws no dashes yet. False where the item is not shown or is an overlay, a length is negative, not finite or past 511.5, or a dash has no gap.
view must be NULL or a live view.
cadaclysm_view_set_point_style
bool cadaclysm_view_set_point_style(struct CadaclysmView *view,
uint32_t item,
uint32_t shape,
bool hollow);
A points item's marker (1.28): CADACLYSM_VIEW_POINT_DISC (the default), _RING, _SQUARE or _DIAMOND, filled or hollow. Kept across uploads. False where the item is not shown or not a points item, or shape is not one of the four.
view must be NULL or a live view.
cadaclysm_view_set_point_states
bool cadaclysm_view_set_point_states(struct CadaclysmView *view,
uint32_t item,
const uint8_t *states,
size_t count);
A points item's per-point states (1.28): count bytes, one a point in the order shown — CADACLYSM_VIEW_POINT_STATE_NORMAL, _HOVER, _SELECTED or _FIRST. Hover and selected draw the point in their colour (cadaclysm_view_set_point_state_colours); first keeps its colour and draws a ring round it. Written into the drawn points in place. Kept across uploads. False where the item is not shown or not a points item, states is NULL with a count above 0, count is not the item's point count, or a state is past 3. NULL with a count of 0 is an empty list (an item with no points takes it).
view must be NULL or a live view; states NULL (with count 0) or count readable bytes.
cadaclysm_view_set_on_top
bool cadaclysm_view_set_on_top(struct CadaclysmView *view, uint32_t item, bool on);
Draws item item after every other item, depth testing off (1.28): over whatever is in front of it, on-top items in id order among themselves; its hidden lines draw SOLID and its points draw through. Picked ahead of what is under it. Kept across uploads. The terminal accepts it and draws the item in place. The render view library accepts false and refuses true. False where the item is not shown, or is an overlay, text, an image, a body shown with exact surfaces (a cadaclysm_view_show_curves item is accepted since 1.29: its exact edges draw on top), or a machining stock. Glyph items (1.29) are accepted.
view must be NULL or a live view.
cadaclysm_view_show_glyphs
uint32_t cadaclysm_view_show_glyphs(struct CadaclysmView *view,
const float *at,
const float *dir,
size_t count,
uint32_t kind,
float size_pt,
const float *colour);
Shows count glyphs of one kind (1.29, CADACLYSM_VIEW_GLYPH_*) as one item: at at (three floats each), turned to dir as projected on the screen (three floats each; NULL: all unturned; ARROW points along it), size_pt points across (1 to 128; device pixels at the host's screen density, which hosts that set one — the web View, mobile — scale) at any zoom, in colour (NULL: the edge colour, as cadaclysm_view_show_points). kind is one of ARROW 0, TICK 1, CROSS 2, SQUARE 3, TRIANGLE 4, PARALLEL 5, PERPENDICULAR 6, COINCIDENT 7, TANGENT 8, FIXED 9, HORIZONTAL 10, VERTICAL 11 (CADACLYSM_VIEW_GLYPH_<NAME>). Glyph i is node i: it picks as the item and node i, and the node calls reach it. Under the curves layer; hidden behind a surface at its anchor unless x-ray or on top. The item's id, 0 on failure. The terminal library and the render view library draw no glyphs and refuse it.
view must be NULL or a live view; at NULL (with count 0) or count * 3 floats; dir NULL or count * 3 floats; colour NULL or three floats.
cadaclysm_view_show_solid
uint32_t cadaclysm_view_show_solid(struct CadaclysmView *view,
const CadaclysmBlacksmithSolid *solid,
double tolerance,
const float *rgb);
Shows a kernel solid by its handle, read in place: exact surfaces where they draw, triangles at tolerance (0: 0.05) otherwise, its edges, its paint (or rgb over it). The item's id, 0 on failure. The solid must stay alive until the item is removed or the view destroyed. Needs cadaclysm_blacksmith loaded in the process; the view never links it. Fails, with the reason, where the kernel is not loaded or is too old for this library (it lacks a call the view reads a solid through).
The item's faces — what a pick reports and cadaclysm_view_set_face_colours takes — are numbered as the solid numbers them (cadaclysm_blacksmith_face_count's faces), exact or as triangles.
view must be NULL or a live view; solid NULL or a live solid of the loaded kernel; rgb NULL or three floats.
cadaclysm_view_show_solid_faces
uint32_t cadaclysm_view_show_solid_faces(struct CadaclysmView *view,
const CadaclysmBlacksmithSolid *solid,
double tolerance,
const float *rgb,
uint32_t material,
float opacity,
const uint32_t *faces,
uint32_t face_count);
cadaclysm_view_show_solid in a material and an opacity, all the solid's faces or only some (1.21): material one of CADACLYSM_VIEW_MATERIAL_*, opacity 0..1 (1 opaque), faces NULL for every face, else face_count of the solid's face numbers to show alone, with no edges — a trim's ghost. The item's faces are numbered as the solid numbers them, faces or not. 0 on failure: cadaclysm_view_show_solid's, a material not one of the seven, an opacity outside 0..1, or a face the solid does not have.
view must be NULL or a live view; solid NULL or a live solid of the loaded kernel; rgb NULL or three floats; faces NULL or face_count words.
Live geometry
cadaclysm_view_set_lines
bool cadaclysm_view_set_lines(struct CadaclysmView *view,
uint32_t item,
const float *segments,
size_t count);
Replaces line item item's segments (1.29): segments six floats a segment (two xyz points), count segments, under the same id — colour, layer, dash, placement, on top kept, the camera not re-framed. Written in place, or appended to the item's own range, with no merge; a view drawing half precision, and the terminal library, merge and upload instead. The render view library refuses it. False where the item is not shown, is not a cadaclysm_view_show_lines item, or a value is not finite. NULL with count 0 is an empty list.
view must be NULL or a live view; segments NULL (with count 0) or count * 6 floats.
cadaclysm_view_set_curves
bool cadaclysm_view_set_curves(struct CadaclysmView *view,
uint32_t item,
const float *beziers,
size_t count);
Replaces curves item item's Beziers (1.29): beziers sixteen floats a curve (four control points as x, y, z, weight), count curves, under the same id; kept as cadaclysm_view_set_lines keeps. The sampled polyline goes as cadaclysm_view_set_lines does; the exact curves are written in place for the same count, and another count sends the exact half again. The render view library refuses it. False where the item is not shown, is not a cadaclysm_view_show_curves item, or a value is not finite or a weight not positive. NULL with count 0 is an empty list.
view must be NULL or a live view; beziers NULL (with count 0) or count * 16 floats.
cadaclysm_view_set_points
bool cadaclysm_view_set_points(struct CadaclysmView *view,
uint32_t item,
const float *positions,
size_t count);
Replaces points item item's positions (1.29): positions three floats a point, count points, under the same id. The same count keeps the states and writes in place; a new count sends the points again, keeping states, node colours, highlights and hidden flags by index, new points normal. The render view library and the terminal library draw no points, so no points item exists there. False where the item is not shown, is not a cadaclysm_view_show_points item, or a value is not finite. NULL with count 0 is an empty list.
view must be NULL or a live view; positions NULL (with count 0) or count * 3 floats.
cadaclysm_view_set_mesh_positions
bool cadaclysm_view_set_mesh_positions(struct CadaclysmView *view,
uint32_t item,
const float *positions,
const float *normals,
size_t count);
Replaces mesh item item's vertex positions (1.29): positions three floats a vertex, normals NULL or three floats a vertex, count vertices — the count the item was shown with (cadaclysm_view_show_mesh), in the same order. NULL normals are recomputed, facet for a mesh shown without normals and smooth for one shown with. Written in place, the terminal library included, uploaded only under half precision; colour, paint, look and placement kept. It drops the mesh's simplified levels of detail until the next merge. The render view library refuses it. False where the item is not shown, was not shown with cadaclysm_view_show_mesh, was shown with edges, count is not its vertex count, or a value is not finite.
view must be NULL or a live view; positions and normals (when not NULL) count * 3 floats.
Frames
cadaclysm_view_needs_draw
bool cadaclysm_view_needs_draw(const struct CadaclysmView *view);
Whether a draw is owed: a change, an upload or exact refinement still settling, a pick or a snap waiting for its answer. A snap's answer that has landed and not been read owes none, unlike a pick's: the draw that landed it drew its marker, and a hover's answers are many and may go unread (1.22). True, too, while the device is lost or the document is still owed to a rebuilt one: the next cadaclysm_view_draw rebuilds or re-uploads. True while the view's timeline plays or a track is still catching up (1.7).
view must be NULL or a live view.
cadaclysm_view_draw
bool cadaclysm_view_draw(struct CadaclysmView *view);
Draws and presents to the window. On AppKit, call it on the main thread. False with a reason where the device was lost and could not be rebuilt yet (the next draw tries again), or where this draw lost the device or the GPU reported an error while drawing. A loss is reported once, by the draw that finds it; the next draw rebuilds the device. While the rebuild itself keeps failing, each draw returns false with the rebuild's reason. A rebuild, or a retried re-upload onto a rebuilt device, drops a pick in flight (cadaclysm_view_request_pick) — its readback lived on the lost device and would never land; the host asks again. False, too, from the third draw in a row whose window gave no frame to present (usually a cadaclysm_view_resize size that is not the window's current client size) until a frame is presented or the view is resized.
Ticks the view's timeline by the wall clock first (1.7): a track's refusal is reported once, by the draw that meets it, after the frame is drawn.
An offscreen view (1.4): renders without presenting — nothing is shown anywhere — and lands a pick in flight, as a window's draw does; every draw lands a snap in flight (1.22); read the frame with cadaclysm_view_image.
cadaclysm_view_size
bool cadaclysm_view_size(struct CadaclysmView *view, uint32_t *width, uint32_t *height);
The size cadaclysm_view_image writes, in physical pixels: the view's drawing size, as cadaclysm_view_resize last set it (1.4). False for a NULL out.
view must be NULL or a live view; width and height NULL or writable.
cadaclysm_view_image
bool cadaclysm_view_image(struct CadaclysmView *view, uint8_t *rgba, size_t capacity);
Draws one frame at the view's size (cadaclysm_view_size) and writes it to rgba: width * height * 4 bytes, RGBA8, rows from the top (1.4). Synchronous: it waits for the GPU. As cadaclysm_view_draw, it uploads the items shown since the last frame first, and fails with the reason where the GPU rejects them.
Every view: an offscreen one, the own window, a host's window (the frame is drawn apart from what the window presents). False where capacity is too small (the reason says how many bytes are needed) or rgba is NULL. The terminal library reads its picture from its CPU raster.
view must be NULL or a live view; rgba NULL or capacity writable bytes.
The camera
cadaclysm_view_orbit
void cadaclysm_view_orbit(struct CadaclysmView *view, float dx, float dy);
Orbits the camera by a drag of dx, dy pixels (in orthographic, pans). A non-finite delta is ignored. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_pan
void cadaclysm_view_pan(struct CadaclysmView *view, float dx, float dy);
Pans the camera by a drag of dx, dy pixels. A non-finite delta is ignored. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_zoom
void cadaclysm_view_zoom(struct CadaclysmView *view, float steps);
Zooms by steps wheel notches: positive zooms in. A non-finite value is ignored. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_frame
bool cadaclysm_view_frame(struct CadaclysmView *view, uint32_t item);
Fits the camera to item, or to everything shown for 0. False where the item is not shown, is an overlay (it is in screen space: there is nothing of it to fit; "everything shown" leaves the overlays out too), or there is nothing to fit. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_standard
bool cadaclysm_view_standard(struct CadaclysmView *view, uint32_t which);
A standard view, CADACLYSM_VIEW_STANDARD_*: top looks down the up axis. False for another value. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_set_orthographic
void cadaclysm_view_set_orthographic(struct CadaclysmView *view, bool on);
An orthographic camera (true) or a perspective one. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_frame_node
bool cadaclysm_view_frame_node(struct CadaclysmView *view, uint32_t item, uint32_t node);
Fits the camera to node of item and its subtree. False where the item is not a shown scene or the node is out of range.
view must be NULL or a live view.
cadaclysm_view_focus
bool cadaclysm_view_focus(struct CadaclysmView *view, const float *point);
The orbit point moved to point (1.8): three floats, in the coordinates the items were shown in (a pick's point). The eye keeps its direction and distance from the target — the camera moves sideways, the view does not turn. Leaves fly mode. False, changing nothing, for a NULL view or point, a point not finite, or while viewports are set.
view must be NULL or a live view; point NULL or three readable floats.
cadaclysm_view_look
void cadaclysm_view_look(struct CadaclysmView *view, float dx, float dy);
Turns the camera about its eye by a drag of dx, dy pixels (fly). Non-finite: ignored. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_dolly
void cadaclysm_view_dolly(struct CadaclysmView *view, float ratio);
Scales the eye's distance by ratio (below 1 is closer), as a pinch does. Non-finite or not positive: ignored. Viewport 0's: with viewports set, its camera moves (a fixed one does not).
view must be NULL or a live view.
cadaclysm_view_aim
bool cadaclysm_view_aim(struct CadaclysmView *view,
uint32_t viewport,
const float *direction,
const float *up);
Turns viewport viewport's camera to look along direction (three floats, world): an orbit camera from that side of its target, a fly camera at its pivot from where it is, an ortho camera square to it with up (three floats) its screen up — NULL, zero or along the direction: +Y up for a look along Z, else +Z. False for a fixed camera, a zero or non-finite direction, no such viewport. The render view library refuses a viewport other than 0.
view must be NULL or a live view; direction, up NULL or three floats each.
cadaclysm_view_set_pivot
bool cadaclysm_view_set_pivot(struct CadaclysmView *view,
uint32_t viewport,
const float *point);
The point (three floats, world) Alt and the left button orbit viewport viewport about; NULL: its own target again. The render view library refuses it: it has a single camera with no pivot.
view must be NULL or a live view; point NULL or three floats.
cadaclysm_view_orbit_in
void cadaclysm_view_orbit_in(struct CadaclysmView *view, uint32_t viewport, float dx, float dy);
cadaclysm_view_orbit on viewport viewport (by its camera: a fly camera orbits its pivot, an ortho one pans; a fixed one does not move). Past the last viewport: nothing.
view must be NULL or a live view.
cadaclysm_view_pan_in
void cadaclysm_view_pan_in(struct CadaclysmView *view, uint32_t viewport, float dx, float dy);
cadaclysm_view_pan on viewport viewport. Past the last viewport: nothing.
view must be NULL or a live view.
cadaclysm_view_zoom_in
void cadaclysm_view_zoom_in(struct CadaclysmView *view, uint32_t viewport, float steps);
cadaclysm_view_zoom on viewport viewport: an ortho camera zooms about its centre, a fly camera dollies. Past the last viewport: nothing.
view must be NULL or a live view.
cadaclysm_view_look_in
void cadaclysm_view_look_in(struct CadaclysmView *view, uint32_t viewport, float dx, float dy);
cadaclysm_view_look on viewport viewport. Past the last viewport: nothing.
view must be NULL or a live view.
cadaclysm_view_dolly_in
void cadaclysm_view_dolly_in(struct CadaclysmView *view, uint32_t viewport, float ratio);
cadaclysm_view_dolly on viewport viewport. Past the last viewport: nothing.
view must be NULL or a live view.
cadaclysm_view_frame_in
bool cadaclysm_view_frame_in(struct CadaclysmView *view, uint32_t viewport, uint32_t item);
cadaclysm_view_frame on viewport viewport: item 0 fits everything shown. An overlay is refused, as there.
view must be NULL or a live view.
cadaclysm_view_standard_in
bool cadaclysm_view_standard_in(struct CadaclysmView *view, uint32_t viewport, uint32_t which);
cadaclysm_view_standard on viewport viewport: an ortho camera turns to the named plane (ISO refused); a fly or fixed one answers true with nothing moved. False past the last viewport.
view must be NULL or a live view.
Viewports
cadaclysm_view_set_viewports
bool cadaclysm_view_set_viewports(struct CadaclysmView *view,
const struct CadaclysmViewViewport *viewports,
uint32_t count);
Splits the window into viewports, each drawn by the matrices it carries; NULL or 0 puts back the built-in camera. While set, each viewport's camera is fixed: orbit, pan, zoom, look, dolly, frame and standard leave it; cadaclysm_view_set_viewport_camera gives a viewport a camera the view moves (1.10). The array's stride is viewports[0].size; every element carries the same size. False, changing nothing, for a mixed size, a value not finite, a grid not a CADACLYSM_VIEW_GRID_*.
The terminal library: refuses (false, changing nothing) more than one viewport; one viewport is accepted and drawn over the whole picture.
view must be NULL or a live view; viewports NULL or count elements of viewports[0].size bytes each.
cadaclysm_view_viewport_camera
bool cadaclysm_view_viewport_camera(const struct CadaclysmView *view,
uint32_t viewport,
struct CadaclysmViewViewportCamera *out);
Viewport viewport's camera: what it draws with now (rect, view, projection, eye) and its kind and state, CADACLYSM_VIEW_CAMERA_*. With no viewports set, viewport 0 is the built-in orbit camera. False past the last viewport. out.size must be at least the 1.10 struct's. The render view library refuses a viewport other than 0: it has the one camera.
view must be NULL or a live view; out NULL or a CadaclysmViewViewportCamera of out->size bytes.
cadaclysm_view_set_viewport_camera
bool cadaclysm_view_set_viewport_camera(struct CadaclysmView *view,
uint32_t viewport,
const struct CadaclysmViewViewportCamera *camera);
Gives viewport viewport a camera of camera->kind, from that kind's fields (its rect is not read: cadaclysm_view_set_viewport_rects). With no viewports set only an orbit camera fits viewport 0. A distance, speed, radius or height that is not positive takes its default (1, 1, 1, 100). False, changing nothing, for a value not finite, an ortho basis that is not unit and perpendicular, a kind not CADACLYSM_VIEW_CAMERA_*. The render view library refuses a viewport other than 0, and any kind but an orbit camera.
view must be NULL or a live view; camera NULL or a struct of camera->size bytes.
cadaclysm_view_set_viewport_rects
bool cadaclysm_view_set_viewport_rects(struct CadaclysmView *view,
const uint32_t *rects,
uint32_t count);
Moves the viewports: count rects of four uint32_t (x, y, width, height, physical pixels), one a viewport, their cameras untouched — an empty rect hides a viewport and keeps its camera. False unless count is the number of viewports set. The render view library refuses it: it has one camera, so one viewport.
view must be NULL or a live view; rects NULL or 4 * count readable uint32_ts.
cadaclysm_view_set_viewport_label
bool cadaclysm_view_set_viewport_label(struct CadaclysmView *view,
uint32_t viewport,
const char *text,
const float *colour);
Names viewport viewport (1.28): text (UTF-8) drawn top left inside it at 12 points in colour (three floats; NULL: the text default, white); NULL text clears it. Kept across cadaclysm_view_set_viewport_rects, and across cadaclysm_view_set_viewports while the index survives (NULL viewports keep viewport 0's). A pick on it answers viewport_label (the pick's item 0). The terminal accepts it and prints it as characters, as it prints overlays; the render view library accepts NULL text and refuses a label. False for no such viewport, text not UTF-8 or a colour not finite.
view must be NULL or a live view; text NULL or NUL-terminated; colour NULL or three floats.
cadaclysm_view_set_viewport_border
bool cadaclysm_view_set_viewport_border(struct CadaclysmView *view,
uint32_t viewport,
const float *colour);
Frames viewport viewport in colour (1.28), one point wide inside its edge; NULL clears it. Kept and cleared as the label is; never picked. The terminal accepts it and prints it as characters, as it prints overlays; the render view library accepts NULL and refuses a border. False for no such viewport or a colour not finite.
view must be NULL or a live view; colour NULL or three floats.
Textures for your own renderer
cadaclysm_view_create_on_device
struct CadaclysmView *cadaclysm_view_create_on_device(const struct CadaclysmViewDevice *device,
const struct CadaclysmViewOptions *options);
Creates a view on the host's own device and queue: it draws into a texture on that device, handed back by cadaclysm_view_texture after each draw. NULL with the reason otherwise.
The host's objects. device and queue (and for Vulkan instance and physical_device) are the host's: it keeps them alive until cadaclysm_view_destroy, and the view destroys none of them. The view submits on queue from wherever the host calls cadaclysm_view_draw, so the host calls it where it submits its own work (or under its own lock).
Sync. Queue order: the host submits the work that samples the texture after the draw. Every call on the view may submit on the host's queue or wait on it — not only cadaclysm_view_draw, but cadaclysm_view_resize, cadaclysm_view_image, a pick, and cadaclysm_view_destroy, which waits until the queue is idle — so the host makes all of them where it submits its own work, or under its own queue lock.
cadaclysm_view_texture
bool cadaclysm_view_texture(struct CadaclysmView *view, struct CadaclysmViewTexture *out);
The texture of the last draw — or, on creation and right after a resize, the new texture undrawn (drawn 0) for the host to adopt — written to out up to out->size bytes. On a host-device view: kind VULKAN_IMAGE (texture the VkImage, state VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL), METAL_TEXTURE (the id<MTLTexture>, state 0) or D3D12_RESOURCE (the ID3D12Resource*, state PIXEL_SHADER_RESOURCE | NON_PIXEL_SHADER_RESOURCE); slot 0 of 1; no fences. Owned by the view: valid until the next generation or cadaclysm_view_destroy. On a shared view: after a draw, the slot it filled (drawn 1, its ready_value and release_value), whatever out->slot says; while the generation is undrawn, the slot named by out->slot on input (drawn 0, values 0), so the host adopts every slot of the three — out of range refused; kind WIN32_HANDLE (an NT handle in texture), POSIX_FD (fd; import a dup()) or METAL_SHARED (an MTLSharedTextureHandle), the fences' handles or fds, memory_size for a Vulkan import, state D3D12 COMMON / Vulkan SHADER_READ_ONLY_OPTIMAL / Metal 0. Every handle and fd is the view's: valid until the next generation or cadaclysm_view_destroy; the host opens or imports its own. False with the reason on a view that draws into a window or offscreen.
out->size must reach at least generation (an older, shorter struct cannot carry the texture): smaller is refused.
view must be NULL or a live view; out NULL or a CadaclysmViewTexture whose size the caller set.
cadaclysm_view_release
bool cadaclysm_view_release(struct CadaclysmView *view, uint64_t release_value);
The host's release of release_value on the CPU, for a host that cannot signal the release fence (Vulkan shared mode without CADACLYSM_VIEW_SHARED_HOST_SEMAPHORES), once its sampling work has completed — refused past the last frame drawn. On every other view a no-op that returns true.
view must be NULL or a live view.
A display through KMS
cadaclysm_view_kms_info
bool cadaclysm_view_kms_info(const struct CadaclysmView *view,
struct CadaclysmViewKmsInfo *out);
Fills out with how the KMS view draws onto its display (1.19): its buffers' path (CADACLYSM_VIEW_KMS_GBM, _GPU or _COPY), their format and modifier, the connector, the mode, the display's device and the Vulkan device that draws. out->size is left as the caller set it. A view of CADACLYSM_VIEW_WINDOW_KMS and a window of the view's own at a console answer; false, with "draws onto no KMS display", for any other view, and for a NULL or undersized out.
The terminal library refuses it: "KMS displays need the wgpu view library".
view must be NULL or a live view; out NULL or a CadaclysmViewKmsInfo of at least out->size bytes.
cadaclysm_view_kms_probe
bool cadaclysm_view_kms_probe(const struct CadaclysmViewWindow *window,
struct CadaclysmViewKmsInfo *out);
Fills out with how cadaclysm_view_create would draw onto the display window names (1.19), without taking the display or drawing: a window of CADACLYSM_VIEW_WINDOW_KMS, read as create reads it, or NULL for the display a window of the view's own takes at a console (the first connected output at its preferred mode). The same output and Vulkan device are chosen as create would choose; for CADACLYSM_VIEW_KMS_GBM one buffer is made and taken by the display, then freed, so its modifier is the one create would get. False, with the reason create would give, where it would be refused — the display has another master (a compositor), no connected output, no Vulkan device, the host's mode is not the connector's — and for a NULL or undersized out. Slow: it enumerates the Vulkan devices. While a KMS view of this process is open, a probe that opens the display itself finds that view its master and says so; cadaclysm_view_kms_info answers for it.
The terminal library refuses it: "KMS displays need the wgpu view library".
window must be NULL or point at a CadaclysmViewWindow of at least its size bytes, window->display NULL or an int, an open DRM fd; out NULL or a CadaclysmViewKmsInfo of at least out->size bytes.
What draws
cadaclysm_view_set_surfaces
bool cadaclysm_view_set_surfaces(struct CadaclysmView *view, uint32_t surfaces);
CADACLYSM_VIEW_SURFACES_EXACT or _TRIANGLES. False for another value.
The terminal library: accepted with a difference — it has no exact pass, so CADACLYSM_VIEW_SURFACES_EXACT is taken but cadaclysm_view_surfaces still reads back CADACLYSM_VIEW_SURFACES_TRIANGLES, and every surface draws as triangles.
view must be NULL or a live view.
cadaclysm_view_surfaces
uint32_t cadaclysm_view_surfaces(const struct CadaclysmView *view);
What draws: _EXACT only where it was asked for and the device draws it. CADACLYSM_VIEW_SURFACES_TRIANGLES for a NULL view.
view must be NULL or a live view.
cadaclysm_view_set_layer
bool cadaclysm_view_set_layer(struct CadaclysmView *view, uint32_t layer, bool on);
Switches a layer, CADACLYSM_VIEW_LAYER_*, on or off. False for another value.
The terminal library: CADACLYSM_VIEW_LAYER_EDGES also switches CADACLYSM_VIEW_LAYER_CURVES (an SDK's B-rep edges are drawn there as curves, so the two must move together for on/off to mean "the drawing's edges"); CADACLYSM_VIEW_LAYER_GRID is accepted but draws nothing. CADACLYSM_VIEW_LAYER_TEXT (1.6): every text item, labels and world text.
view must be NULL or a live view.
cadaclysm_view_set_user_layer
bool cadaclysm_view_set_user_layer(struct CadaclysmView *view, uint32_t layer, bool on);
Switches user layer layer, 0..31, on or off in every viewport (1.16); all start on. False past 31.
view must be NULL or a live view.
cadaclysm_view_set_background
void cadaclysm_view_set_background(struct CadaclysmView *view, const float *rgb);
The colour the view is cleared to: rgb, three linear floats in 0..1 (clamped). A NULL or non-finite colour is refused and changes nothing.
view must be NULL or a live view; rgb must be NULL or point at 3 floats.
cadaclysm_view_set_lighting
bool cadaclysm_view_set_lighting(struct CadaclysmView *view, uint32_t lighting);
How plain parts are lit (1.9): CADACLYSM_VIEW_LIGHTING_HEADLIGHT, the default — whatever faces the camera is bright — CADACLYSM_VIEW_LIGHTING_STUDIO, a key light fixed above the model, ambient and a fill from the camera, so a top reads brighter than its sides from anywhere, or (1.15) CADACLYSM_VIEW_LIGHTING_SHOWROOM, a showroom fixed in the world mirrored in a clear coat over the colours (a terminal view draws it as studio). False, changing nothing, with cadaclysm_view_last_error naming cadaclysm_view_set_lighting, for another value or a NULL or closed view.
view must be NULL or a live view.
cadaclysm_view_lighting
uint32_t cadaclysm_view_lighting(const struct CadaclysmView *view);
The lighting in use, CADACLYSM_VIEW_LIGHTING_* (1.9); the headlight for a NULL view.
view must be NULL or a live view.
cadaclysm_view_set_analysis
bool cadaclysm_view_set_analysis(struct CadaclysmView *view,
const struct CadaclysmViewAnalysis *analysis);
Draw every surface for judging it (1.14), in place of the lighting: analysis->mode CADACLYSM_VIEW_ANALYSIS_ZEBRA (zebra stripes, fixed to the camera), _ISOPHOTES (lines of equal angle to one light), _GAUSSIAN, _MEAN, _MIN or _MAX (curvature as false colour, blue negative, green zero, red positive), or _NONE; NULL is NONE. Zeros take the defaults (see CadaclysmViewAnalysis). Edges, curves, the grid, text, images, points and stocks are drawn as before. The terminal library accepts NONE only. False, changing nothing, with cadaclysm_view_last_error naming the call, for a size below the 1.14 struct's, an unknown mode or a value out of range.
view must be NULL or a live view; analysis NULL or a CadaclysmViewAnalysis of analysis->size bytes.
cadaclysm_view_analysis
bool cadaclysm_view_analysis(const struct CadaclysmView *view,
struct CadaclysmViewAnalysis *out);
The analysis in use (1.14), into out with every default filled in: only out->size bytes are written, and out->size must be at least the 1.14 struct's. False for a NULL view or out.
view must be NULL or a live view; out NULL or a CadaclysmViewAnalysis of out->size bytes.
Colour
cadaclysm_view_parse_colour
bool cadaclysm_view_parse_colour(const char *text, float *out);
A colour's text as r, g, b in 0..1, into out[0..3] (1.5): "#rgb", "#rrggbb" (the # optional) or one of the 148 CSS Color Module Level 4 names, matched case-insensitively — the same forms as the reader's cadaclysm_parse_colour, but as floats, the type every colour of this header takes, and without the reader loaded. Text carries no alpha: a wrapper filling a four-float rgba from text sets the alpha to 1. False, with cadaclysm_view_last_error naming the text, for anything else (transparent, currentcolor, rgb(..), #rgba, ...), and for a NULL text or out; out is then untouched. Needs no view.
text must be NULL or a NUL-terminated string; out NULL or room for three floats.
Text
cadaclysm_view_load_font
uint32_t cadaclysm_view_load_font(const uint8_t *bytes, size_t length);
A font for every view of this library: TTF or OTF bytes, copied in. Font 0 is the bundled one and needs no loading. The font's id; 0 on failure (bytes that are not a font, an empty font, a font with no outlines), with the reason.
bytes must be NULL or readable for length bytes.
cadaclysm_view_show_text
uint32_t cadaclysm_view_show_text(struct CadaclysmView *view,
const struct CadaclysmViewText *text);
Text shown as one item (a label, world text or — 1.24 — an overlay's screen text, as text->mode says); its id, 0 on failure (NULL or non-UTF-8 text, an unknown mode, align or font, a height not finite and positive, a number not finite, world right and up parallel), with the reason. Screen text is an overlay (cadaclysm_view_show_overlay): hung from the window's align anchor, offset pixels inward, in order, picked before anything beneath it, moved by cadaclysm_view_move_overlay.
The terminal library: accepted with a difference — a label is printed as terminal characters over the picture, one character row a line whatever its height, at the cell under its anchor (offset and box_padding turned into whole cells, alignment counted in characters), and picked on those cells; world text draws into the picture; screen text is printed as a label is, at the cell under its anchor.
view must be NULL or a live view; text NULL or a CadaclysmViewText of text->size bytes whose text is NULL or a NUL-terminated string.
cadaclysm_view_set_text
bool cadaclysm_view_set_text(struct CadaclysmView *view, uint32_t item, const char *text);
The item's string replaced, nothing else changed. Overlay text's too (screen text, 1.24). False for an item that is not text (an overlay shape or image is named as one), or text that is NULL or not UTF-8.
view must be NULL or a live view; text NULL or a NUL-terminated string.
Overlays
cadaclysm_view_show_overlay
uint32_t cadaclysm_view_show_overlay(struct CadaclysmView *view,
const struct CadaclysmViewOverlay *shape);
A 2D shape over the window, as one item: shape->beziers (a blacksmith profile's, sixteen floats a curve) in pixels, y up, its origin at the anchor plus the offset — closed loops filled even-odd, every loop stroked, as has_fill and has_stroke say. Drawn after everything else over the whole window (once, whatever the viewports), in order; never moved by the camera; kept where it is as the window resizes. A click on its fill, or within a few pixels of its stroke, picks it (CadaclysmViewPick.overlay), and nothing beneath it. cadaclysm_view_move_overlay moves it, cadaclysm_view_remove takes it away, cadaclysm_view_set_item_layer puts it on a user layer. The item's id; 0 on failure: no curves, a number not finite, a weight not positive, an unknown anchor, with the reason.
The terminal library: accepted with a difference — it prints the shape as characters over the picture: a cell whose centre is inside the fill a full block in the fill's colour, a cell the stroke crosses a box-drawing line in the stroke's.
view must be NULL or a live view; shape NULL or a CadaclysmViewOverlay of shape->size bytes whose beziers holds curve_count * 16 floats.
cadaclysm_view_show_overlay_image
uint32_t cadaclysm_view_show_overlay_image(struct CadaclysmView *view,
const struct CadaclysmViewOverlayImage *image);
An image over the window, as one item: image->rgba copied in, drawn extent pixels across and down (0: its own size) at opacity, its box hanging from the anchor as text's does (its top-right corner at a top-right anchor), plus the offset. Drawn, picked, moved and removed as cadaclysm_view_show_overlay's shapes are. The item's id; 0 on failure: no pixels, bytes that do not make the size, an extent not finite or negative, an unknown anchor, with the reason.
The terminal library: refuses (0, nothing shown), as it refuses cadaclysm_view_show_image.
view must be NULL or a live view; image NULL or a CadaclysmViewOverlayImage of image->size bytes whose rgba holds width * height * 4 bytes.
cadaclysm_view_move_overlay
bool cadaclysm_view_move_overlay(struct CadaclysmView *view,
uint32_t item,
uint32_t anchor,
float x,
float y);
Overlay item — a shape, an image or screen text — hung from another anchor at another offset (pixels inward, as CadaclysmViewOverlay::offset), its order kept. Cheap: a HUD element may move every frame. False for an item that is no overlay, an unknown anchor or an offset not finite.
view must be NULL or a live view.
Frame statistics
cadaclysm_view_stats
bool cadaclysm_view_stats(struct CadaclysmView *view, struct CadaclysmViewStats *out);
Fills out with what the view has drawn (1.25): frames_drawn, the frames drawn so far — each frame drawn to its window or texture (an own window's pump, a host's cadaclysm_view_draw) and each picture cadaclysm_view_image rendered; an offscreen view's cadaclysm_view_draw renders nothing, so its frames are its images. A pump or draw that owes or draws nothing does not count, so a still scene's count stays put. Then the last frame's last_frame_ms (CPU), last_gpu_ms (the GPU's clock, the latest frame it has answered for, read back without waiting; -1 where the device has no timestamp queries, on WebGL2, on a host's device or before the first), triangles and draw_calls. out->size is left as the caller set it. False for a NULL or undersized out.
The terminal library: frames_drawn counts the pictures it rendered, last_frame_ms their time, triangles those a picture showed; last_gpu_ms -1 and draw_calls 0.
view must be NULL or a live view; out NULL or a CadaclysmViewStats of at least out->size bytes.
Input events
cadaclysm_view_next_event
bool cadaclysm_view_next_event(struct CadaclysmView *view, struct CadaclysmViewInputEvent *out);
Takes the oldest input event the view's own window handled and has not handed out yet (1.26) into out: true with one, false with "no event" while the queue is empty — as cadaclysm_view_pick_result answers before its answer lands, never waiting. out->size is left as the caller set it.
An own window (and the console, and the terminal library's view) queues every input it handles, in order, as well as handling it: a drag still orbits, Escape still closes, W still flies — the events report, they do not intercept. CADACLYSM_VIEW_INPUT_EVENT_* names each kind: - POINTER_DOWN, _MOVE, _UP: x, y in physical pixels (as cadaclysm_view_input takes them), button, pointer, pointer_id, modifiers. Consecutive moves of one pointer with the same modifiers are coalesced into the latest. Buttons past the middle are not reported, nor a touch the system cancels. - WHEEL: wheel_y (a DOM deltaY: negative forward), at the pointer's x, y. - KEY_DOWN, KEY_UP: key, the KeyboardEvent.code name ("KeyR", "Digit1", "Space", "Escape", "ArrowUp", "ShiftLeft", "F5"), modifiers, repeat — every key, the ones the view binds (W, A, S, D, E, Q, Tab, Escape, ...) and the ones it does not, with Ctrl or not. - RESIZE: width, height, the drawing area's new physical size. - PICK: a pick a click (or double click) asked has landed: pick, the same answer cadaclysm_view_pick_result then gives — both see it, so a host reads either. A host's own cadaclysm_view_request_pick is not queued. 1.30: pick_segment and pick_distance_px carry the pick's segment and distance_px. - SNAP: with snapping on, a snap the window's input asked has landed — a hover's (clicks 0) or a click's: snap, as cadaclysm_view_snap_result gives it. A host's own cadaclysm_view_request_snap_in is not queued. 1.30: snap keeps its 1.22 layout (size 88); snap_label, snap_locked, snap_locked_angle, snap_guide_count and snap_guides carry the rest. - CLOSE: the window closed (Escape, its close button, cadaclysm_view_close) — the last event, with camera the camera it closed on, as cadaclysm_view_run reports it; the queue is still read after cadaclysm_view_pump answers CADACLYSM_VIEW_CLOSED. - TIMELINE (1.27): the timeline's clock moved this frame — it played, or the host sought, played or paused it — at most one a drawn frame, with no fields beyond time_ms; the host reads cadaclysm_view_timeline_time.
The queue holds 1024 events: past that, the oldest pointer move is dropped first, then the oldest event of any kind; the next event read says how many went (dropped). A host that blocks in cadaclysm_view_run and never reads keeps only the latest.
cadaclysm_view_close
bool cadaclysm_view_close(struct CadaclysmView *view);
Closes the view's own window as its close button does (1.26): hidden, a CLOSE event queued, cadaclysm_view_pump answering CADACLYSM_VIEW_CLOSED and a cadaclysm_view_run returning; the view stays live until cadaclysm_view_destroy. True, and nothing more, for a window already closed. The terminal library: the live picture ends, as q ends it. The console: as Escape. False for a view in a host's window or offscreen — "only a view with a window of its own is closed" — and on a thread other than the own windows' one.
view must be NULL or a live view.
Nodes
cadaclysm_view_set_node_visible
bool cadaclysm_view_set_node_visible(struct CadaclysmView *view,
uint32_t item,
uint32_t node,
bool visible);
Shows or hides node (the reader's node index) of item and its whole subtree. False where the item is not shown or the node is out of range; an overlay, which has no nodes, is refused by name, as by cadaclysm_view_set_node_color, _set_node_highlight and _frame_node.
view must be NULL or a live view.
cadaclysm_view_set_node_color
bool cadaclysm_view_set_node_color(struct CadaclysmView *view,
uint32_t item,
uint32_t node,
const float *rgba);
Colours node of item and its whole subtree: rgba four floats in 0..1 (clamped; the alpha is not used), NULL clears. A node colour wins over the node's own; a face's does not change. False where the item is not shown, the node is out of range, or a component is not finite.
view must be NULL or a live view; rgba must be NULL or point at 4 floats.
cadaclysm_view_set_node_highlight
bool cadaclysm_view_set_node_highlight(struct CadaclysmView *view,
uint32_t item,
uint32_t node,
const float *rgba);
Highlights node of item and its whole subtree: tinted toward rgba's RGB by its alpha, the strength (0 leaves the colour, 1 is the tint; each clamped into 0..1), over whatever colour it draws in. NULL clears. False as cadaclysm_view_set_node_color.
view must be NULL or a live view; rgba must be NULL or point at 4 floats.
cadaclysm_view_set_node_transforms
bool cadaclysm_view_set_node_transforms(struct CadaclysmView *view,
uint32_t item,
const double *transforms,
uint32_t count);
Poses item's scene: one world transform per node, count arrays of sixteen doubles each, column-major (entry 4 * col + row; count the scene's node count), drawn in place of each node's rest transform. NULL with count 0 restores the rest pose. False, with the reason on cadaclysm_view_last_error, where the item is not a shown scene, the count differs from the scene's node count, or a matrix is not finite or not rigid; an overlay is refused by name, as cadaclysm_view_set_placement refuses it.
view must be NULL or a live view; transforms must be NULL (with count 0) or point at count arrays of sixteen doubles.
cadaclysm_view_set_node_ghosts
bool cadaclysm_view_set_node_ghosts(struct CadaclysmView *view,
uint32_t item,
const uint32_t *nodes,
uint32_t count);
Draws exactly the nodes nodes of item x-ray (1.27) — see-through, as cadaclysm_view_set_xray draws a whole item — replacing the item's earlier ghosts; nodes NULL (count 0) clears them all. A node is the reader's node index, as cadaclysm_view_set_node_visible takes it, and only that node is ghosted, not its subtree. A plain item (a mesh, lines, a solid) has one node, 0. Kept across uploads. Face picks ignore it; since 1.30 a ghosted node's lines and points are picked through what covers them, as an x-ray item's are. The terminal accepts it and draws the nodes as ordinary geometry. The render view library differs: it ghosts each named node's whole subtree. False, with the reason, where the item is not shown ("set_node_ghosts: no item N") or a node is past its nodes ("set_node_ghosts: item N has no node M (it has K)"), changing nothing.
view must be NULL or a live view; nodes NULL or count words.
Picking
cadaclysm_view_request_pick
void cadaclysm_view_request_pick(struct CadaclysmView *view, uint32_t x, uint32_t y);
Asks what is under pixel (x, y) of viewport 0, in physical pixels from its top left (a Qt host multiplies a mouse position by devicePixelRatio); cadaclysm_view_request_pick_in(view, 0, x, y).
view must be NULL or a live view.
cadaclysm_view_request_pick_in
void cadaclysm_view_request_pick_in(struct CadaclysmView *view,
uint32_t viewport,
uint32_t x,
uint32_t y);
Asks what is under pixel (x, y) of viewport, in physical pixels from its own top left (the window's while no viewports are set, viewport 0 then being the built-in camera). The answer comes on a later call to cadaclysm_view_pick_result, after a draw; cadaclysm_view_needs_draw is true until it has. A pick requested before the view's first draw is asked by that draw, once it has drawn the scene: it answers what that first frame shows under the pixel. One naming a viewport past those set answers nothing (item 0). A new request replaces one still pending. A device loss during a draw drops the pick (its readback lived on the lost device); the host asks again.
view must be NULL or a live view.
cadaclysm_view_pick_result
bool cadaclysm_view_pick_result(struct CadaclysmView *view, struct CadaclysmViewPick *out);
The answer to the last pick asked — by cadaclysm_view_request_pick, cadaclysm_view_request_pick_in, or cadaclysm_view_input (a click or double click, reported by CADACLYSM_VIEW_INPUT_PICKED) — true once, when it has landed: out.item 0 (and node, face, has_point 0) for nothing under the pixel. False, with "no pick result", while none has landed or none was asked, or where a device loss dropped the pick in flight (the host asks again); it never waits for the GPU. out.size must be at least the 1.0 struct's; fields past it are not written.
1.8: clicks is 2 for a double click's pick, 1 for a click's or the host's own; has_point 1 and point the point hit, in the coordinates the items were shown in, for a hit — 0 for no hit, a machining stock, and on the terminal library, which reads no depth.
1.28: viewport_label is the viewport whose label (cadaclysm_view_set_viewport_label) was under the pixel (item 0), else -1; a struct whose size ends before it does not get it.
cadaclysm_view_set_pick_aperture
bool cadaclysm_view_set_pick_aperture(struct CadaclysmView *view, float aperture_pt);
How far a pick reaches for lines, points and glyphs, in points (times the screen density): 0 restores the default, 4; others clamp to 1..32; negative or not finite is refused. The terminal library keeps it, but its picks reach no wires. The render view library keeps it too; its picks are face picks. (1.30)
view must be NULL or a live view.
cadaclysm_view_pick_rect
size_t cadaclysm_view_pick_rect(struct CadaclysmView *view,
uint32_t viewport,
float x,
float y,
float w,
float h,
bool crossing,
struct CadaclysmViewRectHit *out,
size_t capacity);
What lies in a rectangle of viewport (device pixels from its top left; a negative w or h flips it), CPU only: with crossing, everything with a visible part inside, else what lies wholly inside and is visible. Hidden things come only drawn x-ray or on top. Text, images, overlays, viewport labels, machining stocks and isocurves are left out. Answers how many there are, and writes at most capacity into out (NULL with 0 to count), sorted by item, kind, index; 0 with the last error set on a refusal. (1.30)
A NULL out with a nonzero capacity, a rectangle that is not finite, and an unknown viewport are refused. The rectangle is clipped to the viewport: one wholly off it answers 0 with no error.
Each hit's kind is a CADACLYSM_VIEW_HIT_*: a face (numbered as the pick numbers it), a node of an item with no face ranges, a lines item's segment or a curves item's Bezier, a kernel solid's or read scene's edge (its kernel edge index, as the pick's segment), or a point's or glyph's index. An exact item shown with no mesh has no triangles, so its faces are never in the answer (its edges are). On a lost device it answers 0 with no error: nothing the screen shows is current there, as cadaclysm_view_pick_result and cadaclysm_view_snap_result answer nothing. The render view library refuses it.
Snapping
cadaclysm_view_set_snap
bool cadaclysm_view_set_snap(struct CadaclysmView *view,
const struct CadaclysmViewSnapSettings *settings);
How the view snaps from now on: the CADACLYSM_VIEW_SNAP_* kinds a snap may land on (0 switches snapping off, as a new view starts), how far from the cursor it reaches (aperture_px points, 0 for the default 10, otherwise clamped to 2-32, times the screen density), and whether the view draws the marker at the last snap (marker 1). Turning snapping or the marker off hides the marker shown.
False, changing nothing, for a NULL or undersized settings, kinds with bits past CADACLYSM_VIEW_SNAP_ALL, an aperture_px that is negative or not finite, and a marker other than 0 or 1.
The terminal library refuses it: "snapping needs the wgpu view library".
cadaclysm_view_request_snap_in
void cadaclysm_view_request_snap_in(struct CadaclysmView *view,
uint32_t viewport,
uint32_t x,
uint32_t y);
Asks for the snap under pixel (x, y) of viewport, in physical pixels from its own top left, as cadaclysm_view_request_pick_in asks for a pick. The answer comes on a later call to cadaclysm_view_snap_result, after a draw; cadaclysm_view_needs_draw is true until it has landed. A new request replaces one still pending; a device loss drops it.
A view fed cadaclysm_view_input, or in its own window, also asks snaps itself once snapping is on: under a mouse hovering with no button down, and under each click (the answer's clicks 1 or 2). snap_result answers the latest; a hover's never replaces a click's not read yet.
The terminal library refuses it: "snapping needs the wgpu view library".
cadaclysm_view_snap_result
bool cadaclysm_view_snap_result(struct CadaclysmView *view, struct CadaclysmViewSnap *out);
The answer to the last snap asked — by cadaclysm_view_request_snap_in, or by the mouse over a view in its own window or one fed cadaclysm_view_input — into out, once it has landed (a draw lands it). kind 0 where nothing in the kinds set lies within the aperture, or snapping is off. False, with "no snap result", while none has landed; each answer is read once. Still answers once the view's window is closed, as cadaclysm_view_pick_result does.
1.30: label, locked/locked_angle and guides/guide_count for a struct of 232 bytes; with the angle lock (cadaclysm_view_set_snap_base) a snap that lands on no point kind answers PLANE with locked 1; kind 0 leaves label empty.
The terminal library refuses it: "snapping needs the wgpu view library".
cadaclysm_view_clear_snap
void cadaclysm_view_clear_snap(struct CadaclysmView *view);
Hides the snap marker and drops any snap asked and not yet answered, or answered and not yet read. The next snap shows the marker again.
The terminal library refuses it: "snapping needs the wgpu view library".
view must be NULL or a live view.
cadaclysm_view_set_work_plane
bool cadaclysm_view_set_work_plane(struct CadaclysmView *view,
const double *origin,
const double *x_axis,
const double *normal,
double step);
A work plane for CADACLYSM_VIEW_SNAP_GRID and _PLANE snaps in place of the viewport's grid plane: its origin, its x_axis and its normal, three doubles each in world coordinates (the axes need not be unit; the x axis is made square to the normal), and its grid's step, 0 for the drawn grid's.
False, changing nothing, for a NULL array, a value that is not finite, a negative step, and an x_axis or normal of no length, or the two parallel.
The terminal library refuses it: "snapping needs the wgpu view library".
cadaclysm_view_clear_work_plane
bool cadaclysm_view_clear_work_plane(struct CadaclysmView *view);
Goes back to the viewport's grid plane for CADACLYSM_VIEW_SNAP_GRID and _PLANE snaps.
The terminal library refuses it: "snapping needs the wgpu view library".
view must be NULL or a live view.
cadaclysm_view_set_snap_points
bool cadaclysm_view_set_snap_points(struct CadaclysmView *view,
uint32_t item,
const float *xyz,
size_t count,
const char *label);
Points item item snaps to as CADACLYSM_VIEW_SNAP_POINT, in the coordinates it was shown in (count points, three floats each), moving with its node 0, labelled label (UTF-8, at most 31 bytes; NULL or an empty label answers "point"). A count of 0 clears them. False for an unknown item, with no error. Text, glyph, image and machining items are refused, as are a label past 31 bytes or not UTF-8, a value that is not finite, and a NULL xyz with a nonzero count. The points go with the item's removal. The terminal and render view libraries refuse it: snapping needs the wgpu view library (the render view library names an unknown item first). (1.30)
view must be NULL or a live view; xyz NULL (with count 0) or count * 3 floats; label NULL or zero-terminated.
cadaclysm_view_set_snap_base
bool cadaclysm_view_set_snap_base(struct CadaclysmView *view, const float *xyz, float step_deg);
The angle lock: snaps that land on no point kind are turned about xyz (world) onto the nearest multiple of step_deg (0 < step <= 180), in the work plane's directions or the plane facing the eye; the answer is PLANE with locked 1. NULL clears it (step_deg then ignored). False, changing nothing, for a point that is not finite or a step out of range. The terminal and render view libraries refuse it. (1.30)
view must be NULL or a live view; xyz NULL or three floats.
Input
cadaclysm_view_set_double_click_frames
void cadaclysm_view_set_double_click_frames(struct CadaclysmView *view, bool on);
Whether a double click frames what it hit (1.8) — as every double click did before 1.8. Off by default: a double click is then a pick answered with clicks 2, and the camera stays where it is. A NULL view: nothing.
view must be NULL or a live view.
cadaclysm_view_input
uint32_t cadaclysm_view_input(struct CadaclysmView *view,
const struct CadaclysmViewEvent *event);
Hands the view's gesture handler one event — the same handler the own window and the web use, so a host that forwards its window's events gets the same gestures: the left button orbits (in fly mode, turns the view about the eye), the right (or Shift-left) pans, the wheel zooms, a click picks, a double click picks with clicks 2, T/F/R/I standard views, O orthographic, X exact/triangles, Space frames all, W/S/A/D/E/Q fly while held (and enter fly mode, which stays: cadaclysm_view_navigation), Tab toggles fly mode, Escape asks to close. Alt with the left button (CadaclysmViewEvent.alt, 1.10) orbits the viewport's pivot (cadaclysm_view_set_pivot). What it asked of the host, as CADACLYSM_VIEW_INPUT_* bits; 0 for an event that does nothing or is refused.
With viewports set, each gesture is read by the camera under the press and moves that viewport's camera: a left drag orbits an orbit camera, looks with a fly camera, pans an ortho one; the wheel zooms an orbit camera, dollies a fly camera and zooms an ortho one about the cursor; a fixed camera does not move. A drag stays with the viewport it started in; the fly keys move the fly camera under the pointer, else the first. In fly mode (cadaclysm_view_navigation) the orbit camera the fly keys move turns about its eye on a left drag, as a fly camera does. A Wheel event's x and y name the pane it zooms (and where it zooms toward): fill them with the pointer's position — a wheel at 0, 0 zooms the pane at the window's top left. A click's travel and time are cadaclysm_view_set_tap's.
A click or double click asks a pick and returns CADACLYSM_VIEW_INPUT_PICKED: the host then calls cadaclysm_view_pick_result after its draws until it answers. cadaclysm_view_needs_draw stays true until that call takes the answer. A double click moves nothing unless the host opted in with cadaclysm_view_set_double_click_frames: then it frames what it hit when that call takes the answer.
cadaclysm_view_set_tap
bool cadaclysm_view_set_tap(struct CadaclysmView *view, float px, double ms);
A click's most travel (px, physical pixels) and longest press (ms; 0: no limit) for cadaclysm_view_input to pick. Default 10 px, 500 ms. False, changing nothing, for a negative or non-finite value.
view must be NULL or a live view.
Levels of detail
cadaclysm_view_set_lod
bool cadaclysm_view_set_lod(struct CadaclysmView *view, const struct CadaclysmViewLod *lod);
The view's level-of-detail policy, for the device the host runs on (1.4). NULL — the default — builds no levels and draws every frame whole. Otherwise the view builds coarser levels for every part of lod->min_triangles or more, in the background after each show, and draws moving frames as lod->motion says: CADACLYSM_VIEW_LOD_DETAILED keeps every frame whole but for levels within half a pixel; CADACLYSM_VIEW_LOD_SMOOTH holds the frame rate while moving and refines the picture once the camera rests — a host drawing on demand then wakes at cadaclysm_view_wake_ms. min_triangles of 0 is the default threshold (2048), not "every part". The terminal library accepts it and draws every part whole, as before. False, changing nothing, for a NULL view, a size below the 1.4 struct's or an unknown motion.
view must be NULL or a live view; lod must be NULL or point at lod->size bytes.
cadaclysm_view_wake_ms
uint32_t cadaclysm_view_wake_ms(const struct CadaclysmView *view);
Milliseconds until cadaclysm_view_needs_draw turns true by itself, rounded up: a resting frame, chiefly under CADACLYSM_VIEW_LOD_SMOOTH, refining the picture once the camera stops — a CADACLYSM_VIEW_LOD_DETAILED view with levels adopted can owe one too, when a frame drew levels coarser than the scene. A host drawing on demand sets a timer for it and draws if cadaclysm_view_needs_draw then says so. A level build running on its thread owes one when it finishes, and asks to be looked in on every 100 ms until then (the view's own window is woken instead): the frame that adopts its levels frees the scene it held. 0 when one is owed now, and 0 while the timeline plays or a track is catching up (1.7); UINT32_MAX when none is coming (and for a NULL view).
view must be NULL or a live view.
Timeline, machining and animations
cadaclysm_view_show_machining
uint32_t cadaclysm_view_show_machining(struct CadaclysmView *view,
const struct CadaclysmViewMachining *machining);
Shows a CAM job (1.7): machining's programs, played in order on a stock of its box, with its optional part for colouring by deviation; its track joins the view's timeline at time 0, paused. The item's id — the stock, an item like any other (framed, placed, coloured by id); cadaclysm_view_remove takes the machining and its track away — or 0 on failure: a NULL or undersized struct, a programs stride off the struct's alignment, no programs, a tool shape not a CADACLYSM_VIEW_TOOL_*, a program the G-code reader refuses (its line named), a stock box that is not a box, a part index past its vertices, or what the stock refuses. Copied in; the struct, its programs and their text are the caller's again when this returns.
After a lost device the stock comes back under a new view id. Only cadaclysm_view_remove and the cadaclysm_view_machining_* calls translate the id returned here to it; every other call (cadaclysm_view_frame, cadaclysm_view_set_colour, ...) takes the id as given, so after a loss it no longer reaches the stock.
The terminal library refuses it: "stock: machining stocks need the GPU renderer".
cadaclysm_view_machining_seek
bool cadaclysm_view_machining_seek(struct CadaclysmView *view, uint32_t item, uint32_t to);
Jumps the timeline to the end of move to of the machining item (0: the untouched stock; its moves: the end), as the web's Machining.seek(move); the stock gets there over the next draws (at most 20,000 moves a draw) or at once on cadaclysm_view_machining_heights (1.7). False for an id that is no machining, or a move past its end.
The terminal library refuses it: it has no machining ("no machining N is shown").
view must be NULL or a live view.
cadaclysm_view_machining_colour_by
bool cadaclysm_view_machining_colour_by(struct CadaclysmView *view,
uint32_t item,
uint32_t mode);
Colours the machining item's stock from the next draw (1.7): CADACLYSM_VIEW_COLOUR_BY_*. False for an id that is no machining, another mode, or colouring by deviation a machining shown with no part.
The terminal library refuses it: it has no machining ("no machining N is shown").
view must be NULL or a live view.
cadaclysm_view_machining_overlays
bool cadaclysm_view_machining_overlays(struct CadaclysmView *view,
uint32_t item,
bool path,
bool tool);
Turns the machining item's toolpath and tool on or off (both on when shown), from the next draw (1.7). False for an id that is no machining.
The terminal library refuses it: it has no machining ("no machining N is shown").
view must be NULL or a live view.
cadaclysm_view_machining_info
bool cadaclysm_view_machining_info(struct CadaclysmView *view,
uint32_t item,
struct CadaclysmViewMachiningInfo *out);
Fills out with the machining item's facts (1.7): its moves, the move the stock is at (as of the last draw or cadaclysm_view_machining_heights), the heights' grid nx x ny, its cell and cell (0, 0)'s corner min in mm, and the job's cycle_time in seconds. out->size is left as the caller set it. False for a NULL or undersized out, an id that is no machining, or a stock lost with the GPU device and not drawn again yet.
The terminal library refuses it: it has no machining ("no machining N is shown").
view must be NULL or a live view; out NULL or a CadaclysmViewMachiningInfo of at least out->size bytes.
cadaclysm_view_machining_heights
bool cadaclysm_view_machining_heights(struct CadaclysmView *view,
uint32_t item,
float *heights,
size_t capacity);
Settles the machining item's track at the timeline's time, with no limit on its work, then reads its stock's heights back, blocking (it polls the device, at most 10 s), into heights (1.7): capacity floats, at least nx * ny of cadaclysm_view_machining_info; rows y then x (z[j * nx + i]), mm, as Machining.heights() on the web. False for an id that is no machining, a NULL heights, a capacity too small (the reason says how many floats are needed), or heights that did not land within 10 s.
The terminal library refuses it: it has no machining ("no machining N is shown").
view must be NULL or a live view; heights NULL or capacity writable floats.
cadaclysm_view_timeline_play
bool cadaclysm_view_timeline_play(struct CadaclysmView *view, double speed);
Plays the view's timeline at speed times real time (1.7): each cadaclysm_view_draw (so cadaclysm_view_pump and cadaclysm_view_run) and cadaclysm_view_image moves it by the wall-clock time since the last. At the end of a timeline that does not loop it starts again from 0. False for a speed not positive and finite.
view must be NULL or a live view.
cadaclysm_view_timeline_pause
bool cadaclysm_view_timeline_pause(struct CadaclysmView *view);
Stops the view's timeline where it is (1.7); a track still catching up to that time carries on over the next draws.
view must be NULL or a live view.
cadaclysm_view_timeline_seek
bool cadaclysm_view_timeline_seek(struct CadaclysmView *view, double seconds);
Sets the view's timeline to seconds (1.7), clamped to [0, duration], NaN as 0; every track gets there over the next draws (a machining stamps at most 20,000 moves a draw), playing or not: cadaclysm_view_needs_draw stays true until they have.
view must be NULL or a live view.
cadaclysm_view_timeline_set_loop
bool cadaclysm_view_timeline_set_loop(struct CadaclysmView *view, bool on);
Whether playing past the end of the view's timeline wraps to its start (1.7); off when the view is made.
view must be NULL or a live view.
cadaclysm_view_timeline_time
double cadaclysm_view_timeline_time(const struct CadaclysmView *view);
The view's timeline's clock, in seconds (1.7); 0 for a NULL view.
view must be NULL or a live view.
cadaclysm_view_timeline_duration
double cadaclysm_view_timeline_duration(const struct CadaclysmView *view);
The view's timeline's length in seconds (1.7): the latest end of its tracks, 0 with none (always, in the terminal library) and for a NULL view.
view must be NULL or a live view.
cadaclysm_view_timeline_playing
bool cadaclysm_view_timeline_playing(const struct CadaclysmView *view);
Whether the view's timeline plays (1.7): it stops by itself at the end of a timeline that does not loop. False for a NULL view.
view must be NULL or a live view.
cadaclysm_view_timeline_status
size_t cadaclysm_view_timeline_status(const struct CadaclysmView *view,
char *text,
size_t capacity);
Where the view's timeline's tracks are (1.7), one UTF-8 line per track in the order they were added, joined by a newline with none after the last ("" with no tracks); a machining's reads "move 120 of 2206 · T1 flat 6 mm · X10.0 Y20.0 Z5.0", as of the last draw. Returns the text's length in bytes, not counting the NUL; writes it NUL-terminated into text only when capacity is more than that length, else writes nothing (text NULL with capacity 0 asks the length). 0 for a NULL view.
view must be NULL or a live view; text NULL or capacity writable bytes.
cadaclysm_view_play_animation
uint32_t cadaclysm_view_play_animation(struct CadaclysmView *view,
const CadaclysmBlacksmithAnimation *animation,
const struct CadaclysmViewAnimationBinding *bindings,
uint32_t count);
Plays a kernel animation on the view's timeline (1.27), bound to shown items and nodes: each binding names one of the animation's targets and the item it drives, or a node of the item (node, the reader's node index) and that node's whole subtree, which move rigidly; CADACLYSM_VIEW_ALL_NODES binds the item itself. Each frame the track writes, at the timeline's time, the channels the animation keys on a bound target: translate, rotate and scale composed onto the placement the target had at play (scale on an item only), visible (shown above 0.5), colour, and ghost (x-ray above 0.5). A target with no binding drives nothing; a value track is the host's own. The animation is copied: it is the caller's again, free to change or free, when this returns. The new track's id (1 or more) — what cadaclysm_view_timeline_remove takes — or 0, with the reason: a NULL animation, a binding with no target, an item not shown, a node past the item's, a target bound twice to one item and node, a scale on a node, two placement targets one inside the other's subtree, or no kernel loaded in the process ("play_animation: the kernel is not loaded"). The timeline does not start playing: cadaclysm_view_timeline_play and _seek move it. Each frame whose clock moved queues one CADACLYSM_VIEW_INPUT_EVENT_TIMELINE.
The terminal library and the render view library refuse it: "play_animation: animations need the GPU renderer's timeline".
view must be NULL or a live view; animation NULL or a live animation of the loaded kernel; bindings NULL (with count 0) or count bindings, each target NULL or a NUL-terminated string.
cadaclysm_view_timeline_remove
bool cadaclysm_view_timeline_remove(struct CadaclysmView *view, uint32_t track);
Takes animation track track off the view's timeline (1.27), putting back what it drove as it was at play: the bound items' placements, colours, x-ray and visibility, and their nodes' transforms, switches, ghosts and colours — only the channels the animation keyed; what the host set elsewhere stands. False, with "timeline_remove: no track N", for a track no animation played (a machining's track is taken away with its item).
The terminal library and the render view library play no animation: every track is refused there.
view must be NULL or a live view.
Types
CadaclysmViewWindow
typedef struct CadaclysmViewWindow {
uint32_t size;
uint32_t kind;
void *window;
uint64_t window_id;
void *display;
uint32_t width;
uint32_t height;
} CadaclysmViewWindow;
The host's native window. The window must outlive the view.
CadaclysmViewOptions
typedef struct CadaclysmViewOptions {
uint32_t size;
uint32_t surfaces;
uint32_t backend;
uint32_t y_up;
const char *title;
uint32_t width;
uint32_t height;
uint32_t offscreen;
} CadaclysmViewOptions;
How the view draws, chosen at create. Zeroed fields are the defaults.
CadaclysmViewCamera
typedef struct CadaclysmViewCamera {
uint32_t size;
float eye[3];
float target[3];
float up[3];
uint32_t orthographic;
} CadaclysmViewCamera;
The camera the view ended on when cadaclysm_view_run returned, 1.2.
CadaclysmViewPick
typedef struct CadaclysmViewPick {
uint32_t size;
uint32_t item;
uint32_t node;
uint32_t face;
uint32_t clicks;
uint32_t has_point;
float point[3];
uint32_t overlay;
int32_t viewport_label;
uint32_t segment;
float distance_px;
} CadaclysmViewPick;
A pick's answer (cadaclysm_view_pick_result).
CadaclysmViewAnalysis
typedef struct CadaclysmViewAnalysis {
uint32_t size;
uint32_t mode;
uint32_t count;
float angle;
float width;
float light[3];
double range;
} CadaclysmViewAnalysis;
How every surface is drawn for judging it (cadaclysm_view_set_analysis, 1.14). Curvature is signed against the outward normal (a ball's outside is positive) and estimated from the drawn normals for now.
CadaclysmViewOccludedStyle
typedef struct CadaclysmViewOccludedStyle {
uint32_t size;
float dash;
float gap;
float dim;
uint32_t has_colour;
float colour[3];
} CadaclysmViewOccludedStyle;
How every DASHED item's hidden lines and points look, view-wide (cadaclysm_view_set_occluded_style, 1.20). Zeroes are the defaults.
CadaclysmViewLod
typedef struct CadaclysmViewLod {
uint32_t size;
uint32_t min_triangles;
uint32_t motion;
} CadaclysmViewLod;
Levels of detail, as cadaclysm_view_set_lod takes them (1.4).
CadaclysmViewViewport
typedef struct CadaclysmViewViewport {
uint32_t size;
uint32_t rect[4];
float view[16];
float projection[16];
float eye[3];
uint32_t grid;
uint32_t layer_mask;
} CadaclysmViewViewport;
One rectangle of the window and the camera the caller computed for it (cadaclysm_view_set_viewports).
CadaclysmViewEvent
typedef struct CadaclysmViewEvent {
uint32_t size;
uint32_t kind;
uint32_t pointer_id;
uint32_t pointer;
uint32_t button;
uint32_t shift;
float x;
float y;
float wheel_y;
const char *key;
uint32_t key_down;
double time_ms;
uint32_t alt;
} CadaclysmViewEvent;
One raw input event (cadaclysm_view_input): the same gesture handler every surface feeds — the own window, the web, and a host through this ABI.
CadaclysmViewMesh
typedef struct CadaclysmViewMesh {
uint32_t size;
const float *positions;
uint32_t vertex_count;
const float *normals;
const uint32_t *indices;
uint32_t index_count;
const float *edges;
uint32_t edge_count;
const float *rgb;
} CadaclysmViewMesh;
A mesh of plain arrays, copied in when shown: positions, optional normals, triangles, optional edge segments, an optional colour.
CadaclysmViewImage
typedef struct CadaclysmViewImage {
uint32_t size;
float corners[12];
const uint8_t *rgba;
uint32_t width;
uint32_t height;
float opacity;
uint32_t flip_x;
uint32_t flip_y;
} CadaclysmViewImage;
A reference image on a quad, copied in when shown.
CadaclysmViewProgram
typedef struct CadaclysmViewProgram {
uint32_t size;
uint32_t tool_number;
uint32_t tool_shape;
double tool_diameter;
double tool_flute_length;
double tool_angle;
double tool_corner_radius;
const char *gcode;
} CadaclysmViewProgram;
One program of a CAM job and the tool it runs with (CadaclysmViewMachining.programs, 1.7): an array whose stride is the first element's size.
CadaclysmViewMachining
typedef struct CadaclysmViewMachining {
uint32_t size;
uint32_t program_count;
const struct CadaclysmViewProgram *programs;
double stock_min[3];
double stock_max[3];
const float *part_positions;
const uint32_t *part_indices;
uint32_t part_vertex_count;
uint32_t part_index_count;
double cell;
double tolerance;
double skin;
double rapid_rate;
uint32_t skin_set;
} CadaclysmViewMachining;
A CAM job (cadaclysm_view_show_machining, 1.7): its programs, the stock they cut and an optional part. Zeroed fields are the defaults.
CadaclysmViewMachiningInfo
typedef struct CadaclysmViewMachiningInfo {
uint32_t size;
uint32_t moves;
uint32_t move;
uint32_t nx;
uint32_t ny;
float cell;
float min[2];
double cycle_time;
} CadaclysmViewMachiningInfo;
A machining's facts (cadaclysm_view_machining_info, 1.7).
CadaclysmViewAnimationBinding
typedef struct CadaclysmViewAnimationBinding {
const char *target;
uint32_t item;
uint32_t node;
} CadaclysmViewAnimationBinding;
One target of a kernel animation bound to a shown item, or to a node of it and the node's whole subtree (cadaclysm_view_play_animation, 1.27). 16 bytes on a 64-bit target.
CadaclysmViewText
typedef struct CadaclysmViewText {
uint32_t size;
const char *text;
uint32_t mode;
float at[3];
float right[3];
float up[3];
float height;
float rgb[3];
uint32_t align;
float offset[2];
float box_rgba[4];
float box_padding;
uint32_t on_top;
uint32_t font;
int32_t order;
} CadaclysmViewText;
One text item (1.6): a label in screen pixels anchored to a point, or text lying in a plane of the model. Fields past the caller's size take their defaults.
CadaclysmViewViewportCamera
typedef struct CadaclysmViewViewportCamera {
uint32_t size;
uint32_t kind;
uint32_t rect[4];
float view[16];
float projection[16];
float eye[3];
float target[3];
float distance;
float yaw;
float pitch;
uint32_t orthographic;
float speed;
float radius;
float height;
float axis_view[3];
float axis_right[3];
float axis_up[3];
} CadaclysmViewViewportCamera;
One viewport's camera (1.10): cadaclysm_view_viewport_camera fills it, cadaclysm_view_set_viewport_camera reads it. Read back, rect, view, projection and eye are what the viewport draws with now; the rest is the kind's state. Set, kind and its fields are read (a fixed camera reads view, projection and eye), rect never (cadaclysm_view_set_viewport_rects). Every field 4-aligned: 240 bytes.
CadaclysmViewDevice
typedef struct CadaclysmViewDevice {
uint32_t size;
uint32_t api;
uint32_t flags;
void *device;
void *queue;
void *instance;
void *physical_device;
uint32_t queue_family;
uint32_t queue_index;
uint32_t api_version;
const char *const *instance_extensions;
uint32_t instance_extension_count;
const char *const *extensions;
uint32_t extension_count;
const void *enabled_features;
uint32_t width;
uint32_t height;
} CadaclysmViewDevice;
Host-device mode (1.12): the view built on the host's own device and queue, drawing into a texture on that device. The host keeps the device, queue and instance alive until the view is destroyed.
CadaclysmViewTexture
typedef struct CadaclysmViewTexture {
uint32_t size;
uint32_t kind;
void *texture;
int32_t fd;
uint64_t memory_size;
uint32_t width;
uint32_t height;
uint32_t state;
uint32_t slot;
uint32_t slot_count;
uint32_t drawn;
uint64_t generation;
void *ready_fence;
void *release_fence;
int32_t ready_fence_fd;
int32_t release_fence_fd;
uint64_t ready_value;
uint64_t release_value;
} CadaclysmViewTexture;
What cadaclysm_view_texture hands back (1.12): the texture to sample and how to sync.
CadaclysmViewKmsInfo
typedef struct CadaclysmViewKmsInfo {
uint32_t size;
uint32_t path;
uint64_t modifier;
uint32_t connector;
uint32_t width;
uint32_t height;
uint32_t refresh;
uint32_t fourcc;
char connector_name[32];
char card[64];
char adapter[128];
} CadaclysmViewKmsInfo;
How a KMS view draws onto its display (cadaclysm_view_kms_info, cadaclysm_view_kms_probe, 1.19). The text fields are UTF-8, NUL-terminated, cut short at a character to fit.
CadaclysmViewSnapSettings
typedef struct CadaclysmViewSnapSettings {
uint32_t size;
uint32_t kinds;
float aperture_px;
uint32_t marker;
} CadaclysmViewSnapSettings;
How the view snaps (cadaclysm_view_set_snap, 1.22). Snapping starts off.
CadaclysmViewSnap
typedef struct CadaclysmViewSnap {
uint32_t size;
uint32_t kind;
double point[3];
uint32_t item;
uint32_t node;
uint32_t face;
uint32_t edge;
float tangent[3];
float axis[3];
double radius;
float distance_px;
uint32_t clicks;
char label[32];
uint32_t locked;
float locked_angle;
uint32_t guide_count;
uint32_t pad0;
double guides[12];
} CadaclysmViewSnap;
A snap's answer (cadaclysm_view_snap_result, 1.22).
CadaclysmViewOverlay
typedef struct CadaclysmViewOverlay {
uint32_t size;
uint32_t anchor;
const float *beziers;
uint32_t curve_count;
int32_t order;
float offset[2];
uint32_t has_fill;
float fill_rgba[4];
uint32_t has_stroke;
float stroke_rgba[4];
float stroke_width;
} CadaclysmViewOverlay;
A 2D shape over the window (cadaclysm_view_show_overlay, 1.24): a blacksmith profile's Beziers, in pixels, y up, its origin at the anchor plus the offset. Fields past the caller's size take their defaults (zero).
The curves are split into loops where one does not start where the one before it ended, and a loop is closed where it ends where it started (both within a ten-thousandth of the shape's extent): a profile's outline and each hole. Closed loops are filled together by the even-odd rule — a loop inside another is a hole; every loop is stroked, centred on the curve, round at its joins and ends. An open loop is never filled.
CadaclysmViewOverlayImage
typedef struct CadaclysmViewOverlayImage {
uint32_t size;
uint32_t anchor;
const uint8_t *rgba;
uint32_t width;
uint32_t height;
float offset[2];
float extent[2];
float opacity;
int32_t order;
} CadaclysmViewOverlayImage;
An image over the window (cadaclysm_view_show_overlay_image, 1.24), copied in when shown. Its box hangs from the anchor as text's does: the anchor's own point of the box (its top-right corner for a top-right anchor) sits at the anchor plus the offset.
CadaclysmViewStats
typedef struct CadaclysmViewStats {
uint32_t size;
uint32_t pad0;
uint64_t frames_drawn;
float last_frame_ms;
float last_gpu_ms;
uint64_t triangles;
uint32_t draw_calls;
uint32_t pad1;
} CadaclysmViewStats;
What a view has drawn (cadaclysm_view_stats, 1.25). Laid out with no implicit padding: 40 bytes, every field at its natural alignment.
CadaclysmViewEventPick
typedef struct CadaclysmViewEventPick {
uint32_t size;
uint32_t item;
uint32_t node;
uint32_t face;
uint32_t clicks;
uint32_t has_point;
float point[3];
uint32_t overlay;
} CadaclysmViewEventPick;
The pick inside a CadaclysmViewInputEvent: CadaclysmViewPick as it was when 1.26 laid the event out (40 bytes), so the event's later fields stay where 1.26 put them. The 1.28 label hit is the event's own pick_viewport_label.
CadaclysmViewEventSnap
typedef struct CadaclysmViewEventSnap {
uint32_t size;
uint32_t kind;
double point[3];
uint32_t item;
uint32_t node;
uint32_t face;
uint32_t edge;
float tangent[3];
float axis[3];
double radius;
float distance_px;
uint32_t clicks;
} CadaclysmViewEventSnap;
The snap inside a CadaclysmViewInputEvent, frozen at 1.22: the snap grew in 1.30, the event's copy did not (its tail carries the rest). 88 bytes, so the event's camera stays where 1.26 put it.
CadaclysmViewInputEvent
typedef struct CadaclysmViewInputEvent {
uint32_t size;
uint32_t kind;
double time_ms;
float x;
float y;
float wheel_y;
uint32_t button;
uint32_t modifiers;
uint32_t pointer;
uint32_t pointer_id;
uint32_t width;
uint32_t height;
uint32_t repeat;
uint32_t dropped;
uint32_t pad0;
char key[32];
struct CadaclysmViewEventPick pick;
struct CadaclysmViewEventSnap snap;
struct CadaclysmViewCamera camera;
int32_t pick_viewport_label;
uint32_t pick_segment;
float pick_distance_px;
char snap_label[32];
uint32_t snap_locked;
float snap_locked_angle;
uint32_t snap_guide_count;
uint32_t pad1;
double snap_guides[12];
} CadaclysmViewInputEvent;
One input event a view's own window handled (cadaclysm_view_next_event, 1.26). Laid out with no implicit padding: 272 bytes, every field at its natural alignment. The fields a kind does not use are zero. 1.30 grew it to 424 bytes at its tail: check that cadaclysm_view_abi_version()'s minor is at least 30 before reading pick_segment and the snap_* fields; a 1.29 library leaves them as the caller filled them.
CadaclysmViewRectHit
typedef struct CadaclysmViewRectHit {
uint32_t item;
uint32_t kind;
uint32_t index;
} CadaclysmViewRectHit;
One thing in a rectangle (cadaclysm_view_pick_rect, 1.30): its item, what it is (CADACLYSM_VIEW_HIT_*) and its index. 12 bytes, fixed: an array element, with no size.