Repository navigation
Read the surface entity family as modeler geometry #1155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0c6026a
Read the surface entity family as modeler geometry
ilCosmico f6d2833
Skip the surface entities in the DWG and DXF writers
ilCosmico 7a6958e
Use file-scoped namespaces in the surface entity files
ilCosmico 8beb660
Define the DXF class of the surface entities
ilCosmico 369f908
Remove the DXF surface reading tests
ilCosmico d05ea12
Remove the modeler geometry comment from readSurface
ilCosmico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,128 @@ | ||
| using ACadSharp.Entities; | ||
| using ACadSharp.IO; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using Xunit; | ||
|
|
||
| namespace ACadSharp.Tests.IO.DXF; | ||
|
|
||
| public class DxfSurfaceTests | ||
| { | ||
| [Fact] | ||
| public void ReadGenericSurface() | ||
| { | ||
| CadDocument doc = readDxf(surfaceDxf("SURFACE", "AcDbSurface")); | ||
|
|
||
| Surface surface = Assert.IsType<Surface>(doc.Entities.Single()); | ||
| Assert.Equal(6, surface.UIsolines); | ||
| Assert.Equal(7, surface.VIsolines); | ||
| Assert.Equal(SatHeader + "\n" + SatBody, surface.GetAcisText()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ReadPlaneSurface() | ||
| { | ||
| CadDocument doc = readDxf(surfaceDxf("PLANESURFACE", "AcDbSurface", "AcDbPlaneSurface")); | ||
|
|
||
| PlaneSurface surface = Assert.IsType<PlaneSurface>(doc.Entities.Single()); | ||
| Assert.Equal(6, surface.UIsolines); | ||
| Assert.Equal(7, surface.VIsolines); | ||
| Assert.Equal(SatHeader + "\n" + SatBody, surface.GetAcisText()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ReadExtrudedSurface() | ||
| { | ||
| CadDocument doc = readDxf(surfaceDxf("EXTRUDEDSURFACE", "AcDbSurface", "AcDbExtrudedSurface")); | ||
|
|
||
| ExtrudedSurface surface = Assert.IsType<ExtrudedSurface>(doc.Entities.Single()); | ||
| Assert.Equal(6, surface.UIsolines); | ||
| Assert.Equal(7, surface.VIsolines); | ||
| Assert.Equal(SatHeader + "\n" + SatBody, surface.GetAcisText()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ReadLoftedSurface() | ||
| { | ||
| CadDocument doc = readDxf(surfaceDxf("LOFTEDSURFACE", "AcDbSurface", "AcDbLoftedSurface")); | ||
|
|
||
| Assert.IsType<LoftedSurface>(doc.Entities.Single()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ReadRevolvedSurface() | ||
| { | ||
| CadDocument doc = readDxf(surfaceDxf("REVOLVEDSURFACE", "AcDbSurface", "AcDbRevolvedSurface")); | ||
|
|
||
| Assert.IsType<RevolvedSurface>(doc.Entities.Single()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ReadSweptSurface() | ||
| { | ||
| CadDocument doc = readDxf(surfaceDxf("SWEPTSURFACE", "AcDbSurface", "AcDbSweptSurface")); | ||
|
|
||
| Assert.IsType<SweptSurface>(doc.Entities.Single()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ReadNurbSurface() | ||
| { | ||
| CadDocument doc = readDxf(surfaceDxf("NURBSURFACE", "AcDbSurface", "AcDbNurbSurface")); | ||
|
|
||
| Assert.IsType<NurbSurface>(doc.Entities.Single()); | ||
| } | ||
|
|
||
| private const string SatHeader = "400 0 1 0"; | ||
|
|
||
| private const string SatBody = "body $-1 $1 $-1 $-1 #"; | ||
|
|
||
| //A minimal entities section with one surface entity: the modeler geometry | ||
| //codes (70, 1, 3) carry the SAT text, the AcDbSurface codes 71 and 72 the | ||
| //isoline counts, followed by the empty subclass of the derived surface. | ||
| private static string surfaceDxf(string name, params string[] subclasses) | ||
| { | ||
| StringBuilder dxf = new StringBuilder(); | ||
| void add(string code, string value) | ||
| { | ||
| dxf.Append(code).Append('\n').Append(value).Append('\n'); | ||
| } | ||
|
|
||
| add("0", "SECTION"); | ||
| add("2", "ENTITIES"); | ||
| add("0", name); | ||
| add("5", "A1"); | ||
| add("100", "AcDbEntity"); | ||
| add("8", "0"); | ||
| add("100", "AcDbModelerGeometry"); | ||
| add("70", "1"); | ||
| add("1", SatHeader); | ||
| add("1", SatBody); | ||
|
|
||
| foreach (string subclass in subclasses) | ||
| { | ||
| add("100", subclass); | ||
|
|
||
| if (subclass == "AcDbSurface") | ||
| { | ||
| add("71", "6"); | ||
| add("72", "7"); | ||
| } | ||
| } | ||
|
|
||
| add("0", "ENDSEC"); | ||
| add("0", "EOF"); | ||
|
|
||
| return dxf.ToString(); | ||
| } | ||
|
|
||
| private static CadDocument readDxf(string dxf) | ||
| { | ||
| using (MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes(dxf))) | ||
| using (DxfReader reader = new DxfReader(stream)) | ||
| { | ||
| return reader.Read(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
| using ACadSharp.Attributes; | ||
| using ACadSharp.Classes; | ||
|
|
||
| namespace ACadSharp.Entities; | ||
|
|
||
| /// <summary> | ||
| /// Represents an <see cref="ExtrudedSurface"/> entity. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Object name <see cref="DxfFileToken.EntityExtrudedSurface"/> <br/> | ||
| /// Dxf class name <see cref="DxfSubclassMarker.ExtrudedSurface"/> | ||
| /// </remarks> | ||
| [DxfName(DxfFileToken.EntityExtrudedSurface)] | ||
| [DxfSubClass(DxfSubclassMarker.ExtrudedSurface)] | ||
| public class ExtrudedSurface : Surface | ||
| { | ||
| /// <inheritdoc/> | ||
| public override string ObjectName => DxfFileToken.EntityExtrudedSurface; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string SubclassMarker => DxfSubclassMarker.ExtrudedSurface; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override DxfClass GetDxfClass() | ||
| { | ||
| return new DxfClass | ||
| { | ||
| CppClassName = DxfSubclassMarker.ExtrudedSurface, | ||
| DwgVersion = (ACadVersion)26, | ||
| DxfName = DxfFileToken.EntityExtrudedSurface, | ||
| ItemClassId = 498, | ||
| MaintenanceVersion = 0, | ||
| ProxyFlags = ProxyFlags.None, | ||
| WasZombie = false, | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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,37 @@ | ||
| using ACadSharp.Attributes; | ||
| using ACadSharp.Classes; | ||
|
|
||
| namespace ACadSharp.Entities; | ||
|
|
||
| /// <summary> | ||
| /// Represents a <see cref="LoftedSurface"/> entity. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Object name <see cref="DxfFileToken.EntityLoftedSurface"/> <br/> | ||
| /// Dxf class name <see cref="DxfSubclassMarker.LoftedSurface"/> | ||
| /// </remarks> | ||
| [DxfName(DxfFileToken.EntityLoftedSurface)] | ||
| [DxfSubClass(DxfSubclassMarker.LoftedSurface)] | ||
| public class LoftedSurface : Surface | ||
| { | ||
| /// <inheritdoc/> | ||
| public override string ObjectName => DxfFileToken.EntityLoftedSurface; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string SubclassMarker => DxfSubclassMarker.LoftedSurface; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override DxfClass GetDxfClass() | ||
| { | ||
| return new DxfClass | ||
| { | ||
| CppClassName = DxfSubclassMarker.LoftedSurface, | ||
| DwgVersion = (ACadVersion)26, | ||
| DxfName = DxfFileToken.EntityLoftedSurface, | ||
| ItemClassId = 498, | ||
| MaintenanceVersion = 0, | ||
| ProxyFlags = ProxyFlags.None, | ||
| WasZombie = false, | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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,37 @@ | ||
| using ACadSharp.Attributes; | ||
| using ACadSharp.Classes; | ||
|
|
||
| namespace ACadSharp.Entities; | ||
|
|
||
| /// <summary> | ||
| /// Represents a <see cref="NurbSurface"/> entity. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Object name <see cref="DxfFileToken.EntityNurbSurface"/> <br/> | ||
| /// Dxf class name <see cref="DxfSubclassMarker.NurbSurface"/> | ||
| /// </remarks> | ||
| [DxfName(DxfFileToken.EntityNurbSurface)] | ||
| [DxfSubClass(DxfSubclassMarker.NurbSurface)] | ||
| public class NurbSurface : Surface | ||
| { | ||
| /// <inheritdoc/> | ||
| public override string ObjectName => DxfFileToken.EntityNurbSurface; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string SubclassMarker => DxfSubclassMarker.NurbSurface; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override DxfClass GetDxfClass() | ||
| { | ||
| return new DxfClass | ||
| { | ||
| CppClassName = DxfSubclassMarker.NurbSurface, | ||
| DwgVersion = (ACadVersion)26, | ||
| DxfName = DxfFileToken.EntityNurbSurface, | ||
| ItemClassId = 498, | ||
| MaintenanceVersion = 0, | ||
| ProxyFlags = (ProxyFlags)4095, | ||
| WasZombie = false, | ||
| }; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.