Samples#

ovclash ships three runnable samples, with launchers that set up the runtime and run example queries. The clash_suite_api sample also holds the Clash Processor, a command-line program that runs queries on your own stages without code.

This page ships as docs/consumer/samples.md in the SDK archive. Paths on this page are relative to the package root:

  • In the wheel, the package root is the installed ovclash package directory, <site-packages>/ovclash/. python -m pip show ovclash prints <site-packages> as Location.

  • In the SDK archive, the package root is the ovclash/ directory that the archive unpacks to.

Samples map#

Sample

Covers

Read next

samples/clash_api/

The clash C ABI of the canonical API and its ovclash Python binding: settings, scope, synchronous and asynchronous (--async) pipelines, overlap details, overlap reports with faces, outline and points, query statistics and --duplicates. It prints the results, and --json PATH writes a plain JSON summary.

python_quickstart.md

samples/clash_suite_api/

The Suite API end to end, mirroring the clash examples of Kit in five cases: a static query, a dynamic query, duplicate search, a point-vs-mesh query against point clouds and its dynamic form, with .ovclashdb (SQLite) and JSON directory stores and HTML and JSON export. Its program is the Clash Processor; see The Clash Processor.

suite_workflows.md

samples/legacy_clash_detection/

Reading and writing the legacy .clashDetection container through the Suite API. It creates an input file, opens it, and writes a copied .clashDetection and an .ovclashdb database.

legacy_container.md

Each sample has a Python program and a C++ program that do the same work. Each sample directory has a README.md that lists the options of its launchers. The clash_api and legacy_clash_detection READMEs also list their programs’ options and show the expected output; for clash_suite_api, the Clash Processor guide, samples/clash_suite_api/clash_processor.md, holds them.

What each package ships#

Files

Wheel

SDK archive

The Python programs: clash_api_python.py, clash_suite_api_python.py, legacy_clash_detection_python_api.py

yes

yes

The Python launchers, run_<sample>_python.sh or .bat

yes

yes

samples/clash_suite_api/run_custom_clash.sh or .bat, and the Clash Processor guide samples/clash_suite_api/clash_processor.md

yes

yes

Each sample’s README.md

yes

yes

samples/data/time_sampled.usda, the stage that the examples open

yes

yes

samples/ovclash_backend.txt, which names the packaged backend for the launchers

yes

yes

samples/sample_python.py, the launchers’ runtime helper

yes

yes

The C++ programs (ClashApi.cpp, ClashSuiteApi.cpp, LegacyClashDetection.cpp), their CMakeLists.txt files and the run_<sample>_cpp.sh or .bat launchers

no

yes

samples/build_samples.sh or .bat, which builds the C++ programs, and samples/sdk_runtime.py

no

yes

A package carries the launchers for its own platform only: .sh launchers on Linux and .bat launchers on Windows.

The wheel cannot build the C++ programs. With the SDK archive, Building the C++ samples describes samples/build_samples.sh and the run_<sample>_cpp launchers.

Running the Python samples#

A launcher finds its own location, so you can run it from any directory. From the package root, on Linux:

./samples/clash_api/run_clash_api_python.sh
./samples/clash_suite_api/run_clash_suite_api_python.sh
./samples/legacy_clash_detection/run_legacy_clash_detection_python.sh

On Windows:

samples\clash_api\run_clash_api_python.bat
samples\clash_suite_api\run_clash_suite_api_python.bat
samples\legacy_clash_detection\run_legacy_clash_detection_python.bat
  • The clash_api and clash_suite_api launchers run five example queries against samples/data/time_sampled.usda.

  • The legacy_clash_detection launcher creates input.clashDetection and writes copy.clashDetection and copy.ovclashdb.

  • A launcher runs the library of the package that holds it.

The launchers share these options:

Option

Launchers

Default

Effect

--stage USD

clash_api, clash_suite_api

samples/data/time_sampled.usda

The stage file of the example queries.

--install-root DIR

All

The package that holds the launcher

Runs against the SDK archive whose root is DIR.

--output-dir DIR

