Closed mindbrix closed 6 years ago
You just allocate an array of points and put your points in reversed order there before adding the contour. Like this:
// The points
float* pts = ...;
int npts = ...;
float* rev = malloc(sizeof(float)*2*npts);
float* dst = &rev[(npts-1)*2];
float* src = pts;
for (int i = 0; i < npts; i++) {
dst[0] = src[0];
dst[1] = src[1];
dst -= 2:
src += 2;
}
tessAddContour(...);
free(rev);
People often need to change the contours from their internal format to the one used by libtess2, that is a good spot to put the reversing code too.
Hi. The flag was added to optimise away this extra allocation and copy.
Fair enough. I would not like to break the API for tessAddContour()
. I would like to keep the function to bare minimum, just enough params that are required to pass in a contour.
How about:
tessSetOption(tess, TESS_REVERSE_CONTOUR);
tessAddContour(...);
I'm not super proud of tessSetOption()
either, but it seemed like the best compromise for tessTesselate()
, so maybe for this case too.
Yes. Better to just break my code than everyone else's ;-)
TESS_REVERSE_CONTOUR
option
Need to sort this out