I have a .py file, that holds a 3d lists of signed floats.
test.py
def myfunc():
tabToReturn = [[[-1.03,5.68],[4.16,-78.12]],[[74.1,8.95],[59.82,1.48]],[[74.1,8.95],[59.82,87.4]]]
print(tabToReturn)
return tabToReturn
I want to call that .py, make it return this 3d list, and convert it to a 3D vector for my c++ program.
Here is an example to check if I get what we need:
program.cpp
#include <iostream>
std::vector<std::vector<std::vector<float>>> callPython();
int main(int argc, char** argv)
{
std::vector<std::vector<std::vector<float>>> my3DVector = callPython();
std::cout << "Result we got : "<< std::endl;
for (int i = 0; i < my3DVector.size(); i++)
{
for (int j = 0; j < my3DVector[i].size(); j++)
{
for (int k = 0; k < my3DVector[i][j].size(); k++)
{
std::cout << my3DVector[i][j][k];
std::cout << " ";
}
}
std::cout << "" << std::endl;
}
}
The output should be :
Result we got :
-1.03 5.68
4.16 -78.12
74.1 8.95
59.82 1.48
74.1 8.95
59.82 87.4
I have already seen some questions on this subject, here and here
The problem is that one of the questions has an answer I don't understand at all, and the 2nd is only about a float to return, and I need a 3D vector, I didn't find what I need here
Also, this tutorial does not explain how to pass a 3d list, or even a list at all.