file_path
stringlengths 21
207
| content
stringlengths 5
1.02M
| size
int64 5
1.02M
| lang
stringclasses 9
values | avg_line_length
float64 1.33
100
| max_line_length
int64 4
993
| alphanum_fraction
float64 0.27
0.93
|
---|---|---|---|---|---|---|
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/tests/test_helper.py | import unittest
import pathlib
import carb
import omni.kit.test
from pxr import UsdShade
from omni.ui.tests.test_base import OmniUiTest
from .inspector_query import InspectorQuery
class TestMouseUIHelper(OmniUiTest):
# Before running each test
async def setUp(self):
await super().setUp()
extension_path = omni.kit.app.get_app().get_extension_manager().get_extension_path_by_module(__name__)
self._test_path = pathlib.Path(extension_path).joinpath("data").joinpath("tests")
self._inspector_query = InspectorQuery()
# After running each test
async def tearDown(self):
await super().tearDown()
async def wait_for_update(self, usd_context=omni.usd.get_context(), wait_frames=10):
max_loops = 0
while max_loops < wait_frames:
_, files_loaded, total_files = usd_context.get_stage_loading_status()
await omni.kit.app.get_app().next_update_async()
if files_loaded or total_files:
continue
max_loops = max_loops + 1
async def _simulate_mouse(self, data):
import omni.appwindow
import omni.ui as ui
mouse = omni.appwindow.get_default_app_window().get_mouse()
input_provider = carb.input.acquire_input_provider()
window_width = ui.Workspace.get_main_window_width()
window_height = ui.Workspace.get_main_window_height()
for type, x, y in data:
input_provider.buffer_mouse_event(mouse, type, (x / window_width, y / window_height), 0, (x, y))
await self.wait_for_update()
async def _debug_capture(self, image_name: str):
from pathlib import Path
import omni.renderer_capture
capture_next_frame = omni.renderer_capture.acquire_renderer_capture_interface().capture_next_frame_swapchain(image_name)
await self.wait_for_update()
wait_async_capture = omni.renderer_capture.acquire_renderer_capture_interface().wait_async_capture()
await self.wait_for_update()
| 2,027 | Python | 37.999999 | 128 | 0.662062 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/tests/test_context_menu.py | import carb
import omni
import omni.kit.test
import omni.usd
import omni.client
import omni.kit.widget.stage
import omni.kit.app
import omni.kit.ui_test as ui_test
import pathlib
from omni.kit.test_suite.helpers import arrange_windows
from pxr import Sdf, UsdShade
class TestContextMenu(omni.kit.test.AsyncTestCase):
async def setUp(self):
await arrange_windows("Stage", 800, 600)
self.app = omni.kit.app.get_app()
self.usd_context = omni.usd.get_context()
await self.usd_context.new_stage_async()
self.stage = omni.usd.get_context().get_stage()
self.layer = Sdf.Layer.CreateAnonymous()
extension_path = omni.kit.app.get_app().get_extension_manager().get_extension_path_by_module(__name__)
self._test_path = pathlib.Path(extension_path).joinpath("data").joinpath("tests")
self._cube_usd_path = str(self._test_path.joinpath("usd/cube.usda"))
self.ref_prim = self.stage.DefinePrim("/reference0", "Xform")
self.ref_prim.GetReferences().AddReference(self.layer.identifier)
self.child_prim = self.stage.DefinePrim("/reference0/child0", "Xform")
self.payload_prim = self.stage.DefinePrim("/payload0", "Xform")
self.payload_prim.GetPayloads().AddPayload(self.layer.identifier)
self.rf_prim = self.stage.DefinePrim("/reference_and_payload0", "Xform")
self.rf_prim.GetReferences().AddReference(self.layer.identifier)
self.rf_prim.GetPayloads().AddPayload(self.layer.identifier)
await self.wait()
async def tearDown(self):
pass
async def wait(self, frames=10):
for i in range(frames):
await self.app.next_update_async()
async def _find_all_prim_items(self):
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
reference_widget = stage_tree.find("**/Label[*].text=='reference0'")
payload_widget = stage_tree.find("**/Label[*].text=='payload0'")
reference_and_payload_widget = stage_tree.find("**/Label[*].text=='reference_and_payload0'")
return reference_widget, payload_widget, reference_and_payload_widget
async def test_expand_collapse_tree(self):
rf_widget, _, _ = await self._find_all_prim_items()
for name in ["All", "Component", "Group", "Assembly", "SubComponent"]:
await rf_widget.right_click()
await ui_test.select_context_menu(f"Collapse/{name}")
await rf_widget.right_click()
await ui_test.select_context_menu(f"Expand/{name}")
async def test_default_prim(self):
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
with self.assertRaises(Exception):
await ui_test.select_context_menu("Clear Default Prim")
await rf_widget.right_click()
await ui_test.select_context_menu("Set as Default Prim")
await self.wait()
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
ref_widget = stage_tree.find("**/Label[*].text=='reference0 (defaultPrim)'")
self.assertTrue(ref_widget)
ref_widget_old = stage_tree.find("**/Label[*].text=='reference0'")
self.assertFalse(ref_widget_old)
with self.assertRaises(Exception):
await ui_test.select_context_menu("Set as Default Prim")
await rf_widget.right_click()
await ui_test.select_context_menu("Clear Default Prim")
await self.wait()
ref_widget_old = stage_tree.find("**/Label[*].text=='reference0 (defaultPrim)'")
self.assertFalse(ref_widget_old)
ref_widget = stage_tree.find("**/Label[*].text=='reference0'")
self.assertTrue(ref_widget)
async def test_find_in_browser(self):
self.usd_context.get_selection().set_selected_prim_paths(
[str(self.ref_prim.GetPath())], True
)
await self.wait()
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
# If there are no on-disk references
with self.assertRaises(Exception):
await ui_test.select_context_menu("Find in Content Browser")
# Adds a reference that's on disk.
self.ref_prim.GetReferences().ClearReferences()
self.ref_prim.GetReferences().AddReference(self._cube_usd_path)
await self.wait()
await rf_widget.right_click()
await ui_test.select_context_menu("Find in Content Browser")
async def test_group_selected(self):
self.usd_context.get_selection().set_selected_prim_paths(
[str(self.ref_prim.GetPath()), str(self.payload_prim.GetPath())], True
)
await self.wait()
old_ref_path = self.ref_prim.GetPath()
old_payload_path = self.payload_prim.GetPath()
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
await ui_test.select_context_menu("Group Selected")
await self.wait()
new_ref_path = Sdf.Path("/Group").AppendElementString(old_ref_path.name)
new_payload_path = Sdf.Path("/Group").AppendElementString(old_payload_path.name)
self.assertFalse(self.stage.GetPrimAtPath(old_ref_path))
self.assertFalse(self.stage.GetPrimAtPath(old_payload_path))
self.assertTrue(self.stage.GetPrimAtPath(new_ref_path))
self.assertTrue(self.stage.GetPrimAtPath(new_payload_path))
self.usd_context.get_selection().set_selected_prim_paths(
[str(new_ref_path), str(new_payload_path)], True
)
await self.wait()
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
ref_widget = stage_tree.find("**/Label[*].text=='reference0'")
self.assertTrue(ref_widget)
await rf_widget.right_click()
await ui_test.select_context_menu("Ungroup Selected")
await self.wait()
self.assertTrue(self.stage.GetPrimAtPath(old_ref_path))
self.assertTrue(self.stage.GetPrimAtPath(old_payload_path))
self.assertFalse(self.stage.GetPrimAtPath(new_ref_path))
self.assertFalse(self.stage.GetPrimAtPath(new_payload_path))
async def test_duplicate_prim(self):
self.usd_context.get_selection().set_selected_prim_paths(
[str(self.ref_prim.GetPath()), str(self.payload_prim.GetPath())], True
)
await self.wait()
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
await ui_test.select_context_menu("Duplicate")
self.assertTrue(self.stage.GetPrimAtPath("/reference0_01"))
self.assertTrue(self.stage.GetPrimAtPath("/payload0_01"))
async def test_delete_prim(self):
self.usd_context.get_selection().set_selected_prim_paths(
[str(self.ref_prim.GetPath()), str(self.payload_prim.GetPath())], True
)
await self.wait()
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
await ui_test.select_context_menu("Delete")
self.assertFalse(self.ref_prim)
self.assertFalse(self.payload_prim)
async def test_refresh_reference_or_payload(self):
self.usd_context.get_selection().set_selected_prim_paths(
[str(self.ref_prim.GetPath())], True
)
await self.wait()
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
await ui_test.select_context_menu("Refresh Reference")
async def test_convert_between_ref_and_payload(self):
rf_widget, payload_widget, ref_and_payload_widget = await self._find_all_prim_items()
await rf_widget.right_click()
with self.assertRaises(Exception):
await ui_test.select_context_menu("Convert Payloads to References")
await rf_widget.right_click()
await ui_test.select_context_menu("Convert References to Payloads")
ref_prim = self.stage.GetPrimAtPath("/reference0")
ref_and_layers = omni.usd.get_composed_references_from_prim(ref_prim)
payload_and_layers = omni.usd.get_composed_payloads_from_prim(ref_prim)
self.assertTrue(len(ref_and_layers) == 0)
self.assertTrue(len(payload_and_layers) == 1)
await payload_widget.right_click()
with self.assertRaises(Exception):
await ui_test.select_context_menu("Convert References to Payloads")
await payload_widget.right_click()
await ui_test.select_context_menu("Convert Payloads to References")
payload_prim = self.stage.GetPrimAtPath("/payload0")
ref_and_layers = omni.usd.get_composed_references_from_prim(payload_prim)
payload_and_layers = omni.usd.get_composed_payloads_from_prim(payload_prim)
self.assertTrue(len(ref_and_layers) == 1)
self.assertTrue(len(payload_and_layers) == 0)
await ref_and_payload_widget.right_click()
await ui_test.select_context_menu("Convert References to Payloads")
prim = self.stage.GetPrimAtPath("/reference_and_payload0")
ref_and_layers = omni.usd.get_composed_references_from_prim(prim)
payload_and_layers = omni.usd.get_composed_payloads_from_prim(prim)
self.assertEqual(len(ref_and_layers), 0)
self.assertEqual(len(payload_and_layers), 1)
await ref_and_payload_widget.right_click()
await ui_test.select_context_menu("Convert Payloads to References")
prim = self.stage.GetPrimAtPath("/reference_and_payload0")
ref_and_layers = omni.usd.get_composed_references_from_prim(prim)
payload_and_layers = omni.usd.get_composed_payloads_from_prim(prim)
self.assertEqual(len(ref_and_layers), 1)
self.assertEqual(len(payload_and_layers), 0)
async def test_select_bound_objects(self):
menu_name = "Select Bound Objects"
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
with self.assertRaises(Exception):
await ui_test.select_context_menu(menu_name)
material = UsdShade.Material.Define(self.stage, "/material0")
UsdShade.MaterialBindingAPI(self.payload_prim).Bind(material)
await self.wait()
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
material_widget = stage_tree.find("**/Label[*].text=='material0'")
await material_widget.right_click()
await ui_test.select_context_menu(menu_name)
await self.wait()
self.assertEqual(omni.usd.get_context().get_selection().get_selected_prim_paths(), [str(self.payload_prim.GetPath())])
async def test_binding_material(self):
menu_name = "Bind Material To Selected Objects"
rf_widget, _, _ = await self._find_all_prim_items()
await rf_widget.right_click()
with self.assertRaises(Exception):
await ui_test.select_context_menu(menu_name)
material = UsdShade.Material.Define(self.stage, "/material0")
UsdShade.MaterialBindingAPI(self.payload_prim).Bind(material)
await self.wait()
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
material_widget = stage_tree.find("**/Label[*].text=='material0'")
await material_widget.right_click()
# No valid selection
with self.assertRaises(Exception):
await ui_test.select_context_menu(menu_name)
self.usd_context.get_selection().set_selected_prim_paths(
[str(self.payload_prim.GetPath())], True
)
await self.wait()
await material_widget.right_click()
await ui_test.select_context_menu(menu_name)
await self.wait()
selected_paths = omni.usd.get_context().get_selection().get_selected_prim_paths()
self.assertEqual(selected_paths, [str(self.payload_prim.GetPath())])
async def test_set_kind(self):
rf_widget, _, _ = await self._find_all_prim_items()
self.usd_context.get_selection().set_selected_prim_paths(
[str(self.ref_prim.GetPath())], True
)
await self.wait()
for name in ["Assembly", "Group", "Component", "Subcomponent"]:
await rf_widget.right_click()
await ui_test.select_context_menu(f"Set Kind/{name}")
async def test_lock_specs(self):
rf_widget, _, _ = await self._find_all_prim_items()
for menu_name in ["Lock Selected", "Unlock Selected", "Lock Selected Hierarchy", "Unlock Selected Hierarchy"]:
await rf_widget.right_click()
await ui_test.select_context_menu(f"Locks/{menu_name}")
await rf_widget.right_click()
await ui_test.select_context_menu("Locks/Lock Selected Hierarchy")
await rf_widget.right_click()
await ui_test.select_context_menu("Locks/Select Locked Prims")
await self.wait()
selected_paths = omni.usd.get_context().get_selection().get_selected_prim_paths()
self.assertEqual(selected_paths, [str(self.ref_prim.GetPath()), str(self.child_prim.GetPath())])
async def test_assign_material(self):
menu_name = "Assign Material"
rf_widget, _, _ = await self._find_all_prim_items()
material = UsdShade.Material.Define(self.stage, "/material0")
UsdShade.MaterialBindingAPI(self.payload_prim).Bind(material)
await self.wait()
await rf_widget.right_click()
await ui_test.select_context_menu(menu_name)
dialog = ui_test.find("Bind material to reference0###context_menu_bind")
self.assertTrue(dialog)
button = dialog.find("**/Button[*].text=='Ok'")
self.assertTrue(button)
await button.click()
async def test_rename_prim(self):
await ui_test.find("Stage").focus()
menu_name = "Rename"
rf_widget, _, _ = await self._find_all_prim_items()
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
await rf_widget.right_click(rf_widget.center)
await ui_test.select_context_menu(menu_name)
await self.wait(10)
string_fields = stage_tree.find_all("**/StringField[*].identifier=='rename_field'")
self.assertTrue(len(string_fields) > 0)
string_field = string_fields[0]
# FIXME: Cannot make it visible in tests, but have to do it manually
string_field.widget.visible = True
await string_field.input("test")
self.assertTrue(self.stage.GetPrimAtPath("/reference0test"))
self.assertFalse(self.stage.GetPrimAtPath("/reference0"))
| 14,680 | Python | 42.95509 | 126 | 0.64673 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/tests/test_stage.py | ## Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
import omni.kit.test
from pathlib import Path
from omni.kit.widget.stage import StageWidget
from omni.kit.widget.stage.stage_icons import StageIcons
from omni.ui.tests.test_base import OmniUiTest
from pxr import Usd, UsdGeom
from omni.kit import ui_test
from omni.kit.test_suite.helpers import arrange_windows, wait_stage_loading
import omni.kit.app
CURRENT_PATH = Path(__file__).parent
REPO_PATH = CURRENT_PATH
for i in range(10):
REPO_PATH = REPO_PATH.parent
BOWL_STAGE = REPO_PATH.joinpath("data/usd/tests/bowl.usd")
STYLE = {"Field": {"background_color": 0xFF24211F, "border_radius": 2}}
class TestStage(OmniUiTest):
# Before running each test
async def setUp(self):
await arrange_windows(hide_viewport=True)
# After running each test
async def tearDown(self):
await wait_stage_loading()
async def test_general(self):
"""Testing general look of StageWidget"""
StageIcons()._icons = {}
window = await self.create_test_window()
stage = Usd.Stage.Open(f"{BOWL_STAGE}")
if not stage:
self.fail(f"Stage {BOWL_STAGE} doesn't exist")
return
with window.frame:
stage_widget = StageWidget(stage, style=STYLE)
# 5 frames to rasterize the icons
for _ in range(5):
await omni.kit.app.get_app().next_update_async()
await self.finalize_test()
async def test_visibility(self):
"""Testing visibility of StageWidget"""
StageIcons()._icons = {}
window = await self.create_test_window()
stage = Usd.Stage.CreateInMemory("test.usd")
with window.frame:
stage_widget = StageWidget(stage, style=STYLE)
UsdGeom.Mesh.Define(stage, "/A")
UsdGeom.Mesh.Define(stage, "/A/B")
UsdGeom.Mesh.Define(stage, "/C").MakeInvisible()
# 5 frames to rasterize the icons
for _ in range(5):
await omni.kit.app.get_app().next_update_async()
await self.finalize_test()
async def test_dynamic(self):
"""Testing the ability to watch the stage"""
StageIcons()._icons = {}
window = await self.create_test_window()
stage = Usd.Stage.CreateInMemory("test.usd")
with window.frame:
stage_widget = StageWidget(stage, style=STYLE)
UsdGeom.Mesh.Define(stage, "/A")
# Wait one frame to be sure other objects created after initialization
await omni.kit.app.get_app().next_update_async()
UsdGeom.Mesh.Define(stage, "/B")
mesh = UsdGeom.Mesh.Define(stage, "/C")
# Wait one frame to be sure other objects created after initialization
await omni.kit.app.get_app().next_update_async()
mesh.MakeInvisible()
UsdGeom.Mesh.Define(stage, "/D")
# 5 frames to rasterize the icons
for _ in range(5):
await omni.kit.app.get_app().next_update_async()
await self.finalize_test()
async def test_instanceable(self):
"""Testing the ability to watch the instanceable state"""
StageIcons()._icons = {}
window = await self.create_test_window()
stage = Usd.Stage.CreateInMemory("test.usd")
with window.frame:
stage_widget = StageWidget(stage, style=STYLE)
UsdGeom.Xform.Define(stage, "/A")
UsdGeom.Mesh.Define(stage, "/A/Shape")
prim = UsdGeom.Xform.Define(stage, "/B").GetPrim()
prim.GetReferences().AddInternalReference("/A")
# Wait one frame to be sure other objects created after initialization
await omni.kit.app.get_app().next_update_async()
stage_widget.expand("/B")
await omni.kit.app.get_app().next_update_async()
prim.SetInstanceable(True)
# 5 frames to rasterize the icons
for _ in range(5):
await omni.kit.app.get_app().next_update_async()
await self.finalize_test()
| 4,390 | Python | 30.141844 | 78 | 0.645103 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/tests/drag_drop_multi.py | ## Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
import omni.kit.test
import omni.kit.app
import omni.usd
from omni.kit.test.async_unittest import AsyncTestCase
from omni.kit import ui_test
from pxr import Sdf, UsdShade
from omni.kit.test_suite.helpers import (
open_stage,
get_test_data_path,
get_prims,
wait_stage_loading,
arrange_windows
)
from omni.kit.window.content_browser.test_helper import ContentBrowserTestHelper
class DragDropFileStageMulti(AsyncTestCase):
# Before running each test
async def setUp(self):
await arrange_windows()
await open_stage(get_test_data_path(__name__, "bound_shapes.usda"))
# After running each test
async def tearDown(self):
await wait_stage_loading()
async def test_l1_drag_drop_multi_usd_stage(self):
from carb.input import KeyboardInput
await ui_test.find("Content").focus()
usd_context = omni.usd.get_context()
stage = usd_context.get_stage()
stage_window = ui_test.find("Stage")
await stage_window.focus()
# verify prims
paths = [prim.GetPath().pathString for prim in get_prims(stage) if not omni.usd.is_hidden_type(prim)]
self.assertEqual(paths, ['/World', '/World/defaultLight', '/World/Cone', '/World/Cube', '/World/Sphere', '/World/Cylinder', '/World/Looks', '/World/Looks/OmniPBR', '/World/Looks/OmniPBR/Shader', '/World/Looks/OmniGlass', '/World/Looks/OmniGlass/Shader', '/World/Looks/OmniSurface_Plastic', '/World/Looks/OmniSurface_Plastic/Shader'])
# drag/drop files to stage window
drag_target = stage_window.position + ui_test.Vec2(stage_window.size.x / 2, stage_window.size.y - 96)
async with ContentBrowserTestHelper() as content_browser_helper:
usd_path = get_test_data_path(__name__)
await content_browser_helper.drag_and_drop_tree_view(
usd_path, names=["4Lights.usda", "quatCube.usda"], drag_target=drag_target)
# verify prims
paths = [prim.GetPath().pathString for prim in get_prims(stage) if not omni.usd.is_hidden_type(prim)]
self.assertEqual(paths, ['/World', '/World/defaultLight', '/World/Cone', '/World/Cube', '/World/Sphere', '/World/Cylinder', '/World/Looks', '/World/Looks/OmniPBR', '/World/Looks/OmniPBR/Shader', '/World/Looks/OmniGlass', '/World/Looks/OmniGlass/Shader', '/World/Looks/OmniSurface_Plastic', '/World/Looks/OmniSurface_Plastic/Shader', '/World/_Lights', '/World/_Lights/SphereLight_01', '/World/_Lights/SphereLight_02', '/World/_Lights/SphereLight_03', '/World/_Lights/SphereLight_00', '/World/_Lights/Cube', '/World/quatCube', '/World/quatCube/Cube'])
| 3,064 | Python | 49.245901 | 557 | 0.698107 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/tests/test_header.py | import carb
import omni
import omni.kit.test
import omni.usd
import omni.client
import omni.kit.widget.stage
import omni.kit.app
import omni.kit.ui_test as ui_test
from omni.kit.test_suite.helpers import arrange_windows
from ..stage_model import StageItemSortPolicy
class TestHeader(omni.kit.test.AsyncTestCase):
async def setUp(self):
self.app = omni.kit.app.get_app()
await arrange_windows("Stage", 800, 600)
async def tearDown(self):
pass
async def wait(self, frames=4):
for i in range(frames):
await self.app.next_update_async()
async def test_name_header(self):
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
self.assertTrue(stage_tree)
stage_model = stage_tree.widget.model
stage_model.set_items_sort_policy(StageItemSortPolicy.DEFAULT)
name_label = stage_tree.find("**/Label[*].text=='Name (Old to New)'")
self.assertTrue(name_label)
await name_label.click()
await self.wait()
name_label = stage_tree.find("**/Label[*].text=='Name (A to Z)'")
self.assertTrue(name_label)
await name_label.click()
await self.wait()
name_label = stage_tree.find("**/Label[*].text=='Name (Z to A)'")
self.assertTrue(name_label)
await name_label.click()
await self.wait()
name_label = stage_tree.find("**/Label[*].text=='Name (New to Old)'")
self.assertTrue(name_label)
await name_label.click()
await self.wait()
name_label = stage_tree.find("**/Label[*].text=='Name (Old to New)'")
self.assertTrue(name_label)
async def test_visibility_header(self):
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
self.assertTrue(stage_tree)
stage_model = stage_tree.widget.model
stage_model.set_items_sort_policy(StageItemSortPolicy.DEFAULT)
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.DEFAULT)
visibility_image = stage_tree.find("**/Image[*].name=='visibility_header'")
self.assertTrue(visibility_image)
await visibility_image.click()
await self.wait()
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.VISIBILITY_COLUMN_VISIBLE_TO_INVISIBLE)
await visibility_image.click()
await self.wait()
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.VISIBILITY_COLUMN_INVISIBLE_TO_VISIBLE)
await visibility_image.click()
await self.wait()
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.DEFAULT)
async def test_type_header(self):
stage_tree = ui_test.find("Stage//Frame/**/ScrollingFrame/TreeView[*].visible==True")
self.assertTrue(stage_tree)
stage_model = stage_tree.widget.model
stage_model.set_items_sort_policy(StageItemSortPolicy.DEFAULT)
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.DEFAULT)
type_label = stage_tree.find("**/Label[*].text=='Type'")
self.assertTrue(type_label)
await type_label.click()
await self.wait()
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.TYPE_COLUMN_A_TO_Z)
await type_label.click()
await self.wait()
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.TYPE_COLUMN_Z_TO_A)
await type_label.click()
await self.wait()
self.assertEqual(stage_model.get_items_sort_policy(), StageItemSortPolicy.DEFAULT)
| 3,679 | Python | 36.938144 | 121 | 0.660506 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/tests/inspector_query.py | from typing import Optional, Union
import omni.ui as ui
import carb
class InspectorQuery:
def __init__(self) -> None:
pass
@classmethod
def child_widget(cls, widget: ui.Widget, predicate: str, last=False) -> Union[ui.Widget, None]:
adjusted_predicate = predicate
# when we don't have index we assume it is the first one
index = None
if "[" in adjusted_predicate:
index = int(adjusted_predicate.split("[")[-1].split("]")[0])
adjusted_predicate = adjusted_predicate.split("[")[0]
if last and index is None:
if widget.__class__.__name__ == adjusted_predicate:
return widget
else:
carb.log_warn(f"Widget {widget} is not matching predicate {adjusted_predicate}")
return None
if not widget.__class__.__name__ == adjusted_predicate:
carb.log_warn(f"Widget {widget} is not matching predicate {adjusted_predicate}")
return None
children = ui.Inspector.get_children(widget)
if not index:
index = 0
if index >= len(children):
carb.log_warn(f"Widget {widget} only as {len(children)}, asked for index {index}")
return None
return children[index]
@classmethod
def find_widget_path(cls, window: ui.Window, widget: ui.Widget) -> Union[str, None]:
def traverse_widget_tree_for_match(
location: ui.Widget, current_path: str, searched_widget: ui.Widget
) -> Union[str, None]:
current_index = 0
current_children = ui.Inspector.get_children(location)
for a_child in current_children:
class_name = a_child.__class__.__name__
if a_child == widget:
return f"{current_path}[{current_index}]/{class_name}"
if isinstance(a_child, ui.Container):
path = traverse_widget_tree_for_match(
a_child, f"{current_path}[{current_index}]/{class_name}", searched_widget
)
if path:
return path
current_index = current_index + 1
return None
if window:
start_path = f"{window.title}/Frame"
return traverse_widget_tree_for_match(window.frame, start_path, widget)
else:
return None
@classmethod
def find_menu_item(cls, query: str) -> Optional[ui.Widget]:
from omni.kit.mainwindow import get_main_window
main_menu_bar = get_main_window().get_main_menu_bar()
if not main_menu_bar:
carb.log_warn("Current App doesn't have a MainMenuBar")
return None
tokens = query.split("/")
current_children = main_menu_bar
for i in range(1, len(tokens)):
last = i == len(tokens) - 1
child = InspectorQuery.child_widget(current_children, tokens[i], last)
if not child:
carb.log_warn(f"Failed to find Child Widget at level {tokens[i]}")
return None
current_children = child
return current_children
@classmethod
def find_context_menu_item(cls, query: str, menu_root: ui.Menu) -> Optional[ui.Widget]:
menu_items = ui.Inspector.get_children(menu_root)
for menu_item in menu_items:
if isinstance(menu_item, ui.MenuItem):
if query in menu_item.text:
return menu_item
return None
@classmethod
def find_widget(cls, query: str) -> Union[ui.Widget, None]:
if not query:
return None
tokens = query.split("/")
window = ui.Workspace.get_window(tokens[0])
if not window:
carb.log_warn(f"Failed to find window: {tokens[0]}")
return None
if not isinstance(window, ui.Window):
carb.log_warn(f"window: {tokens[0]} is not a ui.Window, query only work on ui.Window")
return None
if not (tokens[1] == "Frame" or tokens[1] == "Frame[0]"):
carb.log_warn("Query currently only Support '<WindowName>/Frame/* or <WindowName>/Frame[0]/ type of query")
return None
frame = window.frame
if len(tokens) == 2:
return frame
if tokens[-1] == "":
tokens = tokens[:-1]
current_children = ui.Inspector.get_children(frame)[0]
for i in range(2, len(tokens)):
last = i == len(tokens) - 1
child = InspectorQuery.child_widget(current_children, tokens[i], last)
if not child:
carb.log_warn(f"Failed to find Child Widget at level {tokens[i]}")
return None
current_children = child
return current_children
| 4,854 | Python | 33.928057 | 119 | 0.559333 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/delegates/type_column_delegate.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
__all__ = ["TypeColumnDelegate"]
from ..abstract_stage_column_delegate import AbstractStageColumnDelegate
from ..stage_model import StageModel, StageItemSortPolicy
from ..stage_item import StageItem
from typing import List
from enum import Enum
import omni.ui as ui
class TypeColumnSortPolicy(Enum):
DEFAULT = 0
A_TO_Z = 1
Z_TO_A = 2
class TypeColumnDelegate(AbstractStageColumnDelegate):
"""The column delegate that represents the type column"""
def __init__(self):
super().__init__()
self.__name_label_layout = None
self.__name_label = None
self.__items_sort_policy = TypeColumnSortPolicy.DEFAULT
self.__stage_model: StageModel = None
def destroy(self):
if self.__name_label_layout:
self.__name_label_layout.set_mouse_pressed_fn(None)
@property
def initial_width(self):
"""The width of the column"""
return ui.Pixel(100)
def __initialize_policy_from_model(self):
stage_model = self.__stage_model
if not stage_model:
return
if stage_model.get_items_sort_policy() == StageItemSortPolicy.TYPE_COLUMN_A_TO_Z:
self.__items_sort_policy = TypeColumnSortPolicy.A_TO_Z
elif stage_model.get_items_sort_policy() == StageItemSortPolicy.TYPE_COLUMN_Z_TO_A:
self.__items_sort_policy = TypeColumnSortPolicy.Z_TO_A
else:
self.__items_sort_policy = TypeColumnSortPolicy.DEFAULT
self.__update_label_from_policy()
def __update_label_from_policy(self):
if not self.__name_label:
return
if self.__name_label:
if self.__items_sort_policy == TypeColumnSortPolicy.A_TO_Z:
name = "Type (A to Z)"
elif self.__items_sort_policy == TypeColumnSortPolicy.Z_TO_A:
name = "Type (Z to A)"
else:
name = "Type"
self.__name_label.text = name
def __on_policy_changed(self):
stage_model = self.__stage_model
if not stage_model:
return
if self.__items_sort_policy == TypeColumnSortPolicy.A_TO_Z:
stage_model.set_items_sort_policy(StageItemSortPolicy.TYPE_COLUMN_A_TO_Z)
elif self.__items_sort_policy == TypeColumnSortPolicy.Z_TO_A:
stage_model.set_items_sort_policy(StageItemSortPolicy.TYPE_COLUMN_Z_TO_A)
else:
stage_model.set_items_sort_policy(StageItemSortPolicy.DEFAULT)
self.__update_label_from_policy()
def __on_name_label_clicked(self, x, y, b, m):
stage_model = self.__stage_model
if b != 0 or not stage_model:
return
if self.__items_sort_policy == TypeColumnSortPolicy.A_TO_Z:
self.__items_sort_policy = TypeColumnSortPolicy.Z_TO_A
elif self.__items_sort_policy == TypeColumnSortPolicy.Z_TO_A:
self.__items_sort_policy = TypeColumnSortPolicy.DEFAULT
else:
self.__items_sort_policy = TypeColumnSortPolicy.A_TO_Z
self.__on_policy_changed()
def build_header(self, **kwargs):
"""Build the header"""
stage_model = kwargs.get("stage_model", None)
self.__stage_model = stage_model
if stage_model:
self.__name_label_layout = ui.HStack()
with self.__name_label_layout:
ui.Spacer(width=10)
self.__name_label = ui.Label(
"Type", name="columnname", style_type_name_override="TreeView.Header"
)
self.__initialize_policy_from_model()
self.__name_label_layout.set_mouse_pressed_fn(self.__on_name_label_clicked)
else:
self.__name_label_layout.set_mouse_pressed_fn(None)
with ui.HStack():
ui.Spacer(width=10)
ui.Label("Type", name="columnname", style_type_name_override="TreeView.Header")
async def build_widget(self, _, **kwargs):
"""Build the type widget"""
item = kwargs.get("stage_item", None)
if not item or not item.stage:
return
prim = item.stage.GetPrimAtPath(item.path)
if not prim or not prim.IsValid():
return
with ui.HStack(enabled=not item.instance_proxy, spacing=4, height=20):
ui.Spacer(width=4)
ui.Label(item.type_name, width=0, name="object_name", style_type_name_override="TreeView.Item")
def on_stage_items_destroyed(self, items: List[StageItem]):
pass
@property
def sortable(self):
return True
@property
def order(self):
return -100
@property
def minimum_width(self):
return ui.Pixel(20)
| 5,139 | Python | 33.039735 | 107 | 0.616852 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/delegates/visibility_column_delegate.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
__all__ = ["VisibilityColumnDelegate"]
from ..abstract_stage_column_delegate import AbstractStageColumnDelegate
from ..stage_model import StageModel, StageItemSortPolicy
from ..stage_item import StageItem
from pxr import UsdGeom
from typing import List
from functools import partial
from enum import Enum
import weakref
import omni.ui as ui
class VisibilityColumnSortPolicy(Enum):
DEFAULT = 0
INVISIBLE_TO_VISIBLE = 1
VISIBLE_TO_INVISIBLE = 2
class VisibilityColumnDelegate(AbstractStageColumnDelegate):
"""The column delegate that represents the visibility column"""
def __init__(self):
super().__init__()
self.__visibility_layout = None
self.__items_sort_policy = VisibilityColumnSortPolicy.DEFAULT
self.__stage_model: StageModel = None
def destroy(self):
if self.__visibility_layout:
self.__visibility_layout.set_mouse_pressed_fn(None)
self.__visibility_layout = None
self.__stage_model = None
@property
def initial_width(self):
"""The width of the column"""
return ui.Pixel(24)
def __initialize_policy_from_model(self):
stage_model = self.__stage_model
if not stage_model:
return
if stage_model.get_items_sort_policy() == StageItemSortPolicy.VISIBILITY_COLUMN_INVISIBLE_TO_VISIBLE:
self.__items_sort_policy = VisibilityColumnSortPolicy.INVISIBLE_TO_VISIBLE
elif stage_model.get_items_sort_policy() == StageItemSortPolicy.VISIBILITY_COLUMN_VISIBLE_TO_INVISIBLE:
self.__items_sort_policy = VisibilityColumnSortPolicy.VISIBLE_TO_INVISIBLE
else:
self.__items_sort_policy = VisibilityColumnSortPolicy.DEFAULT
def __on_policy_changed(self):
stage_model = self.__stage_model
if not stage_model:
return
if self.__items_sort_policy == VisibilityColumnSortPolicy.INVISIBLE_TO_VISIBLE:
stage_model.set_items_sort_policy(StageItemSortPolicy.VISIBILITY_COLUMN_INVISIBLE_TO_VISIBLE)
elif self.__items_sort_policy == VisibilityColumnSortPolicy.VISIBLE_TO_INVISIBLE:
stage_model.set_items_sort_policy(StageItemSortPolicy.VISIBILITY_COLUMN_VISIBLE_TO_INVISIBLE)
else:
stage_model.set_items_sort_policy(StageItemSortPolicy.DEFAULT)
def __on_visiblity_clicked(self, x, y, b, m):
if b != 0 or not self.__stage_model:
return
if self.__items_sort_policy == VisibilityColumnSortPolicy.VISIBLE_TO_INVISIBLE:
self.__items_sort_policy = VisibilityColumnSortPolicy.INVISIBLE_TO_VISIBLE
elif self.__items_sort_policy == VisibilityColumnSortPolicy.INVISIBLE_TO_VISIBLE:
self.__items_sort_policy = VisibilityColumnSortPolicy.DEFAULT
else:
self.__items_sort_policy = VisibilityColumnSortPolicy.VISIBLE_TO_INVISIBLE
self.__on_policy_changed()
def build_header(self, **kwargs):
"""Build the header"""
stage_model = kwargs.get("stage_model", None)
self.__stage_model = stage_model
self.__initialize_policy_from_model()
if stage_model:
with ui.ZStack():
ui.Rectangle(name="hovering", style_type_name_override="TreeView.Header")
self.__visibility_layout = ui.HStack()
with self.__visibility_layout:
ui.Spacer()
with ui.VStack(width=0):
ui.Spacer()
ui.Image(width=22, height=14, name="visibility_header", style_type_name_override="TreeView.Header")
ui.Spacer()
ui.Spacer()
self.__visibility_layout.set_mouse_pressed_fn(self.__on_visiblity_clicked)
else:
with ui.HStack():
ui.Spacer()
with ui.VStack(width=0):
ui.Spacer()
ui.Image(width=22, height=14, name="visibility_header", style_type_name_override="TreeView.Header")
ui.Spacer()
ui.Spacer()
async def build_widget(self, _, **kwargs):
"""Build the eye widget"""
item = kwargs.get("stage_item", None)
if not item or not item.prim or not item.prim.IsA(UsdGeom.Imageable):
return
with ui.ZStack(height=20):
# Min size
ui.Spacer(width=22)
# TODO the way to make this widget grayed out
ui.ToolButton(item.visibility_model, enabled=not item.instance_proxy, name="visibility")
@property
def order(self):
# Ensure it's always to the leftmost column except the name column.
return -101
@property
def sortable(self):
return True
def on_stage_items_destroyed(self, items: List[StageItem]):
pass
@property
def minimum_width(self):
return ui.Pixel(20)
| 5,352 | Python | 36.964539 | 123 | 0.640882 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/delegates/__init__.py | # Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from .name_column_delegate import *
from .type_column_delegate import *
from .visibility_column_delegate import *
| 547 | Python | 44.666663 | 76 | 0.804388 |
omniverse-code/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/delegates/name_column_delegate.py | # Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
__all__ = ["NameColumnDelegate"]
import asyncio
import math
import omni.ui as ui
from ..abstract_stage_column_delegate import AbstractStageColumnDelegate
from ..stage_model import StageModel, StageItemSortPolicy
from ..stage_item import StageItem
from ..stage_icons import StageIcons
from functools import partial
from typing import List
from enum import Enum
class NameColumnSortPolicy(Enum):
NEW_TO_OLD = 0
OLD_TO_NEW = 1
A_TO_Z = 2
Z_TO_A = 3
def split_selection(text, selection):
"""
Split given text to substrings to draw selected text. Result starts with unselected text.
Example: "helloworld" "o" -> ["hell", "o", "w", "o", "rld"]
Example: "helloworld" "helloworld" -> ["", "helloworld"]
"""
if not selection or text == selection:
return ["", text]
selection = selection.lower()
selection_len = len(selection)
result = []
while True:
found = text.lower().find(selection)
result.append(text if found < 0 else text[:found])
if found < 0:
break
else:
result.append(text[found : found + selection_len])
text = text[found + selection_len :]
return result
class NameColumnDelegate(AbstractStageColumnDelegate):
"""The column delegate that represents the type column"""
def __init__(self):
super().__init__()
self.__name_label_layout = None
self.__name_label = None
self.__drop_down_layout = None
self.__name_sort_options_menu = None
self.__items_sort_policy = NameColumnSortPolicy.OLD_TO_NEW
self.__highlighting_enabled = None
# Text that is highlighted in flat mode
self.__highlighting_text = None
self.__stage_model: StageModel = None
def set_highlighting(self, enable: bool = None, text: str = None):
"""
Specify if the widgets should consider highlighting. Also set the text that should be highlighted in flat mode.
"""
if enable is not None:
self.__highlighting_enabled = enable
if text is not None:
self.__highlighting_text = text.lower()
@property
def sort_policy(self):
return self.__items_sort_policy
@sort_policy.setter
def sort_policy(self, value):
if self.__items_sort_policy != value:
self.__items_sort_policy = value
self.__on_policy_changed()
def destroy(self):
if self.__name_label_layout:
self.__name_label_layout.set_mouse_pressed_fn(None)
if self.__drop_down_layout:
self.__drop_down_layout.set_mouse_pressed_fn(None)
self.__drop_down_layout = None
self.__name_sort_options_menu = None
if self.__name_label_layout:
self.__name_label_layout.set_mouse_pressed_fn(None)
self.__name_label_layout = None
self.__stage_model = None
@property
def initial_width(self):
"""The width of the column"""
return ui.Fraction(1)
def __initialize_policy_from_model(self):
stage_model = self.__stage_model
if not stage_model:
return
if stage_model.get_items_sort_policy() == StageItemSortPolicy.NAME_COLUMN_NEW_TO_OLD:
self.__items_sort_policy = NameColumnSortPolicy.NEW_TO_OLD
elif stage_model.get_items_sort_policy() == StageItemSortPolicy.NAME_COLUMN_A_TO_Z:
self.__items_sort_policy = NameColumnSortPolicy.A_TO_Z
elif stage_model.get_items_sort_policy() == StageItemSortPolicy.NAME_COLUMN_Z_TO_A:
self.__items_sort_policy = NameColumnSortPolicy.Z_TO_A
else:
self.__items_sort_policy = NameColumnSortPolicy.OLD_TO_NEW
self.__update_label_from_policy()
def __update_label_from_policy(self):
if not self.__name_label:
return
if self.__items_sort_policy == NameColumnSortPolicy.NEW_TO_OLD:
name = "Name (New to Old)"
elif self.__items_sort_policy == NameColumnSortPolicy.A_TO_Z:
name = "Name (A to Z)"
elif self.__items_sort_policy == NameColumnSortPolicy.Z_TO_A:
name = "Name (Z to A)"
else:
name = "Name (Old to New)"
self.__name_label.text = name
def __on_policy_changed(self):
stage_model = self.__stage_model
if not stage_model:
return
if self.__items_sort_policy == NameColumnSortPolicy.NEW_TO_OLD:
stage_model.set_items_sort_policy(StageItemSortPolicy.NAME_COLUMN_NEW_TO_OLD)
elif self.__items_sort_policy == NameColumnSortPolicy.A_TO_Z:
stage_model.set_items_sort_policy(StageItemSortPolicy.NAME_COLUMN_A_TO_Z)
elif self.__items_sort_policy == NameColumnSortPolicy.Z_TO_A:
stage_model.set_items_sort_policy(StageItemSortPolicy.NAME_COLUMN_Z_TO_A)
else:
stage_model.set_items_sort_policy(StageItemSortPolicy.NAME_COLUMN_OLD_TO_NEW)
self.__update_label_from_policy()
def __on_name_label_clicked(self, x, y, b, m):
if b != 0 or not self.__stage_model:
return
if self.__items_sort_policy == NameColumnSortPolicy.A_TO_Z:
self.__items_sort_policy = NameColumnSortPolicy.Z_TO_A
elif self.__items_sort_policy == NameColumnSortPolicy.Z_TO_A:
self.__items_sort_policy = NameColumnSortPolicy.NEW_TO_OLD
elif self.__items_sort_policy == NameColumnSortPolicy.NEW_TO_OLD:
self.__items_sort_policy = NameColumnSortPolicy.OLD_TO_NEW
else:
self.__items_sort_policy = NameColumnSortPolicy.A_TO_Z
self.__on_policy_changed()
def build_header(self, **kwargs):
"""Build the header"""
style_type_name = "TreeView.Header"
stage_model = kwargs.get("stage_model", None)
self.__stage_model = stage_model
if stage_model:
with ui.HStack():
self.__name_label_layout = ui.HStack()
self.__name_label_layout.set_mouse_pressed_fn(self.__on_name_label_clicked)
with self.__name_label_layout:
ui.Spacer(width=10)
self.__name_label = ui.Label(
"Name", name="columnname", style_type_name_override=style_type_name
)
self.__initialize_policy_from_model()
ui.Spacer()
with ui.ZStack(width=16):
ui.Rectangle(name="drop_down_hovered_area", style_type_name_override=style_type_name)
self.__drop_down_layout = ui.ZStack(width=0)
with self.__drop_down_layout:
ui.Rectangle(width=16, name="drop_down_background", style_type_name_override=style_type_name)
with ui.HStack():
ui.Spacer()
with ui.VStack(width=0):
ui.Spacer(height=4)
ui.Triangle(
name="drop_down_button",
width=8, height=8,
style_type_name_override=style_type_name,
alignment=ui.Alignment.CENTER_BOTTOM
)
ui.Spacer(height=2)
ui.Spacer()
ui.Spacer(width=4)
def on_sort_policy_changed(policy, value):
if self.sort_policy != policy:
self.sort_policy = policy
self.__on_policy_changed()
def on_mouse_pressed_fn(x, y, b, m):
if b != 0:
return
items_sort_policy = self.__items_sort_policy
self.__name_sort_options_menu = ui.Menu("Sort Options")
with self.__name_sort_options_menu:
ui.MenuItem("Sort By", enabled=False)
ui.Separator()
ui.MenuItem(
"New to Old",
checkable=True,
checked=items_sort_policy == NameColumnSortPolicy.NEW_TO_OLD,
checked_changed_fn=partial(
on_sort_policy_changed,
NameColumnSortPolicy.NEW_TO_OLD
),
hide_on_click=False,
)
ui.MenuItem(
"Old to New",
checkable=True,
checked=items_sort_policy == NameColumnSortPolicy.OLD_TO_NEW,
checked_changed_fn=partial(
on_sort_policy_changed,
NameColumnSortPolicy.OLD_TO_NEW
),
hide_on_click=False,
)
ui.MenuItem(
"A to Z",
checkable=True,
checked=items_sort_policy == NameColumnSortPolicy.A_TO_Z,
checked_changed_fn=partial(
on_sort_policy_changed,
NameColumnSortPolicy.A_TO_Z
),
hide_on_click=False
)
ui.MenuItem(
"Z to A",
checkable=True,
checked=items_sort_policy == NameColumnSortPolicy.Z_TO_A,
checked_changed_fn=partial(
on_sort_policy_changed,
NameColumnSortPolicy.Z_TO_A
),
hide_on_click=False
)
self.__name_sort_options_menu.show()
self.__drop_down_layout.set_mouse_pressed_fn(on_mouse_pressed_fn)
self.__drop_down_layout.visible = False
else:
self.__name_label_layout.set_mouse_pressed_fn(None)
with ui.HStack():
ui.Spacer(width=10)
ui.Label("Name", name="columnname", style_type_name_override="TreeView.Header")
def get_type_icon(self, node_type):
"""Convert USD Type to icon file name"""
icons = StageIcons()
if node_type in ["DistantLight", "SphereLight", "RectLight", "DiskLight", "CylinderLight", "DomeLight"]:
return icons.get(node_type, "Light")
if node_type == "":
node_type = "Xform"
return icons.get(node_type, "Prim")
async def build_widget(self, _, **kwargs):
self.build_widget_async(_, **kwargs)
def __get_all_icons_to_draw(self, item: StageItem, item_is_native):
# Get the node type
node_type = item.type_name if item != item.stage_model.root else None
icon_filenames = [self.get_type_icon(node_type)]
# Get additional icons based on the properties of StageItem
if item_is_native:
if item.references:
icon_filenames.append(StageIcons().get("Reference"))
if item.payloads:
icon_filenames.append(StageIcons().get("Payload"))
if item.instanceable:
icon_filenames.append(StageIcons().get("Instance"))
return icon_filenames
def __draw_all_icons(self, item: StageItem, item_is_native, is_highlighted):
icon_filenames = self.__get_all_icons_to_draw(item, item_is_native)
# Gray out the icon if the filter string is not in the text
iconname = "object_icon" if is_highlighted else "object_icon_grey"
parent_layout = ui.ZStack(width=20, height=20)
with parent_layout:
for icon_filename in icon_filenames:
ui.Image(icon_filename, name=iconname, style_type_name_override="TreeView.Image")
if item.instance_proxy:
parent_layout.set_tooltip("Instance Proxy")
def __build_rename_field(self, item: StageItem, name_labels, parent_stack):
def on_end_edit(name_labels, field):
for label in name_labels:
label.visible = True
field.visible = False
self.end_edit_subscription = None
def on_mouse_double_clicked(button, name_labels, field):
if button != 0 or item.instance_proxy:
return
for label in name_labels:
label.visible = False
field.visible = True
self.end_edit_subscription = field.model.subscribe_end_edit_fn(lambda _: on_end_edit(name_labels, field))
import omni.kit.app
async def focus(field):
await omni.kit.app.get_app().next_update_async()
field.focus_keyboard()
asyncio.ensure_future(focus(field))
field = ui.StringField(item.name_model, identifier="rename_field", visible=False)
parent_stack.set_mouse_double_clicked_fn(
lambda x, y, b, _: on_mouse_double_clicked(b, name_labels, field)
)
item._ui_widget = parent_stack
def build_widget_sync(self, _, **kwargs):
"""Build the type widget"""
# True if it's StageItem. We need it to determine if it's a Root item (which is None).
model = kwargs.get("stage_model", None)
item = kwargs.get("stage_item", None)
if not item:
item = model.root
item_is_native = False
else:
item_is_native = True
if not item:
return
# If highlighting disabled completley, all the items should be light
is_highlighted = not self.__highlighting_enabled and not self.__highlighting_text
if not is_highlighted:
# If it's not disabled completley
is_highlighted = item_is_native and item.filtered
with ui.HStack(enabled=not item.instance_proxy, spacing=4, height=20):
# Draw all icons on top of each other
self.__draw_all_icons(item, item_is_native, is_highlighted)
value_model = item.name_model
text = value_model.get_value_as_string()
stack = ui.HStack()
name_labels = []
# We have three different text draw model depending on the column and on the highlighting state
if item_is_native and model.flat:
# Flat search mode. We need to highlight only the part that is is the search field
selection_chain = split_selection(text, self.__highlighting_text)
labelnames_chain = ["object_name_grey", "object_name"]
# Extend the label names depending on the size of the selection chain. Example, if it was [a, b]
# and selection_chain is [z,y,x,w], it will become [a, b, a, b].
labelnames_chain *= int(math.ceil(len(selection_chain) / len(labelnames_chain)))
with stack:
for current_text, current_name in zip(selection_chain, labelnames_chain):
if not current_text:
continue
label = ui.Label(
current_text,
name=current_name,
width=0,
style_type_name_override="TreeView.Item",
hide_text_after_hash=False
)
name_labels.append(label)
if hasattr(item, "_callback_id"):
item._callback_id = None
else:
with stack:
if item.has_missing_references:
name = "object_name_missing"
else:
name = "object_name" if is_highlighted else "object_name_grey"
if item.is_outdated:
name = "object_name_outdated"
if item.in_session:
name = "object_name_live"
if item.is_outdated:
style_override = "TreeView.Item.Outdated"
elif item.in_session:
style_override = "TreeView.Item.Live"
else:
style_override = "TreeView.Item"
text = value_model.get_value_as_string()
if item.is_default:
text += " (defaultPrim)"
label = ui.Label(
text, hide_text_after_hash=False,
name=name, style_type_name_override=style_override
)
if item.has_missing_references:
label.set_tooltip("Missing references found.")
name_labels.append(label)
# The hidden field for renaming the prim
if item != model.root and not item.instance_proxy:
self.__build_rename_field(item, name_labels, stack)
elif hasattr(item, "_ui_widget"):
item._ui_widget = None
def rename_item(self, item: StageItem):
if not item or not hasattr(item, "_ui_widget") or not item._ui_widget or item.instance_proxy:
return
item._ui_widget.call_mouse_double_clicked_fn(0, 0, 0, 0)
def on_stage_items_destroyed(self, items: List[StageItem]):
for item in items:
if hasattr(item, "_ui_widget"):
item._ui_widget = None
def on_header_hovered(self, hovered):
self.__drop_down_layout.visible = hovered
@property
def sortable(self):
return True
@property
def order(self):
return -100000
@property
def minimum_width(self):
return ui.Pixel(40)
| 18,548 | Python | 38.050526 | 119 | 0.537578 |
omniverse-code/kit/exts/omni.kit.widget.stage/docs/CHANGELOG.md | # Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [2.7.24] - 2023-02-21
### Fixed
- OM-82577: Drag&drop of flowusd presets will call flowusd command to add a reference.
## [2.7.23] - 2023-02-16
### Fixed
- OM-81767: Drag&drop behaviour of sbsar files now consistent with viewport's behaviour.
## [2.7.22] - 2023-01-11
### Updated
- Allow to select children under instance.
- Fix selection issue after clearing search text.
- Move SelectionWatch from omni.kit.window.stage to provide default implementation.
## [2.7.21] - 2022-12-9
### Updated
- Fixed issue where drag & drop material urls with encoded subidentifiers were not being handled.
## [2.7.20] - 2022-12-14
### Updated
- Improve drag and drop style.
## [2.7.19] - 2022-12-09
### Updated
- Improve filter and search.
- Fix issue that creates new prims will not be filtered when it's in filtering mode.
- Add support to search with prim path.
## [2.7.18] - 2022-12-08
### Updated
- Fix style of search results in stage window.
## [2.7.17] - 2022-11-29
### Updated
- Don't show context menu for converting references or payloads if they are not in the local layer stack.
## [2.7.16] - 2022-11-29
### Updated
- Don't show context menu for header of stage widget.
## [2.7.15] - 2022-11-15
### Updated
- Fixed issue with context menu & not hovering over label
## [2.7.14] - 2022-11-14
### Updated
- Supports sorting by name/visibility/type.
## [2.7.13] - 2022-11-14
### Updated
- Fix issue to search or filter stage window.
## [2.7.12] - 2022-11-07
### Updated
- Optimize more loading time to avoid populating tree item when it's to get children count.
## [2.7.11] - 2022-11-04
### Updated
- Refresh prim handle when it's resyced to avoid access staled prim.
## [2.7.10] - 2022-11-03
### Updated
- Support to show 'displayName' of prim from metadata.
## [2.7.9] - 2022-11-02
### Updated
- Drag and drop assets to default prim from content browser if default prim is existed.
## [2.7.8] - 2022-11-01
### Updated
- Fix rename issue.
## [2.7.7] - 2022-10-25
### Updated
- More optimization to stage window refresh without traversing.
## [2.7.6] - 2022-09-13
### Updated
- Don't use "use_hovered" for context menu objects when user click nowhere
## [2.7.5] - 2022-09-10
- Add TreeView drop style to show hilighting.
## [2.7.4] - 2022-09-08
### Updated
- Added "use_hovered" to context menu objects so menu can create child prims
## [2.7.3] - 2022-08-31
### Fixed
- Moved eye icon to front of ZStack to receive mouse clicks.
## [2.7.2] - 2022-08-12
### Fixed
- Updated context menu behaviour
## [2.7.1] - 2022-08-13
- Fix prims filter.
- Clear prims filter after stage switching.
## [2.7.0] - 2022-08-06
- Refactoring stage model to improve perf and fix issue of refresh.
## [2.6.26] - 2022-08-04
- Support multi-selection for toggling visibility
## [2.6.25] - 2022-08-02
### Fixed
- Show non-defined prims as well.
## [2.6.24] - 2022-07-28
### Fixed
- Fix regression to drag and drop prim to absolute root.
## [2.6.23] - 2022-07-28
### Fixed
- Ensure rename operation non-destructive.
## [2.6.23] - 2022-07-25
### Changes
- Refactored unittests to make use of content_browser test helpers
## [2.6.22] - 2022-07-18
### Fixed
- Restored the arguments of ExportPrimUSD
## [2.6.21] - 2022-07-05
- Replaced filepicker dialog with file exporter
## [2.6.20] - 2022-06-23
- Make material paths relative if "/persistent/app/material/dragDropMaterialPath" is set to "relative"
## [2.6.19] - 2022-06-22
- Multiple drag and drop support.
## [2.6.18] - 2022-05-31
- Changed "Export Selected" to "Save Selected"
## [2.6.17] - 2022-05-20
- Support multi-selection for toggling visibility
## [2.6.16] - 2022-05-17
- Support multi-file drag & drop
## [2.6.15] - 2022-04-28
- Drag & Drop can create payload or reference based on /persistent/app/stage/dragDropImport setting
## [2.6.14] - 2022-03-09
- Updated unittests to retrieve the treeview widget from content browser.
## [2.6.13] - 2022-03-07
- Expand default prim
## [2.6.12] - 2022-02-09
- Fix stage window refresh after sublayer is inserted/removed.
## [2.6.11] - 2022-01-26
- Fix the columns item not able to reorder
## [2.6.10] - 2022-01-05
- Support drag/drop from material browser
## [2.6.9] - 2021-11-03
- Updated to use new omni.kit.material.library `get_subidentifier_from_mdl`
## [2.6.8] - 2021-09-24
- Fix export selected prims if it has external dependences outside of the copy prim tree.
## [2.6.7] - 2021-09-17
- Copy axis after export selected prims.
## [2.6.6] - 2021-08-11
- Updated drag/drop material to no-prim to not bind to /World
- Added drag/drop test
## [2.6.5] - 2021-08-11
- Updated to lastest omni.kit.material.library
## [2.6.4] - 2021-07-26
- Added "Refesh Payload" to context menu
- Added Payload icon
- Added "Convert Payloads to References" to context menu
- Added "Convert References to Payloads" to context menu
## [2.6.3] - 2021-07-21
- Added "Refesh Reference" to context menu
## [2.6.2] - 2021-06-30
- Changed "Assign Material" to use async show function as it could be slow on large scenes
## [2.6.1] - 2021-06-02
- Changed export prim as usd, postfix name now lowercase
## [2.6.0] - 2021-06-16
### Added
- "Show Missing Reference" that is off by default. When it's on, missing
references are displayed with red color in the tree.
### Changed
- Indentation level. There is no offset on the left anymore.
## [2.5.0] - 2021-06-02
- Added export prim as usd
## [2.4.2] - 2021-04-29
- Use sub-material selector on material import
## [2.4.1] - 2021-04-09
### Fixed
- Context menu in extensions that are not omni.kit.window.stage
## [2.4.0] - 2021-03-19
### Added
- Supported accepting drag and drop to create versioned reference.
## [2.3.7] - 2021-03-17
### Changed
- Updated to new context_menu and how custom functions are added
## [2.3.6] - 2021-03-01
### Changed
- Additional check if the stage and prim are still valid
## [2.3.5] - 2021-02-23
### Added
- Exclusion list allows to hide prims of specific types silently. To hide the
prims of specific type, set the string array setting
`ext/omni.kit.widget.stage/exclusion/types`
```
[settings]
ext."omni.kit.widget.stage".exclusion.types = ["Mesh"]
```
## [2.3.4] - 2021-02-10
### Changes
- Updated StyleUI handling
## [2.3.3] - 2020-11-16
### Changed
- Updated Find In Browser
## [2.3.2] - 2020-11-13
### Changed
- Fixed disappearing the "eye" icon when searched objects are toggled off
## [2.3.1] - 2020-10-22
### Added
- An interface to add and remove the icons in the TreeView dependin on the prim type
### Removed
- The standard prim icons are moved to omni.kit.widget.stage_icons
## [2.3.0] - 2020-09-16
### Changed
- Split to two parts: omni.kit.widget.stage and omni.kit.window.stage
## [2.2.0] - 2020-09-15
### Changed - Detached from Editor and using UsdNotice for notifications
| 6,926 | Markdown | 25.438931 | 105 | 0.6838 |
omniverse-code/kit/exts/omni.kit.test_suite.layout/omni/kit/test_suite/layout/__init__.py | from .scripts import *
| 23 | Python | 10.999995 | 22 | 0.73913 |
omniverse-code/kit/exts/omni.kit.test_suite.layout/omni/kit/test_suite/layout/tests/__init__.py | from .compare_layout import *
from .verify_dockspace import *
| 62 | Python | 19.999993 | 31 | 0.774194 |
omniverse-code/kit/exts/omni.kit.test_suite.layout/omni/kit/test_suite/layout/tests/verify_dockspace.py | ## Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
import carb
import omni.kit.test
import omni.kit.app
import omni.ui as ui
import omni.kit.commands
from omni.kit.test.async_unittest import AsyncTestCase
from omni.kit import ui_test
from omni.kit.test_suite.helpers import get_test_data_path, arrange_windows
class VerifyDockspace(AsyncTestCase):
# Before running each test
async def setUp(self):
await arrange_windows("Stage", 256)
await omni.usd.get_context().new_stage_async()
omni.kit.commands.execute("CreatePrimWithDefaultXform", prim_type="Sphere", select_new_prim=True)
# After running each test
async def tearDown(self):
pass
async def test_verify_dockspace(self):
# verify "Dockspace" window doesn't disapear when a prim is selected as this breaks layout load/save
omni.usd.get_context().get_selection().set_selected_prim_paths([], True)
await ui_test.human_delay(100)
self.assertNotEqual(ui.Workspace.get_window("DockSpace"), None)
omni.usd.get_context().get_selection().set_selected_prim_paths(["/Sphere"], True)
await ui_test.human_delay(100)
self.assertNotEqual(ui.Workspace.get_window("DockSpace"), None)
async def test_verify_dockspace_shutdown(self):
self._hooks = []
self._hooks.append(omni.kit.app.get_app().get_shutdown_event_stream().create_subscription_to_pop_by_type(
omni.kit.app.POST_QUIT_EVENT_TYPE,
self._on_shutdown_handler,
name="omni.create.app.setup shutdown for layout",
order=0))
omni.usd.get_context().get_selection().set_selected_prim_paths(["/Sphere"], True)
await ui_test.human_delay(100)
def _on_shutdown_handler(self, e: carb.events.IEvent):
# verify "Dockspace" window hasn't disapeared as prims are selected as this breaks layout load/save
print("running _on_shutdown_handler test")
self.assertNotEqual(ui.Workspace.get_window("DockSpace"), None)
| 2,418 | Python | 42.981817 | 113 | 0.702233 |
omniverse-code/kit/exts/omni.kit.test_suite.layout/omni/kit/test_suite/layout/tests/compare_layout.py | ## Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
import omni.kit.test
import omni.kit.app
import omni.ui as ui
from omni.kit.test.async_unittest import AsyncTestCase
from omni.kit import ui_test
from omni.kit.test_suite.helpers import get_test_data_path, arrange_windows
from omni.kit.quicklayout import QuickLayout
from omni.ui.workspace_utils import CompareDelegate
class CompareLayout(AsyncTestCase):
# Before running each test
async def setUp(self):
await arrange_windows("Stage", 256)
# After running each test
async def tearDown(self):
pass
async def test_compare_layout(self):
layout_path = get_test_data_path(__name__, "layout.json")
# compare layout, this should fail
result = QuickLayout.compare_file(layout_path)
self.assertNotEqual(result, [])
# load layout
QuickLayout.load_file(layout_path)
# need to pause as load_file does some async stuff
await ui_test.human_delay(10)
# compare layout, this should pass
result = QuickLayout.compare_file(layout_path)
self.assertEqual(result, [])
async def test_compare_layout_delegate(self):
called_delegate = False
layout_path = get_test_data_path(__name__, "layout.json")
class TestCompareDelegate(CompareDelegate):
def failed_get_window(self, error_list: list, target: dict):
nonlocal called_delegate
called_delegate = True
return super().failed_get_window(error_list, target)
def failed_window_key(self, error_list: list, key: str, target: dict, target_window: ui.Window):
nonlocal called_delegate
called_delegate = True
return super().failed_window_key(error_list, key, target, target_window)
def failed_window_value(self, error_list: list, key: str, value, target: dict, target_window: ui.Window):
nonlocal called_delegate
called_delegate = True
return super().failed_window_value(error_list, key, value, target, target_window)
def compare_value(self, key:str, value, target):
nonlocal called_delegate
called_delegate = True
return super().compare_value(key, value, target)
self.assertFalse(called_delegate)
# compare layout, this should fail
result = QuickLayout.compare_file(layout_path, compare_delegate=TestCompareDelegate())
self.assertNotEqual(result, [])
# load layout
QuickLayout.load_file(layout_path)
# need to pause as load_file does some async stuff
await ui_test.human_delay(10)
# compare layout, this should pass
result = QuickLayout.compare_file(layout_path, compare_delegate=TestCompareDelegate())
self.assertEqual(result, [])
self.assertTrue(called_delegate)
| 3,328 | Python | 36.829545 | 117 | 0.666166 |
omniverse-code/kit/exts/omni.kit.test_suite.layout/docs/index.rst | omni.kit.test_suite.layout
############################
layout tests
.. toctree::
:maxdepth: 1
CHANGELOG
| 114 | reStructuredText | 10.499999 | 28 | 0.508772 |
omniverse-code/kit/exts/omni.resourcemonitor/PACKAGE-LICENSES/omni.resourcemonitor-LICENSE.md | Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
NVIDIA CORPORATION and its licensors retain all intellectual property
and proprietary rights in and to this software, related documentation
and any modifications thereto. Any use, reproduction, disclosure or
distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited. | 412 | Markdown | 57.999992 | 74 | 0.839806 |
omniverse-code/kit/exts/omni.resourcemonitor/config/extension.toml | [package]
title = "Resource Monitor"
description = "Monitor utility for device and host memory"
authors = ["NVIDIA"]
changelog = "docs/CHANGELOG.md"
readme = "docs/README.md"
category = "Internal"
preview_image = "data/preview.png"
icon = "data/icon.png"
version = "1.0.0"
[dependencies]
"omni.kit.renderer.core" = {}
"omni.kit.window.preferences" = {}
[[python.module]]
name = "omni.resourcemonitor"
[[native.plugin]]
path = "bin/*.plugin"
# Additional python module with tests, to make them discoverable by test system
[[python.module]]
name = "omni.resourcemonitor.tests"
[[test]]
timeout = 300
| 603 | TOML | 20.571428 | 79 | 0.713101 |
omniverse-code/kit/exts/omni.resourcemonitor/omni/resourcemonitor/__init__.py | from .scripts.extension import *
| 33 | Python | 15.999992 | 32 | 0.787879 |
omniverse-code/kit/exts/omni.resourcemonitor/omni/resourcemonitor/_resourceMonitor.pyi | """pybind11 omni.resourcemonitor bindings"""
from __future__ import annotations
import omni.resourcemonitor._resourceMonitor
import typing
import carb.events._events
__all__ = [
"IResourceMonitor",
"ResourceMonitorEventType",
"acquire_resource_monitor_interface",
"deviceMemoryWarnFractionSettingName",
"deviceMemoryWarnMBSettingName",
"hostMemoryWarnFractionSettingName",
"hostMemoryWarnMBSettingName",
"release_resource_monitor_interface",
"sendDeviceMemoryWarningSettingName",
"sendHostMemoryWarningSettingName",
"timeBetweenQueriesSettingName"
]
class IResourceMonitor():
def get_available_device_memory(self, arg0: int) -> int: ...
def get_available_host_memory(self) -> int: ...
def get_event_stream(self) -> carb.events._events.IEventStream: ...
def get_total_device_memory(self, arg0: int) -> int: ...
def get_total_host_memory(self) -> int: ...
pass
class ResourceMonitorEventType():
"""
ResourceMonitor notification.
Members:
DEVICE_MEMORY
HOST_MEMORY
LOW_DEVICE_MEMORY
LOW_HOST_MEMORY
"""
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: int) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __repr__(self) -> str: ...
def __setstate__(self, state: int) -> None: ...
@property
def name(self) -> str:
"""
:type: str
"""
@property
def value(self) -> int:
"""
:type: int
"""
DEVICE_MEMORY: omni.resourcemonitor._resourceMonitor.ResourceMonitorEventType # value = <ResourceMonitorEventType.DEVICE_MEMORY: 0>
HOST_MEMORY: omni.resourcemonitor._resourceMonitor.ResourceMonitorEventType # value = <ResourceMonitorEventType.HOST_MEMORY: 1>
LOW_DEVICE_MEMORY: omni.resourcemonitor._resourceMonitor.ResourceMonitorEventType # value = <ResourceMonitorEventType.LOW_DEVICE_MEMORY: 2>
LOW_HOST_MEMORY: omni.resourcemonitor._resourceMonitor.ResourceMonitorEventType # value = <ResourceMonitorEventType.LOW_HOST_MEMORY: 3>
__members__: dict # value = {'DEVICE_MEMORY': <ResourceMonitorEventType.DEVICE_MEMORY: 0>, 'HOST_MEMORY': <ResourceMonitorEventType.HOST_MEMORY: 1>, 'LOW_DEVICE_MEMORY': <ResourceMonitorEventType.LOW_DEVICE_MEMORY: 2>, 'LOW_HOST_MEMORY': <ResourceMonitorEventType.LOW_HOST_MEMORY: 3>}
pass
def acquire_resource_monitor_interface(plugin_name: str = None, library_path: str = None) -> IResourceMonitor:
pass
def release_resource_monitor_interface(arg0: IResourceMonitor) -> None:
pass
deviceMemoryWarnFractionSettingName = '/persistent/resourcemonitor/deviceMemoryWarnFraction'
deviceMemoryWarnMBSettingName = '/persistent/resourcemonitor/deviceMemoryWarnMB'
hostMemoryWarnFractionSettingName = '/persistent/resourcemonitor/hostMemoryWarnFraction'
hostMemoryWarnMBSettingName = '/persistent/resourcemonitor/hostMemoryWarnMB'
sendDeviceMemoryWarningSettingName = '/persistent/resourcemonitor/sendDeviceMemoryWarning'
sendHostMemoryWarningSettingName = '/persistent/resourcemonitor/sendHostMemoryWarning'
timeBetweenQueriesSettingName = '/persistent/resourcemonitor/timeBetweenQueries'
| 3,333 | unknown | 40.674999 | 288 | 0.712571 |
omniverse-code/kit/exts/omni.resourcemonitor/omni/resourcemonitor/scripts/extension.py | import omni.ext
from .._resourceMonitor import *
class PublicExtension(omni.ext.IExt):
def on_startup(self):
self._resourceMonitor = acquire_resource_monitor_interface()
def on_shutdown(self):
release_resource_monitor_interface(self._resourceMonitor)
| 277 | Python | 26.799997 | 68 | 0.729242 |
omniverse-code/kit/exts/omni.resourcemonitor/omni/resourcemonitor/scripts/resource_monitor_page.py | import omni.ui as ui
from omni.kit.window.preferences import PreferenceBuilder, SettingType
from .. import _resourceMonitor
class ResourceMonitorPreferences(PreferenceBuilder):
def __init__(self):
super().__init__("Resource Monitor")
def build(self):
""" Resource Monitor """
with ui.VStack(height=0):
with self.add_frame("Resource Monitor"):
with ui.VStack():
self.create_setting_widget(
"Time Between Queries",
_resourceMonitor.timeBetweenQueriesSettingName,
SettingType.FLOAT,
)
self.create_setting_widget(
"Send Device Memory Warnings",
_resourceMonitor.sendDeviceMemoryWarningSettingName,
SettingType.BOOL,
)
self.create_setting_widget(
"Device Memory Warning Threshold (MB)",
_resourceMonitor.deviceMemoryWarnMBSettingName,
SettingType.INT,
)
self.create_setting_widget(
"Device Memory Warning Threshold (Fraction)",
_resourceMonitor.deviceMemoryWarnFractionSettingName,
SettingType.FLOAT,
range_from=0.,
range_to=1.,
)
self.create_setting_widget(
"Send Host Memory Warnings",
_resourceMonitor.sendHostMemoryWarningSettingName,
SettingType.BOOL
)
self.create_setting_widget(
"Host Memory Warning Threshold (MB)",
_resourceMonitor.hostMemoryWarnMBSettingName,
SettingType.INT,
)
self.create_setting_widget(
"Host Memory Warning Threshold (Fraction)",
_resourceMonitor.hostMemoryWarnFractionSettingName,
SettingType.FLOAT,
range_from=0.,
range_to=1.,
)
| 2,300 | Python | 41.61111 | 77 | 0.475652 |
omniverse-code/kit/exts/omni.resourcemonitor/omni/resourcemonitor/tests/__init__.py | """
Presence of this file allows the tests directory to be imported as a module so that all of its contents
can be scanned to automatically add tests that are placed into this directory.
"""
scan_for_test_modules = True
| 220 | Python | 35.833327 | 103 | 0.777273 |
omniverse-code/kit/exts/omni.resourcemonitor/omni/resourcemonitor/tests/test_resource_monitor.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import numpy as np
import carb.settings
import omni.kit.test
import omni.resourcemonitor as rm
class TestResourceSettings(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
self._savedSettings = {}
self._rm_interface = rm.acquire_resource_monitor_interface()
self._settings = carb.settings.get_settings()
# Save current settings
self._savedSettings[rm.timeBetweenQueriesSettingName] = \
self._settings.get_as_float(rm.timeBetweenQueriesSettingName)
self._savedSettings[rm.sendDeviceMemoryWarningSettingName] = \
self._settings.get_as_bool(rm.sendDeviceMemoryWarningSettingName)
self._savedSettings[rm.deviceMemoryWarnMBSettingName] = \
self._settings.get_as_int(rm.deviceMemoryWarnMBSettingName)
self._savedSettings[rm.deviceMemoryWarnFractionSettingName] = \
self._settings.get_as_float(rm.deviceMemoryWarnFractionSettingName)
self._savedSettings[rm.sendHostMemoryWarningSettingName] = \
self._settings.get_as_bool(rm.sendHostMemoryWarningSettingName)
self._savedSettings[rm.hostMemoryWarnMBSettingName] = \
self._settings.get_as_int(rm.hostMemoryWarnMBSettingName)
self._savedSettings[rm.hostMemoryWarnFractionSettingName] = \
self._settings.get_as_float(rm.hostMemoryWarnFractionSettingName)
# After running each test
async def tearDown(self):
# Restore settings
self._settings.set_float(
rm.timeBetweenQueriesSettingName,
self._savedSettings[rm.timeBetweenQueriesSettingName])
self._settings.set_bool(
rm.sendDeviceMemoryWarningSettingName,
self._savedSettings[rm.sendDeviceMemoryWarningSettingName])
self._settings.set_int(
rm.deviceMemoryWarnMBSettingName,
self._savedSettings[rm.deviceMemoryWarnMBSettingName])
self._settings.set_float(
rm.deviceMemoryWarnFractionSettingName,
self._savedSettings[rm.deviceMemoryWarnFractionSettingName])
self._settings.set_bool(
rm.sendHostMemoryWarningSettingName,
self._savedSettings[rm.sendHostMemoryWarningSettingName])
self._settings.set_int(
rm.hostMemoryWarnMBSettingName,
self._savedSettings[rm.hostMemoryWarnMBSettingName])
self._settings.set_float(
rm.hostMemoryWarnFractionSettingName,
self._savedSettings[rm.hostMemoryWarnFractionSettingName])
async def test_resource_monitor(self):
"""
Test host memory warnings by setting the warning threshold to slightly
less than 10 GB below current memory usage then allocating a 10 GB buffer
"""
hostBytesAvail = self._rm_interface.get_available_host_memory()
memoryToAlloc = 10 * 1024 * 1024 * 1024
queryTime = 0.1
fudge = 512 * 1024 * 1024 # make sure we go below the warning threshold
warnHostThresholdBytes = hostBytesAvail - memoryToAlloc + fudge
self._settings.set_float(
rm.timeBetweenQueriesSettingName,
queryTime)
self._settings.set_bool(
rm.sendHostMemoryWarningSettingName,
True)
self._settings.set_int(
rm.hostMemoryWarnMBSettingName,
warnHostThresholdBytes // (1024 * 1024)) # bytes to MB
hostMemoryWarningOccurred = False
def on_rm_update(event):
nonlocal hostMemoryWarningOccurred
hostBytesAvail = self._rm_interface.get_available_host_memory()
if event.type == int(rm.ResourceMonitorEventType.LOW_HOST_MEMORY):
hostMemoryWarningOccurred = True
sub = self._rm_interface.get_event_stream().create_subscription_to_pop(on_rm_update, name='resource monitor update')
self.assertIsNotNone(sub)
# allocate something
numElements = memoryToAlloc // np.dtype(np.int64).itemsize
array = np.zeros(numElements, dtype=np.int64)
array[:] = 1
time = 0.
while time < 2. * queryTime: # give time for a resourcemonitor event to come through
dt = await omni.kit.app.get_app().next_update_async()
time = time + dt
self.assertTrue(hostMemoryWarningOccurred)
| 4,789 | Python | 37.015873 | 124 | 0.683441 |
omniverse-code/kit/exts/omni.resourcemonitor/docs/CHANGELOG.md | # CHANGELOG
## [1.0.0] - 2021-09-14
### Added
- Initial implementation.
- Provide event stream for low memory warnings.
- Provide convenience functions for host and device memory queries.
| 189 | Markdown | 22.749997 | 67 | 0.740741 |
omniverse-code/kit/exts/omni.resourcemonitor/docs/README.md | # [omni.resourcemonitor]
Utility extension for host and device memory updates.
Clients can subscribe to this extension's event stream to receive updates on available memory and/or receive warnings when available memory falls below specified thresholds.
| 254 | Markdown | 49.99999 | 173 | 0.830709 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnVersionedDeformerPy.rst | .. _omni_graph_examples_python_VersionedDeformerPy_2:
.. _omni_graph_examples_python_VersionedDeformerPy:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: VersionedDeformerPy
:keywords: lang-en omnigraph node examples python versioned-deformer-py
VersionedDeformerPy
===================
.. <description>
Test node to confirm version upgrading works. Performs a basic deformation on some points.
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:points", "``pointf[3][]``", "Set of points to be deformed", "[]"
"inputs:wavelength", "``float``", "Wavelength of sinusodal deformer function", "50.0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:points", "``pointf[3][]``", "Set of deformed points", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.VersionedDeformerPy"
"Version", "2"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "VersionedDeformerPy"
"Categories", "examples"
"Generated Class Name", "OgnVersionedDeformerPyDatabase"
"Python Module", "omni.graph.examples.python"
| 1,775 | reStructuredText | 24.73913 | 115 | 0.590986 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnPyUniversalAdd.rst | .. _omni_graph_examples_python_UniversalAdd_1:
.. _omni_graph_examples_python_UniversalAdd:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Universal Add For All Types (Python)
:keywords: lang-en omnigraph node examples python universal-add
Universal Add For All Types (Python)
====================================
.. <description>
Python-based universal add node for all types. This file is generated using UniversalAddGenerator.py
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:bool_0", "``bool``", "Input of type bool", "False"
"inputs:bool_1", "``bool``", "Input of type bool", "False"
"inputs:bool_arr_0", "``bool[]``", "Input of type bool[]", "[]"
"inputs:bool_arr_1", "``bool[]``", "Input of type bool[]", "[]"
"inputs:colord3_0", "``colord[3]``", "Input of type colord[3]", "[0.0, 0.0, 0.0]"
"inputs:colord3_1", "``colord[3]``", "Input of type colord[3]", "[0.0, 0.0, 0.0]"
"inputs:colord3_arr_0", "``colord[3][]``", "Input of type colord[3][]", "[]"
"inputs:colord3_arr_1", "``colord[3][]``", "Input of type colord[3][]", "[]"
"inputs:colord4_0", "``colord[4]``", "Input of type colord[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:colord4_1", "``colord[4]``", "Input of type colord[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:colord4_arr_0", "``colord[4][]``", "Input of type colord[4][]", "[]"
"inputs:colord4_arr_1", "``colord[4][]``", "Input of type colord[4][]", "[]"
"inputs:colorf3_0", "``colorf[3]``", "Input of type colorf[3]", "[0.0, 0.0, 0.0]"
"inputs:colorf3_1", "``colorf[3]``", "Input of type colorf[3]", "[0.0, 0.0, 0.0]"
"inputs:colorf3_arr_0", "``colorf[3][]``", "Input of type colorf[3][]", "[]"
"inputs:colorf3_arr_1", "``colorf[3][]``", "Input of type colorf[3][]", "[]"
"inputs:colorf4_0", "``colorf[4]``", "Input of type colorf[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:colorf4_1", "``colorf[4]``", "Input of type colorf[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:colorf4_arr_0", "``colorf[4][]``", "Input of type colorf[4][]", "[]"
"inputs:colorf4_arr_1", "``colorf[4][]``", "Input of type colorf[4][]", "[]"
"inputs:colorh3_0", "``colorh[3]``", "Input of type colorh[3]", "[0.0, 0.0, 0.0]"
"inputs:colorh3_1", "``colorh[3]``", "Input of type colorh[3]", "[0.0, 0.0, 0.0]"
"inputs:colorh3_arr_0", "``colorh[3][]``", "Input of type colorh[3][]", "[]"
"inputs:colorh3_arr_1", "``colorh[3][]``", "Input of type colorh[3][]", "[]"
"inputs:colorh4_0", "``colorh[4]``", "Input of type colorh[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:colorh4_1", "``colorh[4]``", "Input of type colorh[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:colorh4_arr_0", "``colorh[4][]``", "Input of type colorh[4][]", "[]"
"inputs:colorh4_arr_1", "``colorh[4][]``", "Input of type colorh[4][]", "[]"
"inputs:double2_0", "``double[2]``", "Input of type double[2]", "[0.0, 0.0]"
"inputs:double2_1", "``double[2]``", "Input of type double[2]", "[0.0, 0.0]"
"inputs:double2_arr_0", "``double[2][]``", "Input of type double[2][]", "[]"
"inputs:double2_arr_1", "``double[2][]``", "Input of type double[2][]", "[]"
"inputs:double3_0", "``double[3]``", "Input of type double[3]", "[0.0, 0.0, 0.0]"
"inputs:double3_1", "``double[3]``", "Input of type double[3]", "[0.0, 0.0, 0.0]"
"inputs:double3_arr_0", "``double[3][]``", "Input of type double[3][]", "[]"
"inputs:double3_arr_1", "``double[3][]``", "Input of type double[3][]", "[]"
"inputs:double4_0", "``double[4]``", "Input of type double[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:double4_1", "``double[4]``", "Input of type double[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:double4_arr_0", "``double[4][]``", "Input of type double[4][]", "[]"
"inputs:double4_arr_1", "``double[4][]``", "Input of type double[4][]", "[]"
"inputs:double_0", "``double``", "Input of type double", "0.0"
"inputs:double_1", "``double``", "Input of type double", "0.0"
"inputs:double_arr_0", "``double[]``", "Input of type double[]", "[]"
"inputs:double_arr_1", "``double[]``", "Input of type double[]", "[]"
"inputs:float2_0", "``float[2]``", "Input of type float[2]", "[0.0, 0.0]"
"inputs:float2_1", "``float[2]``", "Input of type float[2]", "[0.0, 0.0]"
"inputs:float2_arr_0", "``float[2][]``", "Input of type float[2][]", "[]"
"inputs:float2_arr_1", "``float[2][]``", "Input of type float[2][]", "[]"
"inputs:float3_0", "``float[3]``", "Input of type float[3]", "[0.0, 0.0, 0.0]"
"inputs:float3_1", "``float[3]``", "Input of type float[3]", "[0.0, 0.0, 0.0]"
"inputs:float3_arr_0", "``float[3][]``", "Input of type float[3][]", "[]"
"inputs:float3_arr_1", "``float[3][]``", "Input of type float[3][]", "[]"
"inputs:float4_0", "``float[4]``", "Input of type float[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:float4_1", "``float[4]``", "Input of type float[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:float4_arr_0", "``float[4][]``", "Input of type float[4][]", "[]"
"inputs:float4_arr_1", "``float[4][]``", "Input of type float[4][]", "[]"
"inputs:float_0", "``float``", "Input of type float", "0.0"
"inputs:float_1", "``float``", "Input of type float", "0.0"
"inputs:float_arr_0", "``float[]``", "Input of type float[]", "[]"
"inputs:float_arr_1", "``float[]``", "Input of type float[]", "[]"
"inputs:frame4_0", "``frame[4]``", "Input of type frame[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"inputs:frame4_1", "``frame[4]``", "Input of type frame[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"inputs:frame4_arr_0", "``frame[4][]``", "Input of type frame[4][]", "[]"
"inputs:frame4_arr_1", "``frame[4][]``", "Input of type frame[4][]", "[]"
"inputs:half2_0", "``half[2]``", "Input of type half[2]", "[0.0, 0.0]"
"inputs:half2_1", "``half[2]``", "Input of type half[2]", "[0.0, 0.0]"
"inputs:half2_arr_0", "``half[2][]``", "Input of type half[2][]", "[]"
"inputs:half2_arr_1", "``half[2][]``", "Input of type half[2][]", "[]"
"inputs:half3_0", "``half[3]``", "Input of type half[3]", "[0.0, 0.0, 0.0]"
"inputs:half3_1", "``half[3]``", "Input of type half[3]", "[0.0, 0.0, 0.0]"
"inputs:half3_arr_0", "``half[3][]``", "Input of type half[3][]", "[]"
"inputs:half3_arr_1", "``half[3][]``", "Input of type half[3][]", "[]"
"inputs:half4_0", "``half[4]``", "Input of type half[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:half4_1", "``half[4]``", "Input of type half[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:half4_arr_0", "``half[4][]``", "Input of type half[4][]", "[]"
"inputs:half4_arr_1", "``half[4][]``", "Input of type half[4][]", "[]"
"inputs:half_0", "``half``", "Input of type half", "0.0"
"inputs:half_1", "``half``", "Input of type half", "0.0"
"inputs:half_arr_0", "``half[]``", "Input of type half[]", "[]"
"inputs:half_arr_1", "``half[]``", "Input of type half[]", "[]"
"inputs:int2_0", "``int[2]``", "Input of type int[2]", "[0, 0]"
"inputs:int2_1", "``int[2]``", "Input of type int[2]", "[0, 0]"
"inputs:int2_arr_0", "``int[2][]``", "Input of type int[2][]", "[]"
"inputs:int2_arr_1", "``int[2][]``", "Input of type int[2][]", "[]"
"inputs:int3_0", "``int[3]``", "Input of type int[3]", "[0, 0, 0]"
"inputs:int3_1", "``int[3]``", "Input of type int[3]", "[0, 0, 0]"
"inputs:int3_arr_0", "``int[3][]``", "Input of type int[3][]", "[]"
"inputs:int3_arr_1", "``int[3][]``", "Input of type int[3][]", "[]"
"inputs:int4_0", "``int[4]``", "Input of type int[4]", "[0, 0, 0, 0]"
"inputs:int4_1", "``int[4]``", "Input of type int[4]", "[0, 0, 0, 0]"
"inputs:int4_arr_0", "``int[4][]``", "Input of type int[4][]", "[]"
"inputs:int4_arr_1", "``int[4][]``", "Input of type int[4][]", "[]"
"inputs:int64_0", "``int64``", "Input of type int64", "0"
"inputs:int64_1", "``int64``", "Input of type int64", "0"
"inputs:int64_arr_0", "``int64[]``", "Input of type int64[]", "[]"
"inputs:int64_arr_1", "``int64[]``", "Input of type int64[]", "[]"
"inputs:int_0", "``int``", "Input of type int", "0"
"inputs:int_1", "``int``", "Input of type int", "0"
"inputs:int_arr_0", "``int[]``", "Input of type int[]", "[]"
"inputs:int_arr_1", "``int[]``", "Input of type int[]", "[]"
"inputs:matrixd2_0", "``matrixd[2]``", "Input of type matrixd[2]", "[[0.0, 0.0], [0.0, 0.0]]"
"inputs:matrixd2_1", "``matrixd[2]``", "Input of type matrixd[2]", "[[0.0, 0.0], [0.0, 0.0]]"
"inputs:matrixd2_arr_0", "``matrixd[2][]``", "Input of type matrixd[2][]", "[]"
"inputs:matrixd2_arr_1", "``matrixd[2][]``", "Input of type matrixd[2][]", "[]"
"inputs:matrixd3_0", "``matrixd[3]``", "Input of type matrixd[3]", "[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]"
"inputs:matrixd3_1", "``matrixd[3]``", "Input of type matrixd[3]", "[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]"
"inputs:matrixd3_arr_0", "``matrixd[3][]``", "Input of type matrixd[3][]", "[]"
"inputs:matrixd3_arr_1", "``matrixd[3][]``", "Input of type matrixd[3][]", "[]"
"inputs:matrixd4_0", "``matrixd[4]``", "Input of type matrixd[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"inputs:matrixd4_1", "``matrixd[4]``", "Input of type matrixd[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"inputs:matrixd4_arr_0", "``matrixd[4][]``", "Input of type matrixd[4][]", "[]"
"inputs:matrixd4_arr_1", "``matrixd[4][]``", "Input of type matrixd[4][]", "[]"
"inputs:normald3_0", "``normald[3]``", "Input of type normald[3]", "[0.0, 0.0, 0.0]"
"inputs:normald3_1", "``normald[3]``", "Input of type normald[3]", "[0.0, 0.0, 0.0]"
"inputs:normald3_arr_0", "``normald[3][]``", "Input of type normald[3][]", "[]"
"inputs:normald3_arr_1", "``normald[3][]``", "Input of type normald[3][]", "[]"
"inputs:normalf3_0", "``normalf[3]``", "Input of type normalf[3]", "[0.0, 0.0, 0.0]"
"inputs:normalf3_1", "``normalf[3]``", "Input of type normalf[3]", "[0.0, 0.0, 0.0]"
"inputs:normalf3_arr_0", "``normalf[3][]``", "Input of type normalf[3][]", "[]"
"inputs:normalf3_arr_1", "``normalf[3][]``", "Input of type normalf[3][]", "[]"
"inputs:normalh3_0", "``normalh[3]``", "Input of type normalh[3]", "[0.0, 0.0, 0.0]"
"inputs:normalh3_1", "``normalh[3]``", "Input of type normalh[3]", "[0.0, 0.0, 0.0]"
"inputs:normalh3_arr_0", "``normalh[3][]``", "Input of type normalh[3][]", "[]"
"inputs:normalh3_arr_1", "``normalh[3][]``", "Input of type normalh[3][]", "[]"
"inputs:pointd3_0", "``pointd[3]``", "Input of type pointd[3]", "[0.0, 0.0, 0.0]"
"inputs:pointd3_1", "``pointd[3]``", "Input of type pointd[3]", "[0.0, 0.0, 0.0]"
"inputs:pointd3_arr_0", "``pointd[3][]``", "Input of type pointd[3][]", "[]"
"inputs:pointd3_arr_1", "``pointd[3][]``", "Input of type pointd[3][]", "[]"
"inputs:pointf3_0", "``pointf[3]``", "Input of type pointf[3]", "[0.0, 0.0, 0.0]"
"inputs:pointf3_1", "``pointf[3]``", "Input of type pointf[3]", "[0.0, 0.0, 0.0]"
"inputs:pointf3_arr_0", "``pointf[3][]``", "Input of type pointf[3][]", "[]"
"inputs:pointf3_arr_1", "``pointf[3][]``", "Input of type pointf[3][]", "[]"
"inputs:pointh3_0", "``pointh[3]``", "Input of type pointh[3]", "[0.0, 0.0, 0.0]"
"inputs:pointh3_1", "``pointh[3]``", "Input of type pointh[3]", "[0.0, 0.0, 0.0]"
"inputs:pointh3_arr_0", "``pointh[3][]``", "Input of type pointh[3][]", "[]"
"inputs:pointh3_arr_1", "``pointh[3][]``", "Input of type pointh[3][]", "[]"
"inputs:quatd4_0", "``quatd[4]``", "Input of type quatd[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:quatd4_1", "``quatd[4]``", "Input of type quatd[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:quatd4_arr_0", "``quatd[4][]``", "Input of type quatd[4][]", "[]"
"inputs:quatd4_arr_1", "``quatd[4][]``", "Input of type quatd[4][]", "[]"
"inputs:quatf4_0", "``quatf[4]``", "Input of type quatf[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:quatf4_1", "``quatf[4]``", "Input of type quatf[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:quatf4_arr_0", "``quatf[4][]``", "Input of type quatf[4][]", "[]"
"inputs:quatf4_arr_1", "``quatf[4][]``", "Input of type quatf[4][]", "[]"
"inputs:quath4_0", "``quath[4]``", "Input of type quath[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:quath4_1", "``quath[4]``", "Input of type quath[4]", "[0.0, 0.0, 0.0, 0.0]"
"inputs:quath4_arr_0", "``quath[4][]``", "Input of type quath[4][]", "[]"
"inputs:quath4_arr_1", "``quath[4][]``", "Input of type quath[4][]", "[]"
"inputs:texcoordd2_0", "``texcoordd[2]``", "Input of type texcoordd[2]", "[0.0, 0.0]"
"inputs:texcoordd2_1", "``texcoordd[2]``", "Input of type texcoordd[2]", "[0.0, 0.0]"
"inputs:texcoordd2_arr_0", "``texcoordd[2][]``", "Input of type texcoordd[2][]", "[]"
"inputs:texcoordd2_arr_1", "``texcoordd[2][]``", "Input of type texcoordd[2][]", "[]"
"inputs:texcoordd3_0", "``texcoordd[3]``", "Input of type texcoordd[3]", "[0.0, 0.0, 0.0]"
"inputs:texcoordd3_1", "``texcoordd[3]``", "Input of type texcoordd[3]", "[0.0, 0.0, 0.0]"
"inputs:texcoordd3_arr_0", "``texcoordd[3][]``", "Input of type texcoordd[3][]", "[]"
"inputs:texcoordd3_arr_1", "``texcoordd[3][]``", "Input of type texcoordd[3][]", "[]"
"inputs:texcoordf2_0", "``texcoordf[2]``", "Input of type texcoordf[2]", "[0.0, 0.0]"
"inputs:texcoordf2_1", "``texcoordf[2]``", "Input of type texcoordf[2]", "[0.0, 0.0]"
"inputs:texcoordf2_arr_0", "``texcoordf[2][]``", "Input of type texcoordf[2][]", "[]"
"inputs:texcoordf2_arr_1", "``texcoordf[2][]``", "Input of type texcoordf[2][]", "[]"
"inputs:texcoordf3_0", "``texcoordf[3]``", "Input of type texcoordf[3]", "[0.0, 0.0, 0.0]"
"inputs:texcoordf3_1", "``texcoordf[3]``", "Input of type texcoordf[3]", "[0.0, 0.0, 0.0]"
"inputs:texcoordf3_arr_0", "``texcoordf[3][]``", "Input of type texcoordf[3][]", "[]"
"inputs:texcoordf3_arr_1", "``texcoordf[3][]``", "Input of type texcoordf[3][]", "[]"
"inputs:texcoordh2_0", "``texcoordh[2]``", "Input of type texcoordh[2]", "[0.0, 0.0]"
"inputs:texcoordh2_1", "``texcoordh[2]``", "Input of type texcoordh[2]", "[0.0, 0.0]"
"inputs:texcoordh2_arr_0", "``texcoordh[2][]``", "Input of type texcoordh[2][]", "[]"
"inputs:texcoordh2_arr_1", "``texcoordh[2][]``", "Input of type texcoordh[2][]", "[]"
"inputs:texcoordh3_0", "``texcoordh[3]``", "Input of type texcoordh[3]", "[0.0, 0.0, 0.0]"
"inputs:texcoordh3_1", "``texcoordh[3]``", "Input of type texcoordh[3]", "[0.0, 0.0, 0.0]"
"inputs:texcoordh3_arr_0", "``texcoordh[3][]``", "Input of type texcoordh[3][]", "[]"
"inputs:texcoordh3_arr_1", "``texcoordh[3][]``", "Input of type texcoordh[3][]", "[]"
"inputs:timecode_0", "``timecode``", "Input of type timecode", "0.0"
"inputs:timecode_1", "``timecode``", "Input of type timecode", "0.0"
"inputs:timecode_arr_0", "``timecode[]``", "Input of type timecode[]", "[]"
"inputs:timecode_arr_1", "``timecode[]``", "Input of type timecode[]", "[]"
"inputs:token_0", "``token``", "Input of type token", "default_token"
"inputs:token_1", "``token``", "Input of type token", "default_token"
"inputs:token_arr_0", "``token[]``", "Input of type token[]", "[]"
"inputs:token_arr_1", "``token[]``", "Input of type token[]", "[]"
"inputs:transform4_0", "``transform[4]``", "Input of type transform[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"inputs:transform4_1", "``transform[4]``", "Input of type transform[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"inputs:transform4_arr_0", "``transform[4][]``", "Input of type transform[4][]", "[]"
"inputs:transform4_arr_1", "``transform[4][]``", "Input of type transform[4][]", "[]"
"inputs:uchar_0", "``uchar``", "Input of type uchar", "0"
"inputs:uchar_1", "``uchar``", "Input of type uchar", "0"
"inputs:uchar_arr_0", "``uchar[]``", "Input of type uchar[]", "[]"
"inputs:uchar_arr_1", "``uchar[]``", "Input of type uchar[]", "[]"
"inputs:uint64_0", "``uint64``", "Input of type uint64", "0"
"inputs:uint64_1", "``uint64``", "Input of type uint64", "0"
"inputs:uint64_arr_0", "``uint64[]``", "Input of type uint64[]", "[]"
"inputs:uint64_arr_1", "``uint64[]``", "Input of type uint64[]", "[]"
"inputs:uint_0", "``uint``", "Input of type uint", "0"
"inputs:uint_1", "``uint``", "Input of type uint", "0"
"inputs:uint_arr_0", "``uint[]``", "Input of type uint[]", "[]"
"inputs:uint_arr_1", "``uint[]``", "Input of type uint[]", "[]"
"inputs:vectord3_0", "``vectord[3]``", "Input of type vectord[3]", "[0.0, 0.0, 0.0]"
"inputs:vectord3_1", "``vectord[3]``", "Input of type vectord[3]", "[0.0, 0.0, 0.0]"
"inputs:vectord3_arr_0", "``vectord[3][]``", "Input of type vectord[3][]", "[]"
"inputs:vectord3_arr_1", "``vectord[3][]``", "Input of type vectord[3][]", "[]"
"inputs:vectorf3_0", "``vectorf[3]``", "Input of type vectorf[3]", "[0.0, 0.0, 0.0]"
"inputs:vectorf3_1", "``vectorf[3]``", "Input of type vectorf[3]", "[0.0, 0.0, 0.0]"
"inputs:vectorf3_arr_0", "``vectorf[3][]``", "Input of type vectorf[3][]", "[]"
"inputs:vectorf3_arr_1", "``vectorf[3][]``", "Input of type vectorf[3][]", "[]"
"inputs:vectorh3_0", "``vectorh[3]``", "Input of type vectorh[3]", "[0.0, 0.0, 0.0]"
"inputs:vectorh3_1", "``vectorh[3]``", "Input of type vectorh[3]", "[0.0, 0.0, 0.0]"
"inputs:vectorh3_arr_0", "``vectorh[3][]``", "Input of type vectorh[3][]", "[]"
"inputs:vectorh3_arr_1", "``vectorh[3][]``", "Input of type vectorh[3][]", "[]"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:bool_0", "``bool``", "Output of type bool", "False"
"outputs:bool_arr_0", "``bool[]``", "Output of type bool[]", "[]"
"outputs:colord3_0", "``colord[3]``", "Output of type colord[3]", "[0.0, 0.0, 0.0]"
"outputs:colord3_arr_0", "``colord[3][]``", "Output of type colord[3][]", "[]"
"outputs:colord4_0", "``colord[4]``", "Output of type colord[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:colord4_arr_0", "``colord[4][]``", "Output of type colord[4][]", "[]"
"outputs:colorf3_0", "``colorf[3]``", "Output of type colorf[3]", "[0.0, 0.0, 0.0]"
"outputs:colorf3_arr_0", "``colorf[3][]``", "Output of type colorf[3][]", "[]"
"outputs:colorf4_0", "``colorf[4]``", "Output of type colorf[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:colorf4_arr_0", "``colorf[4][]``", "Output of type colorf[4][]", "[]"
"outputs:colorh3_0", "``colorh[3]``", "Output of type colorh[3]", "[0.0, 0.0, 0.0]"
"outputs:colorh3_arr_0", "``colorh[3][]``", "Output of type colorh[3][]", "[]"
"outputs:colorh4_0", "``colorh[4]``", "Output of type colorh[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:colorh4_arr_0", "``colorh[4][]``", "Output of type colorh[4][]", "[]"
"outputs:double2_0", "``double[2]``", "Output of type double[2]", "[0.0, 0.0]"
"outputs:double2_arr_0", "``double[2][]``", "Output of type double[2][]", "[]"
"outputs:double3_0", "``double[3]``", "Output of type double[3]", "[0.0, 0.0, 0.0]"
"outputs:double3_arr_0", "``double[3][]``", "Output of type double[3][]", "[]"
"outputs:double4_0", "``double[4]``", "Output of type double[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:double4_arr_0", "``double[4][]``", "Output of type double[4][]", "[]"
"outputs:double_0", "``double``", "Output of type double", "0.0"
"outputs:double_arr_0", "``double[]``", "Output of type double[]", "[]"
"outputs:float2_0", "``float[2]``", "Output of type float[2]", "[0.0, 0.0]"
"outputs:float2_arr_0", "``float[2][]``", "Output of type float[2][]", "[]"
"outputs:float3_0", "``float[3]``", "Output of type float[3]", "[0.0, 0.0, 0.0]"
"outputs:float3_arr_0", "``float[3][]``", "Output of type float[3][]", "[]"
"outputs:float4_0", "``float[4]``", "Output of type float[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:float4_arr_0", "``float[4][]``", "Output of type float[4][]", "[]"
"outputs:float_0", "``float``", "Output of type float", "0.0"
"outputs:float_arr_0", "``float[]``", "Output of type float[]", "[]"
"outputs:frame4_0", "``frame[4]``", "Output of type frame[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"outputs:frame4_arr_0", "``frame[4][]``", "Output of type frame[4][]", "[]"
"outputs:half2_0", "``half[2]``", "Output of type half[2]", "[0.0, 0.0]"
"outputs:half2_arr_0", "``half[2][]``", "Output of type half[2][]", "[]"
"outputs:half3_0", "``half[3]``", "Output of type half[3]", "[0.0, 0.0, 0.0]"
"outputs:half3_arr_0", "``half[3][]``", "Output of type half[3][]", "[]"
"outputs:half4_0", "``half[4]``", "Output of type half[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:half4_arr_0", "``half[4][]``", "Output of type half[4][]", "[]"
"outputs:half_0", "``half``", "Output of type half", "0.0"
"outputs:half_arr_0", "``half[]``", "Output of type half[]", "[]"
"outputs:int2_0", "``int[2]``", "Output of type int[2]", "[0, 0]"
"outputs:int2_arr_0", "``int[2][]``", "Output of type int[2][]", "[]"
"outputs:int3_0", "``int[3]``", "Output of type int[3]", "[0, 0, 0]"
"outputs:int3_arr_0", "``int[3][]``", "Output of type int[3][]", "[]"
"outputs:int4_0", "``int[4]``", "Output of type int[4]", "[0, 0, 0, 0]"
"outputs:int4_arr_0", "``int[4][]``", "Output of type int[4][]", "[]"
"outputs:int64_0", "``int64``", "Output of type int64", "0"
"outputs:int64_arr_0", "``int64[]``", "Output of type int64[]", "[]"
"outputs:int_0", "``int``", "Output of type int", "0"
"outputs:int_arr_0", "``int[]``", "Output of type int[]", "[]"
"outputs:matrixd2_0", "``matrixd[2]``", "Output of type matrixd[2]", "[[0.0, 0.0], [0.0, 0.0]]"
"outputs:matrixd2_arr_0", "``matrixd[2][]``", "Output of type matrixd[2][]", "[]"
"outputs:matrixd3_0", "``matrixd[3]``", "Output of type matrixd[3]", "[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]"
"outputs:matrixd3_arr_0", "``matrixd[3][]``", "Output of type matrixd[3][]", "[]"
"outputs:matrixd4_0", "``matrixd[4]``", "Output of type matrixd[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"outputs:matrixd4_arr_0", "``matrixd[4][]``", "Output of type matrixd[4][]", "[]"
"outputs:normald3_0", "``normald[3]``", "Output of type normald[3]", "[0.0, 0.0, 0.0]"
"outputs:normald3_arr_0", "``normald[3][]``", "Output of type normald[3][]", "[]"
"outputs:normalf3_0", "``normalf[3]``", "Output of type normalf[3]", "[0.0, 0.0, 0.0]"
"outputs:normalf3_arr_0", "``normalf[3][]``", "Output of type normalf[3][]", "[]"
"outputs:normalh3_0", "``normalh[3]``", "Output of type normalh[3]", "[0.0, 0.0, 0.0]"
"outputs:normalh3_arr_0", "``normalh[3][]``", "Output of type normalh[3][]", "[]"
"outputs:pointd3_0", "``pointd[3]``", "Output of type pointd[3]", "[0.0, 0.0, 0.0]"
"outputs:pointd3_arr_0", "``pointd[3][]``", "Output of type pointd[3][]", "[]"
"outputs:pointf3_0", "``pointf[3]``", "Output of type pointf[3]", "[0.0, 0.0, 0.0]"
"outputs:pointf3_arr_0", "``pointf[3][]``", "Output of type pointf[3][]", "[]"
"outputs:pointh3_0", "``pointh[3]``", "Output of type pointh[3]", "[0.0, 0.0, 0.0]"
"outputs:pointh3_arr_0", "``pointh[3][]``", "Output of type pointh[3][]", "[]"
"outputs:quatd4_0", "``quatd[4]``", "Output of type quatd[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:quatd4_arr_0", "``quatd[4][]``", "Output of type quatd[4][]", "[]"
"outputs:quatf4_0", "``quatf[4]``", "Output of type quatf[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:quatf4_arr_0", "``quatf[4][]``", "Output of type quatf[4][]", "[]"
"outputs:quath4_0", "``quath[4]``", "Output of type quath[4]", "[0.0, 0.0, 0.0, 0.0]"
"outputs:quath4_arr_0", "``quath[4][]``", "Output of type quath[4][]", "[]"
"outputs:texcoordd2_0", "``texcoordd[2]``", "Output of type texcoordd[2]", "[0.0, 0.0]"
"outputs:texcoordd2_arr_0", "``texcoordd[2][]``", "Output of type texcoordd[2][]", "[]"
"outputs:texcoordd3_0", "``texcoordd[3]``", "Output of type texcoordd[3]", "[0.0, 0.0, 0.0]"
"outputs:texcoordd3_arr_0", "``texcoordd[3][]``", "Output of type texcoordd[3][]", "[]"
"outputs:texcoordf2_0", "``texcoordf[2]``", "Output of type texcoordf[2]", "[0.0, 0.0]"
"outputs:texcoordf2_arr_0", "``texcoordf[2][]``", "Output of type texcoordf[2][]", "[]"
"outputs:texcoordf3_0", "``texcoordf[3]``", "Output of type texcoordf[3]", "[0.0, 0.0, 0.0]"
"outputs:texcoordf3_arr_0", "``texcoordf[3][]``", "Output of type texcoordf[3][]", "[]"
"outputs:texcoordh2_0", "``texcoordh[2]``", "Output of type texcoordh[2]", "[0.0, 0.0]"
"outputs:texcoordh2_arr_0", "``texcoordh[2][]``", "Output of type texcoordh[2][]", "[]"
"outputs:texcoordh3_0", "``texcoordh[3]``", "Output of type texcoordh[3]", "[0.0, 0.0, 0.0]"
"outputs:texcoordh3_arr_0", "``texcoordh[3][]``", "Output of type texcoordh[3][]", "[]"
"outputs:timecode_0", "``timecode``", "Output of type timecode", "0.0"
"outputs:timecode_arr_0", "``timecode[]``", "Output of type timecode[]", "[]"
"outputs:token_0", "``token``", "Output of type token", "default_token"
"outputs:token_arr_0", "``token[]``", "Output of type token[]", "[]"
"outputs:transform4_0", "``transform[4]``", "Output of type transform[4]", "[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]"
"outputs:transform4_arr_0", "``transform[4][]``", "Output of type transform[4][]", "[]"
"outputs:uchar_0", "``uchar``", "Output of type uchar", "0"
"outputs:uchar_arr_0", "``uchar[]``", "Output of type uchar[]", "[]"
"outputs:uint64_0", "``uint64``", "Output of type uint64", "0"
"outputs:uint64_arr_0", "``uint64[]``", "Output of type uint64[]", "[]"
"outputs:uint_0", "``uint``", "Output of type uint", "0"
"outputs:uint_arr_0", "``uint[]``", "Output of type uint[]", "[]"
"outputs:vectord3_0", "``vectord[3]``", "Output of type vectord[3]", "[0.0, 0.0, 0.0]"
"outputs:vectord3_arr_0", "``vectord[3][]``", "Output of type vectord[3][]", "[]"
"outputs:vectorf3_0", "``vectorf[3]``", "Output of type vectorf[3]", "[0.0, 0.0, 0.0]"
"outputs:vectorf3_arr_0", "``vectorf[3][]``", "Output of type vectorf[3][]", "[]"
"outputs:vectorh3_0", "``vectorh[3]``", "Output of type vectorh[3]", "[0.0, 0.0, 0.0]"
"outputs:vectorh3_arr_0", "``vectorh[3][]``", "Output of type vectorh[3][]", "[]"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.UniversalAdd"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "usd"
"uiName", "Universal Add For All Types (Python)"
"Categories", "examples"
"Generated Class Name", "OgnPyUniversalAddDatabase"
"Python Module", "omni.graph.examples.python"
| 27,714 | reStructuredText | 72.320106 | 169 | 0.526665 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnBouncingCubesGpu.rst | .. _omni_graph_examples_python_BouncingCubesGpu_1:
.. _omni_graph_examples_python_BouncingCubesGpu:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Deprecated Node - Bouncing Cubes (GPU)
:keywords: lang-en omnigraph node examples python bouncing-cubes-gpu
Deprecated Node - Bouncing Cubes (GPU)
======================================
.. <description>
Deprecated node - no longer supported
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.BouncingCubesGpu"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "True"
"Implementation Language", "Python"
"Default Memory Type", "cuda"
"Generated Code Exclusions", "usd, test"
"uiName", "Deprecated Node - Bouncing Cubes (GPU)"
"__memoryType", "cuda"
"Categories", "examples"
"Generated Class Name", "OgnBouncingCubesGpuDatabase"
"Python Module", "omni.graph.examples.python"
| 1,346 | reStructuredText | 25.411764 | 115 | 0.57578 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnCountTo.rst | .. _omni_graph_examples_python_CountTo_1:
.. _omni_graph_examples_python_CountTo:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Count To
:keywords: lang-en omnigraph node examples python count-to
Count To
========
.. <description>
Example stateful node that counts to countTo by a certain increment
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:countTo", "``double``", "The ceiling to count to", "3"
"inputs:increment", "``double``", "Increment to count by", "0.1"
"inputs:reset", "``bool``", "Whether to reset the count", "False"
"inputs:trigger", "``double[3]``", "Position to be used as a trigger for the counting", "[0.0, 0.0, 0.0]"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:count", "``double``", "The current count", "0.0"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.CountTo"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Count To"
"Categories", "examples"
"Generated Class Name", "OgnCountToDatabase"
"Python Module", "omni.graph.examples.python"
| 1,784 | reStructuredText | 24.140845 | 115 | 0.567265 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnPositionToColor.rst | .. _omni_graph_examples_python_PositionToColor_1:
.. _omni_graph_examples_python_PositionToColor:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: PositionToColor
:keywords: lang-en omnigraph node examples python position-to-color
PositionToColor
===============
.. <description>
This node takes positional data (double3) and converts to a color, and outputs as color3f[] (which seems to be the default color connection in USD)
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:color_offset", "``colorf[3]``", "Offset added to the scaled color to get the final result", "[0.0, 0.0, 0.0]"
"inputs:position", "``double[3]``", "Position to be converted to a color", "[0.0, 0.0, 0.0]"
"inputs:scale", "``float``", "Constant by which to multiply the position to get the color", "1.0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:color", "``colorf[3][]``", "Color value extracted from the position", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.PositionToColor"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "PositionToColor"
"Categories", "examples"
"Generated Class Name", "OgnPositionToColorDatabase"
"Python Module", "omni.graph.examples.python"
| 1,967 | reStructuredText | 27.114285 | 148 | 0.593798 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnDeformerYAxis.rst | .. _omni_graph_examples_python_DeformerYAxis_1:
.. _omni_graph_examples_python_DeformerYAxis:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Sine Wave Deformer Y-axis (Python)
:keywords: lang-en omnigraph node examples python deformer-y-axis
Sine Wave Deformer Y-axis (Python)
==================================
.. <description>
Example node applying a sine wave deformation to a set of points, written in Python. Deforms along Y-axis instead of Z
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:multiplier", "``double``", "The multiplier for the amplitude of the sine wave", "1"
"inputs:offset", "``double``", "The offset of the sine wave", "0"
"inputs:points", "``pointf[3][]``", "The input points to be deformed", "[]"
"inputs:wavelength", "``double``", "The wavelength of the sine wave", "1"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:points", "``pointf[3][]``", "The deformed output points", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.DeformerYAxis"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Sine Wave Deformer Y-axis (Python)"
"Categories", "examples"
"Generated Class Name", "OgnDeformerYAxisDatabase"
"Python Module", "omni.graph.examples.python"
| 1,995 | reStructuredText | 27.112676 | 119 | 0.582957 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnComposeDouble3.rst | .. _omni_graph_examples_python_ComposeDouble3_1:
.. _omni_graph_examples_python_ComposeDouble3:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Compose Double3 (Python)
:keywords: lang-en omnigraph node examples python compose-double3
Compose Double3 (Python)
========================
.. <description>
Example node that takes in the components of three doubles and outputs a double3
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:x", "``double``", "The x component of the input double3", "0"
"inputs:y", "``double``", "The y component of the input double3", "0"
"inputs:z", "``double``", "The z component of the input double3", "0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:double3", "``double[3]``", "Output double3", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.ComposeDouble3"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Compose Double3 (Python)"
"Categories", "examples"
"Generated Class Name", "OgnComposeDouble3Database"
"Python Module", "omni.graph.examples.python"
| 1,805 | reStructuredText | 24.8 | 115 | 0.577839 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnMultDouble.rst | .. _omni_graph_examples_python_MultDouble_1:
.. _omni_graph_examples_python_MultDouble:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Multiply Double (Python)
:keywords: lang-en omnigraph node examples python mult-double
Multiply Double (Python)
========================
.. <description>
Example node that multiplies 2 doubles together
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:a", "``double``", "Input a", "0"
"inputs:b", "``double``", "Input b", "0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:out", "``double``", "The result of a * b", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.MultDouble"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Multiply Double (Python)"
"Categories", "examples"
"Generated Class Name", "OgnMultDoubleDatabase"
"Python Module", "omni.graph.examples.python"
| 1,618 | reStructuredText | 22.463768 | 115 | 0.556242 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnDecomposeDouble3.rst | .. _omni_graph_examples_python_DecomposeDouble3_1:
.. _omni_graph_examples_python_DecomposeDouble3:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Decompose Double3 (Python)
:keywords: lang-en omnigraph node examples python decompose-double3
Decompose Double3 (Python)
==========================
.. <description>
Example node that takes in a double3 and outputs scalars that are its components
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:double3", "``double[3]``", "Input double3", "[0, 0, 0]"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:x", "``double``", "The x component of the input double3", "None"
"outputs:y", "``double``", "The y component of the input double3", "None"
"outputs:z", "``double``", "The z component of the input double3", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.DecomposeDouble3"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Decompose Double3 (Python)"
"Categories", "examples"
"Generated Class Name", "OgnDecomposeDouble3Database"
"Python Module", "omni.graph.examples.python"
| 1,838 | reStructuredText | 25.271428 | 115 | 0.581066 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnDynamicSwitch.rst | .. _omni_graph_examples_python_DynamicSwitch_1:
.. _omni_graph_examples_python_DynamicSwitch:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Dynamic Switch
:keywords: lang-en omnigraph node examples python dynamic-switch
Dynamic Switch
==============
.. <description>
A switch node that will enable the left side or right side depending on the input. Requires dynamic scheduling to work
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:left_value", "``int``", "Left value to output", "-1"
"inputs:right_value", "``int``", "Right value to output", "1"
"inputs:switch", "``int``", "Enables right value if greater than 0, else left value", "0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:left_out", "``int``", "Left side output", "0"
"outputs:right_out", "``int``", "Right side output", "0"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.DynamicSwitch"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "usd"
"uiName", "Dynamic Switch"
"Categories", "examples"
"Generated Class Name", "OgnDynamicSwitchDatabase"
"Python Module", "omni.graph.examples.python"
| 1,856 | reStructuredText | 25.154929 | 119 | 0.579741 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnClampDouble.rst | .. _omni_graph_examples_python_ClampDouble_1:
.. _omni_graph_examples_python_ClampDouble:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Clamp Double (Python)
:keywords: lang-en omnigraph node examples python clamp-double
Clamp Double (Python)
=====================
.. <description>
Example node that a number to a range
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:max", "``double``", "Maximum value", "0"
"inputs:min", "``double``", "Mininum value", "0"
"inputs:num", "``double``", "Input number", "0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:out", "``double``", "The result of the number, having been clamped to the range min,max", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.ClampDouble"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Clamp Double (Python)"
"Categories", "examples"
"Generated Class Name", "OgnClampDoubleDatabase"
"Python Module", "omni.graph.examples.python"
| 1,716 | reStructuredText | 23.528571 | 115 | 0.564103 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnBouncingCubesCpu.rst | .. _omni_graph_examples_python_BouncingCubes_1:
.. _omni_graph_examples_python_BouncingCubes:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Deprecated Node - Bouncing Cubes (GPU)
:keywords: lang-en omnigraph node examples python bouncing-cubes
Deprecated Node - Bouncing Cubes (GPU)
======================================
.. <description>
Deprecated node - no longer supported
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
State
-----
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"Translations (*state:translations*)", "``float[3][]``", "Set of translation attributes gathered from the inputs. Translations have velocities applied to them each evaluation.", "None"
"Velocities (*state:velocities*)", "``float[]``", "Set of velocity attributes gathered from the inputs", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.BouncingCubes"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "True"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Deprecated Node - Bouncing Cubes (GPU)"
"Categories", "examples"
"Generated Class Name", "OgnBouncingCubesCpuDatabase"
"Python Module", "omni.graph.examples.python"
| 1,716 | reStructuredText | 27.616666 | 188 | 0.594406 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnExecSwitch.rst | .. _omni_graph_examples_python_ExecSwitch_1:
.. _omni_graph_examples_python_ExecSwitch:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Exec Switch
:keywords: lang-en omnigraph node examples python exec-switch
Exec Switch
===========
.. <description>
A switch node that will enable the left side or right side depending on the input
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"Exec In (*inputs:execIn*)", "``execution``", "Trigger the output", "None"
"inputs:switch", "``bool``", "Enables right value if greater than 0, else left value", "False"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:execLeftOut", "``execution``", "Left execution", "None"
"outputs:execRightOut", "``execution``", "Right execution", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.ExecSwitch"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "usd"
"uiName", "Exec Switch"
"Categories", "examples"
"Generated Class Name", "OgnExecSwitchDatabase"
"Python Module", "omni.graph.examples.python"
| 1,764 | reStructuredText | 24.214285 | 115 | 0.579932 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnDeformerCpu.rst | .. _omni_graph_examples_python_DeformerPy_1:
.. _omni_graph_examples_python_DeformerPy:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Sine Wave Deformer Z-axis (Python)
:keywords: lang-en omnigraph node examples python deformer-py
Sine Wave Deformer Z-axis (Python)
==================================
.. <description>
Example node applying a sine wave deformation to a set of points, written in Python
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:multiplier", "``float``", "The multiplier for the amplitude of the sine wave", "1.0"
"inputs:points", "``pointf[3][]``", "The input points to be deformed", "[]"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:points", "``pointf[3][]``", "The deformed output points", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.DeformerPy"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Sine Wave Deformer Z-axis (Python)"
"Categories", "examples"
"Generated Class Name", "OgnDeformerCpuDatabase"
"Python Module", "omni.graph.examples.python"
| 1,797 | reStructuredText | 25.057971 | 115 | 0.57429 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnAbsDouble.rst | .. _omni_graph_examples_python_AbsDouble_1:
.. _omni_graph_examples_python_AbsDouble:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Abs Double (Python)
:keywords: lang-en omnigraph node examples python abs-double
Abs Double (Python)
===================
.. <description>
Example node that takes the absolute value of a number
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:num", "``double``", "Input number", "0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:out", "``double``", "The absolute value of input number", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.AbsDouble"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Abs Double (Python)"
"Categories", "examples"
"Generated Class Name", "OgnAbsDoubleDatabase"
"Python Module", "omni.graph.examples.python"
| 1,577 | reStructuredText | 22.205882 | 115 | 0.56246 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnTestInitNode.rst | .. _omni_graph_examples_python_TestInitNode_1:
.. _omni_graph_examples_python_TestInitNode:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: TestInitNode
:keywords: lang-en omnigraph node examples python test-init-node
TestInitNode
============
.. <description>
Test Init Node
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:value", "``float``", "Value", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.TestInitNode"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "TestInitNode"
"Categories", "examples"
"Generated Class Name", "OgnTestInitNodeDatabase"
"Python Module", "omni.graph.examples.python"
| 1,332 | reStructuredText | 21.59322 | 115 | 0.563814 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnSubtractDouble.rst | .. _omni_graph_examples_python_SubtractDouble_1:
.. _omni_graph_examples_python_SubtractDouble:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Subtract Double (Python)
:keywords: lang-en omnigraph node examples python subtract-double
Subtract Double (Python)
========================
.. <description>
Example node that subtracts 2 doubles from each other
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:a", "``double``", "Input a", "0"
"inputs:b", "``double``", "Input b", "0"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:out", "``double``", "The result of a - b", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.SubtractDouble"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Subtract Double (Python)"
"Categories", "examples"
"Generated Class Name", "OgnSubtractDoubleDatabase"
"Python Module", "omni.graph.examples.python"
| 1,644 | reStructuredText | 22.840579 | 115 | 0.562044 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnIntCounter.rst | .. _omni_graph_examples_python_IntCounter_1:
.. _omni_graph_examples_python_IntCounter:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Int Counter
:keywords: lang-en omnigraph node examples python int-counter
Int Counter
===========
.. <description>
Example stateful node that increments every time it's evaluated
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:increment", "``int``", "Increment to count by", "1"
"inputs:reset", "``bool``", "Whether to reset the count", "False"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:count", "``int``", "The current count", "0"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.IntCounter"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"uiName", "Int Counter"
"Categories", "examples"
"Generated Class Name", "OgnIntCounterDatabase"
"Python Module", "omni.graph.examples.python"
| 1,620 | reStructuredText | 22.492753 | 115 | 0.567901 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnDeformerGpu.rst | .. _omni_graph_examples_python_DeformerPyGpu_1:
.. _omni_graph_examples_python_DeformerPyGpu:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Sine Wave Deformer Z-axis (Python GPU)
:keywords: lang-en omnigraph node examples python deformer-py-gpu
Sine Wave Deformer Z-axis (Python GPU)
======================================
.. <description>
Example node applying a sine wave deformation to a set of points, written in Python for the GPU
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Inputs
------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"inputs:multiplier", "``float``", "The multiplier for the amplitude of the sine wave", "1"
"inputs:points", "``pointf[3][]``", "The input points to be deformed", "[]"
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:points", "``pointf[3][]``", "The deformed output points", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.DeformerPyGpu"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cuda"
"Generated Code Exclusions", "None"
"uiName", "Sine Wave Deformer Z-axis (Python GPU)"
"__memoryType", "cuda"
"Categories", "examples"
"Generated Class Name", "OgnDeformerGpuDatabase"
"Python Module", "omni.graph.examples.python"
| 1,864 | reStructuredText | 25.642857 | 115 | 0.577253 |
omniverse-code/kit/exts/omni.graph.examples.python/ogn/docs/OgnTestSingleton.rst | .. _omni_graph_examples_python_TestSingleton_1:
.. _omni_graph_examples_python_TestSingleton:
.. ================================================================================
.. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT.
.. ================================================================================
:orphan:
.. meta::
:title: Test Singleton
:keywords: lang-en omnigraph node examples python test-singleton
Test Singleton
==============
.. <description>
Example node that showcases the use of singleton nodes (nodes that can have only 1 instance)
.. </description>
Installation
------------
To use this node enable :ref:`omni.graph.examples.python<ext_omni_graph_examples_python>` in the Extension Manager.
Outputs
-------
.. csv-table::
:header: "Name", "Type", "Descripton", "Default"
:widths: 20, 20, 50, 10
"outputs:out", "``double``", "The unique output of the only instance of this node", "None"
Metadata
--------
.. csv-table::
:header: "Name", "Value"
:widths: 30,70
"Unique ID", "omni.graph.examples.python.TestSingleton"
"Version", "1"
"Extension", "omni.graph.examples.python"
"Has State?", "False"
"Implementation Language", "Python"
"Default Memory Type", "cpu"
"Generated Code Exclusions", "None"
"singleton", "1"
"uiName", "Test Singleton"
"Categories", "examples"
"Generated Class Name", "OgnTestSingletonDatabase"
"Python Module", "omni.graph.examples.python"
| 1,488 | reStructuredText | 23.816666 | 115 | 0.583333 |
omniverse-code/kit/exts/omni.graph.examples.python/PACKAGE-LICENSES/omni.graph.examples.python-LICENSE.md | Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
NVIDIA CORPORATION and its licensors retain all intellectual property
and proprietary rights in and to this software, related documentation
and any modifications thereto. Any use, reproduction, disclosure or
distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited. | 412 | Markdown | 57.999992 | 74 | 0.839806 |
omniverse-code/kit/exts/omni.graph.examples.python/config/extension.toml | [package]
title = "OmniGraph Python Examples"
version = "1.3.2"
category = "Graph"
readme = "docs/README.md"
changelog = "docs/CHANGELOG.md"
description = "Contains a set of sample OmniGraph nodes implemented in Python."
repository = ""
keywords = ["kit", "omnigraph", "nodes", "python"]
# Main module for the Python interface
[[python.module]]
name = "omni.graph.examples.python"
# Watch the .ogn files for hot reloading (only works for Python files)
[fswatcher.patterns]
include = ["*.ogn", "*.py"]
exclude = ["Ogn*Database.py"]
# Python array data uses numpy as its format
[python.pipapi]
requirements = ["numpy"] # SWIPAT filed under: http://nvbugs/3193231
# Other extensions that need to load in order for this one to work
[dependencies]
"omni.graph" = {}
"omni.graph.tools" = {}
"omni.kit.test" = {}
"omni.kit.pipapi" = {}
[[test]]
stdoutFailPatterns.exclude = [
"*[omni.graph.core.plugin] getTypes called on non-existent path*",
"*Trying to create multiple instances of singleton*"
]
[documentation]
deps = [
["kit-sdk", "_build/docs/kit-sdk/latest"], # WAR to include omni.graph refs until that workflow is moved
]
pages = [
"docs/Overview.md",
"docs/CHANGELOG.md",
]
| 1,199 | TOML | 25.666666 | 108 | 0.69558 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/__init__.py | """Module containing example nodes written in pure Python.
There is no public API to this module.
"""
__all__ = []
from ._impl.extension import _PublicExtension # noqa: F401
| 177 | Python | 21.249997 | 59 | 0.711864 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnSubtractDoubleDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.SubtractDouble
Example node that subtracts 2 doubles from each other
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnSubtractDoubleDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.SubtractDouble
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.a
inputs.b
Outputs:
outputs.out
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:a', 'double', 0, None, 'Input a', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:b', 'double', 0, None, 'Input b', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('outputs:out', 'double', 0, None, 'The result of a - b', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"a", "b", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.a, self._attributes.b]
self._batchedReadValues = [0, 0]
@property
def a(self):
return self._batchedReadValues[0]
@a.setter
def a(self, value):
self._batchedReadValues[0] = value
@property
def b(self):
return self._batchedReadValues[1]
@b.setter
def b(self, value):
self._batchedReadValues[1] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"out", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def out(self):
value = self._batchedWriteValues.get(self._attributes.out)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.out)
return data_view.get()
@out.setter
def out(self, value):
self._batchedWriteValues[self._attributes.out] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnSubtractDoubleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnSubtractDoubleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnSubtractDoubleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnSubtractDoubleDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.SubtractDouble'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnSubtractDoubleDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnSubtractDoubleDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnSubtractDoubleDatabase(node)
try:
compute_function = getattr(OgnSubtractDoubleDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnSubtractDoubleDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnSubtractDoubleDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnSubtractDoubleDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnSubtractDoubleDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnSubtractDoubleDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnSubtractDoubleDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnSubtractDoubleDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnSubtractDoubleDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnSubtractDoubleDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Subtract Double (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node that subtracts 2 doubles from each other")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnSubtractDoubleDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnSubtractDoubleDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnSubtractDoubleDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnSubtractDoubleDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.SubtractDouble")
| 11,207 | Python | 43.832 | 136 | 0.627197 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnAbsDoubleDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.AbsDouble
Example node that takes the absolute value of a number
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnAbsDoubleDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.AbsDouble
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.num
Outputs:
outputs.out
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:num', 'double', 0, None, 'Input number', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('outputs:out', 'double', 0, None, 'The absolute value of input number', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"num", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.num]
self._batchedReadValues = [0]
@property
def num(self):
return self._batchedReadValues[0]
@num.setter
def num(self, value):
self._batchedReadValues[0] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"out", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def out(self):
value = self._batchedWriteValues.get(self._attributes.out)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.out)
return data_view.get()
@out.setter
def out(self, value):
self._batchedWriteValues[self._attributes.out] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnAbsDoubleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnAbsDoubleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnAbsDoubleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnAbsDoubleDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.AbsDouble'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnAbsDoubleDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnAbsDoubleDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnAbsDoubleDatabase(node)
try:
compute_function = getattr(OgnAbsDoubleDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnAbsDoubleDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnAbsDoubleDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnAbsDoubleDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnAbsDoubleDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnAbsDoubleDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnAbsDoubleDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnAbsDoubleDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnAbsDoubleDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnAbsDoubleDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Abs Double (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node that takes the absolute value of a number")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnAbsDoubleDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnAbsDoubleDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnAbsDoubleDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnAbsDoubleDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.AbsDouble")
| 10,774 | Python | 43.895833 | 131 | 0.627158 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnCountToDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.CountTo
Example stateful node that counts to countTo by a certain increment
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnCountToDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.CountTo
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.countTo
inputs.increment
inputs.reset
inputs.trigger
Outputs:
outputs.count
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:countTo', 'double', 0, None, 'The ceiling to count to', {ogn.MetadataKeys.DEFAULT: '3'}, True, 3, False, ''),
('inputs:increment', 'double', 0, None, 'Increment to count by', {ogn.MetadataKeys.DEFAULT: '0.1'}, True, 0.1, False, ''),
('inputs:reset', 'bool', 0, None, 'Whether to reset the count', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:trigger', 'double3', 0, None, 'Position to be used as a trigger for the counting', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''),
('outputs:count', 'double', 0, None, 'The current count', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"countTo", "increment", "reset", "trigger", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.countTo, self._attributes.increment, self._attributes.reset, self._attributes.trigger]
self._batchedReadValues = [3, 0.1, False, [0.0, 0.0, 0.0]]
@property
def countTo(self):
return self._batchedReadValues[0]
@countTo.setter
def countTo(self, value):
self._batchedReadValues[0] = value
@property
def increment(self):
return self._batchedReadValues[1]
@increment.setter
def increment(self, value):
self._batchedReadValues[1] = value
@property
def reset(self):
return self._batchedReadValues[2]
@reset.setter
def reset(self, value):
self._batchedReadValues[2] = value
@property
def trigger(self):
return self._batchedReadValues[3]
@trigger.setter
def trigger(self, value):
self._batchedReadValues[3] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"count", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def count(self):
value = self._batchedWriteValues.get(self._attributes.count)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.count)
return data_view.get()
@count.setter
def count(self, value):
self._batchedWriteValues[self._attributes.count] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnCountToDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnCountToDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnCountToDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnCountToDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.CountTo'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnCountToDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnCountToDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnCountToDatabase(node)
try:
compute_function = getattr(OgnCountToDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnCountToDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnCountToDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnCountToDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnCountToDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnCountToDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnCountToDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnCountToDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnCountToDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnCountToDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Count To")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example stateful node that counts to countTo by a certain increment")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnCountToDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnCountToDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnCountToDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnCountToDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.CountTo")
| 12,082 | Python | 43.586716 | 181 | 0.622993 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnVersionedDeformerPyDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.VersionedDeformerPy
Test node to confirm version upgrading works. Performs a basic deformation on some points.
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnVersionedDeformerPyDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.VersionedDeformerPy
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.points
inputs.wavelength
Outputs:
outputs.points
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:points', 'point3f[]', 0, None, 'Set of points to be deformed', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
('inputs:wavelength', 'float', 0, None, 'Wavelength of sinusodal deformer function', {ogn.MetadataKeys.DEFAULT: '50.0'}, True, 50.0, False, ''),
('outputs:points', 'point3f[]', 0, None, 'Set of deformed points', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.points = og.AttributeRole.POSITION
role_data.outputs.points = og.AttributeRole.POSITION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"wavelength", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.wavelength]
self._batchedReadValues = [50.0]
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get()
@points.setter
def points(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.points)
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
@property
def wavelength(self):
return self._batchedReadValues[0]
@wavelength.setter
def wavelength(self, value):
self._batchedReadValues[0] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.points_size = None
self._batchedWriteValues = { }
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get(reserved_element_count=self.points_size)
@points.setter
def points(self, value):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnVersionedDeformerPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnVersionedDeformerPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnVersionedDeformerPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.VersionedDeformerPy'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnVersionedDeformerPyDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnVersionedDeformerPyDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnVersionedDeformerPyDatabase(node)
try:
compute_function = getattr(OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnVersionedDeformerPyDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnVersionedDeformerPyDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnVersionedDeformerPyDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnVersionedDeformerPyDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "VersionedDeformerPy")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Test node to confirm version upgrading works. Performs a basic deformation on some points.")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnVersionedDeformerPyDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnVersionedDeformerPyDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnVersionedDeformerPyDatabase.abi, 2)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.VersionedDeformerPy")
| 11,729 | Python | 45.733068 | 162 | 0.644727 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnDecomposeDouble3Database.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.DecomposeDouble3
Example node that takes in a double3 and outputs scalars that are its components
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnDecomposeDouble3Database(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.DecomposeDouble3
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.double3
Outputs:
outputs.x
outputs.y
outputs.z
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:double3', 'double3', 0, None, 'Input double3', {ogn.MetadataKeys.DEFAULT: '[0, 0, 0]'}, True, [0, 0, 0], False, ''),
('outputs:x', 'double', 0, None, 'The x component of the input double3', {}, True, None, False, ''),
('outputs:y', 'double', 0, None, 'The y component of the input double3', {}, True, None, False, ''),
('outputs:z', 'double', 0, None, 'The z component of the input double3', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"double3", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.double3]
self._batchedReadValues = [[0, 0, 0]]
@property
def double3(self):
return self._batchedReadValues[0]
@double3.setter
def double3(self, value):
self._batchedReadValues[0] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"x", "y", "z", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def x(self):
value = self._batchedWriteValues.get(self._attributes.x)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.x)
return data_view.get()
@x.setter
def x(self, value):
self._batchedWriteValues[self._attributes.x] = value
@property
def y(self):
value = self._batchedWriteValues.get(self._attributes.y)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.y)
return data_view.get()
@y.setter
def y(self, value):
self._batchedWriteValues[self._attributes.y] = value
@property
def z(self):
value = self._batchedWriteValues.get(self._attributes.z)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.z)
return data_view.get()
@z.setter
def z(self, value):
self._batchedWriteValues[self._attributes.z] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnDecomposeDouble3Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnDecomposeDouble3Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnDecomposeDouble3Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnDecomposeDouble3Database.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.DecomposeDouble3'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnDecomposeDouble3Database.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnDecomposeDouble3Database(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnDecomposeDouble3Database(node)
try:
compute_function = getattr(OgnDecomposeDouble3Database.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnDecomposeDouble3Database.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnDecomposeDouble3Database._initialize_per_node_data(node)
initialize_function = getattr(OgnDecomposeDouble3Database.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnDecomposeDouble3Database.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnDecomposeDouble3Database.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnDecomposeDouble3Database._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnDecomposeDouble3Database._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnDecomposeDouble3Database.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnDecomposeDouble3Database.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Decompose Double3 (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node that takes in a double3 and outputs scalars that are its components")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnDecomposeDouble3Database.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnDecomposeDouble3Database.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnDecomposeDouble3Database.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnDecomposeDouble3Database.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.DecomposeDouble3")
| 12,140 | Python | 43.800738 | 152 | 0.624053 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnDeformerCpuDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.DeformerPy
Example node applying a sine wave deformation to a set of points, written in Python
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnDeformerCpuDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.DeformerPy
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.multiplier
inputs.points
Outputs:
outputs.points
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:multiplier', 'float', 0, None, 'The multiplier for the amplitude of the sine wave', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''),
('inputs:points', 'point3f[]', 0, None, 'The input points to be deformed', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
('outputs:points', 'point3f[]', 0, None, 'The deformed output points', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.points = og.AttributeRole.POSITION
role_data.outputs.points = og.AttributeRole.POSITION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"multiplier", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.multiplier]
self._batchedReadValues = [1.0]
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get()
@points.setter
def points(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.points)
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
@property
def multiplier(self):
return self._batchedReadValues[0]
@multiplier.setter
def multiplier(self, value):
self._batchedReadValues[0] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.points_size = None
self._batchedWriteValues = { }
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get(reserved_element_count=self.points_size)
@points.setter
def points(self, value):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnDeformerCpuDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnDeformerCpuDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnDeformerCpuDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnDeformerCpuDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.DeformerPy'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnDeformerCpuDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnDeformerCpuDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnDeformerCpuDatabase(node)
try:
compute_function = getattr(OgnDeformerCpuDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnDeformerCpuDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnDeformerCpuDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnDeformerCpuDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnDeformerCpuDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnDeformerCpuDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnDeformerCpuDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnDeformerCpuDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnDeformerCpuDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnDeformerCpuDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Sine Wave Deformer Z-axis (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node applying a sine wave deformation to a set of points, written in Python")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnDeformerCpuDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnDeformerCpuDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnDeformerCpuDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnDeformerCpuDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.DeformerPy")
| 11,530 | Python | 44.940239 | 158 | 0.637641 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnExecSwitchDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.ExecSwitch
A switch node that will enable the left side or right side depending on the input
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnExecSwitchDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.ExecSwitch
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.execIn
inputs.switch
Outputs:
outputs.execLeftOut
outputs.execRightOut
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:execIn', 'execution', 0, 'Exec In', 'Trigger the output', {}, True, None, False, ''),
('inputs:switch', 'bool', 0, None, 'Enables right value if greater than 0, else left value', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:execLeftOut', 'execution', 0, None, 'Left execution', {}, True, None, False, ''),
('outputs:execRightOut', 'execution', 0, None, 'Right execution', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.outputs.execLeftOut = og.AttributeRole.EXECUTION
role_data.outputs.execRightOut = og.AttributeRole.EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"execIn", "switch", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.execIn, self._attributes.switch]
self._batchedReadValues = [None, False]
@property
def execIn(self):
return self._batchedReadValues[0]
@execIn.setter
def execIn(self, value):
self._batchedReadValues[0] = value
@property
def switch(self):
return self._batchedReadValues[1]
@switch.setter
def switch(self, value):
self._batchedReadValues[1] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"execLeftOut", "execRightOut", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def execLeftOut(self):
value = self._batchedWriteValues.get(self._attributes.execLeftOut)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.execLeftOut)
return data_view.get()
@execLeftOut.setter
def execLeftOut(self, value):
self._batchedWriteValues[self._attributes.execLeftOut] = value
@property
def execRightOut(self):
value = self._batchedWriteValues.get(self._attributes.execRightOut)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.execRightOut)
return data_view.get()
@execRightOut.setter
def execRightOut(self, value):
self._batchedWriteValues[self._attributes.execRightOut] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnExecSwitchDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnExecSwitchDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnExecSwitchDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnExecSwitchDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.ExecSwitch'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnExecSwitchDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnExecSwitchDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnExecSwitchDatabase(node)
try:
compute_function = getattr(OgnExecSwitchDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnExecSwitchDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnExecSwitchDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnExecSwitchDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnExecSwitchDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnExecSwitchDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnExecSwitchDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnExecSwitchDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnExecSwitchDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnExecSwitchDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Exec Switch")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "A switch node that will enable the left side or right side depending on the input")
node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "usd")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnExecSwitchDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnExecSwitchDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnExecSwitchDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnExecSwitchDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.ExecSwitch")
| 12,440 | Python | 44.24 | 162 | 0.630064 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnIntCounterDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.IntCounter
Example stateful node that increments every time it's evaluated
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnIntCounterDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.IntCounter
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.increment
inputs.reset
Outputs:
outputs.count
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:increment', 'int', 0, None, 'Increment to count by', {ogn.MetadataKeys.DEFAULT: '1'}, True, 1, False, ''),
('inputs:reset', 'bool', 0, None, 'Whether to reset the count', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:count', 'int', 0, None, 'The current count', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"increment", "reset", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.increment, self._attributes.reset]
self._batchedReadValues = [1, False]
@property
def increment(self):
return self._batchedReadValues[0]
@increment.setter
def increment(self, value):
self._batchedReadValues[0] = value
@property
def reset(self):
return self._batchedReadValues[1]
@reset.setter
def reset(self, value):
self._batchedReadValues[1] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"count", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def count(self):
value = self._batchedWriteValues.get(self._attributes.count)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.count)
return data_view.get()
@count.setter
def count(self, value):
self._batchedWriteValues[self._attributes.count] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnIntCounterDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnIntCounterDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnIntCounterDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnIntCounterDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.IntCounter'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnIntCounterDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnIntCounterDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnIntCounterDatabase(node)
try:
compute_function = getattr(OgnIntCounterDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnIntCounterDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnIntCounterDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnIntCounterDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnIntCounterDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnIntCounterDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnIntCounterDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnIntCounterDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnIntCounterDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnIntCounterDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Int Counter")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example stateful node that increments every time it's evaluated")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnIntCounterDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnIntCounterDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnIntCounterDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnIntCounterDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.IntCounter")
| 11,273 | Python | 44.096 | 135 | 0.628848 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnBouncingCubesGpuDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.BouncingCubesGpu
Deprecated node - no longer supported
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnBouncingCubesGpuDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.BouncingCubesGpu
Class Members:
node: Node being evaluated
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnBouncingCubesGpuDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnBouncingCubesGpuDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnBouncingCubesGpuDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.BouncingCubesGpu'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnBouncingCubesGpuDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnBouncingCubesGpuDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnBouncingCubesGpuDatabase(node)
try:
compute_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnBouncingCubesGpuDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnBouncingCubesGpuDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnBouncingCubesGpuDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnBouncingCubesGpuDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Deprecated Node - Bouncing Cubes (GPU)")
node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Deprecated node - no longer supported")
node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "usd,test")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda")
node_type.set_has_state(True)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnBouncingCubesGpuDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.BouncingCubesGpu")
| 9,183 | Python | 47.336842 | 138 | 0.653055 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnMultDoubleDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.MultDouble
Example node that multiplies 2 doubles together
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnMultDoubleDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.MultDouble
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.a
inputs.b
Outputs:
outputs.out
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:a', 'double', 0, None, 'Input a', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:b', 'double', 0, None, 'Input b', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('outputs:out', 'double', 0, None, 'The result of a * b', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"a", "b", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.a, self._attributes.b]
self._batchedReadValues = [0, 0]
@property
def a(self):
return self._batchedReadValues[0]
@a.setter
def a(self, value):
self._batchedReadValues[0] = value
@property
def b(self):
return self._batchedReadValues[1]
@b.setter
def b(self, value):
self._batchedReadValues[1] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"out", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def out(self):
value = self._batchedWriteValues.get(self._attributes.out)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.out)
return data_view.get()
@out.setter
def out(self, value):
self._batchedWriteValues[self._attributes.out] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnMultDoubleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnMultDoubleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnMultDoubleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnMultDoubleDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.MultDouble'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnMultDoubleDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnMultDoubleDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnMultDoubleDatabase(node)
try:
compute_function = getattr(OgnMultDoubleDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnMultDoubleDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnMultDoubleDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnMultDoubleDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnMultDoubleDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnMultDoubleDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnMultDoubleDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnMultDoubleDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnMultDoubleDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnMultDoubleDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Multiply Double (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node that multiplies 2 doubles together")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnMultDoubleDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnMultDoubleDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnMultDoubleDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnMultDoubleDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.MultDouble")
| 11,091 | Python | 43.368 | 132 | 0.623659 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnComposeDouble3Database.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.ComposeDouble3
Example node that takes in the components of three doubles and outputs a double3
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnComposeDouble3Database(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.ComposeDouble3
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.x
inputs.y
inputs.z
Outputs:
outputs.double3
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:x', 'double', 0, None, 'The x component of the input double3', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:y', 'double', 0, None, 'The y component of the input double3', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:z', 'double', 0, None, 'The z component of the input double3', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('outputs:double3', 'double3', 0, None, 'Output double3', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"x", "y", "z", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.x, self._attributes.y, self._attributes.z]
self._batchedReadValues = [0, 0, 0]
@property
def x(self):
return self._batchedReadValues[0]
@x.setter
def x(self, value):
self._batchedReadValues[0] = value
@property
def y(self):
return self._batchedReadValues[1]
@y.setter
def y(self, value):
self._batchedReadValues[1] = value
@property
def z(self):
return self._batchedReadValues[2]
@z.setter
def z(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"double3", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def double3(self):
value = self._batchedWriteValues.get(self._attributes.double3)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.double3)
return data_view.get()
@double3.setter
def double3(self, value):
self._batchedWriteValues[self._attributes.double3] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnComposeDouble3Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnComposeDouble3Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnComposeDouble3Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnComposeDouble3Database.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.ComposeDouble3'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnComposeDouble3Database.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnComposeDouble3Database(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnComposeDouble3Database(node)
try:
compute_function = getattr(OgnComposeDouble3Database.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnComposeDouble3Database.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnComposeDouble3Database._initialize_per_node_data(node)
initialize_function = getattr(OgnComposeDouble3Database.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnComposeDouble3Database.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnComposeDouble3Database.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnComposeDouble3Database._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnComposeDouble3Database._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnComposeDouble3Database.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnComposeDouble3Database.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Compose Double3 (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node that takes in the components of three doubles and outputs a double3")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnComposeDouble3Database.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnComposeDouble3Database.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnComposeDouble3Database.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnComposeDouble3Database.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.ComposeDouble3")
| 11,727 | Python | 43.934866 | 152 | 0.628038 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnTestInitNodeDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.TestInitNode
Test Init Node
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnTestInitNodeDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.TestInitNode
Class Members:
node: Node being evaluated
Attribute Value Properties:
Outputs:
outputs.value
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('outputs:value', 'float', 0, None, 'Value', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"value", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def value(self):
value = self._batchedWriteValues.get(self._attributes.value)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.value)
return data_view.get()
@value.setter
def value(self, value):
self._batchedWriteValues[self._attributes.value] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnTestInitNodeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnTestInitNodeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnTestInitNodeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnTestInitNodeDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.TestInitNode'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnTestInitNodeDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnTestInitNodeDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnTestInitNodeDatabase(node)
try:
compute_function = getattr(OgnTestInitNodeDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnTestInitNodeDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnTestInitNodeDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnTestInitNodeDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnTestInitNodeDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnTestInitNodeDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnTestInitNodeDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnTestInitNodeDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnTestInitNodeDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnTestInitNodeDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "TestInitNode")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Test Init Node")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnTestInitNodeDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnTestInitNodeDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnTestInitNodeDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnTestInitNodeDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.TestInitNode")
| 9,872 | Python | 44.497696 | 134 | 0.63675 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnDeformerYAxisDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.DeformerYAxis
Example node applying a sine wave deformation to a set of points, written in Python. Deforms along Y-axis instead of Z
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnDeformerYAxisDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.DeformerYAxis
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.multiplier
inputs.offset
inputs.points
inputs.wavelength
Outputs:
outputs.points
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:multiplier', 'double', 0, None, 'The multiplier for the amplitude of the sine wave', {ogn.MetadataKeys.DEFAULT: '1'}, True, 1, False, ''),
('inputs:offset', 'double', 0, None, 'The offset of the sine wave', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:points', 'point3f[]', 0, None, 'The input points to be deformed', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
('inputs:wavelength', 'double', 0, None, 'The wavelength of the sine wave', {ogn.MetadataKeys.DEFAULT: '1'}, True, 1, False, ''),
('outputs:points', 'point3f[]', 0, None, 'The deformed output points', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.points = og.AttributeRole.POSITION
role_data.outputs.points = og.AttributeRole.POSITION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"multiplier", "offset", "wavelength", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.multiplier, self._attributes.offset, self._attributes.wavelength]
self._batchedReadValues = [1, 0, 1]
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get()
@points.setter
def points(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.points)
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
@property
def multiplier(self):
return self._batchedReadValues[0]
@multiplier.setter
def multiplier(self, value):
self._batchedReadValues[0] = value
@property
def offset(self):
return self._batchedReadValues[1]
@offset.setter
def offset(self, value):
self._batchedReadValues[1] = value
@property
def wavelength(self):
return self._batchedReadValues[2]
@wavelength.setter
def wavelength(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.points_size = None
self._batchedWriteValues = { }
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get(reserved_element_count=self.points_size)
@points.setter
def points(self, value):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnDeformerYAxisDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnDeformerYAxisDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnDeformerYAxisDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnDeformerYAxisDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.DeformerYAxis'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnDeformerYAxisDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnDeformerYAxisDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnDeformerYAxisDatabase(node)
try:
compute_function = getattr(OgnDeformerYAxisDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnDeformerYAxisDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnDeformerYAxisDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnDeformerYAxisDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnDeformerYAxisDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnDeformerYAxisDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnDeformerYAxisDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnDeformerYAxisDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnDeformerYAxisDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnDeformerYAxisDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Sine Wave Deformer Y-axis (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node applying a sine wave deformation to a set of points, written in Python. Deforms along Y-axis instead of Z")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnDeformerYAxisDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnDeformerYAxisDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnDeformerYAxisDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnDeformerYAxisDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.DeformerYAxis")
| 12,463 | Python | 44.99262 | 191 | 0.636925 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnDynamicSwitchDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.DynamicSwitch
A switch node that will enable the left side or right side depending on the input. Requires dynamic scheduling to work
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnDynamicSwitchDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.DynamicSwitch
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.left_value
inputs.right_value
inputs.switch
Outputs:
outputs.left_out
outputs.right_out
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:left_value', 'int', 0, None, 'Left value to output', {ogn.MetadataKeys.DEFAULT: '-1'}, True, -1, False, ''),
('inputs:right_value', 'int', 0, None, 'Right value to output', {ogn.MetadataKeys.DEFAULT: '1'}, True, 1, False, ''),
('inputs:switch', 'int', 0, None, 'Enables right value if greater than 0, else left value', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('outputs:left_out', 'int', 0, None, 'Left side output', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('outputs:right_out', 'int', 0, None, 'Right side output', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"left_value", "right_value", "switch", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.left_value, self._attributes.right_value, self._attributes.switch]
self._batchedReadValues = [-1, 1, 0]
@property
def left_value(self):
return self._batchedReadValues[0]
@left_value.setter
def left_value(self, value):
self._batchedReadValues[0] = value
@property
def right_value(self):
return self._batchedReadValues[1]
@right_value.setter
def right_value(self, value):
self._batchedReadValues[1] = value
@property
def switch(self):
return self._batchedReadValues[2]
@switch.setter
def switch(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"left_out", "right_out", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def left_out(self):
value = self._batchedWriteValues.get(self._attributes.left_out)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.left_out)
return data_view.get()
@left_out.setter
def left_out(self, value):
self._batchedWriteValues[self._attributes.left_out] = value
@property
def right_out(self):
value = self._batchedWriteValues.get(self._attributes.right_out)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.right_out)
return data_view.get()
@right_out.setter
def right_out(self, value):
self._batchedWriteValues[self._attributes.right_out] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnDynamicSwitchDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnDynamicSwitchDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnDynamicSwitchDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnDynamicSwitchDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.DynamicSwitch'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnDynamicSwitchDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnDynamicSwitchDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnDynamicSwitchDatabase(node)
try:
compute_function = getattr(OgnDynamicSwitchDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnDynamicSwitchDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnDynamicSwitchDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnDynamicSwitchDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnDynamicSwitchDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnDynamicSwitchDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnDynamicSwitchDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnDynamicSwitchDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnDynamicSwitchDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnDynamicSwitchDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Dynamic Switch")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "A switch node that will enable the left side or right side depending on the input. Requires dynamic scheduling to work")
node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "usd")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnDynamicSwitchDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnDynamicSwitchDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnDynamicSwitchDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnDynamicSwitchDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.DynamicSwitch")
| 12,626 | Python | 44.75 | 191 | 0.627435 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnBouncingCubesCpuDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.BouncingCubes
Deprecated node - no longer supported
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnBouncingCubesCpuDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.BouncingCubes
Class Members:
node: Node being evaluated
Attribute Value Properties:
State:
state.translations
state.velocities
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('state:translations', 'float3[]', 0, 'Translations', 'Set of translation attributes gathered from the inputs.\nTranslations have velocities applied to them each evaluation.', {}, True, None, False, ''),
('state:velocities', 'float[]', 0, 'Velocities', 'Set of velocity attributes gathered from the inputs', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.translations_size = None
self.velocities_size = None
@property
def translations(self):
data_view = og.AttributeValueHelper(self._attributes.translations)
self.translations_size = data_view.get_array_size()
return data_view.get()
@translations.setter
def translations(self, value):
data_view = og.AttributeValueHelper(self._attributes.translations)
data_view.set(value)
self.translations_size = data_view.get_array_size()
@property
def velocities(self):
data_view = og.AttributeValueHelper(self._attributes.velocities)
self.velocities_size = data_view.get_array_size()
return data_view.get()
@velocities.setter
def velocities(self, value):
data_view = og.AttributeValueHelper(self._attributes.velocities)
data_view.set(value)
self.velocities_size = data_view.get_array_size()
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnBouncingCubesCpuDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnBouncingCubesCpuDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnBouncingCubesCpuDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.BouncingCubes'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnBouncingCubesCpuDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnBouncingCubesCpuDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnBouncingCubesCpuDatabase(node)
try:
compute_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnBouncingCubesCpuDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnBouncingCubesCpuDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnBouncingCubesCpuDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnBouncingCubesCpuDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Deprecated Node - Bouncing Cubes (GPU)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Deprecated node - no longer supported")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnBouncingCubesCpuDatabase.INTERFACE.add_to_node_type(node_type)
node_type.set_has_state(True)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnBouncingCubesCpuDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.BouncingCubes")
| 10,508 | Python | 46.337838 | 211 | 0.649505 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnDeformerGpuDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.DeformerPyGpu
Example node applying a sine wave deformation to a set of points, written in Python for the GPU
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnDeformerGpuDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.DeformerPyGpu
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.multiplier
inputs.points
Outputs:
outputs.points
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:multiplier', 'float', 0, None, 'The multiplier for the amplitude of the sine wave', {ogn.MetadataKeys.DEFAULT: '1'}, True, 1, False, ''),
('inputs:points', 'point3f[]', 0, None, 'The input points to be deformed', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
('outputs:points', 'point3f[]', 0, None, 'The deformed output points', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.points = og.AttributeRole.POSITION
role_data.outputs.points = og.AttributeRole.POSITION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def multiplier(self):
data_view = og.AttributeValueHelper(self._attributes.multiplier)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
return data_view.get(on_gpu=True)
@multiplier.setter
def multiplier(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.multiplier)
data_view = og.AttributeValueHelper(self._attributes.multiplier)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
data_view.set(value, on_gpu=True)
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
return data_view.get(on_gpu=True)
@points.setter
def points(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.points)
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
data_view.set(value, on_gpu=True)
self.points_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.points_size = None
self._batchedWriteValues = { }
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
return data_view.get(reserved_element_count=self.points_size, on_gpu=True)
@points.setter
def points(self, value):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
data_view.set(value, on_gpu=True)
self.points_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnDeformerGpuDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnDeformerGpuDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnDeformerGpuDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnDeformerGpuDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.DeformerPyGpu'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnDeformerGpuDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnDeformerGpuDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnDeformerGpuDatabase(node)
try:
compute_function = getattr(OgnDeformerGpuDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnDeformerGpuDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnDeformerGpuDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnDeformerGpuDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnDeformerGpuDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnDeformerGpuDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnDeformerGpuDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnDeformerGpuDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnDeformerGpuDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnDeformerGpuDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Sine Wave Deformer Z-axis (Python GPU)")
node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node applying a sine wave deformation to a set of points, written in Python for the GPU")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda")
OgnDeformerGpuDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnDeformerGpuDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnDeformerGpuDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnDeformerGpuDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.DeformerPyGpu")
| 11,810 | Python | 46.055777 | 167 | 0.641829 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnTestSingletonDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.TestSingleton
Example node that showcases the use of singleton nodes (nodes that can have only 1 instance)
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnTestSingletonDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.TestSingleton
Class Members:
node: Node being evaluated
Attribute Value Properties:
Outputs:
outputs.out
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('outputs:out', 'double', 0, None, 'The unique output of the only instance of this node', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"out", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def out(self):
value = self._batchedWriteValues.get(self._attributes.out)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.out)
return data_view.get()
@out.setter
def out(self, value):
self._batchedWriteValues[self._attributes.out] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnTestSingletonDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnTestSingletonDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnTestSingletonDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnTestSingletonDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.TestSingleton'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnTestSingletonDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnTestSingletonDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnTestSingletonDatabase(node)
try:
compute_function = getattr(OgnTestSingletonDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnTestSingletonDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnTestSingletonDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnTestSingletonDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnTestSingletonDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnTestSingletonDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnTestSingletonDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnTestSingletonDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnTestSingletonDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnTestSingletonDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.SINGLETON, "1")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Test Singleton")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node that showcases the use of singleton nodes (nodes that can have only 1 instance)")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnTestSingletonDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnTestSingletonDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnTestSingletonDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnTestSingletonDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.TestSingleton")
| 10,157 | Python | 45.59633 | 164 | 0.640248 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnPositionToColorDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.PositionToColor
This node takes positional data (double3) and converts to a color, and outputs as color3f[] (which seems to be the default
color connection in USD)
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnPositionToColorDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.PositionToColor
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.color_offset
inputs.position
inputs.scale
Outputs:
outputs.color
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:color_offset', 'color3f', 0, None, 'Offset added to the scaled color to get the final result', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''),
('inputs:position', 'double3', 0, None, 'Position to be converted to a color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''),
('inputs:scale', 'float', 0, None, 'Constant by which to multiply the position to get the color', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''),
('outputs:color', 'color3f[]', 0, None, 'Color value extracted from the position', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.color_offset = og.AttributeRole.COLOR
role_data.outputs.color = og.AttributeRole.COLOR
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"color_offset", "position", "scale", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.color_offset, self._attributes.position, self._attributes.scale]
self._batchedReadValues = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 1.0]
@property
def color_offset(self):
return self._batchedReadValues[0]
@color_offset.setter
def color_offset(self, value):
self._batchedReadValues[0] = value
@property
def position(self):
return self._batchedReadValues[1]
@position.setter
def position(self, value):
self._batchedReadValues[1] = value
@property
def scale(self):
return self._batchedReadValues[2]
@scale.setter
def scale(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.color_size = None
self._batchedWriteValues = { }
@property
def color(self):
data_view = og.AttributeValueHelper(self._attributes.color)
return data_view.get(reserved_element_count=self.color_size)
@color.setter
def color(self, value):
data_view = og.AttributeValueHelper(self._attributes.color)
data_view.set(value)
self.color_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnPositionToColorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnPositionToColorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnPositionToColorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.PositionToColor'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnPositionToColorDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnPositionToColorDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnPositionToColorDatabase(node)
try:
compute_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnPositionToColorDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnPositionToColorDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnPositionToColorDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnPositionToColorDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnPositionToColorDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "PositionToColor")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This node takes positional data (double3) and converts to a color, and outputs as color3f[] (which seems to be the default color connection in USD)")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnPositionToColorDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnPositionToColorDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnPositionToColorDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.PositionToColor")
| 12,043 | Python | 45.863813 | 220 | 0.639708 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnClampDoubleDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.ClampDouble
Example node that a number to a range
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnClampDoubleDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.ClampDouble
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.max
inputs.min
inputs.num
Outputs:
outputs.out
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:max', 'double', 0, None, 'Maximum value', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:min', 'double', 0, None, 'Mininum value', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:num', 'double', 0, None, 'Input number', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('outputs:out', 'double', 0, None, 'The result of the number, having been clamped to the range min,max', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"max", "min", "num", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.max, self._attributes.min, self._attributes.num]
self._batchedReadValues = [0, 0, 0]
@property
def max(self):
return self._batchedReadValues[0]
@max.setter
def max(self, value):
self._batchedReadValues[0] = value
@property
def min(self):
return self._batchedReadValues[1]
@min.setter
def min(self, value):
self._batchedReadValues[1] = value
@property
def num(self):
return self._batchedReadValues[2]
@num.setter
def num(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"out", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def out(self):
value = self._batchedWriteValues.get(self._attributes.out)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.out)
return data_view.get()
@out.setter
def out(self, value):
self._batchedWriteValues[self._attributes.out] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnClampDoubleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnClampDoubleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnClampDoubleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnClampDoubleDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.ClampDouble'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnClampDoubleDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnClampDoubleDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnClampDoubleDatabase(node)
try:
compute_function = getattr(OgnClampDoubleDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnClampDoubleDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnClampDoubleDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnClampDoubleDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnClampDoubleDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnClampDoubleDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnClampDoubleDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnClampDoubleDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnClampDoubleDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnClampDoubleDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Clamp Double (Python)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Example node that a number to a range")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnClampDoubleDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnClampDoubleDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnClampDoubleDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnClampDoubleDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.ClampDouble")
| 11,534 | Python | 43.365384 | 140 | 0.623288 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnAbsDouble.py | """
Implementation of an OmniGraph node takes the absolute value of a number
"""
class OgnAbsDouble:
@staticmethod
def compute(db):
db.outputs.out = abs(db.inputs.num)
return True
| 206 | Python | 17.81818 | 72 | 0.669903 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnComposeDouble3.py | """
Implementation of an OmniGraph node that composes a double3 from its components
"""
class OgnComposeDouble3:
@staticmethod
def compute(db):
db.outputs.double3 = (db.inputs.x, db.inputs.y, db.inputs.z)
return True
| 243 | Python | 21.181816 | 79 | 0.687243 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnDeformerYAxis.py | """
Implementation of an OmniGraph node that deforms a surface using a sine wave
"""
import numpy as np
class OgnDeformerYAxis:
@staticmethod
def compute(db):
"""Deform the input points by a multiple of the sine wave"""
points = db.inputs.points
multiplier = db.inputs.multiplier
wavelength = db.inputs.wavelength
offset = db.inputs.offset
db.outputs.points_size = points.shape[0]
# Nothing to evaluate if there are no input points
if db.outputs.points_size == 0:
return True
output_points = db.outputs.points
if wavelength <= 0:
wavelength = 1.0
pt = points.copy() # we still need to do a copy here because we do not want to modify points
tx = pt[:, 0]
offset_tx = tx + offset
disp = np.sin(offset_tx / wavelength)
pt[:, 1] += disp * multiplier
output_points[:] = pt[:] # we modify output_points in memory so we do not need to set the value again
return True
| 1,037 | Python | 29.529411 | 110 | 0.612343 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnClampDouble.py | """
Implementation of an OmniGraph node that clamps a double value
"""
class OgnClampDouble:
@staticmethod
def compute(db):
if db.inputs.num < db.inputs.min:
db.outputs.out = db.inputs.min
elif db.inputs.num > db.inputs.max:
db.outputs.out = db.inputs.max
else:
db.outputs.out = db.inputs.num
return True
| 384 | Python | 21.647058 | 62 | 0.596354 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnDecomposeDouble3.py | """
Implementation of an OmniGraph node that decomposes a double3 into its comonents
"""
class OgnDecomposeDouble3:
@staticmethod
def compute(db):
in_double3 = db.inputs.double3
db.outputs.x = in_double3[0]
db.outputs.y = in_double3[1]
db.outputs.z = in_double3[2]
return True
| 327 | Python | 22.42857 | 80 | 0.64526 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnMultDouble.py | """
Implementation of an OmniGraph node that calculates a * b
"""
class OgnMultDouble:
@staticmethod
def compute(db):
db.outputs.out = db.inputs.a * db.inputs.b
return True
| 199 | Python | 17.181817 | 57 | 0.648241 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnSubtractDouble.py | """
Implementation of an OmniGraph node that subtracts b from a
"""
class OgnSubtractDouble:
@staticmethod
def compute(db):
db.outputs.out = db.inputs.a - db.inputs.b
return True
| 205 | Python | 17.727271 | 59 | 0.663415 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnPositionToColor.py | """
Implementation of the node algorith to convert a position to a color
"""
class OgnPositionToColor:
"""
This node takes positional data (double3) and converts to a color, and outputs
as color3f[] (which seems to be the default color connection in USD)
"""
@staticmethod
def compute(db):
"""Run the algorithm to convert a position to a color"""
position = db.inputs.position
scale_value = db.inputs.scale
color_offset = db.inputs.color_offset
color = (abs(position[:])) / scale_value
color += color_offset
ramp = (scale_value - abs(position[0])) / scale_value
ramp = max(ramp, 0)
color[0] -= ramp
if color[0] < 0:
color[0] = 0
color[1] += ramp
if color[1] > 1:
color[1] = 1
color[2] -= ramp
if color[2] < 0:
color[2] = 0
db.outputs.color_size = 1
db.outputs.color[0] = color
return True
| 993 | Python | 24.487179 | 82 | 0.558912 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/realtime/OgnBouncingCubesCpu.py | """
Example node showing realtime update from gathered data.
"""
class OgnBouncingCubesCpu:
@staticmethod
def compute(db):
velocities = db.state.velocities
translations = db.state.translations
# Empty input means nothing to do
if translations.size == 0 or velocities.size == 0:
return True
h = 1.0 / 60.0
g = -1000.0
for ii, velocity in enumerate(velocities):
velocity += h * g
translations[ii][2] += h * velocity
if translations[ii][2] < 1.0:
translations[ii][2] = 1.0
velocity = -5 * h * g
translations[0][0] += 0.03
translations[1][0] += 0.03
# We no longer need to set values because we do not copy memory of the numpy arrays
# Mutating the numpy array will also mutate the attribute data
# Alternative, setting values using the below lines will also work
# context.set_attr_value(translations, attr_translations)
# context.set_attr_value(velocities, attr_translations)
return True
| 1,102 | Python | 29.638888 | 91 | 0.598004 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/realtime/OgnBouncingCubesGpu.py | """
Example node showing realtime update from gathered data computed on the GPU.
"""
class OgnBouncingCubesGpu:
@staticmethod
def compute(db):
# This is how it should work when gather is fully supported
# velocities = db.state.velocities
# translations = db.state.translations
attr_velocities = db.node.get_attribute("state:velocities")
attr_translations = db.node.get_attribute("state:translations")
velocities = db.context_helper.get_attr_value(attr_velocities, isGPU=True, isTensor=True)
translations = db.context_helper.get_attr_value(attr_translations, isGPU=True, isTensor=True)
# When there is no data there is nothing to do
if velocities.size == 0 or translations.size == 0:
return True
h = 1.0 / 60.0
g = -1000.0
velocities += h * g
translations[:, 2] += h * velocities
translations_z = translations.split(1, dim=1)[2].squeeze(-1)
update_idx = (translations_z < 1.0).nonzero().squeeze(-1)
if update_idx.shape[0] > 0:
translations[update_idx, 2] = 1
velocities[update_idx] = -5 * h * g
translations[:, 0] += 0.03
# We no longer need to set values because we do not copy memory of the numpy arrays
# Mutating the numpy array will also mutate the attribute data
# Computegraph APIs using torch tensors currently do not have support for setting values.
# context.set_attr_value(translations, attr_translations)
# context.set_attr_value(velocities, attr_translations)
return True
| 1,624 | Python | 35.11111 | 101 | 0.644089 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/utility/OgnPyUniversalAdd.py | class OgnPyUniversalAdd:
@staticmethod
def compute(db):
db.outputs.bool_0 = db.inputs.bool_0 ^ db.inputs.bool_1
db.outputs.bool_arr_0 = [
db.inputs.bool_arr_0[i] ^ db.inputs.bool_arr_1[i] for i in range(len(db.inputs.bool_arr_0))
]
db.outputs.colord3_0 = db.inputs.colord3_0 + db.inputs.colord3_1
db.outputs.colord4_0 = db.inputs.colord4_0 + db.inputs.colord4_1
db.outputs.colord3_arr_0 = db.inputs.colord3_arr_0 + db.inputs.colord3_arr_1
db.outputs.colord4_arr_0 = db.inputs.colord4_arr_0 + db.inputs.colord4_arr_1
db.outputs.colorf3_0 = db.inputs.colorf3_0 + db.inputs.colorf3_1
db.outputs.colorf4_0 = db.inputs.colorf4_0 + db.inputs.colorf4_1
db.outputs.colorf3_arr_0 = db.inputs.colorf3_arr_0 + db.inputs.colorf3_arr_1
db.outputs.colorf4_arr_0 = db.inputs.colorf4_arr_0 + db.inputs.colorf4_arr_1
db.outputs.colorh3_0 = db.inputs.colorh3_0 + db.inputs.colorh3_1
db.outputs.colorh4_0 = db.inputs.colorh4_0 + db.inputs.colorh4_1
db.outputs.colorh3_arr_0 = db.inputs.colorh3_arr_0 + db.inputs.colorh3_arr_1
db.outputs.colorh4_arr_0 = db.inputs.colorh4_arr_0 + db.inputs.colorh4_arr_1
db.outputs.double_0 = db.inputs.double_0 + db.inputs.double_1
db.outputs.double2_0 = db.inputs.double2_0 + db.inputs.double2_1
db.outputs.double3_0 = db.inputs.double3_0 + db.inputs.double3_1
db.outputs.double4_0 = db.inputs.double4_0 + db.inputs.double4_1
db.outputs.double_arr_0 = db.inputs.double_arr_0 + db.inputs.double_arr_1
db.outputs.double2_arr_0 = db.inputs.double2_arr_0 + db.inputs.double2_arr_1
db.outputs.double3_arr_0 = db.inputs.double3_arr_0 + db.inputs.double3_arr_1
db.outputs.double4_arr_0 = db.inputs.double4_arr_0 + db.inputs.double4_arr_1
db.outputs.float_0 = db.inputs.float_0 + db.inputs.float_1
db.outputs.float2_0 = db.inputs.float2_0 + db.inputs.float2_1
db.outputs.float3_0 = db.inputs.float3_0 + db.inputs.float3_1
db.outputs.float4_0 = db.inputs.float4_0 + db.inputs.float4_1
db.outputs.float_arr_0 = db.inputs.float_arr_0 + db.inputs.float_arr_1
db.outputs.float2_arr_0 = db.inputs.float2_arr_0 + db.inputs.float2_arr_1
db.outputs.float3_arr_0 = db.inputs.float3_arr_0 + db.inputs.float3_arr_1
db.outputs.float4_arr_0 = db.inputs.float4_arr_0 + db.inputs.float4_arr_1
db.outputs.frame4_0 = db.inputs.frame4_0 + db.inputs.frame4_1
db.outputs.frame4_arr_0 = db.inputs.frame4_arr_0 + db.inputs.frame4_arr_1
db.outputs.half_0 = db.inputs.half_0 + db.inputs.half_1
db.outputs.half2_0 = db.inputs.half2_0 + db.inputs.half2_1
db.outputs.half3_0 = db.inputs.half3_0 + db.inputs.half3_1
db.outputs.half4_0 = db.inputs.half4_0 + db.inputs.half4_1
db.outputs.half_arr_0 = db.inputs.half_arr_0 + db.inputs.half_arr_1
db.outputs.half2_arr_0 = db.inputs.half2_arr_0 + db.inputs.half2_arr_1
db.outputs.half3_arr_0 = db.inputs.half3_arr_0 + db.inputs.half3_arr_1
db.outputs.half4_arr_0 = db.inputs.half4_arr_0 + db.inputs.half4_arr_1
db.outputs.int_0 = db.inputs.int_0 + db.inputs.int_1
db.outputs.int2_0 = db.inputs.int2_0 + db.inputs.int2_1
db.outputs.int3_0 = db.inputs.int3_0 + db.inputs.int3_1
db.outputs.int4_0 = db.inputs.int4_0 + db.inputs.int4_1
db.outputs.int_arr_0 = db.inputs.int_arr_0 + db.inputs.int_arr_1
db.outputs.int2_arr_0 = db.inputs.int2_arr_0 + db.inputs.int2_arr_1
db.outputs.int3_arr_0 = db.inputs.int3_arr_0 + db.inputs.int3_arr_1
db.outputs.int4_arr_0 = db.inputs.int4_arr_0 + db.inputs.int4_arr_1
db.outputs.int64_0 = db.inputs.int64_0 + db.inputs.int64_1
db.outputs.int64_arr_0 = db.inputs.int64_arr_0 + db.inputs.int64_arr_1
db.outputs.matrixd2_0 = db.inputs.matrixd2_0 + db.inputs.matrixd2_1
db.outputs.matrixd3_0 = db.inputs.matrixd3_0 + db.inputs.matrixd3_1
db.outputs.matrixd4_0 = db.inputs.matrixd4_0 + db.inputs.matrixd4_1
db.outputs.matrixd2_arr_0 = db.inputs.matrixd2_arr_0 + db.inputs.matrixd2_arr_1
db.outputs.matrixd3_arr_0 = db.inputs.matrixd3_arr_0 + db.inputs.matrixd3_arr_1
db.outputs.matrixd4_arr_0 = db.inputs.matrixd4_arr_0 + db.inputs.matrixd4_arr_1
db.outputs.normald3_0 = db.inputs.normald3_0 + db.inputs.normald3_1
db.outputs.normald3_arr_0 = db.inputs.normald3_arr_0 + db.inputs.normald3_arr_1
db.outputs.normalf3_0 = db.inputs.normalf3_0 + db.inputs.normalf3_1
db.outputs.normalf3_arr_0 = db.inputs.normalf3_arr_0 + db.inputs.normalf3_arr_1
db.outputs.normalh3_0 = db.inputs.normalh3_0 + db.inputs.normalh3_1
db.outputs.normalh3_arr_0 = db.inputs.normalh3_arr_0 + db.inputs.normalh3_arr_1
db.outputs.pointd3_0 = db.inputs.pointd3_0 + db.inputs.pointd3_1
db.outputs.pointd3_arr_0 = db.inputs.pointd3_arr_0 + db.inputs.pointd3_arr_1
db.outputs.pointf3_0 = db.inputs.pointf3_0 + db.inputs.pointf3_1
db.outputs.pointf3_arr_0 = db.inputs.pointf3_arr_0 + db.inputs.pointf3_arr_1
db.outputs.pointh3_0 = db.inputs.pointh3_0 + db.inputs.pointh3_1
db.outputs.pointh3_arr_0 = db.inputs.pointh3_arr_0 + db.inputs.pointh3_arr_1
db.outputs.quatd4_0 = db.inputs.quatd4_0 + db.inputs.quatd4_1
db.outputs.quatd4_arr_0 = db.inputs.quatd4_arr_0 + db.inputs.quatd4_arr_1
db.outputs.quatf4_0 = db.inputs.quatf4_0 + db.inputs.quatf4_1
db.outputs.quatf4_arr_0 = db.inputs.quatf4_arr_0 + db.inputs.quatf4_arr_1
db.outputs.quath4_0 = db.inputs.quath4_0 + db.inputs.quath4_1
db.outputs.quath4_arr_0 = db.inputs.quath4_arr_0 + db.inputs.quath4_arr_1
db.outputs.texcoordd2_0 = db.inputs.texcoordd2_0 + db.inputs.texcoordd2_1
db.outputs.texcoordd3_0 = db.inputs.texcoordd3_0 + db.inputs.texcoordd3_1
db.outputs.texcoordd2_arr_0 = db.inputs.texcoordd2_arr_0 + db.inputs.texcoordd2_arr_1
db.outputs.texcoordd3_arr_0 = db.inputs.texcoordd3_arr_0 + db.inputs.texcoordd3_arr_1
db.outputs.texcoordf2_0 = db.inputs.texcoordf2_0 + db.inputs.texcoordf2_1
db.outputs.texcoordf3_0 = db.inputs.texcoordf3_0 + db.inputs.texcoordf3_1
db.outputs.texcoordf2_arr_0 = db.inputs.texcoordf2_arr_0 + db.inputs.texcoordf2_arr_1
db.outputs.texcoordf3_arr_0 = db.inputs.texcoordf3_arr_0 + db.inputs.texcoordf3_arr_1
db.outputs.texcoordh2_0 = db.inputs.texcoordh2_0 + db.inputs.texcoordh2_1
db.outputs.texcoordh3_0 = db.inputs.texcoordh3_0 + db.inputs.texcoordh3_1
db.outputs.texcoordh2_arr_0 = db.inputs.texcoordh2_arr_0 + db.inputs.texcoordh2_arr_1
db.outputs.texcoordh3_arr_0 = db.inputs.texcoordh3_arr_0 + db.inputs.texcoordh3_arr_1
db.outputs.timecode_0 = db.inputs.timecode_0 + db.inputs.timecode_1
db.outputs.timecode_arr_0 = db.inputs.timecode_arr_0 + db.inputs.timecode_arr_1
db.outputs.token_0 = db.inputs.token_0 + db.inputs.token_1
db.outputs.token_arr_0 = [
db.inputs.token_arr_0[i] + db.inputs.token_arr_1[i] for i in range(len(db.inputs.token_arr_0))
]
db.outputs.transform4_0 = db.inputs.transform4_0 + db.inputs.transform4_1
db.outputs.transform4_arr_0 = db.inputs.transform4_arr_0 + db.inputs.transform4_arr_1
db.outputs.uchar_0 = db.inputs.uchar_0 + db.inputs.uchar_1
db.outputs.uchar_arr_0 = db.inputs.uchar_arr_0 + db.inputs.uchar_arr_1
db.outputs.uint_0 = db.inputs.uint_0 + db.inputs.uint_1
db.outputs.uint_arr_0 = db.inputs.uint_arr_0 + db.inputs.uint_arr_1
db.outputs.uint64_0 = db.inputs.uint64_0 + db.inputs.uint64_1
db.outputs.uint64_arr_0 = db.inputs.uint64_arr_0 + db.inputs.uint64_arr_1
db.outputs.vectord3_0 = db.inputs.vectord3_0 + db.inputs.vectord3_1
db.outputs.vectord3_arr_0 = db.inputs.vectord3_arr_0 + db.inputs.vectord3_arr_1
db.outputs.vectorf3_0 = db.inputs.vectorf3_0 + db.inputs.vectorf3_1
db.outputs.vectorf3_arr_0 = db.inputs.vectorf3_arr_0 + db.inputs.vectorf3_arr_1
db.outputs.vectorh3_0 = db.inputs.vectorh3_0 + db.inputs.vectorh3_1
db.outputs.vectorh3_arr_0 = db.inputs.vectorh3_arr_0 + db.inputs.vectorh3_arr_1
return True
| 8,362 | Python | 72.359648 | 106 | 0.669816 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/utility/OgnDynamicSwitch.py | """
Implementation of an stateful OmniGraph node that enables 1 branch or another using dynamic scheduling
"""
class OgnDynamicSwitch:
@staticmethod
def compute(db):
db.node.set_dynamic_downstream_control(True)
left_out_attr = db.node.get_attribute("outputs:left_out")
right_out_attr = db.node.get_attribute("outputs:right_out")
if db.inputs.switch > 0:
left_out_attr.set_disable_dynamic_downstream_work(True)
right_out_attr.set_disable_dynamic_downstream_work(False)
else:
left_out_attr.set_disable_dynamic_downstream_work(False)
right_out_attr.set_disable_dynamic_downstream_work(True)
db.outputs.left_out = db.inputs.left_value
db.outputs.right_out = db.inputs.right_value
return True
| 812 | Python | 34.347825 | 102 | 0.671182 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/stateful/OgnCountTo.py | """
Implementation of an stateful OmniGraph node that counts to a number defined by countTo
"""
class OgnCountTo:
@staticmethod
def compute(db):
if db.inputs.reset:
db.outputs.count = 0
else:
db.outputs.count = db.outputs.count + db.inputs.increment
if db.outputs.count > db.inputs.countTo:
db.outputs.count = db.inputs.countTo
else:
db.node.set_compute_incomplete()
return True
| 495 | Python | 23.799999 | 87 | 0.589899 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/stateful/OgnIntCounter.py | """
Implementation of an stateful OmniGraph node that counts up by an increment
"""
class OgnIntCounter:
@staticmethod
def compute(db):
if db.inputs.reset:
db.outputs.count = 0
else:
db.outputs.count = db.outputs.count + db.inputs.increment
return True
| 312 | Python | 19.866665 | 75 | 0.625 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tests/OgnTestInitNode.py | import omni.graph.core as og
class OgnTestInitNode:
@staticmethod
def initialize(context, node):
_ = og.Controller()
@staticmethod
def release(node):
pass
@staticmethod
def compute(db):
db.outputs.value = 1.0
return True
| 281 | Python | 15.588234 | 34 | 0.608541 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tests/OgnTestSingleton.py | class OgnTestSingleton:
@staticmethod
def compute(db):
db.outputs.out = 88.8
return True
| 113 | Python | 17.999997 | 29 | 0.619469 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/deformers/OgnVersionedDeformerPy.py | """
Implementation of a Python node that handles a simple version upgrade where the different versions contain
different attributes:
Version 0: multiplier
Version 1: multiplier, wavelength
Version 2: wavelength
Depending on the version that was received the upgrade will remove the obsolete "multiplier" attribute and/or
insert the new "wavelength" attribute.
"""
import numpy as np
import omni.graph.core as og
class OgnVersionedDeformerPy:
@staticmethod
def compute(db):
input_points = db.inputs.points
if len(input_points) <= 0:
return False
wavelength = db.inputs.wavelength
if wavelength <= 0.0:
wavelength = 310.0
db.outputs.points_size = input_points.shape[0]
# Nothing to evaluate if there are no input points
if db.outputs.points_size == 0:
return True
output_points = db.outputs.points
pt = input_points.copy() # we still need to do a copy here because we do not want to modify points
tx = (pt[:, 0] - wavelength) / wavelength
ty = (pt[:, 1] - wavelength) / wavelength
disp = 10.0 * (np.sin(tx * 10.0) + np.cos(ty * 15.0))
pt[:, 2] += disp * 5
output_points[:] = pt[:] # we modify output_points in memory so we do not need to set the value again
return True
@staticmethod
def update_node_version(context, node, old_version, new_version):
if old_version < new_version:
if old_version < 1:
node.create_attribute(
"inputs:wavelength",
og.Type(og.BaseDataType.FLOAT),
og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT,
50.0,
)
if old_version < 2:
node.remove_attribute("inputs:multiplier")
return True
return False
@staticmethod
def initialize_type(node_type):
node_type.add_input("test_input", "int", True)
node_type.add_output("test_output", "float", True)
node_type.add_extended_input(
"test_union_input", "float,double", True, og.ExtendedAttributeType.EXTENDED_ATTR_TYPE_UNION
)
return True
| 2,233 | Python | 33.906249 | 110 | 0.605911 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/deformers/OgnDeformerCpu.py | """
Implementation of an OmniGraph node that deforms a surface using a sine wave
"""
import numpy as np
class OgnDeformerCpu:
@staticmethod
def compute(db):
"""Deform the input points by a multiple of the sine wave"""
points = db.inputs.points
multiplier = db.inputs.multiplier
db.outputs.points_size = points.shape[0]
# Nothing to evaluate if there are no input points
if db.outputs.points_size == 0:
return True
output_points = db.outputs.points
pt = points.copy() # we still need to do a copy here because we do not want to modify points
tx = (pt[:, 0] - 310.0) / 310.0
ty = (pt[:, 1] - 310.0) / 310.0
disp = 10.0 * (np.sin(tx * 10.0) + np.cos(ty * 15.0))
pt[:, 2] += disp * multiplier
output_points[:] = pt[:] # we modify output_points in memory so we do not need to set the value again
return True
| 942 | Python | 32.67857 | 110 | 0.599788 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/deformers/OgnDeformerGpu.py | """
Implementation of an OmniGraph node that runs a simple deformer on the GPU
"""
from contextlib import suppress
with suppress(ImportError):
import torch
class OgnDeformerGpu:
@staticmethod
def compute(db) -> bool:
try:
# TODO: This method of GPU compute isn't recommended. Use CPU compute or Warp.
if torch:
input_points = db.inputs.points
multiplier = db.inputs.multiplier
db.outputs.points_size = input_points.shape[0]
# Nothing to evaluate if there are no input points
if db.outputs.points_size == 0:
return True
output_points = db.outputs.points
pt = input_points.copy()
tx = (pt[:, 0] - 310.0) / 310.0
ty = (pt[:, 1] - 310.0) / 310.0
disp = 10.0 * (torch.sin(tx * 10.0) + torch.cos(ty * 15.0))
pt[:, 2] += disp * multiplier
output_points[:] = pt[:]
return True
except NameError:
db.log_warning("Torch not found, no compute")
return False
| 1,153 | Python | 30.189188 | 90 | 0.525585 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnBouncingCubesGpu.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnBouncingCubesGpuDatabase import OgnBouncingCubesGpuDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_examples_python_BouncingCubesGpu", "omni.graph.examples.python.BouncingCubesGpu")
})
database = OgnBouncingCubesGpuDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 1,275 | Python | 48.076921 | 148 | 0.719216 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnAbsDouble.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:num', -8.0, False],
],
'outputs': [
['outputs:out', 8.0, False],
],
},
{
'inputs': [
['inputs:num', 8.0, False],
],
'outputs': [
['outputs:out', 8.0, False],
],
},
{
'inputs': [
['inputs:num', -0.0, False],
],
'outputs': [
['outputs:out', 0.0, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_AbsDouble", "omni.graph.examples.python.AbsDouble", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.AbsDouble User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_AbsDouble","omni.graph.examples.python.AbsDouble", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.AbsDouble User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnAbsDoubleDatabase import OgnAbsDoubleDatabase
test_file_name = "OgnAbsDoubleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_AbsDouble")
database = OgnAbsDoubleDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:num"))
attribute = test_node.get_attribute("inputs:num")
db_value = database.inputs.num
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:out"))
attribute = test_node.get_attribute("outputs:out")
db_value = database.outputs.out
| 3,904 | Python | 43.375 | 192 | 0.618852 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnDynamicSwitch.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnDynamicSwitchDatabase import OgnDynamicSwitchDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_examples_python_DynamicSwitch", "omni.graph.examples.python.DynamicSwitch")
})
database = OgnDynamicSwitchDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:left_value"))
attribute = test_node.get_attribute("inputs:left_value")
db_value = database.inputs.left_value
expected_value = -1
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:right_value"))
attribute = test_node.get_attribute("inputs:right_value")
db_value = database.inputs.right_value
expected_value = 1
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:switch"))
attribute = test_node.get_attribute("inputs:switch")
db_value = database.inputs.switch
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:left_out"))
attribute = test_node.get_attribute("outputs:left_out")
db_value = database.outputs.left_out
self.assertTrue(test_node.get_attribute_exists("outputs:right_out"))
attribute = test_node.get_attribute("outputs:right_out")
db_value = database.outputs.right_out
| 2,527 | Python | 47.615384 | 142 | 0.695291 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnExecSwitch.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnExecSwitchDatabase import OgnExecSwitchDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_examples_python_ExecSwitch", "omni.graph.examples.python.ExecSwitch")
})
database = OgnExecSwitchDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:switch"))
attribute = test_node.get_attribute("inputs:switch")
db_value = database.inputs.switch
expected_value = False
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execLeftOut"))
attribute = test_node.get_attribute("outputs:execLeftOut")
db_value = database.outputs.execLeftOut
self.assertTrue(test_node.get_attribute_exists("outputs:execRightOut"))
attribute = test_node.get_attribute("outputs:execRightOut")
db_value = database.outputs.execRightOut
| 2,107 | Python | 46.90909 | 136 | 0.703844 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnPyUniversalAdd.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnPyUniversalAddDatabase import OgnPyUniversalAddDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_examples_python_UniversalAdd", "omni.graph.examples.python.UniversalAdd")
})
database = OgnPyUniversalAddDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:bool_0"))
attribute = test_node.get_attribute("inputs:bool_0")
db_value = database.inputs.bool_0
expected_value = False
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:bool_1"))
attribute = test_node.get_attribute("inputs:bool_1")
db_value = database.inputs.bool_1
expected_value = False
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:bool_arr_0"))
attribute = test_node.get_attribute("inputs:bool_arr_0")
db_value = database.inputs.bool_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:bool_arr_1"))
attribute = test_node.get_attribute("inputs:bool_arr_1")
db_value = database.inputs.bool_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_0"))
attribute = test_node.get_attribute("inputs:colord3_0")
db_value = database.inputs.colord3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_1"))
attribute = test_node.get_attribute("inputs:colord3_1")
db_value = database.inputs.colord3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_arr_0"))
attribute = test_node.get_attribute("inputs:colord3_arr_0")
db_value = database.inputs.colord3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_arr_1"))
attribute = test_node.get_attribute("inputs:colord3_arr_1")
db_value = database.inputs.colord3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_0"))
attribute = test_node.get_attribute("inputs:colord4_0")
db_value = database.inputs.colord4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_1"))
attribute = test_node.get_attribute("inputs:colord4_1")
db_value = database.inputs.colord4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_arr_0"))
attribute = test_node.get_attribute("inputs:colord4_arr_0")
db_value = database.inputs.colord4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_arr_1"))
attribute = test_node.get_attribute("inputs:colord4_arr_1")
db_value = database.inputs.colord4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_0"))
attribute = test_node.get_attribute("inputs:colorf3_0")
db_value = database.inputs.colorf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_1"))
attribute = test_node.get_attribute("inputs:colorf3_1")
db_value = database.inputs.colorf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_arr_0"))
attribute = test_node.get_attribute("inputs:colorf3_arr_0")
db_value = database.inputs.colorf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_arr_1"))
attribute = test_node.get_attribute("inputs:colorf3_arr_1")
db_value = database.inputs.colorf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_0"))
attribute = test_node.get_attribute("inputs:colorf4_0")
db_value = database.inputs.colorf4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_1"))
attribute = test_node.get_attribute("inputs:colorf4_1")
db_value = database.inputs.colorf4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_arr_0"))
attribute = test_node.get_attribute("inputs:colorf4_arr_0")
db_value = database.inputs.colorf4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_arr_1"))
attribute = test_node.get_attribute("inputs:colorf4_arr_1")
db_value = database.inputs.colorf4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_0"))
attribute = test_node.get_attribute("inputs:colorh3_0")
db_value = database.inputs.colorh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_1"))
attribute = test_node.get_attribute("inputs:colorh3_1")
db_value = database.inputs.colorh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_arr_0"))
attribute = test_node.get_attribute("inputs:colorh3_arr_0")
db_value = database.inputs.colorh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_arr_1"))
attribute = test_node.get_attribute("inputs:colorh3_arr_1")
db_value = database.inputs.colorh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_0"))
attribute = test_node.get_attribute("inputs:colorh4_0")
db_value = database.inputs.colorh4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_1"))
attribute = test_node.get_attribute("inputs:colorh4_1")
db_value = database.inputs.colorh4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_arr_0"))
attribute = test_node.get_attribute("inputs:colorh4_arr_0")
db_value = database.inputs.colorh4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_arr_1"))
attribute = test_node.get_attribute("inputs:colorh4_arr_1")
db_value = database.inputs.colorh4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_0"))
attribute = test_node.get_attribute("inputs:double2_0")
db_value = database.inputs.double2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_1"))
attribute = test_node.get_attribute("inputs:double2_1")
db_value = database.inputs.double2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_arr_0"))
attribute = test_node.get_attribute("inputs:double2_arr_0")
db_value = database.inputs.double2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_arr_1"))
attribute = test_node.get_attribute("inputs:double2_arr_1")
db_value = database.inputs.double2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_0"))
attribute = test_node.get_attribute("inputs:double3_0")
db_value = database.inputs.double3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_1"))
attribute = test_node.get_attribute("inputs:double3_1")
db_value = database.inputs.double3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_arr_0"))
attribute = test_node.get_attribute("inputs:double3_arr_0")
db_value = database.inputs.double3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_arr_1"))
attribute = test_node.get_attribute("inputs:double3_arr_1")
db_value = database.inputs.double3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_0"))
attribute = test_node.get_attribute("inputs:double4_0")
db_value = database.inputs.double4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_1"))
attribute = test_node.get_attribute("inputs:double4_1")
db_value = database.inputs.double4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_arr_0"))
attribute = test_node.get_attribute("inputs:double4_arr_0")
db_value = database.inputs.double4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_arr_1"))
attribute = test_node.get_attribute("inputs:double4_arr_1")
db_value = database.inputs.double4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_0"))
attribute = test_node.get_attribute("inputs:double_0")
db_value = database.inputs.double_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_1"))
attribute = test_node.get_attribute("inputs:double_1")
db_value = database.inputs.double_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_arr_0"))
attribute = test_node.get_attribute("inputs:double_arr_0")
db_value = database.inputs.double_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_arr_1"))
attribute = test_node.get_attribute("inputs:double_arr_1")
db_value = database.inputs.double_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_0"))
attribute = test_node.get_attribute("inputs:float2_0")
db_value = database.inputs.float2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_1"))
attribute = test_node.get_attribute("inputs:float2_1")
db_value = database.inputs.float2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_arr_0"))
attribute = test_node.get_attribute("inputs:float2_arr_0")
db_value = database.inputs.float2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_arr_1"))
attribute = test_node.get_attribute("inputs:float2_arr_1")
db_value = database.inputs.float2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_0"))
attribute = test_node.get_attribute("inputs:float3_0")
db_value = database.inputs.float3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_1"))
attribute = test_node.get_attribute("inputs:float3_1")
db_value = database.inputs.float3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_arr_0"))
attribute = test_node.get_attribute("inputs:float3_arr_0")
db_value = database.inputs.float3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_arr_1"))
attribute = test_node.get_attribute("inputs:float3_arr_1")
db_value = database.inputs.float3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_0"))
attribute = test_node.get_attribute("inputs:float4_0")
db_value = database.inputs.float4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_1"))
attribute = test_node.get_attribute("inputs:float4_1")
db_value = database.inputs.float4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_arr_0"))
attribute = test_node.get_attribute("inputs:float4_arr_0")
db_value = database.inputs.float4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_arr_1"))
attribute = test_node.get_attribute("inputs:float4_arr_1")
db_value = database.inputs.float4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_0"))
attribute = test_node.get_attribute("inputs:float_0")
db_value = database.inputs.float_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_1"))
attribute = test_node.get_attribute("inputs:float_1")
db_value = database.inputs.float_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_arr_0"))
attribute = test_node.get_attribute("inputs:float_arr_0")
db_value = database.inputs.float_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_arr_1"))
attribute = test_node.get_attribute("inputs:float_arr_1")
db_value = database.inputs.float_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_0"))
attribute = test_node.get_attribute("inputs:frame4_0")
db_value = database.inputs.frame4_0
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_1"))
attribute = test_node.get_attribute("inputs:frame4_1")
db_value = database.inputs.frame4_1
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_arr_0"))
attribute = test_node.get_attribute("inputs:frame4_arr_0")
db_value = database.inputs.frame4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_arr_1"))
attribute = test_node.get_attribute("inputs:frame4_arr_1")
db_value = database.inputs.frame4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_0"))
attribute = test_node.get_attribute("inputs:half2_0")
db_value = database.inputs.half2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_1"))
attribute = test_node.get_attribute("inputs:half2_1")
db_value = database.inputs.half2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_arr_0"))
attribute = test_node.get_attribute("inputs:half2_arr_0")
db_value = database.inputs.half2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_arr_1"))
attribute = test_node.get_attribute("inputs:half2_arr_1")
db_value = database.inputs.half2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_0"))
attribute = test_node.get_attribute("inputs:half3_0")
db_value = database.inputs.half3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_1"))
attribute = test_node.get_attribute("inputs:half3_1")
db_value = database.inputs.half3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_arr_0"))
attribute = test_node.get_attribute("inputs:half3_arr_0")
db_value = database.inputs.half3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_arr_1"))
attribute = test_node.get_attribute("inputs:half3_arr_1")
db_value = database.inputs.half3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_0"))
attribute = test_node.get_attribute("inputs:half4_0")
db_value = database.inputs.half4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_1"))
attribute = test_node.get_attribute("inputs:half4_1")
db_value = database.inputs.half4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_arr_0"))
attribute = test_node.get_attribute("inputs:half4_arr_0")
db_value = database.inputs.half4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_arr_1"))
attribute = test_node.get_attribute("inputs:half4_arr_1")
db_value = database.inputs.half4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_0"))
attribute = test_node.get_attribute("inputs:half_0")
db_value = database.inputs.half_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_1"))
attribute = test_node.get_attribute("inputs:half_1")
db_value = database.inputs.half_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_arr_0"))
attribute = test_node.get_attribute("inputs:half_arr_0")
db_value = database.inputs.half_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_arr_1"))
attribute = test_node.get_attribute("inputs:half_arr_1")
db_value = database.inputs.half_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_0"))
attribute = test_node.get_attribute("inputs:int2_0")
db_value = database.inputs.int2_0
expected_value = [0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_1"))
attribute = test_node.get_attribute("inputs:int2_1")
db_value = database.inputs.int2_1
expected_value = [0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_arr_0"))
attribute = test_node.get_attribute("inputs:int2_arr_0")
db_value = database.inputs.int2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_arr_1"))
attribute = test_node.get_attribute("inputs:int2_arr_1")
db_value = database.inputs.int2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_0"))
attribute = test_node.get_attribute("inputs:int3_0")
db_value = database.inputs.int3_0
expected_value = [0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_1"))
attribute = test_node.get_attribute("inputs:int3_1")
db_value = database.inputs.int3_1
expected_value = [0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_arr_0"))
attribute = test_node.get_attribute("inputs:int3_arr_0")
db_value = database.inputs.int3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_arr_1"))
attribute = test_node.get_attribute("inputs:int3_arr_1")
db_value = database.inputs.int3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_0"))
attribute = test_node.get_attribute("inputs:int4_0")
db_value = database.inputs.int4_0
expected_value = [0, 0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_1"))
attribute = test_node.get_attribute("inputs:int4_1")
db_value = database.inputs.int4_1
expected_value = [0, 0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_arr_0"))
attribute = test_node.get_attribute("inputs:int4_arr_0")
db_value = database.inputs.int4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_arr_1"))
attribute = test_node.get_attribute("inputs:int4_arr_1")
db_value = database.inputs.int4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_0"))
attribute = test_node.get_attribute("inputs:int64_0")
db_value = database.inputs.int64_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_1"))
attribute = test_node.get_attribute("inputs:int64_1")
db_value = database.inputs.int64_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_arr_0"))
attribute = test_node.get_attribute("inputs:int64_arr_0")
db_value = database.inputs.int64_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_arr_1"))
attribute = test_node.get_attribute("inputs:int64_arr_1")
db_value = database.inputs.int64_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_0"))
attribute = test_node.get_attribute("inputs:int_0")
db_value = database.inputs.int_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_1"))
attribute = test_node.get_attribute("inputs:int_1")
db_value = database.inputs.int_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_arr_0"))
attribute = test_node.get_attribute("inputs:int_arr_0")
db_value = database.inputs.int_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_arr_1"))
attribute = test_node.get_attribute("inputs:int_arr_1")
db_value = database.inputs.int_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_0"))
attribute = test_node.get_attribute("inputs:matrixd2_0")
db_value = database.inputs.matrixd2_0
expected_value = [[0.0, 0.0], [0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_1"))
attribute = test_node.get_attribute("inputs:matrixd2_1")
db_value = database.inputs.matrixd2_1
expected_value = [[0.0, 0.0], [0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_arr_0"))
attribute = test_node.get_attribute("inputs:matrixd2_arr_0")
db_value = database.inputs.matrixd2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_arr_1"))
attribute = test_node.get_attribute("inputs:matrixd2_arr_1")
db_value = database.inputs.matrixd2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_0"))
attribute = test_node.get_attribute("inputs:matrixd3_0")
db_value = database.inputs.matrixd3_0
expected_value = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_1"))
attribute = test_node.get_attribute("inputs:matrixd3_1")
db_value = database.inputs.matrixd3_1
expected_value = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_arr_0"))
attribute = test_node.get_attribute("inputs:matrixd3_arr_0")
db_value = database.inputs.matrixd3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_arr_1"))
attribute = test_node.get_attribute("inputs:matrixd3_arr_1")
db_value = database.inputs.matrixd3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_0"))
attribute = test_node.get_attribute("inputs:matrixd4_0")
db_value = database.inputs.matrixd4_0
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_1"))
attribute = test_node.get_attribute("inputs:matrixd4_1")
db_value = database.inputs.matrixd4_1
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_arr_0"))
attribute = test_node.get_attribute("inputs:matrixd4_arr_0")
db_value = database.inputs.matrixd4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_arr_1"))
attribute = test_node.get_attribute("inputs:matrixd4_arr_1")
db_value = database.inputs.matrixd4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_0"))
attribute = test_node.get_attribute("inputs:normald3_0")
db_value = database.inputs.normald3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_1"))
attribute = test_node.get_attribute("inputs:normald3_1")
db_value = database.inputs.normald3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_arr_0"))
attribute = test_node.get_attribute("inputs:normald3_arr_0")
db_value = database.inputs.normald3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_arr_1"))
attribute = test_node.get_attribute("inputs:normald3_arr_1")
db_value = database.inputs.normald3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_0"))
attribute = test_node.get_attribute("inputs:normalf3_0")
db_value = database.inputs.normalf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_1"))
attribute = test_node.get_attribute("inputs:normalf3_1")
db_value = database.inputs.normalf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_arr_0"))
attribute = test_node.get_attribute("inputs:normalf3_arr_0")
db_value = database.inputs.normalf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_arr_1"))
attribute = test_node.get_attribute("inputs:normalf3_arr_1")
db_value = database.inputs.normalf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_0"))
attribute = test_node.get_attribute("inputs:normalh3_0")
db_value = database.inputs.normalh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_1"))
attribute = test_node.get_attribute("inputs:normalh3_1")
db_value = database.inputs.normalh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_arr_0"))
attribute = test_node.get_attribute("inputs:normalh3_arr_0")
db_value = database.inputs.normalh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_arr_1"))
attribute = test_node.get_attribute("inputs:normalh3_arr_1")
db_value = database.inputs.normalh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_0"))
attribute = test_node.get_attribute("inputs:pointd3_0")
db_value = database.inputs.pointd3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_1"))
attribute = test_node.get_attribute("inputs:pointd3_1")
db_value = database.inputs.pointd3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_arr_0"))
attribute = test_node.get_attribute("inputs:pointd3_arr_0")
db_value = database.inputs.pointd3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_arr_1"))
attribute = test_node.get_attribute("inputs:pointd3_arr_1")
db_value = database.inputs.pointd3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_0"))
attribute = test_node.get_attribute("inputs:pointf3_0")
db_value = database.inputs.pointf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_1"))
attribute = test_node.get_attribute("inputs:pointf3_1")
db_value = database.inputs.pointf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_arr_0"))
attribute = test_node.get_attribute("inputs:pointf3_arr_0")
db_value = database.inputs.pointf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_arr_1"))
attribute = test_node.get_attribute("inputs:pointf3_arr_1")
db_value = database.inputs.pointf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_0"))
attribute = test_node.get_attribute("inputs:pointh3_0")
db_value = database.inputs.pointh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_1"))
attribute = test_node.get_attribute("inputs:pointh3_1")
db_value = database.inputs.pointh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_arr_0"))
attribute = test_node.get_attribute("inputs:pointh3_arr_0")
db_value = database.inputs.pointh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_arr_1"))
attribute = test_node.get_attribute("inputs:pointh3_arr_1")
db_value = database.inputs.pointh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_0"))
attribute = test_node.get_attribute("inputs:quatd4_0")
db_value = database.inputs.quatd4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_1"))
attribute = test_node.get_attribute("inputs:quatd4_1")
db_value = database.inputs.quatd4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_arr_0"))
attribute = test_node.get_attribute("inputs:quatd4_arr_0")
db_value = database.inputs.quatd4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_arr_1"))
attribute = test_node.get_attribute("inputs:quatd4_arr_1")
db_value = database.inputs.quatd4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_0"))
attribute = test_node.get_attribute("inputs:quatf4_0")
db_value = database.inputs.quatf4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_1"))
attribute = test_node.get_attribute("inputs:quatf4_1")
db_value = database.inputs.quatf4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_arr_0"))
attribute = test_node.get_attribute("inputs:quatf4_arr_0")
db_value = database.inputs.quatf4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_arr_1"))
attribute = test_node.get_attribute("inputs:quatf4_arr_1")
db_value = database.inputs.quatf4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_0"))
attribute = test_node.get_attribute("inputs:quath4_0")
db_value = database.inputs.quath4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_1"))
attribute = test_node.get_attribute("inputs:quath4_1")
db_value = database.inputs.quath4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_arr_0"))
attribute = test_node.get_attribute("inputs:quath4_arr_0")
db_value = database.inputs.quath4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_arr_1"))
attribute = test_node.get_attribute("inputs:quath4_arr_1")
db_value = database.inputs.quath4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_0"))
attribute = test_node.get_attribute("inputs:texcoordd2_0")
db_value = database.inputs.texcoordd2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_1"))
attribute = test_node.get_attribute("inputs:texcoordd2_1")
db_value = database.inputs.texcoordd2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordd2_arr_0")
db_value = database.inputs.texcoordd2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordd2_arr_1")
db_value = database.inputs.texcoordd2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_0"))
attribute = test_node.get_attribute("inputs:texcoordd3_0")
db_value = database.inputs.texcoordd3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_1"))
attribute = test_node.get_attribute("inputs:texcoordd3_1")
db_value = database.inputs.texcoordd3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordd3_arr_0")
db_value = database.inputs.texcoordd3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordd3_arr_1")
db_value = database.inputs.texcoordd3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_0"))
attribute = test_node.get_attribute("inputs:texcoordf2_0")
db_value = database.inputs.texcoordf2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_1"))
attribute = test_node.get_attribute("inputs:texcoordf2_1")
db_value = database.inputs.texcoordf2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordf2_arr_0")
db_value = database.inputs.texcoordf2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordf2_arr_1")
db_value = database.inputs.texcoordf2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_0"))
attribute = test_node.get_attribute("inputs:texcoordf3_0")
db_value = database.inputs.texcoordf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_1"))
attribute = test_node.get_attribute("inputs:texcoordf3_1")
db_value = database.inputs.texcoordf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordf3_arr_0")
db_value = database.inputs.texcoordf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordf3_arr_1")
db_value = database.inputs.texcoordf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_0"))
attribute = test_node.get_attribute("inputs:texcoordh2_0")
db_value = database.inputs.texcoordh2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_1"))
attribute = test_node.get_attribute("inputs:texcoordh2_1")
db_value = database.inputs.texcoordh2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordh2_arr_0")
db_value = database.inputs.texcoordh2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordh2_arr_1")
db_value = database.inputs.texcoordh2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_0"))
attribute = test_node.get_attribute("inputs:texcoordh3_0")
db_value = database.inputs.texcoordh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_1"))
attribute = test_node.get_attribute("inputs:texcoordh3_1")
db_value = database.inputs.texcoordh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordh3_arr_0")
db_value = database.inputs.texcoordh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordh3_arr_1")
db_value = database.inputs.texcoordh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_0"))
attribute = test_node.get_attribute("inputs:timecode_0")
db_value = database.inputs.timecode_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_1"))
attribute = test_node.get_attribute("inputs:timecode_1")
db_value = database.inputs.timecode_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_arr_0"))
attribute = test_node.get_attribute("inputs:timecode_arr_0")
db_value = database.inputs.timecode_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_arr_1"))
attribute = test_node.get_attribute("inputs:timecode_arr_1")
db_value = database.inputs.timecode_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_0"))
attribute = test_node.get_attribute("inputs:token_0")
db_value = database.inputs.token_0
expected_value = "default_token"
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_1"))
attribute = test_node.get_attribute("inputs:token_1")
db_value = database.inputs.token_1
expected_value = "default_token"
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_arr_0"))
attribute = test_node.get_attribute("inputs:token_arr_0")
db_value = database.inputs.token_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_arr_1"))
attribute = test_node.get_attribute("inputs:token_arr_1")
db_value = database.inputs.token_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_0"))
attribute = test_node.get_attribute("inputs:transform4_0")
db_value = database.inputs.transform4_0
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_1"))
attribute = test_node.get_attribute("inputs:transform4_1")
db_value = database.inputs.transform4_1
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_arr_0"))
attribute = test_node.get_attribute("inputs:transform4_arr_0")
db_value = database.inputs.transform4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_arr_1"))
attribute = test_node.get_attribute("inputs:transform4_arr_1")
db_value = database.inputs.transform4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_0"))
attribute = test_node.get_attribute("inputs:uchar_0")
db_value = database.inputs.uchar_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_1"))
attribute = test_node.get_attribute("inputs:uchar_1")
db_value = database.inputs.uchar_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_arr_0"))
attribute = test_node.get_attribute("inputs:uchar_arr_0")
db_value = database.inputs.uchar_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_arr_1"))
attribute = test_node.get_attribute("inputs:uchar_arr_1")
db_value = database.inputs.uchar_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_0"))
attribute = test_node.get_attribute("inputs:uint64_0")
db_value = database.inputs.uint64_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_1"))
attribute = test_node.get_attribute("inputs:uint64_1")
db_value = database.inputs.uint64_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_arr_0"))
attribute = test_node.get_attribute("inputs:uint64_arr_0")
db_value = database.inputs.uint64_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_arr_1"))
attribute = test_node.get_attribute("inputs:uint64_arr_1")
db_value = database.inputs.uint64_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_0"))
attribute = test_node.get_attribute("inputs:uint_0")
db_value = database.inputs.uint_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_1"))
attribute = test_node.get_attribute("inputs:uint_1")
db_value = database.inputs.uint_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_arr_0"))
attribute = test_node.get_attribute("inputs:uint_arr_0")
db_value = database.inputs.uint_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_arr_1"))
attribute = test_node.get_attribute("inputs:uint_arr_1")
db_value = database.inputs.uint_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_0"))
attribute = test_node.get_attribute("inputs:vectord3_0")
db_value = database.inputs.vectord3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_1"))
attribute = test_node.get_attribute("inputs:vectord3_1")
db_value = database.inputs.vectord3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_arr_0"))
attribute = test_node.get_attribute("inputs:vectord3_arr_0")
db_value = database.inputs.vectord3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_arr_1"))
attribute = test_node.get_attribute("inputs:vectord3_arr_1")
db_value = database.inputs.vectord3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_0"))
attribute = test_node.get_attribute("inputs:vectorf3_0")
db_value = database.inputs.vectorf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_1"))
attribute = test_node.get_attribute("inputs:vectorf3_1")
db_value = database.inputs.vectorf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_arr_0"))
attribute = test_node.get_attribute("inputs:vectorf3_arr_0")
db_value = database.inputs.vectorf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_arr_1"))
attribute = test_node.get_attribute("inputs:vectorf3_arr_1")
db_value = database.inputs.vectorf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_0"))
attribute = test_node.get_attribute("inputs:vectorh3_0")
db_value = database.inputs.vectorh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_1"))
attribute = test_node.get_attribute("inputs:vectorh3_1")
db_value = database.inputs.vectorh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_arr_0"))
attribute = test_node.get_attribute("inputs:vectorh3_arr_0")
db_value = database.inputs.vectorh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_arr_1"))
attribute = test_node.get_attribute("inputs:vectorh3_arr_1")
db_value = database.inputs.vectorh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:bool_0"))
attribute = test_node.get_attribute("outputs:bool_0")
db_value = database.outputs.bool_0
self.assertTrue(test_node.get_attribute_exists("outputs:bool_arr_0"))
attribute = test_node.get_attribute("outputs:bool_arr_0")
db_value = database.outputs.bool_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord3_0"))
attribute = test_node.get_attribute("outputs:colord3_0")
db_value = database.outputs.colord3_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord3_arr_0"))
attribute = test_node.get_attribute("outputs:colord3_arr_0")
db_value = database.outputs.colord3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord4_0"))
attribute = test_node.get_attribute("outputs:colord4_0")
db_value = database.outputs.colord4_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord4_arr_0"))
attribute = test_node.get_attribute("outputs:colord4_arr_0")
db_value = database.outputs.colord4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf3_0"))
attribute = test_node.get_attribute("outputs:colorf3_0")
db_value = database.outputs.colorf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf3_arr_0"))
attribute = test_node.get_attribute("outputs:colorf3_arr_0")
db_value = database.outputs.colorf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf4_0"))
attribute = test_node.get_attribute("outputs:colorf4_0")
db_value = database.outputs.colorf4_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf4_arr_0"))
attribute = test_node.get_attribute("outputs:colorf4_arr_0")
db_value = database.outputs.colorf4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh3_0"))
attribute = test_node.get_attribute("outputs:colorh3_0")
db_value = database.outputs.colorh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh3_arr_0"))
attribute = test_node.get_attribute("outputs:colorh3_arr_0")
db_value = database.outputs.colorh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh4_0"))
attribute = test_node.get_attribute("outputs:colorh4_0")
db_value = database.outputs.colorh4_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh4_arr_0"))
attribute = test_node.get_attribute("outputs:colorh4_arr_0")
db_value = database.outputs.colorh4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double2_0"))
attribute = test_node.get_attribute("outputs:double2_0")
db_value = database.outputs.double2_0
self.assertTrue(test_node.get_attribute_exists("outputs:double2_arr_0"))
attribute = test_node.get_attribute("outputs:double2_arr_0")
db_value = database.outputs.double2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double3_0"))
attribute = test_node.get_attribute("outputs:double3_0")
db_value = database.outputs.double3_0
self.assertTrue(test_node.get_attribute_exists("outputs:double3_arr_0"))
attribute = test_node.get_attribute("outputs:double3_arr_0")
db_value = database.outputs.double3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double4_0"))
attribute = test_node.get_attribute("outputs:double4_0")
db_value = database.outputs.double4_0
self.assertTrue(test_node.get_attribute_exists("outputs:double4_arr_0"))
attribute = test_node.get_attribute("outputs:double4_arr_0")
db_value = database.outputs.double4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double_0"))
attribute = test_node.get_attribute("outputs:double_0")
db_value = database.outputs.double_0
self.assertTrue(test_node.get_attribute_exists("outputs:double_arr_0"))
attribute = test_node.get_attribute("outputs:double_arr_0")
db_value = database.outputs.double_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float2_0"))
attribute = test_node.get_attribute("outputs:float2_0")
db_value = database.outputs.float2_0
self.assertTrue(test_node.get_attribute_exists("outputs:float2_arr_0"))
attribute = test_node.get_attribute("outputs:float2_arr_0")
db_value = database.outputs.float2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float3_0"))
attribute = test_node.get_attribute("outputs:float3_0")
db_value = database.outputs.float3_0
self.assertTrue(test_node.get_attribute_exists("outputs:float3_arr_0"))
attribute = test_node.get_attribute("outputs:float3_arr_0")
db_value = database.outputs.float3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float4_0"))
attribute = test_node.get_attribute("outputs:float4_0")
db_value = database.outputs.float4_0
self.assertTrue(test_node.get_attribute_exists("outputs:float4_arr_0"))
attribute = test_node.get_attribute("outputs:float4_arr_0")
db_value = database.outputs.float4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float_0"))
attribute = test_node.get_attribute("outputs:float_0")
db_value = database.outputs.float_0
self.assertTrue(test_node.get_attribute_exists("outputs:float_arr_0"))
attribute = test_node.get_attribute("outputs:float_arr_0")
db_value = database.outputs.float_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:frame4_0"))
attribute = test_node.get_attribute("outputs:frame4_0")
db_value = database.outputs.frame4_0
self.assertTrue(test_node.get_attribute_exists("outputs:frame4_arr_0"))
attribute = test_node.get_attribute("outputs:frame4_arr_0")
db_value = database.outputs.frame4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half2_0"))
attribute = test_node.get_attribute("outputs:half2_0")
db_value = database.outputs.half2_0
self.assertTrue(test_node.get_attribute_exists("outputs:half2_arr_0"))
attribute = test_node.get_attribute("outputs:half2_arr_0")
db_value = database.outputs.half2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half3_0"))
attribute = test_node.get_attribute("outputs:half3_0")
db_value = database.outputs.half3_0
self.assertTrue(test_node.get_attribute_exists("outputs:half3_arr_0"))
attribute = test_node.get_attribute("outputs:half3_arr_0")
db_value = database.outputs.half3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half4_0"))
attribute = test_node.get_attribute("outputs:half4_0")
db_value = database.outputs.half4_0
self.assertTrue(test_node.get_attribute_exists("outputs:half4_arr_0"))
attribute = test_node.get_attribute("outputs:half4_arr_0")
db_value = database.outputs.half4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half_0"))
attribute = test_node.get_attribute("outputs:half_0")
db_value = database.outputs.half_0
self.assertTrue(test_node.get_attribute_exists("outputs:half_arr_0"))
attribute = test_node.get_attribute("outputs:half_arr_0")
db_value = database.outputs.half_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int2_0"))
attribute = test_node.get_attribute("outputs:int2_0")
db_value = database.outputs.int2_0
self.assertTrue(test_node.get_attribute_exists("outputs:int2_arr_0"))
attribute = test_node.get_attribute("outputs:int2_arr_0")
db_value = database.outputs.int2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int3_0"))
attribute = test_node.get_attribute("outputs:int3_0")
db_value = database.outputs.int3_0
self.assertTrue(test_node.get_attribute_exists("outputs:int3_arr_0"))
attribute = test_node.get_attribute("outputs:int3_arr_0")
db_value = database.outputs.int3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int4_0"))
attribute = test_node.get_attribute("outputs:int4_0")
db_value = database.outputs.int4_0
self.assertTrue(test_node.get_attribute_exists("outputs:int4_arr_0"))
attribute = test_node.get_attribute("outputs:int4_arr_0")
db_value = database.outputs.int4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int64_0"))
attribute = test_node.get_attribute("outputs:int64_0")
db_value = database.outputs.int64_0
self.assertTrue(test_node.get_attribute_exists("outputs:int64_arr_0"))
attribute = test_node.get_attribute("outputs:int64_arr_0")
db_value = database.outputs.int64_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int_0"))
attribute = test_node.get_attribute("outputs:int_0")
db_value = database.outputs.int_0
self.assertTrue(test_node.get_attribute_exists("outputs:int_arr_0"))
attribute = test_node.get_attribute("outputs:int_arr_0")
db_value = database.outputs.int_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd2_0"))
attribute = test_node.get_attribute("outputs:matrixd2_0")
db_value = database.outputs.matrixd2_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd2_arr_0"))
attribute = test_node.get_attribute("outputs:matrixd2_arr_0")
db_value = database.outputs.matrixd2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd3_0"))
attribute = test_node.get_attribute("outputs:matrixd3_0")
db_value = database.outputs.matrixd3_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd3_arr_0"))
attribute = test_node.get_attribute("outputs:matrixd3_arr_0")
db_value = database.outputs.matrixd3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd4_0"))
attribute = test_node.get_attribute("outputs:matrixd4_0")
db_value = database.outputs.matrixd4_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd4_arr_0"))
attribute = test_node.get_attribute("outputs:matrixd4_arr_0")
db_value = database.outputs.matrixd4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:normald3_0"))
attribute = test_node.get_attribute("outputs:normald3_0")
db_value = database.outputs.normald3_0
self.assertTrue(test_node.get_attribute_exists("outputs:normald3_arr_0"))
attribute = test_node.get_attribute("outputs:normald3_arr_0")
db_value = database.outputs.normald3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalf3_0"))
attribute = test_node.get_attribute("outputs:normalf3_0")
db_value = database.outputs.normalf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalf3_arr_0"))
attribute = test_node.get_attribute("outputs:normalf3_arr_0")
db_value = database.outputs.normalf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalh3_0"))
attribute = test_node.get_attribute("outputs:normalh3_0")
db_value = database.outputs.normalh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalh3_arr_0"))
attribute = test_node.get_attribute("outputs:normalh3_arr_0")
db_value = database.outputs.normalh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointd3_0"))
attribute = test_node.get_attribute("outputs:pointd3_0")
db_value = database.outputs.pointd3_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointd3_arr_0"))
attribute = test_node.get_attribute("outputs:pointd3_arr_0")
db_value = database.outputs.pointd3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointf3_0"))
attribute = test_node.get_attribute("outputs:pointf3_0")
db_value = database.outputs.pointf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointf3_arr_0"))
attribute = test_node.get_attribute("outputs:pointf3_arr_0")
db_value = database.outputs.pointf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointh3_0"))
attribute = test_node.get_attribute("outputs:pointh3_0")
db_value = database.outputs.pointh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointh3_arr_0"))
attribute = test_node.get_attribute("outputs:pointh3_arr_0")
db_value = database.outputs.pointh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatd4_0"))
attribute = test_node.get_attribute("outputs:quatd4_0")
db_value = database.outputs.quatd4_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatd4_arr_0"))
attribute = test_node.get_attribute("outputs:quatd4_arr_0")
db_value = database.outputs.quatd4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatf4_0"))
attribute = test_node.get_attribute("outputs:quatf4_0")
db_value = database.outputs.quatf4_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatf4_arr_0"))
attribute = test_node.get_attribute("outputs:quatf4_arr_0")
db_value = database.outputs.quatf4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:quath4_0"))
attribute = test_node.get_attribute("outputs:quath4_0")
db_value = database.outputs.quath4_0
self.assertTrue(test_node.get_attribute_exists("outputs:quath4_arr_0"))
attribute = test_node.get_attribute("outputs:quath4_arr_0")
db_value = database.outputs.quath4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd2_0"))
attribute = test_node.get_attribute("outputs:texcoordd2_0")
db_value = database.outputs.texcoordd2_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd2_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordd2_arr_0")
db_value = database.outputs.texcoordd2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd3_0"))
attribute = test_node.get_attribute("outputs:texcoordd3_0")
db_value = database.outputs.texcoordd3_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd3_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordd3_arr_0")
db_value = database.outputs.texcoordd3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf2_0"))
attribute = test_node.get_attribute("outputs:texcoordf2_0")
db_value = database.outputs.texcoordf2_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf2_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordf2_arr_0")
db_value = database.outputs.texcoordf2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf3_0"))
attribute = test_node.get_attribute("outputs:texcoordf3_0")
db_value = database.outputs.texcoordf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf3_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordf3_arr_0")
db_value = database.outputs.texcoordf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh2_0"))
attribute = test_node.get_attribute("outputs:texcoordh2_0")
db_value = database.outputs.texcoordh2_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh2_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordh2_arr_0")
db_value = database.outputs.texcoordh2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh3_0"))
attribute = test_node.get_attribute("outputs:texcoordh3_0")
db_value = database.outputs.texcoordh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh3_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordh3_arr_0")
db_value = database.outputs.texcoordh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:timecode_0"))
attribute = test_node.get_attribute("outputs:timecode_0")
db_value = database.outputs.timecode_0
self.assertTrue(test_node.get_attribute_exists("outputs:timecode_arr_0"))
attribute = test_node.get_attribute("outputs:timecode_arr_0")
db_value = database.outputs.timecode_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:token_0"))
attribute = test_node.get_attribute("outputs:token_0")
db_value = database.outputs.token_0
self.assertTrue(test_node.get_attribute_exists("outputs:token_arr_0"))
attribute = test_node.get_attribute("outputs:token_arr_0")
db_value = database.outputs.token_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:transform4_0"))
attribute = test_node.get_attribute("outputs:transform4_0")
db_value = database.outputs.transform4_0
self.assertTrue(test_node.get_attribute_exists("outputs:transform4_arr_0"))
attribute = test_node.get_attribute("outputs:transform4_arr_0")
db_value = database.outputs.transform4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:uchar_0"))
attribute = test_node.get_attribute("outputs:uchar_0")
db_value = database.outputs.uchar_0
self.assertTrue(test_node.get_attribute_exists("outputs:uchar_arr_0"))
attribute = test_node.get_attribute("outputs:uchar_arr_0")
db_value = database.outputs.uchar_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint64_0"))
attribute = test_node.get_attribute("outputs:uint64_0")
db_value = database.outputs.uint64_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint64_arr_0"))
attribute = test_node.get_attribute("outputs:uint64_arr_0")
db_value = database.outputs.uint64_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint_0"))
attribute = test_node.get_attribute("outputs:uint_0")
db_value = database.outputs.uint_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint_arr_0"))
attribute = test_node.get_attribute("outputs:uint_arr_0")
db_value = database.outputs.uint_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectord3_0"))
attribute = test_node.get_attribute("outputs:vectord3_0")
db_value = database.outputs.vectord3_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectord3_arr_0"))
attribute = test_node.get_attribute("outputs:vectord3_arr_0")
db_value = database.outputs.vectord3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorf3_0"))
attribute = test_node.get_attribute("outputs:vectorf3_0")
db_value = database.outputs.vectorf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorf3_arr_0"))
attribute = test_node.get_attribute("outputs:vectorf3_arr_0")
db_value = database.outputs.vectorf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorh3_0"))
attribute = test_node.get_attribute("outputs:vectorh3_0")
db_value = database.outputs.vectorh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorh3_arr_0"))
attribute = test_node.get_attribute("outputs:vectorh3_arr_0")
db_value = database.outputs.vectorh3_arr_0
| 86,139 | Python | 49.970414 | 140 | 0.666191 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnComposeDouble3.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:x', 1.0, False],
['inputs:y', 2.0, False],
['inputs:z', 3.0, False],
],
'outputs': [
['outputs:double3', [1.0, 2.0, 3.0], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_ComposeDouble3", "omni.graph.examples.python.ComposeDouble3", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.ComposeDouble3 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_ComposeDouble3","omni.graph.examples.python.ComposeDouble3", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.ComposeDouble3 User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnComposeDouble3Database import OgnComposeDouble3Database
test_file_name = "OgnComposeDouble3Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_ComposeDouble3")
database = OgnComposeDouble3Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:x"))
attribute = test_node.get_attribute("inputs:x")
db_value = database.inputs.x
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:y"))
attribute = test_node.get_attribute("inputs:y")
db_value = database.inputs.y
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:z"))
attribute = test_node.get_attribute("inputs:z")
db_value = database.inputs.z
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:double3"))
attribute = test_node.get_attribute("outputs:double3")
db_value = database.outputs.double3
| 4,507 | Python | 49.088888 | 202 | 0.658753 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnDeformerCpu.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:points', [[1.0, 2.0, 3.0]], False],
['inputs:multiplier', 2.0, False],
],
'outputs': [
['outputs:points', [[1.0, 2.0, -0.53249073]], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_DeformerPy", "omni.graph.examples.python.DeformerPy", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.DeformerPy User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_DeformerPy","omni.graph.examples.python.DeformerPy", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.DeformerPy User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnDeformerCpuDatabase import OgnDeformerCpuDatabase
test_file_name = "OgnDeformerCpuTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_DeformerPy")
database = OgnDeformerCpuDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:multiplier"))
attribute = test_node.get_attribute("inputs:multiplier")
db_value = database.inputs.multiplier
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:points"))
attribute = test_node.get_attribute("inputs:points")
db_value = database.inputs.points
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:points"))
attribute = test_node.get_attribute("outputs:points")
db_value = database.outputs.points
| 4,092 | Python | 49.530864 | 194 | 0.660557 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnSubtractDouble.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', 2.0, False],
['inputs:b', 3.0, False],
],
'outputs': [
['outputs:out', -1.0, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_SubtractDouble", "omni.graph.examples.python.SubtractDouble", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.SubtractDouble User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_SubtractDouble","omni.graph.examples.python.SubtractDouble", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.SubtractDouble User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnSubtractDoubleDatabase import OgnSubtractDoubleDatabase
test_file_name = "OgnSubtractDoubleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_SubtractDouble")
database = OgnSubtractDoubleDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:a"))
attribute = test_node.get_attribute("inputs:a")
db_value = database.inputs.a
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:b"))
attribute = test_node.get_attribute("inputs:b")
db_value = database.inputs.b
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:out"))
attribute = test_node.get_attribute("outputs:out")
db_value = database.outputs.out
| 4,026 | Python | 48.716049 | 202 | 0.660705 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnIntCounter.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnIntCounterDatabase import OgnIntCounterDatabase
test_file_name = "OgnIntCounterTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_IntCounter")
database = OgnIntCounterDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:increment"))
attribute = test_node.get_attribute("inputs:increment")
db_value = database.inputs.increment
expected_value = 1
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:reset"))
attribute = test_node.get_attribute("inputs:reset")
db_value = database.inputs.reset
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:count"))
attribute = test_node.get_attribute("outputs:count")
db_value = database.outputs.count
| 2,553 | Python | 49.07843 | 99 | 0.696436 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnMultDouble.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', 2.0, False],
['inputs:b', 3.0, False],
],
'outputs': [
['outputs:out', 6.0, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_MultDouble", "omni.graph.examples.python.MultDouble", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.MultDouble User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_MultDouble","omni.graph.examples.python.MultDouble", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.MultDouble User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnMultDoubleDatabase import OgnMultDoubleDatabase
test_file_name = "OgnMultDoubleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_MultDouble")
database = OgnMultDoubleDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:a"))
attribute = test_node.get_attribute("inputs:a")
db_value = database.inputs.a
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:b"))
attribute = test_node.get_attribute("inputs:b")
db_value = database.inputs.b
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:out"))
attribute = test_node.get_attribute("outputs:out")
db_value = database.outputs.out
| 3,981 | Python | 48.160493 | 194 | 0.657121 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/__init__.py | """====== GENERATED BY omni.graph.tools - DO NOT EDIT ======"""
import omni.graph.tools._internal as ogi
ogi.import_tests_in_directory(__file__, __name__)
| 155 | Python | 37.999991 | 63 | 0.645161 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnDeformerYAxis.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:points', [[1.0, 2.0, 3.0]], False],
['inputs:multiplier', 2.0, False],
],
'outputs': [
['outputs:points', [[1.0, 3.6829419136047363, 3.0]], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_DeformerYAxis", "omni.graph.examples.python.DeformerYAxis", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.DeformerYAxis User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_examples_python_DeformerYAxis","omni.graph.examples.python.DeformerYAxis", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.examples.python.DeformerYAxis User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnDeformerYAxisDatabase import OgnDeformerYAxisDatabase
test_file_name = "OgnDeformerYAxisTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_DeformerYAxis")
database = OgnDeformerYAxisDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:multiplier"))
attribute = test_node.get_attribute("inputs:multiplier")
db_value = database.inputs.multiplier
expected_value = 1
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:offset"))
attribute = test_node.get_attribute("inputs:offset")
db_value = database.inputs.offset
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:points"))
attribute = test_node.get_attribute("inputs:points")
db_value = database.inputs.points
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:wavelength"))
attribute = test_node.get_attribute("inputs:wavelength")
db_value = database.inputs.wavelength
expected_value = 1
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:points"))
attribute = test_node.get_attribute("outputs:points")
db_value = database.outputs.points
| 4,992 | Python | 50.474226 | 200 | 0.667268 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnTestInitNode.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnTestInitNodeDatabase import OgnTestInitNodeDatabase
test_file_name = "OgnTestInitNodeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_examples_python_TestInitNode")
database = OgnTestInitNodeDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
| 1,699 | Python | 47.571427 | 101 | 0.705121 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.