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 ovx/ headers

<ovclash/ovclash.h>

Canonical C ABI: types, contexts, settings, scope, pipeline and results.

Yes

<ovclash/version.h>

Generated version constants; see Version constants.

No

<ovclash/ovclash_export.h>

The single definition of OVCLASH_API; see Linkage macro.

No

<ovclash/ovclash_ovstage.h>

Optional ovstage-only extensions: attached stages, owner operations and matrix decomposition.

Yes

<ovclash_suite/ovclash_suite.h>

Suite runtime, persistence and export entry points. It includes ovclash_suite_types.h, ovclash_suite_models.h and ovclash_suite_serializer.h.

No

<ovclash_suite/ovclash_suite_types.h>

Suite handles, strings, enums and plain-data views.

No

<ovclash_suite/ovclash_suite_models.h>

Suite model objects: query, clash info (a clash record), frame info (one frame of a clash) and point-cloud settings.

No

<ovclash_suite/ovclash_suite_serializer.h>

Custom persistence callbacks and the saved-data reader for fetch-and-save.

No

<ovclash_suite/ovclash_suite_ovstage.h>

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

OVCLASH_VERSION_MAJOR

Integer literal

Yes, always defined

0 or more

Major component of the version the headers were generated for.

OVCLASH_VERSION_MINOR

Integer literal

Yes, always defined

0 or more

Minor component.

OVCLASH_VERSION_PATCH

Integer literal

Yes, always defined

0 or more; 0 for a version without a patch number

Patch component.

OVCLASH_VERSION_STRING

String literal

Yes, always defined

"MAJOR.MINOR.PATCH", without a prerelease label

The numeric version as a string.

OVCLASH_VERSION_ENCODE(major, minor, patch)

Function-like macro; an integer expression

Yes, always defined

major * 1000000 + minor * 1000 + patch

Encodes a version as one comparable integer. The order holds while minor and patch stay below 1000.

OVCLASH_VERSION

Integer expression

Yes, always defined

OVCLASH_VERSION_ENCODE of the three components

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 three uint32_t out-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

ovclash_result_t::status

ovclash_status_t

Yes

OVCLASH_STATUS_SUCCESS (0), OVCLASH_STATUS_ERROR (1)

The outcome of a canonical call.

ovclash_suite_result_t::status

ovclash_suite_status_t

Yes

OVCLASH_SUITE_STATUS_SUCCESS (0), OVCLASH_SUITE_STATUS_ERROR (1), OVCLASH_SUITE_STATUS_UNAVAILABLE (2)

The outcome of a Suite call.

  • Success is zero. Compare the field: result.status == OVCLASH_STATUS_SUCCESS, or OVCLASH_SUITE_STATUS_SUCCESS on the Suite layer. Both are 0.

  • if (result.status) therefore tests for failure, and if (!result) does not compile, because a result is a struct.

  • A failure is OVCLASH_STATUS_ERROR (1), or OVCLASH_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). Only ovclash_suite_create_overlap_report() and ovclash_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 return OVCLASH_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() writes uint32_t* out_step_count;

  • ovclash_run_pipeline_async() writes ovclash_async_t** out_async;

  • ovclash_is_pipeline_running() writes bool* 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

ovclash_reset_settings()

The default settings table. A fresh context holds exactly these values. Canonical C lists each field of ovclash_settings_t with its type and default.

ovclash_reset_overlap_data()

Empty names and hashes, zero counts, maxLocalDepth -1.0f (“not computed”), and type OVCLASH_OVERLAP_PAIR_TYPE_UNDEFINED (0x7fffffff, not zero). ovclash_get_overlap_data() leaves the struct untouched when it fails.

ovclash_reset_duplicate_mesh_data()

Empty names, zero hashes, triangle count and time.

ovclash_reset_overlap_report()

Zero counts and null buffer pointers. It never frees anything; see Borrowed memory.

ovclash_reset_step_data()

Empty name, zero indices and progress, and finished set to true. Do not use finished as an initialized-or-not test.

ovclash_reset_stats()

Zero counters. It clears no counter held by a context; ovclash_reset_context() does that.

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

ovclash_get_last_error(context)

Per context. It is the only diagnostic channel of the canonical C ABI and has no thread-local fallback.

Suite runtime

ovclash_suite_get_last_error(runtime)

Per runtime handle, falling back to the thread-local text

Suite data handle

ovclash_suite_data_get_last_error(data)

Per data handle, falling back to the thread-local text

Suite async fetch

ovclash_suite_fetch_async_get_last_error(async, &text)

Per async fetch operation

Suite calls without a handle-local channel

ovclash_suite_get_thread_last_error()

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), any ovclash_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. nbCookedMeshes below nbMeshes minus nbSharedMeshes in ovclash_stats_t is 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 the ovclash_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_t catches C++ exceptions. It turns them into OVCLASH_SUITE_STATUS_ERROR and 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

ovclash_get_result_string()

It maps a status to its static name; a status for it to check would be circular.

ovclash_get_last_error()

It is the error-reporting channel. A null context yields an empty { NULL, 0 } view.

ovclash_get_version_string()

It takes no context and cannot fail.

Strings#

Strings are explicit-length byte spans, not owned C strings.

  • ovclash_string_t is a typedef of the producer-owned ovx_string_t from <ovx/string_types.h>. The Suite API defines ovclash_suite_string_t with the same layout, so the core Suite headers need no ovx/ 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

ptr

const char*

Yes, unless length is 0

UTF-8 bytes, or NULL for an empty view

The first byte of the string.

length

size_t

Yes

0 or more

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 ptr is non-null or length is zero. A null ptr with a non-zero length is 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() and ovclash_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). strncmp is 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() and ovclash_suite_runtime_fetch_and_save_async_with_reader().

Units and layout#

  • Canonical pipeline times are seconds. This covers ovclash_settings_t::startTime, endTime and the time fields of the result structs.

  • ovclash_get_prim_matrix() takes a USD time code. Convert with the stage’s effective rate from ovclash_get_stage_timeline_data(): seconds = time code / timeCodesPerSecond.

  • timeCodesPerSecond in 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 metersPerUnit metadata, the length of one unit in meters, applies. This covers minDistance, maxLocalDepth and the tolerance.

  • Suite times are seconds unless a function explicitly names USD time codes. The Suite frame fields named timecode also 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 INTERFACE compile definition on ovclash::ovclash.

  • The pkg-config Cflags define it too.

  • A consumer that uses neither package passes -DOVCLASH_STANDALONE (value 1) itself, as Linking shows. The header tests #if OVCLASH_STANDALONE, so a bare #define OVCLASH_STANDALONE without a value does not compile.

These canonical entry points are declared only behind it:

  • ovclash_open_stage() and ovclash_get_prim_matrix();

  • ovclash_sdf_path_to_int() and ovclash_set_scope_paths();

  • ovclash_get_last_error() and ovclash_get_settings();

  • ovclash_get_version() and ovclash_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

OVCLASH_API

Windows, library build (OVCLASH_EXPORTS defined)

__declspec(dllexport)

Windows, consumer

__declspec(dllimport)

GCC or Clang on other platforms

__attribute__((visibility("default")))

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.