clash_data#
This module provides the main interface for managing clash detection data within a USD stage.
Classes#
ClashData#
- class omni.physxclashdetectioncore.clash_data.ClashData(clash_data_serializer: AbstractClashDataSerializer)#
A class for handling clash detection data within a USD stage.
This class manages the creation, modification, and deletion of clash detection data layers in a USD stage. It interfaces with a specified serializer to handle the persistence of clash data and ensures compatibility and integrity of the data structures.
- Parameters:
clash_data_serializer (AbstractClashDataSerializer) – The serializer used to manage the persistence of clash detection data.
Class Constants:
- CLASH_DATA_LAYER_FILE_EXT: str = ".clashDetection"#
File extension for clash data layer files.
- CLASH_DATA_FILE_EXT: str = ".clashdata"#
File extension for clash data files.
- CLASH_DATA_LAYER_CUSTOM_CLASH_DB_PATH: str = "clashDbPath"#
Custom layer data key for clash database path.
- CLASH_DATA_LAYER_CUSTOM_MODIFIED: str = "clashDbModified"#
Custom layer data key for modification status.
Methods:
- __init__(clash_data_serializer: AbstractClashDataSerializer)#
Initializes the ClashData object.
- Parameters:
clash_data_serializer (AbstractClashDataSerializer) – The serializer to use for data persistence.
- destroy() None#
Cleans up resources and resets object state.
- open(
- stage_id: int | None,
- force_reload_layer: bool = False,
Creates a file or opens an existing one.
- Parameters:
stage_id (Optional[int]) – Stage ID of the stage to work with.
force_reload_layer (bool) – Force reload target layer to ensure it doesn’t come from the stage cache.
- is_open() bool#
Checks if the serializer is ready.
- Returns:
True if the serializer is ready.
- Return type:
bool
- save() bool#
Saves data to the target file.
- Returns:
True if the save operation was successful.
- Return type:
bool
- save_as(usd_file_path: str) bool#
Saves data to a new target file.
- Parameters:
usd_file_path (str) – The new file path to save to.
- Returns:
True if the save operation was successful.
- Return type:
bool
- saved() None#
Performs operations after save.
- close() None#
Closes the opened file.
- commit() None#
Writes any unwritten data to the file.
- migrate_data_structures_to_latest_version(file_path_name: str) bool#
Migrates data structures to the latest versions.
- Parameters:
file_path_name (str) – Path to the clash data.
- Returns:
True if migration was successful, False otherwise.
- Return type:
bool
- insert_overlap(
- clash_info: ClashInfo,
- insert_also_frame_info: bool,
- update_identifier: bool,
- commit: bool,
Inserts clash data. If already present, insertion is skipped.
- Parameters:
clash_info (ClashInfo) – The clash information to insert.
insert_also_frame_info (bool) – Insert frame info as well.
update_identifier (bool) – Update the identifier.
commit (bool) – Commit the changes.
- Returns:
ID of the new record.
- Return type:
int
- update_overlap(
- clash_info: ClashInfo,
- update_also_frame_info: bool,
- commit: bool,
Updates clash data if present in the database.
- Parameters:
clash_info (ClashInfo) – The clash information to update.
update_also_frame_info (bool) – Update frame info as well.
commit (bool) – Commit the changes.
- Returns:
Number of affected records.
- Return type:
int
- 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,
Finds all overlaps associated with a specific query ID.
- Parameters:
clash_query_id (int) – The ID of the query to search for overlaps.
fetch_also_frame_info (bool) – If True, fetches frame information.
num_frames_to_load (int) – The maximum number of frames to load. Defaults to -1 (all frames).
first_frame_offset (int) – The offset for the first frame to load. Defaults to 0.
num_overlaps_to_load (int) – The maximum number of overlaps to load. Defaults to -1 (all overlaps).
first_overlap_offset (int) – The offset for the first overlap to load. Defaults to 0.
- Returns:
A dictionary where keys are overlap IDs and values are ClashInfo objects.
- Return type:
Dict[str, ClashInfo]
- get_overlaps_count_by_query_id(clash_query_id: int) int#
Gets the total number of overlaps for a specific query ID.
- Parameters:
clash_query_id (int) – The ID of the query to count overlaps for.
- Returns:
The total number of overlaps for the query. Returns 0 if no results found.
- Return type:
int
- get_overlaps_count_by_query_id_grouped_by_state(
- clash_query_id: int,
Gets the total number of overlaps for a specific query ID grouped by state.
- Parameters:
clash_query_id (int) – The ID of the query to count overlaps for.
- Returns:
A dictionary where keys are ClashState values and values are counts.
- Return type:
Dict[ClashState, int]
- 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,
Finds all overlaps by their overlap IDs.
- Parameters:
overlap_id (Sequence[int]) – A sequence of overlap IDs to search for.
fetch_also_frame_info (bool) – If True, fetches frame information.
num_frames_to_load (int) – The maximum number of frames to load. Defaults to -1 (all frames).
first_frame_offset (int) – The offset for the first frame to load. Defaults to 0.
- Returns:
A dictionary where keys are overlap IDs and values are ClashInfo objects.
- Return type:
Dict[str, ClashInfo]
- remove_all_overlaps_by_query_id(
- clash_query_id: int,
- commit: bool,
Deletes specified clash data related to query_id.
- Parameters:
clash_query_id (int) – ID of the clash query.
commit (bool) – Commit changes to the database.
- Returns:
Number of deleted rows.
- Return type:
int
- remove_overlap_by_id(overlap_id: int, commit: bool) int#
Deletes specified clash data.
- Parameters:
overlap_id (int) – ID of the overlap.
commit (bool) – Commit changes to the database.
- Returns:
Number of deleted rows.
- Return type:
int
- fetch_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Fetches frame information associated with a specific clash.
- Parameters:
clash_info_id (int) – The ID of the clash for which frame information is to be fetched.
num_frames_to_load (int) – The maximum number of frames to load. Defaults to -1 (all frames).
first_frame_offset (int) – The offset for the first frame to load. Defaults to 0.
- Returns:
A list of ClashFrameInfo objects.
- Return type:
Sequence[ClashFrameInfo]
- get_clash_frame_info_count_by_clash_info_id(clash_info_id: int) int#
Gets the total number of frame info records for a specific clash info ID.
- Parameters:
clash_info_id (int) – The ID of the clash info to count frame info records for.
- Returns:
The total number of frame info records. Returns 0 if no results found.
- Return type:
int
- insert_clash_frame_info_from_clash_info(
- clash_info: ClashInfo,
- commit: bool,
Inserts clash_frame_info. If already present, insertion is skipped.
- Parameters:
clash_info (ClashInfo) – Clash info to insert.
commit (bool) – Commit changes to the database.
- Returns:
Number of affected records.
- Return type:
int
- insert_clash_frame_info(
- clash_frame_info: ClashFrameInfo,
- clash_info_id: int,
- commit: bool,
Inserts clash_frame_info. If already present, insertion is skipped.
- Parameters:
clash_frame_info (ClashFrameInfo) – Clash frame info to insert.
clash_info_id (int) – ID of the clash info.
commit (bool) – Commit changes to the database.
- Returns:
ID of the new record.
- Return type:
int
- remove_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- commit: bool,
Deletes specified clash_frame_info data.
- Parameters:
clash_info_id (int) – ID of the clash info.
commit (bool) – Commit changes to the database.
- Returns:
Number of deleted rows.
- Return type:
int
- fetch_all_queries() Dict[int, ClashQuery]#
Returns all clash queries.
- Returns:
Dictionary of clash queries. Key is query identifier, value is ClashQuery object.
- Return type:
Dict[int, ClashQuery]
- insert_query(
- clash_query: ClashQuery,
- update_identifier: bool = True,
- commit: bool = True,
Inserts clash query. If already present, insertion is skipped.
- Parameters:
clash_query (ClashQuery) – Clash query to insert.
update_identifier (bool) – Update identifier if True.
commit (bool) – Commit changes to the database.
- Returns:
ID of the new record.
- Return type:
int
- find_query(clash_query_id: int) ClashQuery | None#
Returns specified clash query.
- Parameters:
clash_query_id (int) – ID of the clash query.
- Returns:
The clash query or None if not present.
- Return type:
Optional[ClashQuery]
- update_query(clash_query: ClashQuery, commit: bool = True) int#
Updates clash query if present in the DB.
- Parameters:
clash_query (ClashQuery) – Clash query to update.
commit (bool) – Commit changes to the database.
- Returns:
Number of affected records.
- Return type:
int
- remove_query_by_id(query_id: int, commit: bool = True) int#
Deletes specified clash data.
- Parameters:
query_id (int) – ID of the query.
commit (bool) – Commit changes to the database.
- Returns:
Number of deleted rows.
- Return type:
int
Properties:
- stage_id: int | None#
Gets the associated stage ID.
- stage: Usd.Stage | None#
Gets the associated stage.
- usd_file_path: str#
Gets the stage file path.
- serializer_path: str#
Gets the serializer file path.
- data_structures_compatible: bool#
Gets whether the serializer has no compatibility issues.
- data_structures_migration_to_latest_version_possible: bool#
Returns True if the serializer can migrate data structures to the latest version.
- deferred_file_creation_until_first_write_op: bool#
Gets whether the serializer will postpone file creation until the first write operation.
Can also be set to control this behavior.
Functions#
- omni.physxclashdetectioncore.clash_data.serializer_data_op(fnc)#
Decorator to identify serializer data operation.
Handy for tests to quickly find out that a method was added or removed.
- Parameters:
fnc (function) – The function to be registered as a serializer data operation.
- Returns:
The registered function.
- Return type:
function
Module Variables#
- omni.physxclashdetectioncore.clash_data.Serializer_data_operations: List#
List of functions decorated with @serializer_data_op.