@@ -1072,7 +1072,7 @@ class VectorSprite : public Sprite
10721072 return false ;
10731073
10741074 std::vector<RC> raster_pts;
1075- std::map<int , std::vector<int >> map_row_to_occupied_cols ;
1075+ std::vector<std:: map<int , std::vector<int >>> polygons_map_row_to_occupied_cols ;
10761076
10771077 for (const auto & line_seg : vector_frame->line_segments )
10781078 {
@@ -1119,6 +1119,7 @@ class VectorSprite : public Sprite
11191119 {
11201120 for (const auto & polygon : vector_frame->closed_polylines )
11211121 {
1122+ auto & map_row_to_occupied_cols = polygons_map_row_to_occupied_cols.emplace_back ();
11221123 for (const auto & line_seg : polygon)
11231124 {
11241125 auto [p0, p1] = calc_seg_world_pos_round (line_seg);
@@ -1131,33 +1132,32 @@ class VectorSprite : public Sprite
11311132
11321133 for (int r = 0 ; r < sh.num_rows (); ++r)
11331134 {
1134- auto & occupied_cols = map_row_to_occupied_cols[r];
1135-
1136- /*
1137- if (occupied_cols.size() % 2 == 1)
1138- {
1139- //std::cerr << "ERROR in VectorSprite::draw() : Odd number of scan-line isect pts detected.\n";
1140- continue;
1141- }
1142- */
1143-
1144- stlutils::sort (occupied_cols);
1145-
1146- bool enable_fill = true ;
1147- for (int ci = 0 ; ci < stlutils::sizeI (occupied_cols) - 1 ; ++ci)
1135+ for (auto & map_row_to_occupied_cols : polygons_map_row_to_occupied_cols)
11481136 {
1149- const auto & c0 = occupied_cols[ci];
1150- const auto & c1 = occupied_cols[ci + 1 ];
1151- if (enable_fill)
1137+ auto & occupied_cols = map_row_to_occupied_cols[r];
1138+
1139+ /*
1140+ if (occupied_cols.size() % 2 == 1)
11521141 {
1153- for (int c = c0 + 1 ; c < c1; ++c)
1154- {
1155- sh.write_buffer (std::string (1 , vector_frame->fill_char ), r, c, vector_frame->fill_style );
1156- }
1142+ //std::cerr << "ERROR in VectorSprite::draw() : Odd number of scan-line isect pts detected.\n";
1143+ continue;
11571144 }
1145+ */
1146+
1147+ stlutils::sort (occupied_cols);
11581148
1159- if (c1 - c0 > 1 )
1160- math::toggle (enable_fill);
1149+ bool enable_fill = true ;
1150+ for (int ci = 0 ; ci < stlutils::sizeI (occupied_cols) - 1 ; ++ci)
1151+ {
1152+ const auto & c0 = occupied_cols[ci];
1153+ const auto & c1 = occupied_cols[ci + 1 ];
1154+ if (enable_fill)
1155+ for (int c = c0 + 1 ; c < c1; ++c)
1156+ sh.write_buffer (std::string (1 , vector_frame->fill_char ), r, c, vector_frame->fill_style );
1157+
1158+ if (c1 - c0 > 1 )
1159+ math::toggle (enable_fill);
1160+ }
11611161 }
11621162 }
11631163 }
0 commit comments