Database

class HPS.Database : public IDisposable

The Database class is a special type that is never intended to be instantiated. It contains static functions for creating top-level database objects as well as performing global queries and actions.

Public Functions

Database (HPS.Database in_that)
void Dispose ()

Public Static Functions

HPS.ApplicationWindowKey CreateApplicationWindow (IntPtr in_window_handle)

Create an application window for the given window handle that Visualize can draw into with the specified driver. By default Visualize will try to create an anti-alias capable driver.

Param in_window_handle

Handle to the window that Visualize will draw into.

Return

An application window key corresponding to the given handle using the specified driver.

HPS.ApplicationWindowKey CreateApplicationWindow (IntPtr in_window_handle, HPS.ApplicationWindowOptionsKit in_options)

Create an application window for the given window handle that Visualize can draw into with the specified options.

Param in_window_handle

Handle to the window that Visualize will draw into.

Param in_options

Options for the application window.

Return

An application window key corresponding to the given handle using the specified options.

HPS.ApplicationWindowKey CreateApplicationWindow (IntPtr in_window_handle, HPS.Window.Driver in_driver)

Create an application window for the given window handle that Visualize can draw into with the specified driver. By default Visualize will try to create an anti-alias capable driver.

Param in_window_handle

Handle to the window that Visualize will draw into.

Param in_driver

Type of driver Visualize should create. Defaults to Window.Driver.Default3D.

Return

An application window key corresponding to the given handle using the specified driver.

HPS.EventDispatcher CreateEventDispatcher ()

Create a new EventDispatcher with a dedicated thread ready to dispatch events to handlers.

Return

A new EventDispatcher.

HPS.EventDispatcher CreateEventDispatcher (string in_name)

Create a new EventDispatcher with a dedicated thread ready to dispatch events to handlers.

Param in_name

A specific name for the new dispatcher.

Return

A new EventDispatcher.

HPS.OffScreenWindowKey CreateOffScreenWindow (HPS.ImageDefinition in_destination_image)

Create an offscreen window with the specified driver. By default, Visualize will try to create an anti-alias capable driver.

Param in_destination_image

An RGB or RGBA image definition that the offscreen window will be rendered to.

Return

An offscreen window key of the specified size using the specified driver.

HPS.OffScreenWindowKey CreateOffScreenWindow (HPS.ImageDefinition in_destination_image, HPS.OffScreenWindowOptionsKit in_options)

Create an offscreen window of the given height and width with the specified options.

Param in_destination_image

An RGB or RGBA image definition that the offscreen window will be rendered to.

Param in_options

Options for the offscreen window.

Return

An offscreen window key of the specified size using the specified options.

HPS.OffScreenWindowKey CreateOffScreenWindow (HPS.ImageDefinition in_destination_image, HPS.Window.Driver in_driver)

Create an offscreen window with the specified driver. By default, Visualize will try to create an anti-alias capable driver.

Param in_destination_image

An RGB or RGBA image definition that the offscreen window will be rendered to.

Param in_driver

Type of driver Visualize should create. Defaults to Window.Driver.Default3D.

Return

An offscreen window key of the specified size using the specified driver.

HPS.OffScreenWindowKey CreateOffScreenWindow (uint in_width, uint in_height)

Create an offscreen window of the given height and width with the specified driver. By default Visualize will try to create an anti-alias capable driver.

Param in_width

Width of the offscreen window in pixels.

Param in_height

Height of the offscreen window in pixels.

Return

An offscreen window key of the specified size using the specified driver.

HPS.OffScreenWindowKey CreateOffScreenWindow (uint in_width, uint in_height, HPS.OffScreenWindowOptionsKit in_options)

Create an offscreen window of the given height and width with the specified options.

Param in_width

Width of the offscreen window in pixels.

Param in_height

Height of the offscreen window in pixels.

Param in_options

Options for the offscreen window.

Return

An offscreen window key of the specified size using the specified options.

HPS.OffScreenWindowKey CreateOffScreenWindow (uint in_width, uint in_height, HPS.Window.Driver in_driver)

Create an offscreen window of the given height and width with the specified driver. By default Visualize will try to create an anti-alias capable driver.

Param in_width

Width of the offscreen window in pixels.

Param in_height

Height of the offscreen window in pixels.

Param in_driver

Type of driver Visualize should create. Defaults to Window.Driver.Default3D.

Return

An offscreen window key of the specified size using the specified driver.

HPS.PortfolioKey CreatePortfolio ()

Create a new portfolio.

Return

A new portfolio key.

HPS.SegmentKey CreateRootSegment ()

Create a new root segment, i.e., a segment without an owner.

Return

A new root segment key.

HPS.StandAloneWindowKey CreateStandAloneWindow ()

Create a stand-alone window with the specified driver. By default Visualize will try to create an anti-alias capable driver.

Return

