public void RubberbandRectangleTouchedSelection() { var ctx = Context.Current; var sel = ctx.WorkspaceController.Selection; var body1 = Body.Create(Box.Create(10, 10, 10)); body1.Position = new Pnt(-15, 0, 0); var body2 = Body.Create(Cylinder.Create(6, 8)); body2.Position = new Pnt(15, 0, 0); var body3 = Body.Create(Sphere.Create(8)); body2.Position = new Pnt(0, 15, 0); ctx.ViewportController.ZoomFitAll(); Assert.Multiple(() => { // Select two of three ctx.MoveTo(400, 400); ctx.ViewportController.MouseDown(); ctx.ViewportController.StartRubberbandSelection(ViewportController.RubberbandSelectionMode.Rectangle, true); ctx.MoveTo(170, 270); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RubberbandSelection31")); ctx.ViewportController.MouseUp(false); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RubberbandSelection32")); Assert.AreEqual(2, sel.SelectedEntities.Count); }); }
public static Shape3D Create(string name, ShapeType.Material mType, double arg1, double arg2) { Shape3D rv = null; switch (name) { case "球": rv = Ball.Create(arg1, mType); return(rv); case "立方體": rv = Cube.Create(arg1, mType); return(rv); case "圓柱體": rv = Cylinder.Create(arg1, arg2, mType); return(rv); case "金字塔": rv = Pyramid.Create(arg1, arg2, mType); return(rv); default: return(rv); } }
public void RubberbandFreehandTouchedSelection() { var ctx = Context.Current; var sel = ctx.WorkspaceController.Selection; var body1 = Body.Create(Box.Create(10, 10, 10)); body1.Position = new Pnt(-15, 0, 0); var body2 = Body.Create(Cylinder.Create(6, 8)); body2.Position = new Pnt(15, 0, 0); var body3 = Body.Create(Cylinder.Create(4, 6)); body2.Position = new Pnt(0, 15, 0); ctx.ViewportController.ZoomFitAll(); // Select two of three ctx.MoveTo(300, 50); ctx.ViewportController.MouseDown(); ctx.ViewportController.StartRubberbandSelection(ViewportController.RubberbandSelectionMode.Freehand, true); ctx.MoveTo(395, 120); ctx.MoveTo(392, 237); ctx.MoveTo(317, 253); ctx.MoveTo(159, 140); Assert.Multiple(() => { AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RubberbandSelection21")); ctx.ViewportController.MouseUp(false); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RubberbandSelection22")); Assert.AreEqual(2, sel.SelectedEntities.Count); }); }
public static Scene CreateAndPopulateScene() { var scene = new Scene(); var cube = Cube.Create(10.0); cube.Frame = Matrix44D.CreateTranslation(new Vector3D(0, 0, 5)); scene.Bodies.Add(cube); var cube2 = Cube.Create(10.0); cube2.Frame = Matrix44D.CreateTranslation(new Vector3D(0, 0, 15)) * Matrix44D.CreateRotation(new Vector3D(0, 0, 1), 45.0.DegToRad());; cube2.Sensor = new CylinderSensor(new Vector3D(0, 0, 1)); scene.Bodies.Add(cube2); var cylinder = Cylinder.Create(16, 4.0, 10.0); cylinder.Frame = Matrix44D.CreateTranslation(new Vector3D(10, 10, 5.1)); cylinder.Sensor = new LinearSensor(new Vector3D(0, 1, 0)); scene.Bodies.Add(cylinder); var floor = Floor.Create(4, 20); scene.Bodies.Add(floor); double[][] segments = new double[][] { new [] { 0.0, 0.0, 5.0, 0.0 }, new [] { 5.0, 0.0, 5.0, 1.0 }, new [] { 5.0, 1.0, 1.0, 5.0 }, new [] { 1.0, 5.0, 1.0, 7.0 }, new [] { 1.0, 7.0, 5.0, 11.0 }, new [] { 5.0, 11.0, 5.0, 12.0 }, new [] { 5.0, 12.0, 0.0, 12.0 }, }; bool[] borderFlags = new bool[] { true, true, true, true, true, true, true }; bool[] facetsFlags = new bool[] { false, false, false, false, false, false, false }; var rotationBody = RotationBody.Create(16, segments, borderFlags, facetsFlags); rotationBody.Sensor = new PlaneSensor(new Vector3D(0, 0, 1)); rotationBody.Frame = Matrix44D.CreateTranslation(new Vector3D(30, -30, 0.1)); scene.Bodies.Add(rotationBody); var sphere = Sphere.Create(16, 8); sphere.Sensor = new SphereSensor(); sphere.Frame = Matrix44D.CreateTranslation(new Vector3D(-30, 30, 10)); scene.Bodies.Add(sphere); return(scene); }
public void CylinderSurface() { var cylinder = Cylinder.Create(10, 10); Body.Create(cylinder); var face = cylinder.GetSubshapeReference(SubshapeType.Face, 0); var edge = cylinder.GetSubshapeReference(SubshapeType.Edge, 2); var taper = Taper.Create(cylinder.Body, face, edge, 22.5); Assert.IsTrue(taper.Make(Shape.MakeFlags.None)); AssertHelper.IsSameModel(taper, Path.Combine(_BasePath, "CylinderSurface")); }
public void RubberbandRectangleSelection() { var ctx = Context.Current; var sel = ctx.WorkspaceController.Selection; var body1 = Body.Create(Box.Create(10, 10, 10)); body1.Position = new Pnt(-15, 0, 0); var body2 = Body.Create(Cylinder.Create(6, 8)); body2.Position = new Pnt(15, 0, 0); var body3 = Body.Create(Sphere.Create(8)); body2.Position = new Pnt(0, 15, 0); ctx.ViewportController.ZoomFitAll(); // Select two of three ctx.MoveTo(170, 30); ctx.ViewportController.MouseDown(); ctx.ViewportController.StartRubberbandSelection(ViewportController.RubberbandSelectionMode.Rectangle, false); ctx.MoveTo(400, 400); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RubberbandSelection01")); ctx.ViewportController.MouseUp(false); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "RubberbandSelection02")); Assert.AreEqual(2, sel.SelectedEntities.Count); // Additional selection ctx.MoveTo(30, 120); ctx.ViewportController.MouseDown(); ctx.ViewportController.StartRubberbandSelection(ViewportController.RubberbandSelectionMode.Rectangle, false); ctx.MoveTo(290, 420); ctx.ViewportController.MouseUp(true); Assert.AreEqual(3, sel.SelectedEntities.Count); // Reduce selection ctx.MoveTo(30, 120); ctx.ViewportController.MouseDown(); ctx.ViewportController.StartRubberbandSelection(ViewportController.RubberbandSelectionMode.Rectangle, false); ctx.MoveTo(290, 420); ctx.ViewportController.MouseUp(false); Assert.AreEqual(1, sel.SelectedEntities.Count); // Empty selection ctx.MoveTo(10, 10); ctx.ViewportController.MouseDown(); ctx.ViewportController.StartRubberbandSelection(ViewportController.RubberbandSelectionMode.Rectangle, false); ctx.MoveTo(100, 100); ctx.ViewportController.MouseUp(false); Assert.AreEqual(0, sel.SelectedEntities.Count); }
public override void Build() { vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT); vp.NumSamples = 4; backgroundColor = ColorUtils.BLACK; tracer = new RayCast(this); Ambient a = new Ambient(); a.ScaleRadiance = 1.0f; AmbientLight = a; Pinhole pinhole = new Pinhole(new Vec3(0.0, 80.0, 210), new Vec3(0.0, 0.0, 0.0), new Vec3(0.0, 1.0, 0.0), 500); Camera = pinhole; PointLight l = new PointLight(); l.Color = ColorUtils.WHITE; l.SetLocation(100, 100, 200); l.ScaleRadiance = 3.0f; l.Shadows = true; AddLight(l); Phong m = new Phong(); m.SetColor(new Vec3(0.35f)); m.SetKa(0.2f); m.SetKd(0.65f); m.SetKs(0.4f); m.SetExp(64.0f); float t = 20; float b = -80; float r = 50; //BeveledCylinder bc = new BeveledCylinder(b, t, r, 6); //bc.Material = m; Cylinder c = Cylinder.Create(b, t, r, 3); c.Material = m; AddObject(c); }
public void NoAutoFaceDetection() { Context.InitWithView(500); var ctx = Context.Current; // Create a shape with a planar face, but without an opposite face var cylinder = Cylinder.Create(10, 10); var body = Body.Create(cylinder); var face = cylinder.GetSubshapeReference(SubshapeType.Face, 1); var edge = cylinder.GetSubshapeReference(SubshapeType.Edge, 0); var taper = Taper.Create(cylinder.Body, face, edge, 22.5); taper.BaseParameter = 0.0; Assert.IsTrue(taper.Make(Shape.MakeFlags.None)); ctx.Document.AddChild(body); ctx.ViewportController.ZoomFitAll(); // Start tool ctx.WorkspaceController.Selection.SelectEntity(body); Assert.IsTrue(ToolboxCommands.CreateEtchingMask.CanExecute()); ToolboxCommands.CreateEtchingMask.Execute(); var tool = ctx.WorkspaceController.CurrentTool as EtchingMaskEditTool; Assert.IsNotNull(tool); Assert.IsNotNull(ctx.WorkspaceController.CurrentToolAction); // Check selection filter ctx.MoveTo(150, 300); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "NoAutoFaceDetection02")); ctx.MoveTo(250, 250); AssertHelper.IsSameViewport(Path.Combine(_BasePath, "NoAutoFaceDetection01")); ctx.ClickAt(250, 250); Assert.IsNull(ctx.WorkspaceController.CurrentToolAction); // Component should exist, even if it can not work correctly var component = body.FindComponent <EtchingMaskComponent>(); Assert.IsNotNull(component); Assert.IsFalse(component.IsValid); }
public void CurvedEdges() { var cylinder = Cylinder.Create(10, 10); cylinder.SegmentAngle = 270; Body.Create(cylinder); var face = cylinder.GetSubshapeReference(SubshapeType.Face, 1); var edge = cylinder.GetSubshapeReference(SubshapeType.Edge, 0); var taper = Taper.Create(cylinder.Body, face, edge, 22.5); Assert.IsTrue(taper.Make(Shape.MakeFlags.None)); AssertHelper.IsSameModel(taper, Path.Combine(_BasePath, "CurvedEdges1")); edge = cylinder.GetSubshapeReference(SubshapeType.Edge, 4); taper.BaseEdgeOrVertex = edge; Assert.IsTrue(taper.Make(Shape.MakeFlags.None)); AssertHelper.IsSameModel(taper, Path.Combine(_BasePath, "CurvedEdges2")); }
// Token: 0x060041A6 RID: 16806 RVA: 0x0014C3B4 File Offset: 0x0014A7B4 public void OnButtonHit(int id) { this.animTimeout = this.animTimeMax; BaseObject baseObject = null; switch (id) { case 0: { baseObject = Triangle.Create(1f, 0); float[] array = new float[6]; array[0] = 4f; array[1] = 4f; this.shapeParamsMax = array; float[] array2 = new float[6]; array2[0] = 1f; array2[1] = 1f; this.shapeParamsStart = array2; break; } case 1: baseObject = PlaneObject.Create(1f, 1f, 1, 1); this.shapeParamsMax = new float[] { 4f, 4f, 1f, 1f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 1f, 1f, 1f, 0f, 0f }; break; case 2: { baseObject = Circle.Create(1f, 3); float[] array3 = new float[6]; array3[0] = 2.5f; array3[1] = 40f; this.shapeParamsMax = array3; float[] array4 = new float[6]; array4[0] = 1f; array4[1] = 3f; this.shapeParamsStart = array4; break; } case 3: baseObject = Ellipse.Create(1f, 0.5f, 3); this.shapeParamsMax = new float[] { 2.5f, 1.2f, 40f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 0.5f, 3f, 0f, 0f, 0f }; break; case 4: baseObject = Ring.Create(0.5f, 1f, 3); this.shapeParamsMax = new float[] { 1f, 2.5f, 40f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 0.5f, 1f, 3f, 0f, 0f, 0f }; break; case 5: baseObject = Box.Create(1f, 1f, 1f, 1, 1, 1, false, null, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 2.5f, 2.5f, 2.5f, 1f, 1f, 1f }; this.shapeParamsStart = new float[] { 1f, 1f, 1f, 1f, 1f, 1f }; break; case 6: baseObject = Cylinder.Create(1f, 3f, 3, 1, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 1.25f, 4f, 40f, 1f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 3f, 3f, 1f, 0f, 0f, 0f }; break; case 7: baseObject = Cone.Create(1f, 0f, 0f, 2f, 3, 10, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 1.25f, 0f, 4f, 40f, 10f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 1f, 2f, 3f, 10f, 0f, 0f }; break; case 8: { baseObject = Sphere.Create(1f, 4, 0f, 0f, 0f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); float[] array5 = new float[6]; array5[0] = 2.25f; array5[1] = 40f; this.shapeParamsMax = array5; float[] array6 = new float[6]; array6[0] = 1f; array6[1] = 4f; this.shapeParamsStart = array6; break; } case 9: baseObject = Ellipsoid.Create(1f, 1f, 1f, 4, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 1.25f, 2.45f, 2.5f, 40f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 1f, 1f, 4f, 0f, 0f, 0f }; break; case 10: baseObject = Pyramid.Create(1f, 1f, 1f, 1, 1, 1, false, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 2.7f, 2.7f, 1.7f, 1f, 1f, 1f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f }; break; case 11: { baseObject = GeoSphere.Create(1f, 0, GeoSpherePrimitive.BaseType.Icosahedron, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); float[] array7 = new float[6]; array7[0] = 2.45f; array7[1] = 4f; this.shapeParamsMax = array7; float[] array8 = new float[6]; array8[0] = 1f; this.shapeParamsStart = array8; break; } case 12: baseObject = Tube.Create(0.8f, 1f, 1f, 3, 1, 0f, false, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 0.8f, 1.5f, 4f, 40f, 0f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 0.8f, 1f, 1f, 3f, 0f, 0f, 0f, 0f }; break; case 13: baseObject = Capsule.Create(1f, 1f, 4, 1, false, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 1.2f, 4f, 40f, 1f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 1f, 4f, 1f, 0f, 0f, 0f }; break; case 14: baseObject = RoundedCube.Create(1f, 1f, 1f, 1, 0.2f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 1.6f, 1.6f, 1.6f, 20f, 0.6f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 1f, 1f, 1f, 0.2f, 0f, 0f, 0f }; break; case 15: baseObject = Torus.Create(1f, 0.5f, 4, 4, 0f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 1.6f, 0.8f, 40f, 40f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 0.5f, 4f, 4f, 0f, 0f, 0f }; break; case 16: baseObject = TorusKnot.Create(0.5f, 0.3f, 10, 4, 2, 3, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 1f, 0.5f, 120f, 40f, 2f, 3f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 0.5f, 0.3f, 10f, 4f, 2f, 3f, 0f, 0f, 0f }; break; case 17: baseObject = Arc.Create(1f, 1f, 1f, 1f, 10, PivotPosition.Botttom); ((Arc)baseObject).gizmo.gameObject.transform.localPosition = new Vector3(-1f, -1f, 0f); this.shapeParamsMax = new float[] { 4f, 3f, 2f, 1f, 20f, -1f }; this.shapeParamsStart = new float[] { 0.5f, 0.5f, 0.1f, 0.5f, 0f, 0f }; break; case 18: baseObject = SphericalCone.Create(1f, 20, 180f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 2f, 40f, 20f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 1f, 20f, 360f, 0f, 0f, 0f }; break; case 19: baseObject = SuperEllipsoid.Create(1f, 1f, 1f, 20, 0.5f, 1f, (!this.flatNormals) ? NormalsType.Vertex : NormalsType.Face, PivotPosition.Botttom); this.shapeParamsMax = new float[] { 2f, 2f, 2f, 20f, 0.5f, 1f, 0f, 0f, 0f }; this.shapeParamsStart = new float[] { 0.5f, 0.5f, 0.5f, 1f, 0f, 0f, 0f, 0f, 0f }; break; case 20: this.textureToggle = !this.textureToggle; break; case 21: this.flatNormals = !this.flatNormals; break; } if (baseObject) { if (this.shapeOld) { UnityEngine.Object.Destroy(this.shapeOld.gameObject); } this.shapeOld = this.shapeMain; this.shapeMain = baseObject; this.shapeMain.gameObject.GetComponent <Renderer>().material = new Material(this.GetSpecularShader()); this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 0.7058824f, 0.7058824f)); this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_SpecColor", Color.white); this.shapeMain.gameObject.transform.position = this.prevPosition.position; this.nextShowTimeout = this.nextShowTimeoutMax; this.shapeID = id; } if (this.textureToggle) { this.shapeMain.GetComponent <MeshRenderer>().sharedMaterial = (Resources.Load("Checker") as Material); } else { this.shapeMain.GetComponent <MeshRenderer>().sharedMaterial = new Material(this.GetSpecularShader()); this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 0.7058824f, 0.7058824f)); this.shapeMain.gameObject.GetComponent <Renderer>().material.SetColor("_SpecColor", Color.white); } }
static void Forstnerize_Executing(object sender, EventArgs e) { Window activeWindow = Window.ActiveWindow; IDesignBody forstnerBody = null; Box faceBoundingBox = Box.Empty; foreach (IDesignFace iDesignFace in activeWindow.ActiveContext.GetSelection <IDesignFace>()) { forstnerBody = iDesignFace.GetAncestor <IDesignBody>(); faceBoundingBox |= iDesignFace.Shape.GetBoundingBox(Matrix.Identity); } if (forstnerBody == null || faceBoundingBox == Box.Empty) { return; } Part part = Part.Create(activeWindow.Document, "Forstner Bottoms"); Component component = Component.Create(activeWindow.Scene as Part, part); Box bodyBoundingBox = forstnerBody.Shape.GetBoundingBox(Matrix.Identity); Plane topPlane = Plane.Create(Frame.Create(bodyBoundingBox.MaxCorner, Direction.DirX, Direction.DirY)); double xSpacing = diameter * Math.Sqrt(3) / 2; double ySpacing = diameter * 3 / 4; bool shortRow = false; for (double y = faceBoundingBox.MinCorner.Y; y < faceBoundingBox.MaxCorner.Y; y += ySpacing) { for (double x = shortRow ? faceBoundingBox.MinCorner.X + xSpacing / 2 : faceBoundingBox.MinCorner.X; x < faceBoundingBox.MaxCorner.X; x += xSpacing) { List <IDesignBody> referenceBodies = new List <IDesignBody>(); referenceBodies.Add(DesignBody.Create( Part.Create(activeWindow.Document, "Temp"), "Target Copy", forstnerBody.Master.Shape.Copy() )); Point lowerPoint = Point.Create(x, y, bodyBoundingBox.MinCorner.Z); Point upperPoint = Point.Create(x, y, bodyBoundingBox.MaxCorner.Z); IDesignBody drillBody = ShapeHelper.CreateCylinder(lowerPoint, upperPoint, diameter, activeWindow.Scene as Part); ICollection <IDesignBody> outputBodies = new List <IDesignBody>(); try { //XXX outputBodies = drillBody.Subtract(referenceBodies); } finally { //outputBodies = new List<IDesignBody>(); } // Find the top of the faces created by the intersection of the cylinder and the target. The top of the bounding box of all faces except the top face and the cylinder of the drill are perfect. Box bottomBox = Box.Empty; Cylinder drillCylinder = Cylinder.Create( Frame.Create(lowerPoint, Direction.DirX, Direction.DirY), diameter / 2 ); bool hasTop = false; foreach (IDesignBody iDesignBody in outputBodies) { foreach (IDesignFace iDesignFace in iDesignBody.Faces) { Plane plane = iDesignFace.Shape.Geometry as Plane; if (plane != null) { if (AddInHelper.isCooincident(plane, topPlane)) { hasTop = true; continue; } } Cylinder cylinder = iDesignFace.Shape.Geometry as Cylinder; if (cylinder != null) { if (AddInHelper.isCooincident(cylinder, drillCylinder)) { continue; } } bottomBox |= iDesignFace.Shape.GetBoundingBox(Matrix.Identity); } iDesignBody.Delete(); } if (!bottomBox.IsEmpty && hasTop) { Point bottomPoint = Point.Create(lowerPoint.X, lowerPoint.Y, bottomBox.MaxCorner.Z); DesignBody bottomBody = ShapeHelper.CreateCircle(Frame.Create(bottomPoint, Direction.DirX, Direction.DirY), diameter, part); //AddInHelper.CreateCircle(Frame.Create(bottomPoint, Direction.DirX, Direction.DirY), 0.001, part); foreach (DesignFace designFace in bottomBody.Faces) { NoteHelper.AnnotateFace(designFace.GetAncestor <Part>(), designFace, activeWindow.Units.Length.Format(-bottomPoint.Z), diameter / 5, Direction.DirZ); } } } shortRow = !shortRow; } }