commit
dbe3e5f609
2 changed files with 127 additions and 73 deletions
|
|
@ -27,6 +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.Threading.Tasks;
|
||||
using DualContouring;
|
||||
using g3;
|
||||
|
|
@ -49,6 +50,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
Boxes_3,
|
||||
Sphere,
|
||||
Cylinder,
|
||||
Subtract,
|
||||
}
|
||||
|
||||
public DualContouringObject3D()
|
||||
|
|
@ -100,7 +102,17 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
this.DebugDepth("Rebuild");
|
||||
|
||||
return Task.Run(() =>
|
||||
var title = "Dual Contouring";
|
||||
|
||||
if (Ouptput != OuptutTypes.DualContouring)
|
||||
{
|
||||
title = "Marching Cubes";
|
||||
}
|
||||
|
||||
return ApplicationController.Instance.Tasks.Execute(
|
||||
title,
|
||||
null,
|
||||
(reporter, cancellationTokenSource) =>
|
||||
{
|
||||
using (RebuildLock())
|
||||
{
|
||||
|
|
@ -168,13 +180,51 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
Height = Size
|
||||
};
|
||||
break;
|
||||
|
||||
case Shapes.Subtract:
|
||||
shape = new Intersection()
|
||||
{
|
||||
Items = new ISdf[]
|
||||
{
|
||||
new Subtraction()
|
||||
{
|
||||
Items = new ISdf[]
|
||||
{
|
||||
new Sphere()
|
||||
{
|
||||
Radius = Size
|
||||
},
|
||||
new Transform(new Cylinder()
|
||||
{
|
||||
Height = Size*2,
|
||||
Radius = Size/2
|
||||
}, Matrix4X4.CreateRotationX(MathHelper.Tau / 4)),
|
||||
new Transform(new Cylinder()
|
||||
{
|
||||
Height = Size*2,
|
||||
Radius = Size/2
|
||||
}, Matrix4X4.CreateRotationY(MathHelper.Tau / 4)),
|
||||
new Cylinder()
|
||||
{
|
||||
Height = Size*2,
|
||||
Radius = Size/2
|
||||
}
|
||||
}
|
||||
},
|
||||
new Box()
|
||||
{
|
||||
Size = new Vector3(Size * 1.5, Size * 1.5, Size * 1.5)
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
var bounds = shape.Bounds;
|
||||
bounds.Expand(.1);
|
||||
if (Iterations > 7)
|
||||
if (Iterations > 8)
|
||||
{
|
||||
Iterations = 7;
|
||||
Iterations = 8;
|
||||
}
|
||||
|
||||
if (Ouptput == OuptutTypes.DualContouring)
|
||||
|
|
@ -187,10 +237,14 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
var min = shape.Bounds.MinXYZ;
|
||||
var max = shape.Bounds.MaxXYZ;
|
||||
var size = shape.Bounds.Size;
|
||||
var maxSize = Math.Max(size.X, Math.Max(size.Y, size.Z));
|
||||
|
||||
var c = new MarchingCubes()
|
||||
{
|
||||
Implicit = new SdfToImplicit(shape),
|
||||
Bounds = new AxisAlignedBox3d(min.X, min.Y, min.Z, max.X, max.Y, max.Z),
|
||||
CubeSize = maxSize / Math.Pow(2, Iterations)
|
||||
};
|
||||
c.Generate();
|
||||
MeshNormals.QuickCompute(c.Mesh); // generate normals
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 84b6947e49f3fb1cdb5e777ecf7451f8369c91ea
|
||||
Subproject commit ad2d82da3826dd2f64b4b1ab6d696a7c758539d7
|
||||
Loading…
Add table
Add a link
Reference in a new issue