diff options
author | Stan Seibert <stan@mtrr.org> | 2012-01-20 13:37:33 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:38 -0700 |
commit | b2bb0a2604d28b0ea25b2f3b3331062a3d6dcabe (patch) | |
tree | 57559bdcf0b566806ae945f5c8c9e89c95ca5730 | |
parent | 0b720e26a7fba043168f2c843c8db73d4e642ed3 (diff) | |
download | chroma-b2bb0a2604d28b0ea25b2f3b3331062a3d6dcabe.tar.gz chroma-b2bb0a2604d28b0ea25b2f3b3331062a3d6dcabe.tar.bz2 chroma-b2bb0a2604d28b0ea25b2f3b3331062a3d6dcabe.zip |
Make load from string method handle functions that return Mesh, Solid, or Geometry.
-rw-r--r-- | chroma/loader.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/chroma/loader.py b/chroma/loader.py index 39842e1..4923f99 100644 --- a/chroma/loader.py +++ b/chroma/loader.py @@ -5,7 +5,7 @@ import time from chroma.log import logger from chroma.cache import Cache from chroma.bvh import make_simple_bvh -from chroma.geometry import Geometry, Solid, Mesh +from chroma.geometry import Geometry, Solid, Mesh, vacuum from chroma.detector import Detector from chroma.stl import mesh_from_stl from chroma.gpu import create_cuda_context @@ -91,19 +91,25 @@ def load_geometry_from_string(geometry_str, # Load from function function_path = geometry_id[1:] - module_name, function_name = function_path.rsplit('.', 1) + module_name, obj_name = function_path.rsplit('.', 1) orig_sys_path = list(sys.path) try: sys.path.append('.') - module = __import__(module_name, fromlist=[function_name]) + module = __import__(module_name, fromlist=[obj_name]) sys.path = orig_sys_path except ImportError: sys.path = orig_sys_path raise - function = getattr(module, function_name) - geometry = function() - geometry.flatten() + obj = getattr(module, obj_name) + + geometry = create_geometry_from_obj(obj, bvh_name=bvh_name, + auto_build_bvh=auto_build_bvh, + read_bvh_cache=read_bvh_cache, + update_bvh_cache=update_bvh_cache, + cache_dir=cache_dir, + cuda_device=cuda_device) + return geometry # RETURN EARLY HERE! ALREADY GOT BVH else: # Load from cache @@ -113,7 +119,6 @@ def load_geometry_from_string(geometry_str, geometry = cache.load_geometry(geometry_id) # Cached geometries are flattened already - geometry.bvh = load_bvh(geometry, auto_build_bvh=auto_build_bvh, read_bvh_cache=read_bvh_cache, update_bvh_cache=update_bvh_cache, |