public async Task AabbCalculatedCorrectlyForCurvedFitObjects() { AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); // Automation runner must do as much as program.cs to spin up platform string platformFeaturesProvider = "MatterHackers.MatterControl.WindowsPlatformsFeatures, MatterControl.Winforms"; AppContext.Platform = AggContext.CreateInstanceFrom <INativePlatformFeatures>(platformFeaturesProvider); AppContext.Platform.ProcessCommandline(); var root = new Object3D(); var cube = await CubeObject3D.Create(20, 20, 20); var fit = await FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; Assert.IsTrue(fit.GetAxisAlignedBoundingBox().Equals(new AxisAlignedBoundingBox(new Vector3(-25, -10, -10), new Vector3(25, 10, 10)), 1.0)); var curve = new CurveObject3D_2(); curve.Children.Add(fit); await curve.Rebuild(); var curveAabb = curve.GetAxisAlignedBoundingBox(); root.Children.Add(curve); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-17.5, -9.9, -10), new Vector3(17.5, 11.97, 10)), 1.0)); }
public async Task AabbCalculatedCorrectlyForAlignedFitObject() { AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); // Automation runner must do as much as program.cs to spin up platform string platformFeaturesProvider = "MatterHackers.MatterControl.WindowsPlatformsFeatures, MatterControl.Winforms"; AppContext.Platform = AggContext.CreateInstanceFrom <INativePlatformFeatures>(platformFeaturesProvider); AppContext.Platform.ProcessCommandline(); var root = new Object3D(); var cube = await CubeObject3D.Create(20, 20, 20); var fit = await FitToBoundsObject3D_2.Create(cube); fit.SizeX = 10; fit.SizeY = 10; fit.SizeZ = 6; Assert.IsTrue(fit.GetAxisAlignedBoundingBox().Equals(new AxisAlignedBoundingBox(new Vector3(-5, -5, -10), new Vector3(5, 5, -4)), .01)); var bigCube = await CubeObject3D.Create(20, 20, 20); Assert.IsTrue(bigCube.GetAxisAlignedBoundingBox().Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)), .01)); var align = new AlignObject3D(); align.Children.Add(bigCube); align.Children.Add(fit); await align.Rebuild(); align.XAlign = Align.Center; align.YAlign = Align.Center; align.ZAlign = Align.Max; align.Advanced = true; align.ZOffset = 1; await align.Rebuild(); var alignAabb = align.GetAxisAlignedBoundingBox(); Assert.IsTrue(alignAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 11)), .01)); alignAabb = align.GetAxisAlignedBoundingBox(); root.Children.Add(align); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 11)), .01)); }
public void AabbCalculatedCorrectlyForCurvedFitObjects() { var root = new Object3D(); var cube = new CubeObject3D(20, 20, 20); var fit = FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; var curve = new CurveObject3D(); curve.Children.Add(fit); curve.Invalidate(new InvalidateArgs(curve, InvalidateType.Properties)); root.Children.Add(curve); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-25, 4, -10), new Vector3(25, 15, 10)), 1.0)); }
public async void DoAabbCalculatedCorrectlyForCurvedFitObjects() { var root = new Object3D(); var cube = CubeObject3D.Create(20, 20, 20); var fit = FitToBoundsObject3D_2.Create(cube).Result; fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; Assert.IsTrue(fit.GetAxisAlignedBoundingBox().Equals(new AxisAlignedBoundingBox(new Vector3(-25, -10, -10), new Vector3(25, 10, 10)), 1.0)); var curve = new CurveObject3D_2(); curve.Children.Add(fit); await curve.Rebuild(); var curveAabb = curve.GetAxisAlignedBoundingBox(); root.Children.Add(curve); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-17.5, -9.2, -10), new Vector3(17.5, 9.2, 10)), 1.0)); }
public async Task AabbCalculatedCorrectlyForPinchedFitObjects() { AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); // Automation runner must do as much as program.cs to spin up platform string platformFeaturesProvider = "MatterHackers.MatterControl.WindowsPlatformsFeatures, MatterControl.Winforms"; AppContext.Platform = AggContext.CreateInstanceFrom <INativePlatformFeatures>(platformFeaturesProvider); AppContext.Platform.InitPluginFinder(); AppContext.Platform.ProcessCommandline(); // build without pinch { var root = new Object3D(); var cube = await CubeObject3D.Create(20, 20, 20); root.Children.Add(cube); Assert.IsTrue(root.GetAxisAlignedBoundingBox().Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)), .001)); root.Children.Remove(cube); var fit = await FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; root.Children.Add(fit); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-25, -10, -10), new Vector3(25, 10, 10)), .001)); } // build with pinch { var root = new Object3D(); var cube = await CubeObject3D.Create(20, 20, 20); var fit = await FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; var pinch = new PinchObject3D_2(); pinch.Children.Add(fit); await pinch.Rebuild(); root.Children.Add(pinch); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)), .001)); } // build with translate { var root = new Object3D(); var cube = await CubeObject3D.Create(20, 20, 20); var translate = new TranslateObject3D(cube, 11, 0, 0); root.Children.Add(translate); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001)); } // build with pinch and translate { var root = new Object3D(); var cube = await CubeObject3D.Create(20, 20, 20); var translate = new TranslateObject3D(cube, 11, 0, 0); var pinch = new PinchObject3D_2(); pinch.Children.Add(translate); root.Children.Add(pinch); await pinch.Rebuild(); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001)); } // build with pinch and translate { var root = new Object3D(); var cube = await CubeObject3D.Create(20, 20, 20); var fit = await FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; var translate = new TranslateObject3D(fit, 11, 0, 0); var pinch = new PinchObject3D_2(); pinch.Children.Add(translate); await pinch.Rebuild(); root.Children.Add(pinch); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001)); } }
public void AabbCalculatedCorrectlyForPinchedFitObjects() { // build without pinch { var root = new Object3D(); var cube = new CubeObject3D(20, 20, 20); root.Children.Add(cube); Assert.IsTrue(root.GetAxisAlignedBoundingBox().Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)), .001)); root.Children.Remove(cube); var fit = FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; root.Children.Add(fit); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-25, -10, -10), new Vector3(25, 10, 10)), .001)); } // build with pinch { var root = new Object3D(); var cube = new CubeObject3D(20, 20, 20); root.Children.Add(cube); var fit = FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; var pinch = new PinchObject3D(); pinch.Children.Add(fit); root.Children.Add(pinch); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)), .001)); } // build with translate { var root = new Object3D(); var cube = new CubeObject3D(20, 20, 20); var translate = new TranslateObject3D(cube, 11, 0, 0); root.Children.Add(translate); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001)); } // build with pinch and translate { var root = new Object3D(); var cube = new CubeObject3D(20, 20, 20); var translate = new TranslateObject3D(cube, 11, 0, 0); var pinch = new PinchObject3D(); pinch.Children.Add(translate); root.Children.Add(pinch); pinch.Invalidate(new InvalidateArgs(pinch, InvalidateType.Properties)); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001)); } // build with pinch and translate { var root = new Object3D(); var cube = new CubeObject3D(20, 20, 20); var fit = FitToBoundsObject3D_2.Create(cube); fit.SizeX = 50; fit.SizeY = 20; fit.SizeZ = 20; var translate = new TranslateObject3D(fit, 11, 0, 0); var pinch = new PinchObject3D(); pinch.Children.Add(translate); pinch.Invalidate(new InvalidateArgs(pinch, InvalidateType.Properties)); root.Children.Add(pinch); var rootAabb = root.GetAxisAlignedBoundingBox(); Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001)); } }