Python API Reference#
ovclash ships two peer Python packages:
ovclashis a thin ctypes binding over the canonical clash C ABI (ovclash.h), the engine layer’s C application binary interface.ovclash_suiteis the product API over the Suite C ABI: an object model, persistence and JSON/HTML export.
The wheel, the Python package file that pip installs, carries both packages,
and so does the python/ directory of the SDK archive, the C/C++ and Python
release package. A name that exists in both
packages, such as RunSettings or backend_info, is a different object in
each. The Glossary section of Concepts defines the
terms this page uses.
Choosing an API explains how to pick, and
C API Reference documents the C contracts that both build on. The
Python Quickstart runs a first query.
Both packages share one native library, which the first import loads. The Native library lookup section of ovclash Python Package gives the lookup order, the loader variables and the errors the import raises.
The wheel and the SDK archive also ship omni.physxclashdetectioncore, which
exposes ovclash_suite names under their import paths in Kit (NVIDIA
Omniverse Kit, the application framework of the Kit clash detection
extension). This page documents the ovclash_suite originals.
Kit Compatibility lists what the
compatibility package exports.
The canonical binding: ovclash#
Core classes#
Async Pipelines covers AsyncPipeline.
Threading and Ownership covers the
lifetimes of OverlapReport and BufferView data.
ovstage Integration covers borrowing a
caller-owned Stage of ovstage, the runtime through which ovclash reads USD
(Universal Scene Description) scenes, with ClashRuntime.attach_ovstage().
A BufferView borrows native memory that dies with its report. Copy what you
keep before the report closes. This complete script opens time_sampled.usda,
which the wheel ships in <site-packages>/ovclash/samples/data/ and the SDK
archive in <sdk>/samples/data/, where <site-packages> is the
interpreter’s package directory and <sdk> the extracted archive. Run it from
that directory, or pass the stage’s full path to open_stage:
from ovclash import ClashRuntime, OverlapReportFlag
with ClashRuntime() as runtime:
runtime.open_stage("time_sampled.usda")
runtime.set_scope(["/Root/Xform_Primitives/Cube"], ["/Root/Xform_Primitives/Plane"])
runtime.run_pipeline()
flags = OverlapReportFlag.FACES0 | OverlapReportFlag.OUTLINE
with runtime.get_overlap_report(0, flags=flags) as report:
faces = report.faces0.numpy().copy() # copy: the view dies with the report
segments = report.outline.tolist() # tolist() always copies
print(len(faces), "faces,", len(segments), "outline segments")
4 faces, 10 outline segments
- class ovclash.ClashRuntime#
Bases:
objectStandalone clash runtime that owns one native context of the canonical clash C ABI.
The lifecycle follows the engine contract.
open_stage()opens the stage.set_run_settings()applies the engine settings, including the requested full-scene flag, and clears the native scope. The explicit A/B scope recorded byset_scope()is applied just before the pipeline is created, so it survives that reset.Call
destroy()when done; that is the primary lifetime contract. As a context manager, a normal exit waits for an active async run, and an exit by exception cancels the run first; both then release the context. A finalizer that runs inside an ovstage owner callback defers the native cleanup and keeps the attachments alive until then.A failed native call raises
RuntimeErrorwith the context’s last error. While anAsyncPipelinefromrun_async()is active, the methods that change the settings, scope or stage, run the pipeline or read results raiseRuntimeErroruntil the run is finished or cancelled. Serialize calls on one runtime; only theAsyncPipelinemethods may be called from other threads. Native calls from inside an ovstage owner operation are rejected withRuntimeError.- Raises:
RuntimeError – The native context cannot be created.
- attach_ovstage(
- stage: Any,
- committed_ordinal: int,
- **metadata: Any,
Borrow the owner’s live ovstage Stage instead of opening a file.
The metadata fields follow
ovclash_ovstage_binding_tinovclash/ovclash_ovstage.h.evaluate_time(seconds)receives NaN for the Default time and returns a newer committed ordinal. While clash operations run, the owner must exclude concurrent rendering, edits and destruction of the Stage. Withoutcomposition_root, no source filename is opened.authored_transform_updates=Truerequires the C binding’s full raw-op/default-order population and same-time update provenance contract, plus an evaluator that seals a newer ordinal at identical seconds. Without that explicit capability, attached meshes stay non-static.composition_rootandcomposition_layersfill the binding’sovclash_ovstage_composition_tand make the attachment engine-evaluated. Default selection reads the Stage atcommitted_ordinal, which must stay retained until detach. Every finite time is evaluated natively in private ovstage instances that replay the root andcomposition_layers, the texts of the owner’s surviving root merges in the order it added them; the Stage is never evaluated or advanced. The owner guarantees that the composition reproduces its transforms at every finite time, and keeps the root file and every file that the root or a layer references unchanged on disk while attached, because each replay reopens the root by its string. A relative root resolves against the working directory at replay time, so open the Stage from an absolute path or URL and pass that string. It requires a NaNtime_secondsand noevaluate_timeorauthored_transform_updates.A successful attachment replaces any previous one, drops the scope recorded by
set_scope()and invalidates the pipeline. Likeopen_stage(), it does not restore full-scene traversal. This runtime keeps the Stage and the callback alive untildetach_ovstage(),reset(), another attachment, anopen_stage()call with a nonempty path, ordestroy(). A failed attachment keeps the previous one.- Parameters:
stage – Live
ovstage.Stageto borrow.committed_ordinal – Positive uint64 ordinal of the Stage’s current committed evaluation.
**metadata – Binding fields and their defaults:
time_seconds(NaN, the Default time),meters_per_unit(0.01),start_time_codeandend_time_code(0.0),time_codes_per_secondandframes_per_second(24.0),evaluate_time(None),authored_transform_updates(False),composition_root(None, the exact path, URL or USDA text the owner opened),composition_layers(an empty sequence of USDA texts, earliest first) andcomposition_root_is_usda(False).
- Raises:
TypeError –
stageis not a liveovstage.Stage, an argument has the wrong type, or a metadata keyword is unknown.ValueError –
committed_ordinalis not a positive uint64,authored_transform_updatesis set withoutevaluate_time, composition layers orcomposition_root_is_usdaare passed without a root, the root or a layer is empty, contains NUL or is not encodable as UTF-8, or a root is combined withevaluate_time,authored_transform_updatesor atime_secondsother than NaN.RuntimeError – The backend is OpenUSD, an async run is active, or the native attachment fails.
- close() None#
Destroy the native context owned by this runtime.
Calling it again does nothing.
destroyis the primary name, matching the main object ofovclash_suite;closeis an alias kept for existing callers. An active async run is finished first, and active reports are closed.The handle is retired when the native release succeeds or when its result is lost to an interruption. An explicit native rejection keeps the handle, so the call can be retried. A failure while closing a dependent pipeline or report also keeps the context, because its native release was not attempted yet.
- Raises:
RuntimeError – The native release or the close of a dependent report fails, or the call is made inside an ovstage owner operation.
- create_pipeline() list[PipelineStepData]#
Apply the recorded scope, build the pipeline and return its planned steps.
Active reports are closed.
- Returns:
One
PipelineStepDataper step, at least seven, asget_pipeline_step_data()reports them.- Raises:
RuntimeError – An async run is active, a scope path is invalid, or the native call fails.
- destroy() None#
Destroy the native context owned by this runtime.
Calling it again does nothing.
destroyis the primary name, matching the main object ofovclash_suite;closeis an alias kept for existing callers. An active async run is finished first, and active reports are closed.The handle is retired when the native release succeeds or when its result is lost to an interruption. An explicit native rejection keeps the handle, so the call can be retried. A failure while closing a dependent pipeline or report also keeps the context, because its native release was not attempted yet.
- Raises:
RuntimeError – The native release or the close of a dependent report fails, or the call is made inside an ovstage owner operation.
- detach_ovstage() None#
Stop borrowing the attached Stage without destroying it.
Active reports are closed, and the results and the pipeline are invalidated. The call also forgets a stage opened with
open_stage(), and it succeeds without an attachment.- Raises:
RuntimeError – The backend is OpenUSD, an async run is active, or the native detach fails.
- get_duplicate(
- index: int,
Return the names, hashes, triangle count and time of one duplicate mesh pair.
The names are copied, so the record outlives the results.
- Parameters:
index – Index of the duplicate pair.
- Returns:
The copied pair.
- Raises:
OverflowError –
indexis outside the uint32 range.RuntimeError –
indexis out of range or stale, or an async run is active.
- get_duplicate_count() int#
Return the number of duplicate mesh pairs found by the last run.
A time-sampled run finds no duplicates and reports 0.
- Returns:
The number of duplicate pairs.
- Raises:
RuntimeError – An async run is active, or the native query fails.
- get_overlap_count() int#
Return the number of overlap groups of the last run, one per colliding prim pair.
A cancelled run can report 0, so check
AsyncPipeline.is_cancelled()before reading 0 as clash-free.- Returns:
The number of overlap groups.
- Raises:
RuntimeError – An async run is active, or the native query fails.
- get_overlap_details(
- overlap_index: int,
- record_index: int = 0,
Return
get_overlap_record()data plus the hashes, minimum distance and depth.Each hash is the pair of uint64 words of a 128-bit hash, in native array order;
clash_hashhashes the two prim paths.min_distanceandmax_local_depthare in stage units.max_local_depthis -1.0 when depth was not computed (max_local_depth_modeisDISABLED) and 0.0 for a point-vs-mesh overlap.- Parameters:
overlap_index – Index of the overlap group.
record_index – Sampled frame within the group; always 0 for a static query.
- Returns:
The copied record details.
- Raises:
OverflowError – An index is outside the uint32 range.
RuntimeError – An index is out of range or stale, or an async run is active.
- get_overlap_record(
- overlap_index: int,
- record_index: int = 0,
Return the names, counts, type and time of one overlap record.
The names are copied, so the record outlives the results.
timeis in seconds.- Parameters:
overlap_index – Index of the overlap group.
record_index – Sampled frame within the group; always 0 for a static query.
- Returns:
The copied record.
- Raises:
OverflowError – An index is outside the uint32 range.
RuntimeError – An index is out of range or stale, or an async run is active.
- get_overlap_report(
- overlap_index: int,
- *,
- record_index: int = 0,
- flags: ~ovclash.python.api.types.OverlapReportFlag = <OverlapReportFlag.OUTLINE|FACES0|FACES1|POINTS0: 30>,
Build the detailed geometry report of one overlap frame.
The default flags request every content buffer that this entry point can fill:
FACES0,FACES1,OUTLINEandPOINTS0. Explicitflagsnarrow the work.OverlapReportFlag.DEFAULT(0) andFACESselect nothing here, so flags without a content bit raiseValueError; an empty report would read as “this clash touches no geometry”. Close the returned report, or use it as a context manager.- Parameters:
overlap_index – Index of the overlap group.
record_index – Sampled frame within the group; always 0 for a static query.
flags –
OverlapReportFlagbits that select the buffers to fill.
- Returns:
The open report.
- Raises:
ValueError –
flagshas no content bit.OverflowError – An index is outside the uint32 range.
RuntimeError – An async run is active, or the native report fails.
- get_ovstage_matrix_decomposition() str#
Return the matrix decomposition selected for this ovstage context.
- Returns:
"openusd"or"ovclash".- Raises:
RuntimeError – The backend is OpenUSD, or the native call fails or reports an unknown mode.
- get_pipeline_step_data(
- step_index: int,
Return the planned description of one pipeline step, not live progress.
progressisstep_index / nb_steps,step_progressis 0.0 andfinishedis True only for the last step.- Parameters:
step_index – Index of the step in the created pipeline.
- Returns:
The planned step.
- Raises:
OverflowError –
step_indexis outside the uint32 range.RuntimeError –
step_indexis outside the created pipeline, or an async run is active.
- get_query_stats() QueryStats#
Return the mesh, shared-mesh, cooked-mesh and point-cloud counts of the last run.
On ovstage,
nb_cooked_meshesbelownb_meshes - nb_shared_meshesmeans that meshes that could not be cooked were dropped from the results; seeovclash_stats_t.- Returns:
The counts.
- Raises:
RuntimeError – An async run is active, or the native query fails.
- get_run_settings() RunSettings#
Read back the settings currently applied to the native context.
This is the inverse of
set_run_settings(). A new runtime reports the engine defaults, which differ fromRunSettings().The native context has no
set_timesflag, soset_timesreads back True only when a native time is non-zero. Afterset_run_settings()withset_times=False, and on a new runtime, all three times are 0.0. The readback then hasset_times=Falseandtime_codes_per_second=0.0. Enabling a dynamic range from that readback keeps the 0.0 rate, so the run takes one sample atstart_time; passtime_codes_per_secondtoo.- Returns:
The applied settings, limited to the fields that
RunSettingsmodels.- Raises:
RuntimeError – The native call fails.
- get_stage_timeline_data() StageTimelineData#
Read the root-layer timeline metadata of the open stage.
A Stage attached with
attach_ovstage()reports the timeline fields of its attachment instead.- Returns:
The timeline metadata, as USD resolves it for an opened file.
- Raises:
RuntimeError – No stage is open or attached, an async run is active, or the native query fails.
- last_error() str#
Return a copy of the context’s last error message.
Successful calls do not always clear the message, so read it only after a call failed.
- Returns:
The message, or an empty string when there is none or the context is destroyed.
- open_stage(stage_path: str) None#
Open a USD stage file.
A nonempty path detaches a borrowed ovstage Stage first, so the Stage stays detached even when the open fails. An empty path or a path that cannot be encoded keeps the borrowed Stage. A missing file or a USD or ovstage open error also drops the stage that was open before.
A successful open drops the scope recorded by
set_scope(), because both backends clear the native scope there. A failed open keeps the recorded scope, as the Suite runtime does.Opening does not restore full-scene traversal. Once
create_pipelinehas applied a non-empty scope,enable_full_scenestays cleared untilset_run_settingsenables it again. Until then, the next run on the new stage selects nothing and reports zero overlaps with a success status. Record a new scope withset_scope(), or callruntime.set_run_settings(runtime.get_run_settings(), enable_full_scene=True)to traverse the whole stage again. Passingget_run_settings()as the base keeps the otherRunSettingsfields; a call without a base starts from theRunSettings()defaults.- Parameters:
stage_path – Local path of the stage file; asset URIs are rejected.
- Raises:
RuntimeError – The open fails, or an async run is active.
UnicodeEncodeError –
stage_pathcannot be encoded as UTF-8.
- reset() None#
Drop all results; keep the settings, the opened stage file and the recorded scope.
Like
ovclash_reset_context, which keeps the native scope, this keeps the scope recorded byset_scope(), socreate_pipelineapplies it again after a laterset_run_settings. A borrowed ovstage Stage is detached, and active reports are closed.- Raises:
RuntimeError – An async run is active, or the native reset fails.
- run_async() AsyncPipeline#
Start the pipeline on a background worker.
Creates the pipeline first when none is cached, and closes active reports. The Python owner of the run exists before the native launch. When the launch or its result handling raises, the worker is drained, if possible, before the exception propagates; that cleanup can block until the worker finishes. Only one async run exists per runtime.
- Returns:
The run handle. Finish, cancel or close it before most other methods of this runtime work again.
- Raises:
RuntimeError – An async run is already active, or the pipeline cannot be created or started.
- run_pipeline() list[PipelineStepData]#
Create the pipeline and run every step on the calling thread.
- Returns:
The planned steps, as
create_pipeline()returns them.- Raises:
RuntimeError – Creating the pipeline or running a step fails.
- run_pipeline_step(step_index: int) None#
Run one pipeline step synchronously.
Active reports are closed first. Run the steps in ascending order from 0; out-of-order execution is not diagnosed.
- Parameters:
step_index – Index of the step to run.
- Raises:
OverflowError –
step_indexis outside the uint32 range.RuntimeError – The native step is rejected or, on ovstage, fails, or an async run is active.
- set_ovstage_dynamic_matrix_cache(enabled: bool) None#
Enable or disable the sampled transform cache of ovstage.
Authored-transform classification defers matrix reads to bounded playback windows, at most 32 copied frames across the current and prefetched windows. Eligible parallel playback can prepare the next window in the background; both windows share the cache byte budget. Disabling the cache also disables prefetch and reads one frame at a time. Unresolved authored values keep sampled pose validation but are conservatively treated as non-static, because sampled pose comparisons cannot prove them static. This control does not change the reported sample times or poses.
The cache is on for a new context. Calling this closes active reports and invalidates the pipeline.
- Parameters:
enabled – True to enable the cache.
- Raises:
RuntimeError – The backend is OpenUSD and does not export the setter, an async run is active, or the native call fails.
- set_ovstage_matrix_decomposition(
- implementation: str,
Select the matrix decomposition,
"openusd"(the default) or"ovclash".This ovstage-only setting belongs to the context and survives reset and stage replacement. A change clears results, closes active reports and invalidates the pipeline; the next
run_pipeline()orrun_async()creates it again. Selecting the current mode again keeps the reports and the pipeline. Immediate mesh queries also use this setting. The"ovclash"math can change zero-tolerance clash membership. A call fails while an async handle is active, even after its worker stops and when the current mode is selected again.Both modes reject non-finite matrix values, values or linear row magnitudes outside the float range, and invalid resulting poses or scales. That includes finite rotation quaternions that are not unit length: the affected query fails instead of normalizing the rotation.
- Parameters:
implementation –
"openusd"or"ovclash".- Raises:
ValueError –
implementationnames another mode.RuntimeError – The backend is OpenUSD, an async run is active, or the native call fails.
- set_run_settings(
- settings: RunSettings | None = None,
- **kwargs: Any,
Apply
settingswith the fields given inkwargsreplaced.Canonical settings that
RunSettingsdoes not model are reset to theovclash_reset_settings()defaults instead of being kept from the context. The time fields are applied only whenset_timesis True; otherwise all three native times are 0.0, which selects a static query.Applying settings clears the native scope;
create_pipeline()applies the scope recorded byset_scope()again. It also closes active reports and invalidates the pipeline, but keeps completed results. A rejected call leaves the previous settings in place.- Parameters:
settings – Base settings. None starts from
RunSettings().**kwargs –
RunSettingsfields that replace the values ofsettings.
- Returns:
The effective settings.
- Raises:
TypeError – A keyword is not a
RunSettingsfield.ValueError – A value is out of range or not finite.
RuntimeError – An async run is active, or the native call fails.
- set_scope(
- prim_paths1: Iterable[str],
- prim_paths2: Iterable[str] = (),
Record the explicit A/B scope.
The scope is applied to the engine just before
create_pipelinebuilds the pipeline, becauseset_run_settingsapplies the requested full-scene flag and clears any native scope applied earlier. Settings and this recorded scope may therefore be set in either order. A successfulopen_stageorattach_ovstagedrops the recorded scope, because both backends clear their native scope there;resetkeeps it, likeovclash_reset_context. Invalid paths raiseRuntimeErrorfromcreate_pipeline, not here.Two empty sequences clear the scope, as in
ovclash_set_scope_paths. Clearing the scope does not return to full-scene traversal, because applying a non-empty scope clearsOVCLASH_SETTINGS_FLAG_FULL_SCENE. To traverse the whole stage again, call bothset_scope([], [])andset_run_settings(enable_full_scene=True), in either order, before the pipeline is built again. Passget_run_settings()as theset_run_settingsbase to keep the otherRunSettingsfields.- Parameters:
prim_paths1 – Absolute USD prim paths of search set A. An entry also covers the descendants of its prim.
prim_paths2 – Absolute USD prim paths of search set B, with the same rule.
- Raises:
RuntimeError – An async run is active.
- class ovclash.AsyncPipeline(
- runtime: ClashRuntime,
- handle: c_void_p,
Bases:
objectHandle to a clash pipeline running in the background.
ClashRuntime.run_async()creates it. The methods may be called from several threads. A call that overlaps afinish()running on another thread never uses the async cookie that the finish is freeing.is_running(),is_cancelled()andstep_data()then answer from the state latched here, andfinish(),cancel()andclose()wait for that finish to return. Socancel()cannot interrupt afinish()that is already waiting on another thread. To cancel from a UI, poll and cancel on one thread, and callfinish()on that thread once the loop ends.As a context manager, it waits for the run on normal exit, and cancels and drains it when the block raises. Neither exit raises for a failed or cancelled run; call
finish()to have a failed run raise.- Parameters:
runtime – Runtime that started the run.
handle – Async cookie that
ovclash_run_pipeline_asyncfills.
- cancel() None#
Request cancellation of a running pipeline and finish it.
The canonical C ABI frees the async cookie only in finish, so this requests the stop and then finishes the run. It blocks until the worker exits, which releases the runtime guard. Finishing also clears the native cancel flag, so the request is latched here and
is_cancelled()keeps reporting it. The cancelled outcome does not raise. Once the pipeline is finished, this does nothing.A
finish()already waiting on another thread cannot be interrupted, because the cookie that a cancel request needs may be freed at any moment. This then requests nothing and only waits for that finish, which keeps its own outcome.- Raises:
RuntimeError – The native cancel request fails, or the call is made inside an ovstage owner operation.
- close() None#
Finish the run if it was never finished, without raising for its outcome.
Blocks until the worker exits, or until a finish running on another thread returns. An
Exceptionraised while finishing is suppressed, and the handle is retired either way.- Raises:
RuntimeError – The call is made inside an ovstage owner operation.
- finish() None#
Block until the run completes, then release the async handle.
The results are readable through the runtime afterwards.
ovclash_finish_pipelinedeletes the async cookie, so this object never uses it again. A later call waits for a finish in progress on another thread, and otherwise returns at once without raising.cancel()finishes the run itself, so a laterfinish()does not raise.Once the native finish is attempted, the handle is retired even when an interruption or the Python result processing raises. Such an exception does not mean that the run succeeded, and later calls, which do nothing, do not change that outcome. Destroy the runtime when the outcome of an interrupted cleanup is uncertain.
- Raises:
RuntimeError – The run failed, or cancellation was requested before the finish, for example by the broadphase limit. The message holds the context’s last error. Also raised when the call is made inside an ovstage owner operation.
- is_cancelled() bool#
Return whether cancellation was requested for this run.
Once True, this stays True, also after the pipeline is finished. A caller can therefore make the cross-check that
ovclash.hprescribes before trusting a zero overlap count.The native flag cannot answer alone:
ovclash_finish_pipelinefrees the async cookie and clears the flag, andcancel()must finish the run to release the runtime guard. So the native flag is read only while the cookie is live. Once the cookie is gone, or while another thread’sfinish()frees it, this answers from the latch.- Returns:
True when cancellation was requested.
- Raises:
RuntimeError – The native query fails.
- is_running() bool#
Return whether the run is still going.
A cancelled, finished or closed pipeline is not running, so this returns False instead of calling through the released cookie, and
poll()keeps working after teardown. The native poll also reports False as soon as cancellation is requested, before the worker stops; onlyfinish()waits for the worker.While another thread’s
finish()waits for the run, the results are not readable yet. This then returns True unless cancellation was requested, as the native poll would.- Returns:
True while the run is going.
- Raises:
RuntimeError – The native query fails.
- poll() tuple[bool, PipelineStepData]#
Return
(is_running(), step_data()).step_data().finishedmarks the last step index, not a completed run. Drive a poll loop by the running flag, then callfinish().- Returns:
The running flag and the current or last observed step.
- Raises:
RuntimeError – Either query fails.
- step_data() PipelineStepData#
Return the current step of the run, or the last one observed once the run is over.
After
cancel(),finish()orclose(), the async cookie that every native getter needs is gone, so this answers from a latch. A caller draining a poll loop then gets the final step instead of an error on its last iteration.A successful read fills the latch, and a successful finish settles it. A completed run reports
finished=Trueat full progress, so the lastpoll()of a drained loop does not report “not running, not finished”. Settling rewrites the cached record locally. Teardown never reads through the handle to refresh it: teardown also runs on pipelines whose handle is already unusable, and such a read crashes the process instead of raising a clean error.A cancelled run is not settled. It did not finish, so the latch keeps the last step actually observed; check
is_cancelled(). While another thread’sfinish()waits for the run, this also answers from the latch.- Returns:
The current or last observed step.
- Raises:
RuntimeError – The native query fails, or the cookie is gone or being finished and no step was ever read.
- class ovclash.OverlapReport(
- runtime: ClashRuntime,
- overlap_index: int,
- record_index: int,
- flags: int,
Bases:
objectDetailed geometry of one overlap record: colliding faces, outline segments and points.
ClashRuntime.get_overlap_report()creates reports throughovclash_create_overlap_report_ex, which also returns the world transforms of both prims for that record. A report has these attributes:faces0andfaces1:BufferViewofuint32USD face indices of mesh 0 and mesh 1 (flagsFACES0andFACES1).outline:BufferViewoffloat32with shape(n, 6). Each row is one segmentx0, y0, z0, x1, y1, z1(flagOUTLINE).points0:BufferViewofuint32USD point indices of point cloud 0 (flagPOINTS0).point_size0: point width (diameter) in stage units, without the prim’s transform scaling. It is0.0when the cloud authors per-point widths, except that ovstage reports a uniform per-point array as its single value.matrix0andmatrix1: tuples of 16 floats, the row-major 4x4 world transforms of the two prims.
A buffer whose flag was not requested is empty. The buffer views borrow library-owned memory. The runtime closes its active reports before any call that changes its stage, settings, scope or pipeline, and on reset and destroy. The views of a closed report raise
RuntimeError, but arrays already exported from them dangle. Consume or copy the buffers before those calls.- Parameters:
runtime – Runtime whose results the report reads.
overlap_index – Index of the overlap group.
record_index – Sampled frame within the group.
flags –
OverlapReportFlagbits that select the buffers to fill.
- Raises:
OverflowError – An index is outside the uint32 range.
RuntimeError – The native report fails.
- close() None#
Release the native report and invalidate its buffer views.
Calling it again does nothing. The views are invalidated even when the release raises. A failed release is not retried, because the native call may already have freed the buffers; when the failure happened before the call reached native code, OpenUSD report memory can stay allocated. Copy exported arrays before closing.
- Raises:
RuntimeError – The native release fails, or the call is made inside an ovstage owner operation.
- class ovclash.BufferView(
- owner: Any,
- pointer: Any,
- count: int,
- ctype: Any,
- warp_dtype_name: str,
- *,
- components: int = 1,
Bases:
objectBuffer view with an explicit lifetime, backed by an ovclash overlap report.
The view borrows library-owned memory that is valid only until the owning
OverlapReportis released. Consume or copy the data before the report is closed. After the report closes, every accessor raisesRuntimeError. Arrays already exported throughnumpy(),warp()or DLPack are not tracked and dangle.- Parameters:
owner – Report that owns the memory. The view stops working once the report is closed.
pointer – ctypes pointer to the first element, or None or a null pointer for an empty buffer.
count – Number of elements.
ctype – ctypes type of one component, such as
ctypes.c_uint32.warp_dtype_name – Name of the Warp dtype of one component,
"uint32"or"float32".components – Number of components per element, for example 6 for outline segments.
- __bool__() bool#
Return True when the buffer has a non-null address and at least one element.
- Raises:
RuntimeError – The owning report is closed.
- __dlpack__(
- *,
- stream=None,
- max_version=None,
- dl_device=None,
- copy=None,
Export the buffer as a DLPack capsule without copying.
This implements the array-interchange protocol, so
torch.from_dlpack(view),np.from_dlpack(view)and similar calls consume report buffers directly. The capsule aliases library-owned memory that stays valid only while the owning report is open, likenumpy()andwarp(). Consume it, or copy out of it, before the report is released.max_version,dl_deviceandcopyare passed on to NumPy when they are not None. NumPy older than 2.1 does not accept them, and they are then dropped.- Parameters:
stream – Accepted and ignored. The data is host memory, so there is no stream to synchronize with.
max_version – Highest DLPack version that the consumer supports.
dl_device – Device that the consumer requests.
copy – Copy request of the consumer.
- Returns:
The DLPack capsule.
- Raises:
RuntimeError – NumPy is not installed, or the owning report is closed.
- __dlpack_device__() tuple[int, int]#
Return the DLPack device of the buffer, which is always host memory.
- Returns:
(1, 0), where 1 iskDLCPUin the DLPack device enum.- Raises:
RuntimeError – The owning report is closed.
- __len__() int#
Return the number of elements.
- Raises:
RuntimeError – The owning report is closed.
- property address: int#
Address of the first element, or 0 when the pointer is null.
- property components: int#
Number of components per element.
- property count: int#
Number of elements; a multi-component element counts once.
- numpy() Any#
Return a zero-copy NumPy array, valid only while the owning report is open.
Copy the array before closing the report or advancing its runtime’s pipeline, which closes active reports before it changes native results.
- Returns:
The array, with the shape of the buffer. An empty buffer gives a new empty array.
- Raises:
RuntimeError – NumPy is not installed, or the owning report is closed.
- property shape: tuple[int, ...]#
Shape of the data,
(count,)or(count, components).
- tolist() list[Any]#
Copy the buffer into a list.
- Returns:
The values, or one list of components per element for a multi-component buffer. An empty buffer gives an empty list.
- Raises:
RuntimeError – The owning report is closed.
- warp() Any#
Return a zero-copy CPU
warp.array, valid only while the owning report is open.The array references the report, but closing the report, directly or through its runtime, still invalidates the array.
- Returns:
The Warp array, with the shape of the buffer.
- Raises:
RuntimeError – Warp is not installed, or the owning report is closed.
Module functions#
- ovclash.version() tuple[int, int, int]#
Return the version of the loaded native library.
This is the runtime version, which decides ABI compatibility. When you also build against the C headers, compare it with the compile-time constants in
<ovclash/version.h>.- Returns:
The
(major, minor, patch)version numbers.- Raises:
RuntimeError – The native version query fails.
- ovclash.version_string() str#
Return the version string of the loaded native library,
"<major>.<minor>.<patch>".- Returns:
The version string, or an empty string when the library reports none.
- ovclash.backend_info() ovclash.python.api.types.BackendInfo#
Return capability and load-path information about the active clash backend.
- Returns:
The backend information.
native_library_pathis the name or path the shared library was loaded from.- Raises:
RuntimeError – The native query fails.
Types and enums#
ovclash exports every type of this section except StageTimelineData.
Import that one from ovclash.types, an alias of ovclash.python.api.types,
which is the module documented here.
These dataclasses mirror a C struct of the C API Reference, with snake_case field names:
Python type |
C struct |
|---|---|
|
|
|
|
|
|
|
|
|
|
The class docstrings that this section renders describe every field, including
the Python conversions such as the hash tuples and the bool flags.
BackendInfo.native_library_path has no C counterpart.
Public data types of the canonical clash binding (ovclash).
The types mirror the curated surface of the ovclash Suite, but ClashRuntime fills them from the
canonical clash C ABI (ovclash.h) instead of the Suite ABI. ovclash.types is an alias of
this module.
- class ovclash.python.api.types.BackendInfo(
- backend_name: str,
- native_openusd_linked: bool,
- ovpopulation_runtime_loaded: bool,
- ovstage_cuda_enabled: bool,
- native_library_path: str,
Bases:
objectCapability and load-path information about the active clash backend.
The fields mirror
ovclash_backend_info_t, with theuint32flags converted tobool. Every flag is a compile-time constant of the loaded library.- Parameters:
backend_name –
"openusd"or"ovstage", or"unknown"when the library reports no name.native_openusd_linked – True for the OpenUSD backend.
ovpopulation_runtime_loaded – True for the ovstage backend.
ovstage_cuda_enabled – True when the ovstage backend was built with CUDA.
native_library_path – Name or path the shared library was loaded from. It has no C counterpart.
- backend_name: str#
- native_library_path: str#
- native_openusd_linked: bool#
- ovpopulation_runtime_loaded: bool#
- ovstage_cuda_enabled: bool#
- class ovclash.python.api.types.DuplicateMesh(
- name0: str | None,
- name1: str | None,
- clash_hash: tuple[int, int],
- mesh_hash0: tuple[int, int],
- mesh_hash1: tuple[int, int],
- nb_tris: int,
- time: float,
Bases:
objectOne duplicate mesh pair, from
ovclash_duplicate_mesh_data_t.Each hash is the pair of uint64 words of a 128-bit hash, in native array order.
- Parameters:
name0 – Path of the first mesh, or None when it is empty.
name1 – Path of the second mesh, or None when it is empty.
clash_hash – Hash of the two mesh paths.
mesh_hash0 – Hash of the mesh data of the first mesh.
mesh_hash1 – Hash of the mesh data of the second mesh.
nb_tris – Number of triangles in the duplicated mesh.
time – Time of the pair on the timeline.
- clash_hash: tuple[int, int]#
- mesh_hash0: tuple[int, int]#
- mesh_hash1: tuple[int, int]#
- name0: str | None#
- name1: str | None#
- nb_tris: int#
- time: float#
- class ovclash.python.api.types.MaxLocalDepthMode(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
IntEnumMax-local-depth computation mode, matching
ovclash_max_local_depth_mode_t.DISABLEDskips the computation.MINIMALis the original fast estimate;MEDIUMandHIGHrefine it with increasing accuracy and cost.- DISABLED = 0#
- HIGH = 3#
- MEDIUM = 2#
- MINIMAL = 1#
- class ovclash.python.api.types.OverlapDetails(
- name0: str | None,
- name1: str | None,
- clash_hash: tuple[int, int],
- mesh_hash0: tuple[int, int],
- mesh_hash1: tuple[int, int],
- nb_records: int,
- nb_elements: int,
- type: OverlapType,
- time: float,
- min_distance: float,
- max_local_depth: float,
Bases:
objectFull data of one overlap record, from
ovclash_overlap_data_t.Each hash is the pair of uint64 words of a 128-bit hash, in native array order.
- Parameters:
name0 – Path of the first prim, a point cloud or a mesh, or None when it is empty.
name1 – Path of the second prim, a mesh, or None when it is empty.
clash_hash – Hash of the two prim paths.
mesh_hash0 – Hash of the data of the first prim.
mesh_hash1 – Hash of the data of the second prim.
nb_records – Number of frames in which the pair overlaps; always 1 for a static query.
nb_elements – Number of overlapping triangles or points in this frame.
type – Type of the pair.
time – Time of the frame on the timeline, in seconds, not USD time codes.
min_distance – Minimum distance between the triangle pairs, in stage units; 0.0 when they touch or interpenetrate.
max_local_depth – Maximum local depth between the triangle pairs, in stage units. It is -1.0 when depth was not computed (
max_local_depth_modeisDISABLED) and always 0.0 for a point-vs-mesh overlap.
- clash_hash: tuple[int, int]#
- max_local_depth: float#
- mesh_hash0: tuple[int, int]#
- mesh_hash1: tuple[int, int]#
- min_distance: float#
- name0: str | None#
- name1: str | None#
- nb_elements: int#
- nb_records: int#
- time: float#
- type: OverlapType#
- class ovclash.python.api.types.OverlapRecord(
- name0: str | None,
- name1: str | None,
- nb_records: int,
- nb_elements: int,
- type: OverlapType,
- time: float,
Bases:
objectNames, counts, type and time of one overlap record, from
ovclash_overlap_data_t.- Parameters:
name0 – Path of the first prim, a point cloud or a mesh, or None when it is empty.
name1 – Path of the second prim, a mesh, or None when it is empty.
nb_records – Number of frames in which the pair overlaps; always 1 for a static query.
nb_elements – Number of overlapping triangles or points in this frame.
type – Type of the pair.
time – Time of the frame on the timeline, in seconds, not USD time codes.
- name0: str | None#
- name1: str | None#
- nb_elements: int#
- nb_records: int#
- time: float#
- type: OverlapType#
- class ovclash.python.api.types.OverlapReportFlag(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
IntFlagOverlap-report content flags, matching
ovclash_overlap_report_flag_t.FACES0,FACES1andOUTLINEselect mesh-vs-mesh content andPOINTS0the point indices of a point-vs-mesh record.DEFAULTandFACESare the legacy mesh-index selectors ofovclash_create_overlap_report.ovclash_create_overlap_report_exignores them, andget_overlap_report()rejects flags made only of them withValueError.- DEFAULT = 0#
- FACES = 1#
- FACES0 = 4#
- FACES1 = 8#
- OUTLINE = 2#
- POINTS0 = 16#
- class ovclash.python.api.types.OverlapType(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
IntEnumType of an overlap pair, matching
ovclash_overlap_pair_type_t.The undefined value is not zero, so test a pair type as
== POINT_VS_MESHand never as!= 0, which reports an undefined type as a point-cloud pair.- MESH_VS_MESH = 0#
- POINT_VS_MESH = 1#
- UNDEFINED = 2147483647#
- class ovclash.python.api.types.PipelineStepData(
- name: str | None,
- step_index: int,
- nb_steps: int,
- progress: float,
- step_progress: float,
- finished: bool,
Bases:
objectDescription and progress of one pipeline step, mirroring
ovclash_step_data_t.- Parameters:
name – Name of the step, or None when it is empty.
step_index – Index of the step.
nb_steps – Number of steps in the pipeline.
progress – Pipeline progress, nominally 0.0 to 1.0. An OpenUSD async poll can briefly report a value outside that range or a non-finite one; clamp it, and treat a non-finite value as unknown.
step_progress – Progress within the step, nominally 0.0 to 1.0, with the same OpenUSD caveat.
finished – True for the last step. It marks the last step index, not a completed run.
- finished: bool#
- name: str | None#
- nb_steps: int#
- progress: float#
- step_index: int#
- step_progress: float#
- class ovclash.python.api.types.QueryStats(
- nb_meshes: int,
- nb_shared_meshes: int,
- nb_cooked_meshes: int,
- nb_point_clouds: int,
Bases:
objectMesh and point-cloud counts of the last run, from
ovclash_stats_t.The counts are zero before the pipeline has run.
- Parameters:
nb_meshes – Number of selected meshes.
nb_shared_meshes – Number of selected meshes that are shared instances.
nb_cooked_meshes – Number of unique meshes cooked on ovstage, or of cooks attempted on OpenUSD. On ovstage, a value below
nb_meshes - nb_shared_meshesmeans that meshes that could not be cooked were dropped from the results.nb_point_clouds – Number of selected point clouds.
- nb_cooked_meshes: int#
- nb_meshes: int#
- nb_point_clouds: int#
- class ovclash.python.api.types.RunSettings(
- enable_log: bool = False,
- enable_full_scene: bool = True,
- enable_point_clouds: bool = False,
- ignore_invisible_prims: bool = True,
- use_usdrt: bool = False,
- single_threaded: bool = False,
- only_find_duplicates: bool = False,
- set_times: bool = False,
- start_time: float = 0.0,
- end_time: float = 0.0,
- time_codes_per_second: float = 24.0,
- tolerance: float = 0.0,
- max_local_depth_mode: MaxLocalDepthMode = MaxLocalDepthMode.DISABLED,
- new_task_manager: bool = True,
- nb_tasks: int = 128,
Bases:
objectCurated clash run settings, mapped onto
ovclash_settings_t.Only the settings that standalone clash queries commonly tune are exposed here. The other canonical settings, such as coplanar handling, tight bounds, permanent-overlap purging and the epsilons, keep the values that
ovclash_reset_settingsproduces. Values are checked whenClashRuntime.set_run_settingsapplies them, not on construction. Every float field must be finite.The threading controls are
single_threaded,new_task_managerandnb_tasks. None of them changes which pairs overlap or the per-pair data. A task count is not an exact OS-thread count.- Parameters:
enable_log – Print the backend’s progress and diagnostic lines to stdout.
enable_full_scene – Traverse the whole stage when no scope is applied.
enable_point_clouds – Also run point-cloud-vs-mesh queries.
ignore_invisible_prims – Exclude invisible prims from the selection.
use_usdrt – Stored and read back only; it has no effect in standalone ovclash.
single_threaded – Force serial execution on both backends. On ovstage the result order stays the same; on OpenUSD it may differ.
only_find_duplicates – Run duplicate-mesh detection only and skip overlap detection. A time-sampled run finds no duplicates.
set_times – Apply
start_time,end_timeandtime_codes_per_second. When False, the query is static.start_time – Start of the sampled range, in seconds, not USD time codes.
end_time – End of the sampled range, in seconds. It must not be below
start_timewhenset_timesis True; equal values select a single-sample query.time_codes_per_second – Query samples per second, not the stage’s time-code rate. It must be finite and non-negative; 0 collapses the range to one sample.
tolerance – Clearance distance in stage units; mesh pairs closer than this count as clashing. 0.0 reports touching or interpenetrating geometry only.
max_local_depth_mode – Max-local-depth computation mode.
DISABLEDleaves the mesh-vs-meshmax_local_depthat -1.0, which means not computed.new_task_manager – Use the new task manager, which ignores
nb_tasks. On ovstage it selects Carbonite workers, and False selectsstd::threadworkers. On OpenUSD, detection uses Carbonite under both managers, and False runs report extraction onstd::threadworkers.nb_tasks – Task count of the legacy task manager. On OpenUSD it sets the detection task split and bounds the
std::threadreport-extraction workers; on ovstage it bounds thestd::threadworkers. Hardware concurrency and the available work bound them too. It must be in 1..255 whensingle_threadedandnew_task_managerare both False.
- enable_full_scene: bool#
- enable_log: bool#
- enable_point_clouds: bool#
- end_time: float#
- ignore_invisible_prims: bool#
- max_local_depth_mode: MaxLocalDepthMode#
- nb_tasks: int#
- new_task_manager: bool#
- only_find_duplicates: bool#
- set_times: bool#
- single_threaded: bool#
- start_time: float#
- time_codes_per_second: float#
- tolerance: float#
- use_usdrt: bool#
- with_updates(
- **kwargs: Any,
Return a copy of these settings with some fields replaced.
- Parameters:
**kwargs – Field values to replace.
- Returns:
The new settings. This object is not changed.
- Raises:
TypeError – A keyword is not a field name.
- class ovclash.python.api.types.StageTimelineData(
- start_time_code: float,
- end_time_code: float,
- time_codes_per_second: float,
- frames_per_second: float,
Bases:
objectRoot-layer timeline metadata of the open stage, as USD resolves it.
A Stage attached with
ClashRuntime.attach_ovstage()reports the timeline fields of its attachment, as supplied.RunSettingstimes are in seconds:seconds = time_code / time_codes_per_second. OpenUSD can report a nonpositive authored rate, so reject a nonpositive or non-finite rate before converting.- Parameters:
start_time_code – Stage
startTimeCode; 0.0 when unauthored.end_time_code – Stage
endTimeCode; 0.0 when unauthored.time_codes_per_second – Effective rate on both backends. It is the authored
timeCodesPerSecond, else the authoredframesPerSecond, else 24.0.frames_per_second – Stage
framesPerSecond; 24.0 when unauthored.
- end_time_code: float#
- frames_per_second: float#
- start_time_code: float#
- time_codes_per_second: float#
The Threading section of Performance describes what
the single_threaded, new_task_manager and nb_tasks fields of
RunSettings control on each backend, the scene-reading implementation that
the native library was built with.
The product API: ovclash_suite#
import ovclash_suite is an alias of ovclash.python.suite, the module
documented in this section. Every name shown with an ovclash.python.suite.
prefix is reachable as ovclash_suite.<name>. The types under
Suite types and enums are also exported at the top level, for example
ovclash_suite.SettingId.
Runtime#
Async Pipelines covers
AsyncPipeline.Persistence covers fetch-and-save, which writes the clash records of a completed run into a store.
The Suite fetch and cursor lifetime section of Threading and Ownership covers the
AsyncFetchAndSavethatClashDetection.run_async_fetch_and_save()returns.ovstage Integration covers
ClashDetection.attach_ovstage()andrun_ovstage_owner_operation().
- class ovclash.python.suite.ClashDetection(backend: str = 'ovclash')#
Legacy-compatible clash detection runtime backed by the Suite C ABI.
Serialize calls that share this runtime. A started fetch iterator reserves the runtime until it is exhausted or explicitly closed, even while it is suspended after its final progress yield. While the runtime is reserved, it rejects destroy and reset, stage, settings and scope changes, pipeline execution and depth computation. A synchronous fetch keeps result reads available; an async fetch also rejects reads until its operation closes. Finish asynchronous detection before starting a fetch. Separate runtime reports still need their documented cleanup.
Explicit
destroy()is the primary lifetime contract. A finalizer that runs inside an owner callback defers the native cleanup and keeps the attachments.- Parameters:
backend – Compatibility name, one of “ovclash”, “suite” or “legacy”. It does not select a backend; the loaded native library determines that.
- Raises:
ValueError –
backendis not an accepted name.RuntimeError – The native runtime cannot be created.
- DEFAULT_SETTINGS = {SettingId.SETTING_LOGGING: False, SettingId.SETTING_DYNAMIC: False, SettingId.SETTING_DYNAMIC_START_TIME: 0.0, SettingId.SETTING_DYNAMIC_END_TIME: 0.0, SettingId.SETTING_PURGE_PERMANENT_OVERLAPS: False, SettingId.SETTING_QUANTIZED: False, SettingId.SETTING_SINGLE_THREADED: False, SettingId.SETTING_NEW_TASK_MANAGER: True, SettingId.SETTING_FILTER_TEST: False, SettingId.SETTING_TIGHT_BOUNDS: True, SettingId.SETTING_COPLANAR: True, SettingId.SETTING_NB_TASKS: 128, SettingId.SETTING_POSE_EPSILON: 1e-06, SettingId.SETTING_BOUNDS_EPSILON: 0.01, SettingId.SETTING_AREA_EPSILON: 1e-06, SettingId.SETTING_TRIS_PER_LEAF: 15, SettingId.SETTING_TOLERANCE: 0.0, SettingId.SETTING_ANY_HIT: False, SettingId.SETTING_OVERLAP_CODE: 3, SettingId.SETTING_DUP_MESHES: False, SettingId.SETTING_STATIC_TIME: 0.0, SettingId.SETTING_COMPUTE_MAX_LOCAL_DEPTH: False, SettingId.SETTING_DEPTH_EPSILON: -1.0, SettingId.SETTING_DISCARD_TOUCHING_CONTACTS: False, SettingId.SETTING_PURGE_PERMANENT_STATIC_OVERLAPS: True, SettingId.SETTING_USE_USDRT: True, SettingId.SETTING_TRIANGLE_LIMIT: 0, SettingId.SETTING_IGNORE_REDUNDANT_OVERLAPS: False, SettingId.SETTING_IGNORE_INVISIBLE_PRIMS: True, SettingId.SETTING_CONTACT_CUTOFF: -1.0, SettingId.SETTING_MAX_LOCAL_DEPTH_MODE: 1, SettingId.SETTING_ENABLE_POINT_CLOUDS: False, SettingId.SETTING_POINT_SIZE_OVERRIDE: 0.0}#
Default value of each run setting, keyed by
SettingId, read from the native defaults.
- attach_ovstage(
- stage: Any,
- committed_ordinal: int,
- **metadata: Any,
Borrow a live
ovstage.Stageunder its owner’s exclusive query lease.The metadata names match the C binding descriptor.
evaluate_time(seconds)receives NaN for the Default time and returns a newly committed ordinal. The Stage, the callback and the composition buffers are kept until a successful detachment, a reset, destruction, a successful file open or another attachment. A successful attachment replaces any open file or previous binding, and clears the scope, results and pipeline. The owner must keep the Stage live and exclude rendering and edits while attached operations run. Withoutcomposition_root, no source file name is consulted.authored_transform_updates=Trueopts into static-pair pruning. Use it only for owners that meet the full contract of the C binding for raw-op and default-order population and for same-time update provenance. It requiresevaluate_time, and that callback must publish a newer ordinal even for identical seconds. The default leaves attached meshes conservatively non-static.composition_rootmakes the attachment engine-evaluated instead. Default selection still reads the Stage atcommitted_ordinal, which the owner keeps retained until detach. Every finite time is evaluated natively in private ovstage instances that replay the root andcomposition_layers, the texts of the owner’s surviving root merges in the order it added them. The Stage is never evaluated or advanced, so the owner’s time stays where it is. The owner guarantees that the composition reproduces its transforms at every finite time, and keeps the root file and every file that the root or a layer references unchanged on disk while attached, because each replay reopens the root by its string. A relative root resolves against the working directory at replay time, so open the Stage from an absolute path or URL and pass that string.time_secondsmust stay NaN, andevaluate_timeandauthored_transform_updatesmust stay unset; classification then prunes static pairs from the private population.- Parameters:
stage – Live
ovstage.Stageto borrow.committed_ordinal – Positive uint64 read ordinal of the current evaluation of the Stage.
**metadata – Keyword-only binding fields and their defaults:
time_seconds(NaN, the Default time),meters_per_unit(0.01),start_time_codeandend_time_code(0.0),time_codes_per_secondandframes_per_second(24.0),evaluate_time(None),authored_transform_updates(False),composition_root(None, the exact path, URL or USDA text the owner opened),composition_layers(an empty sequence of USDA texts, earliest first) andcomposition_root_is_usda(False).
- Raises:
TypeError –
stageis not a live ovstage.Stage,committed_ordinalis not an integer, an unknown metadata keyword is passed,evaluate_timeis not callable,authored_transform_updatesorcomposition_root_is_usdais not a bool,composition_rootis not a str or path-like object (a str for USDA), orcomposition_layersis a str, a set, or holds anything but str.ValueError –
committed_ordinalis outside the positive uint64 range,authored_transform_updatesis set withoutevaluate_time, composition layers orcomposition_root_is_usdaare passed without a root, the root or a layer is empty, contains NUL or is not encodable as UTF-8, or a root is combined withevaluate_time,authored_transform_updatesor atime_secondsother than NaN.RuntimeError – An async operation is alive, the ovstage backend extension is missing, or the native attachment fails.
- cancel_async_pipeline(
- cookie: AsyncPipeline,
Cancel and close an async pipeline; it is closed even when the cancel fails.
- Parameters:
cookie – Handle that
run_async_pipeline()returned.
- property clash_detect_api: Any#
Loaded ctypes library, kept for compatibility with older callers.
- property clash_detect_context: c_void_p | None#
Native runtime handle, kept for compatibility with older callers.
- close() None#
Destroy the native runtime handle that this object owns.
An unfinished async pipeline is closed first. Closing finishes it rather than cancelling it, and blocks until it completes; cancel it first to stop early. A failed cleanup of a dependent async operation leaves the runtime owned. A failed finalizer cleanup can still be recovered after the native handle of this runtime was consumed, when its async operation keeps a data store. Close fetch iterators first.
close()is an alias.An explicit native failure keeps the handle for retry. An uncertain ctypes return retires it, because the native deletion may already have run.
- Raises:
RuntimeError – An async fetch-and-save operation is still open, or the native destroy fails. A live native fetch also rejects the call and leaves the handle usable; retry after releasing the fetch.
- compute_max_local_depth(
- mesh_path0: Any,
- matrix0: Any,
- mesh_path1: Any,
- matrix1: Any,
- clash_query: ClashQuery,
Compute the maximum local depth between two mesh instances.
Both paths must resolve to meshes. A pair the engine does not support raises here instead of returning a depth, so call
is_depth_computation_supported()first. During the call the runtime uses the query’s settings plusSETTING_COMPUTE_MAX_LOCAL_DEPTH. Afterwards the query’s own settings stay applied, replacing the settings applied before the call.- Parameters:
mesh_path0 – USD path of the first mesh.
matrix0 – Row-major 4x4 transform of the first mesh, as 16 values in any nesting.
mesh_path1 – USD path of the second mesh.
matrix1 – Row-major 4x4 transform of the second mesh, as 16 values in any nesting.
clash_query – Query whose
clash_detect_settingsdrive the computation. The query is not modified.
- Returns:
The maximum local depth in scene units, or 0.0 when the runtime was destroyed.
- Raises:
ValueError – A matrix does not hold 16 values.
RuntimeError – An async operation is alive, applying the settings fails, or the native computation fails.
- compute_penetration_depth(
- mesh_path0: Any,
- matrix0: Any,
- mesh_path1: Any,
- matrix1: Any,
- clash_query: ClashQuery,
- dir: tuple[float, float, float],
Compute the penetration depth between two mesh instances along a direction.
Both paths must resolve to meshes. A pair the engine does not support raises here instead of returning a depth, so call
is_depth_computation_supported()first. During the call the runtime uses the query’s settings plusSETTING_COMPUTE_MAX_LOCAL_DEPTH. Afterwards the query’s own settings stay applied, replacing the settings applied before the call.- Parameters:
mesh_path0 – USD path of the first mesh.
matrix0 – Row-major 4x4 transform of the first mesh, as 16 values in any nesting.
mesh_path1 – USD path of the second mesh.
matrix1 – Row-major 4x4 transform of the second mesh, as 16 values in any nesting.
clash_query – Query whose
clash_detect_settingsdrive the computation. The query is not modified.dir – Query direction as three floats.
- Returns:
A namespace with
depthanddir(a 3-tuple) and the legacy aliasesmDepthandmDir(withx,yandz), or None whendiris None or zero or the runtime was destroyed.- Raises:
ValueError – A matrix does not hold 16 values.
RuntimeError – An async operation is alive, applying the settings fails, or the native computation fails.
- create_pipeline() int#
Build the clash pipeline.
- Returns:
The number of pipeline steps.
- Raises:
RuntimeError – An async operation is alive, or the native call fails.
- destroy() None#
Destroy the native runtime handle that this object owns.
An unfinished async pipeline is closed first. Closing finishes it rather than cancelling it, and blocks until it completes; cancel it first to stop early. A failed cleanup of a dependent async operation leaves the runtime owned. A failed finalizer cleanup can still be recovered after the native handle of this runtime was consumed, when its async operation keeps a data store. Close fetch iterators first.
close()is an alias.An explicit native failure keeps the handle for retry. An uncertain ctypes return retires it, because the native deletion may already have run.
- Raises:
RuntimeError – An async fetch-and-save operation is still open, or the native destroy fails. A live native fetch also rejects the call and leaves the handle usable; retry after releasing the fetch.
- detach_ovstage() None#
Release the borrowed ovstage Stage without closing it.
The results and the pipeline are invalidated, and the retained Stage and callback are released. Serialize this call with every other call on this runtime and its attached Stage.
- Raises:
RuntimeError – An async pipeline or fetch is alive, the ovstage backend extension is missing, or the native detachment fails.
- fetch_and_save_overlaps(
- stage: Any,
- clash_data: Any,
- clash_query: ClashQuery,
- timing_callback: Any = None,
- *,
- progress_callback: Any = None,
- async_mode: bool = False,
Persist the runtime results and yield bounded progress, synchronously or by polling.
This is a lazy generator. The argument checks, the native launch or synchronous begin, and the settings snapshot happen on the first iteration, not when the generator is created. In async mode, initialization then runs on the background worker.
With
update_clash_states_after_detectionenabled (the default), re-detected normal and duplicate overlaps become ACTIVE, except an APPROVED clash whose detected contents are exactly unchanged, and absent clashes become RESOLVED. Equality compares the type, tolerance, depth epsilon, object paths and mesh checksums, the aggregate results and the complete ordered frame history, including times, matrices, metrics and geometry payload. Stored overlap and frame row identifiers, review fields, timestamps and user penetration-depth annotations do not take part. The query and the ordered pair hash establish result identity; a matching overlap hash alone does not prove unchanged contents.The numeric comparison uses no epsilon, treats signed zeros as equal and NaNs as unequal, and does not depend on the caller’s denormal controls. It compares at ABI precision: float32 for outlines and point sizes, float64 for header values, frame scalar metrics, times and matrices. The SQLite, directory and Python custom serializers provide the stored-result reader for this comparison. Disable the flag to preserve stored states. New overlaps start NEW and are not promoted during their first fetch. Absent clashes are marked not present in either mode.
Native operations reserve their runtime and native data store until they are destroyed, even after completion or failure. While that reservation exists, resetting or destroying the runtime and modifying, reopening, saving-as or closing the store is rejected. Close an abandoned iterator before closing the data store or destroying the runtime.
Each native step attempts at most 1024 runtime frame reports across approval comparison and capture, and stops once it reaches 8 MiB of runtime report payload; one indivisible report may exceed that threshold. Long overlaps span several steps, and no borrowed report or preparation worker stays alive between steps. Async mode drives the steps on one persistence worker. Its polling yields may occur during initialization, a native step or cleanup, and busy runtime or data reads are rejected. Modification notifications use a path cached before the launch. Duplicate persistence follows
SETTING_DUP_MESHESof this query, independently of the runtime’sonly_find_duplicatessetting. Fetch preparation uses the threading settings that the runtime has at native initialization.Fetch-and-save is not all-or-nothing for every failure:
A serializer callback failure while the fetch advances, including a saved-result reader failure, requests a rollback of the whole pending transaction. That includes earlier batches and other uncommitted changes on the same destination.
An initialization failure leaves pre-existing writes pending.
An extraction, frame-preparation or scheduling failure restores only an incomplete streamed overlap and keeps earlier completed pending writes. A failed overlap cleanup falls back to a full rollback.
A cancellation or an iterator close also leaves completed writes pending when the cleanup succeeds. An explicit iterator close raises on a failed cleanup; an earlier processing exception stays primary during unwinding.
The SQLite and directory stores attempt to commit retained pending writes when they close or are destroyed, so an exception or an abandoned iterator can still leave partial results on disk.
A successful native completion reconciles absent overlaps, calls the idempotent BEGIN and commits before it yields 1.0, even for an empty result; pending writes are published too. Reconciliation can span several steps. Stopping synchronous iteration, or a cancellation that the async worker observes before the commit, leaves the absent-state updates applied so far pending and performs no further reconciliation. Stopping async polling alone leaves the worker running; close requests cancellation and drains it. A cancellation can race a successful commit and does not undo committed results.
After the final 1.0 yield, exhaust or explicitly close the iterator to release its runtime and store leases. A modification-notification callback can raise after that commit, and
timing_callbackruns after the iteration completes; either exception leaves the committed results intact. A failed native operation cannot resume; a retry must start a new iterator. Custom serializers must implement the same transaction and savepoint contract. The threading mode does not change these rules.- Parameters:
stage – Kept for caller compatibility; the results come from the runtime.
clash_data – Open Suite serializer or its
ClashDatafacade. Custom serializers implement theAbstractClashDataSerializerfetch hooks; native code owns scheduling and reconciliation for every serializer.clash_query – Query that owns the fetched overlaps.
timing_callback – Optional callable that receives
(level, name, seconds, detail)timing rows.progress_callback – Optional callable that receives exact
(written, total)result-group counts after initialization and after each modification notification. Synchronous mode reports after each native step; async mode reports polling snapshots and always reports the final counts. The first call is(0, total). The counts include the query’s selected duplicates and exclude old rows and incomplete streamed overlaps. Written results may still be pending;written == totaldoes not imply a commit. The final reconciliation and commit precede the 1.0 progress yield. The callable runs on the iterating thread while the runtime and destination stay reserved. Its exception closes the operation and propagates; committed results are kept, and earlier pending writes follow the cancellation rules above. The float progress yields are unchanged.async_mode – Run the persistence on a native worker and yield polling progress. Custom serializers then opt into callbacks on the worker thread. Progress, modification and timing callbacks stay on the iterating thread.
- Yields:
Progress between 0.0 and 1.0; the last yield of a successful fetch is 1.0.
- Raises:
TypeError –
progress_callbackis neither callable nor None.ValueError –
clash_datais None. This method persists results and does not run detection; when persistence is not needed, run the pipeline and read its results directly.NotImplementedError – A custom serializer does not override
fetch_transaction().RuntimeError – Another async operation is alive,
clash_datais not an open Suite serializer, or a native fetch call fails.
- finish_async_pipeline(
- cookie: AsyncPipeline,
Finish and close an async pipeline.
- Parameters:
cookie – Handle that
run_async_pipeline()returned.- Returns:
True.
- get_async_pipeline_step_data(
- cookie: AsyncPipeline,
Return the progress data of an async pipeline.
- Parameters:
cookie – Handle that
run_async_pipeline()returned.- Returns:
The step data of
cookie.step_data().
- classmethod get_default_setting_value(
- setting_id: SettingId,
Return the default value of a legacy setting.
- Parameters:
setting_id –
SettingIdmember, or its integer value.- Returns:
The default value, or None for an unknown setting.
- classmethod get_list_of_prims_int_paths(
- stage: Any,
- prim_str_path: str,
- add_prim_children: bool = False,
- prim_accept_fn: Any = None,
- exclude_invisible: bool = True,
Encode literal prim paths as integer paths.
Path expressions are not evaluated, and children are not expanded.
- Parameters:
stage – Kept for signature compatibility; unused.
prim_str_path – Prim paths separated by spaces, tabs or newlines.
add_prim_children – Kept for compatibility; unused.
prim_accept_fn – Kept for compatibility; no filtering is done in Python.
exclude_invisible – Kept for compatibility; the native run settings control visibility.
- Returns:
A
(prim_paths, int_paths)tuple with the split path strings and their encoded integer paths.- Raises:
RuntimeError – A path cannot be encoded.
- get_nb_duplicates() int#
Return the number of detected duplicate mesh pairs.
- Raises:
RuntimeError – An async operation is alive, or the native query fails.
- get_nb_overlaps() int#
Return the number of detected overlap groups.
get_overlap_count()is the same method.- Raises:
RuntimeError – An async operation is alive, or the native query fails.
- get_overlap_count() int#
Return the number of detected overlap groups.
get_overlap_count()is the same method.- Raises:
RuntimeError – An async operation is alive, or the native query fails.
- get_overlap_data(
- overlap_index: int,
- frame_index: int = 0,
Return the raw overlap data of one overlap frame.
- Parameters:
overlap_index – Zero-based overlap group index.
frame_index – Zero-based frame (record) index within the overlap group.
- Returns:
An
OverlapDatarecord of copied Python values.- Raises:
OverflowError – An index is outside the unsigned 32-bit range.
RuntimeError – An async operation is alive, or the native query fails, for example for an index past the overlap count.
- get_overlap_report(
- overlap_index: int,
- frame_index: int = 0,
- mesh_index: Any = 0,
- flags: int = 0,
Return a legacy overlap report dictionary with a
usd_facesalias for one mesh.- Parameters:
overlap_index – Zero-based overlap group index.
frame_index – Zero-based frame or record index within the overlap group.
mesh_index – 1, or an enum whose
valueis 1, makesusd_facesan alias ofusd_faces1; any other value makes it an alias ofusd_faces0.flags – Kept for legacy signature compatibility. The default flags of
get_overlap_report2()apply.
- Returns:
The dictionary of
get_overlap_report2()with the addedusd_faceskey.- Raises:
OverflowError – An index is outside the uint32 range.
RuntimeError – An async operation is alive, or the native report fails.
- get_overlap_report2(
- overlap_index: int,
- frame_index: int = 0,
- flags: int | None = None,
Return owned copies of the detailed report buffers of one overlap frame.
- Parameters:
overlap_index – Zero-based overlap group index.
frame_index – Zero-based frame or record index within the overlap group.
flags –
OverlapReportFlagbitmask. None selects FACES0, FACES1, POINTS0 and OUTLINE.
- Returns:
A dictionary with
usd_faces0,usd_faces1andusd_points0(uint32 ArrayView),collision_outline(float32 ArrayView of xyzxyz segment endpoints),point_size0and thematrix0andmatrix1transforms. The native report is released before the method returns.- Raises:
OverflowError – An index is outside the uint32 range.
RuntimeError – An async operation is alive, or the native report fails.
- get_pipeline_step_data(
- index: int,
Return the progress data of a pipeline step.
- Parameters:
index – Zero-based pipeline step index.
- Returns:
The step data.
- Raises:
OverflowError –
indexis outside the uint32 range.RuntimeError – An async operation is alive, or the native query fails.
- get_prim_matrix(
- prim_path: str,
- timecode: float = 0.0,
Return the row-major 4x4 local-to-world transform of a prim at a USD time code.
- Parameters:
prim_path – Path of the prim.
timecode – USD time code, not seconds.
- Returns:
A NumPy float64 array of shape (4, 4) when NumPy is importable, otherwise a tuple of four row tuples.
- Raises:
RuntimeError – An async operation is alive, or the transform query fails.
- get_query_stats() QueryStats#
Return mesh and point-cloud statistics of the last pipeline run.
- Raises:
RuntimeError – An async operation is alive, or the native query fails.
- get_query_stats_for_telemetry() Any#
Return query statistics under the legacy telemetry attribute names.
- Returns:
A namespace with
nbMeshes,nbSharedMeshesandnbCookedMeshes.- Raises:
RuntimeError – An async operation is alive, or the native query fails.
- get_stage_timeline() StageTimeline#
Return the root-layer timeline metadata of the open stage.
The runtime reads it natively on both backends when it opens the stage, so it needs neither
pxrnor a text (.usda) stage. An attached ovstage Stage reports the metadata its owner supplied.- Raises:
RuntimeError – No stage is open, or an async operation is alive.
- is_async_pipeline_running(
- cookie: AsyncPipeline,
Return True while an async pipeline is still running.
- Parameters:
cookie – Handle that
run_async_pipeline()returned.
- static is_depth_computation_supported(
- overlap_type: OverlapType,
Return whether depth computations are available for an overlap type.
compute_max_local_depth()andcompute_penetration_depth()resolve both paths as meshes, so a point-cloud-vs-mesh overlap cannot be computed. Call this check before either of them; neither tests the overlap type itself.Only
POINT_CLOUD_MESHis rejected.UNDEFINED(0x7fffffff) returns True: an overlap whose type was never classified is not known to be a point cloud, and the compute methods still raise when a path does not resolve to a mesh.- Parameters:
overlap_type – An
ovclash_suite.OverlapType, for exampleClashInfo.overlap_type. Do not passovclash.OverlapTypefrom the canonical binding. The two enums are unrelated and their point-cloud members differ in value (ovclash_suitePOINT_CLOUD_MESHis 3,ovclashPOINT_VS_MESHis 1). A canonical value is compared by number, so a point-cloud overlap would be reported as supported.- Returns:
True when the depth computations can run for such an overlap.
- property is_out_of_memory: bool#
Whether the runtime is in an out-of-memory state.
- last_error() str#
Return the last native error message recorded on this runtime.
- Returns:
The message, or an empty string for a destroyed runtime.
- open_stage(stage_path: str) None#
Open a file-backed USD stage, or raise on failure.
- Parameters:
stage_path – Filesystem path of the USD stage.
- Raises:
RuntimeError – An async operation is alive, or the stage cannot be opened.
- process_duplicate(
- stage: Any,
- idx: int,
- existing_overlaps: dict[str, ClashInfo],
- query_identifier: int,
Convert one native duplicate mesh pair into a
ClashInfo.- Parameters:
stage – Kept for legacy compatibility; unused.
idx – Zero-based duplicate mesh pair index.
existing_overlaps – Existing overlaps keyed by overlap hash. A matching record is updated in place and keeps its identifier and user-editable fields; its state can then become ACTIVE (see
update_clash_states_after_detection). The last-modified fields of the returned record are refreshed either way.query_identifier – Query identifier to assign to the processed clash.
- Returns:
The new or updated record.
- Raises:
OverflowError –
idxis outside the uint32 range.RuntimeError – An async operation is alive, the native query fails, or the transform of either object cannot be read. The existing record is then left unchanged.
- process_overlap(
- stage: Any,
- idx: int,
- existing_overlaps: dict[str, ClashInfo],
- query_identifier: int,
- setting_tolerance: float,
- setting_depth_epsilon: float,
- yield_progress_range: tuple[float, float] | None = None,
Convert one native overlap group into a
ClashInfo.Records whose report is unavailable are dropped with a logged warning. The aggregates, the times and
num_recordsof the result describe only the frames that are kept.- Parameters:
stage – Kept for legacy compatibility; unused.
idx – Zero-based overlap group index.
existing_overlaps – Existing overlaps keyed by overlap hash. A matching record is updated in place and keeps its identifier and user-editable fields; its state can then become ACTIVE (see
update_clash_states_after_detection). The last-modified fields of the returned record are refreshed either way.query_identifier – Query identifier to assign to the processed clash.
setting_tolerance – Tolerance used for clash classification.
setting_depth_epsilon – Depth epsilon used for contact classification.
yield_progress_range – Legacy progress range; this method ignores it.
- Returns:
The new or updated record.
- Raises:
OverflowError –
idxis outside the uint32 range.RuntimeError – An async operation is alive, a native query fails, or no record of the group could be reported.
- process_overlap_generator(
- stage: Any,
- idx: int,
- existing_overlaps: dict[str, ClashInfo],
- query_identifier: int,
- setting_tolerance: float,
- setting_depth_epsilon: float,
- yield_progress_range: tuple[float, float] = (0.0, 1.0),
Process one overlap group, then yield
yield_progress_range[1]once.The generator returns the resulting
ClashInfo; read it withyield fromor fromStopIteration.value. The work and its errors are those ofprocess_overlap().- Parameters:
stage – Kept for legacy compatibility; unused.
idx – Zero-based overlap group index.
existing_overlaps – Existing overlaps keyed by overlap hash. A matching record is updated in place and keeps its identifier and user-editable fields; its state can then become ACTIVE (see
update_clash_states_after_detection). The last-modified fields of the returned record are refreshed either way.query_identifier – Query identifier to assign to the processed clash.
setting_tolerance – Tolerance used for clash classification.
setting_depth_epsilon – Depth epsilon used for contact classification.
yield_progress_range – Progress range; only its end value is yielded.
- Yields:
yield_progress_range[1], once.
- reset() None#
Drop the detection results and release a borrowed ovstage Stage.
Settings, scope and an open file-backed stage are kept; the cached pipeline step count is cleared.
- Raises:
RuntimeError – An async pipeline or fetch is alive, or the native reset fails. Release the operation first.
- run_async() AsyncPipeline#
Start the prepared pipeline asynchronously.
The pipeline is created first when it is not prepared. The Python owner is set up before the native launch. If the launch raises, a blocking cleanup is attempted before the original exception propagates; an explicit cleanup failure leaves the owner attached, so that runtime teardown can retry it.
run_async()is an alias.- Returns:
The handle of the running pipeline.
- Raises:
RuntimeError – An async operation is alive, or the native launch fails.
- run_async_fetch_and_save(
- stage: Any,
- clash_data: Any,
- clash_query: ClashQuery,
Launch the result persistence and return the async operation that owns it.
This call opts custom serializers into callbacks on the worker thread.
finish()andcancel()keep the leases and snapshots; close the operation before using the destination again. Detection must already have completed on this runtime.- Parameters:
stage – Kept for compatibility; unused.
clash_data – Open Suite serializer, or its
ClashDatafacade, that receives the results.clash_query – Query that owns the fetched overlaps. Its settings select the tolerance, the depth epsilon and whether duplicates are persisted.
- Returns:
The running operation.
- Raises:
ValueError –
clash_datais None.NotImplementedError – A custom serializer does not implement
fetch_transaction.RuntimeError – Another async operation is alive,
clash_datais not an open Suite serializer, or the native launch fails.
- run_async_pipeline() AsyncPipeline#
Start the prepared pipeline asynchronously.
The pipeline is created first when it is not prepared. The Python owner is set up before the native launch. If the launch raises, a blocking cleanup is attempted before the original exception propagates; an explicit cleanup failure leaves the owner attached, so that runtime teardown can retry it.
run_async()is an alias.- Returns:
The handle of the running pipeline.
- Raises:
RuntimeError – An async operation is alive, or the native launch fails.
- run_pipeline() list[PipelineStepData]#
Create and execute the full clash pipeline synchronously.
- Returns:
The step data of every step, read after the pipeline is created and before any step runs.
- Raises:
RuntimeError – An async operation is alive, or a pipeline call fails.
- run_pipeline_step(index: int) None#
Execute one pipeline step.
- Parameters:
index – Zero-based pipeline step index.
- Raises:
OverflowError –
indexis outside the uint32 range.RuntimeError – An async operation is alive, or the step fails.
- set_scope(
- stage: Any,
- obj_a: str,
- obj_b: str,
- merge_scopes: bool = False,
Set the clash scope from literal prim paths without evaluating path expressions.
- Parameters:
stage – File path or file-backed stage to open, or None to reuse the open stage. A path that resolves to the open file reuses it instead of reopening it, as for
set_settings().obj_a – Literal prim paths of search set A, separated by spaces, tabs or newlines.
obj_b – Literal prim paths of search set B, separated the same way.
merge_scopes – When True, combine both path lists into search set A.
- Returns:
True when the native runtime accepts the scope.
- Raises:
ValueError – No file-backed stage is open and
stagenames none, orstageis not the attached ovstage Stage.RuntimeError – An async operation is alive, the stage cannot be opened, a path cannot be encoded, or the C ABI rejects the scope.
- set_scope_paths(
- prim_paths_a: Iterable[str],
- prim_paths_b: Iterable[str] | None = None,
Set the clash scope from explicit USD prim paths.
- Parameters:
prim_paths_a – Prim paths of search set A. Empty strings are skipped.
prim_paths_b – Prim paths of search set B. None or empty tests set A against itself. When both sets are empty, the scope is cleared and a run covers the whole stage.
- Returns:
True when the native runtime accepts the scope.
- Raises:
RuntimeError – An async operation is alive, or the C ABI rejects the scope.
- set_settings(
- settings: dict[Any, Any],
- stage: Any = None,
- *,
- time_codes_per_second: float | None = None,
Apply legacy setting values to the native runtime.
- Parameters:
settings – Setting values keyed by
SettingIdmember, its integer value or its name, such as"SETTING_TOLERANCE". Other keys are ignored without an error. A missing setting takes itsDEFAULT_SETTINGSvalue.stage – Optional legacy Python stage object, used only to open the same file-backed stage and to derive the time settings. When it names the open file, resolved from the current directory, the file is not reopened and the scope from
set_scope_paths()is kept. Any spelling of the open file counts: its open path, apathlib.Pathor a layer’s absoluterealPath. After a failed open dropped the stage, any spelling opens the file again, the repeated path included. Any other file is opened as byopen_stage(), which drops the scope. C callers set the time fields ofovclash_suite_run_settings_tinstead.time_codes_per_second – Optional sampling rate of a dynamic run, in samples per second. The default is the open stage’s own
timeCodesPerSecond. The seconds that the query times resolve to do not change. C callers setovclash_suite_run_settings_t.time_codes_per_seconddirectly.
- Returns:
True when the native runtime accepts the settings.
- Raises:
RuntimeError – An async operation is alive,
stagecannot be opened, an attached ovstage Stage reports no timeline, a dynamic query on a binary crate stage has neither a readable timeline nor an explicit range, or the C ABI rejects the settings.ValueError –
time_codes_per_secondis given and is not a positive number, a resolved value is out of range or not finite,stagenames no file while none is open, orstageis not the attached ovstage Stage.
- set_stage_path(stage_path: str) bool#
Open a file-backed USD stage and remember its path.
A non-empty path that encodes successfully first detaches a borrowed Stage, and a later file-open failure leaves this runtime detached. An empty path, or a path that fails to encode, keeps the borrowed binding. A successful open drops the scope set by
set_scope_paths(), even when it reopens the file that is already open; a failed open keeps it.- Parameters:
stage_path – Filesystem path of the USD stage.
- Returns:
True when the stage opened; False when the native open fails (see
last_error()).- Raises:
RuntimeError – An async operation is alive, or detaching a borrowed Stage fails.
- class ovclash.python.suite.AsyncPipeline(
- runtime: ClashDetection,
- handle: c_void_p,
Bases:
objectHandle of a Suite clash pipeline that runs asynchronously.
ClashDetection.run_async_pipeline()creates it. While the handle is alive, the runtime rejects other work; finish, cancel or close the handle first.- Parameters:
runtime –
ClashDetectionthat started the pipeline.handle – Native async handle from
ovclash_suite_run_pipeline_async. This object owns it and releases it withovclash_suite_async_destroy.
- cancel() None#
Request cancellation, drain the execution and release the native async cookie.
A call after the handle is released does nothing.
- Raises:
RuntimeError – The native cancel or the handle release fails.
- close() None#
Release the native asynchronous pipeline handle.
An unfinished run is finished first, which blocks until it completes; call
cancel()to stop it early. An explicit native destroy failure keeps the handle for retry. When a Python exception hides the native outcome, the handle is retired, because it may already be freed. Destroy the runtime to drain any worker that it still owns. If the cleanup never entered C, the outer handle that the caller owns may stay allocated, because runtime destruction only invalidates it.- Raises:
RuntimeError – The native destroy fails.
- finish() None#
Wait for the asynchronous pipeline to finish, then release the native handle.
A call after
finish()orcancel()does nothing.- Raises:
RuntimeError – The native finish or the handle release fails.
- is_running() bool#
Return True while the asynchronous pipeline is still running.
A finished or cancelled pipeline reports False instead of raising. Both terminators drain the run and release the native cookie, because
ovclash_suite_async_destroydeletes the handle. The answer then comes from the state this object tracks, not from a poll of a released handle, which the C ABI can only reject.- Raises:
RuntimeError – The native poll fails.
- poll() tuple[bool, PipelineStepData]#
Return the running state and the current step data in one call.
A finished or cancelled pipeline reports False and a cleared, completed step, so both halves agree with
is_running()andstep_data().- Returns:
(running, step_data).- Raises:
RuntimeError – A native query fails.
- step_data() PipelineStepData#
Return the progress of the active asynchronous pipeline step.
A finished or cancelled pipeline reports a cleared, completed step instead of raising. That answer comes from the state this object tracks, because the native progress call rejects a handle whose engine run was already consumed.
progressis passed through unclamped. On OpenUSD, a poll that races the counter reset of a phase can report a value outside [0, 1] or a non-finite one; clamp it, and treat a non-finite value as unknown.- Returns:
The step data.
- Raises:
RuntimeError – The native progress query fails.
- class ovclash.python.suite.AsyncFetchAndSave(
- runtime: ClashDetection,
- destination: Any,
- handle: c_void_p,
- adapter: Any = None,
- notification_path: str = '',
Bases:
objectAsync fetch-and-save operation that owns its runtime and destination leases until close.
ClashDetection.run_async_fetch_and_save()creates it.finish()andcancel()join the worker and keep the terminal snapshots readable.close()cancels and drains the worker, and releases the handle and every Python owner. Serialize calls that share one operation. Custom serializer hooks run on its worker thread.- Parameters:
runtime –
ClashDetectionwhose results are persisted.destination – Suite serializer or
ClashDatafacade that receives the results.handle – Native fetch handle, filled by the launch. This object owns it.
adapter – Adapter of a custom serializer, or None for a built-in serializer.
notification_path – Store path for modification callbacks, cached before the launch.
- cancel() None#
Cancel and join the worker; work that already completed successfully stays successful.
A closed operation ignores the call.
- Raises:
RuntimeError – The call comes from a serializer callback, or the cancel fails. An exception from a serializer callback is re-raised in its place.
- close() None#
Cancel and drain the worker, then consume the handle, even after a cleanup failure.
A processing failure that
finish()orcancel()already reported is not raised again. The first failure during close still propagates. An interruption before the native destruction keeps every owner for a retry. Native consumption clears the handle even if Python interrupts the return; a later close then completes the interrupted retirement of the Python owners without calling the native destruction again. A failed cleanup of an already finalized parent keeps its native handle owned, so a later close or runtime destroy can recover it.- Raises:
RuntimeError – The call comes from a serializer callback, or the cancel or the destruction fails. An unreported exception from a serializer callback is re-raised in its place.
- finish() None#
Join the worker and report its outcome; the terminal snapshots stay readable.
- Raises:
RuntimeError – The operation is closed, the call comes from its serializer callback, or the operation was cancelled or failed. An exception from a serializer callback is re-raised in its place.
- get_counts() tuple[int, int, bool]#
Return
(written, total, initialized); the counts start at zero.- Raises:
RuntimeError – The operation is closed or the native query fails.
- get_last_error() str#
Return the terminal diagnostic of the operation.
The diagnostic is empty while the worker runs and does not change once it is set.
- Raises:
RuntimeError – The operation is closed or the native query fails.
- get_step_data() PipelineStepData#
Return a snapshot of the current initialization, fetch or commit phase.
- Raises:
RuntimeError – The operation is closed or the native query fails.
- is_running() bool#
Return whether persistence or worker cleanup is still running.
A closed operation reports False.
- Raises:
RuntimeError – The native poll fails.
- ovclash.python.suite.run_ovstage_owner_operation(
- operation: Callable[[...], Any],
- /,
- *args: Any,
- **kwargs: Any,
Run owner SDK work under the process-wide ovstage lifecycle gate of clash.
Calls
operation(*args, **kwargs)synchronously on this thread while holding the gate. Acquire this gate before any owner lock. When other clash contexts share the process, route this work through it: Stage creation and destruction, population, source edits, inspection composition, and renderer attach, step and detach. Calls nest on one thread, up to 64 active operations.Inside the operation, every Suite call that reaches the native library fails, not only the clash runtime calls.
ClashQueryand the other model helpers, data stores, exports, and the timestamp and escape utilities fail too, although they touch no runtime. Only nestedrun_ovstage_owner_operation()calls and last-error reads are allowed.- Parameters:
operation – The callable to run.
*args – Positional arguments for
operation.**kwargs – Keyword arguments for
operation.
- Returns:
The return value of
operation, after the gate is released.- Raises:
TypeError –
operationis not callable.RuntimeError – The loaded backend lacks this optional extension, which only the ovstage backend exports. Also raised when the nesting limit is exceeded or the native gate fails.
BaseException – Any exception that
operationraised, re-raised with its original traceback after the gate is released.
Models#
The object model has two sides:
input: a query and its point-cloud settings;
results: clash records and per-frame records.
ExportColumnDef is the column definition that the export helpers take.
- class ovclash.python.suite.ClashQuery(
- identifier: int = -1,
- query_name: str = '',
- object_a_path: str = '',
- object_b_path: str = '',
- clash_detect_settings: dict[Any, Any] | None = None,
- creation_timestamp: datetime | None = None,
- last_modified_timestamp: datetime | None = None,
- last_modified_by: str = '',
- comment: str = '',
- roi_include_path: str = '',
- roi_exclude_path: str = '',
Bases:
objectA clash query: two scope paths, detection settings and workflow metadata.
Every change goes through a temporary native query model, and a change that the model rejects raises RuntimeError. Two queries are equal when their settings compare equal as Python values and the native model finds their other fields equal.
- Parameters:
identifier – Signed 64-bit persistent query identifier, or -1 for a new unsaved query. A value outside the signed 64-bit range raises OverflowError.
query_name – User-facing query name.
object_a_path – First scope path.
object_b_path – Second scope path.
clash_detect_settings – Mapping of
SettingIdmember names, such asSettingId.SETTING_TOLERANCE.name, to JSON-serializable values; None means an empty mapping. Integer or enum keys become decimal strings in JSON, and later settings lookups ignore them. A mapping that json cannot encode raises TypeError.creation_timestamp – Time the query was created; None uses the current time.
last_modified_timestamp – Time the query was last modified; None uses the current time.
last_modified_by – User name of the last modification; an empty string uses the current user name.
comment – Free-form query comment.
roi_include_path – Region-of-interest include path.
roi_exclude_path – Region-of-interest exclude path.
- VERSION = 5#
- property clash_detect_settings: Any#
Settings decoded from the stored JSON text.
Assigning None stores an empty mapping; a mapping json cannot encode raises TypeError.
- property comment: str#
Free-form query comment.
- property creation_timestamp: datetime#
Time the query was created; read-only.
- classmethod deserialize_from_dict(
- data: dict[str, Any],
- reset_identifier: bool = False,
Deserialize a query from the legacy dictionary format.
- Parameters:
data – Dictionary produced by
serialize_to_dict().reset_identifier – When True, reset the restored identifier to -1.
- Returns:
The query, or None for malformed data. An identifier outside the signed 64-bit range is malformed even when
reset_identifieris True.
- get_settings_as_str() str#
Return the clash detection settings as JSON text.
- Raises:
TypeError – The settings mapping cannot be encoded as JSON.
- property identifier: int#
Persistent query identifier, or -1 for an unsaved query.
Read-only;
reset_identifier()sets it to -1.
- property last_modified_by: str#
User name of the last modification; read-only.
update_last_modified_timestamp()sets it to the current user.
- property last_modified_timestamp: datetime#
Time the query was last modified.
- load_settings_from_str(settings_str: str) bool#
Load clash detection settings from JSON text.
This legacy helper reports empty or invalid JSON through its result instead of raising.
- Parameters:
settings_str – JSON object text, as
get_settings_as_str()produces it.- Returns:
True when native validation accepts the text and Python can decode it, otherwise False. Text nested deeper than the Python recursion limit passes native validation but returns False, because the Python copy of the settings cannot be decoded.
- property object_a_path: str#
First scope path.
- property object_b_path: str#
Second scope path.
- property query_name: str#
User-facing query name.
- reset_identifier() None#
Mark the query as unsaved by resetting its identifier to -1.
- property roi_exclude_path: str#
Region-of-interest exclude path.
- property roi_include_path: str#
Region-of-interest include path.
- serialize_to_dict() dict[str, Any]#
Serialize this query to the legacy dictionary format.
The keys are the underscore-prefixed attribute names that
deserialize_from_dict()reads.- Raises:
TypeError – The settings mapping cannot be encoded as JSON.
- update_last_modified_timestamp() None#
Update last-modified metadata to the current suite timestamp and user.
- class ovclash.python.suite.PointCloudSettings(
- identifier: int = -1,
- point_cloud_prim_path: str = '',
- destination_path: str = '',
- save_to_session_layer: bool = True,
- skip_rendering: bool = True,
- max_lod_level: int = 1000000,
Bases:
objectSerializable point-cloud generation settings.
Every change goes through a temporary native settings model, and a change that the model rejects raises RuntimeError.
- Parameters:
identifier – Persistent settings identifier, or -1 for a new unsaved record.
point_cloud_prim_path – Source point-cloud prim path.
destination_path – Destination path for generated data.
save_to_session_layer – Whether generated data is saved to the session layer.
skip_rendering – Whether rendering of the point cloud is skipped.
max_lod_level – Maximum level of detail, stored verbatim; no value has a special meaning. The default,
MAX_LOD_LEVEL(1000000), is effectively unlimited.
- MAX_LOD_LEVEL = 1000000#
- VERSION = 2#
- classmethod deserialize_from_dict(
- data: dict[str, Any],
- reset_identifier: bool = False,
Deserialize point-cloud settings from the legacy dictionary format.
- Parameters:
data – Dictionary produced by
serialize_to_dict().reset_identifier – When True, reset the restored identifier to -1.
- Returns:
The settings, or None for malformed data.
- property destination_path: str#
Destination path for generated data.
- property identifier: int#
Persistent settings identifier, or -1 for an unsaved record.
- property max_lod_level: int#
Maximum level of detail, stored verbatim.
No value has a special meaning, and the default
MAX_LOD_LEVELis effectively unlimited.
- property point_cloud_prim_path: str#
Source point-cloud prim path.
- reset_identifier() None#
Mark the settings record as unsaved by resetting its identifier to -1.
- property save_to_session_layer: bool#
Whether generated data is saved to the session layer.
- serialize_to_dict() dict[str, Any]#
Serialize this settings record to the legacy dictionary format.
The keys are the underscore-prefixed attribute names that
deserialize_from_dict()reads.
- property skip_rendering: bool#
Whether rendering of the point cloud is skipped.
- class ovclash.python.suite.ClashInfo(
- identifier: int = -1,
- query_id: int = 0,
- overlap_id: str = '',
- overlap_type: ~ovclash.python.suite.types.OverlapType = OverlapType.NORMAL,
- present: bool = True,
- min_distance: float = 0.0,
- max_local_depth: float = 0.0,
- depth_epsilon: float = -1.0,
- tolerance: float = 0.0,
- object_a_path: str = '',
- object_a_mesh_crc: str = '',
- object_b_path: str = '',
- object_b_mesh_crc: str = '',
- start_time: float = 0.0,
- end_time: float = 0.0,
- num_records: int = 0,
- overlap_elements: int = 0,
- state: ~ovclash.python.suite.types.ClashState = ClashState.NEW,
- priority: int = 0,
- person_in_charge: str = '',
- creation_timestamp: ~datetime.datetime = <factory>,
- last_modified_timestamp: ~datetime.datetime = <factory>,
- last_modified_by: str = '',
- comment: str = '',
- clash_frame_info_items: list[~ovclash.python.suite.types.ClashFrameInfo] | None = None,
- penetration_depth_px: float = -1.0,
- penetration_depth_nx: float = -1.0,
- penetration_depth_py: float = -1.0,
- penetration_depth_ny: float = -1.0,
- penetration_depth_pz: float = -1.0,
- penetration_depth_nz: float = -1.0,
Bases:
objectPersistent clash record with legacy aliases and workflow metadata.
Both timestamps default to the current Suite timestamp, and an empty
last_modified_bybecomes the current user name at construction. After construction these fields are read-only and assigning one raises AttributeError:identifier,query_id,overlap_id,overlap_type,present,min_distance,depth_epsilon,tolerance, theobject_a_*andobject_b_*fields,start_time,end_time,num_records,overlap_elements,creation_timestampandlast_modified_by. Assigningstate,priority,person_in_charge,comment,max_local_depthor apenetration_depth_*field refresheslast_modified_timestampandlast_modified_bythrough the native model. The underscore-prefixed legacy aliases, such as_state, bypass both rules.- EPSILON: ClassVar[float] = 1e-06#
- VERSION: ClassVar[int] = 18#
- check_object_a_matrix_changed(
- stage: Any,
- frame_info_index: int = 0,
Compare object A’s native runtime transform with the stored frame transform.
The stored frame’s
timecodeis a time in seconds. The runtime transform is read at the stage time code of that time, using the stage’s time-code rate, and compared withobject_0_matrixasClashFrameInfo.check_object_0_matrix_changed()does.- Parameters:
stage – A ClashDetection, or another object with a native
_handle, to query. Any other value, such as a legacy USD stage or None, falls back to the runtime that produced this record.frame_info_index – Index of the stored frame to compare.
- Returns:
True when the transforms differ. False when the frame does not exist, or when a runtime is available and
object_a_pathis empty.- Raises:
OverflowError –
frame_info_indexis negative or exceeds the uint32 range.RuntimeError – No live runtime is available, the stage’s time-code rate cannot be read or is not positive and finite, or the transform query fails.
- check_object_b_matrix_changed(
- stage: Any,
- frame_info_index: int = 0,
Compare object B’s native runtime transform with the stored frame transform.
The stored frame’s
timecodeis a time in seconds. The runtime transform is read at the stage time code of that time, using the stage’s time-code rate, and compared withobject_1_matrixasClashFrameInfo.check_object_1_matrix_changed()does.- Parameters:
stage – A ClashDetection, or another object with a native
_handle, to query. Any other value, such as a legacy USD stage or None, falls back to the runtime that produced this record.frame_info_index – Index of the stored frame to compare.
- Returns:
True when the transforms differ. False when the frame does not exist, or when a runtime is available and
object_b_pathis empty.- Raises:
OverflowError –
frame_info_indexis negative or exceeds the uint32 range.RuntimeError – No live runtime is available, the stage’s time-code rate cannot be read or is not positive and finite, or the transform query fails.
- clash_frame_info_items: list[ClashFrameInfo] | None = None#
- comment: str = ''#
- creation_timestamp: datetime#
- depth_epsilon: float = -1.0#
- classmethod deserialize_from_dict(
- data: dict[str, Any],
- reset_identifier: bool = False,
Deserialize a clash record from the legacy dictionary format.
- Parameters:
data – Dictionary produced by
serialize_to_dict(), keyed by the underscore-prefixed legacy attribute names.reset_identifier – When True, reset the restored identifier to -1.
- Returns:
The restored record, or None when
datais not a dict, a key does not name a record attribute, or restoring a value raises.
- end_time: float = 0.0#
- get_clash_frame_info(
- index: int,
Return a copy of the stored frame at
index, or None when there is none.A record with
num_records == 1and an empty frame list returns, for anyindex, a frame synthesized from the record’s start time, distances and element count. Otherwise None is returned whenclash_frame_info_itemsis None,indexis out of range, or the frame list length differs fromnum_records.- Raises:
OverflowError –
indexis negative or exceeds the uint32 range.
- get_frame_info_index_by_timecode(timecode: float) int#
Return the index of the stored frame whose
timecodeis nearest totimecode.Frames are assumed sorted by timecode. A tie selects the later frame, and a record without stored frames returns 0.
- get_last_clash_frame_info() ClashFrameInfo | None#
Return a copy of the frame at
num_records - 1, or None when there is none.The single-frame synthesis and the None cases of
get_clash_frame_info()apply.
- identifier: int = -1#
- property is_contact: bool#
True when the clash is a contact.
A contact is a NORMAL record with zero
min_distancewhosemax_local_depthis at mostdepth_epsilon, or exactly 0.0 whendepth_epsilonis not positive.
- property is_duplicate: bool#
True when this record represents a duplicate mesh pair.
- property is_hard_clash: bool#
True for a NORMAL record with zero
min_distancethat is not a contact.
- property is_point_cloud_clash: bool#
True when this record represents a point-cloud-vs-mesh clash.
- property is_soft_clash: bool#
True for a NORMAL record with a positive
min_distance.
- last_modified_by: str = ''#
- last_modified_timestamp: datetime#
- max_local_depth: float = 0.0#
- min_distance: float = 0.0#
- num_records: int = 0#
- object_a_mesh_crc: str = ''#
- object_a_path: str = ''#
- object_b_mesh_crc: str = ''#
- object_b_path: str = ''#
- overlap_elements: int = 0#
- overlap_id: str = ''#
- property overlap_points: int#
Number of overlapped point-cloud points.
overlap_elementsfor a POINT_CLOUD_MESH clash, otherwise 0.
- property overlap_tris: int#
Number of overlapped triangles.
overlap_elements, or 0 for a POINT_CLOUD_MESH clash.
- overlap_type: OverlapType = 1#
- penetration_depth_nx: float = -1.0#
- penetration_depth_ny: float = -1.0#
- penetration_depth_nz: float = -1.0#
- penetration_depth_px: float = -1.0#
- penetration_depth_py: float = -1.0#
- penetration_depth_pz: float = -1.0#
- person_in_charge: str = ''#
- present: bool = True#
- priority: int = 0#
- query_id: int = 0#
- reset_identifier() None#
Mark the clash record as unsaved by resetting its identifier to -1.
- serialize_to_dict() dict[str, Any]#
Serialize this clash record to the legacy dictionary format.
- start_time: float = 0.0#
- state: ClashState = 1#
- tolerance: float = 0.0#
- update_last_modified_timestamp() None#
Update last-modified metadata to the current suite timestamp and user.
- class ovclash.python.suite.ClashFrameInfo(
- timecode: float = 0.0,
- min_distance: float = 0.0,
- max_local_depth: float = -1.0,
- overlap_elements: int = 0,
- usd_faces_0: ~ovclash.python.suite.types.ArrayView = <factory>,
- usd_faces_1: ~ovclash.python.suite.types.ArrayView = <factory>,
- collision_outline: ~ovclash.python.suite.types.ArrayView = <factory>,
- object_0_matrix: ~typing.Any = <factory>,
- object_1_matrix: ~typing.Any = <factory>,
- usd_points_0: ~ovclash.python.suite.types.ArrayView = <factory>,
- usd_points_0_sizes: ~ovclash.python.suite.types.ArrayView = <factory>,
- penetration_depth_px: float = -1.0,
- penetration_depth_nx: float = -1.0,
- penetration_depth_py: float = -1.0,
- penetration_depth_ny: float = -1.0,
- penetration_depth_pz: float = -1.0,
- penetration_depth_nz: float = -1.0,
Bases:
objectPer-frame data of a clash record.
Each field can also be read and assigned under its legacy underscore-prefixed name, such as
_timecode.- EPSILON: ClassVar[float] = 1e-06#
- VERSION: ClassVar[int] = 7#
- check_object_0_matrix_changed(
- matrix: Any,
Return True unless every element of
matrixis within 1e-6 ofobject_0_matrix.This is the legacy
not Gf.IsClose(matrix, object_0_matrix, 1e-6), so NaN counts as changed. The native comparison fixes the tolerance at 1e-6.EPSILONonly mirrors it, and overriding it has no effect. Returns False whenmatrixor the storedobject_0_matrixis None.
- check_object_1_matrix_changed(
- matrix: Any,
Return True unless every element of
matrixis within 1e-6 ofobject_1_matrix.This is the legacy
not Gf.IsClose(matrix, object_1_matrix, 1e-6), so NaN counts as changed. The native comparison fixes the tolerance at 1e-6.EPSILONonly mirrors it, and overriding it has no effect. Returns False whenmatrixor the storedobject_1_matrixis None.
- classmethod deserialize_from_dict(
- data: dict[str, Any],
Deserialize a frame from the legacy dictionary format.
- Parameters:
data – Dictionary produced by
serialize_to_dict(), keyed by the underscore-prefixed legacy attribute names.- Returns:
The restored frame, or None when
datais not a dict, a key does not name a frame attribute, or restoring a value raises.
- max_local_depth: float = -1.0#
- min_distance: float = 0.0#
- object_0_matrix: Any#
- object_1_matrix: Any#
- overlap_elements: int = 0#
- property overlap_points: int#
Number of overlapped point-cloud points represented by this frame.
overlap_elementswhen the frame hasusd_points_0, otherwise 0.
- property overlap_tris: int#
Number of overlapped triangles represented by this frame.
overlap_elementswhen the frame has nousd_points_0, otherwise 0.
- penetration_depth_nx: float = -1.0#
- penetration_depth_ny: float = -1.0#
- penetration_depth_nz: float = -1.0#
- penetration_depth_px: float = -1.0#
- penetration_depth_py: float = -1.0#
- penetration_depth_pz: float = -1.0#
- serialize_to_dict() dict[str, Any]#
Serialize this frame to the legacy dictionary format.
- timecode: float = 0.0#
- class ovclash.python.suite.ExportColumnDef(order: int, name: str, alignment: bool = False)#
Bases:
objectColumn definition for the JSON and HTML table exporters.
- alignment: bool = False#
True right-aligns the column in HTML export; JSON export ignores it.
- name: str#
Column label.
- order: int#
Zero-based index of the cell this column reads within each row. Columns are emitted in list order;
orderdoes not reorder them. Must be less than the number of columns.
Persistence#
ClashData is the storage facade. It delegates to a serializer:
ClashDataSerializerSqlitestores all records in one SQLite.ovclashdbfile. Itsopen(),save()andsave_as()also accept a.clashDetectioncontainer, the Kit-era file that wraps a SQLite database behind a 16-byte header.ClashData()without an argument creates this serializer.ClashDataSerializerDirectorystores the same records as separate, readable JSON files in a directory.AbstractClashDataSerializeris the contract that a custom serializer implements. Both built-in serializers derive from it.
Persistence walks through the workflow. SQLite serializer and Directory serializer describe the two stores.
- class ovclash.python.suite.ClashData([clash_data_serializer])#
Bases:
objectHigh-level data facade for queries, overlaps, frames and point-cloud settings.
With either built-in serializer, a live fetch iterator rejects writes, commits and store lifecycle changes until it is exhausted or closed. Python reads return materialized values and release their native read cursors before they return. Cursors created directly through the C ABI still reject lifecycle changes until they are destroyed. A rejected cleanup keeps the serializer reference; close the dependents and retry. Custom serializers enforce their own lifetime rules. Serialize all calls that share the store; the guards do not make concurrent calls safe. Async fetching reserves reads as well and runs the storage work on its native worker.
The query, overlap, frame and point-cloud methods return the serializer’s result. Without an open store they return 0, an empty container or None.
Mutating methods take
commit(default True).commit=Falseleaves the write pending in the handle’s transaction untilcommit(),save(),close()or a later write withcommit=Truecommits it. With either built-in serializer, a later write that fails after its storage write began rolls back the whole pending transaction. That includes earliercommit=Falsewrites that returned successfully. A value that the store checks while writing can cause such a failure: a NaN REAL value with the SQLite serializer (the directory serializer stores NaN), a non-finite frame matrix or, with the directory serializer, a string that contains NUL. Other argument, open-state and not-found failures leave pending writes untouched. Validate inputs before a batch, or commit before a write that may fail.- Parameters:
clash_data_serializer – Serializer implementation. When omitted, a closed SQLite serializer handle is created through the Suite C ABI; call
open()before file-backed operations. None creates a facade without a store.
- CLASH_DATA_FILE_EXT = '.clashdata'#
Extension that the Kit extension gives the temporary database it extracts from such a container. This package extracts to a temporary
.ovclashdbinstead.
- CLASH_DATA_LAYER_CUSTOM_CLASH_DB_PATH = 'clashDbPath'#
customDatakey on the USD layer of a.clashDetectioncontainer that holds the path of the associated database. This package writes no USD, but readers of those layers need it.
- CLASH_DATA_LAYER_CUSTOM_MODIFIED = 'clashDbModified'#
customDatakey on the same layer that records whether the database has unsaved changes.
- CLASH_DATA_LAYER_FILE_EXT = '.clashDetection'#
Extension of the legacy container that
open(),save()andsave_as()of the SQLite serializer accept besides.ovclashdb.
- close() None#
Close the current store; built-in stores first attempt to commit pending writes.
Close fetch iterators first. Closing is not a request to discard pending work. When the commit of a built-in store fails, the store requests a rollback and raises, and it stays available for inspection or retry.
- Raises:
RuntimeError – A built-in store fails to commit or close.
- commit() None#
Commit pending changes of the current data store; without an open store, do nothing.
- property data_structures_compatible: bool#
Whether the schema of the current store is compatible; True without a serializer.
- property data_structures_migration_to_latest_version_possible: bool#
Whether the current store can migrate to the latest schema; True without a serializer.
- property deferred_file_creation_until_first_write_op: bool#
Whether file creation waits for the first write; False without a serializer.
- destroy() None#
Close the store and release this facade’s reference to it.
Built-in stores attempt to commit pending writes first. The native handle of the default serializer is destroyed too. A caller-supplied serializer is only closed; its caller still owns it. Close fetch iterators first. A rejected or failed cleanup propagates its error and keeps the serializer reference for inspection or retry.
- Raises:
RuntimeError – A built-in store rejects the cleanup or fails to commit or close.
- fetch_all_point_cloud_settings() dict[int, PointCloudSettings]#
Return all stored point-cloud settings keyed by identifier.
- Returns:
The settings, or an empty dictionary without an open store.
- fetch_all_queries() dict[int, ClashQuery]#
Return all stored queries keyed by identifier.
- Returns:
The queries, or an empty dictionary without an open store.
- fetch_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return the frames of one overlap, optionally a range of them.
- Parameters:
clash_info_id – Stored identifier of the overlap.
num_frames_to_load – Number of frames to load; -1 loads all.
first_frame_offset – Zero-based index of the first frame to load.
- Returns:
The frames in order, or an empty list without an open store.
- find_all_overlaps_by_overlap_id(
- overlap_id: Sequence[int],
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return stored overlaps by identifier, optionally with a range of their frames.
- Parameters:
overlap_id – Stored identifiers (
ClashInfo.identifier) of the overlaps.fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap; -1 loads all.
first_frame_offset – Zero-based index of the first frame to load.
- Returns:
The overlaps keyed by
overlap_id, or an empty dictionary without an open store.
- find_all_overlaps_by_query_id(
- clash_query_id: int,
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
- num_overlaps_to_load: int = -1,
- first_overlap_offset: int = 0,
Return the overlaps of a query, optionally with ranges of overlaps and frames.
- Parameters:
clash_query_id – Query identifier.
fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap; -1 loads all.
first_frame_offset – Zero-based index of the first frame to load.
num_overlaps_to_load – Number of overlaps to load; -1 loads all.
first_overlap_offset – Zero-based index of the first overlap to load.
- Returns:
The overlaps keyed by
overlap_id, or an empty dictionary without an open store.
- find_point_cloud_settings(
- point_cloud_settings_id: int,
Return point-cloud settings by identifier.
- Parameters:
point_cloud_settings_id – Identifier of the settings.
- Returns:
The settings, or None when they are not stored or no store is open.
- find_point_cloud_settings_by_destination_path(
- destination_path: str,
Return point-cloud settings by destination path.
- Parameters:
destination_path – Destination path for the generated data.
- Returns:
The settings, or None when none match or no store is open.
- find_point_cloud_settings_by_point_cloud_prim_path(
- point_cloud_prim_path: str,
Return point-cloud settings by source prim path.
- Parameters:
point_cloud_prim_path – Path of the source point-cloud prim.
- Returns:
The settings, or None when none match or no store is open.
- find_query(
- clash_query_id: int,
Return a query by identifier.
- Parameters:
clash_query_id – Query identifier.
- Returns:
The query, or None when it is not stored or no store is open.
- get_clash_frame_info_count_by_clash_info_id(
- clash_info_id: int,
Return the number of frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
- Returns:
The count, or 0 without an open store.
- get_overlaps_count_by_query_id(clash_query_id: int) int#
Return the number of overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
- Returns:
The count, or 0 without an open store.
- get_overlaps_count_by_query_id_grouped_by_state(
- clash_query_id: int,
Return the overlap counts of a query per
ClashState.- Parameters:
clash_query_id – Query identifier.
- Returns:
The counts, or an empty dictionary without an open store.
- insert_clash_frame_info(
- clash_frame_info: ClashFrameInfo,
- clash_info_id: int,
- commit: bool = True,
Insert one frame of an overlap.
- Parameters:
clash_frame_info – Frame to insert.
clash_info_id – Stored identifier of the overlap that owns the frame.
commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier of the frame, or 0 without an open store.
- insert_clash_frame_info_from_clash_info(
- clash_info: ClashInfo,
- commit: bool = True,
Insert the frames attached to a
ClashInfo.The built-in serializers replace every stored frame of the overlap.
- Parameters:
clash_info – Overlap whose
clash_frame_info_itemsare written for its identifier.commit – Commit the write. False leaves it pending.
- Returns:
The number of frames written, or 0 without an open store.
- insert_overlap(
- clash_info: ClashInfo,
- insert_also_frame_info: bool = True,
- update_identifier: bool = True,
- commit: bool = True,
Insert an overlap.
- Parameters:
clash_info – Overlap to insert.
insert_also_frame_info – Also insert the frames in
clash_info.clash_frame_info_items.update_identifier – Write the stored identifier back to
clash_info.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, or 0 without an open store.
- insert_point_cloud_settings(
- point_cloud_settings: PointCloudSettings,
- update_identifier: bool = True,
- commit: bool = True,
Insert point-cloud settings.
- Parameters:
point_cloud_settings – Settings to insert.
update_identifier – Write the stored identifier back to
point_cloud_settings.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, or 0 without an open store.
- insert_query(
- clash_query: ClashQuery,
- update_identifier: bool = True,
- commit: bool = True,
Insert a query.
- Parameters:
clash_query – Query to insert.
update_identifier – Write the stored identifier back to
clash_query.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, or 0 without an open store.
- is_open() bool#
Return True when a data store is open.
- last_error() str#
Return why the last failure reported without raising happened.
SQLite
open()leaves an incompatible database closed, andmigrate_data_structures_to_latest_version()returns False; neither raises. This method tells the caller why, so a silently closed store can be told apart from an empty one.- Returns:
The reason, or an empty string when the last such call succeeded. Serializers that track no reason, and a facade without a serializer, return an empty string.
- migrate_data_structures_to_latest_version(
- file_path_name: str,
Migrate a data store file to the latest supported schema.
- Parameters:
file_path_name – Store to migrate in place.
- Returns:
The serializer’s result, or False without a serializer. After False,
last_error()reports the reason when the serializer tracks one.
- open(file_path_name: str) None#
Open the store at
file_path_name, closing another open store first.Without a serializer, or with an empty path, the call does nothing. A relative path resolves against the current working directory at each call. The call also does nothing when the serializer’s absolute
serializer_pathalready names the resolved path; the built-in serializers provideserializer_path. Otherwise the open store is closed and the new one is opened. A store opened through a relative path may name a different store after a directory change, so it is always reopened, as is a store whose serializer has noserializer_path.- Parameters:
file_path_name – Path of the store to open.
- remove_all_overlaps_by_query_id(
- clash_query_id: int,
- commit: bool = True,
Remove all overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
The number of overlaps removed, or 0 without an open store.
- remove_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- commit: bool = True,
Remove all frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
The number of frames removed, or 0 without an open store.
- remove_overlap_by_id(
- overlap_id: int,
- commit: bool = True,
Remove one overlap by identifier.
- Parameters:
overlap_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 when the overlap is not stored or no store is open.
- remove_point_cloud_settings_by_id(
- point_cloud_settings_id: int,
- commit: bool = True,
Remove point-cloud settings by identifier.
- Parameters:
point_cloud_settings_id – Identifier of the settings.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 when the settings are not stored or no store is open.
- remove_query_by_id(
- query_id: int,
- commit: bool = True,
Remove a query by identifier.
- Parameters:
query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 when the query is not stored or no store is open.
- save(file_path_name: str | None = None) bool#
Save the current store, or save it to
file_path_namethroughsave_as().- Parameters:
file_path_name – Destination path. None or an empty string saves the store in place.
- Returns:
The serializer’s result, or False when no store is open.
- save_as(file_path_name: str) bool#
Save the current store to a new path.
- Parameters:
file_path_name – Destination path.
- Returns:
The serializer’s result. False for an empty path, without an open store, or when the serializer has no
save_as()method.
- saved() None#
Do nothing; legacy code calls this compatibility hook after external save handling.
- property serializer_path: str#
Path of the current serializer store, or an empty string.
- update_overlap(
- clash_info: ClashInfo,
- update_also_frame_info: bool = True,
- commit: bool = True,
Update a stored overlap.
- Parameters:
clash_info – Overlap to update, matched by its identifier.
update_also_frame_info – Also update the frames from
clash_info.clash_frame_info_items.commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 when the overlap is not stored or no store is open.
- update_point_cloud_settings(
- point_cloud_settings: PointCloudSettings,
- commit: bool = True,
Update stored point-cloud settings.
- Parameters:
point_cloud_settings – Settings to update, matched by their identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 when the settings are not stored or no store is open.
- update_query(
- clash_query: ClashQuery,
- commit: bool = True,
Update a stored query.
- Parameters:
clash_query – Query to update, matched by its identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 when the query is not stored or no store is open.
- class ovclash.python.suite.ClashDataSerializerSqlite#
SQLite Suite serializer that stores all records in one
.ovclashdbfile.It shares its native fetch and cursor lifetime rules with the directory serializer. It reads and writes legacy
.clashDetectioncontainers through the native import and export.- CLASH_DB_FILE_EXT = '.ovclashdb'#
Legacy alias of
SERIALIZED_FILE_EXT.
- FETCH_ABORT_OVERLAP = 6#
fetch_transaction()operation that returns to the restore point of an overlap.
- FETCH_BEGIN = 1#
fetch_transaction()operation that begins pending writes.
- FETCH_BEGIN_OVERLAP = 4#
fetch_transaction()operation that saves a restore point before an overlap is streamed.
- FETCH_COMMIT = 2#
fetch_transaction()operation that publishes the pending writes.
- FETCH_END_OVERLAP = 5#
fetch_transaction()operation that releases the restore point of an overlap.
- FETCH_ROLLBACK = 3#
fetch_transaction()operation that discards the whole pending transaction.
- SERIALIZED_FILE_EXT = '.ovclashdb'#
Extension of the store file that this serializer writes.
- SUPPORTED_CLASH_FRAME_INFO_VERSION = 7#
ClashFrameInfomodel version that this serializer stores.
- SUPPORTED_CLASH_INFO_VERSION = 18#
ClashInfomodel version that this serializer stores.
- SUPPORTED_CLASH_QUERY_VERSION = 5#
ClashQuerymodel version that this serializer stores.
- SUPPORTED_POINT_CLOUD_SETTINGS_VERSION = 2#
PointCloudSettingsmodel version that this serializer stores.
- check_compatibility_of_tables() bool#
Legacy alias of
data_structures_compatible().
- check_possibility_of_tables_migration() bool#
Legacy alias of
data_structures_migration_to_latest_version_possible().
- static check_serializer_compatibility_with_data_structures() bool#
Return True when the Python model versions match those this serializer supports.
- close() None#
Close the store after attempting to commit pending writes.
The pending writes include partial results kept from failed or abandoned fetches. Close fetch iterators first.
- Raises:
RuntimeError – The commit or the close fails. A failed commit requests a rollback, and the native handle stays available for cleanup or retry.
- commit() None#
Commit pending store changes.
Native read cursors alone do not block a commit.
- Raises:
RuntimeError – The native commit fails. A live native fetch rejects the commit, even after its final progress yield; exhaust or close the fetch iterator first.
- property compatible_with_data_structures: bool#
Legacy alias of
data_structures_compatible().
- data_structures_compatible() bool#
Return True when the schema of the current store is compatible.
- data_structures_migration_to_latest_version_possible() bool#
Return True when the current store can be migrated to the latest schema.
- property db_file_path_name: str#
Legacy alias of
get_file_path().
- property db_tables_compatible: bool#
Legacy alias of
data_structures_compatible().
- property db_tables_migration_possible: bool#
Legacy alias of
data_structures_migration_to_latest_version_possible().
- property deferred_db_creation_until_commit_query: bool#
Legacy alias of
deferred_file_creation_until_first_write_op().
- deferred_file_creation_until_first_write_op() bool#
Return True when store creation is deferred until the first write.
- destroy() None#
Release the native handle after attempting to commit pending writes.
A successful commit publishes the partial results kept after a failed or abandoned fetch. Close fetch iterators first. An explicit native failure keeps the handle for retry. A success, or an uncertain ctypes return, retires the handle before the result is checked.
- Raises:
RuntimeError – The commit or the close fails. A failed commit requests a rollback.
- fetch_all_point_cloud_settings() dict[int, PointCloudSettings]#
Return all stored point-cloud settings keyed by identifier.
The enumeration does not hold a snapshot across external writes, and a failed read never returns a partial inventory.
- Returns:
The settings; an empty dictionary for an empty or destroyed store.
- Raises:
RuntimeError – The count or a counted row cannot be read.
- fetch_all_queries() dict[int, ClashQuery]#
Return all stored queries keyed by identifier.
The enumeration does not hold a snapshot across external writes, and a failed read never returns a partial inventory.
- Returns:
The queries; an empty dictionary for an empty or destroyed store.
- Raises:
RuntimeError – The count or a counted row cannot be read.
- fetch_append_frame(
- identifier: int,
- frame: ClashFrameInfo,
Append one owned frame without committing; raise on failure.
The frame arrays are copied from the borrowed native report before this hook runs, so the serializer may keep the frame. Calls arrive in source order.
- Parameters:
identifier – Stored identifier of the overlap.
frame – Frame to append.
- fetch_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return the frames of one overlap, optionally a range of them.
- Parameters:
clash_info_id – Stored identifier of the overlap.
num_frames_to_load – Number of frames to load; -1 loads all, and 0 or another negative count loads none.
first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
- Returns:
The frames in order; an empty list for a destroyed store.
- Raises:
RuntimeError – A native read fails.
- fetch_clear_frames(identifier: int) None#
Remove the frames of one overlap without committing; raise on failure.
- Parameters:
identifier – Stored identifier of the overlap.
- fetch_find_overlap(
- query_id: int,
- overlap_id: str,
Return one stored overlap header by query and hash.
The header needs no frames. While neither this hook nor
fetch_write_overlap()is overridden, the adapter snapshots the query’s headers once per fetch operation and serves keys not yet written from that snapshot. A lookup of a key written during the fetch reloads its header by stable identifier, so normalization by the CRUD methods stays visible; if the identity changed, the adapter refreshes the snapshot. Overriding this hook or the write hook keeps lookups live. An indexed override helps stores with many existing rows.Native fetching preserves review metadata. With state updates enabled, recurring clashes become Active, except Approved clashes whose detected header and complete ordered frame contents are identical; those stay Approved.
- Parameters:
query_id – Query identifier.
overlap_id – Overlap hash.
- Returns:
The header, or None when the query has no overlap with that hash. Its identifier must be an integer in the signed 64-bit range other than -1.
- fetch_iter_saved_frames(
- identifier: int,
- first_frame_offset: int = 0,
Read the owned saved frames of one overlap lazily through one forward native cursor.
Exhaust or close the iterator before the store is closed or reopened, and serialize calls on the same handle. Each frame owns its payload, so it stays valid after the cursor advances or closes.
- Parameters:
identifier – Stored identifier of the overlap.
first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
- Returns:
An iterator over the frames, in order.
- fetch_mark_absent(
- identifier: int,
- resolve: bool,
Mark a vanished overlap absent, and optionally RESOLVED, without changing its frames.
- Parameters:
identifier – Stored identifier of the overlap.
resolve – Also set the state to RESOLVED.
- Raises:
RuntimeError – The default implementation cannot find or update the stored overlap.
- fetch_transaction(operation: int) None#
Execute one
FETCH_*transaction operation, or raise.Custom fetching requires an override; the default raises NotImplementedError.
FETCH_BEGINbegins pending writes and is idempotent.FETCH_COMMITpublishes the pending writes.FETCH_ROLLBACKdiscards the whole pending transaction, including earlier batches and unrelated uncommitted changes. The fetch requests it after a serializer or saved-result reader callback fails while the fetch advances.FETCH_BEGIN_OVERLAPsaves a restore point before an incomplete overlap is streamed.FETCH_END_OVERLAPreleases that restore point.FETCH_ABORT_OVERLAPreturns to the restore point and keeps earlier completed pending writes.
An initialization failure leaves pre-existing writes pending. An extraction or preparation failure requests
FETCH_ABORT_OVERLAPonly for an incomplete streamed overlap, and a failed abort falls back toFETCH_ROLLBACK; otherwise earlier completed writes stay pending. Closing an unfinished iterator follows the same abort and fallback rules and reports a cleanup failure.The fetch calls
FETCH_BEGINbefore the finalFETCH_COMMIT, even for an empty result, so a successful fetch publishes pre-existing writes too. It requests a full rollback at most once, so the rollback need not be idempotent. A failed rollback cannot guarantee recovery, and a failure after the side effects of a custom commit may leave durable changes even when the callback raises.Fetch-and-save is therefore not all-or-nothing in every case. A serializer must implement these semantics; the base class cannot emulate a rollback with CRUD calls.
- Parameters:
operation – One of the
FETCH_*constants of this class.- Raises:
NotImplementedError – The serializer does not override this method.
- fetch_visit_existing(
- query_id: int,
Return the stored overlap identifiers of a query without loading frames.
The native fetch calls this once when it begins. The default delegates to
find_all_overlaps_by_query_id(); a store with an identifier cursor should override it. A store that allows several rows with the same overlap hash must override it, because the hash-keyed CRUD mapping exposes only one identifier per hash.- Parameters:
query_id – Query identifier.
- Returns:
The identifiers, each an integer in the signed 64-bit range other than the unsaved sentinel -1.
- fetch_write_overlap(
- clash_info: ClashInfo,
Write one overlap header without committing and return its stable identifier.
Leave the existing frames untouched, and do not create placeholder frames from
num_records. TheClashInfoowns its strings and carries no frame payload.- Parameters:
clash_info – Header to write. An identifier of -1 inserts a new overlap; any other identifier updates the stored one.
- Returns:
The stored identifier, an integer in the signed 64-bit range other than the unsaved sentinel -1.
- Raises:
RuntimeError – The default implementation finds no stored overlap to update.
- find_all_overlaps_by_overlap_id(
- overlap_id: Iterable[int],
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return stored overlaps by identifier, optionally with a range of their frames.
- Parameters:
overlap_id – Stored identifiers (
ClashInfo.identifier) of the overlaps. Identifiers that are not stored are skipped.fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap with
fetch_also_frame_info; -1 loads all, and 0 or another negative count loads none.first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
- Returns:
The overlaps keyed by
overlap_id; an empty dictionary for a destroyed store.- Raises:
RuntimeError – A native read fails.
- find_all_overlaps_by_query_id(
- clash_query_id: int,
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
- num_overlaps_to_load: int = -1,
- first_overlap_offset: int = 0,
Return the overlaps of a query, optionally with ranges of overlaps and frames.
- Parameters:
clash_query_id – Query identifier.
fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap with
fetch_also_frame_info; -1 loads all, and 0 or another negative count loads none.first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
num_overlaps_to_load – Number of overlaps to load; -1 loads all, and 0 or another negative count loads none.
first_overlap_offset – Zero-based index of the first overlap; a negative offset counts as zero.
- Returns:
The overlaps keyed by
overlap_id; an empty dictionary for a destroyed store.- Raises:
RuntimeError – A native read fails.
- find_point_cloud_settings(
- identifier: int,
Return point-cloud settings by identifier.
- Parameters:
identifier – Identifier of the settings.
- Returns:
The settings, or None when they are not stored or the store is destroyed.
- Raises:
RuntimeError – The native lookup fails.
- find_point_cloud_settings_by_destination_path(
- destination_path: str,
Return point-cloud settings by destination path.
- Parameters:
destination_path – Destination path for the generated data.
- Returns:
The settings, or None when none match or the store is destroyed.
- Raises:
RuntimeError – The native lookup fails.
- find_point_cloud_settings_by_point_cloud_prim_path(
- point_cloud_prim_path: str,
Return point-cloud settings by source prim path.
- Parameters:
point_cloud_prim_path – Path of the source point-cloud prim.
- Returns:
The settings, or None when none match or the store is destroyed.
- Raises:
RuntimeError – The native lookup fails.
- find_query(
- clash_query_id: int,
Return a query by identifier.
- Parameters:
clash_query_id – Query identifier.
- Returns:
The query, or None when it is not stored or the store is destroyed.
- Raises:
OverflowError – The identifier is outside the signed 64-bit range.
RuntimeError – The native lookup fails.
- get_clash_frame_info_count_by_clash_info_id(
- clash_info_id: int,
Return the number of frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
- Returns:
The count, or 0 for a destroyed store.
- get_file_path() str#
Return the store path, which stays set after close.
- Returns:
The path, or an empty string for an unnamed or destroyed store.
- Raises:
RuntimeError – The native path query fails.
- get_file_size() int#
Return the on-disk size of an open named store in bytes.
The size of a directory store counts every regular file under its root, including exports and internal files.
- Returns:
The size in bytes, or 0 for a destroyed serializer.
- Raises:
RuntimeError – The store is unnamed or closed, or the filesystem query fails.
- get_overlaps_count_by_query_id(
- clash_query_id: int,
Return the number of overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
- Returns:
The count, or 0 for a destroyed store.
- get_overlaps_count_by_query_id_grouped_by_state(
- clash_query_id: int,
Return the overlap counts of a query per
ClashState.Stored states that name no
ClashStatecount as NEW. States without overlaps are absent.- Parameters:
clash_query_id – Query identifier.
- Returns:
The counts; an empty dictionary for a destroyed store.
- insert_clash_frame_info(
- clash_frame_info: ClashFrameInfo | None,
- clash_info_id: int,
- commit: bool = True,
Insert one frame of an overlap.
- Parameters:
clash_frame_info – Frame to insert; None inserts nothing.
clash_info_id – Stored identifier of the overlap that owns the frame.
commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier of the frame, or 0 for None or a destroyed store.
- Raises:
RuntimeError – The native insert fails.
- insert_clash_frame_info_from_clash_info(
- clash_info: ClashInfo | None,
- commit: bool = True,
Replace the stored frames of an overlap with those attached to
clash_info.One bulk call writes every frame in
clash_info.clash_frame_info_itemsforclash_info.identifierand removes the frames stored before.- Parameters:
clash_info – Overlap that carries the frames; None writes nothing.
commit – Commit the write. False leaves it pending.
- Returns:
The number of frames written, or 0 for None or a destroyed store.
- Raises:
ValueError – The C ABI cannot represent a frame; nothing is written.
RuntimeError – The store rejects the replacement.
- insert_overlap(
- clash_info: ClashInfo | None,
- insert_also_frame_info: bool = True,
- update_identifier: bool = True,
- commit: bool = True,
Insert an overlap.
The frames are checked before anything is written, so a frame that the C ABI cannot represent raises ValueError and leaves the store and
clash_infounchanged. With frames, the header is written uncommitted and the frame replace appliescommitto both. A frame write that the store rejects, such as a non-finite matrix or a storage error, therefore rolls the header back with it. A frame count above the materialization limit of the store is rejected before that write begins and leaves the header pending.clash_inforeceives its identifier only after success.- Parameters:
clash_info – Overlap to insert; None inserts nothing.
insert_also_frame_info – Also insert the frames in
clash_info.clash_frame_info_items.update_identifier – Write the stored identifier back to
clash_info.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, or 0 for None or a destroyed store.
- Raises:
ValueError – The C ABI cannot represent a frame.
RuntimeError – The store rejects the header or the frames.
- insert_point_cloud_settings(
- settings: PointCloudSettings | None,
- update_identifier: bool = True,
- commit: bool = True,
Insert point-cloud settings.
- Parameters:
settings – Settings to insert; None inserts nothing.
update_identifier – Write the stored identifier back to
settings.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, or 0 for None or a destroyed store.
- Raises:
RuntimeError – The native insert fails.
- insert_query(
- clash_query: ClashQuery | None,
- update_identifier: bool = True,
- commit: bool = True,
Insert a query.
- Parameters:
clash_query – Query to insert; None inserts nothing.
update_identifier – Write the stored identifier back to
clash_query.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier. 0 for None, for a destroyed store, or when the insert fails on a store that is not open.
- Raises:
RuntimeError – The insert fails on an open store.
- is_open() bool#
Return True when a store is open.
- last_error() str#
Return why the last failure reported without raising happened.
Two methods of this class report failure by returning instead of raising.
open()leaves an incompatible SQLite store closed, for reference parity, and callers inspectis_open().migrate_data_structures_to_latest_version()returns False. Both record the reason that the C ABI produced, so a caller can tell an old-schema store from an empty one, and both clear it when they succeed.The result is the reason recorded by those calls, not the raw last-error text of the handle. The native error is sticky: it survives a later successful call, so reading it directly can report a stale failure as a current one.
- Returns:
The reason, or an empty string when the last such call succeeded.
- migrate_data_structures_to_latest_version(
- file_path_name: str,
Migrate an existing store to the latest supported schema.
file_path_namenames the store to migrate in place; it is not an output path. Migration never creates a missing file, so a path that does not exist yet fails. To put a migrated store somewhere new, migrate the current one and then callsave_as().A directory store validates and reopens the current format; no older directory format can be migrated. An invalid destination manifest leaves the current directory open with its pending writes. A SQLite path that is missing, is not a readable regular file, or names a SQLite file that this process cannot write leaves the open state and the pending writes of the current store unchanged. So does an empty path on a store without a current path, such as an unnamed store.
Migration only reads a
.clashDetectioncontainer. Passing its path extracts it again to a new temporary copy and deletes any earlier copy of the store. Writes to that earlier copy are lost unless they were exported to the container first. An empty path uses the cached path, which names the container afteropen()until asave()orsave_as()succeeds. To keep those writes, migrate the path of the copy, fromget_file_path(), instead.- Parameters:
file_path_name – Store to migrate, or an empty string for the cached path.
- Returns:
True after a successful migration. False otherwise, never an exception; then
last_error()says why.
- property on_modified_fnc: Callable[[str], None] | None#
Callback that runs after modifying operations, or None.
- open(file_path_name: str) None#
Open a store path through the Suite C ABI.
A SQLite store opens a legacy
.clashDetectioncontainer through the native layer, which extracts it to a temporary.ovclashdbfile and opens that file.save()andsave_as()can target either a plain.ovclashdbfile or a legacy.clashDetectioncontainer. A directory store treats every path as a directory, whatever its suffix. An empty path opens an unnamed store;is_open()reports its native state even thoughget_file_path()is empty. Unnamed stores support CRUD and async fetching.For legacy SQLite compatibility, an incompatible database does not raise. The store stays closed and
last_error()records the reason; callers inspectis_open(),data_structures_compatible()anddata_structures_migration_to_latest_version_possible().- Parameters:
file_path_name – Path of the store, or an empty string for an unnamed store.
- Raises:
RuntimeError – The open fails for another reason. A live fetch also rejects the open and keeps the current handle and cached path; exhaust or close the iterator before retrying.
- remove_all_overlaps_by_query_id(
- clash_query_id: int,
- commit: bool = True,
Remove all overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
The number of overlaps removed, or 0 for a destroyed store.
- Raises:
RuntimeError – The native removal fails.
- remove_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- commit: bool = True,
Remove all frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
The number of frames removed, or 0 for a destroyed store.
- Raises:
RuntimeError – The native removal fails.
- remove_overlap_by_id(
- overlap_id: int,
- commit: bool = True,
Remove one overlap by identifier.
- Parameters:
overlap_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 for a destroyed store or when the overlap is not stored.
- Raises:
RuntimeError – The native lookup or removal fails.
- remove_point_cloud_settings_by_id(
- identifier: int,
- commit: bool = True,
Remove point-cloud settings by identifier.
- Parameters:
identifier – Identifier of the settings.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 for a destroyed store or when the settings are not stored.
- Raises:
RuntimeError – The native lookup or removal fails.
- remove_query_by_id(
- query_id: int,
- commit: bool = True,
Remove a query by identifier.
- Parameters:
query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 for a destroyed store or when the query is not stored.
- Raises:
OverflowError – The identifier is outside the signed 64-bit range.
RuntimeError – The native lookup or removal fails.
- save(
- file_path_name: str | None = None,
Save the current store, optionally to a new destination.
Without a destination,
save()passes the cached path and the store commits its pending writes. Afteropen()ormigrate_data_structures_to_latest_version()of a.clashDetectioncontainer, the cached path names the container, so the nextsave()exports to it again. That stops once asave()orsave_as()succeeds, because each success caches the native path, such as the path of the temporary copy. Pass the container path tosave_as()to export again.With a different destination, a SQLite store is backed up there, including committed WAL rows and pending writes. A deferred store whose file does not exist yet adopts the new path instead. A
.clashDetectiondestination receives an exported snapshot, and the current store keeps its path, even the empty path of an unnamed store. After a success, the cached path is read back from the native state.- Parameters:
file_path_name – Destination path. None uses the cached path.
- Returns:
True; failures raise RuntimeError.
- Raises:
RuntimeError – The save fails. A live fetch also rejects the save, and the previous cached path is kept.
- save_as(file_path_name: str) bool#
Save the current store to a new path.
A directory store adopts the target after a successful save. A SQLite store has the native layer back up its database, named or unnamed, and adopts an ordinary destination after success. An existing alias of the current file keeps its identity; a private legacy extraction may move to the new destination after its connection closes. A
.clashDetectiontarget receives a fresh, closed SQLite snapshot, and the source connection and path stay unchanged. After a success, the cached path is read back from the native handle, even the empty path of an unnamed store.- Parameters:
file_path_name – Destination path.
- Returns:
True; failures raise RuntimeError.
- Raises:
RuntimeError – The save fails. A live fetch also rejects the save without changing the current handle or cached path; exhaust or close dependent iterators first.
- saved() None#
Do nothing; legacy code calls this compatibility hook after external save handling.
- property serializer_path: str#
Store path, kept after close; empty for an unnamed or destroyed store.
- set_deferred_file_creation_until_first_write_op(
- value: bool,
Set whether store creation is deferred until the first write.
A destroyed serializer ignores the call.
- Parameters:
value – True defers the store creation.
- Raises:
RuntimeError – The native call fails.
- set_on_modified_fnc(
- on_modified_fnc: Callable[[str], None] | None,
Set the callback that receives the serializer path after each modifying operation.
- Parameters:
on_modified_fnc – Callback, or None to remove it.
- update_overlap(
- clash_info: ClashInfo | None,
- update_also_frame_info: bool = True,
- commit: bool = True,
Update a stored overlap.
The frames are checked before anything is written. With frames, the updated header is written uncommitted and the frame replace applies
committo both, as ininsert_overlap().- Parameters:
clash_info – Overlap to update, matched by its identifier; None updates nothing.
update_also_frame_info – Also replace the stored frames with
clash_info.clash_frame_info_items.commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 for None, for a destroyed store, or when the overlap is not stored.
- Raises:
ValueError – The C ABI cannot represent a frame.
RuntimeError – The store rejects the header or the frames.
- update_point_cloud_settings(
- settings: PointCloudSettings | None,
- commit: bool = True,
Update stored point-cloud settings.
- Parameters:
settings – Settings to update, matched by their identifier; None updates nothing.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 for None, for a destroyed store, or when the settings are not stored.
- Raises:
RuntimeError – The native lookup or update fails.
- update_query(
- clash_query: ClashQuery | None,
- commit: bool = True,
Update a stored query.
- Parameters:
clash_query – Query to update, matched by its identifier; None updates nothing.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 for None, for a destroyed store, or when the query is not stored.
- Raises:
RuntimeError – The native lookup or update fails.
- class ovclash.python.suite.ClashDataSerializerDirectory#
Directory Suite serializer that stores readable JSON records instead of a SQLite database.
Pass a directory path to
open(); a suffix is part of the directory name. Queries, point-cloud settings, clashes and individual frames go to separate JSON files.commit=Falsekeeps edits pending until commit, save or close. Deferred creation leaves a missing directory absent until the first write.open("")opens an unnamed store. Its private temporary directory is created at the first write when creation is deferred, the default, and at open otherwise. Closing the unnamed store removes that directory;save_as(path)keeps its records in a named directory and makes that directory current.Pass an instance to
ClashData(serializer), or directly to the runtime fetch-and-save. Both built-in serializers follow the same native fetch and cursor lifetime rules. Serialize access to one store, and close live fetch iterators before a commit or a lifecycle change.- FETCH_ABORT_OVERLAP = 6#
fetch_transaction()operation that returns to the restore point of an overlap.
- FETCH_BEGIN = 1#
fetch_transaction()operation that begins pending writes.
- FETCH_BEGIN_OVERLAP = 4#
fetch_transaction()operation that saves a restore point before an overlap is streamed.
- FETCH_COMMIT = 2#
fetch_transaction()operation that publishes the pending writes.
- FETCH_END_OVERLAP = 5#
fetch_transaction()operation that releases the restore point of an overlap.
- FETCH_ROLLBACK = 3#
fetch_transaction()operation that discards the whole pending transaction.
- SERIALIZED_FILE_EXT = ''#
Empty, because a directory store has no file extension.
- SUPPORTED_CLASH_FRAME_INFO_VERSION = 7#
ClashFrameInfomodel version that this serializer stores.
- SUPPORTED_CLASH_INFO_VERSION = 18#
ClashInfomodel version that this serializer stores.
- SUPPORTED_CLASH_QUERY_VERSION = 5#
ClashQuerymodel version that this serializer stores.
- SUPPORTED_POINT_CLOUD_SETTINGS_VERSION = 2#
PointCloudSettingsmodel version that this serializer stores.
- check_compatibility_of_tables() bool#
Legacy alias of
data_structures_compatible().
- check_possibility_of_tables_migration() bool#
Legacy alias of
data_structures_migration_to_latest_version_possible().
- static check_serializer_compatibility_with_data_structures() bool#
Return True when the Python model versions match those this serializer supports.
- close() None#
Close the store after attempting to commit pending writes.
The pending writes include partial results kept from failed or abandoned fetches. Close fetch iterators first.
- Raises:
RuntimeError – The commit or the close fails. A failed commit requests a rollback, and the native handle stays available for cleanup or retry.
- commit() None#
Commit pending store changes.
Native read cursors alone do not block a commit.
- Raises:
RuntimeError – The native commit fails. A live native fetch rejects the commit, even after its final progress yield; exhaust or close the fetch iterator first.
- property compatible_with_data_structures: bool#
Legacy alias of
data_structures_compatible().
- data_structures_compatible() bool#
Return True when the schema of the current store is compatible.
- data_structures_migration_to_latest_version_possible() bool#
Return True when the current store can be migrated to the latest schema.
- property db_file_path_name: str#
Legacy alias of
get_file_path().
- property db_tables_compatible: bool#
Legacy alias of
data_structures_compatible().
- property db_tables_migration_possible: bool#
Legacy alias of
data_structures_migration_to_latest_version_possible().
- property deferred_db_creation_until_commit_query: bool#
Legacy alias of
deferred_file_creation_until_first_write_op().
- deferred_file_creation_until_first_write_op() bool#
Return True when store creation is deferred until the first write.
- destroy() None#
Release the native handle after attempting to commit pending writes.
A successful commit publishes the partial results kept after a failed or abandoned fetch. Close fetch iterators first. An explicit native failure keeps the handle for retry. A success, or an uncertain ctypes return, retires the handle before the result is checked.
- Raises:
RuntimeError – The commit or the close fails. A failed commit requests a rollback.
- fetch_all_point_cloud_settings() dict[int, PointCloudSettings]#
Return all stored point-cloud settings keyed by identifier.
The enumeration does not hold a snapshot across external writes, and a failed read never returns a partial inventory.
- Returns:
The settings; an empty dictionary for an empty or destroyed store.
- Raises:
RuntimeError – The count or a counted row cannot be read.
- fetch_all_queries() dict[int, ClashQuery]#
Return all stored queries keyed by identifier.
The enumeration does not hold a snapshot across external writes, and a failed read never returns a partial inventory.
- Returns:
The queries; an empty dictionary for an empty or destroyed store.
- Raises:
RuntimeError – The count or a counted row cannot be read.
- fetch_append_frame(
- identifier: int,
- frame: ClashFrameInfo,
Append one owned frame without committing; raise on failure.
The frame arrays are copied from the borrowed native report before this hook runs, so the serializer may keep the frame. Calls arrive in source order.
- Parameters:
identifier – Stored identifier of the overlap.
frame – Frame to append.
- fetch_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return the frames of one overlap, optionally a range of them.
- Parameters:
clash_info_id – Stored identifier of the overlap.
num_frames_to_load – Number of frames to load; -1 loads all, and 0 or another negative count loads none.
first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
- Returns:
The frames in order; an empty list for a destroyed store.
- Raises:
RuntimeError – A native read fails.
- fetch_clear_frames(
- identifier: int,
Remove the frames of one overlap without committing; raise on failure.
- Parameters:
identifier – Stored identifier of the overlap.
- fetch_find_overlap(
- query_id: int,
- overlap_id: str,
Return one stored overlap header by query and hash.
The header needs no frames. While neither this hook nor
fetch_write_overlap()is overridden, the adapter snapshots the query’s headers once per fetch operation and serves keys not yet written from that snapshot. A lookup of a key written during the fetch reloads its header by stable identifier, so normalization by the CRUD methods stays visible; if the identity changed, the adapter refreshes the snapshot. Overriding this hook or the write hook keeps lookups live. An indexed override helps stores with many existing rows.Native fetching preserves review metadata. With state updates enabled, recurring clashes become Active, except Approved clashes whose detected header and complete ordered frame contents are identical; those stay Approved.
- Parameters:
query_id – Query identifier.
overlap_id – Overlap hash.
- Returns:
The header, or None when the query has no overlap with that hash. Its identifier must be an integer in the signed 64-bit range other than -1.
- fetch_iter_saved_frames(
- identifier: int,
- first_frame_offset: int = 0,
Read the owned saved frames of one overlap lazily through one forward native cursor.
Exhaust or close the iterator before the store is closed or reopened, and serialize calls on the same handle. Each frame owns its payload, so it stays valid after the cursor advances or closes.
- Parameters:
identifier – Stored identifier of the overlap.
first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
- Returns:
An iterator over the frames, in order.
- fetch_mark_absent(
- identifier: int,
- resolve: bool,
Mark a vanished overlap absent, and optionally RESOLVED, without changing its frames.
- Parameters:
identifier – Stored identifier of the overlap.
resolve – Also set the state to RESOLVED.
- Raises:
RuntimeError – The default implementation cannot find or update the stored overlap.
- fetch_transaction(operation: int) None#
Execute one
FETCH_*transaction operation, or raise.Custom fetching requires an override; the default raises NotImplementedError.
FETCH_BEGINbegins pending writes and is idempotent.FETCH_COMMITpublishes the pending writes.FETCH_ROLLBACKdiscards the whole pending transaction, including earlier batches and unrelated uncommitted changes. The fetch requests it after a serializer or saved-result reader callback fails while the fetch advances.FETCH_BEGIN_OVERLAPsaves a restore point before an incomplete overlap is streamed.FETCH_END_OVERLAPreleases that restore point.FETCH_ABORT_OVERLAPreturns to the restore point and keeps earlier completed pending writes.
An initialization failure leaves pre-existing writes pending. An extraction or preparation failure requests
FETCH_ABORT_OVERLAPonly for an incomplete streamed overlap, and a failed abort falls back toFETCH_ROLLBACK; otherwise earlier completed writes stay pending. Closing an unfinished iterator follows the same abort and fallback rules and reports a cleanup failure.The fetch calls
FETCH_BEGINbefore the finalFETCH_COMMIT, even for an empty result, so a successful fetch publishes pre-existing writes too. It requests a full rollback at most once, so the rollback need not be idempotent. A failed rollback cannot guarantee recovery, and a failure after the side effects of a custom commit may leave durable changes even when the callback raises.Fetch-and-save is therefore not all-or-nothing in every case. A serializer must implement these semantics; the base class cannot emulate a rollback with CRUD calls.
- Parameters:
operation – One of the
FETCH_*constants of this class.- Raises:
NotImplementedError – The serializer does not override this method.
- fetch_visit_existing(
- query_id: int,
Return the stored overlap identifiers of a query without loading frames.
The native fetch calls this once when it begins. The default delegates to
find_all_overlaps_by_query_id(); a store with an identifier cursor should override it. A store that allows several rows with the same overlap hash must override it, because the hash-keyed CRUD mapping exposes only one identifier per hash.- Parameters:
query_id – Query identifier.
- Returns:
The identifiers, each an integer in the signed 64-bit range other than the unsaved sentinel -1.
- fetch_write_overlap(
- clash_info: ClashInfo,
Write one overlap header without committing and return its stable identifier.
Leave the existing frames untouched, and do not create placeholder frames from
num_records. TheClashInfoowns its strings and carries no frame payload.- Parameters:
clash_info – Header to write. An identifier of -1 inserts a new overlap; any other identifier updates the stored one.
- Returns:
The stored identifier, an integer in the signed 64-bit range other than the unsaved sentinel -1.
- Raises:
RuntimeError – The default implementation finds no stored overlap to update.
- find_all_overlaps_by_overlap_id(
- overlap_id: Iterable[int],
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return stored overlaps by identifier, optionally with a range of their frames.
- Parameters:
overlap_id – Stored identifiers (
ClashInfo.identifier) of the overlaps. Identifiers that are not stored are skipped.fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap with
fetch_also_frame_info; -1 loads all, and 0 or another negative count loads none.first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
- Returns:
The overlaps keyed by
overlap_id; an empty dictionary for a destroyed store.- Raises:
RuntimeError – A native read fails.
- find_all_overlaps_by_query_id(
- clash_query_id: int,
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
- num_overlaps_to_load: int = -1,
- first_overlap_offset: int = 0,
Return the overlaps of a query, optionally with ranges of overlaps and frames.
- Parameters:
clash_query_id – Query identifier.
fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap with
fetch_also_frame_info; -1 loads all, and 0 or another negative count loads none.first_frame_offset – Zero-based index of the first frame; a negative offset counts as zero.
num_overlaps_to_load – Number of overlaps to load; -1 loads all, and 0 or another negative count loads none.
first_overlap_offset – Zero-based index of the first overlap; a negative offset counts as zero.
- Returns:
The overlaps keyed by
overlap_id; an empty dictionary for a destroyed store.- Raises:
RuntimeError – A native read fails.
- find_point_cloud_settings(
- identifier: int,
Return point-cloud settings by identifier.
- Parameters:
identifier – Identifier of the settings.
- Returns:
The settings, or None when they are not stored or the store is destroyed.
- Raises:
RuntimeError – The native lookup fails.
- find_point_cloud_settings_by_destination_path(
- destination_path: str,
Return point-cloud settings by destination path.
- Parameters:
destination_path – Destination path for the generated data.
- Returns:
The settings, or None when none match or the store is destroyed.
- Raises:
RuntimeError – The native lookup fails.
- find_point_cloud_settings_by_point_cloud_prim_path(
- point_cloud_prim_path: str,
Return point-cloud settings by source prim path.
- Parameters:
point_cloud_prim_path – Path of the source point-cloud prim.
- Returns:
The settings, or None when none match or the store is destroyed.
- Raises:
RuntimeError – The native lookup fails.
- find_query(
- clash_query_id: int,
Return a query by identifier.
- Parameters:
clash_query_id – Query identifier.
- Returns:
The query, or None when it is not stored or the store is destroyed.
- Raises:
OverflowError – The identifier is outside the signed 64-bit range.
RuntimeError – The native lookup fails.
- get_clash_frame_info_count_by_clash_info_id(
- clash_info_id: int,
Return the number of frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
- Returns:
The count, or 0 for a destroyed store.
- get_file_path() str#
Return the store path, which stays set after close.
- Returns:
The path, or an empty string for an unnamed or destroyed store.
- Raises:
RuntimeError – The native path query fails.
- get_file_size() int#
Return the on-disk size of an open named store in bytes.
The size of a directory store counts every regular file under its root, including exports and internal files.
- Returns:
The size in bytes, or 0 for a destroyed serializer.
- Raises:
RuntimeError – The store is unnamed or closed, or the filesystem query fails.
- get_overlaps_count_by_query_id(
- clash_query_id: int,
Return the number of overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
- Returns:
The count, or 0 for a destroyed store.
- get_overlaps_count_by_query_id_grouped_by_state(
- clash_query_id: int,
Return the overlap counts of a query per
ClashState.Stored states that name no
ClashStatecount as NEW. States without overlaps are absent.- Parameters:
clash_query_id – Query identifier.
- Returns:
The counts; an empty dictionary for a destroyed store.
- insert_clash_frame_info(
- clash_frame_info: ClashFrameInfo | None,
- clash_info_id: int,
- commit: bool = True,
Insert one frame of an overlap.
- Parameters:
clash_frame_info – Frame to insert; None inserts nothing.
clash_info_id – Stored identifier of the overlap that owns the frame.
commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier of the frame, or 0 for None or a destroyed store.
- Raises:
RuntimeError – The native insert fails.
- insert_clash_frame_info_from_clash_info(
- clash_info: ClashInfo | None,
- commit: bool = True,
Replace the stored frames of an overlap with those attached to
clash_info.One bulk call writes every frame in
clash_info.clash_frame_info_itemsforclash_info.identifierand removes the frames stored before.- Parameters:
clash_info – Overlap that carries the frames; None writes nothing.
commit – Commit the write. False leaves it pending.
- Returns:
The number of frames written, or 0 for None or a destroyed store.
- Raises:
ValueError – The C ABI cannot represent a frame; nothing is written.
RuntimeError – The store rejects the replacement.
- insert_overlap(
- clash_info: ClashInfo | None,
- insert_also_frame_info: bool = True,
- update_identifier: bool = True,
- commit: bool = True,
Insert an overlap.
The frames are checked before anything is written, so a frame that the C ABI cannot represent raises ValueError and leaves the store and
clash_infounchanged. With frames, the header is written uncommitted and the frame replace appliescommitto both. A frame write that the store rejects, such as a non-finite matrix or a storage error, therefore rolls the header back with it. A frame count above the materialization limit of the store is rejected before that write begins and leaves the header pending.clash_inforeceives its identifier only after success.- Parameters:
clash_info – Overlap to insert; None inserts nothing.
insert_also_frame_info – Also insert the frames in
clash_info.clash_frame_info_items.update_identifier – Write the stored identifier back to
clash_info.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, or 0 for None or a destroyed store.
- Raises:
ValueError – The C ABI cannot represent a frame.
RuntimeError – The store rejects the header or the frames.
- insert_point_cloud_settings(
- settings: PointCloudSettings | None,
- update_identifier: bool = True,
- commit: bool = True,
Insert point-cloud settings.
- Parameters:
settings – Settings to insert; None inserts nothing.
update_identifier – Write the stored identifier back to
settings.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, or 0 for None or a destroyed store.
- Raises:
RuntimeError – The native insert fails.
- insert_query(
- clash_query: ClashQuery | None,
- update_identifier: bool = True,
- commit: bool = True,
Insert a query.
- Parameters:
clash_query – Query to insert; None inserts nothing.
update_identifier – Write the stored identifier back to
clash_query.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier. 0 for None, for a destroyed store, or when the insert fails on a store that is not open.
- Raises:
RuntimeError – The insert fails on an open store.
- is_open() bool#
Return True when the store is open, including an unnamed temporary store.
- last_error() str#
Return why the last failure reported without raising happened.
Two methods of this class report failure by returning instead of raising.
open()leaves an incompatible SQLite store closed, for reference parity, and callers inspectis_open().migrate_data_structures_to_latest_version()returns False. Both record the reason that the C ABI produced, so a caller can tell an old-schema store from an empty one, and both clear it when they succeed.The result is the reason recorded by those calls, not the raw last-error text of the handle. The native error is sticky: it survives a later successful call, so reading it directly can report a stale failure as a current one.
- Returns:
The reason, or an empty string when the last such call succeeded.
- migrate_data_structures_to_latest_version(
- file_path_name: str,
Migrate an existing store to the latest supported schema.
file_path_namenames the store to migrate in place; it is not an output path. Migration never creates a missing file, so a path that does not exist yet fails. To put a migrated store somewhere new, migrate the current one and then callsave_as().A directory store validates and reopens the current format; no older directory format can be migrated. An invalid destination manifest leaves the current directory open with its pending writes. A SQLite path that is missing, is not a readable regular file, or names a SQLite file that this process cannot write leaves the open state and the pending writes of the current store unchanged. So does an empty path on a store without a current path, such as an unnamed store.
Migration only reads a
.clashDetectioncontainer. Passing its path extracts it again to a new temporary copy and deletes any earlier copy of the store. Writes to that earlier copy are lost unless they were exported to the container first. An empty path uses the cached path, which names the container afteropen()until asave()orsave_as()succeeds. To keep those writes, migrate the path of the copy, fromget_file_path(), instead.- Parameters:
file_path_name – Store to migrate, or an empty string for the cached path.
- Returns:
True after a successful migration. False otherwise, never an exception; then
last_error()says why.
- property on_modified_fnc: Callable[[str], None] | None#
Callback that runs after modifying operations, or None.
- open(file_path_name: str) None#
Open a store path through the Suite C ABI.
A SQLite store opens a legacy
.clashDetectioncontainer through the native layer, which extracts it to a temporary.ovclashdbfile and opens that file.save()andsave_as()can target either a plain.ovclashdbfile or a legacy.clashDetectioncontainer. A directory store treats every path as a directory, whatever its suffix. An empty path opens an unnamed store;is_open()reports its native state even thoughget_file_path()is empty. Unnamed stores support CRUD and async fetching.For legacy SQLite compatibility, an incompatible database does not raise. The store stays closed and
last_error()records the reason; callers inspectis_open(),data_structures_compatible()anddata_structures_migration_to_latest_version_possible().- Parameters:
file_path_name – Path of the store, or an empty string for an unnamed store.
- Raises:
RuntimeError – The open fails for another reason. A live fetch also rejects the open and keeps the current handle and cached path; exhaust or close the iterator before retrying.
- remove_all_overlaps_by_query_id(
- clash_query_id: int,
- commit: bool = True,
Remove all overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
The number of overlaps removed, or 0 for a destroyed store.
- Raises:
RuntimeError – The native removal fails.
- remove_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- commit: bool = True,
Remove all frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
The number of frames removed, or 0 for a destroyed store.
- Raises:
RuntimeError – The native removal fails.
- remove_overlap_by_id(
- overlap_id: int,
- commit: bool = True,
Remove one overlap by identifier.
- Parameters:
overlap_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 for a destroyed store or when the overlap is not stored.
- Raises:
RuntimeError – The native lookup or removal fails.
- remove_point_cloud_settings_by_id(
- identifier: int,
- commit: bool = True,
Remove point-cloud settings by identifier.
- Parameters:
identifier – Identifier of the settings.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 for a destroyed store or when the settings are not stored.
- Raises:
RuntimeError – The native lookup or removal fails.
- remove_query_by_id(
- query_id: int,
- commit: bool = True,
Remove a query by identifier.
- Parameters:
query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal. 0 for a destroyed store or when the query is not stored.
- Raises:
OverflowError – The identifier is outside the signed 64-bit range.
RuntimeError – The native lookup or removal fails.
- save(
- file_path_name: str | None = None,
Commit the current directory, or save it to another destination.
An omitted or empty destination keeps the current directory, even after the working directory changes. An explicit relative path resolves against the current working directory.
- Parameters:
file_path_name – Destination directory. None or an empty string commits in place.
- Returns:
True; failures raise RuntimeError.
- Raises:
RuntimeError – The save fails, or a live fetch rejects it.
- save_as(file_path_name: str) bool#
Save the current store to a new path.
A directory store adopts the target after a successful save. A SQLite store has the native layer back up its database, named or unnamed, and adopts an ordinary destination after success. An existing alias of the current file keeps its identity; a private legacy extraction may move to the new destination after its connection closes. A
.clashDetectiontarget receives a fresh, closed SQLite snapshot, and the source connection and path stay unchanged. After a success, the cached path is read back from the native handle, even the empty path of an unnamed store.- Parameters:
file_path_name – Destination path.
- Returns:
True; failures raise RuntimeError.
- Raises:
RuntimeError – The save fails. A live fetch also rejects the save without changing the current handle or cached path; exhaust or close dependent iterators first.
- saved() None#
Do nothing; legacy code calls this compatibility hook after external save handling.
- property serializer_path: str#
Store path, kept after close; empty for an unnamed or destroyed store.
- set_deferred_file_creation_until_first_write_op(
- value: bool,
Set whether store creation is deferred until the first write.
A destroyed serializer ignores the call.
- Parameters:
value – True defers the store creation.
- Raises:
RuntimeError – The native call fails.
- set_on_modified_fnc(
- on_modified_fnc: Callable[[str], None] | None,
Set the callback that receives the serializer path after each modifying operation.
- Parameters:
on_modified_fnc – Callback, or None to remove it.
- update_overlap(
- clash_info: ClashInfo | None,
- update_also_frame_info: bool = True,
- commit: bool = True,
Update a stored overlap.
The frames are checked before anything is written. With frames, the updated header is written uncommitted and the frame replace applies
committo both, as ininsert_overlap().- Parameters:
clash_info – Overlap to update, matched by its identifier; None updates nothing.
update_also_frame_info – Also replace the stored frames with
clash_info.clash_frame_info_items.commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 for None, for a destroyed store, or when the overlap is not stored.
- Raises:
ValueError – The C ABI cannot represent a frame.
RuntimeError – The store rejects the header or the frames.
- update_point_cloud_settings(
- settings: PointCloudSettings | None,
- commit: bool = True,
Update stored point-cloud settings.
- Parameters:
settings – Settings to update, matched by their identifier; None updates nothing.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 for None, for a destroyed store, or when the settings are not stored.
- Raises:
RuntimeError – The native lookup or update fails.
- update_query(
- clash_query: ClashQuery | None,
- commit: bool = True,
Update a stored query.
- Parameters:
clash_query – Query to update, matched by its identifier; None updates nothing.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update. 0 for None, for a destroyed store, or when the query is not stored.
- Raises:
RuntimeError – The native lookup or update fails.
- class ovclash.python.suite.AbstractClashDataSerializer#
Bases:
ABCPersistence contract that
ClashDatauses for a custom serializer.An implementation stores queries, overlaps, frames and point-cloud settings, and keeps the shape of the legacy Suite Python API.
Native fetching calls the
fetch_*hooks below. By default they run synchronously on the caller’s thread; async fetching runs them on its background worker instead. Progress, modification and timing notifications stay on the thread that advances the generator. The native runtime owns report extraction, ordering and result reconciliation.Fetching into a custom serializer requires an override of
fetch_transaction()with real transaction and savepoint semantics; without one, fetching raises NotImplementedError. Override the other hooks when their default adapters over the CRUD methods are inefficient for your store.Persisted identifiers that the hooks return must fit a signed 64-bit integer and must not be -1, which
ClashInforeserves for a new unsaved record. The default fetch adapters require the CRUD methods to raise on persistence errors. If a store reports failures through ambiguous return values, override the matching fetch hook and raise there instead, because zero can be a valid identifier or a count of deleted frames.- FETCH_ABORT_OVERLAP = 6#
fetch_transaction()operation that returns to the restore point of an overlap.
- FETCH_BEGIN = 1#
fetch_transaction()operation that begins pending writes.
- FETCH_BEGIN_OVERLAP = 4#
fetch_transaction()operation that saves a restore point before an overlap is streamed.
- FETCH_COMMIT = 2#
fetch_transaction()operation that publishes the pending writes.
- FETCH_END_OVERLAP = 5#
fetch_transaction()operation that releases the restore point of an overlap.
- FETCH_ROLLBACK = 3#
fetch_transaction()operation that discards the whole pending transaction.
- abstract close() None#
Close the current serializer store.
- abstract commit() None#
Commit pending serializer changes.
- abstract data_structures_compatible() bool#
Return True when the open store matches the supported schema versions.
- abstract data_structures_migration_to_latest_version_possible() bool#
Return True when the open store can be migrated to the latest schema.
- abstract deferred_file_creation_until_first_write_op() bool#
Return True when file creation is deferred until the first write operation.
- abstract fetch_all_point_cloud_settings() dict[int, PointCloudSettings]#
Return all stored point-cloud settings keyed by identifier.
- abstract fetch_all_queries() dict[int, ClashQuery]#
Return all stored queries keyed by identifier.
- fetch_append_frame(
- identifier: int,
- frame: ClashFrameInfo,
Append one owned frame without committing; raise on failure.
The frame arrays are copied from the borrowed native report before this hook runs, so the serializer may keep the frame. Calls arrive in source order.
- Parameters:
identifier – Stored identifier of the overlap.
frame – Frame to append.
- abstract fetch_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return the frames of one overlap, optionally a range of them.
- Parameters:
clash_info_id – Stored identifier of the overlap.
num_frames_to_load – Number of frames to load; -1 loads all.
first_frame_offset – Zero-based index of the first frame to load.
- Returns:
The frames in order.
- fetch_clear_frames(
- identifier: int,
Remove the frames of one overlap without committing; raise on failure.
- Parameters:
identifier – Stored identifier of the overlap.
- fetch_find_overlap(
- query_id: int,
- overlap_id: str,
Return one stored overlap header by query and hash.
The header needs no frames. While neither this hook nor
fetch_write_overlap()is overridden, the adapter snapshots the query’s headers once per fetch operation and serves keys not yet written from that snapshot. A lookup of a key written during the fetch reloads its header by stable identifier, so normalization by the CRUD methods stays visible; if the identity changed, the adapter refreshes the snapshot. Overriding this hook or the write hook keeps lookups live. An indexed override helps stores with many existing rows.Native fetching preserves review metadata. With state updates enabled, recurring clashes become Active, except Approved clashes whose detected header and complete ordered frame contents are identical; those stay Approved.
- Parameters:
query_id – Query identifier.
overlap_id – Overlap hash.
- Returns:
The header, or None when the query has no overlap with that hash. Its identifier must be an integer in the signed 64-bit range other than -1.
- fetch_iter_saved_frames(
- identifier: int,
- first_frame_offset: int = 0,
Read the saved frames of one overlap in order for the exact Approved comparison.
The frames are owned and start at the zero-based
first_frame_offset; a negative offset counts as zero. The adapter holds one frame at a time. Before a write or a transaction, and when the fetch is abandoned, it closes the iterator if the iterator hasclose(). After an intervening write it may reopen the iterator at a nonzero offset. Stores whose ranged reads scan the skipped rows should override this with a forward cursor; this compatibility default requests one frame per ranged CRUD call.- Parameters:
identifier – Stored identifier of the overlap.
first_frame_offset – Zero-based index of the first frame.
- Yields:
The saved frames, in order.
- Raises:
RuntimeError – A ranged read of the default implementation returns several frames.
- fetch_mark_absent(
- identifier: int,
- resolve: bool,
Mark a vanished overlap absent, and optionally RESOLVED, without changing its frames.
- Parameters:
identifier – Stored identifier of the overlap.
resolve – Also set the state to RESOLVED.
- Raises:
RuntimeError – The default implementation cannot find or update the stored overlap.
- fetch_transaction(operation: int) None#
Execute one
FETCH_*transaction operation, or raise.Custom fetching requires an override; the default raises NotImplementedError.
FETCH_BEGINbegins pending writes and is idempotent.FETCH_COMMITpublishes the pending writes.FETCH_ROLLBACKdiscards the whole pending transaction, including earlier batches and unrelated uncommitted changes. The fetch requests it after a serializer or saved-result reader callback fails while the fetch advances.FETCH_BEGIN_OVERLAPsaves a restore point before an incomplete overlap is streamed.FETCH_END_OVERLAPreleases that restore point.FETCH_ABORT_OVERLAPreturns to the restore point and keeps earlier completed pending writes.
An initialization failure leaves pre-existing writes pending. An extraction or preparation failure requests
FETCH_ABORT_OVERLAPonly for an incomplete streamed overlap, and a failed abort falls back toFETCH_ROLLBACK; otherwise earlier completed writes stay pending. Closing an unfinished iterator follows the same abort and fallback rules and reports a cleanup failure.The fetch calls
FETCH_BEGINbefore the finalFETCH_COMMIT, even for an empty result, so a successful fetch publishes pre-existing writes too. It requests a full rollback at most once, so the rollback need not be idempotent. A failed rollback cannot guarantee recovery, and a failure after the side effects of a custom commit may leave durable changes even when the callback raises.Fetch-and-save is therefore not all-or-nothing in every case. A serializer must implement these semantics; the base class cannot emulate a rollback with CRUD calls.
- Parameters:
operation – One of the
FETCH_*constants of this class.- Raises:
NotImplementedError – The serializer does not override this method.
- fetch_visit_existing(
- query_id: int,
Return the stored overlap identifiers of a query without loading frames.
The native fetch calls this once when it begins. The default delegates to
find_all_overlaps_by_query_id(); a store with an identifier cursor should override it. A store that allows several rows with the same overlap hash must override it, because the hash-keyed CRUD mapping exposes only one identifier per hash.- Parameters:
query_id – Query identifier.
- Returns:
The identifiers, each an integer in the signed 64-bit range other than the unsaved sentinel -1.
- fetch_write_overlap(
- clash_info: ClashInfo,
Write one overlap header without committing and return its stable identifier.
Leave the existing frames untouched, and do not create placeholder frames from
num_records. TheClashInfoowns its strings and carries no frame payload.- Parameters:
clash_info – Header to write. An identifier of -1 inserts a new overlap; any other identifier updates the stored one.
- Returns:
The stored identifier, an integer in the signed 64-bit range other than the unsaved sentinel -1.
- Raises:
RuntimeError – The default implementation finds no stored overlap to update.
- abstract find_all_overlaps_by_overlap_id(
- overlap_id: Sequence[int],
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Return stored overlaps by identifier, optionally with a range of their frames.
- Parameters:
overlap_id – Stored identifiers (
ClashInfo.identifier) of the overlaps.fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap; -1 loads all.
first_frame_offset – Zero-based index of the first frame to load.
- Returns:
The overlaps keyed by
overlap_id.
- abstract find_all_overlaps_by_query_id(
- clash_query_id: int,
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
- num_overlaps_to_load: int = -1,
- first_overlap_offset: int = 0,
Return the overlaps of a query, optionally with ranges of overlaps and frames.
- Parameters:
clash_query_id – Query identifier.
fetch_also_frame_info – Also load the frames of each overlap.
num_frames_to_load – Number of frames to load per overlap; -1 loads all.
first_frame_offset – Zero-based index of the first frame to load.
num_overlaps_to_load – Number of overlaps to load; -1 loads all.
first_overlap_offset – Zero-based index of the first overlap to load.
- Returns:
The overlaps keyed by
overlap_id.
- abstract find_point_cloud_settings(
- point_cloud_settings_id: int,
Return point-cloud settings by identifier.
- Parameters:
point_cloud_settings_id – Identifier of the settings.
- Returns:
The settings, or None when they are not stored.
- abstract find_point_cloud_settings_by_destination_path(
- destination_path: str,
Return point-cloud settings by destination path.
- Parameters:
destination_path – Destination path for the generated data.
- Returns:
The settings, or None when none match.
- abstract find_point_cloud_settings_by_point_cloud_prim_path(
- point_cloud_prim_path: str,
Return point-cloud settings by source prim path.
- Parameters:
point_cloud_prim_path – Path of the source point-cloud prim.
- Returns:
The settings, or None when none match.
- abstract find_query(
- clash_query_id: int,
Return a query by identifier.
- Parameters:
clash_query_id – Query identifier.
- Returns:
The query, or None when it is not stored.
- abstract get_clash_frame_info_count_by_clash_info_id(
- clash_info_id: int,
Return the number of frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
- abstract get_file_path() str#
Return the path of the open store.
- abstract get_file_size() int#
Return the size of the open store in bytes.
- abstract get_overlaps_count_by_query_id(
- clash_query_id: int,
Return the number of overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
- abstract get_overlaps_count_by_query_id_grouped_by_state(
- clash_query_id: int,
Return the overlap counts of a query per
ClashState.- Parameters:
clash_query_id – Query identifier.
- abstract insert_clash_frame_info(
- clash_frame_info: ClashFrameInfo,
- clash_info_id: int,
- commit: bool,
Insert one frame of an overlap.
- Parameters:
clash_frame_info – Frame to insert.
clash_info_id – Stored identifier of the overlap that owns the frame.
commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier of the frame.
- abstract insert_clash_frame_info_from_clash_info(
- clash_info: ClashInfo,
- commit: bool,
Insert the frames attached to a
ClashInfo.- Parameters:
clash_info – Overlap whose
clash_frame_info_itemsare written for its identifier.commit – Commit the write. False leaves it pending.
- Returns:
The number of frames written.
- abstract insert_overlap(
- clash_info: ClashInfo,
- insert_also_frame_info: bool,
- update_identifier: bool,
- commit: bool,
Insert an overlap.
- Parameters:
clash_info – Overlap to insert.
insert_also_frame_info – Also insert the frames in
clash_info.clash_frame_info_items.update_identifier – Write the stored identifier back to
clash_info.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier, which the default
fetch_write_overlap()relies on.
- abstract insert_point_cloud_settings(
- point_cloud_settings: PointCloudSettings,
- update_identifier: bool,
- commit: bool,
Insert point-cloud settings.
- Parameters:
point_cloud_settings – Settings to insert.
update_identifier – Write the stored identifier back to
point_cloud_settings.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier.
- abstract insert_query(
- clash_query: ClashQuery,
- update_identifier: bool,
- commit: bool,
Insert a query.
- Parameters:
clash_query – Query to insert.
update_identifier – Write the stored identifier back to
clash_query.commit – Commit the write. False leaves it pending.
- Returns:
The stored identifier.
- abstract is_open() bool#
Return True when a serializer store is open.
- last_error() str#
Return why the last failure reported without raising happened.
The method is not abstract, so a serializer that tracks no reason keeps working and reports none.
- Returns:
The reason, or an empty string when the last such call succeeded.
- abstract migrate_data_structures_to_latest_version(
- file_path_name: str,
Migrate the store at
file_path_nameto the latest supported schema.The migration happens in place:
file_path_nameis not an output path, and migration never creates a missing file. Report a failure through the result andlast_error()instead of raising.- Parameters:
file_path_name – Store to migrate.
- Returns:
True after a successful migration, otherwise False.
- property on_modified_fnc: Callable[[str], None] | None#
Callback that runs after modifying operations, or None.
- abstract open(file_path_name: str) None#
Open the store at
file_path_name.- Parameters:
file_path_name – Path of the store to open.
- abstract remove_all_overlaps_by_query_id(
- clash_query_id: int,
- commit: bool,
Remove all overlaps of a query.
- Parameters:
clash_query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
The number of overlaps removed.
- abstract remove_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- commit: bool,
Remove all frames of one overlap.
- Parameters:
clash_info_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
The number of frames removed.
- abstract remove_overlap_by_id(
- overlap_id: int,
- commit: bool,
Remove one overlap by identifier.
- Parameters:
overlap_id – Stored identifier of the overlap.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal, 0 when the overlap is not stored.
- abstract remove_point_cloud_settings_by_id(
- point_cloud_settings_id: int,
- commit: bool,
Remove point-cloud settings by identifier.
- Parameters:
point_cloud_settings_id – Identifier of the settings.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal, 0 when the settings are not stored.
- abstract remove_query_by_id(
- query_id: int,
- commit: bool,
Remove a query by identifier.
- Parameters:
query_id – Query identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the removal, 0 when the query is not stored.
- abstract save() bool#
Save the current serializer store.
- Returns:
True when the store was saved.
- abstract set_deferred_file_creation_until_first_write_op(
- value: bool,
Set whether file creation is deferred until the first write operation.
- Parameters:
value – True defers the file creation.
- set_on_modified_fnc(
- on_modified_fnc: Callable[[str], None] | None,
Set the callback that receives the serializer path after each modifying operation.
- Parameters:
on_modified_fnc – Callback, or None to remove it.
- abstract update_overlap(
- clash_info: ClashInfo,
- update_also_frame_info: bool,
- commit: bool,
Update a stored overlap.
- Parameters:
clash_info – Overlap to update, matched by its identifier.
update_also_frame_info – Also update the frames from
clash_info.clash_frame_info_items.commit – Commit the write. False leaves it pending.
- Returns:
1 after the update, 0 when the overlap is not stored. The default
fetch_write_overlap()andfetch_mark_absent()raise on 0.
- abstract update_point_cloud_settings(
- point_cloud_settings: PointCloudSettings,
- commit: bool,
Update stored point-cloud settings.
- Parameters:
point_cloud_settings – Settings to update, matched by their identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update, 0 when the settings are not stored.
- abstract update_query(
- clash_query: ClashQuery,
- commit: bool,
Update a stored query.
- Parameters:
clash_query – Query to update, matched by its identifier.
commit – Commit the write. False leaves it pending.
- Returns:
1 after the update, 0 when the query is not stored.
- ovclash.python.suite.serializer_data_op(
- fnc: Callable[[...], Any],
Mark a
ClashDatamethod as a serializer data operation.The decorator appends
fnctoSerializer_data_operationsand returns it unchanged.- Parameters:
fnc – Method to mark.
- Returns:
fncitself.
- ovclash.python.suite.Serializer_data_operations#
A list of the
ClashDatamethods thatserializer_data_opmarks, as function objects. The decorator appends each method when theClashDataclass body runs. The list is public becauseomni.physxclashdetectioncore.clash_datare-exports it.
Export helpers#
Export shows how columns and rows map to the JSON and HTML output.
- ovclash.python.suite.export_to_json(
- column_defs: Iterable[ExportColumnDef],
- rows: Iterable[Iterable[Any]],
- additional_info: dict[str, Any] | None = None,
Serialize rows to JSON with the Suite C exporter.
- Parameters:
column_defs – Columns, emitted in this order. The
orderof each column selects the zero-based cell it reads within every row; it does not reorder the columns.rows – Rows of cell values, each holding exactly one value per column. Cells are converted with
str(), and None becomes an empty string.additional_info – Optional metadata name/value pairs included in the export, converted with
str()like the cells.
- Returns:
The UTF-8 encoded JSON document.
- Raises:
ValueError – A row does not hold one value per column, or a column order is outside the uint32 range.
RuntimeError – The native exporter rejects the input, for example a column order that is not less than the number of columns.
- ovclash.python.suite.export_to_html(
- title: str,
- subtitle: str,
- column_defs: Iterable[ExportColumnDef],
- rows: Iterable[Iterable[Any]],
- additional_info: dict[str, Any] | None = None,
Serialize rows to an HTML document with the Suite C exporter.
- Parameters:
title – HTML document title.
subtitle – HTML document subtitle.
column_defs – Columns, emitted in this order. The
orderof each column selects the zero-based cell it reads within every row, andalignmentright-aligns it.rows – Rows of cell values, each holding exactly one value per column. Cells are converted with
str(), and None becomes an empty string.additional_info – Optional metadata name/value pairs included in the export, converted with
str()like the cells.
- Returns:
The UTF-8 encoded HTML document.
- Raises:
ValueError – A row does not hold one value per column, or a column order is outside the uint32 range.
RuntimeError – The native exporter rejects the input, for example a column order that is not less than the number of columns.
- ovclash.python.suite.html_escape(text: str) str#
Escape text with the HTML escaping rules of the Suite export layer.
Replaces
&,<,>,"and'with&,<,>,"and', and leaves other characters unchanged.- Parameters:
text – The text to escape. A non-string value is converted with
str(), and None becomes an empty string.- Returns:
The escaped text.
- Raises:
RuntimeError – The native call fails.
- ovclash.python.suite.format_int128_hex(hi: int, lo: int) str#
Format unsigned high and low 64-bit words as a Suite clash-id hexadecimal string.
The result is
0xfollowed by lowercase hexadecimal digits without leading zeros, so zero formats as0x0.- Parameters:
hi – The high 64-bit word.
lo – The low 64-bit word.
- Returns:
The hexadecimal string.
- Raises:
RuntimeError – The native call fails.
- ovclash.python.suite.make_int128(hi: int, lo: int) int#
Combine unsigned high and low 64-bit words into one 128-bit integer.
The words are not range-checked.
lomust be in[0, 2**64)for the result to equalhi * 2**64 + lo.- Parameters:
hi – The high 64-bit word.
lo – The low 64-bit word.
- Returns:
The combined integer.
System helpers#
These functions wrap Suite C ABI entry points: backend information, the current
user name, file operations and the .clashDetection container probe.
- ovclash.python.suite.backend_info() ovclash.python.suite.types.BackendInfo#
Return the backend name and compile-time capability flags of the loaded native library.
- Returns:
The backend information.
- Raises:
RuntimeError – The native query fails.
- ovclash.python.suite.current_user_name() str#
Return the user name that Suite metadata such as
last_modified_byrecords.The name comes from
LOGNAME,USER,LNAMEorUSERNAME, in that order, and then from the OS account: the password database entry of the real user ID on POSIX,GetUserNameWon Windows. A value that is not valid UTF-8 is skipped.- Returns:
The user name, or an empty string when no source qualifies.
- Raises:
RuntimeError – The native query fails.
- ovclash.python.suite.file_exists(path: str) bool#
Return whether
pathnames a regular file, following symbolic links.This matches
os.path.isfile: an empty or missing path, a directory, another file type or a path that contains a NUL character reports False.- Parameters:
path – Filesystem path to test.
- Returns:
True for a regular file.
- Raises:
RuntimeError – The native query fails.
- ovclash.python.suite.copy_file(
- source_path: str,
- target_path: str,
- follow_symlinks: bool = True,
Copy a file with
shutil.copysemantics using the suite C ABI.A directory target receives the copy under the source’s file name, and an existing target file is overwritten. The source’s permission bits are then applied to the target. With
follow_symlinks=Falsea symbolic-link source is recreated as a link, which fails when the target already exists.- Parameters:
source_path – Source filesystem path.
target_path – Destination filesystem path.
follow_symlinks – When True, copy the linked target for symbolic links.
- Returns:
True when the copy and the permission copy both succeeded. False for an empty path, a missing or directory source, a failed copy, or a failed permission copy, which leaves the target already written.
- Raises:
RuntimeError – A path contains a NUL character; nothing is copied.
- ovclash.python.suite.delete_file(path: str) bool#
Delete a non-directory entry with
os.removesemantics using the suite C ABI.Symbolic links are not followed: a link is removed, never its target.
- Parameters:
path – Filesystem path to delete.
- Returns:
True when an entry was removed. False for an empty or missing path, a directory, or a failed removal.
- Raises:
RuntimeError – The path contains a NUL character; nothing is deleted.
- ovclash.python.suite.probe_legacy_clash_detection_file(path: str) tuple[bool, bool]#
Probe whether a file is a legacy
.clashDetectioncontainer.- Parameters:
path – Filesystem path to inspect.
- Returns:
A pair
(is_legacy_container, has_sqlite_payload). The payload flag only means that the embedded payload starts with SQLite’s file header; it does not validate schema compatibility. A missing path reports(False, False).- Raises:
RuntimeError – The path contains a NUL character.
Settings#
Settings lists every setting of both packages with its default, unit and effect.
- ovclash.python.suite.default_run_settings() RunSettings#
Return the default run settings of the loaded native library.
They equal a default-constructed
RunSettingsexcepttime_codes_per_second, which is0.0here, the single-sample fallback.- Returns:
A new settings object that holds the native defaults.
- Raises:
RuntimeError – The native defaults cannot be read.
- ovclash.python.suite.run_settings_to_query_settings_json(
- settings: RunSettings,
Serialize run settings to the legacy query-settings JSON through the Suite C ABI.
Doubles are written with 17 significant digits (printf
"%.17g"), so every value round-trips exactly. This is not the shortest form: a default epsilon of 1e-6 comes back as9.9999999999999995e-07. A C caller that stores this text as a query’ssettings_jsonstores it verbatim, so its spelling is part of that format.ClashQuerykeeps its settings as a dictionary and re-encodes them withjson.dumpson every write.- Parameters:
settings – The run settings to serialize.
- Returns:
The query-settings JSON text.
- Raises:
ValueError – A setting is outside its accepted range or not finite,
time_codes_per_secondis negative, orset_timesis set andend_timeis less thanstart_time.RuntimeError – The native serializer fails.
- ovclash.python.suite.run_settings_to_query_settings_dict(
- settings: RunSettings,
Return the legacy query-settings JSON of
settingsdecoded into adict.- Parameters:
settings – The run settings to serialize.
- Returns:
The decoded output of
run_settings_to_query_settings_json().- Raises:
ValueError – A setting is invalid, as for
run_settings_to_query_settings_json().RuntimeError – The native serializer fails.
Suite types and enums#
Enums, settings, results and clash record models of the Suite Python API.
- class ovclash.python.suite.types.ArrayView(
- values: Any = (),
- *,
- dtype: str = 'float32',
- components: int = 1,
Bases:
objectSmall array container compatible with list, NumPy, and Warp consumers.
The values are copied into a tuple at construction.
- Parameters:
values – Flat scalar values to expose. An object with
tolist(), such as a NumPy array, is converted first;Noneis empty.dtype – Element type name,
"float32"or"uint32".numpy()treats any name other than"float32"asuint32;warp()looks the name up on thewarpmodule.components – Number of scalar components per logical element.
- numpy() Any#
Return the values as a NumPy array with the shape of
shape.The element type is float32 for the
float32dtype and uint32 for any other.- Raises:
RuntimeError – NumPy is not installed.
- property shape: tuple[int, ...]#
Shape of
tolist()andnumpy(),(n,)or(n // components, components).
- tolist() list[Any]#
Return the stored values as a Python list.
- warp() Any#
Return the values as a flat one-dimensional Warp array; components are not grouped.
The element type is the
warpattribute named by the dtype.- Raises:
RuntimeError – Warp is not installed.
- class ovclash.python.suite.types.BackendInfo(
- backend_name: str,
- native_openusd_linked: bool,
- ovpopulation_runtime_loaded: bool,
- ovstage_cuda_enabled: bool,
Bases:
objectBackend name and compile-time capability flags of the loaded native clash library.
backend_nameis"openusd"or"ovstage"("unknown"when the library reports no name).native_openusd_linkedis True only on OpenUSD,ovpopulation_runtime_loadedonly on ovstage, andovstage_cuda_enabledonly on an ovstage build with CUDA enabled. The values are fixed when the library is built; nothing is probed at run time.- backend_name: str#
- native_openusd_linked: bool#
- ovpopulation_runtime_loaded: bool#
- ovstage_cuda_enabled: bool#
- class ovclash.python.suite.types.ClashState(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
IntEnumWorkflow states stored on clash records.
- ACTIVE = 6#
- APPROVED = 2#
- CLOSED = 4#
- INVALID = 5#
- NEW = 1#
- RESOLVED = 3#
- class ovclash.python.suite.types.OverlapData(
- name0: str | None = None,
- name1: str | None = None,
- clash_hash: tuple[int, int] = (0, 0),
- mesh_hash0: tuple[int, int] = (0, 0),
- mesh_hash1: tuple[int, int] = (0, 0),
- nb_records: int = 0,
- nb_elements: int = 0,
- type: OverlapType = OverlapType.UNDEFINED,
- time: float = 0.0,
- min_distance: float = 0.0,
- max_local_depth: float = -1.0,
Bases:
objectRaw overlap data returned directly by the suite runtime.
name0andname1are copied object paths (None when empty). The hashes are 128-bit identifiers as(high64, low64).nb_recordscounts the group’s frame records andnb_elementsthe collided elements of this record.timeis the record’s sample time in seconds;min_distanceandmax_local_depthare in scene units.- clash_hash: tuple[int, int] = (0, 0)#
- max_local_depth: float = -1.0#
- mesh_hash0: tuple[int, int] = (0, 0)#
- mesh_hash1: tuple[int, int] = (0, 0)#
- min_distance: float = 0.0#
- name0: str | None = None#
- name1: str | None = None#
- nb_elements: int = 0#
- nb_records: int = 0#
- time: float = 0.0#
- type: OverlapType = 2147483647#
- class ovclash.python.suite.types.OverlapReportFlag(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
IntFlagBit flags selecting buffers to compute for an overlap report.
- DEFAULT = 0#
- FACES = 1#
- FACES0 = 4#
- FACES1 = 8#
- OUTLINE = 2#
- POINTS0 = 16#
- class ovclash.python.suite.types.OverlapType(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
IntEnumSuite clash classification values stored in clash records.
- DUPLICATE = 2#
- MESH_MESH = 1#
- NORMAL = 1#
- POINT_CLOUD_MESH = 3#
- UNDEFINED = 2147483647#
- class ovclash.python.suite.types.PipelineStepData(
- name: str | None,
- step_index: int,
- nb_steps: int,
- progress: float,
- finished: bool,
Bases:
objectProgress information for one pipeline step.
The
m-prefixed read-only properties alias the fields under their legacy names.- finished: bool#
- property mFinished: bool#
Legacy alias of
finished.
- property mName: str | None#
Legacy alias of
name.
- property mNbSteps: int#
Legacy alias of
nb_steps.
- property mProgress: float#
Legacy alias of
progress.
- property mStepIndex: int#
Legacy alias of
step_index.
- name: str | None#
- nb_steps: int#
- progress: float#
- step_index: int#
- class ovclash.python.suite.types.QueryStats(
- nb_meshes: int,
- nb_shared_meshes: int,
- nb_cooked_meshes: int,
- nb_point_clouds: int,
Bases:
objectMesh and point-cloud counters collected by the native query.
- nb_cooked_meshes: int#
- nb_meshes: int#
- nb_point_clouds: int#
- class ovclash.python.suite.types.RunSettings(
- enable_log: bool = False,
- enable_full_scene: bool = True,
- dynamic: bool = False,
- purge_permanent_dynamic_overlaps: bool = False,
- purge_permanent_static_overlaps: bool = True,
- only_find_duplicates: bool = False,
- ignore_redundant_overlaps: bool = False,
- enable_point_clouds: bool = False,
- ignore_invisible_prims: bool = True,
- use_usdrt: bool = True,
- single_threaded: bool = False,
- new_task_manager: bool = True,
- coplanar: bool = True,
- any_hit: bool = False,
- quantized: bool = False,
- tight_bounds: bool = True,
- subcomponent_filtering: bool = False,
- compute_max_local_depth: bool = False,
- discard_touching_contacts: bool = False,
- max_local_depth_mode: int = 1,
- nb_tasks: int = 128,
- tris_per_leaf: int = 15,
- overlap_code: int = 3,
- triangle_limit: int = 0,
- set_times: bool = False,
- dynamic_start_time: float = 0.0,
- dynamic_end_time: float = 0.0,
- static_time: float = 0.0,
- start_time: float = 0.0,
- end_time: float = 0.0,
- time_codes_per_second: float = 24.0,
- tolerance: float = 0.0,
- pose_epsilon: float = 1e-06,
- bounds_epsilon: float = 0.01,
- area_epsilon: float = 1e-06,
- depth_epsilon: float = -1.0,
- contact_cutoff: float = -1.0,
- point_size_override: float = 0.0,
Bases:
objectComplete native run-settings payload sent to the suite C ABI.
Field meanings and validation follow
ovclash_suite_run_settings_t. The dataclass defaults equaldefault_run_settings()excepttime_codes_per_second, which defaults to24.0here and to0.0(the single-sample fallback) in the native defaults.- any_hit: bool#
- area_epsilon: float#
- bounds_epsilon: float#
- compute_max_local_depth: bool#
- contact_cutoff: float#
- coplanar: bool#
- depth_epsilon: float#
- discard_touching_contacts: bool#
- dynamic: bool#
- dynamic_end_time: float#
- dynamic_start_time: float#
- enable_full_scene: bool#
- enable_log: bool#
- enable_point_clouds: bool#
- end_time: float#
- ignore_invisible_prims: bool#
- ignore_redundant_overlaps: bool#
- max_local_depth_mode: int#
- nb_tasks: int#
- new_task_manager: bool#
- only_find_duplicates: bool#
- overlap_code: int#
- point_size_override: float#
- pose_epsilon: float#
- purge_permanent_dynamic_overlaps: bool#
- purge_permanent_static_overlaps: bool#
- quantized: bool#
- set_times: bool#
- single_threaded: bool#
- start_time: float#
- static_time: float#
- subcomponent_filtering: bool#
- tight_bounds: bool#
- time_codes_per_second: float#
- tolerance: float#
- triangle_limit: int#
- tris_per_leaf: int#
- use_usdrt: bool#
- with_updates(
- **kwargs: Any,
Return a copy with the fields named in
kwargsreplaced.- Raises:
TypeError – A keyword does not name a field.
- class ovclash.python.suite.types.SettingId(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
IntEnumLegacy setting identifiers that
ClashDetection.set_settings()accepts directly.Use the member names, such as
SettingId.SETTING_TOLERANCE.name, asClashQuerysettings keys, so that they survive JSON serialization.- SETTING_ANY_HIT = 18#
- SETTING_AREA_EPSILON = 15#
- SETTING_BOUNDS_EPSILON = 14#
- SETTING_COMPUTE_MAX_LOCAL_DEPTH = 22#
- SETTING_CONTACT_CUTOFF = 30#
- SETTING_COPLANAR = 11#
- SETTING_DEPTH_EPSILON = 23#
- SETTING_DISCARD_TOUCHING_CONTACTS = 24#
- SETTING_DUP_MESHES = 20#
- SETTING_DYNAMIC = 2#
- SETTING_DYNAMIC_END_TIME = 4#
- SETTING_DYNAMIC_START_TIME = 3#
- SETTING_ENABLE_POINT_CLOUDS = 32#
- SETTING_FILTER_TEST = 9#
- SETTING_IGNORE_INVISIBLE_PRIMS = 29#
- SETTING_IGNORE_REDUNDANT_OVERLAPS = 28#
- SETTING_LOGGING = 1#
- SETTING_MAX_LOCAL_DEPTH_MODE = 31#
- SETTING_NB_TASKS = 12#
- SETTING_NEW_TASK_MANAGER = 8#
- SETTING_OVERLAP_CODE = 19#
- SETTING_POINT_SIZE_OVERRIDE = 33#
- SETTING_POSE_EPSILON = 13#
- SETTING_PURGE_PERMANENT_OVERLAPS = 5#
- SETTING_PURGE_PERMANENT_STATIC_OVERLAPS = 25#
- SETTING_QUANTIZED = 6#
- SETTING_SINGLE_THREADED = 7#
- SETTING_STATIC_TIME = 21#
- SETTING_TIGHT_BOUNDS = 10#
- SETTING_TOLERANCE = 17#
- SETTING_TRIANGLE_LIMIT = 27#
- SETTING_TRIS_PER_LEAF = 16#
- SETTING_USE_USDRT = 26#
- class ovclash.python.suite.types.StageTimeline(
- start_time_code: float,
- end_time_code: float,
- time_codes_per_second: float,
- frames_per_second: float,
Bases:
objectRoot-layer timeline metadata of the open stage, as USD resolves it.
A Stage attached with
ClashDetection.attach_ovstage()reports the timeline fields of its attachment, as supplied. Time codes are the stage’s own units;RunSettingstimes are seconds, soseconds = time_code / time_codes_per_second. Unauthored time codes read0.0and unauthoredframesPerSecondreads24.0. The effective rate resolves authoredtimeCodesPerSecond, then authoredframesPerSecond, then24.0on both backends.- property end_time: float#
end_time_codein seconds (0.0when the rate is not positive).
- end_time_code: float#
- frames_per_second: float#
- property start_time: float#
start_time_codein seconds (0.0when the rate is not positive).
- start_time_code: float#
- time_codes_per_second: float#
Command line#
python -m ovclash runs one query against a stage with the canonical
binding and prints a JSON summary. The Command line section of
ovclash Python Package documents its options, output
keys and exit status.