From: Krzysztof K. <twe...@gm...> - 2012-09-02 22:03:13
|
2012/8/31 mathog <ma...@ca...>: > Is there any documentation for lib2geom? I hunted all over and could > only find the source code, but not a scrap of other documentation or a > complete example program. The only examples so far are in Inkscape, > which isn't so good for the purpose of learning what lib2geom does. (I > did find in inkscape examples of how to copy a path with multiple > segments, just not how to create one!) There are some examples in the 'toys' directory. Maybe they're not the best examples, as they're more proff-of-concept implementations of advanced operations, but they exist. For the basic classes (Affine, Point, Ray, Curve, etc.) there is Doxygen documentation. It's currently lacking for Path and several other classes, mainly because their design should be improved (for a start, Path should be renamed to Subpath and PathVector to Path) and I think writing extensive documentation for them before they are rewritten is something of a waste of time. To generate the Doxygen documentation, run 'doxygen' in the toplevel directory of the checkout. Open doc/html/index.html to read them. > So I'm asking here for some help. Hope that is appropriate for this > mailing list. > > I need to do the following using lib2geom (I think) within inkscape. > Starting with pathA (a Geom::PathVector > passed in from the caller, which in general is drawn both filled and > stroked): > > 1. generate a second PathVector "pathB". In one case this is a > rectangle (with corners known), and in the the other it is an elliptical > ring (center, inner/outer radii, minor, major unit axis vectors all > known). If your rectangle has corners at points a, b, c, d, do the following: Geom::Point Geom::Path x(a); x.appendNew<Geom::LineSegment>(b); x.appendNew<Geom::LineSegment>(c); x.appendNew<Geom::LineSegment>(d); x.close(); For an elliptical ring, do the same, but use two Geom::SVGEllipticalArc. The constructors are the same as for Geom::EllipticalArc and are documented with Doxygen comments. > 2. generate a third PathVector "pathC" = INTERSECTION(pathA,pathB). > Just like the Intersection option on the Paths menu. This cannot be done with 2Geom, because the boolean operations code does not work correctly. You need to use the old livarot library, which is undocumented and frankly nobody understands it. Your best bet is copying what the Spray tool does: create an SP object containing an ellipse and a second SP object (SPPath) containing your path, then intersecting them using the relevant function from sp-livarot.h. > 3. delete pathB and pathC. > Presumably something like: > delete pathB; > delete [] pathB; > > If lib2geom does what I think it does then this should be > straightforward and just be a couple of lines of code. For which I have > absolutely no idea what the syntax might be. PathVectors are intended to be used as a stack variable or through a smart pointer, e.g. boost::shared_ptr, so you should never need to delete them explicitly. Regards, Krzysztof |