If, in svgExample, vector <ofPolyline> outlines; creates one group of polylines to draw one object, then you need something like vector <vector<ofPolyline>> outlines; so that you can have groups of groups of polylines.
After you load you SVG, you only loop through the first one: currentImage is always 0. You need to nest that loop inside another one and do the proper changes to you code.
hey, thanks for the hints. So now I’m working towards setting up everything, so that draw just cycles through a vector where all my vectors of the paths are stored. I like that, I get that.
But I’ve tried a lot of different ways to do it and end up at the same problem every time: I get a runtime error that says bad access and outputs (lldb). For that, I find explanations about memory use (or solutions that point to something with xcode, but I doubt thats the problem…)
to get my head around it
/*the group vector will have as many elemnts as there are pictures in the folder.
each picture is stored as a collection of paths.
each path is simplified to a polyline (the outline of the path)*/
//for every picture in the folder
//for every path in the picture
//add all the polylines
maybe I’m not understanding how polylines are const and thats tripping me up?
void ofApp::setup(){
ofSetVerticalSync(true);
ofBackground(0);
ofSetColor(255);
dir.listDir("svgs");
if ( dir.size()){
images.assign(dir.size(), ofxSVG());
}
for(int d = 0; d < (int)dir.size(); d++){
images[d].load(dir.getPath(d));
}
for (int c =0; c<images.size(); c++){
for (int i = 0; i < images[c].getNumPath(); i++){
ofPath p = images[c].getPathAt(i);
// svg defaults to non zero winding which doesn't look so good as contours
p.setPolyWindingMode(OF_POLY_WINDING_ODD);
//lines is a refrence, remove the const from getOutline results (const bc of oF core stuff?)
vector<ofPolyline>& lines = const_cast< vector<ofPolyline>& > (p.getOutline());
for(int j=0;j<(int)lines.size();j++){
outlines.push_back(lines[j].getResampledBySpacing(1));
}
}
cout<<outlines.size() <<endl;
//and then the simplest imaginable solution...fails
outlinesGroup[c]=outlines;
}
}
Im still stuck on this problem. I have a vector of vectors of polylines called outlines group, and I’m trying to add a vector of polylines to it like so:
outlinesGroup[c]=outlines;
which trips up the program. Details in my post above. Any hints would be great.