diff --git a/MatterControl.Printing/Settings/PrinterSettings.cs b/MatterControl.Printing/Settings/PrinterSettings.cs
index 2611978fc..cc06e9f0b 100644
--- a/MatterControl.Printing/Settings/PrinterSettings.cs
+++ b/MatterControl.Printing/Settings/PrinterSettings.cs
@@ -374,6 +374,46 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
+ ///
+ /// The bounds that a mesh can be placed at and the gcode it creates will be within the bed
+ ///
+ [JsonIgnore]
+ public RectangleDouble MeshAllowedBounds
+ {
+ get
+ {
+ var firstLayerExtrusionWidth = GetDouble(SettingsKey.first_layer_extrusion_width);
+ var bedBounds = BedBounds;
+ var totalOffset = 0.0;
+
+ if (GetBool(SettingsKey.create_raft))
+ {
+ // The slicing engine creates a raft 3x the extrusion width
+ firstLayerExtrusionWidth *= 3;
+ totalOffset += firstLayerExtrusionWidth;
+ totalOffset += GetDouble(SettingsKey.raft_extra_distance_around_part);
+ }
+
+ if (GetBool(SettingsKey.create_skirt))
+ {
+ totalOffset += GetValue(SettingsKey.skirt_distance);
+ totalOffset += (GetDouble(SettingsKey.skirts) + .5) * firstLayerExtrusionWidth;
+ // for every 400mm of min skirt length add another skirt loops
+ totalOffset += GetDouble(SettingsKey.min_skirt_length) / (20 * 20);
+ }
+
+ if (GetBool(SettingsKey.create_brim)
+ && !GetBool(SettingsKey.create_raft))
+ {
+ totalOffset += GetValue(SettingsKey.brims) * GetDouble(SettingsKey.first_layer_extrusion_width);
+ }
+
+ bedBounds.Inflate(-totalOffset);
+
+ return bedBounds;
+ }
+ }
+
[JsonIgnore]
public IEnumerable DefaultLayerCascade
{
@@ -1176,6 +1216,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return GetValue(settingsKey);
}
+ public double GetDouble(string settingsKey)
+ {
+ return GetValue(settingsKey);
+ }
+
///
/// Returns the first matching value discovered while enumerating the settings layers
///
diff --git a/MatterControlLib/ApplicationView/PrinterExtensionMethods.cs b/MatterControlLib/ApplicationView/PrinterExtensionMethods.cs
index c33513d6b..c171cf771 100644
--- a/MatterControlLib/ApplicationView/PrinterExtensionMethods.cs
+++ b/MatterControlLib/ApplicationView/PrinterExtensionMethods.cs
@@ -63,13 +63,15 @@ namespace MatterHackers.MatterControl
return false;
}
+ var bedBounds = printerConfig.Settings.MeshAllowedBounds;
+
switch (bed.BedShape)
{
case BedShape.Rectangular:
- if (aabb.MinXYZ.X < bed.BedCenter.X - bed.ViewerVolume.X / 2
- || aabb.MaxXYZ.X > bed.BedCenter.X + bed.ViewerVolume.X / 2
- || aabb.MinXYZ.Y < bed.BedCenter.Y - bed.ViewerVolume.Y / 2
- || aabb.MaxXYZ.Y > bed.BedCenter.Y + bed.ViewerVolume.Y / 2)
+ if (aabb.MinXYZ.X < bedBounds.Left
+ || aabb.MaxXYZ.X > bedBounds.Right
+ || aabb.MinXYZ.Y < bedBounds.Bottom
+ || aabb.MaxXYZ.Y > bedBounds.Top)
{
return false;
}