private void Settings_OnSettingModified(PrintSettings settings) { SingleMaterialFFFSettings S = CC.PrinterDB.ActivePreset.Settings as SingleMaterialFFFSettings; if (generateSupport.isOn != CC.Settings.GenerateSupport) { generateSupport.isOn = CC.Settings.GenerateSupport; } UnityUIUtil.SetBackgroundColor(generateSupport, settings.GenerateSupport_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(overhangAngle, settings.OverhangAngleDeg_Modified? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(supportMinZTips, settings.SupportMinZTips_Modified? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(supportSpacing, settings.SupportStepX_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(supportShell, settings.EnableSupportShell_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(supportReleaseOpt, settings.EnableSupportReleaseOpt_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(supportGap, settings.SupportSolidSpace_Modified? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); update_visibility(); }
private void BuildToolPaths(GenerationTask generationTask, PrintSettings settings) { lock (active_compute_lock) { DebugUtil.Log("[ToolpathGenerator] Spawning Compute!!"); generationTask.Compute(settings); if (generationTask.Success) { CurrentGCode = generationTask.gcode; Toolpaths = generationTask.paths; LayerInfo = generationTask.layerInfo; Settings = generationTask.PrintSettings; Slices = generationTask.SliceSet; ToolpathsValid = true; ToolpathsFailed = false; //CC.Objects.SetToolpaths(this); } else { CurrentGCode = null; Toolpaths = null; LayerInfo = null; Settings = null; Slices = null; ToolpathsValid = false; ToolpathsFailed = true; } } }
private void Settings_OnNewSettings(PrintSettings settings) { generateSupport.isOn = CC.Settings.GenerateSupport; UnityUIUtil.SetBackgroundColor(generateSupport, CotangentUI.NormalSettingColor); overhangAngle.text = CC.Settings.OverhangAngleDeg.ToString(); UnityUIUtil.SetBackgroundColor(overhangAngle, CotangentUI.NormalSettingColor); supportMinZTips.isOn = CC.Settings.SupportMinZTips; UnityUIUtil.SetBackgroundColor(supportMinZTips, CotangentUI.NormalSettingColor); supportSpacing.text = CC.Settings.SupportStepX.ToString(); UnityUIUtil.SetBackgroundColor(supportSpacing, CotangentUI.NormalSettingColor); supportShell.isOn = CC.Settings.EnableSupportShell; UnityUIUtil.SetBackgroundColor(supportShell, CotangentUI.NormalSettingColor); supportReleaseOpt.isOn = CC.Settings.EnableSupportReleaseOpt; UnityUIUtil.SetBackgroundColor(supportReleaseOpt, CotangentUI.NormalSettingColor); supportGap.text = CC.Settings.SupportSolidSpace.ToString(); UnityUIUtil.SetBackgroundColor(supportGap, CotangentUI.NormalSettingColor); update_visibility(); }
private void Settings_OnNewSettings(PrintSettings settings) { enableBridging.isOn = CC.Settings.EnableBridging; UnityUIUtil.SetBackgroundColor(enableBridging, CotangentUI.NormalSettingColor); maxDistance.text = CC.Settings.MaxBridgeDistanceMM.ToString(); UnityUIUtil.SetBackgroundColor(maxDistance, CotangentUI.NormalSettingColor); update_visibility(); }
private void Settings_OnSettingModified(PrintSettings settings) { SingleMaterialFFFSettings S = CC.PrinterDB.ActivePreset.Settings as SingleMaterialFFFSettings; UnityUIUtil.SetBackgroundColor(enableBridging, settings.EnableBridging_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(maxDistance, settings.MaxBridgeDistanceMM_Modified? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); update_visibility(); }
public void SliceMeshes(List <DMesh3> sourceMeshes, PrintSettings printSettings) { SliceStackValid = false; try { var sliceTask = new SliceTask(); sliceTask.meshCopies = sourceMeshes; sliceTask.Compute(printSettings); SlicerMeshes = sliceTask.MeshAssembly; SliceSet = sliceTask.SliceStack; SliceStackValid = true; } catch (Exception ex) { } }
private void Settings_OnSettingModified(PrintSettings settings) { SingleMaterialFFFSettings S = CC.PrinterDB.ActivePreset.Settings as SingleMaterialFFFSettings; UnityUIUtil.SetBackgroundColor(layerHeight, settings.LayerHeightMM_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(infill, settings.InfillStepX_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(shells, settings.OuterShells_Modified? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(roofLayers, settings.RoofLayers_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(floorLayers, settings.FloorLayers_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(interiorSolidRegionShells, settings.InteriorSolidRegionShells_Modified? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); UnityUIUtil.SetBackgroundColor(clipOverlaps, settings.ClipSelfOverlaps_Modified ? CotangentUI.ModifiedSettingColor : CotangentUI.NormalSettingColor); }
public static void Initialize(FContext context) { ActiveContext = context; ActiveContext.Scene.SelectionChangedEvent += Scene_SelectionChangedEvent; ActiveContext.Scene.ChangedEvent += Scene_ChangedEvent; PrinterDB = new SettingsDatabase(); Settings = new PrintSettings(); PrinterDB.OnPrinterSelectionModified += PrinterDB_OnPrinterSelectionModified; PrinterDB.OnPresetSelectionModified += PrinterDB_OnPresetSelectionModified; PrinterDB.Initialize(); Settings.UpdateFromSettings(PrinterDB.ActivePreset.Settings); update_printer_bed(); ObjSettings = new ObjectSettings(); CCActions.UpdateObjectSettings(); Objects = new PrintScene(); Toolpather = new ToolpathGenerator(); Toolpather.ToolpathsProgressEvent += (status) => { ToolpathProgressEvent?.Invoke(status); }; Slicer = new GeometrySlicer(); Slicer.SlicingProgressEvent += (status) => { SlicingProgressEvent?.Invoke(status); }; Slicer.SlicingInvalidatedEvent += () => { InvalidateToolPaths(); }; MeshAnalysis = new MeshAnalysisManager(); GCodeAnalysis = new GCodeAnalysisManager(); GCodeAnalysis.EnableUpdates = false; FileMonitor = new ExternalFileMonitor(); }
public void CreateToolPaths(PrintMeshAssembly meshes, PlanarSliceStack slices, PrintSettings settings) { // have to wait for valid slice stack if (slices == null) { return; } //mark_spawn_time(); this.BuildToolPaths(new GenerationTask { PrintSettings = settings.CloneCurrentSettings(), Meshes = meshes, SliceSet = slices, InterpretGCodePaths = ShowActualGCodePaths }, settings); }
public void Compute(PrintSettings settings) { RequestCancel = false; printer = new SingleMaterialFFFPrintGenerator(Meshes, SliceSet, PrintSettings); if (PrintSettings.EnableSupportReleaseOpt) { printer.LayerPostProcessor = new SupportConnectionPostProcessor() { ZOffsetMM = PrintSettings.SupportReleaseGap }; } // if we aren't interpreting GCode, we want generator to return its path set printer.AccumulatePathSet = (InterpretGCodePaths == false); // set clip region Box2d clip_box = new Box2d(Vector2d.Zero, new Vector2d(settings.BedSizeXMM / 2, settings.BedSizeYMM / 2)); printer.PathClipRegions = new List <GeneralPolygon2d>() { new GeneralPolygon2d(new Polygon2d(clip_box.ComputeVertices())) }; printer.ErrorF = (msg, trace) => { if (RequestCancel == false) { DebugUtil.Log(2, "Slicer Error! msg: {0} stack {1}", msg, trace); } }; DebugUtil.Log(2, "Generating gcode..."); try { if (printer.Generate() == false) { throw new Exception("generate failed"); // this will be caught below } gcode = printer.Result; //DebugUtil.Log(2, "Interpreting gcode..."); if (InterpretGCodePaths) { GCodeToToolpaths converter = new GCodeToToolpaths(); MakerbotInterpreter interpreter = new MakerbotInterpreter(); interpreter.AddListener(converter); InterpretArgs interpArgs = new InterpretArgs(); interpreter.Interpret(gcode, interpArgs); paths = converter.PathSet; } else { paths = printer.AccumulatedPaths; } //DebugUtil.Log(2, "Detecting layers..."); layerInfo = new LayersDetector(paths); Success = true; } catch (Exception e) { DebugUtil.Log("ToolpathGenerator.Compute: exception: " + e.Message); Success = false; } Finished = true; }
private void Settings_OnSettingModified(PrintSettings settings) { //if ( saveButton != null ) // saveButton.enabled = true; }
public void Compute(PrintSettings printSettings) { int N = meshCopies.Count(); slicer = new MeshPlanarSlicerPro() { LayerHeightMM = printSettings.LayerHeightMM, // [RMS] 1.5 here is a hack. If we don't leave a bit of space then often the filament gets squeezed right at // inside/outside transitions, which is bad. Need a better way to handle. OpenPathDefaultWidthMM = printSettings.NozzleDiameterMM * 1.5, SetMinZValue = 0, SliceFactoryF = PlanarSlicePro.FactoryF }; if (printSettings.OpenMode == PrintSettings.OpenMeshMode.Clipped) { slicer.DefaultOpenPathMode = PrintMeshOptions.OpenPathsModes.Clipped; } else if (printSettings.OpenMode == PrintSettings.OpenMeshMode.Embedded) { slicer.DefaultOpenPathMode = PrintMeshOptions.OpenPathsModes.Embedded; } else if (printSettings.OpenMode == PrintSettings.OpenMeshMode.Ignored) { slicer.DefaultOpenPathMode = PrintMeshOptions.OpenPathsModes.Ignored; } if (printSettings.StartLayers > 0) { int start_layers = printSettings.StartLayers; double std_layer_height = printSettings.LayerHeightMM; double start_layer_height = printSettings.StartLayerHeightMM; slicer.LayerHeightF = (layer_i) => { return((layer_i < start_layers) ? start_layer_height : std_layer_height); }; } try { MeshAssembly = new PrintMeshAssembly(); for (int k = 0; k < N; ++k) { DMesh3 mesh = meshCopies[k]; //Frame3f mapF = meshToScene[k]; PrintMeshSettings settings = new PrintMeshSettings(); var options = new PrintMeshOptions { IsSupport = (settings.ObjectType == PrintMeshSettings.ObjectTypes.Support), IsCavity = (settings.ObjectType == PrintMeshSettings.ObjectTypes.Cavity), IsCropRegion = (settings.ObjectType == PrintMeshSettings.ObjectTypes.CropRegion), IsOpen = settings.OuterShellOnly, OpenPathMode = PrintMeshSettings.Convert(settings.OpenMeshMode), Extended = new ExtendedPrintMeshOptions() { ClearanceXY = settings.Clearance, OffsetXY = settings.OffsetXY } }; //Vector3f scale = localScale[k]; //MeshTransforms.Scale(mesh, scale.x, scale.y, scale.z); //MeshTransforms.FromFrame(mesh, mapF); //MeshTransforms.FlipLeftRightCoordSystems(mesh); //MeshTransforms.ConvertYUpToZUp(mesh); var decomposer = new MeshAssembly(mesh) { HasNoVoids = settings.NoVoids }; decomposer.Decompose(); MeshAssembly.AddMeshes(decomposer.ClosedSolids, options); PrintMeshOptions openOptions = options.Clone(); MeshAssembly.AddMeshes(decomposer.OpenMeshes, openOptions); } if (slicer.Add(MeshAssembly) == false) { throw new Exception("error adding PrintMeshAssembly to Slicer!!"); } // set clip box Box2d clip_box = new Box2d( Vector2d.Zero, new Vector2d(printSettings.BedSizeXMM / 2, printSettings.BedSizeYMM / 2)); slicer.ValidRegions = new List <GeneralPolygon2d>() { new GeneralPolygon2d(new Polygon2d(clip_box.ComputeVertices())) }; SliceStack = slicer.Compute(); Success = true; } catch (Exception e) { //DebugUtil.Log("GeometrySlicer.Compute: exception: " + e.Message); System.Diagnostics.Debugger.Break(); Success = false; } Finished = true; }