Code

More proper fix for 451588 by Tavmjong
authorscislac <scislac@users.sourceforge.net>
Fri, 16 Oct 2009 22:28:40 +0000 (22:28 +0000)
committerscislac <scislac@users.sourceforge.net>
Fri, 16 Oct 2009 22:28:40 +0000 (22:28 +0000)
src/extension/internal/pov-out.cpp

index f8916655df152490daa179fbfc84cec78f520fbd..1cb14fb58bd6522f0b7ed8b34af0ffb3610a4cc7 100644 (file)
@@ -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 <path>
+     */             
+    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;
                 }