0

i'm developing in codeblocks and I have the following:

struct intersectionData_t
{
    unsigned int idxOfBlob;
    unsigned int idxOfRoad;
    ofPoint xPt; //interesection (cross) point
};

typedef vector<intersectionData_t> plineXD_t;

vector<plineXD_t> plinesXData;

basically, each polyline has a vector of intersections registered in plineXD_t. Then plinesXData is just the vector of all the polylines.

in my implementation:

plineXD_t xData = findIntersectionData( trackedBlob , origRoads[i] );
if ( !xData.empty() ) 
    plinesXData.push_back( xData );

I get some weird values from plinesXData[i] later on in the code so I am trying to see what is generated here in xData.

when the watch in codeblocks returns xData[0] : Could not find operator[]. same if I try plinesXData[i][0].

EDIT: xData.size() does not return a number (the watch field is empty).

EDIT2: findInterestionData fills in the vector intersectionData_t with the all intersection points xPt found between 2 polylines. It also stores the indices idxOfRoad & idxOfBlob of the points just before an intersection for each polyline for quick access.

path::plineXD_t path::findIntersectionData( \
            const ofPolyline& trackedBlob , const ofPolyline& road)
{
    plineXD_t xD;

    //for all line segments of path...
    for (unsigned int i = 0 ; i < road.size()-1 ; i++)
    {
        //...test all line segs of trackedBlob for intersections
        for (unsigned int j = 0 ; j < trackedBlob.size()-1 ; j++)
        {
            ofPoint intersectionPoint = ofPoint(0,0);

            if (ofLineSegmentIntersection(road[i] , road[i+1] , trackedBlob[j] , trackedBlob[j+1] , intersectionPoint ))
            {
                struct intersectionData_t id;
                id.idxOfRoad = i;
                id.idxOfBlob = j;
                id.xPt = intersectionPoint;

                xD.push_back( id );
            }
        }
    }

    return xD;
}

what is this ? how can I see the values of the xData vector?

nass
  • 1,453
  • 1
  • 23
  • 38

2 Answers2

0

Seems that really T1 operator[](T2 smth) {...} is not defined in structure plineXD_t but you trying to access it.

It would be better if you showed whole code of all participating structs

AlpenDitrix
  • 322
  • 2
  • 8
0

Not sure if your function findIntersectionData( trackedBlob , origRoads[i] ) actually returns a vector as you haven't shown the complete code. However, for a vector you should be able to read a value simply by using at() member function.

Samboy786
  • 101
  • 1
  • 8