C API Conventions#
These rules hold across both public C ABIs of the
SDK archive: the canonical <ovclash/ovclash.h>
and the Suite headers under <ovclash_suite/...>. The comment on each
declaration in the headers is authoritative;
References in the package lists the headers. Several
rules on this page live only in the headers’ group comments, which the API reference on the
ovclash documentation site does not show.
The C/C++ Quickstart shows how to link and run a first program. Threading and Ownership owns the handle, lifetime and threading rules. ovstage Integration covers the optional ovstage extensions.
Headers#
The SDK archive installs the headers under include/. The wheel ships no headers.
Header |
Contents |
Needs the ovstage |
|---|---|---|
|
Canonical C ABI: types, contexts, settings, scope, pipeline and results. |
Yes |
|
Generated version constants; see Version constants. |
No |
|
The single definition of |
No |
|
Optional ovstage-only extensions: attached stages, owner operations and matrix decomposition. |
Yes |
|
Suite runtime, persistence and export entry points. It includes |
No |
|
Suite handles, strings, enums and plain-data views. |
No |
|
Suite model objects: query, clash info (a clash record), frame info (one frame of a clash) and point-cloud settings. |
No |
|
Custom persistence callbacks and the saved-data reader for fetch-and-save. |
No |
|
Optional ovstage-only Suite extensions: attached stages and owner operations. |
Yes |
<ovclash/ovclash.h> includes <ovx/string_types.h>, or the older <ovx/types.h> when only that
header exists. The SDK archive does not ship either; the include/ directory of the installed
ovstage package supplies them. It also includes <ovx/dlpack/dlpack.h>,
the DLPack header, which the SDK archive ships.
Linking shows how a build finds both. The four core Suite headers
include no ovx/ header.
Version constants#
The build generates <ovclash/version.h> from the ovclash version, and the SDK archive installs
it next to ovclash.h. ovclash.h does not include it, so include it yourself. It defines
compile-time constants only:
Macro |
Type |
Required |
Default or values |
Meaning |
|---|---|---|---|---|
|
Integer literal |
Yes, always defined |
0 or more |
Major component of the version the headers were generated for. |
|
Integer literal |
Yes, always defined |
0 or more |
Minor component. |
|
Integer literal |
Yes, always defined |
0 or more; 0 for a version without a patch number |
Patch component. |
|
String literal |
Yes, always defined |
|
The numeric version as a string. |
|
Function-like macro; an integer expression |
Yes, always defined |
|
Encodes a version as one comparable integer. The order holds while minor and patch stay below 1000. |
|
Integer expression |
Yes, always defined |
|
The header version, already encoded. |
The constants carry no prerelease label: a version of 0.3.0-rc.1 generates "0.3.0". A version
without a patch number reads as patch 0.
Checking the loaded library#
The constants describe the headers. ABI compatibility depends on the shared library that is actually loaded. Two functions report its version at run time:
ovclash_get_version()writes threeuint32_tout-parameters. It fails only for a null argument, and then writes nothing.ovclash_get_version_string()returns a static, library-owned"MAJOR.MINOR.PATCH"view. The view is null-terminated, valid for the process lifetime, and must not be freed or modified.
Both need no context, record no error text and are safe to call concurrently. They are declared
only behind OVCLASH_STANDALONE. Compare the two versions to
check that a build and its runtime agree. The example treats any difference as a mismatch:
#include <ovclash/ovclash.h>
#include <ovclash/version.h>
#include <stdio.h>
/* Returns 1 when the loaded library has the version the headers were generated for. */
static int library_matches_headers(void)
{
uint32_t major = 0, minor = 0, patch = 0;
if (ovclash_get_version(&major, &minor, &patch).status != OVCLASH_STATUS_SUCCESS)
{
return 0;
}
if (OVCLASH_VERSION_ENCODE(major, minor, patch) != OVCLASH_VERSION)
{
fprintf(stderr, "headers %s, library %u.%u.%u\n", OVCLASH_VERSION_STRING, (unsigned)major,
(unsigned)minor, (unsigned)patch);
return 0;
}
return 1;
}
Status results#
Every canonical function returns ovclash_result_t, a struct with one ovclash_status_t status
field. The only exceptions are the three string getters. Every
Suite function returns ovclash_suite_result_t, except the three Suite last-error getters
listed under Error text.
Field |
Type |
Required |
Default or values |
Description |
|---|---|---|---|---|
|
|
Yes |
|
The outcome of a canonical call. |
|
|
Yes |
|
The outcome of a Suite call. |
Success is zero. Compare the field:
result.status == OVCLASH_STATUS_SUCCESS, orOVCLASH_SUITE_STATUS_SUCCESSon the Suite layer. Both are0.if (result.status)therefore tests for failure, andif (!result)does not compile, because a result is a struct.A failure is
OVCLASH_STATUS_ERROR(1), orOVCLASH_SUITE_STATUS_ERROR(1).The two result types and their status enums are distinct types. Do not mix them.
A result owns no memory and is safe to copy by value. It carries no message; see Error text.
The Suite API adds
OVCLASH_SUITE_STATUS_UNAVAILABLE(2). Onlyovclash_suite_create_overlap_report()andovclash_suite_create_clash_info()return it, for a valid record that has no available overlap report. No report is returned. It is not a processing failure, and it is the only status that lets fetch-and-save skip a frame. Extraction, allocation, cancellation and out-of-memory failures still returnOVCLASH_SUITE_STATUS_ERROR.
A complete status check, for a source file of your program:
#include <ovclash/ovclash.h>
#include <stdio.h>
#include <string.h>
/* Opens a USD file on a context from ovclash_create_context(). Returns 1 on success. */
static int open_stage_file(ovclash_context_t* ctx, const char* utf8_path)
{
ovclash_string_t path;
ovclash_result_t r;
path.ptr = utf8_path;
path.length = strlen(utf8_path);
r = ovclash_open_stage(ctx, path);
if (r.status != OVCLASH_STATUS_SUCCESS)
{
ovclash_string_t error = ovclash_get_last_error(ctx); /* see Error text */
fprintf(stderr, "open failed: %.*s\n", (int)error.length, error.length ? error.ptr : "");
return 0;
}
return 1;
}
Out-parameters and reset helpers#
Values come back through out-parameters, the pipeline calls included:
ovclash_create_pipeline()writesuint32_t* out_step_count;ovclash_run_pipeline_async()writesovclash_async_t** out_async;ovclash_is_pipeline_running()writesbool* out_running.
A failed getter generally leaves its outputs untouched. Initialize a canonical output struct with
its ovclash_reset_* helper before the call, so that a failure cannot be mistaken for data:
Helper |
Initial state |
|---|---|
|
The default settings table. A fresh context holds exactly these values. Canonical C lists each field of |
|
Empty names and hashes, zero counts, |
|
Empty names, zero hashes, triangle count and time. |
|
Zero counts and null buffer pointers. It never frees anything; see Borrowed memory. |
|
Empty name, zero indices and progress, and |
|
Zero counters. It clears no counter held by a context; |
The helpers need no context, record no error text and are safe to call concurrently. Each fails
only for a null pointer. Overlap records lists the fields of
ovclash_overlap_data_t, and Overlap reports those of
ovclash_overlap_report_t.
Error text#
A result carries no message. Error text comes through a separate channel:
Layer |
Accessor |
Scope |
|---|---|---|
Canonical |
|
Per context. It is the only diagnostic channel of the canonical C ABI and has no thread-local fallback. |
Suite runtime |
|
Per runtime handle, falling back to the thread-local text |
Suite data handle |
|
Per data handle, falling back to the thread-local text |
Suite async fetch |
|
Per async fetch operation |
Suite calls without a handle-local channel |
|
Per thread, for handle-free and generic errors |
The three Suite getters ovclash_suite_get_last_error(), ovclash_suite_data_get_last_error() and
ovclash_suite_get_thread_last_error() return the text directly. Every other Suite function,
ovclash_suite_fetch_async_get_last_error() included, returns a result.
Read the text only after a failed call. The text is sticky across most successful calls, so a non-empty message alone does not mean that the last call failed.
An empty message does not prove success. Some rejections record nothing: a null context, some null arguments (a null struct passed to
ovclash_set_settings(), for example), anyovclash_get_settings()failure, a null async handle, and a pipeline step rejected because a cancellation is pending. Check the status.A successful run can record text. On ovstage, a run that dropped meshes it could not cook records that while every step still succeeds.
nbCookedMeshesbelownbMeshesminusnbSharedMeshesinovclash_stats_tis the durable signal.Context-free calls record nothing:
ovclash_sdf_path_to_int(),ovclash_get_backend_info(),ovclash_get_result_string(),ovclash_get_version(),ovclash_get_version_string(),ovclash_overlap_report_get_dltensor()and theovclash_reset_*helpers. Their status is the only signal.ovclash_get_result_string()maps a status to its name,"OVCLASH_STATUS_SUCCESS"or"OVCLASH_STATUS_ERROR", not to a failure description.Every Suite function that returns
ovclash_suite_result_tcatches C++ exceptions. It turns them intoOVCLASH_SUITE_STATUS_ERRORand updates the thread-local text; the handle-local accessors keep the failures of their handles.
Error text lifetime lists the calls that clear the text and how long each channel’s text stays valid. Copy the bytes to keep them. A minimal check helper:
#include <ovclash/ovclash.h>
#include <stdio.h>
/* Returns 1 on success. On failure, prints the context's last error and returns 0. */
static int check(ovclash_context_t* ctx, ovclash_result_t result, const char* what)
{
ovclash_string_t error;
if (result.status == OVCLASH_STATUS_SUCCESS)
{
return 1;
}
error = ovclash_get_last_error(ctx); /* borrowed: copy it to keep it */
fprintf(stderr, "%s failed: %.*s\n", what, (int)error.length, error.length ? error.ptr : "");
return 0;
}
The three string getters#
Exactly three canonical entry points return ovclash_string_t instead of a result:
Function |
Why it has no status |
|---|---|
|
It maps a status to its static name; a status for it to check would be circular. |
|
It is the error-reporting channel. A null context yields an empty |
|
It takes no context and cannot fail. |
Strings#
Strings are explicit-length byte spans, not owned C strings.
ovclash_string_tis a typedef of the producer-ownedovx_string_tfrom<ovx/string_types.h>. The Suite API definesovclash_suite_string_twith the same layout, so the core Suite headers need noovx/header.Every input string and every returned string view crosses the ABI in this form.
Both types have the same two fields:
Field |
Type |
Required |
Default or values |
Description |
|---|---|---|---|---|
|
|
Yes, unless |
UTF-8 bytes, or |
The first byte of the string. |
|
|
Yes |
|
The number of UTF-8 bytes, not characters, without any trailing null. It is authoritative. |
Text that a Suite function writes for the caller, such as JSON or an export, goes into a
caller-supplied char* buffer with an explicit size in bytes instead. The function reports the
required UTF-8 byte count, without the trailing null, through out_required_size. A null buffer
with size zero is the size query. A non-null buffer too small for the text plus its trailing null
fails, and the call still reports the required count. Query the size, allocate one more byte and
call again; The serializer buffer rule
shows the pattern.
Input strings:
They are UTF-8 and need no trailing null. Malformed UTF-8 is rejected before the string is used.
A view is valid when
ptris non-null orlengthis zero. A nullptrwith a non-zerolengthis rejected before the API reads it.The callee copies what it keeps, unless a function documents that it borrows.
Returned views:
They are borrowed from the handle, report or library that produced them. Copy the bytes before the next call that mutates the owner, and before you destroy it. Borrowed memory gives the rules per handle.
Read them by
length, even where the bytes are also null-terminated. Non-null Suite views,ovclash_get_last_error()andovclash_get_version_string()are null-terminated for C compatibility; other canonical views need not be.An empty returned view may be
{ NULL, 0 }.Compare by
(length, bytes).strncmpis unsafe, because a shorter string prefix-matches.
#include <ovclash/ovclash.h>
#include <stdio.h>
#include <string.h>
/* Builds an input view over a C string. The callee copies what it keeps. */
static ovclash_string_t make_view(const char* text)
{
ovclash_string_t view;
view.ptr = text;
view.length = strlen(text);
return view;
}
/* Compares a returned view with a C string by (length, bytes). */
static int view_equals(ovclash_string_t view, const char* text)
{
size_t length = strlen(text);
return view.length == length && (length == 0 || memcmp(view.ptr, text, length) == 0);
}
/* Writes a returned view by its length; an empty view may carry a null ptr. */
static void print_view(FILE* stream, ovclash_string_t view)
{
if (view.length != 0)
{
fwrite(view.ptr, 1, view.length, stream);
}
}
Input validation#
Each canonical function documents its own input rules. Common to them: a null context or a null
required pointer returns OVCLASH_STATUS_ERROR, and a string argument that is an invalid span,
is not UTF-8 or contains an embedded NUL is rejected before it is used.
On the Suite layer, these rules hold for every function unless it documents otherwise:
Input strings and filesystem paths must be valid UTF-8.
A path with an embedded NUL character fails before anything is touched.
ovclash_suite_file_exists()reports “no file” instead.A counted array may be null only when its count is zero.
Handles and out pointers must be non-null.
Functions complete their operation before they return, except the three that start asynchronous work:
ovclash_suite_run_pipeline_async(),ovclash_suite_runtime_fetch_and_save_async()andovclash_suite_runtime_fetch_and_save_async_with_reader().
Units and layout#
Canonical pipeline times are seconds. This covers
ovclash_settings_t::startTime,endTimeand thetimefields of the result structs.ovclash_get_prim_matrix()takes a USD time code. Convert with the stage’s effective rate fromovclash_get_stage_timeline_data():seconds = time code / timeCodesPerSecond.timeCodesPerSecondin the settings is the query sampling rate over[startTime, endTime]. It is not the stage rate.Distances are in stage units, so the stage’s
metersPerUnitmetadata, the length of one unit in meters, applies. This coversminDistance,maxLocalDepthand the tolerance.Suite times are seconds unless a function explicitly names USD time codes. The Suite frame fields named
timecodealso hold seconds.Matrices are row-major 4x4 arrays of 16 doubles on both layers.
Suite booleans are 0 for false and non-zero for true.
Suite counts (
*_count,nb_*) are element counts. String lengths and buffer sizes are in bytes.
Ownership and threading#
Threading and Ownership owns these rules: which handle owns what, borrowed memory, error-text lifetime, the Suite fetch and cursor guards, and which calls may cross threads. Asynchronous Pipelines covers the async handle.
The OVCLASH_STANDALONE macro#
OVCLASH_STANDALONE must be defined to 1 in every program that uses the SDK archive:
The installed CMake package defines it as an
INTERFACEcompile definition onovclash::ovclash.The pkg-config
Cflagsdefine it too.A consumer that uses neither package passes
-DOVCLASH_STANDALONE(value1) itself, as Linking shows. The header tests#if OVCLASH_STANDALONE, so a bare#define OVCLASH_STANDALONEwithout a value does not compile.
These canonical entry points are declared only behind it:
ovclash_open_stage()andovclash_get_prim_matrix();ovclash_sdf_path_to_int()andovclash_set_scope_paths();ovclash_get_last_error()andovclash_get_settings();ovclash_get_version()andovclash_get_version_string();the DLPack report interop,
ovclash_overlap_report_get_dltensor(), together with the<ovx/dlpack/dlpack.h>include; see The DLPack path.
ovclash_get_backend_info() sits outside the fence.
Linkage macro#
<ovclash/ovclash_export.h> is the single definition of OVCLASH_API, shared by the canonical
and the Suite headers:
Platform |
|
|---|---|
Windows, library build ( |
|
Windows, consumer |
|
GCC or Clang on other platforms |
|
Other compilers |
empty |
A consumer that defines OVCLASH_API before the include keeps its own definition.
ovstage extensions#
<ovclash/ovclash_ovstage.h> and <ovclash_suite/ovclash_suite_ovstage.h> declare optional
symbols that only the ovstage build of the library exports. A program that links the library of
a released SDK archive at build time calls them directly, because every released package is an
ovstage build. A program that selects the library at run time checks the
backend before it resolves them.
ovstage Integration covers the owner-operation gate, attached stages,
the binding descriptor and the backend check.