コード例 #1
0
        public void CircleArc()
        {
            // Create simple geometry
            var imprint = TestGeomGenerator.CreateImprint();

            Assert.IsTrue(imprint.Make(Shape.MakeFlags.None));
            // Cut circle
            var box = TestGeomGenerator.CreateBox();

            Assert.IsTrue(box.Make(Shape.MakeFlags.None));

            // Create Hlr Exporter
            var pdf = RunExporter(false, _TopProjection, imprint.Body, box.Body);

            // Write to file and compare
            AssertHelper.IsSameTextFile(Path.Combine(_BasePath, "CircleArc.pdf"), pdf, AssertHelper.TextCompareFlags.IgnoreFloatPrecision);
        }
コード例 #2
0
        public void CascadedProcessingScope()
        {
            var box1 = TestGeomGenerator.CreateBox();
            var box2 = TestGeomGenerator.CreateBox();

            using (new ProcessingScope(box1, "Pro1"))
            {
                Messages.Error("Hello World");
                using (new ProcessingScope(box2, "Pro2"))
                {
                    Messages.Error("Hello World");
                }
            }

            Assert.AreEqual(1, Context.Current.MessageHandler.GetEntityMessages(box1).Count);
            Assert.AreEqual(1, Context.Current.MessageHandler.GetEntityMessages(box2).Count);
        }
コード例 #3
0
        public void RemoveBody()
        {
            void __CreateAndRemoveBody()
            {
                var body = TestGeomGenerator.CreateImprint().Body;

                body.Remove();
            }

            __CreateAndRemoveBody();

            dotMemory.Check(memory =>
            {
                Assert.AreEqual(0, memory.ObjectsCount <Body>(), "Body is alive");
                Assert.AreEqual(0, memory.ObjectsCount <Imprint, Box, Sketch>(), "Shapes are alive");
            });
        }
コード例 #4
0
        public void DeleteBodyUndo()
        {
            var model = CoreContext.Current.Document;
            var body  = TestGeomGenerator.CreateImprint().Body;

            model.AddChild(body);
            model.UndoHandler.Commit();
            Assume.That(CoreContext.Current.Document.ChildCount, Is.EqualTo(1));

            model.SafeDelete(new[] { body });
            model.UndoHandler.Commit();
            Assert.That(CoreContext.Current.Document.ChildCount, Is.EqualTo(0));

            Assert.That(CoreContext.Current.UndoHandler.UndoStack.Count, Is.EqualTo(2));
            CoreContext.Current.UndoHandler.DoUndo(1);
            Assert.That(CoreContext.Current.Document.ChildCount, Is.EqualTo(1));
        }
コード例 #5
0
        public void UpdateOnChanges()
        {
            Context.InitWithView(500);
            var ctx  = Context.Current;
            var body = TestGeomGenerator.CreateImprint()?.Body;

            Assume.That(body != null);
            ctx.Document.AddChild(body);
            ctx.ViewportController.ZoomFitAll();

            Assert.Multiple(() =>
            {
                ctx.WorkspaceController.Selection.SelectEntity(body);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ShowReconstructed01"));

                // Start tool
                Assert.IsTrue(ToolboxCommands.CreateSliceContour.CanExecute());
                ToolboxCommands.CreateSliceContour.Execute();

                // Check tool, it should automatically show the reconstructed version
                var tool = ctx.WorkspaceController.CurrentTool as SliceContourEditTool;
                Assert.IsNotNull(tool);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ShowReconstructed02"));

                // Edit layer count
                tool.Component.LayerCount = 4;
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ShowReconstructed03"));
                tool.Component.LayerCount = 1;

                // Edit box size
                var box        = body.Shape.Predecessor as Box;
                box.DimensionX = 8;
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ShowReconstructed04"));

                // Move body
                body.Position = new Pnt(1, 0, 0);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ShowReconstructed05"));

                // Change body layer
                var layer   = new Layer();
                layer.Color = new Color(0, 1, 0);
                ctx.Layers.Add(layer);
                body.Layer = layer;
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ShowReconstructed06"));
            });
        }
