public override void Load() { var library = ApplicationController.Instance.Library; long index = DateTime.Now.Ticks; var libraryItems = new List <GeneratorItem>() { new GeneratorItem( () => "Cube".Localize(), async() => await CubeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Pyramid".Localize(), async() => await PyramidObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Wedge".Localize(), async() => await WedgeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Wedge".Localize(), async() => await HalfWedgeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Text".Localize(), async() => await TextObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Cylinder".Localize(), async() => await CylinderObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Cone".Localize(), async() => await ConeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Cylinder".Localize(), async() => await HalfCylinderObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Torus".Localize(), async() => await TorusObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Ring".Localize(), async() => await RingObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Sphere".Localize(), async() => await SphereObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Sphere".Localize(), async() => await HalfSphereObject3D.Create()) { DateCreated = new System.DateTime(index++) }, #if DEBUG new GeneratorItem( () => "XY Calibration".Localize(), async() => await XyCalibrationFaceObject3D.Create()) { DateCreated = new System.DateTime(index++) }, #endif new GeneratorItem( () => "Image Converter".Localize(), () => { // Construct an image var imageObject = new ImageObject3D() { AssetPath = AggContext.StaticData.ToAssetPath(Path.Combine("Images", "mh-logo.png")) }; // Construct a scene var bedConfig = new BedConfig(null); var tempScene = bedConfig.Scene; tempScene.Children.Add(imageObject); tempScene.SelectedItem = imageObject; // Invoke ImageConverter operation, passing image and scene SceneOperations.ById("ImageConverter").Action(bedConfig); // Return replacement object constructed in ImageConverter operation var constructedComponent = tempScene.SelectedItem; tempScene.Children.Remove(constructedComponent); return(Task.FromResult <IObject3D>(constructedComponent)); }) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Measure Tool".Localize(), async() => await MeasureToolObject3D.Create()) { DateCreated = new System.DateTime(index++) }, }; string title = "Primitive Shapes".Localize(); foreach (var item in libraryItems) { item.Category = title; Items.Add(item); } }
public override void Load() { var library = ApplicationController.Instance.Library; long index = DateTime.Now.Ticks; var libraryItems = new List <GeneratorItem>() { new GeneratorItem( () => "Cube".Localize(), async() => await CubeObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Pyramid".Localize(), async() => await PyramidObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Wedge".Localize(), async() => await WedgeObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Half Wedge".Localize(), async() => await HalfWedgeObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Text".Localize(), async() => await TextObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Cylinder".Localize(), async() => await CylinderObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Cone".Localize(), async() => await ConeObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Half Cylinder".Localize(), async() => await HalfCylinderObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Torus".Localize(), async() => await TorusObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Ring".Localize(), async() => await RingObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Sphere".Localize(), async() => await SphereObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Half Sphere".Localize(), async() => await HalfSphereObject3D.Create()) { DateCreated = new DateTime(index++) }, #if DEBUG new GeneratorItem( () => "SCAD Script".Localize(), async() => await OpenScadScriptObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "MarchingSquares".Localize(), async() => await MarchingSquaresObject3D.Create()) { DateCreated = new DateTime(index++) }, #endif new GeneratorItem( () => "Image Converter".Localize(), () => { // Construct an image var imageObject = new ImageObject3D() { AssetPath = StaticData.Instance.ToAssetPath(Path.Combine("Images", "mh-logo.png")) }; // Construct a scene var bedConfig = new BedConfig(null); var tempScene = bedConfig.Scene; tempScene.Children.Add(imageObject); tempScene.SelectedItem = imageObject; // Invoke ImageConverter operation, passing image and scene SceneOperations.ById("ImageConverter").Action(bedConfig); // Return replacement object constructed in ImageConverter operation var constructedComponent = tempScene.SelectedItem; tempScene.Children.Remove(constructedComponent); return(Task.FromResult(constructedComponent)); }) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Measure Tool".Localize(), async() => await MeasureToolObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Description".Localize(), async() => await DescriptionObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Variable Sheet".Localize(), async() => await SheetObject3D.Create()) { DateCreated = new DateTime(index++) }, }; string title = "Primitive Shapes".Localize(); foreach (var item in libraryItems) { item.Category = title; Items.Add(item); } this.ChildContainers.Add( new DynamicContainerLink( () => "Primitives 2D".Localize(), StaticData.Instance.LoadIcon(Path.Combine("Library", "folder.png")), StaticData.Instance.LoadIcon(Path.Combine("Library", "primitives_library_icon.png")), () => new Primitives2DContainer()) { IsReadOnly = true }); }
public override void Load() { var library = ApplicationController.Instance.Library; long index = DateTime.Now.Ticks; var libraryItems = new List <GeneratorItem>() { new GeneratorItem( () => "Box".Localize(), async() => await BoxPathObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Triangle".Localize(), async() => await PyramidObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Trapezoid".Localize(), async() => await WedgeObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Text".Localize(), async() => await TextPathObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Oval".Localize(), async() => await CylinderObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Star".Localize(), async() => await ConeObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Ring".Localize(), async() => await RingObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( () => "Circle".Localize(), async() => await SphereObject3D.Create()) { DateCreated = new DateTime(index++) }, }; string title = "2D Shapes".Localize(); foreach (var item in libraryItems) { item.Category = title; Items.Add(item); } }
public void CsgCylinderMinusCylinder() { AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5)); // check that we subtarct two 3 sideh cylinders { double topHeight = 10; int sides = 3; IObject3D keep = CylinderObject3D.Create(20, topHeight * 2, sides); IObject3D subtract = CylinderObject3D.Create(10, topHeight * 2, sides); var keepMesh = keep.Mesh; var subtractMesh = subtract.Mesh; if (false) { var split1 = new DebugFace() { EvaluateHeight = topHeight, FileName = "Split1" }; BooleanModeller.Object1SplitFace = split1.Split; BooleanModeller.Object1SplitResults = split1.Result; BooleanModeller.Object1ClassifyFace = split1.Classify1; BooleanModeller.Object2ClassifyFace = split1.Classify2; } var resultMesh = keepMesh.Subtract(subtractMesh, null, CancellationToken.None); // this is for debuging the opperation //split1.FinishOutput(); //resultMesh.Save("c:/temp/mesh1.stl", CancellationToken.None); var topZero = new Vector3(0, 0, topHeight); foreach (var topVertex in keepMesh.Vertices .Where((v) => v.Position.Z == topHeight && v.Position != topZero) .Select((gv) => gv.Position)) { Assert.IsTrue(resultMesh.Vertices.Where((v) => v.Position == topVertex).Any(), "Have all top vertexes"); } foreach (var topVertex in subtractMesh.Vertices .Where((v) => v.Position.Z == topHeight && v.Position != topZero) .Select((gv) => gv.Position)) { Assert.IsTrue(resultMesh.Vertices.Where((v) => v.Position == topVertex).Any(), "Have all top vertexes"); } } // check that we subtarct two 3 sideh cylinders { int sides = 3; IObject3D keep = CylinderObject3D.Create(20, 20, sides); IObject3D subtract = CylinderObject3D.Create(10, 22, sides); var keepMesh = keep.Mesh; var subtractMesh = subtract.Mesh; if (false) { var split1 = new DebugFace() { EvaluateHeight = 10, FileName = "Split2" }; BooleanModeller.Object1SplitFace = split1.Split; BooleanModeller.Object1SplitResults = split1.Result; } var resultMesh = keepMesh.Subtract(subtractMesh, null, CancellationToken.None); // this is for debuging the opperation //split1.FinishOutput(); //resultMesh.Save("c:/temp/mesh2.stl", CancellationToken.None); foreach (var topVertex in keepMesh.Vertices .Where((v) => v.Position.Z == 10 && v.Position != new Vector3(0, 0, 10)) .Select((gv) => gv.Position)) { Assert.IsTrue(resultMesh.Vertices.Where((v) => v.Position == topVertex).Any(), "Have all top vertexes"); } foreach (var topVertex in subtractMesh.Vertices .Where((v) => v.Position.Z == 11 && v.Position != new Vector3(0, 0, 11)) .Select((gv) => gv.Position)) { Assert.IsTrue(resultMesh.Vertices .Where((v) => v.Position.Equals(new Vector3(topVertex.X, topVertex.Y, 10), .0001)) .Any(), "Have all top vertexes"); } } }
public override void Load() { var library = ApplicationController.Instance.Library; long index = DateTime.Now.Ticks; var libraryItems = new List <GeneratorItem>() { new GeneratorItem( () => "Cube".Localize(), () => CubeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Pyramid".Localize(), () => PyramidObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Wedge".Localize(), () => WedgeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Wedge".Localize(), () => HalfWedgeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Text".Localize(), () => TextObject3D.Create().Result) { DateCreated = new System.DateTime(index++) }, #if DEBUG new GeneratorItem( () => "Text".Localize(), () => TextPathObject3D.Create()) { DateCreated = new System.DateTime(index++) }, #endif new GeneratorItem( () => "Cylinder".Localize(), () => CylinderObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Cone".Localize(), () => ConeObject3D.Create().Result) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Cylinder".Localize(), () => HalfCylinderObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Torus".Localize(), () => TorusObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Ring".Localize(), () => RingObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Sphere".Localize(), () => SphereObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Sphere".Localize(), () => HalfSphereObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Image Converter".Localize(), () => { // Construct an image var imageObject = new ImageObject3D() { AssetPath = AggContext.StaticData.ToAssetPath(Path.Combine("Images", "mh-logo.png")) }; // Construct a scene var tempScene = new InteractiveScene(); tempScene.Children.Add(imageObject); tempScene.SelectedItem = imageObject; // Invoke ImageConverter operation, passing image and scene ApplicationController.Instance.Graph.Operations["ImageConverter"].Operation(imageObject, tempScene); // Return replacement object constructed in ImageConverter operation var constructedComponent = tempScene.SelectedItem; tempScene.Children.Remove(constructedComponent); return(constructedComponent); }) { DateCreated = new System.DateTime(index++) }, }; string title = "Primitive Shapes".Localize(); foreach (var item in libraryItems) { item.Category = title; Items.Add(item); } }
public override void Load() { var library = ApplicationController.Instance.Library; long index = DateTime.Now.Ticks; var libraryItems = new List <GeneratorItem>() { new GeneratorItem( () => "Cube".Localize(), () => CubeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Pyramid".Localize(), () => PyramidObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Wedge".Localize(), () => WedgeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Wedge".Localize(), () => HalfWedgeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Text".Localize(), () => TextObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Cylinder".Localize(), () => CylinderObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Cone".Localize(), () => ConeObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Cylinder".Localize(), () => HalfCylinderObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Torus".Localize(), () => TorusObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Ring".Localize(), () => RingObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Sphere".Localize(), () => SphereObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Half Sphere".Localize(), () => HalfSphereObject3D.Create()) { DateCreated = new System.DateTime(index++) }, new GeneratorItem( () => "Image Converter".Localize(), () => { // Build ImageConverter stack var imageObject = new ImageObject3D() { AssetPath = AggContext.StaticData.ToAssetPath(Path.Combine("Images", "mh-logo.png")) }; imageObject.Invalidate(new InvalidateArgs(imageObject, InvalidateType.Properties, null)); var path = new ImageToPathObject3D(); path.Children.Add(imageObject); path.Invalidate(new InvalidateArgs(path, InvalidateType.Properties, null)); var smooth = new SmoothPathObject3D(); smooth.Children.Add(path); smooth.Invalidate(new InvalidateArgs(smooth, InvalidateType.Properties, null)); var extrude = new LinearExtrudeObject3D(); extrude.Children.Add(smooth); extrude.Invalidate(new InvalidateArgs(extrude, InvalidateType.Properties, null)); var baseObject = new BaseObject3D() { BaseType = BaseTypes.None }; baseObject.Children.Add(extrude); baseObject.Invalidate(new InvalidateArgs(baseObject, InvalidateType.Properties, null)); return(new ComponentObject3D(new [] { baseObject }) { ComponentID = "4D9BD8DB-C544-4294-9C08-4195A409217A", SurfacedEditors = new List <string> { "$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D>.Children<ImageObject3D>", "$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Height", "$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.SmoothDistance", "$.Children<BaseObject3D>.Children<LinearExtrudeObject3D>.Children<SmoothPathObject3D>.Children<ImageToPathObject3D>", "$.Children<BaseObject3D>", } }); }) { DateCreated = new System.DateTime(index++) }, }; string title = "Primitive Shapes".Localize(); foreach (var item in libraryItems) { item.Category = title; Items.Add(item); } }