From: Krzysztof K. <twe...@gm...> - 2012-09-13 16:05:24
|
2012/9/7 mathog <ma...@ca...>: > On 04-Sep-2012 18:02, Krzysztof Kosiński wrote: >> 2012/9/5 mathog <ma...@ca...>: > >>> Can livarot be used that way? >> >> Not without modifications. >> >> The relevant function is in splivarot.cpp, lines 115-602. You can try >> to take everything after the input validation bits (they end around >> line 239) and turn that into a new function that will take >> pathvectors, then call this new function from the original. > > I tried that today and got it to the point where it would compile and > create result of type "Path" (livarot Path, not Geom Path) containing > the result. > I can see this as > > std::cout << "result is: " << res->svg_dump_path() << std::endl; > > at that point shows a reasonable looking string for an SVG path for the > test case: > > M 135.09375 531.25 L 135.09375 799.8125 C 135.09375 799.8125 148.51709 > 791.90059 169.90625 782.96875 L 169.90625 531.25 L 135.09375 531.25 z > > However there seems to be no method in livarot to convert livarot Path > to Geom::Path. So > I went looking for methods to convert that SVG text string to > Geom::PathVector directly > and came up empty. The best I have come up with so far (and this will > not compile): > > Geom::PathVector outres; > std::vector<Geom::Path> tpathv = > Geom::parse_svg_path(res->svg_dump_path()); > for (std::vector<Geom::Path>::const_iterator pit = tpathv.begin(); > pit != tpathv.end(); ++pit){ > outres.push_back(pit); > } > > I thought Geom::PathVector was actually the same thing as > std::vector<Geom::Path>>, but > outres = tpathv; > is not accepted (it doesn't know what to do with the "="). IIRC that's because Geom::Path is not assignable. You are missing a dereference: outres.push_back(*pit); Regards, Krzysztof |