public void DiagonalLineOffsetTest() { var offset = (Line)EditUtilities.Offset( Workspace, new Line(new Point(0, 1, 0), new Point(1, 2, 0)), Point.Origin, 1.0); AssertClose(new Point(0.707106781186547, 0.292893218813453, 0), offset.P1); AssertClose(new Point(1.707106781186547, 1.292893218813453, 0), offset.P2); }
public void HorizontalLineOffsetDownTest() { var offset = (Line)EditUtilities.Offset( Workspace, new Line(new Point(0, 1, 0), new Point(1, 1, 0)), Point.Origin, 1.0); Assert.Equal(new Point(0, 0, 0), offset.P1); Assert.Equal(new Point(1, 0, 0), offset.P2); }
public void VerticalLineOffsetRightTest() { var offset = (Line)EditUtilities.Offset( Workspace, new Line(new Point(1, 0, 0), new Point(1, 1, 0)), new Point(2, 0, 0), 1.0); Assert.Equal(new Point(2, 0, 0), offset.P1); Assert.Equal(new Point(2, 1, 0), offset.P2); }
public void CircleOffsetOutsideTest() { var circle = (Circle)EditUtilities.Offset( Workspace, new Circle(Point.Origin, 2.0, Vector.ZAxis), new Point(3, 0, 0), 1.0); Assert.Equal(Point.Origin, circle.Center); Assert.Equal(3.0, circle.Radius); }
public void CircleOffsetProjectionBug() { // enuse we're using the correct projection matrix when verifying // whether the offset point is inside the circle or not var offset = (Circle)EditUtilities.Offset( Workspace, new Circle(new Point(100, 0, 0), 50, Vector.ZAxis), new Point(100, 0, 0), 10); Assert.Equal(new Point(100, 0, 0), offset.Center); Assert.Equal(40, offset.Radius); }
public void CircleOffsetInsideTest() { var offset = EditUtilities.Offset( Workspace, new Circle(Point.Origin, 2.0, Vector.ZAxis), Point.Origin, 1.0); Assert.True(offset is Circle); var circle = (Circle)offset; Assert.Equal(Point.Origin, circle.Center); Assert.Equal(1.0, circle.Radius); }
public void OffsetPointDirectlyOnEntity() { // line var offset = EditUtilities.Offset( Workspace, new Line(new Point(-1, 0, 0), new Point(1, 0, 0)), Point.Origin, 1.0); Assert.Null(offset); // circle offset = EditUtilities.Offset( Workspace, new Circle(Point.Origin, 1.0, Vector.ZAxis), new Point(1.0, 0, 0), 1.0); Assert.Null(offset); }
public async Task <bool> Execute(IWorkspace workspace, object arg) { var drawingPlane = workspace.DrawingPlane; var distance = await workspace.InputService.GetDistance(defaultDistance : lastOffsetDistance); if (distance.Cancel) { return(false); } double dist; if (distance.HasValue) { dist = distance.Value; } else { dist = lastOffsetDistance; } workspace.OutputService.WriteLine("Using offset distance of {0}", dist); lastOffsetDistance = dist; var selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); while (!selection.Cancel && selection.HasValue) { var ent = selection.Value.Entity; if (!EditUtilities.CanOffsetEntity(ent)) { workspace.OutputService.WriteLine("Unable to offset {0}", ent.Kind); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); continue; } if (!drawingPlane.Contains(ent)) { workspace.OutputService.WriteLine("Entity must be entirely on the drawing plane to offset"); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); continue; } workspace.SelectedEntities.Clear(); workspace.SelectedEntities.Add(ent); var point = await workspace.InputService.GetPoint(new UserDirective("Side to offset")); if (point.Cancel || !point.HasValue) { break; } if (!drawingPlane.Contains(point.Value)) { workspace.OutputService.WriteLine("Point must be on the drawing plane to offset"); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); continue; } // do the actual offset var updated = EditUtilities.Offset(workspace, ent, point.Value, dist); if (updated != null) { var oldLayer = workspace.Drawing.ContainingLayer(ent); workspace.Add(oldLayer, updated); } workspace.SelectedEntities.Clear(); selection = await workspace.InputService.GetEntity(new UserDirective("Select entity")); } return(true); }