summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2d2706a)
raw | patch | inline | side by side (parent: 2d2706a)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 4 Jul 2008 22:41:45 +0000 (22:41 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 4 Jul 2008 22:41:45 +0000 (22:41 +0000) |
src/sp-path.cpp | patch | blob | history |
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index 962be5cb50bb91a9d70287ec3545399c926dcf3b..8327cb88d080bd77cd12549b45d0e2b9fd72f073 100644 (file)
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
{
SPPath *path = SP_PATH(item);
- SPDocument *doc = SP_OBJECT_DOCUMENT(path);
- std::list<std::pair<Geom::Point, Geom::Point> > pts;
-
- NR::Matrix const i2d (from_2geom(sp_item_i2d_affine(SP_ITEM(path))));
-
SPCurve *curve = SP_SHAPE(path)->curve;
if (!curve) return;
- NArtBpath const *bpath = SP_CURVE_BPATH(curve);
-
- NR::Point last_pt;
- NR::Point pt;
- for (int i = 0; bpath[i].code != NR_END; i++){
- if (bpath[i].code == NR_LINETO) {
- /* we only convert straight line segments (converting curve segments would be unintuitive) */
- pt = bpath[i].c(3) * i2d;
- pts.push_back(std::make_pair(last_pt.to_2geom(), pt.to_2geom()));
- }
- /* remember current point for potential reuse in the next step
- (e.g., in case this was an NR_MOVETO or NR_MOVETO_OPEN) */
- last_pt = bpath[i].c(3) * i2d;
+ std::list<std::pair<Geom::Point, Geom::Point> > pts;
+
+ Geom::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(path)));
+
+ Geom::PathVector const & pv = curve->get_pathvector();
+ for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) {
+ for(Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
+ // only add curves for straight line segments
+ if( dynamic_cast<Geom::LineSegment const *>(&*cit) ||
+ dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
+ dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ {
+ pts.push_back(std::make_pair(cit->initialPoint() * i2d, cit->finalPoint() * i2d));
+ }
+ }
}
+ SPDocument *doc = SP_OBJECT_DOCUMENT(path);
sp_guide_pt_pairs_to_guides(doc, pts);
}