コード例 #6
0
        public void FaceSelection()
        {
            var imprint = TestGeomGenerator.CreateImprint(TestGeomGenerator.SketchType.Circle);

            Assume.That(imprint, Is.Not.Null);
            imprint.Depth = 5.0;

            var shape = Chamfer.Create(imprint.Body);

            shape.AddAllEdges();
            shape.Mode           = Chamfer.ChamferModes.TwoDistances;
            shape.Distance       = 0.2;
            shape.SecondDistance = 1;

            Assert.IsTrue(shape.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "FaceSelection")));
        }
コード例 #7
0
        public void CreateExtrude()
        {
            var ctx = Context.Current;

            var sketch = TestGeomGenerator.CreateSketch();
            var body   = TestGeomGenerator.CreateBody(sketch, new Pnt(10, 10, 0));

            ctx.WorkspaceController.Selection.SelectEntity(body);
            ctx.ViewportController.ZoomFitAll();
            ctx.MoveTo(90, 250);

            var tool = new CreateExtrudeTool(body);

            Assert.That(ctx.WorkspaceController.StartTool(tool));
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "CreateExtrude01"));
            Assert.That(ctx.WorkspaceController.CurrentTool, Is.Null);
        }
コード例 #8
0
ファイル: BoxJointTests.cs プロジェクト: Macad3D/Macad3D
        public void Cascaded()
        {
            var body1 = TestGeomGenerator.CreateBody(Box.Create(10, 2, 10), new Pnt(-5, -5, -5));
            var body2 = TestGeomGenerator.CreateBody(Box.Create(2, 10, 10), new Pnt(-5, -5, -5));
            var body3 = TestGeomGenerator.CreateBody(Box.Create(2, 10, 10), new Pnt(0, -5, -5));

            var(_, second)    = BoxJoint.Create(body1, body2);
            var(first, third) = BoxJoint.Create(body1, body3);

            Assert.IsTrue(first.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(first, Path.Combine(_BasePath, "Cascaded1"));

            Assert.IsTrue(second.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(second, Path.Combine(_BasePath, "Cascaded2"));

            Assert.IsTrue(third.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(third, Path.Combine(_BasePath, "Cascaded3"));
        }
コード例 #9
0
ファイル: ImprintTests.cs プロジェクト: lanicon/Macad3D
        public void RingFaceDraft()
        {
            var shape = TestGeomGenerator.CreateImprint(TestGeomGenerator.SketchType.Ring);

            Assert.IsNotNull(shape);

            shape.Depth      = 2.5;
            shape.Mode       = Imprint.ImprintMode.Raise;
            shape.DraftAngle = 10;

            //Imprinting a ring face with draft angle isn't supported by the algo.
            Assert.IsTrue(shape.Make(Shape.MakeFlags.None));
            var messages = Context.Current.MessageHandler.GetEntityMessages(shape);

            Assert.AreEqual(1, messages.Count);
            Assert.AreEqual(MessageSeverity.Warning, messages[0].Severity);
            Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "RingFaceDraft")));
        }
コード例 #10
0
        public void LostEdge()
        {
            var extrude = TestGeomGenerator.CreateExtrude(TestSketchGenerator.SketchType.Rectangle);
            var fillet  = Fillet.Create(extrude.Body);

            fillet.AddEdge(extrude.GetSubshapeReference(SubshapeType.Edge, 11));
            Assert.IsTrue(fillet.Make(Shape.MakeFlags.None));

            // Remove segment by merging points
            var sketch = extrude.Predecessor as Sketch;

            sketch.Constraints.Clear();
            sketch.DeleteSegment(sketch.Segments[1]);
            sketch.MergePoints(1, 2);

            // It is ok to fail, it just should not crash
            Assert.IsFalse(fillet.Make(Shape.MakeFlags.None));
        }