All

A directory inside the package root; see Output directories

Where the examples write their results.

--help

All

None

Prints the launcher’s options and exits.

Each sample’s README.md lists the remaining options of its launchers.

To run one command of your own instead of the examples, pass the program’s arguments after --. The launcher forwards them unchanged. From the package root, on Linux:

./samples/clash_api/run_clash_api_python.sh -- --stage samples/data/time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json

On Windows:

samples\clash_api\run_clash_api_python.bat -- --stage samples\data\time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json
  • The command replaces the whole example command line, so it must name the stage.

  • The first argument that the launcher does not know also starts the command. You need -- only when the command starts with a launcher option such as --stage.

  • Relative paths resolve against the current directory.

How the launchers select a runtime#

A packaged launcher imports the Python packages of the package that holds it, or of the SDK archive that --install-root names, even when another ovclash is installed. It reads the packaged backend from samples/ovclash_backend.txt.

The runtime helper, samples/sample_python.py, selects the interpreter:

  1. It starts from the interpreter that PYTHON names, else python3 on Linux or python on Windows. It ignores an inherited PYTHONPATH.

  2. Wheel. It checks the ovstage that the launch imports, from the wheel’s site directory first. A complete installation of the exact pin there, as pip installs the dependency, runs offline without any setup. When that directory holds no ovstage and the interpreter imports no complete installation of the pin from elsewhere on its path, the helper prepares a cached environment. An ovstage in the wheel’s site directory that is not a complete installation of the pin is an error that names the directory: the samples would import it first. The wheel’s launchers ignore OVCLASH_OVSTAGE_PACKAGE_DIR.

  3. SDK archive. When the interpreter lacks a complete installation of the SDK archive’s exact pin, the helper prepares a cached environment, keyed by the SDK archive location, the exact ovstage pin and the base interpreter. OVCLASH_OVSTAGE_PACKAGE_DIR names another installation by the absolute path of its ovstage package directory. The launchers then prepare no cached environment, so they also work offline. A selection that is not the pinned version is an error.

A cached environment holds only the exact ovstage pin, installed with pip. It leaves the base interpreter’s packages unchanged. It lives under:

Platform

Directory

Windows

%LOCALAPPDATA%/ovclash/samples/python

Linux

${XDG_CACHE_HOME:-~/.cache}/ovclash/samples/python

  • The first setup needs pip access to the pinned ovstage wheel and an interpreter that can create a virtual environment.

  • With pip 22.3 or newer in the base interpreter, setup uses that pip to install into the environment. Otherwise the environment must bootstrap pip itself; on Debian and Ubuntu that needs the python3-venv package.

  • pip runs in isolated mode, so a module in the launch directory is never imported. Your PIP_* variables and pip configuration still apply, for example a package mirror.

  • The first setup prints Preparing isolated ovstage==<pin> sample environment at <directory> on stderr. A later launch reuses the environment.

A failed setup prints Sample Python setup failed:; see Troubleshooting. A launcher copied out of its package runs the helper of the install root that --install-root or OVCLASH_INSTALL_ROOT selects, else the one in its own samples directory. When neither holds sample_python.py, it stops with Sample Python setup helper not found at; see Troubleshooting.

Output directories#

The launchers write their results to an output directory. By default it is created inside the package root, with one directory per sample and backend. Pass --output-dir DIR to write elsewhere, for example when the package root is read-only, as a system-wide Python installation often is. From the package root, on Linux:

./samples/clash_suite_api/run_clash_suite_api_python.sh --output-dir "$HOME/clash_results"

On Windows, in Command Prompt:

samples\clash_suite_api\run_clash_suite_api_python.bat --output-dir "%USERPROFILE%\clash_results"

Launcher

Writes

Default for --output-dir

run_clash_api_python

static.json, dynamic.json, duplicates.json, point_cloud.json and dynamic_point_cloud.json

OVCLASH_CLASH_API_OUTPUT_DIR

run_clash_suite_api_python

<case>.json, <case>.html and <case>.ovclashdb for the five cases static, dynamic, duplicates, point_cloud and dynamic_point_cloud