An stand-alone window key using the specified driver.

HPS.StandAloneWindowKey CreateStandAloneWindow (HPS.StandAloneWindowOptionsKit in_options)

Create a stand-alone window with the specified options.

Param in_options

Options for the stand-alone window. Standalone windows are not supported on Android, iOS, or macOS as all GUI / windowing is controlled at the application level.

Return

An stand-alone window key using the specified options.

HPS.StandAloneWindowKey CreateStandAloneWindow (HPS.Window.Driver in_driver)

Create a stand-alone window with the specified driver. By default Visualize will try to create an anti-alias capable driver.

Param in_driver

Type of driver Visualize should create. Defaults to Window.Driver.Default3D. Standalone windows are not supported on Android, iOS, or macOS as all GUI / windowing is controlled at the application level.

Return

An stand-alone window key using the specified driver.

void Execute ()

This function will pump the stand-alone window event system once by default. If once is false then the calling thread will loop pumping events and will only return when the last window of any type exits.

void Execute (bool in_once)

This function will pump the stand-alone window event system once by default. If once is false then the calling thread will loop pumping events and will only return when the last window of any type exits.

Param in_once

determines if the stand-alone events are pumped once or forever.

bool GetErrorEventFilter (HPS.Info.Code in_code)

Provides the filter state of an ErrorEvent.

Param in_code

The info code in to operate on.

Return

If the specified code is filtered.

HPS.EventDispatcher GetEventDispatcher ()

Get the event dispatcher associated with the database. All database information, errors and warnings will be injected into this EventDispatcher.

Return

The event dispatcher associated with the database.

bool GetInformationEventFilter (HPS.Info.Code in_code)

Provides the filter state of an InformationEvent.

Param in_code

The info code in to operate on.

Return

If the specified code is filtered.

HPS.PortfolioKey GetMaterialLibraryPortfolio ()

Get the material library portfolio. This is the portfolio which contains all relevant definitions for materials coming from the material library. It is provided to facilitate importing definitions from this portfolio, or to allow examination of the definitions in the portfolio. It should not be deleted, and if it is, the scene will not render correctly if a file was loaded which depended on the material library.

Return

The material library portfolio.

ulong GetOOCMemoryLimit ()

Gets the byte limit used for OOC file loading.

Return

The current value in bytes.

HPS.PortfolioKey[] GetPortfolios ()

Get a list of all portfolios which are active (have been created but not deleted).

Return

List of all currently active portfolios.

HPS.SegmentKey[] GetRootSegments ()

Get a list of all root segments which are active (have been created but not deleted).

Return

List of all currently active root segments.

ulong GetSoftMemoryLimit ()

Gets the value at which the EmergencyHandler will be activated for SoftMemoryLimit.

Return

The current value in bytes.

double GetTime ()

Queries the number of milliseconds that have elapsed since Visualize started.

Return

The number of milliseconds that have elapsed since Visualize started.

bool GetWarningEventFilter (HPS.Info.Code in_code)

Provides the filter state of a WarningEvents.

Param in_code

The info code in to operate on.

Return

If the specified code is filtered.

HPS.WindowKey[] GetWindowKeys ()

Get a list of all windows (application, stand-alone, and offscreen) which are active (have been created but not deleted).

Return

List of all currently active windows.

bool IsDriverAvailable (HPS.Window.Driver in_driver)

Checks whether the specified driver type is present and available for use.

Param in_driver

the driver type to check availability for.

Return

Whether the driver is available or not.

void RelinquishMemory ()

Relinquish any internally cached memory to the system. This can reduce performance and stability if overused. If your application inserts or removes items from the Visualize database continuously, this function should not be used, even as a means of ‘obtaining more memory’ for the application. Otherwise, Visualize will simply allocate more memory from the operating system. This is slower than using its built in memory manager to allocate from its currently available memory pool. However, if you have a case where database interactions have perhaps reached a point of stabilization (for example, a model is loaded and has been interacted with already, and no other operations are going to incur extra memory usage), this function could prove useful by having Visualize free up its unused portion of allocated memory. This function should generally not be called on 32-bit Windows operating systems, because it can significantly shorten the life of an application. When memory is freed back to the system on 32-bit Windows, the real memory gets freed and defragmented by the OS, but the virtual address space does not. If an application keeps allocating and freeing system memory during its lifetime, memory will run out due to the address space fragmentation, even though physical memory might still be available. While 64-bit systems do not have the ‘virtual address space fragmentation’ issue, you typically should avoid calling this method, and rely on Visualize to manage its allocated memory during the lifetime of your application. Note that you can track Visualize’s current memory usage by calling HPS.Database.ShowMemoryUsage.

void Reset ()

Performs a complete reset of the Visualize database. All segments are deleted and all window displays are terminated. This will leave all keys, controls, and dispatchers invalid. Kits are preserved. This can never be called from inside an event handler. It may be appropriate to call this method if your application doesn’t need to use Visualize for a while.

