From ee520ce88c7891a10a5590d9af03de273df2e7ce Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 23 Nov 2021 08:57:50 -0800 Subject: [PATCH 1/3] Adding more cancelation --- MatterControl.MeshOperations/CsgBySlicing.cs | 6 +++++- Submodules/agg-sharp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MatterControl.MeshOperations/CsgBySlicing.cs b/MatterControl.MeshOperations/CsgBySlicing.cs index cb350a3f8..0e3d2c0ef 100644 --- a/MatterControl.MeshOperations/CsgBySlicing.cs +++ b/MatterControl.MeshOperations/CsgBySlicing.cs @@ -99,7 +99,6 @@ namespace MatterHackers.PolygonMesh var matrix = SliceLayer.GetTransformTo0Plane(plane); transformTo0Planes[plane] = (matrix, matrix.Inverted); } - } public Mesh Calculate(CsgModes operation, @@ -118,6 +117,11 @@ namespace MatterHackers.PolygonMesh { var mesh1 = transformedMeshes[mesh1Index]; + if (cancellationToken.IsCancellationRequested) + { + return null; + } + for (int faceIndex = 0; faceIndex < mesh1.Faces.Count; faceIndex++) { var face = mesh1.Faces[faceIndex]; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 66f77f1cd..6a55bf626 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 66f77f1cd52f85b7ac3ac6b8e711ad01f32519c5 +Subproject commit 6a55bf6267d1d178666d1fda16f97a5beaeb8f5b From 93c6f6950eb2c0ceb2c37c2ae90deac97905e019 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 23 Nov 2021 10:11:25 -0800 Subject: [PATCH 2/3] Make array objects change [index] to constant on flatten issue: MatterHackers/MCCentral#6604 Make sure monotonic adjacent lines do not have lift when printing --- .../Operations/ArrayAdvancedObject3D.cs | 3 + .../Operations/ArrayLinearObject3D.cs | 37 +---------- .../DesignTools/Operations/ArrayObject3D.cs | 63 ++++++++++++++++--- .../Operations/ArrayRadialObject3D.cs | 3 + .../DesignTools/Sheets/SheetObject3D.cs | 59 ++++++++++------- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 7 files changed, 100 insertions(+), 69 deletions(-) diff --git a/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs index 3199bfff2..41948180a 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs @@ -101,6 +101,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations lastChild = next; } }); + + ProcessIndexExpressions(); + SourceContainer.Visible = false; UiThread.RunOnIdle(() => { diff --git a/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs index c57147547..a2546cbfd 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs @@ -94,42 +94,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations list.AddRange(newChildren); }); - var updateItems = SheetObject3D.SortAndLockUpdateItems(this, (item) => - { - if (!SheetObject3D.HasExpressionWithString(item, "=", true)) - { - return false; - } - - // WIP - if (item.Parent == this) - { - // only process our children that are not the source object - return !(item is OperationSourceObject3D); - } - else if (item.Parent is OperationSourceContainerObject3D) - { - // If we find another source container - // Only process its children that are the source container (they will be replicated and modified correctly by the source container) - return item is OperationSourceObject3D; - } - else if (item.Parent is OperationSourceObject3D operationSourceObject3D - && operationSourceObject3D.Parent == this) - { - // we don't need to rebuild our source object - return false; - } - - // process everything else - return true; - }); - - var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties); - - while (runningInterval.Active) - { - Thread.Sleep(10); - } + ProcessIndexExpressions(); SourceContainer.Visible = false; rebuildLock.Dispose(); diff --git a/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs index 999d607cf..c4b492acf 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs @@ -27,19 +27,68 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Threading; using MatterHackers.DataConverters3D; -using MatterHackers.Localizations; -using MatterHackers.MatterControl.DesignTools.EditableTypes; -using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools.Operations { public abstract class ArrayObject3D : OperationSourceContainerObject3D { public abstract IntOrExpression Count { get; set; } + + public override void Flatten(Agg.UI.UndoBuffer undoBuffer) + { + // convert [index] expressions to their constant values + foreach (var item in this.Descendants((item) => !(item is ArrayObject3D))) + { + foreach(var expression in SheetObject3D.GetActiveExpressions(item, "[index]", false)) + { + expression.Expression = expression.Expression.Replace("[index]", SheetObject3D.RetrieveArrayIndex(item, 0).ToString()); + } + } + + // then call base flatten + base.Flatten(undoBuffer); + } + + internal void ProcessIndexExpressions() + { + var updateItems = SheetObject3D.SortAndLockUpdateItems(this, (item) => + { + if (!SheetObject3D.HasExpressionWithString(item, "=", true)) + { + return false; + } + + // WIP + if (item.Parent == this) + { + // only process our children that are not the source object + return !(item is OperationSourceObject3D); + } + else if (item.Parent is OperationSourceContainerObject3D) + { + // If we find another source container + // Only process its children that are the source container (they will be replicated and modified correctly by the source container) + return item is OperationSourceObject3D; + } + else if (item.Parent is OperationSourceObject3D operationSourceObject3D + && operationSourceObject3D.Parent == this) + { + // we don't need to rebuild our source object + return false; + } + + // process everything else + return true; + }); + + var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties); + + while (runningInterval.Active) + { + Thread.Sleep(10); + } + } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs index 62b0b51db..35463882b 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs @@ -128,6 +128,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations list.Add(next); } }); + + ProcessIndexExpressions(); + SourceContainer.Visible = false; UiThread.RunOnIdle(() => { diff --git a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs index afd491cb6..f11fe3344 100644 --- a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs +++ b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs @@ -334,9 +334,9 @@ namespace MatterHackers.MatterControl.DesignTools return null; } - private static int RetrieveArrayIndex(IObject3D owner, int level) + public static int RetrieveArrayIndex(IObject3D item, int level) { - var arrayObject = FindParentArray(owner, level); + var arrayObject = FindParentArray(item, level); if (arrayObject != null) { @@ -345,7 +345,7 @@ namespace MatterHackers.MatterControl.DesignTools { if (!(child is OperationSourceObject3D)) { - if (child.DescendantsAndSelf().Where(i => i == owner).Any()) + if (child.DescendantsAndSelf().Where(i => i == item).Any()) { return index; } @@ -502,31 +502,42 @@ namespace MatterHackers.MatterControl.DesignTools return false; } + public static IEnumerable GetActiveExpressions(IObject3D item, string checkForString, bool startsWith) + { + foreach (var property in PublicPropertyEditor.GetEditablePropreties(item)) + { + var propertyValue = property.Value; + + if (propertyValue is IDirectOrExpression directOrExpression) + { + if (startsWith) + { + if (directOrExpression.Expression.StartsWith(checkForString)) + { + // WIP: check if the value has actually changed, this will update every object on any cell change + yield return directOrExpression; + } + } + else + { + if(directOrExpression.Expression.Contains(checkForString)) + { + yield return directOrExpression; + } + } + } + } + } + public static bool HasExpressionWithString(IObject3D itemToCheck, string checkForString, bool startsWith) { foreach (var item in itemToCheck.DescendantsAndSelf()) { - // Find all the OrReference properties on this item and check if any start with an '='. - foreach (var property in PublicPropertyEditor.GetEditablePropreties(item)) - { - var propertyValue = property.Value; - - if (propertyValue is IDirectOrExpression directOrExpression) - { - if (startsWith) - { - if (directOrExpression.Expression.StartsWith(checkForString)) - { - // WIP: check if the value has actually changed, this will update every object on any cell change - return true; - } - } - else - { - return directOrExpression.Expression.Contains(checkForString); - } - } - } + if (GetActiveExpressions(item, checkForString, startsWith).Any()) + { + // three is one so return true + return true; + } } return false; diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 939abf357..b75536cd6 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 939abf3577f5dc66a3a2d9eb02d3965dca7264f8 +Subproject commit b75536cd64b66b8c82408e1b8a2bde4988c3a4b0 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 6a55bf626..fb157253f 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 6a55bf6267d1d178666d1fda16f97a5beaeb8f5b +Subproject commit fb157253fa12976da8b533630901b330a325ab01 From 6b52e337ff23d435875dd3ac71e5130d258ec7dd Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 23 Nov 2021 18:42:47 -0800 Subject: [PATCH 3/3] latest MS & agg --- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index b75536cd6..ee639857d 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit b75536cd64b66b8c82408e1b8a2bde4988c3a4b0 +Subproject commit ee639857de9d8157d9a656d3dc76c07aba02818b diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index fb157253f..183673e00 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit fb157253fa12976da8b533630901b330a325ab01 +Subproject commit 183673e004d7c085cb970bd5b8f04fbd3f4750b1