Helios++
Helios software for LiDAR simulations
PyHeliosUtils.h
1 #pragma once
2 #ifdef PYTHON_BINDING
3 
4 #include <boost/python/errors.hpp>
5 
6 namespace pyhelios{
7 
9 public:
16  static size_t handlePythonIndex(long _index, size_t n){
17  size_t index = (size_t) _index;
18  if(_index < 0){
19  index = (size_t) (n + _index);
20  }
21  if(index >= n){
22  std::stringstream ss;
23  ss << "Index " << _index << " out of range";
24  PyErr_SetString(PyExc_IndexError, ss.str().c_str());
25  boost::python::throw_error_already_set();
26  }
27  return index;
28  }
29 };
30 
31 }
32 
33 #endif
Definition: PyHeliosUtils.h:8
static size_t handlePythonIndex(long _index, size_t n)
Translate received index from python, where negative values have a special meaning (i....
Definition: PyHeliosUtils.h:16