OVCLASH_CLASH_SUITE_API_OUTPUT_DIR

run_legacy_clash_detection_python

input.clashDetection, copy.clashDetection and copy.ovclashdb

OVCLASH_LEGACY_CLASH_DETECTION_OUTPUT_DIR, read by the .sh launcher only

A custom command after -- writes only the outputs that its own arguments name, such as --json PATH.

The Clash Processor#

The clash_suite_api Python program, clash_suite_api_python.py, is a clash processor: each run executes one query through the Suite API, saves the results and exports reports. Its command line supplies the stage, the search sets of the scope, the query kind and times, the tolerance and the output paths. samples/clash_suite_api/run_custom_clash.sh (run_custom_clash.bat on Windows) sets up a runtime and runs it with your arguments, without --. From the package root, on Linux:

./samples/clash_suite_api/run_custom_clash.sh --stage samples/data/time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json --html static.html

On Windows:

samples\clash_suite_api\run_custom_clash.bat --stage samples\data\time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json --html static.html

The launcher owns four options:

Launcher option

Default

Effect

--backend NAME

The backend of the SDK archive that holds the launcher, else ovstage

The backend to run. The released packages hold only ovstage.

--install-root DIR

The SDK archive that holds the launcher, else none

Runs against the SDK archive whose root is DIR.

--wheel

Off

Skips the SDK archive that holds the launcher and uses the published wheel, unless --install-root is given too.

--config C

Release

Release or Debug, for developer builds. The published-wheel route ignores it.

  • The launcher forwards every other argument to the processor unchanged. With no processor argument, or with --help, it prints its own options and the processor’s, then exits with status 1.

  • Inside an SDK archive, it runs against that SDK archive. --install-root DIR, or OVCLASH_INSTALL_ROOT, selects another one.

  • Elsewhere, including the copy in an installed wheel, it creates a virtual environment, .venv-ovclash beside the script, with the interpreter that PYTHON names, else python3 (python on Windows). It installs the ovclash wheel and its pinned ovstage there from the package index that OVCLASH_INDEX_URL names, else from the index that pip’s configuration selects, and fails when that index does not host ovclash. --install-root DIR selects an SDK archive instead. --wheel selects this route inside an SDK archive too.

  • When that setup fails, the launcher exits with status 1. A failed install prints Could not install <spec> into "<dir>", where <spec> is ovclash, or ovclash==<version> when OVCLASH_VERSION names a version, and <dir> is the virtual environment. Without OVCLASH_INDEX_URL, it adds OVCLASH_INDEX_URL is not set, so pip used its configured index, which may not host ovclash. Set OVCLASH_INDEX_URL to an index that hosts ovclash, give pip a mirror that does, or pass --install-root DIR to use an SDK archive. A failed Could not create the venv "<dir>" with "<python>" needs an interpreter that can create virtual environments: set PYTHON to one, or on Debian and Ubuntu install python3-venv.

  • OVCLASH_VERSION pins the ovclash version of the first install; the default is the latest. A working environment is reused and not repinned, so delete .venv-ovclash to change the version.

  • On Windows, quote a value that contains spaces, ,, ;, = or one of & | < > ^, because cmd splits or interprets it first: --object-a "/Root/A,/Root/B".

  • On Linux, quote a value that contains spaces or one of ; & | < >, because the shell splits or interprets it first. , and = need no quoting there: --object-a /Root/A,/Root/B.

The Clash Processor guide, samples/clash_suite_api/clash_processor.md, is the complete reference: every processor option, the output stores, the exit statuses and recipes for common queries. skills/ovclash-clash-processor/SKILL.md, in the package directory, keeps the shortest command-line patterns.

Environment variables#

Each launcher variable presets an option or a default, and an option on the command line wins. Environment variables lists every variable that a consumer can set. Its table Sample launchers and build_samples covers the launchers, run_custom_clash and build_samples; OVCLASH_OVSTAGE_PACKAGE_DIR, which the SDK archive’s launchers also read, is in its Loading the library table.