Skip to content

Commit 885f66a

Browse files
authored
Added has_geometry method and fixing conda-package issues (#39)
* fixed issues with cmake and numba in conda package and successfully built on linux * small updates to windows version
1 parent 4927e45 commit 885f66a

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

conda-recipe/meta.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% set name = "rtxpy" %}
2-
{% set version = "0.0.4" %}
2+
{% set version = "0.0.5" %}
33

44
package:
55
name: {{ name|lower }}
@@ -20,8 +20,8 @@ requirements:
2020
build:
2121
- {{ compiler('c') }}
2222
- {{ compiler('cxx') }}
23-
- cmake
24-
- git
23+
- conda-forge::cmake
24+
- conda-forge::git
2525
- cuda-nvcc
2626
- cuda-cudart-dev
2727
- cuda-nvrtc-dev
@@ -39,6 +39,7 @@ requirements:
3939
- python >=3.10
4040
- numpy >=1.21,<3 # [py<313]
4141
- numpy >=2.0,<3 # [py>=313]
42+
- numba >=0.56
4243
- cupy >=12.0
4344
- cuda-version >=12
4445
- __cuda # [linux]

rtxpy/rtx.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,18 @@ def get_geometry_count(self) -> int:
11421142
"""
11431143
return len(_state.gas_entries)
11441144

1145+
def has_geometry(self, geometry_id: str) -> bool:
1146+
"""
1147+
Check if a geometry with the given ID exists.
1148+
1149+
Args:
1150+
geometry_id: The ID of the geometry to check.
1151+
1152+
Returns:
1153+
True if the geometry exists, False otherwise.
1154+
"""
1155+
return geometry_id in _state.gas_entries
1156+
11451157
def clear_scene(self) -> None:
11461158
"""
11471159
Remove all geometries and reset to single-GAS mode.

rtxpy/tests/test_simple.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,36 @@ def test_cupy_buffers_multi_gas(test_cupy):
929929
np.testing.assert_almost_equal(hits_np[0], 10.0, decimal=1)
930930

931931

932+
@pytest.mark.parametrize("test_cupy", [False, True])
933+
def test_has_geometry(test_cupy):
934+
"""Test has_geometry() query method."""
935+
if test_cupy:
936+
if not has_cupy:
937+
pytest.skip("cupy not available")
938+
import cupy
939+
backend = cupy
940+
else:
941+
backend = np
942+
943+
rtx = RTX()
944+
rtx.clear_scene()
945+
946+
# Should not exist initially
947+
assert rtx.has_geometry("test_geo") == False
948+
949+
# Add geometry
950+
verts = backend.float32([0, 0, 0, 1, 0, 0, 0.5, 1, 0])
951+
tris = backend.int32([0, 1, 2])
952+
rtx.add_geometry("test_geo", verts, tris)
953+
954+
# Should exist now
955+
assert rtx.has_geometry("test_geo") == True
956+
957+
# Remove and check again
958+
rtx.remove_geometry("test_geo")
959+
assert rtx.has_geometry("test_geo") == False
960+
961+
932962
# =============================================================================
933963
# Primitive ID and Instance ID Tests
934964
# =============================================================================
@@ -946,7 +976,6 @@ def test_primitive_ids_single_gas(test_cupy):
946976

947977
rtx = RTX()
948978
rtx.clear_scene()
949-
950979
# Create a mesh with 2 triangles (a quad)
951980
# Triangle 0: vertices 0,1,2 (bottom-left triangle)
952981
# Triangle 1: vertices 2,1,3 (top-right triangle)

0 commit comments

Comments
 (0)