Improving curve and pinch to have more base class code sharing

Cleaning up flags
Refactoring
This commit is contained in:
LarsBrubaker 2018-05-27 08:48:31 -07:00
parent d7b885e6d0
commit 734fa69134
7 changed files with 43 additions and 90 deletions

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.DataConverters3D.UndoCommands;
@ -173,7 +174,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
}
}
public void ResetMeshWrappers(Object3DPropertyFlags flags)
public IEnumerable<(IObject3D original, IObject3D meshCopy)> MeshObjects()
{
return this.Descendants()
.Where((obj) => obj.OwnerID == this.ID)
.Select((mw) => (mw.Children.First(), mw));
}
public void ResetMeshWrapperMeshes(Object3DPropertyFlags flags, CancellationToken cancellationToken)
{
// if there are not already, wrap all meshes with our id (some inner object may have changed it's meshes)
AddMeshWrapperToAllChildren();
@ -183,8 +191,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
foreach (var item in participants)
{
var firstChild = item.Children.First();
// set the mesh back to the child mesh
item.Mesh = firstChild.Mesh;
// set the mesh back to a copy of the child mesh
item.Mesh = Mesh.Copy(firstChild.Mesh, cancellationToken);
// and reset the properties
item.CopyProperties(firstChild, flags & (~Object3DPropertyFlags.Matrix));
}

View file

@ -161,7 +161,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
subtractObject3D.Rebuilding = true;
// make sure the mesh on the group is not visible
subtractObject3D.ResetMeshWrappers(Object3DPropertyFlags.All);
subtractObject3D.ResetMeshWrapperMeshes(Object3DPropertyFlags.All, CancellationToken.None);
foreach (var keyValue in objectChecks)
{

View file

@ -62,7 +62,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
public override void Rebuild(UndoBuffer undoBuffer)
{
Rebuilding = true;
ResetMeshWrappers(Object3DPropertyFlags.All & (~Object3DPropertyFlags.OutputType));
ResetMeshWrapperMeshes(Object3DPropertyFlags.All & (~Object3DPropertyFlags.OutputType), CancellationToken.None);
// spin up a task to remove holes from the objects in the group
ApplicationController.Instance.Tasks.Execute(