File indexing completed on 2026-04-09 07:49:02
0001
0002
0003
0004
0005
0006
0007 #include <nanobind/nanobind.h>
0008 #include <nanobind/stl/string.h>
0009 #include <nanobind/ndarray.h>
0010 #include "NP_nanobind.h"
0011
0012 #include "ssys.h"
0013 #include "OPTICKS_LOG.hh"
0014 #include "CSGOptiXService.h"
0015
0016 namespace nb = nanobind;
0017
0018
0019 struct _CSGOptiXService
0020 {
0021 int level ;
0022 CSGOptiXService svc ;
0023
0024 _CSGOptiXService();
0025 virtual ~_CSGOptiXService();
0026
0027 nb::ndarray<nb::numpy> simulate( nb::ndarray<nb::numpy> _gs, int eventID ) ;
0028 nb::tuple simulate_with_meta( nb::ndarray<nb::numpy> _gs, nb::str _gs_meta, int eventID ) ;
0029
0030 std::string desc() const ;
0031 };
0032
0033 inline _CSGOptiXService::_CSGOptiXService()
0034 :
0035 level(ssys::getenvint("_CSGOptiXService_level",0)),
0036 svc()
0037 {
0038 OPTICKS_ELOG("_CSGOptiXService");
0039 if(level > 0) std::cout << "-_CSGOptiXService::_CSGOptiXService level[" << level << "]\n" ;
0040 }
0041
0042 inline _CSGOptiXService::~_CSGOptiXService()
0043 {
0044 if(level > 0) std::cout << "-_CSGOptiXService::~_CSGOptiXService\n" ;
0045 }
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 inline nb::ndarray<nb::numpy> _CSGOptiXService::simulate( nb::ndarray<nb::numpy> _gs, int eventID )
0062 {
0063 if(level > 0) std::cout << "[_CSGOptiXService::simulate eventID " << eventID << "\n" ;
0064 NP* gs = NP_nanobind::NP_copy_of_numpy_array(_gs);
0065
0066 NP* ht = svc.simulate(gs, eventID );
0067
0068 nb::ndarray<nb::numpy> _ht = NP_nanobind::numpy_array_view_of_NP(ht);
0069
0070 if(level > 0) std::cout << "]_CSGOptiXService::simulate eventID " << eventID << "\n" ;
0071 return _ht ;
0072 }
0073
0074 inline nb::tuple _CSGOptiXService::simulate_with_meta( nb::ndarray<nb::numpy> _gs, nb::str _gs_meta, int eventID )
0075 {
0076 if(level > 0) std::cout << "[_CSGOptiXService::simulate_with_meta eventID " << eventID << "\n" ;
0077 NP* gs = NP_nanobind::NP_copy_of_numpy_array_with_meta(_gs, _gs_meta);
0078
0079 if(level > 0) std::cout << "-_CSGOptiXService::simulate_with_meta gs.meta[" << gs->meta << "]\n" ;
0080
0081 NP* ht = svc.simulate(gs, eventID );
0082
0083 nb::tuple _ht = NP_nanobind::numpy_array_view_of_NP_with_meta(ht);
0084
0085 if(level > 0) std::cout << "]_CSGOptiXService::simulate_with_meta eventID " << eventID << "\n" ;
0086 return _ht ;
0087 }
0088
0089
0090 inline std::string _CSGOptiXService::desc() const
0091 {
0092 return svc.desc();
0093 }
0094
0095
0096
0097 NB_MODULE(opticks_CSGOptiX, m)
0098 {
0099 m.doc() = "nanobind _CSGOptiXService ";
0100
0101 nb::class_<_CSGOptiXService>(m, "_CSGOptiXService")
0102 .def(nb::init<>())
0103 .def("__repr__", &_CSGOptiXService::desc)
0104 .def("simulate", &_CSGOptiXService::simulate )
0105 .def("simulate_with_meta", &_CSGOptiXService::simulate_with_meta )
0106 ;
0107 }
0108
0109