Adding hole processing to curve

This commit is contained in:
Lars Brubaker 2022-04-29 18:05:06 -07:00
parent ce9019884f
commit ab6a75c586
2 changed files with 35 additions and 2 deletions

View file

@ -677,11 +677,16 @@ namespace MatterHackers.MatterControl
return new SceneOperation("Align")
{
OperationType = typeof(IObject3D),
ResultType = typeof(AlignObject3D_3),
ResultType = typeof(AlignObject3D_2),
TitleGetter = () => "Align".Localize(),
Action = (sceneContext) =>
{
new AlignObject3D_3().WrapSelectedItemAndSelect(sceneContext.Scene);
var scene = sceneContext.Scene;
var selectedItem = scene.SelectedItem;
var align = new AlignObject3D_2();
align.AddSelectionAsChildren(scene, selectedItem);
align.Name = align.NameFromChildren();
align.NameOverriden = false;
},
Icon = (theme) => StaticData.Instance.LoadIcon("align_left_dark.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(),
HelpTextGetter = () => "At least 2 parts must be selected".Localize().Stars(),

View file

@ -31,6 +31,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg;
@ -39,6 +40,7 @@ using MatterHackers.DataConverters3D;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.DesignTools.Operations;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.MatterControl.PartPreviewWindow.View3D;
using MatterHackers.PolygonMesh;
using MatterHackers.RenderOpenGl;
using MatterHackers.RenderOpenGl.OpenGl;
@ -351,6 +353,32 @@ namespace MatterHackers.MatterControl.DesignTools
initialAabb.MinXYZ.Z - postAabb.MinXYZ.Z);
}
var removeItems = Children.Where(c => c.OutputType == PrintOutputTypes.Hole && c.Visible);
if (removeItems.Any())
{
var keepItems = Children.Where(c => c.OutputType != PrintOutputTypes.Hole && c.Visible);
// apply any holes before we return
var resultItems = SubtractObject3D_2.DoSubtract(this,
keepItems,
removeItems,
reporter,
cancellationToken.Token);
RemoveAllButSource();
// add back in the results of the hole removal
Children.Modify(list =>
{
foreach (var child in resultItems)
{
list.Add(child);
child.Visible = true;
}
});
}
this.cancellationToken = null;
UiThread.RunOnIdle(() =>
{