Skip to content

Commit

Permalink
Merge pull request #111 from DomCR/DwgReader_missing-objects
Browse files Browse the repository at this point in the history
Dwg reader missing objects
  • Loading branch information
DomCR committed Jul 8, 2023
2 parents c612a20 + 210fb71 commit 7d8b3ae
Show file tree
Hide file tree
Showing 40 changed files with 1,050 additions and 52 deletions.
2 changes: 1 addition & 1 deletion ACadSharp.Examples/ACadSharp.Examples.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ACadSharp.Tests/ACadSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
6 changes: 5 additions & 1 deletion ACadSharp.Tests/Common/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ protected static T map<T>(T e)
.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
.Where(o => o.CanWrite && !o.PropertyType.IsClass && !o.PropertyType.IsEnum && !o.PropertyType.IsInterface))
{
p.SetValue(e, _random.Next(p.PropertyType));
try
{
p.SetValue(e, _random.Next(p.PropertyType));
}
catch (Exception) { }
}

return e;
Expand Down
12 changes: 12 additions & 0 deletions ACadSharp.Tests/DxfMapTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public void CreateMapTest(Type t)
case DxfFileToken.EntityLwPolyline:
DxfMap.Create<LwPolyline>();
break;
case DxfFileToken.EntityMesh:
DxfMap.Create<Mesh>();
break;
case DxfFileToken.EntityMLine:
DxfMap.Create<MLine>();
break;
Expand All @@ -133,6 +136,9 @@ public void CreateMapTest(Type t)
case DxfFileToken.EntityPoint:
DxfMap.Create<Point>();
break;
case DxfFileToken.EntityPolyFaceMesh:
DxfMap.Create<PolyfaceMesh>();
break;
case DxfFileToken.EntityPolyline:
switch (subclass.ClassName)
{
Expand Down Expand Up @@ -183,6 +189,9 @@ public void CreateMapTest(Type t)
case DxfSubclassMarker.Polyline3dVertex:
DxfMap.Create<Vertex3D>();
break;
case DxfSubclassMarker.PolyfaceMeshFace:
DxfMap.Create<FaceMesh>();
break;
default:
throw new NotImplementedException($"Test not implemented for type {t.Name}");
}
Expand All @@ -196,6 +205,9 @@ public void CreateMapTest(Type t)
case DxfFileToken.TableVport:
DxfMap.Create<VPort>();
break;
case DxfFileToken.EntityWipeout:
DxfMap.Create<Wipeout>();
break;
case DxfFileToken.EntityXline:
DxfMap.Create<XLine>();
break;
Expand Down
12 changes: 12 additions & 0 deletions ACadSharp.Tests/IO/DXF/DxfWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public DxfWriterTests(ITestOutputHelper output) : base(output) { }
[MemberData(nameof(Versions))]
public void WriteEmptyAsciiTest(ACadVersion version)
{
if (version < ACadVersion.AC1015)
// Not implemented
return;

CadDocument doc = new CadDocument();
doc.Header.Version = version;

Expand Down Expand Up @@ -46,6 +50,10 @@ public void WriteEmptyAsciiTest(ACadVersion version)
[MemberData(nameof(Versions))]
public void WriteEmptyBinaryTest(ACadVersion version)
{
if (version < ACadVersion.AC1015)
// Not implemented
return;

CadDocument doc = new CadDocument();
doc.Header.Version = version;

Expand Down Expand Up @@ -73,6 +81,10 @@ public void WriteEmptyBinaryTest(ACadVersion version)
[MemberData(nameof(Versions))]
public void WriteDocumentWithEntitiesTest(ACadVersion version)
{
if (version < ACadVersion.AC1015)
// Not implemented
return;

CadDocument doc = new CadDocument();
doc.Header.Version = version;

Expand Down
4 changes: 4 additions & 0 deletions ACadSharp.Tests/IO/IOTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public IOTestsBase(ITestOutputHelper output)
protected void onNotification(object sender, NotificationEventArgs e)
{
_output.WriteLine(e.Message);
if (e.Exception != null)
{
_output.WriteLine(e.Exception.ToString());
}
}

protected void checkDxfDocumentInAutocad(string path)
Expand Down
3 changes: 3 additions & 0 deletions ACadSharp/DxfFileToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static class DxfFileToken
public const string EntityOle2Frame = "OLE2FRAME";
public const string EntityPoint = "POINT";
public const string EntityPolyline = "POLYLINE";
public const string EntityPolyFaceMesh = "PFACE";
public const string EntityRay = "RAY";
public const string EntityRegion = "REGION";
public const string EntitySection = "SECTION";
Expand All @@ -92,6 +93,8 @@ public static class DxfFileToken

public const string ObjectsSection = "OBJECTS";
public const string ObjectDictionary = "DICTIONARY";
public const string ObjectDictionaryWithDefault = "ACDBDICTIONARYWDFLT";
public const string ObjectAcdbPlaceHolder = "ACDBPLACEHOLDER";
public const string ObjectDictionaryVar = "DICTIONARYVAR";
public const string ObjectPlotSettings = "PLOTSETTINGS";
public const string ObjectLayout = "LAYOUT";
Expand Down
2 changes: 2 additions & 0 deletions ACadSharp/DxfSubclassMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public static class DxfSubclassMarker
public const string Attribute = "AcDbAttribute";
public const string AttributeDefinition = "AcDbAttributeDefinition";
public const string Dictionary = "AcDbDictionary";
public const string DictionaryWithDefault = "AcDbDictionaryWithDefault";
public const string VisualStyle = "AcDbVisualStyle";
public const string XRecord = "AcDbXrecord";
public const string RasterImage = "AcDbRasterImage";
public const string RasterImageDef = "AcDbRasterImageDef";
Expand Down
17 changes: 17 additions & 0 deletions ACadSharp/Entities/ClipType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace ACadSharp.Entities
{
/// <summary>
/// Clipping boundary type
/// </summary>
public enum ClipType : short
{
/// <summary>
/// Rectangular
/// </summary>
Rectangular = 1,
/// <summary>
/// Polygonal
/// </summary>
Polygonal = 2
}
}
46 changes: 46 additions & 0 deletions ACadSharp/Entities/FaceMesh.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using ACadSharp.Attributes;

namespace ACadSharp.Entities
{
/// <summary>
/// Represents a <see cref="FaceMesh"/> entity.
/// </summary>
/// <remarks>
/// Object name <see cref="DxfFileToken.EntityVertex"/> <br/>
/// Dxf class name <see cref="DxfSubclassMarker.PolyfaceMeshFace"/>
/// </remarks>
[DxfName(DxfFileToken.EntityVertex)]
[DxfSubClass(DxfSubclassMarker.PolyfaceMeshFace)]
public class FaceMesh : Entity
{
/// <inheritdoc/>
public override ObjectType ObjectType { get { return ObjectType.VERTEX_PFACE_FACE; } }

/// <inheritdoc/>
public override string ObjectName => DxfFileToken.EntityVertex;

/// <summary>
/// Vert index BS 71 1 - based vertex index(see DXF doc)
/// </summary>
[DxfCodeValue(71)]
public short Index1 { get; set; }

/// <summary>
/// Vert index BS 72 1 - based vertex index(see DXF doc)
/// </summary>
[DxfCodeValue(72)]
public short Index2 { get; set; }

/// <summary>
/// Vert index BS 73 1 - based vertex index(see DXF doc)
/// </summary>
[DxfCodeValue(73)]
public short Index3 { get; set; }

/// <summary>
/// Vert index BS 74 1 - based vertex index(see DXF doc)
/// </summary>
[DxfCodeValue(74)]
public short Index4 { get; set; }
}
}
29 changes: 29 additions & 0 deletions ACadSharp/Entities/ImageDisplayFlags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;

namespace ACadSharp.Entities
{
[Flags]
public enum ImageDisplayFlags : short
{
/// <summary>
/// None
/// </summary>
None = 0,
/// <summary>
/// Show image
/// </summary>
ShowImage = 1,
/// <summary>
/// Show image when not aligned with screen
/// </summary>
ShowNotAlignedImage = 2,
/// <summary>
/// Use clipping boundary
/// </summary>
UseClippingBoundary = 8,
/// <summary>
/// Transparency is on
/// </summary>
TransparencyIsOn = 8
}
}
64 changes: 64 additions & 0 deletions ACadSharp/Entities/Mesh.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using ACadSharp.Attributes;
using System.Drawing;
using System;

namespace ACadSharp.Entities
{
/// <summary>
/// Represents a <see cref="Mesh"/> entity.
/// </summary>
/// <remarks>
/// Object name <see cref="DxfFileToken.EntityMesh"/> <br/>
/// Dxf class name <see cref="DxfSubclassMarker.Mesh"/>
/// </remarks>
[DxfName(DxfFileToken.EntityMesh)]
[DxfSubClass(DxfSubclassMarker.Mesh)]
public class Mesh : Entity
{
/// <inheritdoc/>
public override ObjectType ObjectType => ObjectType.UNLISTED;

/// <inheritdoc/>
public override string ObjectName => DxfFileToken.EntityMesh;

/// <summary>
/// Version number
/// </summary>
[DxfCodeValue(71)]
public short Version { get; internal set; }

//72 "Blend Crease" property
//0 = Turn off
//1 = Turn on

//91 Number of subdivision level

//92 Vertex count of level 0

//10 Vertex position

//93 Size of face list of level 0

//90 Face list item

//94 Edge count of level 0

//90 Vertex index of each edge

//95 Edge crease count of level 0

//140 Edge create value

//90 Count of sub-entity which property has been overridden

//91 Sub-entity marker

//92 Count of property was overridden

//90 Property type
//0 = Color
//1 = Material
//2 = Transparency
//3 = Material mapper
}
}
1 change: 0 additions & 1 deletion ACadSharp/Entities/Point.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ACadSharp.Attributes;
using ACadSharp.IO.Templates;
using CSMath;

namespace ACadSharp.Entities
Expand Down
32 changes: 32 additions & 0 deletions ACadSharp/Entities/PolyfaceMesh.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using ACadSharp.Attributes;

namespace ACadSharp.Entities
{
/// <summary>
/// Represents a <see cref="PolyfaceMesh"/> entity.
/// </summary>
/// <remarks>
/// Object name <see cref="DxfFileToken.EntityPolyFaceMesh"/> <br/>
/// Dxf class name <see cref="DxfSubclassMarker.PolyfaceMesh"/>
/// </remarks>
[DxfName(DxfFileToken.EntityPolyFaceMesh)]
[DxfSubClass(DxfSubclassMarker.PolyfaceMesh)]
public class PolyfaceMesh : Entity
{
/// <inheritdoc/>
public override ObjectType ObjectType { get { return ObjectType.POLYLINE_PFACE; } }

/// <inheritdoc/>
public override string ObjectName => DxfFileToken.EntityPolyFaceMesh;

public SeqendCollection<Vertex3D> Vertices { get; }

public SeqendCollection<FaceMesh> Faces { get; }

public PolyfaceMesh()
{
this.Vertices = new SeqendCollection<Vertex3D>(this);
this.Faces = new SeqendCollection<FaceMesh>(this);
}
}
}
5 changes: 0 additions & 5 deletions ACadSharp/Entities/Vertex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public abstract class Vertex : Entity, IVertex
[DxfCodeValue(DxfReferenceType.IsAngle, 50)]
public double CurveTangent { get; set; }

//71 Polyface mesh vertex index(optional; present only if nonzero)
//72 Polyface mesh vertex index(optional; present only if nonzero)
//73 Polyface mesh vertex index(optional; present only if nonzero)
//74 Polyface mesh vertex index(optional; present only if nonzero)

/// <summary>
/// Vertex identifier
/// </summary>
Expand Down
Loading

0 comments on commit 7d8b3ae

Please sign in to comment.