-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 20240619_mme_#6-support-dynamic-blocks-rea…
…d-evaluation-graphs-and-block-visibility-parameters
- Loading branch information
Showing
21 changed files
with
372 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using ACadSharp.Entities; | ||
using ACadSharp.Tests.Common; | ||
using CSMath; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace ACadSharp.Tests.Entities | ||
{ | ||
public class ViewportTests | ||
{ | ||
[Fact] | ||
public void GetBoundingBoxTest() | ||
{ | ||
Viewport viewport = new Viewport(); | ||
viewport.Width = 100; | ||
viewport.Height = 50; | ||
viewport.Center = new XYZ(10, 10, 0); | ||
|
||
BoundingBox boundingBox = viewport.GetBoundingBox(); | ||
|
||
AssertUtils.AreEqual(viewport.Center, boundingBox.Center); | ||
AssertUtils.AreEqual(new XYZ(-40, -15, 0), boundingBox.Min); | ||
AssertUtils.AreEqual(new XYZ(60, 35, 0), boundingBox.Max); | ||
} | ||
|
||
[Fact] | ||
public void GetModelBoundingBoxTest() | ||
{ | ||
Viewport viewport = new Viewport(); | ||
viewport.Width = 100; | ||
viewport.Height = 50; | ||
viewport.ViewHeight = 50; | ||
viewport.ViewCenter = new XY(10, 10); | ||
|
||
BoundingBox boundingBox = viewport.GetModelBoundingBox(); | ||
|
||
Assert.Equal(100, viewport.ViewWidth); | ||
AssertUtils.AreEqual(viewport.ViewCenter, ((XY)boundingBox.Center)); | ||
AssertUtils.AreEqual(new XYZ(-40, -15, 0), boundingBox.Min); | ||
AssertUtils.AreEqual(new XYZ(60, 35, 0), boundingBox.Max); | ||
} | ||
|
||
[Fact] | ||
public void SelectEntitiesTest() | ||
{ | ||
CadDocument doc = new CadDocument(); | ||
|
||
Viewport viewport = new Viewport(); | ||
viewport.Width = 100; | ||
viewport.Height = 50; | ||
viewport.ViewHeight = 50; | ||
viewport.ViewCenter = new XY(10, 10); | ||
|
||
//Viewbox | ||
//min: -40, -15 | ||
//max: 60, 35 | ||
|
||
doc.PaperSpace.Entities.Add(viewport); | ||
|
||
//Entities in the view | ||
Point ptIn = new Point(new XYZ(0, 0, 0)); | ||
Line lineIn = new Line(new XYZ(), new XYZ(100, 100, 0)); | ||
|
||
List<Entity> inView = new List<Entity> | ||
{ | ||
ptIn, | ||
lineIn | ||
}; | ||
doc.Entities.AddRange(inView); | ||
|
||
//Entities out the view | ||
Point ptOut = new Point(new XYZ(100, 100, 0)); | ||
|
||
List<Entity> outView = new List<Entity> | ||
{ | ||
ptOut | ||
}; | ||
doc.Entities.AddRange(outView); | ||
|
||
var selected = viewport.SelectEntities(); | ||
|
||
Assert.NotEmpty(selected); | ||
|
||
foreach (Entity e in selected) | ||
{ | ||
Assert.Contains(e, inView); | ||
Assert.DoesNotContain(e, outView); | ||
} | ||
|
||
var selectedPartial = viewport.SelectEntities(false); | ||
Assert.DoesNotContain(lineIn, selectedPartial); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using ACadSharp.Entities; | ||
using ACadSharp.IO; | ||
using ACadSharp.Tests.TestModels; | ||
using System.IO; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace ACadSharp.Tests.IO | ||
{ | ||
public class ViewportTests : IOTestsBase | ||
{ | ||
public ViewportTests(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(DwgFilePaths))] | ||
[MemberData(nameof(DxfAsciiFiles))] | ||
public void ScaleInViewport(FileModel test) | ||
{ | ||
CadDocument doc; | ||
if (Path.GetExtension(test.FileName).Equals(".dxf")) | ||
{ | ||
doc = DxfReader.Read(test.Path); | ||
} | ||
else | ||
{ | ||
doc = DwgReader.Read(test.Path); | ||
} | ||
|
||
ACadSharp.Tables.BlockRecord paper = doc.PaperSpace; | ||
foreach (Viewport v in paper.Viewports) | ||
{ | ||
Assert.NotNull(v.Scale); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.