From 6346f075ef2259594b25c8ebdfe2e17f41eef56a Mon Sep 17 00:00:00 2001 From: jlewin Date: Wed, 22 May 2019 16:20:22 -0700 Subject: [PATCH] Use new untyped Parents member --- .../DesignTools/EditorTools/LithophanePlugin.cs | 4 +--- .../DesignTools/GeneratedSupportObject3D.cs | 10 ---------- MatterControlLib/DesignTools/SupportGenerator.cs | 7 +++++-- .../PartPreviewWindow/GenerateSupportPanel.cs | 3 ++- .../PartPreviewWindow/RoundedToggleSwitch.cs | 1 + 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs index 94d02dfe3..686ac9ec2 100644 --- a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs +++ b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs @@ -36,9 +36,7 @@ using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.DesignTools; -using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.MatterControl.Extensibility; -using MatterHackers.MatterControl.PartPreviewWindow.View3D; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.Plugins.Lithophane @@ -63,7 +61,7 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane if (scene != null) { - var topParent = wrapper.Parents().LastOrDefault((i) => i.Parent != null); + var topParent = wrapper.Parents().LastOrDefault(i => i.Parent != null); UiThread.RunOnIdle(() => { scene.SelectedItem = topParent != null ? topParent : wrapper; diff --git a/MatterControlLib/DesignTools/GeneratedSupportObject3D.cs b/MatterControlLib/DesignTools/GeneratedSupportObject3D.cs index ed37c1fa0..285885820 100644 --- a/MatterControlLib/DesignTools/GeneratedSupportObject3D.cs +++ b/MatterControlLib/DesignTools/GeneratedSupportObject3D.cs @@ -27,17 +27,7 @@ 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; -using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.DataConverters3D; -using MatterHackers.MatterControl.PartPreviewWindow; -using MatterHackers.PolygonMesh; -using MatterHackers.RayTracer; -using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { diff --git a/MatterControlLib/DesignTools/SupportGenerator.cs b/MatterControlLib/DesignTools/SupportGenerator.cs index e69813ced..14f87be42 100644 --- a/MatterControlLib/DesignTools/SupportGenerator.cs +++ b/MatterControlLib/DesignTools/SupportGenerator.cs @@ -143,7 +143,7 @@ namespace MatterHackers.MatterControl.DesignTools return BoundingVolumeHierarchy.CreateNewHierachy(allPolys, maxRecursion); } - public Task Create(IProgress progress, CancellationToken cancelationToken) + public Task Create(IProgress progress, CancellationToken cancellationToken) { var selectedItem = scene.SelectedItem; @@ -179,6 +179,7 @@ namespace MatterHackers.MatterControl.DesignTools Math.Floor((double)(suppoortBounds.MinXYZ.Y / PillarSize)), Math.Ceiling(suppoortBounds.MaxXYZ.X / PillarSize), Math.Ceiling(suppoortBounds.MaxXYZ.Y / PillarSize)); + var partBounds = new RectangleDouble(gridBounds.Left * PillarSize, gridBounds.Bottom * PillarSize, gridBounds.Right * PillarSize, @@ -187,6 +188,7 @@ namespace MatterHackers.MatterControl.DesignTools int gridWidth = (int)gridBounds.Width; int gridHeight = (int)gridBounds.Height; var supportGrid = new List>>(); + for (int x = 0; x < gridWidth; x++) { supportGrid.Add(new List>()); @@ -320,6 +322,7 @@ namespace MatterHackers.MatterControl.DesignTools { bool fromBed = SupportType == SupportGenerationType.From_Bed; var halfPillar = PillarSize / 2; + foreach (var kvp in supportGrid) { var supportColumnData = kvp.Value; @@ -360,12 +363,12 @@ namespace MatterHackers.MatterControl.DesignTools { // add all the faces var matrix = item.WorldMatrix(scene); + for (int faceIndex = 0; faceIndex < item.Mesh.Faces.Count; faceIndex++) { var face0Normal = item.Mesh.Faces[faceIndex].normal.TransformNormal(matrix).GetNormal(); var face = item.Mesh.Faces[faceIndex]; - var verts = new int[] { face.v0, face.v1, face.v2 }; var p0 = item.Mesh.Vertices[face.v0].Transform(matrix); var p1 = item.Mesh.Vertices[face.v1].Transform(matrix); var p2 = item.Mesh.Vertices[face.v2].Transform(matrix); diff --git a/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs b/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs index 9194b3fcb..db53a0469 100644 --- a/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs +++ b/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs @@ -138,7 +138,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { return ApplicationController.Instance.Tasks.Execute( "Create Support".Localize(), - null, supportGenerator.Create); + null, + supportGenerator.Create); } } } \ No newline at end of file diff --git a/MatterControlLib/PartPreviewWindow/RoundedToggleSwitch.cs b/MatterControlLib/PartPreviewWindow/RoundedToggleSwitch.cs index 905e35af7..67fd89eea 100644 --- a/MatterControlLib/PartPreviewWindow/RoundedToggleSwitch.cs +++ b/MatterControlLib/PartPreviewWindow/RoundedToggleSwitch.cs @@ -49,6 +49,7 @@ namespace MatterHackers.MatterControl.CustomWidgets { animationRatio += 1.0 / 7.0; } + if (animationRatio >= 1) { Stop();