new support test
This commit is contained in:
parent
a6f0ef439d
commit
c9a67150ae
3 changed files with 33 additions and 6 deletions
|
|
@ -80,8 +80,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public class SupportGenerator
|
||||
{
|
||||
private double minimumSupportHeight;
|
||||
private InteractiveScene scene;
|
||||
private readonly double minimumSupportHeight;
|
||||
private readonly InteractiveScene scene;
|
||||
|
||||
public SupportGenerator(InteractiveScene scene, double minimumSupportHeight)
|
||||
{
|
||||
|
|
@ -427,14 +427,15 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
// add a single plane at the bed so we always know the bed is a top
|
||||
detectedPlanes.Add((x, y), new List<(double z, bool bottom)>());
|
||||
detectedPlanes[(x, y)].Add((0, false));
|
||||
|
||||
IntersectInfo upHit = null;
|
||||
|
||||
for (double yOffset = -1; yOffset <= 1; yOffset++)
|
||||
{
|
||||
for (double xOffset = -1; xOffset <= 1; xOffset++)
|
||||
{
|
||||
var singlXyPlanes = new List<(double z, bool bottom)>();
|
||||
singlXyPlanes.Add((0, false));
|
||||
|
||||
var halfPillar = PillarSize / 2;
|
||||
var yPos = (gridBounds.Bottom + y) * PillarSize + halfPillar + (yOffset * halfPillar);
|
||||
var xPos = (gridBounds.Left + x) * PillarSize + halfPillar + (xOffset * halfPillar);
|
||||
|
|
@ -446,7 +447,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
upHit = traceData.GetClosestIntersection(upRay);
|
||||
if (upHit != null)
|
||||
{
|
||||
detectedPlanes[(x, y)].Add((upHit.HitPosition.Z, true));
|
||||
singlXyPlanes.Add((upHit.HitPosition.Z, true));
|
||||
|
||||
// make a new ray just past the last hit to keep looking for up hits
|
||||
upRay = new Ray(new Vector3(xPos, yPos, upHit.HitPosition.Z + .001), Vector3.UnitZ, intersectionType: IntersectionType.FrontFace);
|
||||
|
|
@ -460,12 +461,14 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
upHit = traceData.GetClosestIntersection(upRay);
|
||||
if (upHit != null)
|
||||
{
|
||||
detectedPlanes[(x, y)].Add((upHit.HitPosition.Z, false));
|
||||
singlXyPlanes.Add((upHit.HitPosition.Z, false));
|
||||
|
||||
// make a new ray just past the last hit to keep looking for up hits
|
||||
upRay = new Ray(new Vector3(xPos, yPos, upHit.HitPosition.Z + .001), Vector3.UnitZ, intersectionType: IntersectionType.BackFace);
|
||||
}
|
||||
} while (upHit != null);
|
||||
|
||||
// union the sigleXyPlanes into detectedPlanes[(x, y)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ using MatterHackers.Agg.Platform;
|
|||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.PolygonMesh.Processors;
|
||||
using MatterHackers.VectorMath;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
|
@ -468,6 +470,28 @@ namespace MatterControl.Tests.MatterControl
|
|||
|
||||
Assert.AreEqual(bedSupportCount, airSupportCount, "Same number of support columns in each space.");
|
||||
}
|
||||
|
||||
// load a complex part that should have no support required
|
||||
{
|
||||
InteractiveScene scene = new InteractiveScene();
|
||||
|
||||
var meshPath = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestParts", "NoSupportNeeded.stl");
|
||||
|
||||
var supportObject = new Object3D()
|
||||
{
|
||||
Mesh = StlProcessing.Load(meshPath, CancellationToken.None)
|
||||
};
|
||||
|
||||
var aabbCube = supportObject.GetAxisAlignedBoundingBox();
|
||||
// move it so the bottom is on the bed
|
||||
supportObject.Matrix = Matrix4X4.CreateTranslation(0, 0, -aabbCube.MinXYZ.Z);
|
||||
scene.Children.Add(supportObject);
|
||||
|
||||
var supportGenerator = new SupportGenerator(scene, minimumSupportHeight);
|
||||
supportGenerator.SupportType = SupportGenerator.SupportGenerationType.Normal;
|
||||
await supportGenerator.Create(null, CancellationToken.None);
|
||||
Assert.AreEqual(1, scene.Children.Count, "We should not have added support");
|
||||
}
|
||||
}
|
||||
|
||||
[Test, Category("Support Generator")]
|
||||
|
|
|
|||
BIN
Tests/TestData/TestParts/NoSupportNeeded.stl
Normal file
BIN
Tests/TestData/TestParts/NoSupportNeeded.stl
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue