# Path: pyoptix/context.py
# def current_context():
#     return _context_stack[-1]
# 
# Path: pyoptix/mixins/graphnode.py
# class GraphNodeMixin(object):
#     def __init__(self):
#         self._parents = []
# 
#     def _add_parent(self, parent):
#         self._parents.append(parent)
# 
#     def _remove_parent(self, parent):
#         self._parents.remove(parent)
# 
# Path: pyoptix/mixins/scoped.py
# class ScopedObject(DestroyableObject):
#     def __init__(self, native):
#         DestroyableObject.__init__(self, native)
#         self._variables = {}
# 
#     def __setitem__(self, key, value):
#         from pyoptix.variable import Variable
# 
#         variable_wrapper = self._safe_native.query_variable(key)
#         declared = False
# 
#         if variable_wrapper is None:
#             variable_wrapper = self._safe_native.declare_variable(key)
#             declared = True
# 
#         try:
#             optix_variable = Variable(variable_wrapper)
#             optix_variable.value = value
#             self._variables[key] = optix_variable
#         except Exception as e:
#             if declared:
#                 self._safe_native.remove_variable(variable_wrapper)
#             raise e
# 
#     def __getitem__(self, key):
#         return self._variables[key].value
# 
#     def __len__(self):
#         return len(self._variables)
# 
#     def __delitem__(self, key):
#         wrapped_variable = self._safe_native.query_variable(key)
#         if not wrapped_variable.is_valid():
#             raise ValueError("Variable not found")
# 
#         self._safe_native.remove_variable(wrapped_variable)
#         del self._variables[key]
# 
#     def __contains__(self, item):
#         return item in self._variables
# 
# Path: pyoptix/mixins/hascontext.py
# class HasContextMixin(object):
#     def __init__(self, context):
#         self._context_ref = weakref.ref(context)
# 
#     @property
#     def _safe_context(self):
#         ctx = self._context_ref()
#         if ctx is not None:
#             return ctx
#         else:
#             raise RuntimeError('Context of this object is no longer valid')


from pyoptix.context import current_context
from pyoptix.mixins.graphnode import GraphNodeMixin
from pyoptix.mixins.scoped import ScopedObject
from pyoptix.mixins.hascontext import HasContextMixin


class Geometry(GraphNodeMixin, ScopedObject, HasContextMixin):
    def __init__(self, bounding_box_program, intersection_program):
        HasContextMixin.__init__(self, current_context())
        ScopedObject.__init__(self, self._safe_context._create_geometry())

# Path: pyoptix/context.py
# def current_context():
#     return _context_stack[-1]
# 
# Path: pyoptix/mixins/graphnode.py
# class GraphNodeMixin(object):
#     def __init__(self):
#         self._parents = []
# 
#     def _add_parent(self, parent):
#         self._parents.append(parent)
# 
#     def _remove_parent(self, parent):
#         self._parents.remove(parent)
# 
# Path: pyoptix/mixins/scoped.py
# class ScopedObject(DestroyableObject):
#     def __init__(self, native):
#         DestroyableObject.__init__(self, native)
#         self._variables = {}
# 
#     def __setitem__(self, key, value):
#         from pyoptix.variable import Variable
# 
#         variable_wrapper = self._safe_native.query_variable(key)
#         declared = False
# 
#         if variable_wrapper is None:
#             variable_wrapper = self._safe_native.declare_variable(key)
#             declared = True
# 
#         try:
#             optix_variable = Variable(variable_wrapper)
#             optix_variable.value = value
#             self._variables[key] = optix_variable
#         except Exception as e:
#             if declared:
#                 self._safe_native.remove_variable(variable_wrapper)
#             raise e
# 
#     def __getitem__(self, key):
#         return self._variables[key].value
# 
#     def __len__(self):
#         return len(self._variables)
# 
#     def __delitem__(self, key):
#         wrapped_variable = self._safe_native.query_variable(key)
#         if not wrapped_variable.is_valid():
#             raise ValueError("Variable not found")
# 
#         self._safe_native.remove_variable(wrapped_variable)
#         del self._variables[key]
# 
#     def __contains__(self, item):
#         return item in self._variables
# 
# Path: pyoptix/mixins/hascontext.py
# class HasContextMixin(object):
#     def __init__(self, context):
#         self._context_ref = weakref.ref(context)
# 
#     @property
#     def _safe_context(self):
#         ctx = self._context_ref()
#         if ctx is not None:
#             return ctx
#         else:
#             raise RuntimeError('Context of this object is no longer valid')


# Path: pyoptix/geometry.py
from pyoptix.context import current_context
from pyoptix.mixins.graphnode import GraphNodeMixin
from pyoptix.mixins.scoped import ScopedObject
from pyoptix.mixins.hascontext import HasContextMixin



class Geometry(GraphNodeMixin, ScopedObject, HasContextMixin):
    def __init__(self, bounding_box_program, intersection_program):
        HasContextMixin.__init__(self, current_context())
        ScopedObject.__init__(self, self._safe_context._create_geometry())

        GraphNodeMixin.__init__(self)