Hey Embers,
TL/DR: The Shape2d object returned by a svg::DocRef doesn’t contain valid Path2d objects, because the contours inside don’t start with a MOVETO segment. This in turn causes the reverse() function call on the Path2d objects to mess them up, as it always expects a MOVETO segment in the beginning.
I’ve tried a few fixes (as elaborated below) but still don’t know how to… 
Elaborate story:
As per a previous topic of mine, I’m working with Shape2d objects generated via a svg::DocRef and attempting to extrude the vector shapes to generate a simple derived model with some depth.
The winding order of the points obtained in the Path2d objects contained within the Shape2d object are not always clock-wise. Even if they were, they might not be after I have performed some transformations on them. Therefore it becomes quite helpful to determine the winding order which the other post explores.
Once the winding order has been determined I call (or do not call) reverse() on the various Path2d objects. It seems generate ‘bad’ Path2d objects however, as they don’t begin with a MOVETO segment. This doesn’t seem to bother the geom::extrude function however, but it does cause the reverse() function to severely alter the Path2d. The reverse() function always expects a path to begin with a MOVETO segment and so will reverse all the points, but only some of the segments.
I thought a quick fix might be to simply manually insert a MOVETO segment in front of every Path2d I get out of the Shape2d object that I get from the svg::DocRef object. But either I’m not doing this correctly or I’m missing something as I’ve only managed to create new Path2d objects that cause geom::extrude to throw an exception I’ve yet to delve into deeper.
So I guess my question is one of two. Either:
- Does someone have a fix for the code in Cinder to have the
svg::DocRefproduce properPath2dobjects inside theShape2dfile? - Failing that, does anyone have any advice on how to safely add a
MOVETOsegment at the beginning of anyPath2d? I’ve tried simply cloning the very first point at the start and inserting a newMOVETOsegment along with it, but that doesn’t seem to go well. ThePath2dobject confuses me a bit as well, as themoveTofunctions don’t seem to automatically add aSegmentTypetomSegmentslike all the other similar functions.
Any thoughts are appreciated!
Cheers,
Gazoo
