Refactoring - moving files
This commit is contained in:
parent
50d77638c7
commit
6d6337f5aa
13 changed files with 355 additions and 282 deletions
|
|
@ -28,125 +28,17 @@ 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.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||
{
|
||||
[Obsolete("Use CombineObject3D_2 instead", false)]
|
||||
public class CombineObject3D : MeshWrapperObject3D
|
||||
{
|
||||
public CombineObject3D()
|
||||
{
|
||||
Name = "Combine";
|
||||
}
|
||||
|
||||
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
||||
{
|
||||
if ((invalidateType.InvalidateType == InvalidateType.Content
|
||||
|| invalidateType.InvalidateType == InvalidateType.Matrix
|
||||
|| invalidateType.InvalidateType == InvalidateType.Mesh)
|
||||
&& invalidateType.Source != this
|
||||
&& !RebuildLocked)
|
||||
{
|
||||
await Rebuild();
|
||||
invalidateType = new InvalidateArgs(this, InvalidateType.Content, invalidateType.UndoBuffer);
|
||||
}
|
||||
else if (invalidateType.InvalidateType == InvalidateType.Properties
|
||||
&& invalidateType.Source == this)
|
||||
{
|
||||
await Rebuild();
|
||||
invalidateType = new InvalidateArgs(this, InvalidateType.Content, invalidateType.UndoBuffer);
|
||||
}
|
||||
|
||||
base.OnInvalidate(invalidateType);
|
||||
}
|
||||
|
||||
public override Task Rebuild()
|
||||
{
|
||||
this.DebugDepth("Rebuild");
|
||||
|
||||
var rebuildLocks = this.RebuilLockAll();
|
||||
|
||||
// spin up a task to remove holes from the objects in the group
|
||||
return ApplicationController.Instance.Tasks.Execute(
|
||||
"Combine".Localize(),
|
||||
null,
|
||||
(reporter, cancellationToken) =>
|
||||
{
|
||||
var progressStatus = new ProgressStatus();
|
||||
reporter.Report(progressStatus);
|
||||
|
||||
try
|
||||
{
|
||||
Combine(cancellationToken, reporter);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
rebuildLocks.Dispose();
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
|
||||
public void Combine()
|
||||
{
|
||||
Combine(CancellationToken.None, null);
|
||||
}
|
||||
|
||||
public void Combine(CancellationToken cancellationToken, IProgress<ProgressStatus> reporter)
|
||||
{
|
||||
ResetMeshWrapperMeshes(Object3DPropertyFlags.All, cancellationToken);
|
||||
|
||||
var participants = this.Descendants().Where(o => o.OwnerID == this.ID).ToList();
|
||||
if (participants.Count() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var first = participants.First();
|
||||
|
||||
var totalOperations = participants.Count() - 1;
|
||||
double amountPerOperation = 1.0 / totalOperations;
|
||||
double percentCompleted = 0;
|
||||
|
||||
ProgressStatus progressStatus = new ProgressStatus();
|
||||
foreach (var item in participants)
|
||||
{
|
||||
if (item != first)
|
||||
{
|
||||
var result = BooleanProcessing.Do(item.Mesh, item.WorldMatrix(),
|
||||
first.Mesh, first.WorldMatrix(),
|
||||
0,
|
||||
reporter, amountPerOperation, percentCompleted, progressStatus, cancellationToken);
|
||||
|
||||
var inverse = first.WorldMatrix();
|
||||
inverse.Invert();
|
||||
result.Transform(inverse);
|
||||
using (first.RebuildLock())
|
||||
{
|
||||
first.Mesh = result;
|
||||
}
|
||||
|
||||
percentCompleted += amountPerOperation;
|
||||
progressStatus.Progress0To1 = percentCompleted;
|
||||
reporter?.Report(progressStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CombineObject3D_2 : OperationSourceContainerObject3D
|
||||
{
|
||||
public CombineObject3D_2()
|
||||
Loading…
Add table
Add a link
Reference in a new issue