* findpolylinestofill now supplies where the vertex is originated from 4.x-dev

Sun, 01 Nov 2020 19:50:13 +0200

author
cemkalyoncu
date
Sun, 01 Nov 2020 19:50:13 +0200
branch
4.x-dev
changeset 1480
bec6420a79ce
parent 1479
5966992813e9
child 1481
00c4b8cec518

* findpolylinestofill now supplies where the vertex is originated from

Source/Gorgon/CGI/Polygon.h file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/CGI/Polygon.h	Sun Nov 01 12:40:10 2020 +0200
+++ b/Source/Gorgon/CGI/Polygon.h	Sun Nov 01 19:50:13 2020 +0200
@@ -16,18 +16,21 @@
    
     ///@cond internal
     namespace internal {
-        struct vertexinfo {
-            vertexinfo() = default;
+    struct vertexinfo {
+        vertexinfo() = default;
 
-            vertexinfo (Float first, Float second) : first(first), second(second) { }
+        vertexinfo (Float first, Float second, int list) : 
+            first(first), second(second), list(list)
+        { }
 
-            Float first, second;
-            bool skip = false;
-            int wind = false;
-        };
-        
-        template<class PL_, class F_, class T_>
-        void findpolylinestofill(const PL_ &pointlist, T_ ymin, T_ ymax, F_ fn, T_ step = 1, T_ cover = 1) {
+        Float first, second;
+        int list;
+        bool skip = false;
+        int wind = false;
+    };
+    
+    template<class PL_, class F_, class T_>
+    void findpolylinestofill(const PL_ &pointlist, T_ ymin, T_ ymax, F_ fn, T_ step = 1, T_ cover = 1) {
         using std::swap;
         
         for(T_ y = ymin; y<ymax; y += step) {
@@ -35,6 +38,7 @@
             
             std::vector<vertexinfo> xpoints;
             
+            int listind = 0;
             for(const auto &points : pointlist) {
                 int N = (int)points.GetSize();
                 
@@ -103,7 +107,7 @@
                             }
                             
                             firstdir = line.YDirection();
-                            xpoints.push_back({x1, x2});
+                            xpoints.push_back({x1, x2, listind});
                             xpoints.back().wind = firstdir;
                         }
                         
@@ -125,6 +129,8 @@
                     xpoints.back().skip= true;
                     //xpoints.back().wind = 0;
                 }
+                
+                listind++;
             }
             
             std::sort(xpoints.begin(), xpoints.end(), [](auto l, auto r) { return l.second < r.second; });
@@ -142,8 +148,6 @@
             //fill
             fn((Float)y, xpoints);
         }
-    
-        
     }
     }
     ///@endcond

mercurial