Working on union validation

This commit is contained in:
LarsBrubaker 2022-06-30 08:20:35 -07:00
parent 39b08fa683
commit 2acc7ed180
3 changed files with 47 additions and 4 deletions

View file

@ -72,7 +72,45 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
private ProcessingResolution InputResolution { get; set; } = ProcessingResolution._64;
#endif
public bool IsBuilding => this.cancellationToken != null;
public static void CheckManifoldData(CombineObject3D_2 item, IObject3D result)
{
bool IsManifold(Mesh mesh)
{
var meshEdgeList = mesh.NewMeshEdges();
foreach (var meshEdge in meshEdgeList)
{
if (meshEdge.Faces.Count() != 2)
{
return false;
}
}
return true;
}
if (!IsManifold(result.Mesh))
{
// create a new combine of a and b and add it to the root
var combine = new CombineObject3D_2();
var participants = item.SourceContainer.VisibleMeshes().Where(m => m.WorldOutputType(item.SourceContainer) != PrintOutputTypes.Hole);
// all participants are manifold
foreach (var participant in participants)
{
combine.SourceContainer.Children.Add(new Object3D()
{
Mesh = participant.Mesh.Copy(new CancellationToken()),
Matrix = participant.Matrix
});
}
var scene = result.Parents().Last();
scene.Children.Add(combine);
}
}
public override Task Rebuild()
{
this.DebugDepth("Rebuild");
@ -183,7 +221,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
resultsItem.CopyProperties(participants.First(), Object3DPropertyFlags.All & (~Object3DPropertyFlags.Matrix));
this.Children.Add(resultsItem);
SourceContainer.Visible = false;
#if DEBUG
//resultsItem.Mesh.MergeVertices(.01);
//resultsItem.Mesh.CleanAndMerge();
//CheckManifoldData(this, resultsItem);
#endif
SourceContainer.Visible = false;
}
public void UpdateControls(PublicPropertyChange change)

@ -1 +1 @@
Subproject commit d30433b04424d0af57fa22e0bf8cec077ac41b2a
Subproject commit ab65243a2b19b8e1a8668443ffb7c8ec0c2b2911

@ -1 +1 @@
Subproject commit 4af60a9822345f3bf6800ede7d5b6c6948ea0dc9
Subproject commit 1d16b11a1d3eb375996808be4ae174e98600edf6