Added the ability to do marching squares subtractions
This commit is contained in:
parent
3988b47019
commit
61aa0bd24a
11 changed files with 396 additions and 206 deletions
|
|
@ -35,7 +35,9 @@ 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
|
||||
|
|
@ -47,6 +49,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
Name = "Intersection";
|
||||
}
|
||||
|
||||
[EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)]
|
||||
public BooleanProcessing.ProcessingModes Processing { get; set; } = BooleanProcessing.ProcessingModes.Exact;
|
||||
|
||||
public override Task Rebuild()
|
||||
{
|
||||
this.DebugDepth("Rebuild");
|
||||
|
|
@ -103,38 +108,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
return;
|
||||
}
|
||||
|
||||
var first = participants.First();
|
||||
var resultsMesh = first.Mesh;
|
||||
var firstWorldMatrix = first.WorldMatrix(SourceContainer);
|
||||
|
||||
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 itemWorldMatrix = item.WorldMatrix(SourceContainer);
|
||||
resultsMesh = BooleanProcessing.Do(item.Mesh, itemWorldMatrix,
|
||||
resultsMesh, firstWorldMatrix,
|
||||
CsgModes.Intersect,
|
||||
reporter, amountPerOperation, percentCompleted, progressStatus, cancellationToken);
|
||||
// after the first union we are working with the transformed mesh and don't need the first transform
|
||||
firstWorldMatrix = Matrix4X4.Identity;
|
||||
|
||||
percentCompleted += amountPerOperation;
|
||||
progressStatus.Progress0To1 = percentCompleted;
|
||||
reporter?.Report(progressStatus);
|
||||
}
|
||||
}
|
||||
var items = participants.Select(i => (i.Mesh, i.WorldMatrix(SourceContainer)));
|
||||
var resultsMesh = BooleanProcessing.DoArray(items,
|
||||
BooleanProcessing.CsgModes.Intersect,
|
||||
Processing,
|
||||
reporter,
|
||||
cancellationToken);
|
||||
|
||||
var resultsItem = new Object3D()
|
||||
{
|
||||
Mesh = resultsMesh
|
||||
};
|
||||
resultsItem.CopyProperties(first, Object3DPropertyFlags.All & (~Object3DPropertyFlags.Matrix));
|
||||
resultsItem.CopyProperties(participants.First(), Object3DPropertyFlags.All & (~Object3DPropertyFlags.Matrix));
|
||||
this.Children.Add(resultsItem);
|
||||
SourceContainer.Visible = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue