For my code I need to compute Convexhull of series of points and for some reasons I need to use qhull libraries. In this library there is a method qconvex that do exactly what I need. I can run this command in terminal and get what I want. for example let's assume I have an input like points.txt
:
2 #dimension
5 #number of points
0 0
1 0
0.5 0.5
1 1
0 1
I can run in terminal one these command to get the result: qconvex Fx < points.txt
or cat points.txt | qconvex -Fx
and the out put is :
4
0
1
3
4
Now my question is how can I call this command in my C++ code iteratively over my input: in my code I have 2 for
inside each other that call a specific function that will generate 10 points each time (stored in float **rs_tmp;
) and I need to compute the qconvex for these 10 points each time. how can I run qconvex
in my code and pipe the rs_tmp
as its input? prefer to avoid writing the rs_tmp
into some temporarily file and read from it since I need my code to be super fast.
float **rs_tmp;
for (int i = 0; i < NUMBER; i++)
{
for (int j = 0; j < NUMBER; j++)
{
rs_tmp = generate_points(label, dect[i], dect[j], fun);
// HERE I NEED TO CALL QCONVEX SOME HOW
// THE POINTS ARE STORED IN rs_tmp as 2-Dimensional floating points array
}
int size = fun.size();
for(int i = 0; i < size; ++i)
{
delete[] rs_tmp[i];
}
delete[] rs_tmp;
}