@@ -1119,10 +1119,6 @@ void LayerPlan::addWallLine(
11191119 {
11201120 add_skin_extrusion (roofing_mask_, roofing_config);
11211121 }
1122- else if (use_skin_config (flooring_mask_, flooring_config))
1123- {
1124- add_skin_extrusion (flooring_mask_, flooring_config);
1125- }
11261122 else if (bridge_wall_mask_.empty ())
11271123 {
11281124 // no bridges required
@@ -1137,102 +1133,102 @@ void LayerPlan::addWallLine(
11371133 GCodePathConfig::FAN_SPEED_DEFAULT,
11381134 travel_to_z);
11391135 }
1140- else
1136+ else if ( PolygonUtils::polygonCollidesWithLineSegment (bridge_wall_mask_, p0. toPoint2LL (), p1. toPoint2LL ()))
11411137 {
1142- // bridges may be required
1143- if (PolygonUtils::polygonCollidesWithLineSegment (bridge_wall_mask_, p0.toPoint2LL (), p1.toPoint2LL ()))
1144- {
1145- // the line crosses the boundary between supported and non-supported regions so one or more bridges are required
1138+ // the line crosses the boundary between supported and non-supported regions so one or more bridges are required
11461139
1147- // determine which segments of the line are bridges
1140+ // determine which segments of the line are bridges
11481141
1149- OpenLinesSet line_polys;
1150- line_polys.addSegment (p0.toPoint2LL (), p1.toPoint2LL ());
1151- constexpr bool restitch = false ; // only a single line doesn't need stitching
1152- line_polys = bridge_wall_mask_.intersection (line_polys, restitch);
1142+ OpenLinesSet line_polys;
1143+ line_polys.addSegment (p0.toPoint2LL (), p1.toPoint2LL ());
1144+ constexpr bool restitch = false ; // only a single line doesn't need stitching
1145+ line_polys = bridge_wall_mask_.intersection (line_polys, restitch);
11531146
1154- // line_polys now contains the wall lines that need to be printed using bridge_config
1147+ // line_polys now contains the wall lines that need to be printed using bridge_config
11551148
1156- while (line_polys.size () > 0 )
1149+ while (line_polys.size () > 0 )
1150+ {
1151+ // find the bridge line segment that's nearest to the current point
1152+ size_t nearest = 0 ;
1153+ double smallest_dist2 = (cur_point - line_polys[0 ][0 ]).vSize2f ();
1154+ for (size_t i = 1 ; i < line_polys.size (); ++i)
11571155 {
1158- // find the bridge line segment that's nearest to the current point
1159- size_t nearest = 0 ;
1160- double smallest_dist2 = (cur_point - line_polys[0 ][0 ]).vSize2f ();
1161- for (size_t i = 1 ; i < line_polys.size (); ++i)
1156+ double dist2 = (cur_point - line_polys[i][0 ]).vSize2f ();
1157+ if (dist2 < smallest_dist2)
11621158 {
1163- double dist2 = (cur_point - line_polys[i][0 ]).vSize2f ();
1164- if (dist2 < smallest_dist2)
1165- {
1166- nearest = i;
1167- smallest_dist2 = dist2;
1168- }
1159+ nearest = i;
1160+ smallest_dist2 = dist2;
11691161 }
1170- const OpenPolyline& bridge = line_polys[nearest];
1162+ }
1163+ const OpenPolyline& bridge = line_polys[nearest];
11711164
1172- // set b0 to the nearest vertex and b1 the furthest
1173- Point3LL b0 = bridge[0 ];
1174- Point3LL b1 = bridge[1 ];
1165+ // set b0 to the nearest vertex and b1 the furthest
1166+ Point3LL b0 = bridge[0 ];
1167+ Point3LL b1 = bridge[1 ];
11751168
1176- if ((cur_point - b1).vSize2f () < (cur_point - b0).vSize2f ())
1177- {
1178- // swap vertex order
1179- b0 = bridge[1 ];
1180- b1 = bridge[0 ];
1181- }
1169+ if ((cur_point - b1).vSize2f () < (cur_point - b0).vSize2f ())
1170+ {
1171+ // swap vertex order
1172+ b0 = bridge[1 ];
1173+ b1 = bridge[0 ];
1174+ }
11821175
1183- // extrude using default_config to the start of the next bridge segment
1176+ // extrude using default_config to the start of the next bridge segment
11841177
1185- addNonBridgeLine (b0);
1178+ addNonBridgeLine (b0);
11861179
1187- const double bridge_line_len = (b1 - cur_point).vSize ();
1180+ const double bridge_line_len = (b1 - cur_point).vSize ();
11881181
1189- if (bridge_line_len >= min_bridge_line_len)
1190- {
1191- // extrude using bridge_config to the end of the next bridge segment
1182+ if (bridge_line_len >= min_bridge_line_len)
1183+ {
1184+ // extrude using bridge_config to the end of the next bridge segment
11921185
1193- if (bridge_line_len > min_line_len)
1194- {
1195- addExtrusionMoveWithGradualOverhang (
1196- b1,
1197- bridge_config,
1198- SpaceFillType::Polygons,
1199- flow,
1200- width_factor,
1201- spiralize,
1202- 1 .0_r,
1203- GCodePathConfig::FAN_SPEED_DEFAULT,
1204- travel_to_z);
1205- non_bridge_line_volume = 0 ;
1206- cur_point = b1;
1207- // after a bridge segment, start slow and accelerate to avoid under-extrusion due to extruder lag
1208- speed_factor = std::max (std::min (Ratio (bridge_config.getSpeed () / default_config.getSpeed ()), 1 .0_r), 0 .5_r);
1209- }
1210- }
1211- else
1186+ if (bridge_line_len > min_line_len)
12121187 {
1213- // treat the short bridge line just like a normal line
1214-
1215- addNonBridgeLine (b1);
1188+ addExtrusionMoveWithGradualOverhang (
1189+ b1,
1190+ bridge_config,
1191+ SpaceFillType::Polygons,
1192+ flow,
1193+ width_factor,
1194+ spiralize,
1195+ 1 .0_r,
1196+ GCodePathConfig::FAN_SPEED_DEFAULT,
1197+ travel_to_z);
1198+ non_bridge_line_volume = 0 ;
1199+ cur_point = b1;
1200+ // after a bridge segment, start slow and accelerate to avoid under-extrusion due to extruder lag
1201+ speed_factor = std::max (std::min (Ratio (bridge_config.getSpeed () / default_config.getSpeed ()), 1 .0_r), 0 .5_r);
12161202 }
1203+ }
1204+ else
1205+ {
1206+ // treat the short bridge line just like a normal line
12171207
1218- // finished with this segment
1219- line_polys.removeAt (nearest);
1208+ addNonBridgeLine (b1);
12201209 }
12211210
1222- // if we haven't yet reached p1, fill the gap with default_config line
1223- addNonBridgeLine (p1);
1224- }
1225- else if (bridge_wall_mask_.inside (p0.toPoint2LL (), true ) && (p0 - p1).vSize () >= min_bridge_line_len)
1226- {
1227- // both p0 and p1 must be above air (the result will be ugly!)
1228- addExtrusionMoveWithGradualOverhang (p1, bridge_config, SpaceFillType::Polygons, flow, width_factor);
1229- non_bridge_line_volume = 0 ;
1230- }
1231- else
1232- {
1233- // no part of the line is above air or the line is too short to print as a bridge line
1234- addNonBridgeLine (p1);
1211+ // finished with this segment
1212+ line_polys.removeAt (nearest);
12351213 }
1214+
1215+ // if we haven't yet reached p1, fill the gap with default_config line
1216+ addNonBridgeLine (p1);
1217+ }
1218+ else if (bridge_wall_mask_.inside (p0.toPoint2LL (), true ) && (p0 - p1).vSize () >= min_bridge_line_len)
1219+ {
1220+ // both p0 and p1 must be above air (the result will be ugly!)
1221+ addExtrusionMoveWithGradualOverhang (p1, bridge_config, SpaceFillType::Polygons, flow, width_factor);
1222+ non_bridge_line_volume = 0 ;
1223+ }
1224+ else if (use_skin_config (flooring_mask_, flooring_config))
1225+ {
1226+ add_skin_extrusion (flooring_mask_, flooring_config);
1227+ }
1228+ else
1229+ {
1230+ // no part of the line is above air or the line is too short to print as a bridge line
1231+ addNonBridgeLine (p1);
12361232 }
12371233}
12381234
0 commit comments