Improved maintain height code

This commit is contained in:
Lars Brubaker 2018-01-29 17:05:55 -08:00
parent 864c71ad0c
commit af30e9784c
9 changed files with 58 additions and 52 deletions

View file

@ -60,12 +60,8 @@ namespace MatterHackers.MatterControl.DesignTools
public void Rebuild()
{
var aabb = AxisAlignedBoundingBox.Zero;
if (Mesh != null)
{
// Keep track of the mesh height so it does not move around unexpectedly
this.GetAxisAlignedBoundingBox();
}
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
path.MoveTo(0, 0);
path.LineTo(Diameter / 2, 0);
@ -73,7 +69,11 @@ namespace MatterHackers.MatterControl.DesignTools
Mesh = VertexSourceToMesh.Revolve(path, Sides);
Mesh.CleanAndMergeMesh(CancellationToken.None);
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -144,9 +144,9 @@ public class ChairFoot2 : MatterCadObject3D
public double Depth { get; set; } = 20;
public double Height { get; set; } = 20;
public static ConeObject3D Create()
public static CubeObject3D Create()
{
var item = new ConeObject3D();
var item = new CubeObject3D();
item.Rebuild();
return item;
}
@ -166,15 +166,15 @@ public class ChairFoot2 : MatterCadObject3D
public void Rebuild()
{
var aabb = AxisAlignedBoundingBox.Zero;
if (Mesh != null)
{
// Keep track of the mesh height so it does not move around unexpectedly
this.GetAxisAlignedBoundingBox();
}
var aabb = this.GetAxisAlignedBoundingBox();
Mesh = PlatonicSolids.CreateCube(Width, Depth, Height);
Mesh.CleanAndMergeMesh(CancellationToken.None);
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -72,12 +72,7 @@ namespace MatterHackers.MatterControl.DesignTools
public void Rebuild()
{
var aabb = AxisAlignedBoundingBox.Zero;
if (Mesh != null)
{
// Keep track of the mesh height so it does not move around unexpectedly
this.GetAxisAlignedBoundingBox();
}
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
path.MoveTo(0, -Height / 2);
@ -109,7 +104,12 @@ namespace MatterHackers.MatterControl.DesignTools
}
Mesh.CleanAndMergeMesh(CancellationToken.None);
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -57,12 +57,8 @@ namespace MatterHackers.MatterControl.DesignTools
public void Rebuild()
{
var aabb = AxisAlignedBoundingBox.Zero;
if (Mesh != null)
{
// Keep track of the mesh height so it does not move around unexpectedly
this.GetAxisAlignedBoundingBox();
}
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
path.MoveTo(0, 0);
path.LineTo(Diameter / 2, 0);
@ -71,7 +67,11 @@ namespace MatterHackers.MatterControl.DesignTools
Mesh = VertexSourceToMesh.Revolve(path, Sides);
Mesh.CleanAndMergeMesh(CancellationToken.None);
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -57,12 +57,7 @@ namespace MatterHackers.MatterControl.DesignTools
public void Rebuild()
{
var aabb = AxisAlignedBoundingBox.Zero;
if (Mesh != null)
{
// Keep track of the mesh height so it does not move around unexpectedly
this.GetAxisAlignedBoundingBox();
}
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
path.MoveTo(0, 0);
@ -73,7 +68,11 @@ namespace MatterHackers.MatterControl.DesignTools
Mesh.Transform(Matrix4X4.CreateRotationZ(MathHelper.DegreesToRadians(45)) * Matrix4X4.CreateScale(Width / 2, Depth / 2, 1));
Mesh.CleanAndMergeMesh(CancellationToken.None);
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -59,12 +59,8 @@ namespace MatterHackers.MatterControl.DesignTools
public void Rebuild()
{
var aabb = AxisAlignedBoundingBox.Zero;
if (Mesh != null)
{
// Keep track of the mesh height so it does not move around unexpectedly
this.GetAxisAlignedBoundingBox();
}
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
var angleDelta = MathHelper.Tau / 2 / LatitudeSides;
var angle = -MathHelper.Tau / 4;
@ -77,7 +73,11 @@ namespace MatterHackers.MatterControl.DesignTools
}
Mesh = VertexSourceToMesh.Revolve(path, LongitudeSides);
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -89,6 +89,8 @@ namespace MatterHackers.MatterControl.DesignTools
public void Rebuild()
{
var aabb = this.GetAxisAlignedBoundingBox();
var letterPrinter = new TypeFacePrinter(NameToWrite, new StyledTypeFace(NamedTypeFaceCache.GetTypeFace(Font), PointSize * 0.352778));
IObject3D nameMesh = new Object3D()
@ -102,6 +104,11 @@ namespace MatterHackers.MatterControl.DesignTools
list.Clear();
list.Add(nameMesh);
});
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -63,12 +63,8 @@ namespace MatterHackers.MatterControl.DesignTools
public void Rebuild()
{
var aabb = AxisAlignedBoundingBox.Zero;
if (Mesh != null)
{
// Keep track of the mesh height so it does not move around unexpectedly
this.GetAxisAlignedBoundingBox();
}
var aabb = this.GetAxisAlignedBoundingBox();
var poleRadius = (OuterDiameter / 2 - InnerDiameter / 2) / 2;
var toroidRadius = InnerDiameter / 2 + poleRadius;
var path = new VertexStorage();
@ -84,7 +80,11 @@ namespace MatterHackers.MatterControl.DesignTools
Mesh = VertexSourceToMesh.Revolve(path, ToroidSides);
Mesh.CleanAndMergeMesh(CancellationToken.None);
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

@ -1 +1 @@
Subproject commit b0c51144b762d465bea298efa7e80452966268f7
Subproject commit 6b6552e231b9b382f030558d1e6f5795f4a6f5fb