diff --git a/MatterControl.MeshOperations/BooleanProcessing.cs b/MatterControl.MeshOperations/BooleanProcessing.cs index bf08be52a..adcffb18f 100644 --- a/MatterControl.MeshOperations/BooleanProcessing.cs +++ b/MatterControl.MeshOperations/BooleanProcessing.cs @@ -68,9 +68,13 @@ namespace MatterHackers.PolygonMesh public enum ProcessingModes { + [Description("Default CSG processing")] Polygons, - ExactLegacy, + [Description("Use libigl (windows only)")] + libigl, + [Description("Experimental Marching Cubes")] Marching_Cubes, + [Description("Experimental Dual Contouring")] Dual_Contouring, } @@ -105,7 +109,7 @@ namespace MatterHackers.PolygonMesh { return ExactBySlicing(items, operation, reporter, cancellationToken); } - else if (processingMode == ProcessingModes.ExactLegacy) + else if (processingMode == ProcessingModes.libigl) { return ExactLegacy(items, operation, processingMode, inputResolution, outputResolution, reporter, cancellationToken); } @@ -501,6 +505,7 @@ namespace MatterHackers.PolygonMesh } } + resultsMesh.CleanAndMerge(); return resultsMesh; } @@ -615,7 +620,7 @@ namespace MatterHackers.PolygonMesh reporter, cancellationToken); } - else if (processingMode == ProcessingModes.ExactLegacy) + else if (processingMode == ProcessingModes.libigl) { // only try to run the improved booleans if we are 64 bit and it is there if (externalAssemblyExists && IntPtr.Size == 8) diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs index f41dade4c..b9383f487 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs @@ -49,8 +49,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D Name = "Combine"; } -#if DEBUG - [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] @@ -61,12 +59,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#else - private BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; - private BooleanProcessing.ProcessingResolution OutputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; - private BooleanProcessing.IplicitSurfaceMethod MeshAnalysis { get; set; } - private BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#endif public override Task Rebuild() { @@ -145,12 +137,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } } + private bool ProcessPolygons + { + get => Processing == BooleanProcessing.ProcessingModes.Polygons || Processing == BooleanProcessing.ProcessingModes.libigl; + } + public void UpdateControls(PublicPropertyChange change) { - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(OutputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(MeshAnalysis), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(OutputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(MeshAnalysis), () => !ProcessPolygons); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); } } } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs index a0e5855f5..683859d56 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs @@ -49,8 +49,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D Name = "Intersection"; } -#if DEBUG - [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] @@ -61,12 +59,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#else - private BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; - private BooleanProcessing.ProcessingResolution OutputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; - private BooleanProcessing.IplicitSurfaceMethod MeshAnalysis { get; set; } - private BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#endif public override Task Rebuild() { @@ -145,12 +137,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } } + private bool ProcessPolygons + { + get => Processing == BooleanProcessing.ProcessingModes.Polygons || Processing == BooleanProcessing.ProcessingModes.libigl; + } + public void UpdateControls(PublicPropertyChange change) { - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(OutputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(MeshAnalysis), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(OutputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(MeshAnalysis), () => !ProcessPolygons); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); } } } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs index 6c3e95230..63d4ad344 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs @@ -59,8 +59,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [DisplayName("Part(s) to Subtract and Replace")] public SelectedChildren SelectedChildren { get; set; } = new SelectedChildren(); -#if DEBUG - [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] @@ -71,12 +69,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#else - private BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; - private BooleanProcessing.ProcessingResolution OutputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; - private BooleanProcessing.IplicitSurfaceMethod MeshAnalysis { get; set; } - private BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#endif public void DrawEditor(Object3DControlsLayer layer, List transparentMeshes, DrawEventArgs e) { @@ -357,12 +349,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } } + private bool ProcessPolygons + { + get => Processing == BooleanProcessing.ProcessingModes.Polygons || Processing == BooleanProcessing.ProcessingModes.libigl; + } + public void UpdateControls(PublicPropertyChange change) { - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(OutputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(MeshAnalysis), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(OutputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(MeshAnalysis), () => !ProcessPolygons); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); } } } \ No newline at end of file diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs index ce1dadf86..88fbb3c62 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs @@ -56,8 +56,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [DisplayName("Part(s) to Subtract")] public SelectedChildren SelectedChildren { get; set; } = new SelectedChildren(); -#if DEBUG - [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] @@ -68,12 +66,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#else - private BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Polygons; - private BooleanProcessing.ProcessingResolution OutputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; - private BooleanProcessing.IplicitSurfaceMethod MeshAnalysis { get; set; } - private BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64; -#endif + public bool RemoveSubtractObjects { get; set; } = true; public void DrawEditor(Object3DControlsLayer layer, List transparentMeshes, DrawEventArgs e) @@ -331,12 +324,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } } + private bool ProcessPolygons + { + get => Processing == BooleanProcessing.ProcessingModes.Polygons || Processing == BooleanProcessing.ProcessingModes.libigl; + } + public void UpdateControls(PublicPropertyChange change) { - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(OutputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(MeshAnalysis), () => Processing != BooleanProcessing.ProcessingModes.Polygons); - change.SetRowVisible(nameof(InputResolution), () => Processing != BooleanProcessing.ProcessingModes.Polygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(OutputResolution), () => !ProcessPolygons); + change.SetRowVisible(nameof(MeshAnalysis), () => !ProcessPolygons); + change.SetRowVisible(nameof(InputResolution), () => !ProcessPolygons && MeshAnalysis == BooleanProcessing.IplicitSurfaceMethod.Grid); } } } \ No newline at end of file diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 6f186b40a..5d28a459f 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 6f186b40afc527eeb20eb8380f26f4102b1e7ac2 +Subproject commit 5d28a459fcccec0e5aed236b35c02d47dc67b40d