コード例 #11
0
ファイル: OffsetTests.cs プロジェクト: Macad3D/Macad3D
    public void SolidCompound()
    {
        var body        = TestGeomGenerator.CreateBox().Body;
        var linearArray = LinearArray.Create(body);

        linearArray.Quantity1     = 2;
        linearArray.Quantity2     = 2;
        linearArray.Distance1     = 2;
        linearArray.Distance2     = 2;
        linearArray.DistanceMode1 = LinearArray.DistanceMode.Spacing;
        linearArray.DistanceMode2 = LinearArray.DistanceMode.Spacing;

        var offset = Offset.Create(body, 0.5);

        Assert.IsTrue(offset.Make(Shape.MakeFlags.None));

        AssertHelper.IsSameModel(offset, Path.Combine(_BasePath, "SolidCompound"));
    }
コード例 #12
0
        public void DuplicateElements()
        {
            var ctx = Context.Current;

            var sketch = TestGeomGenerator.CreateSketch(TestGeomGenerator.SketchType.Rectangle);
            var body   = TestGeomGenerator.CreateBody(sketch);

            ctx.ViewportController.ZoomFitAll();

            var tool = new SketchEditorTool(sketch);

            ctx.WorkspaceController.StartTool(tool);
            Assert.IsFalse(ctx.WorkspaceController.CanDuplicate());

            // Select
            ctx.SelectAt(254, 88);
            ctx.SelectAt(411, 236, true);
            ctx.SelectAt(387, 115, true);
            Assume.That(tool.SelectedSegments.Count, Is.EqualTo(2));

            // Do it
            Assert.Multiple(() =>
            {
                Assert.IsTrue(ctx.WorkspaceController.CanDuplicate());
                ctx.WorkspaceController.Duplicate();

                // Check results
                Assert.AreEqual(7, sketch.Points.Count);
                Assert.AreEqual(6, sketch.Segments.Count);
                Assert.AreEqual(5, sketch.Constraints.Count);
                Assert.AreEqual(3, tool.SelectedPoints.Count);
                Assert.AreEqual(2, tool.SelectedSegments.Count);
                Assert.That(tool.SelectedPoints.SequenceEqual(new[] { 4, 5, 6 }));
                Assert.That(tool.SelectedSegmentIndices.SequenceEqual(new[] { 4, 5 }));
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "DuplicateElements01"));

                // Try move
                ctx.MoveTo(328, 170);
                ctx.ViewportController.MouseDown();
                ctx.MoveTo(350, 150);
                ctx.ViewportController.MouseUp(false);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "DuplicateElements02"));
            });
        }
コード例 #13
0
        public void BodyReferenceSubshapeForwarding()
        {
            var body1 = TestGeomGenerator.CreateBox().Body;

            body1.Position = new Pnt(10, 0, 0);
            var body2 = Reference.Create(body1);

            body2.Position = new Pnt(20, 0, 0);

            Assume.That(body2.Shape.Make(Shape.MakeFlags.None));

            var subshaperef = body2.Shape.GetSubshapeReference(SubshapeType.Edge, 1);

            Assert.AreEqual(body1.Shape.Guid, subshaperef.ShapeId);

            var subshape = body2.Shape.FindSubshape(subshaperef, body2.GetCoordinateSystem());

            Assert.AreEqual(1, subshape.Count);
        }
コード例 #14
0
        public void CreateDoubleSelected()
        {
            var ctx = Context.Current;

            var body1 = TestGeomGenerator.CreateBody(Box.Create(-10, -2, 10));
            var body2 = TestGeomGenerator.CreateBody(Box.Create(-2, -10, 10));

            ctx.ViewportController.ZoomFitAll();

            ctx.WorkspaceController.Selection.SelectEntity(body1);
            ctx.WorkspaceController.StartTool(new CreateBoxJointTool(body1, body2));

            Assert.IsNull(ctx.WorkspaceController.CurrentTool);
            Assert.That(body1.Shape is BoxJoint);
            Assert.That(body2.Shape is BoxJoint);

            ctx.MoveTo(0, 0);
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "CreateDoubleSelected01"));
        }
