public override Task Rebuild() { IObject3D cancerRibbonStl = Object3D.Load("Cancer_Ribbon.stl", CancellationToken.None); cancerRibbonStl = new RotateObject3D(cancerRibbonStl, MathHelper.DegreesToRadians(90)); var letterPrinter = new TypeFacePrinter(NameToWrite.ToUpper(), new StyledTypeFace(ApplicationController.GetTypeFace(Font), 12)); IObject3D nameMesh = new Object3D() { Mesh = VertexSourceToMesh.Extrude(letterPrinter, 5) }; AxisAlignedBoundingBox textBounds = nameMesh.GetAxisAlignedBoundingBox(); var textArea = new Vector2(25, 6); double scale = Math.Min(textArea.X / textBounds.XSize, textArea.Y / textBounds.YSize); nameMesh = new ScaleObject3D_3(nameMesh, scale, scale, 2 / textBounds.ZSize); nameMesh = new AlignObject3D(nameMesh, FaceAlign.Bottom | FaceAlign.Front, cancerRibbonStl, FaceAlign.Top | FaceAlign.Front, 0, 0, -1); nameMesh = new SetCenterObject3D(nameMesh, cancerRibbonStl.GetCenter(), true, false, false); nameMesh = new RotateObject3D(nameMesh, 0, 0, MathHelper.DegreesToRadians(50)); nameMesh = new TranslateObject3D(nameMesh, -37, -14, -1); // output two meshes for card holder and text this.Children.Modify(list => { list.Clear(); list.Add(cancerRibbonStl); list.Add(nameMesh); }); this.Mesh = null; this.Invalidate(InvalidateType.Children); return(Task.CompletedTask); }
protected IObject3D CreateReach(double reach, double innerDiameter) { var finWidth = 4.0; var finLength = innerDiameter; var pattern = new VertexStorage(); pattern.MoveTo(0, 0); pattern.LineTo(finLength / 2, 0); pattern.LineTo(finLength / 2, reach - finLength / 8); pattern.LineTo(finLength / 2 - finLength / 8, reach); pattern.LineTo(-finLength / 2 + finLength / 8, reach); pattern.LineTo(-finLength / 2, reach - finLength / 8); pattern.LineTo(-finLength / 2, 0); var fin1 = new Object3D() { Mesh = VertexSourceToMesh.Extrude(pattern, finWidth) }; fin1 = new TranslateObject3D(fin1, 0, 0, -finWidth / 2); //fin1.ChamferEdge(Face.Top | Face.Back, finLength / 8); //fin1.ChamferEdge(Face.Top | Face.Front, finLength / 8); fin1 = new RotateObject3D(fin1, -MathHelper.Tau / 4); var fin2 = new SetCenterObject3D(new RotateObject3D(fin1, 0, 0, MathHelper.Tau / 4), fin1.GetCenter()); return(new Object3D().SetChildren(new List <IObject3D>() { fin1, fin2 })); }
public override async Task Rebuild() { using (RebuildLock()) { using (new CenterAndHeightMaintainer(this)) { // validate the some of the values and store in user data if changed InnerDiameter = ValidateValue(InnerDiameter, "PipeWorksInnerDiameter", 15); OuterDiameter = ValidateValue(OuterDiameter, "PipeWorksOuterDiameter", 20); BottomReach = ValidateValue(BottomReach, "PipeWorksBottomReach", 30); FrontReach = ValidateValue(FrontReach, "PipeWorksFrontReach", 25); IObject3D bottomReach = new RotateObject3D(CreateReach(BottomReach, InnerDiameter), -MathHelper.Tau / 4); IObject3D frontReach = null; IObject3D elbowConnect = null; if (Angle < 90) { frontReach = bottomReach.Clone(); var translate = new Vector3(-OuterDiameter / 2, 0, 0); bottomReach.Translate(translate); frontReach = new RotateObject3D(frontReach, 0, 0, -MathHelper.DegreesToRadians(Angle)); translate = Vector3Ex.Transform(-translate, Matrix4X4.CreateRotationZ(MathHelper.DegreesToRadians(Angle))); frontReach.Translate(translate); var torus = new TorusObject3D(); using (torus.RebuildLock()) { torus.Advanced = true; torus.InnerDiameter = 0; OuterDiameter = OuterDiameter * 2; torus.RingSides = Sides; torus.Sides = Sides; torus.StartingAngle = Angle; torus.EndingAngle = 180; } torus.Invalidate(new InvalidateArgs(torus, InvalidateType.Properties)); elbowConnect = torus; } else if (Angle < 270) { bottomReach.Translate(0, -OuterDiameter / 2, 0); IObject3D reachConnect = await CylinderObject3D.Create(OuterDiameter, OuterDiameter, Sides, Alignment.Y); reachConnect = new AlignObject3D(reachConnect, FaceAlign.Front, bottomReach, FaceAlign.Back); reachConnect = new SetCenterObject3D(reachConnect, bottomReach.GetCenter(), true, false, true); bottomReach = bottomReach.Plus(reachConnect); frontReach = bottomReach.Clone(); frontReach = new RotateObject3D(frontReach, 0, 0, -MathHelper.DegreesToRadians(Angle)); elbowConnect = new SphereObject3D(OuterDiameter, Sides); } // output multiple meshes for pipe connector this.Children.Modify(list => { list.Clear(); list.Add(elbowConnect); list.Add(bottomReach); list.Add(frontReach); }); this.Color = Color.Transparent; this.Mesh = null; } } Invalidate(InvalidateType.Children); }