C/C++ Quickstart: Link, Build, First Query#
ovclash, a clash detection library for USD scenes, is a C library first. The Python packages are bindings over the same C ABI (application binary interface). The SDK archive ships the public headers and the link files, so a C or C++ consumer needs no source checkout. The Python-only wheel does not ship them, and it does not ship this page either.
This page covers what ships, how to link, a first program and the rules that catch people out.
It is not an API reference. The headers are the reference: every entry point in
include/ovclash/ovclash.h has a doxygen comment for its arguments, ownership and threading, and
References in the package lists every header.
C ABI conventions gives the rules that every entry point follows. The same
reference is published as a browsable site, the
ovclash documentation.
Prerequisites#
An extracted SDK archive. Each release has one archive per platform:
ovclash-<version>-windows-x86_64.zip,ovclash-<version>-linux-x86_64.tar.gzandovclash-<version>-linux-aarch64.tar.gz, where<version>is the ovclash release version. A release attaches them, beside its wheels, to its page on the ovclash GitHub releases. No archive exists for other platforms; see Platforms and package names. An archive unpacks to anovclash/directory, written<sdk>on this page. Paths without a placeholder are relative to it.Python 3.10 or newer with the SDK archive’s
requirements.txtinstalled. The SDK archive does not bundle ovstage, the runtime that ovclash reads USD through; see Installing the ovstage runtime.<site-packages>is that interpreter’s package directory, whichpython -m pip show ovstageprints asLocation. The installed package directory,<site-packages>/ovstage, also holds the ovx headers thatovclash.hincludes.A C or C++ compiler and CMake 3.16 or newer. The minimal program is C11. The C++ samples use C++17.
On Windows, the Microsoft Visual C++ Redistributable (x64). ovclash does not bundle the MSVC runtime.
On Linux, glibc 2.35 or newer and a
libstdc++that providesGLIBCXX_3.4.30; see Linux glibc baseline.A USD stage. The SDK archive ships
samples/data/time_sampled.usda. Its prims/Root/Xform_Primitives/Cubeand/Root/Xform_Primitives/Planeoverlap, and the minimal program queries that pair.
What ships#
Path |
Contents |
|---|---|
|
The canonical clash C ABI and its |
|
Optional ovstage-only extensions: matrix decomposition selection, attaching a caller-owned ovstage stage and the owner-operation gate. ovstage_integration.md describes them. |
|
Defines |
|
Generated |
|
The C ABI of the Suite API: the higher-level object model, SQLite or JSON directory persistence, and HTML and JSON export. |
|
DLPack. |
|
The exported CMake package config. |
|
The pkg-config file, in the conventional location and at the package root. |
|
Windows: the runtime library and its import library. |
|
Linux: the runtime library. |
|
The exact |
|
The same requirement, declared for tools. |
|
The SHA-256 of each ovstage native file that the SDK archive excludes, as the pinned wheel installs it. |
|
A note that names the separately installed ovstage runtime and its install command. |
|
The build’s identity: source revision, backend, ovclash version and pinned ovstage version. |
|
The Python packages, and the C++ and Python samples with the stage they open. |
The runtime’s config.toml sits beside the runtime library. The SDK archive excludes ovstage and
its native dependency closure; Installing the ovstage runtime
installs them. SDK archive layout summarizes the archive, and
the “What is in this archive” section of README.md at the SDK archive root lists every path.
Installing the ovstage runtime#
Before you begin, extract the SDK archive and pick the interpreter that you build and run with,
as Prerequisites describes. The SDK archive’s requirements.txt pins the exact
ovstage version that the SDK archive was built and validated against. That version is published
on public PyPI. Install it with that interpreter (python3 on most Linux systems):
python -m pip install -r <sdk>/requirements.txt
Check the result: python -m pip show ovstage prints Version: followed by the version that
requirements.txt pins. When pip cannot find that version, check which package index pip reads.
pip reads public PyPI unless you configure another index, for example with --index-url or
PIP_INDEX_URL. The installed ovstage of that interpreter is then the runtime that every
consumer of the SDK archive selects:
find_package(ovclash)reads it at configure time, with Python 3.10 or newer. Name the interpreter with-DOVCLASH_PYTHON_EXECUTABLE=<absolute path to python>or theOVCLASH_PYTHON_EXECUTABLEenvironment variable. The path must be absolute: a relative path or a bare name such aspython3.12is refused.Without that variable, the config uses an absolute
Python3_EXECUTABLEof Python 3.10 or newer, else the firstpython3orpythonon the search path. An olderPython3_EXECUTABLEis skipped, not an error.The config does not run
FindPython3. It leaves noPython3_*cache entries and noPython3::Interpretertarget behind for your ownfind_package(Python3).The Python packages use the interpreter that imports them.
The sample launchers and
samples/build_samples.sh(.baton Windows) start from the interpreter thatPYTHONnames, elsepython3(pythonon Windows). They use it when it has the pinned version, and otherwise install the pin into a per-user cached virtual environment that they use instead, leaving the base interpreter unchanged.
find_package(ovclash) and the Python packages require exactly the pinned version. Another
version, or none, is an error that names the interpreter and the install command.
find_package then reports ovclash as not found and gives that reason. A REQUIRED call stops
the configure step, and an optional find_package(ovclash QUIET) continues without ovclash.
Troubleshooting lists the
messages.
OVCLASH_OVSTAGE_PACKAGE_DIR selects one specific installation instead:
Set it to the absolute path of that installation’s
ovstagepackage directory. Its parent holdsovstage-<version>.dist-info.Set it in the environment or, for CMake, as a cache variable. The cache variable takes precedence.
~is expanded and links are resolved.A relative value is refused. So is a directory whose installation is not exactly the pinned version.
Unset it to return to the interpreter’s installed ovstage.
Linking#
Before you begin, install the ovstage runtime as
Installing the ovstage runtime describes. Use the exported
CMake config. Its imported target is ovclash::ovclash. A complete CMakeLists.txt for a
program whose source is main.c in the same directory:
cmake_minimum_required(VERSION 3.16)
project(my_app C CXX)
find_package(ovclash CONFIG REQUIRED)
add_executable(my_app main.c)
target_link_libraries(my_app PRIVATE ovclash::ovclash)
From the directory that holds that CMakeLists.txt, configure with the SDK archive’s package
config and the interpreter that has its requirements.txt installed:
cmake -S . -B build "-Dovclash_DIR=<sdk>/lib/cmake/ovclash" \
"-DOVCLASH_PYTHON_EXECUTABLE=<absolute path to python>"
cmake --build build --config Release
Both commands exit with status 0, and the build writes my_app under build
(build\Release\my_app.exe with a Visual Studio generator). When find_package(ovclash) fails,
its message names the cause; Configuring with CMake
lists the messages and their fixes.
The ovclash::ovclash target sets what the compiler and the linker need:
It defines
OVCLASH_STANDALONE. Without it,ovclash.homits the standalone entry points: file-backed stage access such asovclash_open_stage(), path scopes such asovclash_set_scope_paths(),ovclash_get_last_error(), settings readback, the version queries and the DLPack interop. C ABI conventions describes the macro.It adds the ovx include directory.
On Linux, it adds
-rpath-linkdirectories for the runtime’s indirect dependencies, and it links the ovstage loader; see Running the program.
<ovclash/ovclash.h> needs ovx/string_types.h (or the legacy ovx/types.h), which ovclash
does not ship. The header comes from the include/ directory of the ovstage package, so the
SDK archive needs no OVCLASH_OVX_INCLUDE_DIR. The exported config looks for the header in this
order:
OVCLASH_OVX_INCLUDE_DIR, as a CMake variable, else in the environment. A directory without the header is a fatal error.A
find_pathsearch, hinted by theinclude/directory of the ovstage package that the SDK archive selected, then by<OVCLASH_OVSTAGE_ROOT>/includewhen theOVCLASH_OVSTAGE_ROOTenvironment variable is set.Otherwise
find_package(ovclash CONFIG REQUIRED)fails and names the header and the remedy. SetOVCLASH_ALLOW_MISSING_OVX=ONonly if you supply the header through compiler flags that CMake cannot see. The config then prints a status line and adds no ovx include directory.
OVCLASH_OVSTAGE_ROOT only hints at headers; it never selects the runtime.
CMake variables#
These are the variables that you set when you configure against the SDK archive:
Variable |
Type |
Required |
Default |
Meaning |
|---|---|---|---|---|
|
Directory path |
Yes, unless |
unset |
The directory that holds |
|
Absolute file path |
No |
|
The absolute path of the Python 3.10 or newer interpreter whose installed |
|
Absolute directory path |
No |
unset |
The absolute path of the installed |
|
Directory path |
No |
discovered |
The directory that holds |
|
Boolean: |
No |
|
Accept the package when the ovx header cannot be found, for a header that arrives through compiler flags. |
|
Directory path |
No |
the |
Linux only. One more directory of ovstage shared libraries for the |
|
|
No |
generator-dependent |
The build configuration of a single-config generator. Multi-config generators take |
OVCLASH_OVSTAGE_ROOT is not a cache variable. The config reads it from the environment as a
find_path hint only.
After find_package(ovclash), OVCLASH_RUNTIME_DIRS lists the runtime directories of the SDK
archive and of the selected ovstage package.
Without CMake#
Before you begin, install the ovstage runtime as
Installing the ovstage runtime describes. Then pass both
include directories and OVCLASH_STANDALONE yourself. From the directory that holds your
source file app.c, on Windows with the MSVC compiler:
cl /c /DOVCLASH_STANDALONE /I<sdk>\include /I<site-packages>\ovstage\include app.c
On Linux:
cc -c -DOVCLASH_STANDALONE -I<sdk>/include -I<site-packages>/ovstage/include app.c
The compile exits with status 0 and writes app.obj (Windows) or app.o (Linux). When it stops
at #error "ovclash requires ovx/string_types.h or ovx/types.h", the ovstage include directory
is wrong; check <site-packages>.
On Windows, link against <sdk>\lib\ovclash.lib. On Linux, link through CMake or
pkg-config, because the program must also record the ovstage loader.
Running the program#
On Linux, the exported config makes the executable record the ovstage loader,
libovstage-dynamic.so, from <site-packages>/ovstage/bin, outside the SDK archive. The dynamic
linker then reuses that loaded loader for libovclash.so. CMake gives the build-tree executable run
paths to <sdk>/lib and to <site-packages>/ovstage/bin. A program built through
find_package(ovclash) therefore starts from its build tree without LD_LIBRARY_PATH.
The run paths name this machine’s directories. If you move the SDK archive or the Python environment, build again.
An installed copy follows your own install run path, as for any imported library: set
INSTALL_RPATHon the target, orCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON.libovclash.sorecords its backend libraries asDT_NEEDEDentries, and the linker needs search directories for them. The config adds a-Wl,-rpath-linkoption for each of these directories that exists: the SDK archive’sbin/andlib/, the selected ovstage package’s runtime directories, andOVCLASH_OVSTAGE_LIBRARY_DIRwhen it is set.
Windows has no run path. In the Command Prompt that starts the program, put the SDK archive’s
bin\ and the installed package’s bin\ and bin\plugins\ on PATH:
set "PATH=<sdk>\bin;<site-packages>\ovstage\bin;<site-packages>\ovstage\bin\plugins;%PATH%"
Leave the installed package as pip laid it out: ovstage finds its plugins\ tree relative to
the directory its DLL loads from. With these directories on PATH, the program reaches main.
Without them it exits with code 0xc0000135 before main runs, and a Linux program that cannot
find its libraries exits with 127; see
Exit code 0xc0000135 or 127 before the program starts.
OVCLASH_RUNTIME_DIRS holds the same directories, for example for a test’s ENVIRONMENT
property. A CTest test can prepend them to its PATH. Add these lines to the CMakeLists.txt
of Linking, after its add_executable(my_app main.c):
enable_testing()
add_test(NAME my_app COMMAND my_app)
if(WIN32)
# Escape the ';' separators so the whole PATH value stays one ENVIRONMENT entry.
string(REPLACE ";" "\\;" _my_app_path "${OVCLASH_RUNTIME_DIRS};$ENV{PATH}")
set_tests_properties(my_app PROPERTIES ENVIRONMENT "PATH=${_my_app_path}")
endif()
pkg-config on Linux#
The Linux SDK archive’s ovclash.pc derives the ovx include directory, the ovstage loader and
the run paths from its ovstage_root variable. Define that variable as the installed ovstage
package directory. From the directory that holds your source file app.c:
export PKG_CONFIG_PATH=<sdk>/lib/pkgconfig
ovstage_dir="$(python3 -c 'import importlib.metadata as m; print(m.distribution("ovstage").locate_file("ovstage"))')"
cc app.c -o app $(pkg-config --define-variable=ovstage_root="$ovstage_dir" --cflags --libs ovclash)
The command writes the executable app, and the program then starts without LD_LIBRARY_PATH,
as with CMake. What ovclash.pc defines and emits:
Field |
Type |
Required |
Default or values |
Description |
|---|---|---|---|---|
|
Variable, a directory path |
Yes, through |
|
The installed |
|
Variable, a directory path |
No |
|
The directory of the ovx headers. |
|
Compiler flags |
No |
|
The define and both include directories. |
|
Linker flags |
No |
|
The ovstage loader from |
Limitations:
Without
ovstage_root, the flags name the placeholder/OVCLASH_SET_ovstage_root, for example-I/OVCLASH_SET_ovstage_root/include. The compile then stops at#error "ovclash requires ovx/string_types.h or ovx/types.h".pkg-config output cannot carry a path that contains spaces. Build through CMake when the SDK archive or the ovstage package lives in such a directory.
On Windows, use the CMake package. Its
.pcfiles name no ovstage directory.
Minimal program#
#include <ovclash/ovclash.h>
#include <stdio.h>
#include <string.h>
/* Paths and messages cross the ABI as ovclash_string_t, not const char*. */
static ovclash_string_t str(const char* s)
{
ovclash_string_t out;
out.ptr = s;
out.length = strlen(s);
return out;
}
static void report_failure(const ovclash_context_t* ctx, const char* operation)
{
fprintf(stderr, "%s failed", operation);
if (ctx != NULL) {
ovclash_string_t error = ovclash_get_last_error(ctx);
if (error.ptr != NULL && error.length != 0) {
fputs(": ", stderr);
fwrite(error.ptr, 1, error.length, stderr);
}
}
fputc('\n', stderr);
}
int main(void)
{
ovclash_context_t* ctx = NULL;
ovclash_settings_t settings;
ovclash_string_t a[] = { str("/Root/Xform_Primitives/Cube") };
ovclash_string_t b[] = { str("/Root/Xform_Primitives/Plane") };
uint32_t steps = 0;
uint32_t count = 0;
int exit_code = 1;
if (ovclash_create_context(&ctx).status != OVCLASH_STATUS_SUCCESS) {
report_failure(NULL, "create_context");
goto cleanup;
}
/* A new context already holds these defaults. Change fields before applying them. */
if (ovclash_reset_settings(&settings).status != OVCLASH_STATUS_SUCCESS) {
/* Context-free helpers do not record a context error message. */
report_failure(NULL, "reset_settings");
goto cleanup;
}
if (ovclash_set_settings(ctx, &settings).status != OVCLASH_STATUS_SUCCESS) {
report_failure(ctx, "set_settings");
goto cleanup;
}
/* The path is relative to the working directory. */
if (ovclash_open_stage(ctx, str("time_sampled.usda")).status != OVCLASH_STATUS_SUCCESS) {
report_failure(ctx, "open_stage");
goto cleanup;
}
/* Applying settings and opening a stage both clear the scope, so set it last. */
if (ovclash_set_scope_paths(ctx, a, 1, b, 1).status != OVCLASH_STATUS_SUCCESS) {
report_failure(ctx, "set_scope_paths");
goto cleanup;
}
if (ovclash_create_pipeline(ctx, &steps).status != OVCLASH_STATUS_SUCCESS) {
report_failure(ctx, "create_pipeline");
goto cleanup;
}
for (uint32_t i = 0; i < steps; ++i) {
if (ovclash_run_pipeline_step(ctx, i).status != OVCLASH_STATUS_SUCCESS) {
report_failure(ctx, "run_pipeline_step");
goto cleanup;
}
}
if (ovclash_get_overlap_count(ctx, &count).status != OVCLASH_STATUS_SUCCESS) {
report_failure(ctx, "get_overlap_count");
goto cleanup;
}
exit_code = 0;
cleanup:
if (ctx != NULL && ovclash_release_context(ctx).status != OVCLASH_STATUS_SUCCESS) {
/* The context is no longer available after release. */
report_failure(NULL, "release_context");
exit_code = 1;
}
if (exit_code == 0)
printf("overlaps: %u\n", count);
return exit_code;
}
The program follows the canonical lifecycle:
ovclash_create_context()creates a context.ovclash_reset_settings()fills a settings struct with the defaults.ovclash_set_settings()applies the settings struct.ovclash_open_stage()opens a local USD file.ovclash_set_scope_paths()sets the two search sets of the scope. It comes after the settings and the stage, because both clear the scope.ovclash_create_pipeline()returns the step count.ovclash_run_pipeline_step()runs each step in order.ovclash_get_overlap_count()reads the result.ovclash_release_context()releases the context on every path.
The release validation extracts this program from this page and compiles it against the packaged headers. It then runs the program against stubs that check its error handling and cleanup.
Building and running it#
Save the program as first_query.c beside this CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(first_query C)
find_package(ovclash CONFIG REQUIRED)
add_executable(first_query first_query.c)
target_link_libraries(first_query PRIVATE ovclash::ovclash)
set_target_properties(first_query PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED YES)
Configure and build it as in Linking. <build> on this page is the build directory
that you passed to cmake -B. The native library does not set its
OpenUSD plugin path the way the Python packages do, so set up the
environment before you run it:
Set
OV_PXR_PLUGINPATH_2511to the installed package’s OpenUSD plugin directory,<site-packages>/ovstage/bin/plugins/usd. Without it, the process aborts insideovclash_open_stage()withovstage: fatal USD error: Failed to find the plugInfo.json file ..., and no status or last-error text is returned.On Windows, put the directories that Running the program names on
PATH. On Linux, a program linked through CMake or pkg-config needs noLD_LIBRARY_PATH.
Then run it from samples/data/, or change the stage path in the program. On Linux:
cd <sdk>/samples/data
export OV_PXR_PLUGINPATH_2511=<site-packages>/ovstage/bin/plugins/usd
<build>/first_query
On Windows, where <build>\Release holds the executable of a Visual Studio build:
cd /d <sdk>\samples\data
set "OV_PXR_PLUGINPATH_2511=<site-packages>\ovstage\bin\plugins\usd"
set "PATH=<sdk>\bin;<site-packages>\ovstage\bin;<site-packages>\ovstage\bin\plugins;%PATH%"
<build>\Release\first_query.exe
Output:
overlaps: 1
The run_*_cpp launchers under samples/ set up the same environment for the samples. They
also set PXR_PLUGINPATH_NAME to the same directory, which your program does not need: the
OpenUSD inside ovstage is namespaced and reads OV_PXR_PLUGINPATH_2511.
Keep its plugin directory out of PXR_PLUGINPATH_NAME when an unnamespaced OpenUSD, such as
usd-core, shares the process; USD coexistence explains why.
samples/clash_api/ClashApi.cpp is the full version of this program; Samples
describes it. It adds overlap reports, duplicate search, point clouds and the asynchronous
pipeline.
A pipeline step returns OVCLASH_STATUS_ERROR when its phase fails, and
ovclash_get_last_error() holds the reason. A successful run can still skip meshes that it could
not cook; see Error text is per context in
Rules that bite first. The comments in include/ovclash/ovclash.h
document each entry point’s backend differences;
References in the package lists that header.
Rules that bite first#
C ABI conventions gives the full rules for results, error text and strings. These are the ones that catch people out first.
Results are structs, not enums. Every canonical entry point returns ovclash_result_t, a
struct with one status field. The only exceptions are three string getters:
ovclash_get_result_string(), ovclash_get_last_error() and ovclash_get_version_string().
The minimal program tests every result, and
Status results lists the fields and values. For a result
r:
Test success with
r.status == OVCLASH_STATUS_SUCCESS.OVCLASH_STATUS_SUCCESSis 0, soif (r.status)tests for failure.if (!r)does not compile, becauseris a struct.ovclash_suite_result_thas the same shape, but it is a distinct type with its ownOVCLASH_SUITE_STATUS_*enum. Do not mix them.
Error text is per context. ovclash_get_last_error(ctx) returns the most recent message
recorded on that context. Usually it is the last failure.
A successful run that dropped meshes it could not cook also records a notice there. The durable signal is
nbCookedMeshesbelownbMeshesminusnbSharedMeshesinovclash_get_query_stats().Successful calls do not always clear the text, and later calls can replace it. Read it right after the failure.
Context-free calls, such as the
ovclash_reset_*helpers, record nothing.
Order the setup calls. ovclash_set_settings() and ovclash_open_stage() clear the scope
paths, so call ovclash_set_scope_paths() after them.
A non-empty
ovclash_set_scope_paths()call also turns offOVCLASH_SETTINGS_FLAG_FULL_SCENE. Clearing the scope does not turn it back on.With neither a scope nor that flag, a run selects nothing.
Restore full-scene traversal with
ovclash_set_full_scene(ctx, true).
Dynamic queries skip static pairs. A dynamic query is one whose start
and end times differ. The default settings enable
OVCLASH_SETTINGS_FLAG_PURGE_PERMANENT_STATIC_OVERLAPS. A dynamic query then drops overlaps
between two meshes whose transforms are not animated. To keep them, clear that flag in
the settings that you apply. Canonical C describes the
ovclash_settings_t fields, and Settings lists every setting.
Overlap reports must be released. A report hands out borrowed views into runtime-owned
storage. Call ovclash_release_overlap_report() before any of these: the next pipeline step or
run, ovclash_release_memory(), ovclash_reset_context() or ovclash_release_context(). A
sampled step can replace the arrays behind the views within the same run.
Releasing a context can block. ovclash_release_context() waits until an outstanding
asynchronous pipeline finishes and its worker is joined. To stop it early, call
ovclash_cancel_pipeline() on its handle first.
Overlap index order is not part of the contract. Two runs can report the same overlaps in a
different order. Identify an overlap by name0 and name1, or by clashHash, from
ovclash_get_overlap_data(). Never identify it by its index; see
Overlap index order is not contractual.
ovclash_string_t is a borrowed view. It is the producer-owned ovx_string_t under another
name: { const char* ptr; size_t length; }. String arguments, such as stage and prim paths, use
it. Strings lists its fields.
The library reads
lengthbytes and does not need a terminating NUL.A view that the library returns points into library-owned storage. Use its
length, as thefwritecall inreport_failure()of the minimal program does, and copy the bytes to keep them.
Suite C ABI#
include/ovclash_suite/ is the C counterpart of the ovclash_suite Python package: the legacy
clash object model of the Kit extension (queries,
clash records and their frames), SQLite or JSON directory persistence,
and HTML and JSON export. It wraps the canonical C ABI rather than
replacing it. Both are compiled into the same shared library, so there
is no separate Suite library to link.
samples/clash_suite_api/ClashSuiteApi.cppis the worked example. Samples describes the sample and itsREADME.md, which walks the surface end to end, and suite_workflows.md explains its five queries.The full ownership, threading and transaction contracts are the doxygen comments in
include/ovclash_suite/ovclash_suite.handovclash_suite_serializer.h; References in the package lists the Suite headers.
This section covers what to get right first.
Create a SQLite handle with ovclash_suite_data_create(), or a JSON directory handle with
ovclash_suite_data_create_directory(). Open it with ovclash_suite_data_open().
Persistence helps you choose between them, and
sqlite_serializer.md and directory_serializer.md
cover each store’s path and recovery contract.
To save a completed runtime query, call ovclash_suite_runtime_fetch_and_save_async() with that
data handle and a NULL serializer. This function belongs in a source file of your program. Its
query_id is the identifier of the stored query, and tolerance and depth_epsilon are that
query’s settings:
#include <ovclash_suite/ovclash_suite.h>
#include <stdio.h>
/* Saves the completed run of runtime into the open store data. Returns 1 on success. */
static int save_results(ovclash_suite_runtime_t* runtime, ovclash_suite_data_t* data, int64_t query_id,
double tolerance, double depth_epsilon)
{
uint32_t include_duplicates = 1; /* The owning query's setting, not the runtime's mode. */
uint32_t resolve_stale = 1; /* Update clash states, as Custom serializers describes. */
ovclash_suite_fetch_async_t* fetch = NULL;
ovclash_suite_result_t finished;
ovclash_suite_result_t cleanup;
if (ovclash_suite_runtime_fetch_and_save_async(runtime, data, NULL, query_id, tolerance, depth_epsilon,
include_duplicates, resolve_stale, &fetch)
.status != OVCLASH_SUITE_STATUS_SUCCESS) {
return 0;
}
/* finish waits; a UI polls the progress snapshots before calling it. */
finished = ovclash_suite_fetch_async_finish(fetch);
if (finished.status != OVCLASH_SUITE_STATUS_SUCCESS) {
ovclash_suite_string_t error = {0};
ovclash_suite_result_t diagnostic = ovclash_suite_fetch_async_get_last_error(fetch, &error);
if (diagnostic.status == OVCLASH_SUITE_STATUS_SUCCESS && error.length)
fwrite(error.ptr, 1, error.length, stderr);
}
cleanup = ovclash_suite_fetch_async_destroy_owned(&fetch);
return finished.status == OVCLASH_SUITE_STATUS_SUCCESS && cleanup.status == OVCLASH_SUITE_STATUS_SUCCESS;
}
The function returns 1 when the fetch finished successfully and its handle was released.
Finish detection first. Finish an asynchronous detection run with
ovclash_suite_async_finish(), and destroy its handle, before you launch the fetch.The owners stay leased until the fetch is destroyed, even after completion, failure or cancellation. Until then, the runtime and the built-in store reject conflicting reads, writes, commits and lifecycle calls. On every path, destroy the fetch before you release either owner.
Progress is not commit.
ovclash_suite_fetch_async_get_step_data()reports whole-operation progress in[0, 1].ovclash_suite_fetch_async_get_counts()reports the written and total counts. Only a successful commit reaches1.0. Written equal to total does not prove a commit.Cancel and poll safely.
ovclash_suite_fetch_async_cancel()requests cancellation and waits for cleanup. Cancellation can race completion; a commit that already happened stays. The snapshot getters may overlap one finish or cancel call. Serialize finish and cancel with each other, and let no call overlap destruction.Destroy exactly once.
ovclash_suite_fetch_async_destroy_owned()sets the pointer toNULLonce it has consumed the handle, even when cleanup reported an error. A rejected call or a failed wait leaves the pointer set, so you can retry.Preparation threading follows the run settings.
Nonzero
single_threadedkeeps frame preparation serial.Otherwise, a nonzero
new_task_manageruses the workers of Carbonite, the task framework that ovstage ships, and zero uses native threads bounded bynb_tasks.Directory and custom-serializer frame preparation can use those workers. SQLite frame encoding and every storage write stay on the single background fetch worker.
The bounded synchronous API (
ovclash_suite_runtime_fetch_and_save_begin,_nextand_destroy) runs every callback exceptprepare_frameon the calling thread instead.
Change fetch threading before launch. To fetch with other threading than detection used, start from the current settings. Once settings were applied,
ovclash_suite_get_run_settings()returns them. Before any settings are applied, that getter returns a zero-initialized struct, which the setter rejects, so readovclash_suite_get_default_run_settings()instead. Then:Read the current settings with the getter that applies.
Change only the threading fields.
Apply them with
ovclash_suite_set_run_settings().
ovclash_suite_set_run_settings()returnsOVCLASH_SUITE_STATUS_SUCCESS, andovclash_suite_get_run_settings()then reports the new threading fields. Completed results are kept, so detection does not rerun. The setter rejects changes while a fetch is alive.Each fetch step bounds its work, not its time. Each
ovclash_suite_runtime_fetch_and_save_next()call handles at most 1,024 frame reports, 1,024 overlaps and about 8 MiB of report payload. Each internal step of the asynchronous fetch has the same bounds. One indivisible report can exceed the payload bound. Reconciliation scans at most 1,024 stored identifiers per step. Initialization enumerates every stored identifier and is not bounded.Read stored overlaps through cursors.
ovclash_suite_data_get_overlaps_by_query()returns an owned forward-only cursor. Copy each view fromovclash_suite_overlap_cursor_next()before you advance. Destroy the cursor before its data handle: a live cursor blocks store lifecycle changes and the launch of an asynchronous fetch into that store. The other getters reuse one scratch record per kind. Copy their strings and arrays before the next getter of the same kind or any change to the store.
Fetch failures and pending writes#
Fetch-and-save is not all-or-nothing for every failure.
Saving detection results gives the transaction outcome
of each failure. The outcomes are the same in serial and parallel modes, for the asynchronous and
the bounded synchronous fetch, and for the Python ClashDetection.fetch_and_save_overlaps()
wrapper. In C:
A failed operation cannot resume. Read its error with
ovclash_suite_fetch_async_get_last_error(), then destroy it.ovclash_suite_data_close()andovclash_suite_data_destroy()are the data-handle calls that attempt the commit of the remaining pending writes.To publish a staging destination only after complete success, wait until
ovclash_suite_fetch_async_finish()reports success.
Custom serializers#
For a custom store, fill an ovclash_suite_fetch_serializer_t callback table and pass it to the
same function with a NULL data handle.
Custom stores lists each member of the table with its C type,
whether it is required and what it does. Exactly one of data and serializer must be
non-NULL. The table is copied, but serializer.user_data and the destination behind it must
outlive the fetch. The store must enforce its own lifetime guards. The save_results() function
of Suite C ABI becomes, for a custom store:
#include <ovclash_suite/ovclash_suite.h>
/* Saves the completed run of runtime through a custom store's callbacks. Returns 1 on success. */
static int save_to_custom_store(ovclash_suite_runtime_t* runtime, const ovclash_suite_fetch_serializer_t* serializer,
int64_t query_id, double tolerance, double depth_epsilon)
{
ovclash_suite_fetch_async_t* fetch = NULL;
ovclash_suite_result_t finished;
if (ovclash_suite_runtime_fetch_and_save_async(runtime, NULL, serializer, query_id, tolerance, depth_epsilon,
1 /* include_duplicates */, 1 /* resolve_stale */, &fetch)
.status != OVCLASH_SUITE_STATUS_SUCCESS) {
return 0;
}
finished = ovclash_suite_fetch_async_finish(fetch);
return ovclash_suite_fetch_async_destroy_owned(&fetch).status == OVCLASH_SUITE_STATUS_SUCCESS &&
finished.status == OVCLASH_SUITE_STATUS_SUCCESS;
}
Acknowledge success explicitly. Callbacks return
voidand receive a trailinguint32_t* out_success, which the engine sets to 0. Write exactly 1 only after all work and outputs succeeded. No exception may cross the C ABI.Threads. With the asynchronous API, every callback except
prepare_frameruns on the background fetch worker, and storage writes follow the runtime’s result order. The optionalprepare_framemay run concurrently on preparation workers. It must touch only immutable state and its own output, never a storage connection or the serializer’s diagnostics. Its partnerrelease_frameruns on the fetch worker. It releases every non-null prepared output exactly once, even one from a failed preparation.Transactions. Implement BEGIN, COMMIT, ROLLBACK and the BEGIN_OVERLAP / END_OVERLAP / ABORT_OVERLAP savepoints with the semantics that Custom stores gives. The serializer header,
<ovclash_suite/ovclash_suite_serializer.h>, documents each action; References in the package lists it. The engine requests a full ROLLBACK at most once per operation, and it cannot recover if your rollback fails.Inputs are borrowed for the duration of the callback; copy what you keep. There is one exception:
prepare_framemay keep a copied frame view’s geometry arrays until itsrelease_frame, but never the view pointer. Strings that you return must be valid UTF-8.
Clash states. Fetching keeps existing identifiers and review annotations. With
resolve_stale nonzero, it updates the stored clash states as
Clash states describes, including when an APPROVED clash keeps
its approval. With resolve_stale zero, it keeps the stored states. Absent clashes are marked
absent either way.
Built-in data handles supply the stored-result reader that the approval comparison needs. To keep
unchanged approvals in a custom store, pass an ovclash_suite_fetch_saved_data_reader_t to
ovclash_suite_runtime_fetch_and_save_async_with_reader(), or to its synchronous counterpart
ovclash_suite_runtime_fetch_and_save_begin_with_reader().
The approval comparison lists each member of the reader
with its C type and whether it is required. In short:
read_overlapreturns the saved header and frame count for the identifier thatfind_overlapreturned.read_framereturns the frame at a zero-based persisted index.The optional
closereleases a reader-owned cursor. It must be idempotent when no cursor is open.
With resolve_stale nonzero and no reader, re-detected APPROVED clashes become ACTIVE,
because unchanged contents cannot be proven. include/ovclash_suite/ovclash_suite_serializer.h
documents the lifetimes of callback outputs, and
References in the package lists it.
Building the C++ samples#
Before you begin, meet the Prerequisites; the script installs the ovstage pin
itself when its interpreter lacks it. samples/build_samples.sh (samples\build_samples.bat on
Windows) configures and builds every first-level sample directory that contains a
CMakeLists.txt. It builds against this SDK archive by default, and it is the quickest check that
your toolchain works. The script finds its own location, so you can run it from any directory.
On Linux:
<sdk>/samples/build_samples.sh --config Release
On Windows:
<sdk>\samples\build_samples.bat --config Release
A successful build ends with Built <count> sample(s)., where <count> is the number of sample
directories built, and the script exits with status 0. When it fails, the error names the cause;
Building and running the shipped samples
lists the messages.
Option |
Type |
Required |
Default |
Meaning |
|---|---|---|---|---|
|
|
No |
|
Build configuration. |
|
Directory path |
No |
|
The ovclash SDK archive root to build against. |
|
Directory path |
No |
|
Parent of the per-sample build trees. A relative |
|
Sample directory name, such as |
No |
Every sample directory |
Build only the named sample directory. |
|
Flag |
No |
Off |
Delete each selected sample’s build tree before building. |
|
Flag |
No |
Off |
Print usage. |
|
Flag |
No |
Off |
Print the ovclash version. Use it as the only argument. |
Any other option fails with Unknown option: before any work starts.
The script also reads these environment variables:
Variable |
Values |
Required |
Default |
Effect |
|---|---|---|---|---|
|
Directory path |
No |
Unset: the SDK archive that holds the script |
Default for |
|
Directory path |
No |
Windows SDK archive: |
Default for |
|
Interpreter name or path |
No |
|
Base interpreter for the runtime selection. |
|
Absolute directory path |
No |
Unset |
Another ovstage installation, as in Installing the ovstage runtime. |
|
Directory path |
No |
Unset: this SDK archive’s config finds the headers in the installed |
The ovstage include directory. |
|
Executable name or path |
No |
|
The CMake executable. |
How the script selects the runtime:
It uses
PYTHONwhen that interpreter has a complete installation of the SDK archive’s exact ovstage pin. Otherwise it installs the pin with pip into a per-user cached virtual environment and uses that environment, leaving the base interpreter’s packages unchanged. The first setup needs pip access to the pinned wheel. samples.md describes that cache.It passes the selected interpreter to CMake as
OVCLASH_PYTHON_EXECUTABLE. The C++ launchers runsamples/sdk_runtime.pywith the same interpreter to put the ovstage runtime on the loader path.OVCLASH_OVSTAGE_PACKAGE_DIRoverrides the selection for both.PYTHONmay be a bare name, looked up the way the shell finds a command, or a path. The script makes it absolute but keeps a virtual environment’s interpreter link. An interpreter that cannot be found stops the build before configuring.
The script configures a sample tree from scratch, as --clean would, when its CMakeCache.txt
records a different ovclash_DIR or OVCLASH_PYTHON_EXECUTABLE. build_samples.bat also starts
from scratch when the packaged toolchain’s generator or compilers changed. After configuring,
both scripts store the SDK archive’s ovclash-build-provenance.json in each sample tree as
.ovclash-sdk-identity. When that copy is missing or differs, they start from scratch, so an SDK
archive replaced at the same path cannot keep the previous SDK archive’s binaries. They print
SDK build identity of "<dir>" differs from this build; configuring it from scratch. (the .sh
prints <dir> without quotes).
Note
Set
OVCLASH_SAMPLE_BUILD_ROOTto choose a writable location when the default is unsuitable, for example when the SDK archive sits in a read-only directory. The script refuses a build root that could hold other data; Unsafe sample build root lists the rules.
Each sample directory also has run_<sample>_cpp.sh (.bat on Windows). It builds its sample
first and then runs the example queries in the runtime environment that
Building and running it describes.
Samples map describes each sample’s README.md, which lists the options
of its launchers. The clash_api and legacy_clash_detection READMEs also list the options of
their programs. The Clash Processor introduces the Clash
Processor guide, samples/clash_suite_api/clash_processor.md, which lists those of the
clash_suite_api program.
Next steps#
Asynchronous Pipelines covers the asynchronous pipeline (
ovclash_run_pipeline_async()).include/ovclash/ovclash.hdocuments every lifetime rule, on the entry points themselves; see References in the package.C ABI conventions and threading_and_ownership.md give the rules for results, strings, ownership and threads.
samples.md describes
samples/clash_api/,samples/clash_suite_api/andsamples/legacy_clash_detection/, their launchers and READMEs.persistence.md covers storing results, and export.md the reports.
README.md covers the Python packages, and overview.md helps you pick an API surface.
SECURITY.md lists what to keep under your control when you deploy ovclash.