コード例 #15
0
ファイル: ReferenceTests.cs プロジェクト: Macad3D/Macad3D
        public void CloneMultipleReferences(bool cloneReferencedBody)
        {
            var ctx   = Context.InitWithDefault();
            var body1 = TestGeomGenerator.CreateBox().Body;

            ctx.Document.Add(body1);
            var refs = new List <InteractiveEntity> {
                Reference.Create(body1), Reference.Create(body1)
            };

            refs.ForEach(r => ctx.Document.Add(r));
            Assume.That(ctx.DocumentController.CanDuplicate(refs));

            var clones = ctx.DocumentController.Duplicate(refs, new CloneOptions(cloneReferencedBody)).Cast <Body>().ToList();

            Assert.AreEqual(2, clones.Count());
            Assert.IsTrue(clones[0].Shape.IsValid);
            Assert.IsTrue(clones[1].Shape.IsValid);
        }
コード例 #16
0
        public void Rotate()
        {
            var ctx = Context.Current;

            var body = TestGeomGenerator.CreateBody(Box.Create(10, 5, 2));

            body.Position = new Pnt(3, 2, 1);
            var oldpos = body.Position;

            ctx.ViewportController.ZoomFitAll();

            var tool = new TransformTool(new[] { body }, TransformTool.PivotPoint.EntityPivot, TransformTool.Options.None);

            ctx.WorkspaceController.StartTool(tool);
            tool.ToggleTransformMode();

            Assert.Multiple(() =>
            {
                // X-Axis
                ctx.ViewportController.MouseMove(new Point(374, 123));
                ctx.ViewportController.MouseDown();
                ctx.ViewportController.MouseMove(new Point(390, 154));
                ctx.ViewportController.MouseUp(false);
                Assert.AreEqual(oldpos, body.Position);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "Rotate01"));

                // Y-Axis
                ctx.ViewportController.MouseMove(new Point(310, 120));
                ctx.ViewportController.MouseDown();
                ctx.ViewportController.MouseMove(new Point(291, 143));
                ctx.ViewportController.MouseUp(false);
                Assert.AreEqual(oldpos, body.Position);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "Rotate02"));

                // Z-Axis
                ctx.ViewportController.MouseMove(new Point(420, 178));
                ctx.ViewportController.MouseDown();
                ctx.ViewportController.MouseMove(new Point(411, 214));
                ctx.ViewportController.MouseUp(false);
                Assert.AreEqual(oldpos, body.Position);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "Rotate03"));
            });
        }
コード例 #17
0
ファイル: BodyTests.cs プロジェクト: Macad3D/Macad3D
        public void SetCurrentShape()
        {
            var imprint = TestGeomGenerator.CreateImprint();
            var body    = imprint.Body;

            BooleanFuse.Create(body, Box.Create(1, 1, 10));

            // Current and root shape is boolean fuse
            Assert.That(body.Shape, Is.TypeOf <BooleanFuse>());
            Assert.That(body.RootShape, Is.TypeOf <BooleanFuse>());

            // Switch current
            body.Shape = imprint;
            Assert.That(body.Shape, Is.TypeOf <Imprint>());
            Assert.That(body.RootShape, Is.TypeOf <BooleanFuse>());

            // Check result shape
            AssertHelper.IsSameModel(body.Shape, Path.Combine(_BasePath, "SetCurrentShape"));
        }
コード例 #18
0
        public void DeleteReferencedBody()
        {
            var model = new Model();
            var body1 = TestGeomGenerator.CreateBox().Body;

            model.AddChild(body1);
            var body2 = Reference.Create(body1);

            body2.Position = new Pnt(20, 0, 0);
            model.AddChild(body2);

            Assert.IsTrue(body2.Shape.Make(Shape.MakeFlags.None));
            Assert.IsInstanceOf <Reference>(body2.Shape);

            model.SafeDelete(new[] { body1 });
            Assert.IsTrue(body2.Shape.Make(Shape.MakeFlags.None));
            Assert.IsInstanceOf <Solid>(body2.Shape);
            AssertHelper.IsSameModel(body2.Shape, Path.Combine(_BasePath, "DeleteReferencedBody01"));
        }
