From: scislac Date: Fri, 16 Oct 2009 22:28:40 +0000 (+0000) Subject: More proper fix for 451588 by Tavmjong X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7faab2e3c5a361febf4758a39124466b1c3df259;p=inkscape.git More proper fix for 451588 by Tavmjong --- diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index f8916655d..1cb14fb58 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -303,16 +303,28 @@ bool PovOutput::doCurve(SPItem *item, const String &id) Geom::Matrix tf = sp_item_i2d_affine(item); Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf ); - //Count the NR_CURVETOs/LINETOs (including closing line segment) + /* + * We need to know the number of segments (NR_CURVETOs/LINETOs, including + * closing line segment) before we write out segment data. Since we are + * going to skip degenerate (zero length) paths, we need to loop over all + * subpaths and segments first. + */ int segmentCount = 0; - for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) + /** + * For all Subpaths in the + */ + for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) + { + /** + * For all segments in the subpath, including extra closing segment defined by 2geom + */ + for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit) { - segmentCount += (*it).size(); - - // If segment not closed, add space for a closing segment. - if (!it->closed()) segmentCount += 1; + // Skip zero length segments. + if( !cit->isDegenerate() ) ++segmentCount; } + } out("/*###################################################\n"); out("### PRISM: %s\n", id.c_str()); @@ -347,8 +359,8 @@ bool PovOutput::doCurve(SPItem *item, const String &id) for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit) { - // If path is closed, we don't need extra closing segment. - if( pit->closed() && cit == pit->end() ) + // Skip zero length segments + if( cit->isDegenerate() ) continue; if( is_straight_curve(*cit) ) @@ -371,7 +383,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id) nrNodes += 8; } else - { + { err("logical error, because pathv_to_linear_and_cubic_beziers was used"); return false; }