Improving Plus operation to be more efficient when building dynamic content

Added a rebuild to ImageObject3D
This commit is contained in:
LarsBrubaker 2019-02-02 16:46:54 -08:00
parent a32451635c
commit 5786db9417
3 changed files with 38 additions and 12 deletions

View file

@ -231,19 +231,37 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return output;
}
public static IObject3D Plus(this IObject3D a, IObject3D b)
/// <summary>
/// Union a and b together. This can either return a single item with a mesh on it
/// or a group item that has the a and be itmes as children
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="doMeshCombine"></param>
/// <returns></returns>
public static IObject3D Plus(this IObject3D a, IObject3D b, bool doMeshCombine = false)
{
var combine = new CombineObject3D_2();
combine.Children.Add(a.Clone());
combine.Children.Add(b.Clone());
combine.Combine();
var finalMesh = combine.VisibleMeshes().First().Mesh;
return new Object3D()
if (doMeshCombine)
{
Mesh = finalMesh
};
var combine = new CombineObject3D_2();
combine.Children.Add(a.Clone());
combine.Children.Add(b.Clone());
combine.Combine();
var finalMesh = combine.VisibleMeshes().First().Mesh;
return new Object3D()
{
Mesh = finalMesh
};
}
else
{
var group = new GroupObject3D();
group.Children.Add(a);
group.Children.Add(b);
return group;
}
}
public static IObject3D Minus(this IObject3D a, IObject3D b)

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.ImageProcessing;
@ -172,6 +173,13 @@ namespace MatterHackers.MatterControl.DesignTools
public double ScaleMmPerPixels { get; private set; }
public override Task Rebuild()
{
InitMesh();
return base.Rebuild();
}
private Mesh InitMesh()
{
if (!string.IsNullOrWhiteSpace(this.AssetPath))