コード例 #19
0
        public void AlignOnVertex()
        {
            var ctx = Context.Current;

            var body = TestGeomGenerator.CreateBox().Body;

            ctx.WorkspaceController.Selection.SelectEntity(body);
            ctx.ViewportController.ZoomFitAll();

            var tool = new AlignWorkingPlaneTool(AlignWorkingPlaneTool.AlignWorkingPlaneModes.All);

            Assert.That(ctx.WorkspaceController.StartTool(tool));

            ctx.MoveTo(250, 250);
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "AlignOnVertex1"));

            ctx.SelectAt(250, 250);
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "AlignOnVertex2"));
        }
コード例 #20
0
ファイル: BodyTests.cs プロジェクト: Macad3D/Macad3D
        public void RemoveShapeFromTheMiddle()
        {
            var imprint = TestGeomGenerator.CreateImprint();
            var body    = imprint.Body;

            BooleanFuse.Create(body, Box.Create(1, 1, 10));

            // Current and root shape is boolean fuse
            Assert.That(body.Shape, Is.TypeOf <BooleanFuse>());
            Assert.That(body.RootShape, Is.TypeOf <BooleanFuse>());

            // Remove
            body.RemoveShape(imprint);
            Assert.That(body.Shape, Is.TypeOf <BooleanFuse>());
            Assert.That(body.RootShape, Is.TypeOf <BooleanFuse>());

            // Check result shape
            AssertHelper.IsSameModel(body.Shape, Path.Combine(_BasePath, "RemoveShapeFromTheMiddle"));
        }
コード例 #21
0
        public void ShapeId()
        {
            Context.InitWithDefault();

            var imprint = TestGeomGenerator.CreateImprint();
            var body    = imprint.Body;

            Assume.That(body?.GetBRep() != null);
            imprint.Depth = 10;

            var template = new SliceContourComponent
            {
                Owner     = body,
                ShapeGuid = (imprint.Operands[0] as Shape).Guid
            };

            Assert.IsTrue(template.Make());
            AssertHelper.IsSameModel(template.Layers[0].BRep, Path.Combine(_BasePath, "ShapeId"));
        }
コード例 #22
0
ファイル: BoxJointTests.cs プロジェクト: Macad3D/Macad3D
        public void Ratio()
        {
            var body1 = TestGeomGenerator.CreateBody(Box.Create(10, 2, 10), new Pnt(-5, -5, -5));
            var body2 = TestGeomGenerator.CreateBody(Box.Create(2, 10, 10), new Pnt(-5, -5, -5));

            var(first, second) = BoxJoint.Create(body1, body2);
            first.Ratio        = 0.25;

            Assert.IsTrue(first.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(first, Path.Combine(_BasePath, "Ratio01"));
            Assert.IsTrue(second.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(second, Path.Combine(_BasePath, "Ratio02"));

            second.ReverseOrder = true;
            Assert.IsTrue(first.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(first, Path.Combine(_BasePath, "Ratio11"));
            Assert.IsTrue(second.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(second, Path.Combine(_BasePath, "Ratio12"));
        }
コード例 #23
0
        public void CopyToAndPasteFromClipboard()
        {
            var ctx       = Context.Current;
            var clipboard = TestClipboard.Init();

            var sketch = TestSketchGenerator.CreateSketch(TestSketchGenerator.SketchType.Rectangle);
            var body   = TestGeomGenerator.CreateBody(sketch);

            ctx.ViewportController.ZoomFitAll();

            var tool = new SketchEditorTool(sketch);

            ctx.WorkspaceController.StartTool(tool);
            Assert.IsFalse(ctx.WorkspaceController.CanCopyToClipboard());

            // Select
            ctx.SelectAt(254, 88);
            ctx.SelectAt(411, 236, true);
            ctx.SelectAt(387, 115, true);
            Assume.That(tool.SelectedSegments.Count, Is.EqualTo(2));

            // Do it
            Assert.IsTrue(ctx.WorkspaceController.CanCopyToClipboard());
            ctx.WorkspaceController.CopyToClipboard();
            Assert.That(clipboard.ContainsData("Macad.SketchContent.1"));
            ctx.WorkspaceController.PasteFromClipboard();

            Assert.AreEqual(7, sketch.Points.Count);
            Assert.AreEqual(6, sketch.Segments.Count);
            Assert.AreEqual(5, sketch.Constraints.Count);
            Assert.AreEqual(3, tool.SelectedPoints.Count);
            Assert.AreEqual(2, tool.SelectedSegments.Count);
            Assert.That(tool.SelectedPoints.SequenceEqual(new[] { 4, 5, 6 }));
            Assert.That(tool.SelectedSegmentIndices.SequenceEqual(new[] { 4, 5 }));
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "DuplicateElements01"), 1.0);

            // Try move
            ctx.MoveTo(328, 170);
            ctx.ViewportController.MouseDown();
            ctx.MoveTo(350, 150);
            ctx.ViewportController.MouseUp(false);
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "DuplicateElements02"), 1.0);
        }