ulong SelectByRay (HPS.Point in_start_point, HPS.Vector in_direction, HPS.SelectionOptionsKit in_options, out HPS.SelectionResults out_results)

Performs an object space selection by ray starting at the specified segment using the specified selection options. This method can only select faceted geometry - not subentities.

Param in_start_point

Start point of ray.

Param in_direction

Direction vector for ray.

Param in_options

Selection options to use when performing the selection.

Param out_results

Results of the selection.

Return

Number of selected items.

ulong SelectByShell (HPS.ShellKey in_shell, HPS.SelectionOptionsKit in_options, out HPS.SelectionResults out_results)

Performs an object space selection by shell starting at the specified segment using the specified selection options. This method can only select faceted geometry.

Param in_shell

Shell in the database to use to perform the selection.

Param in_options

Selection options to use when performing the selection.

Param out_results

Results of the selection.

Return

Number of selected items.

ulong SelectByShell (HPS.ShellKit in_shell, HPS.SelectionOptionsKit in_options, out HPS.SelectionResults out_results)

Performs an object space selection by shell starting at the specified segment using the specified selection options. This method can only select faceted geometry.

Param in_shell

Shell to use to perform the selection.

Param in_options

Selection options to use when performing the selection.

Param out_results

Results of the selection.

Return

Number of selected items.

ulong SelectByVolume (HPS.SimpleCuboid in_volume, HPS.SelectionOptionsKit in_options, out HPS.SelectionResults out_results)

Performs an object space selection by volume starting at the specified segment using the specified selection options. If the volume is invalid, i.e., min > max for any component, an exception will be thrown.

Param in_volume

Volume to use when performing the selection.

Param in_options

Selection options to use when performing the selection.

Param out_results

Results of the selection.

Return

Number of selected items.

void SetEmergencyHandler (HPS.EmergencyHandler in_emergency_handler)

Sets a custom EmergencyHandler.

Param in_emergency_handler

The EmergencyHandler to use.

bool SetErrorEventFilter (HPS.Info.Code in_code, bool in_filtered)

Sets if a specific code for ErrorEvent should be filtered.

Param in_code

The info code in to operate on.

Param in_filtered

The new filter state desired.

Return

The old value for the specified code.

bool SetInformationEventFilter (HPS.Info.Code in_code, bool in_filtered)

Sets if a specific code for InformationEvent should be filtered.

Param in_code

The info code in to operate on.

Param in_filtered

The new filter state desired.

Return

The old value for the specified code.

ulong SetOOCMemoryLimit (ulong in_limit_bytes)

Sets the byte limit used for OOC file loading. A limit of zero bytes restores the default value.

Param in_limit_bytes

The new limit value in bytes.

Return

The old value in bytes.

ulong SetSoftMemoryLimit (ulong in_limit_bytes)

Sets the value at which the EmergencyHandler will be activated for SoftMemoryLimit.

Param in_limit_bytes

The new limit value in bytes.

Return

The old value in bytes.

bool SetWarningEventFilter (HPS.Info.Code in_code, bool in_filtered)

Sets if a specific code for WarningEvent should be filtered.

Param in_code

The info code in to operate on.

Param in_filtered

The new filter state desired.

Return

The old value for the specified code.

bool ShowAvailableGPUs (out string[] out_available_gpus)
void ShowMemoryUsage (out ulong out_allocated, out ulong out_used)

Returns information about system memory usage. It may be useful to know how much memory Visualize is using to store graphical information. Visualize utilizes its own internal memory manager. It generally allocates memory in large chunks from the operating system, then parcels the chunks out as needed by the database. Upon entity deletion, Visualize will keep some cached information, as well as the chunks of memory associated with the deleted items, effectively ‘recycling’ them. Allocated memory indicates the total size of all chunks; used memory indicates the amount that’s currently parceled out. The memory usage information is also useful during debugging - you might be able to use it to determine if your program (or perhaps Visualize) is “leaking” memory - for example, not cleaning up the segment tree properly after a procedure is finished. Some changes and deletions in the database might cause immediate changes in the memory usage statistics, while others might be delayed until after the next update. Because of the nature of Visualize’s built-in memory allocation methods, only a call to HPS.Database.RelinquishMemory or HPS.Database.Reset can clean up memory that has been allocated but not used and return it to the operating system. However, HPS.Database.RelinquishMemory should be used with care, so be sure to review the documentation.

Param out_allocated

Total bytes currently allocated from the OS.

Param out_used

Total bytes currently in use by the database.

void Sleep (double milliseconds)

Sleep for the number of milliseconds requested.

void Synchronize ()

Synchronizes the database, guaranteeing that all queued actions and updates have been performed.

void UnsetEmergencyHandler ()

Sets the default EmergencyHandler.