@@ -71,8 +71,8 @@ std::vector<coord_t> shapeLineIntersections(const coord_t line_y, const Transfor
7171 *
7272 * The score is based on the following criteria:
7373 * - Properly bridging segments, i.e. between two supported areas, add their length to the score
74- * - Hanging segments, i.e. supported on one side but not the other (or not at all), subtract their length to the score
75- * - Segments that lie on a supported area are not accounted for */
74+ * - Hanging segments, i.e. supported on one side but not the other (or not at all), subtract their length from the score
75+ * - Segments that lie on a supported area substract part of their length from the score */
7676coord_t evaluateBridgeLine (const coord_t line_y, const TransformedShape& transformed_skin_area, const TransformedShape& transformed_supported_area)
7777{
7878 // Calculate intersections with skin outline to see which segments should actually be printed
@@ -164,8 +164,7 @@ coord_t evaluateBridgeLine(const coord_t line_y, const TransformedShape& transfo
164164
165165 const bool leaving_skin = next_intersection_is_skin_area && ! next_inside_skin_area;
166166 const bool reaching_supported = next_intersection_is_supported_area && next_inside_supported_area;
167- bool add_bridging_segment = false ;
168- bool add_hanging_segment = false ;
167+ double add_segment_score_weight = 0.0 ;
169168
170169 switch (bridge_status)
171170 {
@@ -175,31 +174,33 @@ coord_t evaluateBridgeLine(const coord_t line_y, const TransformedShape& transfo
175174
176175 case BridgeStatus::Supported:
177176 bridge_status = leaving_skin ? BridgeStatus::Outside : BridgeStatus::Anchored;
177+ // Negatively account for fully supported lines to avoid lonely line parts over the supported areas
178+ add_segment_score_weight = -0.1 ;
178179 break ;
179180
180181 case BridgeStatus::Hanging:
181- add_hanging_segment = true ;
182+ add_segment_score_weight = - 1.0 ;
182183 bridge_status = reaching_supported ? BridgeStatus::Supported : BridgeStatus::Outside;
183184 break ;
184185
185186 case BridgeStatus::Anchored:
186187 if (reaching_supported)
187188 {
188- add_bridging_segment = true ;
189+ add_segment_score_weight = 1.0 ;
189190 bridge_status = BridgeStatus::Supported;
190191 }
191192 else if (leaving_skin)
192193 {
193- add_hanging_segment = true ;
194+ add_segment_score_weight = - 1.0 ;
194195 bridge_status = BridgeStatus::Outside;
195196 }
196197 break ;
197198 }
198199
199- if (add_bridging_segment || add_hanging_segment )
200+ if (add_segment_score_weight != 0.0 )
200201 {
201202 const coord_t segment_length = next_intersection - last_position;
202- segment_score += add_bridging_segment ? segment_length : -segment_length ;
203+ segment_score += std::llrint ( segment_length * add_segment_score_weight) ;
203204 }
204205
205206 last_position = next_intersection;
0 commit comments