コード例 #24
0
ファイル: BoxJointTests.cs プロジェクト: Macad3D/Macad3D
        public void VaryBoxCount()
        {
            var body1 = TestGeomGenerator.CreateBody(Box.Create(10, 2, 10), new Pnt(-5, -5, -5));
            var body2 = TestGeomGenerator.CreateBody(Box.Create(2, 10, 10), new Pnt(-5, -5, -5));

            var(first, second) = BoxJoint.Create(body1, body2);
            first.BoxCount     = 4;

            Assert.IsTrue(first.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(first, Path.Combine(_BasePath, "VaryBoxCount1"));

            Assert.IsTrue(second.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(second, Path.Combine(_BasePath, "VaryBoxCount2"));

            second.BoxCount = 5;

            Assert.IsTrue(first.Make(Shape.MakeFlags.None));
            AssertHelper.IsSameModel(first, Path.Combine(_BasePath, "VaryBoxCount3"));
        }
コード例 #25
0
        public void DuplicatedImmediatelyVisible()
        {
            // Bugcheck: This tests that after duplicating a body, the doublette is
            // visible without any other action.
            var ctx  = Context.Current;
            var body = TestGeomGenerator.CreateBox().Body;

            ctx.Document.AddChild(body);
            ctx.WorkspaceController.Selection.SelectEntity(body);
            ctx.WorkspaceController.Duplicate();
            Assume.That(ctx.Document.ChildCount == 2);

            // Deselect and hide original
            ctx.WorkspaceController.Selection.SelectEntity(null);
            body.IsVisible = false;

            ctx.ViewportController.ZoomFitAll();
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "DuplicatedImmediatelyVisible"));
        }
コード例 #26
0
        public void SketchPropertyPanels()
        {
            var ctx        = Context.Current;
            var propPanels = ctx.EnablePropertyPanels();

            var body = TestGeomGenerator.CreateBox().Body;

            body.Translate(new Vec(10, 10, 0));
            ctx.WorkspaceController.Selection.SelectEntity(body);
            ctx.ViewportController.ZoomFitAll();

            var tool = new CreateImprintTool(body);

            Assert.That(ctx.WorkspaceController.StartTool(tool));
            ctx.SelectAt(90, 250);
            Assert.IsInstanceOf <SketchEditorTool>(ctx.WorkspaceController.CurrentTool);

            // Body, BodyShape, Imprint, Sketch, SketchPoints, SketchSegments, SketchConstraints
            Assert.AreEqual(7, propPanels.Count);
        }
コード例 #27
0
        public void Ghosting()
        {
            var ctx = Context.Current;

            var box = TestGeomGenerator.CreateBox();

            box.Body.IsVisible = false;
            ctx.WorkspaceController.Selection.SelectEntity(box.Body);

            Assert.Multiple(() =>
            {
                ctx.ViewportController.ZoomFitAll();
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "Ghosting01"));

                // Update BRep
                box.DimensionX = box.DimensionX * 2.0;
                ctx.ViewportController.ZoomFitAll();
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "Ghosting02"));
            });
        }
