@@ -61,8 +61,8 @@ std::vector<coord_t> shapeLineIntersections(const coord_t line_y, const Transfor
6161 *
6262 * The score is based on the following criteria:
6363 * - Properly bridging segments, i.e. between two supported areas, add their length to the score
64- * - Hanging segments, i.e. supported on one side but not the other (or not at all), subtract their length to the score
65- * - Segments that lie on a supported area are not accounted for */
64+ * - Hanging segments, i.e. supported on one side but not the other (or not at all), subtract their length from the score
65+ * - Segments that lie on a supported area substract part of their length from the score */
6666coord_t evaluateBridgeLine (const coord_t line_y, const TransformedShape& transformed_skin_area, const TransformedShape& transformed_supported_area)
6767{
6868 // Calculate intersections with skin outline to see which segments should actually be printed
@@ -154,8 +154,7 @@ coord_t evaluateBridgeLine(const coord_t line_y, const TransformedShape& transfo
154154
155155 const bool leaving_skin = next_intersection_is_skin_area && ! next_inside_skin_area;
156156 const bool reaching_supported = next_intersection_is_supported_area && next_inside_supported_area;
157- bool add_bridging_segment = false ;
158- bool add_hanging_segment = false ;
157+ double add_segment_score_weight = 0.0 ;
159158
160159 switch (bridge_status)
161160 {
@@ -165,31 +164,33 @@ coord_t evaluateBridgeLine(const coord_t line_y, const TransformedShape& transfo
165164
166165 case BridgeStatus::Supported:
167166 bridge_status = leaving_skin ? BridgeStatus::Outside : BridgeStatus::Anchored;
167+ // Negatively account for fully supported lines to avoid lonely line parts over the supported areas
168+ add_segment_score_weight = -0.1 ;
168169 break ;
169170
170171 case BridgeStatus::Hanging:
171- add_hanging_segment = true ;
172+ add_segment_score_weight = - 1.0 ;
172173 bridge_status = reaching_supported ? BridgeStatus::Supported : BridgeStatus::Outside;
173174 break ;
174175
175176 case BridgeStatus::Anchored:
176177 if (reaching_supported)
177178 {
178- add_bridging_segment = true ;
179+ add_segment_score_weight = 1.0 ;
179180 bridge_status = BridgeStatus::Supported;
180181 }
181182 else if (leaving_skin)
182183 {
183- add_hanging_segment = true ;
184+ add_segment_score_weight = - 1.0 ;
184185 bridge_status = BridgeStatus::Outside;
185186 }
186187 break ;
187188 }
188189
189- if (add_bridging_segment || add_hanging_segment )
190+ if (add_segment_score_weight != 0.0 )
190191 {
191192 const coord_t segment_length = next_intersection - last_position;
192- segment_score += add_bridging_segment ? segment_length : -segment_length ;
193+ segment_score += std::llrint ( segment_length * add_segment_score_weight) ;
193194 }
194195
195196 last_position = next_intersection;
0 commit comments