and how does this function getTheElement should behave, as I see it does not return a pointer to an element of type MxInt2d. I tried with the function returning a pointer but when I call the push_back method with the pointer argument the program does not compile due to the wrong parameter.
I want to use this function as I added a new data structure and a new variable like:
typedef std::vector< edge_t> edge2d_t;
std::vector< edge2d_t > myEdgesIntersect;
and now I want to create my variable myEdgesIntersect like:
for (int i=0;i<1;i++){
edge2d[0][0]=sweepEvents[i][0];
edge2d[0][1]=sweepEvents[i][1];
edge2d[1][0]=sweepEvents[i+1][0];
edge2d[1][1]=sweepEvents[i+1][1];
std::cout<<edge2d[0][0]<<" "<<edge2d[0][1]<<endl;
std::cout<<edge2d[1][0]<<" "<<edge2d[1][1]<<endl;
myEdgesIntersect.push_back(edge2d);
std::cout<<myEdgesIntersect[i][0][0]<<" "<<myEdgesIntersect[i][0][1]
<<" "<<myEdgesIntersect[i][1][0]<<" "<<myEdgesIntersect[i][1][1]
<<endl;
}
but when I run the program the display of the variable myEdgesIntersect is not initialize with the given values of edge2d[..][..] (which during the display are okay).
I tried to display the variable myEdgesIntersect before the push_back and I got an bus error, so I think the problem is that the variable is not initialized. I tried to initialize it like:
edge2d_t edge2d;
edge2d[0][0]=0;
edge2d[0][0]=0;
edge2d[0][0]=0;
edge2d[0][0]=0;
edge2d[0][0]=0;
myEdgesIntersect.push_back(edge2d);
but I got the same error, as actually is the same thing as in the loop.
Apparently I do not know how to initialize this quite complicated variable that I really need.
If you have any suggestions I would be more than happy.
thanks in advance,
madalina