コード例 #28
0
        public void SelectionFilterOnCreate()
        {
            var ctx = Context.Current;

            var body = TestGeomGenerator.CreateImprint().Body;

            body.Translate(new Vec(10, 10, 0));
            ctx.WorkspaceController.Selection.SelectEntity(body);
            ctx.ViewportController.ZoomFitAll();

            var tool = new CreateImprintTool(body);

            Assert.That(ctx.WorkspaceController.StartTool(tool));

            ctx.MoveTo(90, 250);
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SelectionFilterOnCreate1"));

            ctx.MoveTo(200, 277);
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SelectionFilterOnCreate2"));
        }
コード例 #29
0
        public void ImprintReselectTargetFace()
        {
            var ctx  = Context.Current;
            var body = TestGeomGenerator.CreateBox().Body;

            body.Translate(new Vec(10, 10, 0));
            ctx.WorkspaceController.Selection.SelectEntity(body);
            ctx.ViewportController.ZoomFitAll();

            // Build imprint
            var tool = new CreateImprintTool(body);

            Assume.That(ctx.WorkspaceController.StartTool(tool));
            ctx.SelectAt(90, 250);
            var sketchTool = ctx.WorkspaceController.CurrentTool as SketchEditorTool;

            Assume.That(sketchTool != null);

            Assert.Multiple(() =>
            {
                sketchTool.StartSegmentCreation <SketchSegmentCircleCreator>();
                ctx.SelectAt(250, 250);
                ctx.SelectAt(150, 250);
                sketchTool.Stop();
                ctx.MoveTo(250, 250);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ReselectTargetFace1"));

                // Start reselection, then cancel it
                ctx.WorkspaceController.StartTool(new CreateImprintTool(body.Shape as Imprint));
                ctx.MoveTo(300, 250);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ReselectTargetFace2"));
                ctx.WorkspaceController.CancelTool(ctx.WorkspaceController.CurrentTool, true);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "ReselectTargetFace4"));

                // Start reselection, perform
                ctx.WorkspaceController.StartTool(new CreateImprintTool(body.Shape as Imprint));
                ctx.SelectAt(300, 250);
                AssertHelper.IsSameViewport(@Path.Combine(_BasePath, "ReselectTargetFace3"));
                Assert.IsNull(ctx.WorkspaceController.CurrentTool);
            });
        }
コード例 #30
0
ファイル: CloneTests.cs プロジェクト: Macad3D/Macad3D
        public void CloneReferenceBodies()
        {
            var model        = CoreContext.Current.Document;
            var operandBody1 = TestGeomGenerator.CreateBody(Box.Create(5, 5, 5), new Pnt());

            model.Add(operandBody1);
            var targetBody1 = TestGeomGenerator.CreateBody(Box.Create(5, 5, 5), new Pnt(2, 2, 0));

            model.Add(targetBody1);
            BooleanFuse.Create(targetBody1, new BodyShapeOperand(operandBody1));
            var serialized = Serializer.Serialize(targetBody1, new SerializationContext());

            // Deserialize with reusing existing referenced bodies
            var context = new SerializationContext(SerializationScope.CopyPaste);

            context.SetInstance(model);
            context.SetInstance <IDocument>(model);
            context.SetInstance(ReadOptions.RecreateGuids);
            context.SetInstance(new CloneOptions(false));
            var targetBody2 = Serializer.Deserialize <Entity>(serialized, context) as Body;

            Assert.IsNotNull(targetBody2);
            var operandBody2 = ((targetBody2.RootShape as ModifierBase)?.Operands[1] as BodyShapeOperand)?.Body;

            Assert.IsNotNull(operandBody2);
            Assert.AreSame(operandBody1, operandBody2);

            // Deserialize with cloning referenced bodies
            context = new SerializationContext(SerializationScope.CopyPaste);
            context.SetInstance(model);
            context.SetInstance <IDocument>(model);
            context.SetInstance(ReadOptions.RecreateGuids);
            context.SetInstance(new CloneOptions(true));
            var targetBody3 = Serializer.Deserialize <Entity>(serialized, context) as Body;

            Assert.IsNotNull(targetBody3);
            var operandBody3 = ((targetBody3.RootShape as ModifierBase)?.Operands[1] as BodyShapeOperand)?.Body;

            Assert.IsNotNull(operandBody3);
            Assert.AreNotSame(operandBody1, operandBody3);
        }