From ad9289b30c15eb20e0b55f1c0e2f5f3d8577c305 Mon Sep 17 00:00:00 2001 From: DomCR Date: Tue, 24 Sep 2024 12:01:52 +0200 Subject: [PATCH 01/17] submodules --- src/CSUtilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CSUtilities b/src/CSUtilities index bfd1ba4e..d03bb020 160000 --- a/src/CSUtilities +++ b/src/CSUtilities @@ -1 +1 @@ -Subproject commit bfd1ba4e2117d086850a1f01a81121fab08345d6 +Subproject commit d03bb0208febed107485abdabac4a466cd043bdc From 9d95a94f9fda365471e58c551f3f51634c665886 Mon Sep 17 00:00:00 2001 From: DomCR Date: Tue, 24 Sep 2024 12:13:08 +0200 Subject: [PATCH 02/17] update utilities --- src/ACadSharp/Entities/Arc.cs | 4 +- .../DxfStreamReader/DxfSectionReaderBase.cs | 4 +- .../DxfStreamReader/DxfStreamReaderBase.cs | 3 +- .../DxfStreamReader/DxfTablesSectionReader.cs | 2 +- .../DxfSectionWriterBase.Entities.cs | 2 +- .../DxfStreamWriter/DxfStreamWriterBase.cs | 5 ++- .../DxfStreamWriter/DxfTablesSectionWriter.cs | 3 +- src/ACadSharp/IO/Templates/CadArcTemplate.cs | 11 +---- src/ACadSharp/MathUtils.cs | 45 +------------------ src/ACadSharp/Tables/DimensionStyle.cs | 2 +- src/CSUtilities | 2 +- 11 files changed, 17 insertions(+), 66 deletions(-) diff --git a/src/ACadSharp/Entities/Arc.cs b/src/ACadSharp/Entities/Arc.cs index dc7cbba2..0d89dac9 100644 --- a/src/ACadSharp/Entities/Arc.cs +++ b/src/ACadSharp/Entities/Arc.cs @@ -118,8 +118,8 @@ public List PolygonalVertexes(int precision) double cosine = this.Radius * Math.Cos(angle); double sine = this.Radius * Math.Sin(angle); - cosine = MathUtils.IsZero(cosine) ? 0 : cosine; - sine = MathUtils.IsZero(sine) ? 0 : sine; + cosine = Utilities.IsZero(cosine) ? 0 : cosine; + sine = Utilities.IsZero(sine) ? 0 : sine; ocsVertexes.Add(new XY(cosine, sine)); } diff --git a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs index 26030894..5573bc27 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs @@ -374,7 +374,7 @@ private bool readDimension(CadEntityTemplate template, DxfMap map, string subcla case 50: var dim = new DimensionLinear(); tmp.SetDimensionObject(dim); - dim.Rotation = CSMath.MathUtils.DegToRad(this._reader.ValueAsDouble); + dim.Rotation = CSMath.Utilities.DegToRad(this._reader.ValueAsDouble); map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create()); return true; case 70: @@ -1395,7 +1395,7 @@ protected bool tryAssignCurrentValue(CadObject cadObject, DxfClassMap map) if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle)) { - value = (double)value * MathUtils.DegToRadFactor; + value = (double)value * Utilities.DegToRadFactor; } dxfProperty.SetValue(this._reader.Code, cadObject, value); diff --git a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs index 8e34f3fc..a2235cb6 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs @@ -1,4 +1,5 @@ using ACadSharp.Exceptions; +using CSMath; using System; using System.IO; @@ -42,7 +43,7 @@ public string ValueAsString public double ValueAsDouble { get { return Convert.ToDouble(this.Value); } } - public double ValueAsAngle { get { return (double)(Convert.ToDouble(this.Value) * MathUtils.RadToDegFactor); } } + public double ValueAsAngle { get { return (double)(Convert.ToDouble(this.Value) * Utilities.RadToDegFactor); } } public ulong ValueAsHandle { get { return (ulong)this.Value; } } diff --git a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfTablesSectionReader.cs b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfTablesSectionReader.cs index c1978b2a..ec321f9a 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfTablesSectionReader.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfTablesSectionReader.cs @@ -356,7 +356,7 @@ private bool readDimensionStyle(CadTableEntryTemplate template, template.CadObject.FixedExtensionLineLength = this._reader.ValueAsDouble; return true; case 50: - template.CadObject.JoggedRadiusDimensionTransverseSegmentAngle = CSMath.MathUtils.DegToRad(this._reader.ValueAsDouble); + template.CadObject.JoggedRadiusDimensionTransverseSegmentAngle = CSMath.Utilities.DegToRad(this._reader.ValueAsDouble); return true; case 69: template.CadObject.TextBackgroundFillMode = (DimensionTextBackgroundFillMode)this._reader.ValueAsShort; diff --git a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs index c3c679d2..e6da0ed1 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs @@ -406,7 +406,7 @@ private void writeHatchPattern(Hatch hatch, HatchPattern pattern) if (!hatch.IsSolid) { - this._writer.Write(52, pattern.Angle * MathUtils.RadToDegFactor); + this._writer.Write(52, pattern.Angle * Utilities.RadToDegFactor); this._writer.Write(41, pattern.Scale); this._writer.Write(77, (short)(hatch.IsDouble ? 1 : 0)); this._writer.Write(78, (short)pattern.Lines.Count); diff --git a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfStreamWriterBase.cs b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfStreamWriterBase.cs index d996f6d4..fef4446e 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfStreamWriterBase.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfStreamWriterBase.cs @@ -1,4 +1,5 @@ -using CSUtilities.Converters; +using CSMath; +using CSUtilities.Converters; using System; @@ -92,7 +93,7 @@ public void Write(int code, object value, DxfClassMap map) if (prop.ReferenceType.HasFlag(DxfReferenceType.IsAngle)) { - value = (double)value * MathUtils.RadToDegFactor; + value = (double)value * Utilities.RadToDegFactor; } } diff --git a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs index e68dc619..1ce72c46 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs @@ -1,5 +1,6 @@ using ACadSharp.Tables; using ACadSharp.Tables.Collections; +using CSMath; using System; using System.Linq; @@ -276,7 +277,7 @@ private void writeLineType(LineType linetype, DxfClassMap map) } this._writer.Write(46, s.Scale); - this._writer.Write(50, s.Rotation * MathUtils.DegToRadFactor); + this._writer.Write(50, s.Rotation * Utilities.DegToRadFactor); this._writer.Write(44, s.Offset.X); this._writer.Write(45, s.Offset.Y); this._writer.Write(9, s.Text); diff --git a/src/ACadSharp/IO/Templates/CadArcTemplate.cs b/src/ACadSharp/IO/Templates/CadArcTemplate.cs index 4ee4cfe7..af96f5da 100644 --- a/src/ACadSharp/IO/Templates/CadArcTemplate.cs +++ b/src/ACadSharp/IO/Templates/CadArcTemplate.cs @@ -1,6 +1,5 @@ using System; using ACadSharp.Entities; -using ACadSharp.IO.DXF; namespace ACadSharp.IO.Templates { @@ -13,17 +12,9 @@ public CadArcTemplate() : base(new Arc()) { } public CadArcTemplate(Entity entity) : base(entity) { } - public override void Build(CadDocumentBuilder builder) + public override void Build(CadDocumentBuilder builder) { base.Build(builder); - - return; - - if (builder is DxfDocumentBuilder && this.CadObject is Arc arc) - { - arc.StartAngle *= MathUtils.DegToRadFactor; - arc.EndAngle *= MathUtils.DegToRadFactor; - } } } } diff --git a/src/ACadSharp/MathUtils.cs b/src/ACadSharp/MathUtils.cs index 75e4c051..23966f60 100644 --- a/src/ACadSharp/MathUtils.cs +++ b/src/ACadSharp/MathUtils.cs @@ -5,49 +5,6 @@ namespace ACadSharp { public static class MathUtils { - /// - /// Factor for converting radians to degrees. - /// - public const double RadToDegFactor = (180 / Math.PI); - - /// - /// Factor for converting degrees to radians. - /// - public const double DegToRadFactor = (Math.PI / 180); - - public const double Epsilon = 1e-12; - - /// - /// Checks if a number is close to zero. - /// - /// Double precision number. - /// True if its close to one or false in any other case. - public static bool IsZero(double number) - { - return IsZero(number, Epsilon); - } - - /// - /// Checks if a number is close to zero. - /// - /// Double precision number. - /// Tolerance. - /// True if its close to one or false in any other case. - public static bool IsZero(double number, double threshold) - { - return number >= -threshold && number <= threshold; - } - - public static double RadToDeg(double value) - { - return value * RadToDegFactor; - } - - public static double DegToRad(double value) - { - return value * DegToRadFactor; - } - public static XY GetCenter(XY start, XY end, double bulge) { return GetCenter(start, end, bulge, out _); @@ -61,7 +18,7 @@ public static XY GetCenter(XY start, XY end, double bulge, out double radius) double gamma = (Math.PI - theta) / 2; double phi = (end - start).GetAngle() + Math.Sign(bulge) * gamma; - return new XY(start.X + radius * CSMath.MathUtils.Cos(phi), start.Y + radius * CSMath.MathUtils.Sin(phi)); + return new XY(start.X + radius * CSMath.Utilities.Cos(phi), start.Y + radius * CSMath.Utilities.Sin(phi)); } /// diff --git a/src/ACadSharp/Tables/DimensionStyle.cs b/src/ACadSharp/Tables/DimensionStyle.cs index d990d726..9a747f47 100644 --- a/src/ACadSharp/Tables/DimensionStyle.cs +++ b/src/ACadSharp/Tables/DimensionStyle.cs @@ -538,7 +538,7 @@ public double JoggedRadiusDimensionTransverseSegmentAngle set { //5 - 90 - if (value < CSMath.MathUtils.DegToRad(5) || value > Math.PI / 2) + if (value < CSMath.Utilities.DegToRad(5) || value > Math.PI / 2) { throw new ArgumentOutOfRangeException(nameof(value), value, $"The {nameof(JoggedRadiusDimensionTransverseSegmentAngle)} must be in range of 5 to 90 degrees."); } diff --git a/src/CSUtilities b/src/CSUtilities index d03bb020..c42c0e20 160000 --- a/src/CSUtilities +++ b/src/CSUtilities @@ -1 +1 @@ -Subproject commit d03bb0208febed107485abdabac4a466cd043bdc +Subproject commit c42c0e20dcaaadda45ee537041ac4312d2b2ad89 From 821b99710342d90a7add465b41365a9d3d8f27de Mon Sep 17 00:00:00 2001 From: DomCR Date: Tue, 24 Sep 2024 12:22:33 +0200 Subject: [PATCH 03/17] entity abstract methods --- src/ACadSharp/Entities/Entity.cs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ACadSharp/Entities/Entity.cs b/src/ACadSharp/Entities/Entity.cs index 0e1d9f2c..0ccb3c88 100644 --- a/src/ACadSharp/Entities/Entity.cs +++ b/src/ACadSharp/Entities/Entity.cs @@ -93,7 +93,32 @@ public LineType LineType public Entity() : base() { } /// - /// Gets the bounding box aligned with the axis XYZ that ocupies this entity + /// Apply a translation to this entity. + /// + /// + public abstract void Translate(XYZ translation); + + /// + /// Apply a rotation to this entity. + /// + /// + /// + public abstract void Rotate(double rotation, XYZ axis); + + /// + /// Apply a scale to this entity. + /// + /// + public abstract void Scale(XYZ scale); + + /// + /// Apply a transform matrix to this entity. + /// + /// + public abstract void ApplyTransform(Transform transform); + + /// + /// Gets the bounding box aligned with the axis XYZ that occupies this entity /// /// public abstract BoundingBox GetBoundingBox(); From cbcc68deaedbab17b3eb58e679ae3cbfc11340b0 Mon Sep 17 00:00:00 2001 From: DomCR Date: Tue, 24 Sep 2024 15:53:31 +0200 Subject: [PATCH 04/17] implementation --- .../Entities/CommonEntityTests.cs | 25 +++++++++++++ src/ACadSharp.Tests/Entities/PointTests.cs | 26 ++++++++++++++ src/ACadSharp.Tests/IO/IOTestsBase.cs | 2 +- src/ACadSharp/Blocks/Block.cs | 26 +++++++++++++- src/ACadSharp/Blocks/BlockEnd.cs | 24 +++++++++++++ src/ACadSharp/Entities/CadImageBase.cs | 20 +++++++++++ src/ACadSharp/Entities/Circle.cs | 20 +++++++++++ src/ACadSharp/Entities/Dimension.cs | 8 ++--- src/ACadSharp/Entities/DimensionAligned.cs | 20 +++++++++++ .../Entities/DimensionAngular2Line.cs | 20 +++++++++++ src/ACadSharp/Entities/DimensionAngular3Pt.cs | 20 +++++++++++ src/ACadSharp/Entities/DimensionDiameter.cs | 20 +++++++++++ src/ACadSharp/Entities/DimensionOrdinate.cs | 20 +++++++++++ src/ACadSharp/Entities/DimensionRadius.cs | 20 +++++++++++ src/ACadSharp/Entities/Ellipse.cs | 20 +++++++++++ src/ACadSharp/Entities/Face3D.cs | 20 +++++++++++ .../Entities/Hatch.BoundaryPath.Arc.cs | 12 +++---- src/ACadSharp/Entities/Hatch.cs | 21 +++++++++++ src/ACadSharp/Entities/Insert.cs | 20 +++++++++++ src/ACadSharp/Entities/Leader.cs | 20 +++++++++++ src/ACadSharp/Entities/Line.cs | 20 +++++++++++ src/ACadSharp/Entities/LwPolyLine.cs | 21 +++++++++++ src/ACadSharp/Entities/MLine.cs | 21 +++++++++++ src/ACadSharp/Entities/MText.cs | 20 +++++++++++ src/ACadSharp/Entities/Mesh.cs | 21 +++++++++++ src/ACadSharp/Entities/MultiLeader.cs | 36 ++++++++++++++----- src/ACadSharp/Entities/Point.cs | 20 +++++++++++ src/ACadSharp/Entities/PolyLine.cs | 21 +++++++++++ src/ACadSharp/Entities/Ray.cs | 20 +++++++++++ src/ACadSharp/Entities/Seqend.cs | 20 +++++++++++ src/ACadSharp/Entities/Shape.cs | 20 +++++++++++ src/ACadSharp/Entities/Solid.cs | 20 +++++++++++ src/ACadSharp/Entities/Solid3D.cs | 20 +++++++++++ src/ACadSharp/Entities/Spline.cs | 22 +++++++++++- src/ACadSharp/Entities/TextEntity.cs | 20 +++++++++++ src/ACadSharp/Entities/Tolerance.cs | 20 +++++++++++ src/ACadSharp/Entities/UnderlayEntity.cs | 20 +++++++++++ src/ACadSharp/Entities/UnknownEntity.cs | 21 +++++++++++ src/ACadSharp/Entities/Vertex.cs | 21 +++++++++++ src/ACadSharp/Entities/ViewPort.cs | 20 +++++++++++ src/ACadSharp/Entities/XLine.cs | 20 +++++++++++ .../IO/Templates/CadDimensionTemplate.cs | 20 +++++++++++ 42 files changed, 827 insertions(+), 21 deletions(-) create mode 100644 src/ACadSharp.Tests/Entities/CommonEntityTests.cs create mode 100644 src/ACadSharp.Tests/Entities/PointTests.cs diff --git a/src/ACadSharp.Tests/Entities/CommonEntityTests.cs b/src/ACadSharp.Tests/Entities/CommonEntityTests.cs new file mode 100644 index 00000000..bbbf5d08 --- /dev/null +++ b/src/ACadSharp.Tests/Entities/CommonEntityTests.cs @@ -0,0 +1,25 @@ +using ACadSharp.Entities; +using Xunit; + +namespace ACadSharp.Tests.Entities +{ + public abstract class CommonEntityTests + where T : Entity, new() + { + [Fact] + public void DefaultConstructor() + { + T entity = new T(); + + Assert.NotNull(entity); + Assert.True(0 == entity.Handle); + + Assert.NotEqual(ObjectType.UNDEFINED, entity.ObjectType); + + Assert.False(string.IsNullOrEmpty(entity.ObjectName)); + Assert.False(string.IsNullOrEmpty(entity.SubclassMarker)); + + Assert.Null(entity.XDictionary); + } + } +} diff --git a/src/ACadSharp.Tests/Entities/PointTests.cs b/src/ACadSharp.Tests/Entities/PointTests.cs new file mode 100644 index 00000000..f8bd6b36 --- /dev/null +++ b/src/ACadSharp.Tests/Entities/PointTests.cs @@ -0,0 +1,26 @@ +using ACadSharp.Entities; +using ACadSharp.Tests.Common; +using CSMath; +using Xunit; + +namespace ACadSharp.Tests.Entities +{ + public class PointTests : CommonEntityTests + { + private CSMathRandom _random = new CSMathRandom(); + + [Fact] + public void TranslateTest() + { + XYZ init = _random.Next(); + XYZ translation = _random.Next(); + XYZ result = init + translation; + + Point point = new Point(init); + + point.Translate(translation); + + AssertUtils.AreEqual(result, point.Location, "Point Location"); + } + } +} diff --git a/src/ACadSharp.Tests/IO/IOTestsBase.cs b/src/ACadSharp.Tests/IO/IOTestsBase.cs index 608165a8..abd0887d 100644 --- a/src/ACadSharp.Tests/IO/IOTestsBase.cs +++ b/src/ACadSharp.Tests/IO/IOTestsBase.cs @@ -97,7 +97,7 @@ protected static void loadSamples(string folder, string ext, TheoryData /// - /// Cloning a block will also unatach it from the record + /// Cloning a block will also unattached it from the record /// public override CadObject Clone() { @@ -86,6 +86,30 @@ public override CadObject Clone() return clone; } + /// + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + /// + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + /// + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } + + /// public override BoundingBox GetBoundingBox() { BoundingBox box = BoundingBox.Null; diff --git a/src/ACadSharp/Blocks/BlockEnd.cs b/src/ACadSharp/Blocks/BlockEnd.cs index 9629d02d..3850e7cd 100644 --- a/src/ACadSharp/Blocks/BlockEnd.cs +++ b/src/ACadSharp/Blocks/BlockEnd.cs @@ -43,5 +43,29 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } + + /// + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + /// + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + /// + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + /// + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/CadImageBase.cs b/src/ACadSharp/Entities/CadImageBase.cs index d917d42e..93cf7486 100644 --- a/src/ACadSharp/Entities/CadImageBase.cs +++ b/src/ACadSharp/Entities/CadImageBase.cs @@ -189,6 +189,26 @@ internal ImageDefinitionReactor DefinitionReactor private ImageDefinition _definition; private ImageDefinitionReactor _definitionReactor; + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + /// public override BoundingBox GetBoundingBox() { diff --git a/src/ACadSharp/Entities/Circle.cs b/src/ACadSharp/Entities/Circle.cs index 3e7aa66d..9106feaf 100644 --- a/src/ACadSharp/Entities/Circle.cs +++ b/src/ACadSharp/Entities/Circle.cs @@ -73,5 +73,25 @@ public override BoundingBox GetBoundingBox() XYZ max = new XYZ(Math.Max(this.Center.X - this.Radius, this.Center.X + this.Radius), Math.Max(this.Center.Y - this.Radius, this.Center.Y + this.Radius), Math.Max(this.Center.Z, this.Center.Z)); return new BoundingBox(min, max); } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Dimension.cs b/src/ACadSharp/Entities/Dimension.cs index e98fb879..11904f55 100644 --- a/src/ACadSharp/Entities/Dimension.cs +++ b/src/ACadSharp/Entities/Dimension.cs @@ -128,8 +128,8 @@ public bool IsTextUserDefinedLocation /// true if the arrow is to be flipped; otherwise, false. /// /// - /// Arrows are by default drawn inside the extension lines if there is enaugh - /// space; otherwise, outside. This flag overrules the standard behaviour. + /// Arrows are by default drawn inside the extension lines if there is enough + /// space; otherwise, outside. This flag overrules the standard behavior. /// [DxfCodeValue(74)] public bool FlipArrow1 { get; set; } @@ -142,8 +142,8 @@ public bool IsTextUserDefinedLocation /// true if the arrow is to be flipped; otherwise, false. /// /// - /// Arrows are by default drawn inside the extension lines if there is enaugh - /// space; otherwise, outside. This flag overrules the standard behaviour. + /// Arrows are by default drawn inside the extension lines if there is enough + /// space; otherwise, outside. This flag overrules the standard behavior. /// [DxfCodeValue(75)] public bool FlipArrow2 { get; set; } diff --git a/src/ACadSharp/Entities/DimensionAligned.cs b/src/ACadSharp/Entities/DimensionAligned.cs index 74beb1ae..4ace48e0 100644 --- a/src/ACadSharp/Entities/DimensionAligned.cs +++ b/src/ACadSharp/Entities/DimensionAligned.cs @@ -64,5 +64,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.FirstPoint, this.SecondPoint); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/DimensionAngular2Line.cs b/src/ACadSharp/Entities/DimensionAngular2Line.cs index ada1b1e2..a9c8e617 100644 --- a/src/ACadSharp/Entities/DimensionAngular2Line.cs +++ b/src/ACadSharp/Entities/DimensionAngular2Line.cs @@ -71,5 +71,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.FirstPoint, this.SecondPoint); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/DimensionAngular3Pt.cs b/src/ACadSharp/Entities/DimensionAngular3Pt.cs index 3cc87510..9f487de1 100644 --- a/src/ACadSharp/Entities/DimensionAngular3Pt.cs +++ b/src/ACadSharp/Entities/DimensionAngular3Pt.cs @@ -74,5 +74,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.FirstPoint, this.SecondPoint); } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/DimensionDiameter.cs b/src/ACadSharp/Entities/DimensionDiameter.cs index bd8972df..a8482844 100644 --- a/src/ACadSharp/Entities/DimensionDiameter.cs +++ b/src/ACadSharp/Entities/DimensionDiameter.cs @@ -54,5 +54,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.InsertionPoint - this.AngleVertex, this.InsertionPoint + this.AngleVertex); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/DimensionOrdinate.cs b/src/ACadSharp/Entities/DimensionOrdinate.cs index 72d03850..a9982e92 100644 --- a/src/ACadSharp/Entities/DimensionOrdinate.cs +++ b/src/ACadSharp/Entities/DimensionOrdinate.cs @@ -87,5 +87,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.FeatureLocation, this.LeaderEndpoint); } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/DimensionRadius.cs b/src/ACadSharp/Entities/DimensionRadius.cs index f8a0b5c6..4a63bda8 100644 --- a/src/ACadSharp/Entities/DimensionRadius.cs +++ b/src/ACadSharp/Entities/DimensionRadius.cs @@ -54,5 +54,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.InsertionPoint - this.AngleVertex, this.InsertionPoint + this.AngleVertex); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Ellipse.cs b/src/ACadSharp/Entities/Ellipse.cs index 32716e56..b8c1cd45 100644 --- a/src/ACadSharp/Entities/Ellipse.cs +++ b/src/ACadSharp/Entities/Ellipse.cs @@ -72,10 +72,30 @@ public class Ellipse : Entity [DxfCodeValue(42)] public double EndParameter { get; set; } = Math.PI * 2; + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + /// public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Face3D.cs b/src/ACadSharp/Entities/Face3D.cs index 8c80a8ae..162ab483 100644 --- a/src/ACadSharp/Entities/Face3D.cs +++ b/src/ACadSharp/Entities/Face3D.cs @@ -64,5 +64,25 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.FromPoints(new List { this.FirstCorner, this.SecondCorner, this.ThirdCorner, this.FourthCorner }); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Hatch.BoundaryPath.Arc.cs b/src/ACadSharp/Entities/Hatch.BoundaryPath.Arc.cs index 021d6990..e357292d 100644 --- a/src/ACadSharp/Entities/Hatch.BoundaryPath.Arc.cs +++ b/src/ACadSharp/Entities/Hatch.BoundaryPath.Arc.cs @@ -13,34 +13,34 @@ public class Arc : Edge public override EdgeType Type => EdgeType.CircularArc; /// - /// Center point (in OCS) + /// Center point (in OCS). /// [DxfCodeValue(10, 20)] public XY Center { get; set; } /// - /// Radius + /// Radius. /// /// - /// For the ellispe this is the length of minor axis (percentage of major axis length) + /// For the ellipse this is the length of minor axis (percentage of major axis length). /// [DxfCodeValue(40)] public double Radius { get; set; } /// - /// Start angle + /// Start angle. /// [DxfCodeValue(50)] public double StartAngle { get; set; } /// - /// End angle + /// End angle. /// [DxfCodeValue(51)] public double EndAngle { get; set; } /// - /// Is counterclockwise flag + /// Is counterclockwise flag. /// [DxfCodeValue(73)] public bool CounterClockWise { get; set; } diff --git a/src/ACadSharp/Entities/Hatch.cs b/src/ACadSharp/Entities/Hatch.cs index 0772261a..e16e7232 100644 --- a/src/ACadSharp/Entities/Hatch.cs +++ b/src/ACadSharp/Entities/Hatch.cs @@ -1,5 +1,6 @@ using ACadSharp.Attributes; using CSMath; +using System; using System.Collections.Generic; using System.Linq; @@ -132,6 +133,11 @@ public partial class Hatch : Entity /// public Hatch() : base() { } + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + /// public override BoundingBox GetBoundingBox() { @@ -154,5 +160,20 @@ public override CadObject Clone() return clone; } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Insert.cs b/src/ACadSharp/Entities/Insert.cs index 879f53b1..15c80789 100644 --- a/src/ACadSharp/Entities/Insert.cs +++ b/src/ACadSharp/Entities/Insert.cs @@ -229,5 +229,25 @@ private void attributesOnAdd(object sender, CollectionChangedEventArgs e) //TODO: Fix the relation between insert and block //this.Block?.Entities.Add(new AttributeDefinition(e.Item as AttributeEntity)); } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Leader.cs b/src/ACadSharp/Entities/Leader.cs index 1392ea11..0049873a 100644 --- a/src/ACadSharp/Entities/Leader.cs +++ b/src/ACadSharp/Entities/Leader.cs @@ -189,5 +189,25 @@ protected override void tableOnRemove(object sender, CollectionChangedEventArgs this.Style = this.Document.DimensionStyles[DimensionStyle.DefaultName]; } } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Line.cs b/src/ACadSharp/Entities/Line.cs index 959732ca..4cb85fb7 100644 --- a/src/ACadSharp/Entities/Line.cs +++ b/src/ACadSharp/Entities/Line.cs @@ -71,5 +71,25 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/LwPolyLine.cs b/src/ACadSharp/Entities/LwPolyLine.cs index e02c9690..e5fa0a95 100644 --- a/src/ACadSharp/Entities/LwPolyLine.cs +++ b/src/ACadSharp/Entities/LwPolyLine.cs @@ -1,6 +1,7 @@ using ACadSharp.Attributes; using CSMath; using CSUtilities.Extensions; +using System; using System.Collections.Generic; namespace ACadSharp.Entities @@ -117,5 +118,25 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/MLine.cs b/src/ACadSharp/Entities/MLine.cs index 79154276..00d25527 100644 --- a/src/ACadSharp/Entities/MLine.cs +++ b/src/ACadSharp/Entities/MLine.cs @@ -1,6 +1,7 @@ using ACadSharp.Attributes; using ACadSharp.Objects; using CSMath; +using System; using System.Collections.Generic; using System.Linq; @@ -116,6 +117,26 @@ public override BoundingBox GetBoundingBox() return BoundingBox.FromPoints(Vertices.Select(v => v.Position)); } + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + internal override void AssignDocument(CadDocument doc) { base.AssignDocument(doc); diff --git a/src/ACadSharp/Entities/MText.cs b/src/ACadSharp/Entities/MText.cs index 7f55e5ba..bb816c6e 100644 --- a/src/ACadSharp/Entities/MText.cs +++ b/src/ACadSharp/Entities/MText.cs @@ -212,6 +212,26 @@ public double Rotation /// public MText() : base() { } + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + /// public override BoundingBox GetBoundingBox() { diff --git a/src/ACadSharp/Entities/Mesh.cs b/src/ACadSharp/Entities/Mesh.cs index b1a10223..fb41aa0c 100644 --- a/src/ACadSharp/Entities/Mesh.cs +++ b/src/ACadSharp/Entities/Mesh.cs @@ -1,5 +1,6 @@ using ACadSharp.Attributes; using CSMath; +using System; using System.Collections.Generic; namespace ACadSharp.Entities @@ -80,5 +81,25 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.FromPoints(this.Vertices); } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/MultiLeader.cs b/src/ACadSharp/Entities/MultiLeader.cs index 71daafa9..3d8a5cc7 100644 --- a/src/ACadSharp/Entities/MultiLeader.cs +++ b/src/ACadSharp/Entities/MultiLeader.cs @@ -30,13 +30,13 @@ public class MultiLeader : Entity public override string SubclassMarker => DxfSubclassMarker.MultiLeader; // TODO - // We ommit this class because we assumed that the multileader + // We omit this class because we assumed that the multileader // does not have a list of arrow heads associated (see below). // According to the OpenDesign_Specification_for_.dwg_files // each arrowhead shall be associated with an IsDefault flag // having the group code 94. This means the type of the field // is BL instead of B. - // According to the DXF refence the 94 group code refers to + // According to the DXF reference the 94 group code refers to // the index of the arrow head. /* /// @@ -162,7 +162,7 @@ public object Clone() // TODO Additional Line Weight? see Entity.LineWeight. /// - /// Gets or sets a value specifying the lineweight to be applied to all leader lines of this + /// Gets or sets a value specifying the line weight to be applied to all leader lines of this /// (see ). /// This property overrides the value from /// when the flag is set in the @@ -229,7 +229,7 @@ public object Clone() public BlockRecord Arrowhead { get; set; } /// - /// Gests or sets the arrowhead size (see ) + /// Gets or sets the arrowhead size (see ) /// for every leader line /// when the flag is set in the /// property. @@ -447,7 +447,7 @@ public object Clone() // We do not understand what a list of arroheads can be used for, // and we do not know how to create such a list. // The documentation for arrowheads list in OpenDesign_Specification_for_.dwg_files - // and the DXF Reference are contracicting. + // and the DXF Reference are contradicting. // Decision: // Ommit the Arrowheads property, // try to keep the block attributes. @@ -457,7 +457,7 @@ public object Clone() /// /// Gets a list of objects representing - /// a reference to a "block attribute"? and some proprties to adjust + /// a reference to a "block attribute"? and some properties to adjust /// the attribute. /// public IList BlockAttributes { get; } = new List(); @@ -478,8 +478,8 @@ public object Clone() /// Gets or sets a value indicating the text attachment point. /// /// - /// The Open Desisign Specification for DWG files documents this property as Justification, - /// the DXF referenece as Text Attachmenst point. + /// The Open Design Specification for DWG files documents this property as Justification, + /// the DXF reference as Text Attachments point. /// /// This property is also exposed by the class /// (). @@ -595,5 +595,25 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Point.cs b/src/ACadSharp/Entities/Point.cs index fb2f1479..b1a70415 100644 --- a/src/ACadSharp/Entities/Point.cs +++ b/src/ACadSharp/Entities/Point.cs @@ -70,5 +70,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.Location); } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/PolyLine.cs b/src/ACadSharp/Entities/PolyLine.cs index 5dbc7f7f..c5bd558c 100644 --- a/src/ACadSharp/Entities/PolyLine.cs +++ b/src/ACadSharp/Entities/PolyLine.cs @@ -1,6 +1,7 @@ using ACadSharp.Attributes; using CSMath; using CSUtilities.Extensions; +using System; using System.Collections.Generic; using System.Linq; @@ -191,6 +192,26 @@ public override CadObject Clone() return clone; } + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + internal override void AssignDocument(CadDocument doc) { base.AssignDocument(doc); diff --git a/src/ACadSharp/Entities/Ray.cs b/src/ACadSharp/Entities/Ray.cs index 044251db..afeed723 100644 --- a/src/ACadSharp/Entities/Ray.cs +++ b/src/ACadSharp/Entities/Ray.cs @@ -35,10 +35,30 @@ public class Ray : Entity [DxfCodeValue(11, 21, 31)] public XYZ Direction { get; set; } = XYZ.Zero; + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } + /// public override BoundingBox GetBoundingBox() { return BoundingBox.Infinite; } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Seqend.cs b/src/ACadSharp/Entities/Seqend.cs index 037e0e60..311d93c9 100644 --- a/src/ACadSharp/Entities/Seqend.cs +++ b/src/ACadSharp/Entities/Seqend.cs @@ -31,5 +31,25 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Shape.cs b/src/ACadSharp/Entities/Shape.cs index c36561cd..4c0de75e 100644 --- a/src/ACadSharp/Entities/Shape.cs +++ b/src/ACadSharp/Entities/Shape.cs @@ -122,5 +122,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.InsertionPoint); } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Solid.cs b/src/ACadSharp/Entities/Solid.cs index 646029bd..dfeccb0a 100644 --- a/src/ACadSharp/Entities/Solid.cs +++ b/src/ACadSharp/Entities/Solid.cs @@ -48,9 +48,29 @@ public class Solid : Entity [DxfCodeValue(210, 220, 230)] public XYZ Normal { get; set; } = XYZ.AxisZ; + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } + public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Solid3D.cs b/src/ACadSharp/Entities/Solid3D.cs index 727e89ba..5d3ce0ce 100644 --- a/src/ACadSharp/Entities/Solid3D.cs +++ b/src/ACadSharp/Entities/Solid3D.cs @@ -23,10 +23,30 @@ public class Solid3D : Entity /// public override string SubclassMarker => DxfSubclassMarker.ModelerGeometry; + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } + /// public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Spline.cs b/src/ACadSharp/Entities/Spline.cs index ce3f4b31..ce4b848b 100644 --- a/src/ACadSharp/Entities/Spline.cs +++ b/src/ACadSharp/Entities/Spline.cs @@ -28,7 +28,7 @@ public class Spline : Entity /// Specifies the three-dimensional normal unit vector for the object. /// /// - /// Omitted if the spline is nonplanar. + /// Omitted if the spline is non-planar. /// [DxfCodeValue(210, 220, 230)] public XYZ Normal { get; set; } = XYZ.AxisZ; @@ -114,5 +114,25 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.FromPoints(this.ControlPoints); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/TextEntity.cs b/src/ACadSharp/Entities/TextEntity.cs index 0f1e5613..4ed15335 100644 --- a/src/ACadSharp/Entities/TextEntity.cs +++ b/src/ACadSharp/Entities/TextEntity.cs @@ -203,5 +203,25 @@ protected override void tableOnRemove(object sender, CollectionChangedEventArgs this.Style = this.Document.TextStyles[TextStyle.DefaultName]; } } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/Tolerance.cs b/src/ACadSharp/Entities/Tolerance.cs index ece5f9fc..9888b7fd 100644 --- a/src/ACadSharp/Entities/Tolerance.cs +++ b/src/ACadSharp/Entities/Tolerance.cs @@ -81,5 +81,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.InsertionPoint); } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/UnderlayEntity.cs b/src/ACadSharp/Entities/UnderlayEntity.cs index 99f43d78..edbaa843 100644 --- a/src/ACadSharp/Entities/UnderlayEntity.cs +++ b/src/ACadSharp/Entities/UnderlayEntity.cs @@ -113,5 +113,25 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/UnknownEntity.cs b/src/ACadSharp/Entities/UnknownEntity.cs index b078ba8b..0c47619b 100644 --- a/src/ACadSharp/Entities/UnknownEntity.cs +++ b/src/ACadSharp/Entities/UnknownEntity.cs @@ -1,5 +1,6 @@ using ACadSharp.Classes; using CSMath; +using System; namespace ACadSharp.Entities { @@ -56,6 +57,26 @@ internal UnknownEntity(DxfClass dxfClass) this.DxfClass = dxfClass; } + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } + /// /// /// An Unknown Entity does not have any geometric shape, therfore it's bounding box will be always 0 diff --git a/src/ACadSharp/Entities/Vertex.cs b/src/ACadSharp/Entities/Vertex.cs index 8dfd466c..641d5fc2 100644 --- a/src/ACadSharp/Entities/Vertex.cs +++ b/src/ACadSharp/Entities/Vertex.cs @@ -1,5 +1,6 @@ using ACadSharp.Attributes; using CSMath; +using System; namespace ACadSharp.Entities { @@ -59,5 +60,25 @@ public override BoundingBox GetBoundingBox() { return new BoundingBox(this.Location); } + + public override void ApplyTransform(Transform transform) + { + throw new NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/ViewPort.cs b/src/ACadSharp/Entities/ViewPort.cs index 17049b09..86e15b13 100644 --- a/src/ACadSharp/Entities/ViewPort.cs +++ b/src/ACadSharp/Entities/ViewPort.cs @@ -271,6 +271,11 @@ public class Viewport : Entity [DxfCodeValue(63, 421, 431)] public Color AmbientLightColor { get; set; } + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } + //361 Sun ID/Handle(optional) //335 @@ -304,5 +309,20 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/XLine.cs b/src/ACadSharp/Entities/XLine.cs index b77d97f0..09408980 100644 --- a/src/ACadSharp/Entities/XLine.cs +++ b/src/ACadSharp/Entities/XLine.cs @@ -35,10 +35,30 @@ public class XLine : Entity [DxfCodeValue(11, 21, 31)] public XYZ Direction { get; set; } + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } + /// public override BoundingBox GetBoundingBox() { return BoundingBox.Infinite; } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs b/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs index cca9c23b..98e2632b 100644 --- a/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs +++ b/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs @@ -47,6 +47,26 @@ public override BoundingBox GetBoundingBox() { throw new System.InvalidOperationException(); } + + public override void Translate(XYZ translation) + { + throw new System.NotImplementedException(); + } + + public override void Rotate(double rotation, XYZ axis) + { + throw new System.NotImplementedException(); + } + + public override void Scale(XYZ scale) + { + throw new System.NotImplementedException(); + } + + public override void ApplyTransform(Transform transform) + { + throw new System.NotImplementedException(); + } } public void SetDimensionFlags(DimensionType flags) From d55097b9e46aa12a87e4c232c57bf3ffc94cdd55 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 08:39:02 +0100 Subject: [PATCH 05/17] submodule --- src/CSUtilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CSUtilities b/src/CSUtilities index 8352d80b..aa362adf 160000 --- a/src/CSUtilities +++ b/src/CSUtilities @@ -1 +1 @@ -Subproject commit 8352d80b0c806e6924ef0fd68b74cb8fb2af81b4 +Subproject commit aa362adf7830b3c9cab8832c7a4e70d700678f75 From 29da415278b5822dd302ec369bcf0f8dac0591b6 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 09:18:12 +0100 Subject: [PATCH 06/17] build fix --- src/ACadSharp.Tests/Entities/PointTests.cs | 2 +- src/ACadSharp/Blocks/Block.cs | 6 +++--- src/ACadSharp/Blocks/BlockEnd.cs | 6 +++--- src/ACadSharp/Entities/Arc.cs | 4 ++-- src/ACadSharp/Entities/CadWipeoutBase.cs | 6 +++--- src/ACadSharp/Entities/Circle.cs | 6 +++--- src/ACadSharp/Entities/DimensionAligned.cs | 6 +++--- src/ACadSharp/Entities/DimensionAngular2Line.cs | 8 ++++---- src/ACadSharp/Entities/DimensionAngular3Pt.cs | 8 ++++---- src/ACadSharp/Entities/DimensionDiameter.cs | 6 +++--- src/ACadSharp/Entities/DimensionOrdinate.cs | 6 +++--- src/ACadSharp/Entities/DimensionRadius.cs | 6 +++--- src/ACadSharp/Entities/Ellipse.cs | 6 +++--- src/ACadSharp/Entities/Entity.cs | 6 +++--- src/ACadSharp/Entities/Face3D.cs | 6 +++--- src/ACadSharp/Entities/Hatch.cs | 6 +++--- src/ACadSharp/Entities/Insert.cs | 6 +++--- src/ACadSharp/Entities/Leader.cs | 6 +++--- src/ACadSharp/Entities/Line.cs | 6 +++--- src/ACadSharp/Entities/LwPolyLine.cs | 6 +++--- src/ACadSharp/Entities/MLine.cs | 6 +++--- src/ACadSharp/Entities/MText.cs | 6 +++--- src/ACadSharp/Entities/Mesh.cs | 6 +++--- src/ACadSharp/Entities/MultiLeader.cs | 6 +++--- src/ACadSharp/Entities/Point.cs | 6 +++--- src/ACadSharp/Entities/PolyLine.cs | 6 +++--- src/ACadSharp/Entities/Ray.cs | 6 +++--- src/ACadSharp/Entities/Seqend.cs | 6 +++--- src/ACadSharp/Entities/Shape.cs | 6 +++--- src/ACadSharp/Entities/Solid.cs | 6 +++--- src/ACadSharp/Entities/Solid3D.cs | 6 +++--- src/ACadSharp/Entities/Spline.cs | 6 +++--- src/ACadSharp/Entities/TextEntity.cs | 6 +++--- src/ACadSharp/Entities/Tolerance.cs | 6 +++--- src/ACadSharp/Entities/UnderlayEntity.cs | 6 +++--- src/ACadSharp/Entities/UnknownEntity.cs | 6 +++--- src/ACadSharp/Entities/Vertex.cs | 6 +++--- src/ACadSharp/Entities/Viewport.cs | 15 +++++++++++++++ src/ACadSharp/Entities/XLine.cs | 6 +++--- .../IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs | 2 +- .../DXF/DxfStreamWriter/DxfTablesSectionWriter.cs | 2 +- .../IO/Templates/CadDimensionTemplate.cs | 6 +++--- 42 files changed, 133 insertions(+), 118 deletions(-) diff --git a/src/ACadSharp.Tests/Entities/PointTests.cs b/src/ACadSharp.Tests/Entities/PointTests.cs index f8bd6b36..8267a388 100644 --- a/src/ACadSharp.Tests/Entities/PointTests.cs +++ b/src/ACadSharp.Tests/Entities/PointTests.cs @@ -18,7 +18,7 @@ public void TranslateTest() Point point = new Point(init); - point.Translate(translation); + point.ApplyTranslation(translation); AssertUtils.AreEqual(result, point.Location, "Point Location"); } diff --git a/src/ACadSharp/Blocks/Block.cs b/src/ACadSharp/Blocks/Block.cs index 41572f96..89c5433b 100644 --- a/src/ACadSharp/Blocks/Block.cs +++ b/src/ACadSharp/Blocks/Block.cs @@ -87,19 +87,19 @@ public override CadObject Clone() } /// - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } /// - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } /// - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Blocks/BlockEnd.cs b/src/ACadSharp/Blocks/BlockEnd.cs index 3850e7cd..39e4d47d 100644 --- a/src/ACadSharp/Blocks/BlockEnd.cs +++ b/src/ACadSharp/Blocks/BlockEnd.cs @@ -45,19 +45,19 @@ public override BoundingBox GetBoundingBox() } /// - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } /// - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } /// - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Arc.cs b/src/ACadSharp/Entities/Arc.cs index aa16db15..4c6ba507 100644 --- a/src/ACadSharp/Entities/Arc.cs +++ b/src/ACadSharp/Entities/Arc.cs @@ -119,8 +119,8 @@ public List PolygonalVertexes(int precision) double cosine = this.Radius * Math.Cos(angle); double sine = this.Radius * Math.Sin(angle); - cosine = Utilities.IsZero(cosine) ? 0 : cosine; - sine = Utilities.IsZero(sine) ? 0 : sine; + cosine = MathHelper.IsZero(cosine) ? 0 : cosine; + sine = MathHelper.IsZero(sine) ? 0 : sine; ocsVertexes.Add(new XY(cosine + this.Center.X, sine + this.Center.Y)); } diff --git a/src/ACadSharp/Entities/CadWipeoutBase.cs b/src/ACadSharp/Entities/CadWipeoutBase.cs index 83e7bed5..15be8110 100644 --- a/src/ACadSharp/Entities/CadWipeoutBase.cs +++ b/src/ACadSharp/Entities/CadWipeoutBase.cs @@ -215,17 +215,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Circle.cs b/src/ACadSharp/Entities/Circle.cs index 9106feaf..532b9ff9 100644 --- a/src/ACadSharp/Entities/Circle.cs +++ b/src/ACadSharp/Entities/Circle.cs @@ -74,17 +74,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/DimensionAligned.cs b/src/ACadSharp/Entities/DimensionAligned.cs index 4ace48e0..d9511c9c 100644 --- a/src/ACadSharp/Entities/DimensionAligned.cs +++ b/src/ACadSharp/Entities/DimensionAligned.cs @@ -65,17 +65,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FirstPoint, this.SecondPoint); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/DimensionAngular2Line.cs b/src/ACadSharp/Entities/DimensionAngular2Line.cs index e6627f9a..38799b62 100644 --- a/src/ACadSharp/Entities/DimensionAngular2Line.cs +++ b/src/ACadSharp/Entities/DimensionAngular2Line.cs @@ -55,7 +55,7 @@ public override double Measurement XY v1 = (XY)(this.SecondPoint - this.FirstPoint); XY v2 = (XY)(this.DefinitionPoint - this.AngleVertex); - return v1.AngleFrom(v2); + return v1.AngleBetweenVectors(v2); } } @@ -72,17 +72,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FirstPoint, this.SecondPoint); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/DimensionAngular3Pt.cs b/src/ACadSharp/Entities/DimensionAngular3Pt.cs index 9f487de1..ae4d357c 100644 --- a/src/ACadSharp/Entities/DimensionAngular3Pt.cs +++ b/src/ACadSharp/Entities/DimensionAngular3Pt.cs @@ -60,7 +60,7 @@ public override double Measurement return Math.PI; } - return (double)v1.AngleFrom(v2); + return (double)v1.AngleBetweenVectors(v2); } } @@ -75,17 +75,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FirstPoint, this.SecondPoint); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/DimensionDiameter.cs b/src/ACadSharp/Entities/DimensionDiameter.cs index 12ad365e..b550407b 100644 --- a/src/ACadSharp/Entities/DimensionDiameter.cs +++ b/src/ACadSharp/Entities/DimensionDiameter.cs @@ -55,17 +55,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint - this.AngleVertex, this.InsertionPoint + this.AngleVertex); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/DimensionOrdinate.cs b/src/ACadSharp/Entities/DimensionOrdinate.cs index 14794c1f..705d8a74 100644 --- a/src/ACadSharp/Entities/DimensionOrdinate.cs +++ b/src/ACadSharp/Entities/DimensionOrdinate.cs @@ -88,17 +88,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FeatureLocation, this.LeaderEndpoint); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/DimensionRadius.cs b/src/ACadSharp/Entities/DimensionRadius.cs index 395fc56e..1c1e2b82 100644 --- a/src/ACadSharp/Entities/DimensionRadius.cs +++ b/src/ACadSharp/Entities/DimensionRadius.cs @@ -55,17 +55,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint - this.AngleVertex, this.InsertionPoint + this.AngleVertex); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Ellipse.cs b/src/ACadSharp/Entities/Ellipse.cs index e3cdd575..7f28f4d2 100644 --- a/src/ACadSharp/Entities/Ellipse.cs +++ b/src/ACadSharp/Entities/Ellipse.cs @@ -196,17 +196,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.FromPoints(pts.Select(p => (XYZ)p)); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Entity.cs b/src/ACadSharp/Entities/Entity.cs index b5d240e5..58551078 100644 --- a/src/ACadSharp/Entities/Entity.cs +++ b/src/ACadSharp/Entities/Entity.cs @@ -118,20 +118,20 @@ public Entity() : base() { } /// Apply a translation to this entity. /// /// - public abstract void Translate(XYZ translation); + public abstract void ApplyTranslation(XYZ translation); /// /// Apply a rotation to this entity. /// /// /// - public abstract void Rotate(double rotation, XYZ axis); + public abstract void ApplyRotation(double rotation, XYZ axis); /// /// Apply a scale to this entity. /// /// - public abstract void Scale(XYZ scale); + public abstract void ApplyEscalation(XYZ scale); /// /// Apply a transform matrix to this entity. diff --git a/src/ACadSharp/Entities/Face3D.cs b/src/ACadSharp/Entities/Face3D.cs index 162ab483..e07daf7c 100644 --- a/src/ACadSharp/Entities/Face3D.cs +++ b/src/ACadSharp/Entities/Face3D.cs @@ -65,17 +65,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.FromPoints(new List { this.FirstCorner, this.SecondCorner, this.ThirdCorner, this.FourthCorner }); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Hatch.cs b/src/ACadSharp/Entities/Hatch.cs index dd835d77..7f2c6fde 100644 --- a/src/ACadSharp/Entities/Hatch.cs +++ b/src/ACadSharp/Entities/Hatch.cs @@ -166,17 +166,17 @@ public override CadObject Clone() return clone; } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Insert.cs b/src/ACadSharp/Entities/Insert.cs index fda7b2ff..e386eaa3 100644 --- a/src/ACadSharp/Entities/Insert.cs +++ b/src/ACadSharp/Entities/Insert.cs @@ -232,17 +232,17 @@ internal override void UnassignDocument() base.UnassignDocument(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Leader.cs b/src/ACadSharp/Entities/Leader.cs index 0049873a..de4e181c 100644 --- a/src/ACadSharp/Entities/Leader.cs +++ b/src/ACadSharp/Entities/Leader.cs @@ -190,17 +190,17 @@ protected override void tableOnRemove(object sender, CollectionChangedEventArgs } } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Line.cs b/src/ACadSharp/Entities/Line.cs index 4cb85fb7..1a67c0d1 100644 --- a/src/ACadSharp/Entities/Line.cs +++ b/src/ACadSharp/Entities/Line.cs @@ -72,17 +72,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/LwPolyLine.cs b/src/ACadSharp/Entities/LwPolyLine.cs index e5fa0a95..b1b5f32c 100644 --- a/src/ACadSharp/Entities/LwPolyLine.cs +++ b/src/ACadSharp/Entities/LwPolyLine.cs @@ -124,17 +124,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/MLine.cs b/src/ACadSharp/Entities/MLine.cs index 00d25527..102f7b62 100644 --- a/src/ACadSharp/Entities/MLine.cs +++ b/src/ACadSharp/Entities/MLine.cs @@ -122,17 +122,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/MText.cs b/src/ACadSharp/Entities/MText.cs index bb816c6e..93881622 100644 --- a/src/ACadSharp/Entities/MText.cs +++ b/src/ACadSharp/Entities/MText.cs @@ -217,17 +217,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Mesh.cs b/src/ACadSharp/Entities/Mesh.cs index fb41aa0c..feb8035c 100644 --- a/src/ACadSharp/Entities/Mesh.cs +++ b/src/ACadSharp/Entities/Mesh.cs @@ -87,17 +87,17 @@ public override void ApplyTransform(Transform transform) throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/MultiLeader.cs b/src/ACadSharp/Entities/MultiLeader.cs index 3d8a5cc7..12e758f9 100644 --- a/src/ACadSharp/Entities/MultiLeader.cs +++ b/src/ACadSharp/Entities/MultiLeader.cs @@ -596,17 +596,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Null; } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Point.cs b/src/ACadSharp/Entities/Point.cs index b1a70415..a36c8c65 100644 --- a/src/ACadSharp/Entities/Point.cs +++ b/src/ACadSharp/Entities/Point.cs @@ -71,17 +71,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.Location); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/PolyLine.cs b/src/ACadSharp/Entities/PolyLine.cs index c5bd558c..772098b2 100644 --- a/src/ACadSharp/Entities/PolyLine.cs +++ b/src/ACadSharp/Entities/PolyLine.cs @@ -197,17 +197,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Ray.cs b/src/ACadSharp/Entities/Ray.cs index afeed723..8f140a7c 100644 --- a/src/ACadSharp/Entities/Ray.cs +++ b/src/ACadSharp/Entities/Ray.cs @@ -46,17 +46,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Infinite; } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Seqend.cs b/src/ACadSharp/Entities/Seqend.cs index 311d93c9..1530436d 100644 --- a/src/ACadSharp/Entities/Seqend.cs +++ b/src/ACadSharp/Entities/Seqend.cs @@ -32,17 +32,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Null; } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Shape.cs b/src/ACadSharp/Entities/Shape.cs index 4c0de75e..af52071f 100644 --- a/src/ACadSharp/Entities/Shape.cs +++ b/src/ACadSharp/Entities/Shape.cs @@ -123,17 +123,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Solid.cs b/src/ACadSharp/Entities/Solid.cs index dfeccb0a..3db77f97 100644 --- a/src/ACadSharp/Entities/Solid.cs +++ b/src/ACadSharp/Entities/Solid.cs @@ -58,17 +58,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Null; } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Solid3D.cs b/src/ACadSharp/Entities/Solid3D.cs index 5d3ce0ce..10ace5a9 100644 --- a/src/ACadSharp/Entities/Solid3D.cs +++ b/src/ACadSharp/Entities/Solid3D.cs @@ -34,17 +34,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Null; } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Spline.cs b/src/ACadSharp/Entities/Spline.cs index ce4b848b..6ff8bf6d 100644 --- a/src/ACadSharp/Entities/Spline.cs +++ b/src/ACadSharp/Entities/Spline.cs @@ -115,17 +115,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.FromPoints(this.ControlPoints); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/Entities/TextEntity.cs b/src/ACadSharp/Entities/TextEntity.cs index 4ed15335..b265af8f 100644 --- a/src/ACadSharp/Entities/TextEntity.cs +++ b/src/ACadSharp/Entities/TextEntity.cs @@ -204,17 +204,17 @@ protected override void tableOnRemove(object sender, CollectionChangedEventArgs } } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Tolerance.cs b/src/ACadSharp/Entities/Tolerance.cs index 9888b7fd..001f54d2 100644 --- a/src/ACadSharp/Entities/Tolerance.cs +++ b/src/ACadSharp/Entities/Tolerance.cs @@ -82,17 +82,17 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/UnderlayEntity.cs b/src/ACadSharp/Entities/UnderlayEntity.cs index edbaa843..7e19ed3a 100644 --- a/src/ACadSharp/Entities/UnderlayEntity.cs +++ b/src/ACadSharp/Entities/UnderlayEntity.cs @@ -119,17 +119,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/UnknownEntity.cs b/src/ACadSharp/Entities/UnknownEntity.cs index 0c47619b..b3b87f55 100644 --- a/src/ACadSharp/Entities/UnknownEntity.cs +++ b/src/ACadSharp/Entities/UnknownEntity.cs @@ -62,17 +62,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Vertex.cs b/src/ACadSharp/Entities/Vertex.cs index 641d5fc2..f37ebcc9 100644 --- a/src/ACadSharp/Entities/Vertex.cs +++ b/src/ACadSharp/Entities/Vertex.cs @@ -66,17 +66,17 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new NotImplementedException(); } diff --git a/src/ACadSharp/Entities/Viewport.cs b/src/ACadSharp/Entities/Viewport.cs index 76cfcf17..dd1eedae 100644 --- a/src/ACadSharp/Entities/Viewport.cs +++ b/src/ACadSharp/Entities/Viewport.cs @@ -504,5 +504,20 @@ private void updateScaleXRecord() record.CreateEntry(340, _scale); } } + + public override void ApplyTranslation(XYZ translation) + { + throw new NotImplementedException(); + } + + public override void ApplyRotation(double rotation, XYZ axis) + { + throw new NotImplementedException(); + } + + public override void ApplyEscalation(XYZ scale) + { + throw new NotImplementedException(); + } } } diff --git a/src/ACadSharp/Entities/XLine.cs b/src/ACadSharp/Entities/XLine.cs index 09408980..230bde83 100644 --- a/src/ACadSharp/Entities/XLine.cs +++ b/src/ACadSharp/Entities/XLine.cs @@ -46,17 +46,17 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Infinite; } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } diff --git a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs index 258520ac..63115833 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs @@ -43,7 +43,7 @@ public string ValueAsString public double ValueAsDouble { get { return Convert.ToDouble(this.Value); } } - public double ValueAsAngle { get { return (double)(Convert.ToDouble(this.Value) * Utilities.RadToDegFactor); } } + public double ValueAsAngle { get { return (double)(Convert.ToDouble(this.Value) * MathHelper.RadToDegFactor); } } public ulong ValueAsHandle { get { return (ulong)this.Value; } } diff --git a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs index feec6863..8b71a776 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfTablesSectionWriter.cs @@ -276,7 +276,7 @@ private void writeLineType(LineType linetype, DxfClassMap map) } this._writer.Write(46, s.Scale); - this._writer.Write(50, s.Rotation * Utilities.DegToRadFactor); + this._writer.Write(50, MathHelper.RadToDeg(s.Rotation)); this._writer.Write(44, s.Offset.X); this._writer.Write(45, s.Offset.Y); this._writer.Write(9, s.Text); diff --git a/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs b/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs index 235bfe60..a14e42b2 100644 --- a/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs +++ b/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs @@ -48,17 +48,17 @@ public override BoundingBox GetBoundingBox() throw new System.InvalidOperationException(); } - public override void Translate(XYZ translation) + public override void ApplyTranslation(XYZ translation) { throw new System.NotImplementedException(); } - public override void Rotate(double rotation, XYZ axis) + public override void ApplyRotation(double rotation, XYZ axis) { throw new System.NotImplementedException(); } - public override void Scale(XYZ scale) + public override void ApplyEscalation(XYZ scale) { throw new System.NotImplementedException(); } From 36b638a3960227dc2d19d368dc8c81952d5ac0f2 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 15:41:42 +0100 Subject: [PATCH 07/17] save --- src/ACadSharp/Blocks/Block.cs | 18 ----------------- src/ACadSharp/Entities/CadWipeoutBase.cs | 15 -------------- src/ACadSharp/Entities/Circle.cs | 18 ++--------------- src/ACadSharp/Entities/Ellipse.cs | 15 -------------- src/ACadSharp/Entities/Entity.cs | 20 +++++++++++++++---- src/ACadSharp/Entities/Vertex.cs | 15 -------------- src/ACadSharp/Entities/Viewport.cs | 15 -------------- .../IO/Templates/CadDimensionTemplate.cs | 15 -------------- 8 files changed, 18 insertions(+), 113 deletions(-) diff --git a/src/ACadSharp/Blocks/Block.cs b/src/ACadSharp/Blocks/Block.cs index 89c5433b..8c331baf 100644 --- a/src/ACadSharp/Blocks/Block.cs +++ b/src/ACadSharp/Blocks/Block.cs @@ -86,24 +86,6 @@ public override CadObject Clone() return clone; } - /// - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - /// - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - /// - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/CadWipeoutBase.cs b/src/ACadSharp/Entities/CadWipeoutBase.cs index 15be8110..2adcb668 100644 --- a/src/ACadSharp/Entities/CadWipeoutBase.cs +++ b/src/ACadSharp/Entities/CadWipeoutBase.cs @@ -215,21 +215,6 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - /// public override BoundingBox GetBoundingBox() { diff --git a/src/ACadSharp/Entities/Circle.cs b/src/ACadSharp/Entities/Circle.cs index 9e489456..2cc1e70c 100644 --- a/src/ACadSharp/Entities/Circle.cs +++ b/src/ACadSharp/Entities/Circle.cs @@ -74,24 +74,10 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { - throw new NotImplementedException(); + this.Center = transform.ApplyTransform(this.Center); } } } \ No newline at end of file diff --git a/src/ACadSharp/Entities/Ellipse.cs b/src/ACadSharp/Entities/Ellipse.cs index 5725c400..f0b773a3 100644 --- a/src/ACadSharp/Entities/Ellipse.cs +++ b/src/ACadSharp/Entities/Ellipse.cs @@ -195,20 +195,5 @@ public override BoundingBox GetBoundingBox() List pts = this.PolygonalVertexes(100); return BoundingBox.FromPoints(pts.Select(p => (XYZ)p)); } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/Entity.cs b/src/ACadSharp/Entities/Entity.cs index 58551078..3899bcb5 100644 --- a/src/ACadSharp/Entities/Entity.cs +++ b/src/ACadSharp/Entities/Entity.cs @@ -118,20 +118,32 @@ public Entity() : base() { } /// Apply a translation to this entity. /// /// - public abstract void ApplyTranslation(XYZ translation); + public void ApplyTranslation(XYZ translation) + { + Transform transform = Transform.CreateTranslation(translation); + this.ApplyTransform(transform); + } /// /// Apply a rotation to this entity. /// - /// /// - public abstract void ApplyRotation(double rotation, XYZ axis); + /// + public void ApplyRotation(XYZ axis, double rotation) + { + Transform transform = Transform.CreateRotation(axis, rotation); + this.ApplyTransform(transform); + } /// /// Apply a scale to this entity. /// /// - public abstract void ApplyEscalation(XYZ scale); + public void ApplyEscalation(XYZ scale) + { + Transform transform = Transform.CreateEscalation(scale); + this.ApplyTransform(transform); + } /// /// Apply a transform matrix to this entity. diff --git a/src/ACadSharp/Entities/Vertex.cs b/src/ACadSharp/Entities/Vertex.cs index f37ebcc9..ac2f48f7 100644 --- a/src/ACadSharp/Entities/Vertex.cs +++ b/src/ACadSharp/Entities/Vertex.cs @@ -65,20 +65,5 @@ public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/Viewport.cs b/src/ACadSharp/Entities/Viewport.cs index dd1eedae..76cfcf17 100644 --- a/src/ACadSharp/Entities/Viewport.cs +++ b/src/ACadSharp/Entities/Viewport.cs @@ -504,20 +504,5 @@ private void updateScaleXRecord() record.CreateEntry(340, _scale); } } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } } } diff --git a/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs b/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs index a14e42b2..41bc4392 100644 --- a/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs +++ b/src/ACadSharp/IO/Templates/CadDimensionTemplate.cs @@ -48,21 +48,6 @@ public override BoundingBox GetBoundingBox() throw new System.InvalidOperationException(); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); From d6d354294479722b9ca4e396b16d4aa03dc9fe5d Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 16:09:29 +0100 Subject: [PATCH 08/17] methods --- src/ACadSharp/Blocks/BlockEnd.cs | 19 ------------------ src/ACadSharp/Entities/DimensionAligned.cs | 16 +-------------- .../Entities/DimensionAngular2Line.cs | 16 +-------------- src/ACadSharp/Entities/DimensionAngular3Pt.cs | 16 +-------------- src/ACadSharp/Entities/DimensionDiameter.cs | 16 +-------------- src/ACadSharp/Entities/DimensionOrdinate.cs | 16 +-------------- src/ACadSharp/Entities/DimensionRadius.cs | 16 +-------------- src/ACadSharp/Entities/Face3D.cs | 16 +-------------- src/ACadSharp/Entities/Hatch.cs | 15 -------------- src/ACadSharp/Entities/Insert.cs | 16 +-------------- src/ACadSharp/Entities/Leader.cs | 16 +-------------- src/ACadSharp/Entities/Line.cs | 20 ++++--------------- src/ACadSharp/Entities/LwPolyLine.cs | 16 +-------------- src/ACadSharp/Entities/MLine.cs | 15 -------------- src/ACadSharp/Entities/MText.cs | 15 -------------- src/ACadSharp/Entities/Mesh.cs | 16 +-------------- src/ACadSharp/Entities/MultiLeader.cs | 15 -------------- src/ACadSharp/Entities/Point.cs | 19 +++--------------- src/ACadSharp/Entities/PolyLine.cs | 15 -------------- src/ACadSharp/Entities/Ray.cs | 15 -------------- src/ACadSharp/Entities/Seqend.cs | 15 -------------- src/ACadSharp/Entities/Shape.cs | 15 -------------- src/ACadSharp/Entities/Solid.cs | 15 -------------- src/ACadSharp/Entities/Solid3D.cs | 15 -------------- src/ACadSharp/Entities/Spline.cs | 15 -------------- src/ACadSharp/Entities/TextEntity.cs | 15 -------------- src/ACadSharp/Entities/Tolerance.cs | 15 -------------- src/ACadSharp/Entities/UnderlayEntity.cs | 15 -------------- src/ACadSharp/Entities/UnknownEntity.cs | 15 -------------- src/ACadSharp/Entities/XLine.cs | 16 +-------------- 30 files changed, 19 insertions(+), 456 deletions(-) diff --git a/src/ACadSharp/Blocks/BlockEnd.cs b/src/ACadSharp/Blocks/BlockEnd.cs index 39e4d47d..8c2ef77a 100644 --- a/src/ACadSharp/Blocks/BlockEnd.cs +++ b/src/ACadSharp/Blocks/BlockEnd.cs @@ -44,28 +44,9 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Null; } - /// - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - /// - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - /// - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - /// public override void ApplyTransform(Transform transform) { - throw new System.NotImplementedException(); } } } diff --git a/src/ACadSharp/Entities/DimensionAligned.cs b/src/ACadSharp/Entities/DimensionAligned.cs index d9511c9c..cd6a91e3 100644 --- a/src/ACadSharp/Entities/DimensionAligned.cs +++ b/src/ACadSharp/Entities/DimensionAligned.cs @@ -65,21 +65,7 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FirstPoint, this.SecondPoint); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/DimensionAngular2Line.cs b/src/ACadSharp/Entities/DimensionAngular2Line.cs index 38799b62..6755f6e1 100644 --- a/src/ACadSharp/Entities/DimensionAngular2Line.cs +++ b/src/ACadSharp/Entities/DimensionAngular2Line.cs @@ -72,21 +72,7 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FirstPoint, this.SecondPoint); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/DimensionAngular3Pt.cs b/src/ACadSharp/Entities/DimensionAngular3Pt.cs index ae4d357c..4907129d 100644 --- a/src/ACadSharp/Entities/DimensionAngular3Pt.cs +++ b/src/ACadSharp/Entities/DimensionAngular3Pt.cs @@ -75,21 +75,7 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FirstPoint, this.SecondPoint); } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/DimensionDiameter.cs b/src/ACadSharp/Entities/DimensionDiameter.cs index b550407b..84de37a9 100644 --- a/src/ACadSharp/Entities/DimensionDiameter.cs +++ b/src/ACadSharp/Entities/DimensionDiameter.cs @@ -55,21 +55,7 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint - this.AngleVertex, this.InsertionPoint + this.AngleVertex); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/DimensionOrdinate.cs b/src/ACadSharp/Entities/DimensionOrdinate.cs index 705d8a74..65be4f0b 100644 --- a/src/ACadSharp/Entities/DimensionOrdinate.cs +++ b/src/ACadSharp/Entities/DimensionOrdinate.cs @@ -88,21 +88,7 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.FeatureLocation, this.LeaderEndpoint); } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/DimensionRadius.cs b/src/ACadSharp/Entities/DimensionRadius.cs index 1c1e2b82..1530131c 100644 --- a/src/ACadSharp/Entities/DimensionRadius.cs +++ b/src/ACadSharp/Entities/DimensionRadius.cs @@ -55,21 +55,7 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint - this.AngleVertex, this.InsertionPoint + this.AngleVertex); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/Face3D.cs b/src/ACadSharp/Entities/Face3D.cs index e07daf7c..a96ac8a7 100644 --- a/src/ACadSharp/Entities/Face3D.cs +++ b/src/ACadSharp/Entities/Face3D.cs @@ -65,21 +65,7 @@ public override BoundingBox GetBoundingBox() return BoundingBox.FromPoints(new List { this.FirstCorner, this.SecondCorner, this.ThirdCorner, this.FourthCorner }); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/Hatch.cs b/src/ACadSharp/Entities/Hatch.cs index 7f2c6fde..981ecc7b 100644 --- a/src/ACadSharp/Entities/Hatch.cs +++ b/src/ACadSharp/Entities/Hatch.cs @@ -165,20 +165,5 @@ public override CadObject Clone() return clone; } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/Insert.cs b/src/ACadSharp/Entities/Insert.cs index e386eaa3..796582fe 100644 --- a/src/ACadSharp/Entities/Insert.cs +++ b/src/ACadSharp/Entities/Insert.cs @@ -232,21 +232,7 @@ internal override void UnassignDocument() base.UnassignDocument(); } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/Leader.cs b/src/ACadSharp/Entities/Leader.cs index de4e181c..e8c9b8e5 100644 --- a/src/ACadSharp/Entities/Leader.cs +++ b/src/ACadSharp/Entities/Leader.cs @@ -190,21 +190,7 @@ protected override void tableOnRemove(object sender, CollectionChangedEventArgs } } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/Line.cs b/src/ACadSharp/Entities/Line.cs index 1a67c0d1..a20c5d76 100644 --- a/src/ACadSharp/Entities/Line.cs +++ b/src/ACadSharp/Entities/Line.cs @@ -72,24 +72,12 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { - throw new System.NotImplementedException(); + this.StartPoint = transform.ApplyTransform(this.StartPoint); + this.EndPoint = transform.ApplyTransform(this.EndPoint); + this.Normal = transform.ApplyTransform(this.Normal); } } } diff --git a/src/ACadSharp/Entities/LwPolyLine.cs b/src/ACadSharp/Entities/LwPolyLine.cs index b1b5f32c..2324c103 100644 --- a/src/ACadSharp/Entities/LwPolyLine.cs +++ b/src/ACadSharp/Entities/LwPolyLine.cs @@ -119,24 +119,10 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } + /// public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/MLine.cs b/src/ACadSharp/Entities/MLine.cs index 102f7b62..3b82f4f6 100644 --- a/src/ACadSharp/Entities/MLine.cs +++ b/src/ACadSharp/Entities/MLine.cs @@ -122,21 +122,6 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - internal override void AssignDocument(CadDocument doc) { base.AssignDocument(doc); diff --git a/src/ACadSharp/Entities/MText.cs b/src/ACadSharp/Entities/MText.cs index 93881622..15c8c968 100644 --- a/src/ACadSharp/Entities/MText.cs +++ b/src/ACadSharp/Entities/MText.cs @@ -217,21 +217,6 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - /// public override BoundingBox GetBoundingBox() { diff --git a/src/ACadSharp/Entities/Mesh.cs b/src/ACadSharp/Entities/Mesh.cs index feb8035c..11214881 100644 --- a/src/ACadSharp/Entities/Mesh.cs +++ b/src/ACadSharp/Entities/Mesh.cs @@ -82,24 +82,10 @@ public override BoundingBox GetBoundingBox() return BoundingBox.FromPoints(this.Vertices); } + /// public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/MultiLeader.cs b/src/ACadSharp/Entities/MultiLeader.cs index 12e758f9..c52fd26e 100644 --- a/src/ACadSharp/Entities/MultiLeader.cs +++ b/src/ACadSharp/Entities/MultiLeader.cs @@ -596,21 +596,6 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Null; } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/Point.cs b/src/ACadSharp/Entities/Point.cs index a36c8c65..251541f8 100644 --- a/src/ACadSharp/Entities/Point.cs +++ b/src/ACadSharp/Entities/Point.cs @@ -71,24 +71,11 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.Location); } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - + /// public override void ApplyTransform(Transform transform) { - throw new NotImplementedException(); + this.Location = transform.ApplyTransform(this.Location); + this.Normal = transform.ApplyTransform(this.Normal); } } } diff --git a/src/ACadSharp/Entities/PolyLine.cs b/src/ACadSharp/Entities/PolyLine.cs index 772098b2..1a77ed35 100644 --- a/src/ACadSharp/Entities/PolyLine.cs +++ b/src/ACadSharp/Entities/PolyLine.cs @@ -197,21 +197,6 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - internal override void AssignDocument(CadDocument doc) { base.AssignDocument(doc); diff --git a/src/ACadSharp/Entities/Ray.cs b/src/ACadSharp/Entities/Ray.cs index 8f140a7c..a6efbae9 100644 --- a/src/ACadSharp/Entities/Ray.cs +++ b/src/ACadSharp/Entities/Ray.cs @@ -45,20 +45,5 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Infinite; } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/Seqend.cs b/src/ACadSharp/Entities/Seqend.cs index 1530436d..c5b7192b 100644 --- a/src/ACadSharp/Entities/Seqend.cs +++ b/src/ACadSharp/Entities/Seqend.cs @@ -32,21 +32,6 @@ public override BoundingBox GetBoundingBox() return BoundingBox.Null; } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/Shape.cs b/src/ACadSharp/Entities/Shape.cs index af52071f..3003067a 100644 --- a/src/ACadSharp/Entities/Shape.cs +++ b/src/ACadSharp/Entities/Shape.cs @@ -123,21 +123,6 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint); } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/Solid.cs b/src/ACadSharp/Entities/Solid.cs index 3db77f97..a7e5bd7f 100644 --- a/src/ACadSharp/Entities/Solid.cs +++ b/src/ACadSharp/Entities/Solid.cs @@ -57,20 +57,5 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/Solid3D.cs b/src/ACadSharp/Entities/Solid3D.cs index 10ace5a9..0e16d444 100644 --- a/src/ACadSharp/Entities/Solid3D.cs +++ b/src/ACadSharp/Entities/Solid3D.cs @@ -33,20 +33,5 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Null; } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/Spline.cs b/src/ACadSharp/Entities/Spline.cs index 6ff8bf6d..634e90db 100644 --- a/src/ACadSharp/Entities/Spline.cs +++ b/src/ACadSharp/Entities/Spline.cs @@ -115,21 +115,6 @@ public override BoundingBox GetBoundingBox() return BoundingBox.FromPoints(this.ControlPoints); } - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); diff --git a/src/ACadSharp/Entities/TextEntity.cs b/src/ACadSharp/Entities/TextEntity.cs index b265af8f..20d84db4 100644 --- a/src/ACadSharp/Entities/TextEntity.cs +++ b/src/ACadSharp/Entities/TextEntity.cs @@ -204,21 +204,6 @@ protected override void tableOnRemove(object sender, CollectionChangedEventArgs } } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/Tolerance.cs b/src/ACadSharp/Entities/Tolerance.cs index 001f54d2..18a98c9e 100644 --- a/src/ACadSharp/Entities/Tolerance.cs +++ b/src/ACadSharp/Entities/Tolerance.cs @@ -82,21 +82,6 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(this.InsertionPoint); } - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/UnderlayEntity.cs b/src/ACadSharp/Entities/UnderlayEntity.cs index 7e19ed3a..7305a64b 100644 --- a/src/ACadSharp/Entities/UnderlayEntity.cs +++ b/src/ACadSharp/Entities/UnderlayEntity.cs @@ -118,20 +118,5 @@ public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } } } diff --git a/src/ACadSharp/Entities/UnknownEntity.cs b/src/ACadSharp/Entities/UnknownEntity.cs index b3b87f55..a24f465a 100644 --- a/src/ACadSharp/Entities/UnknownEntity.cs +++ b/src/ACadSharp/Entities/UnknownEntity.cs @@ -62,21 +62,6 @@ public override void ApplyTransform(Transform transform) throw new NotImplementedException(); } - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new NotImplementedException(); - } - /// /// /// An Unknown Entity does not have any geometric shape, therfore it's bounding box will be always 0 diff --git a/src/ACadSharp/Entities/XLine.cs b/src/ACadSharp/Entities/XLine.cs index 230bde83..59168bdc 100644 --- a/src/ACadSharp/Entities/XLine.cs +++ b/src/ACadSharp/Entities/XLine.cs @@ -35,6 +35,7 @@ public class XLine : Entity [DxfCodeValue(11, 21, 31)] public XYZ Direction { get; set; } + /// public override void ApplyTransform(Transform transform) { throw new System.NotImplementedException(); @@ -45,20 +46,5 @@ public override BoundingBox GetBoundingBox() { return BoundingBox.Infinite; } - - public override void ApplyRotation(double rotation, XYZ axis) - { - throw new System.NotImplementedException(); - } - - public override void ApplyEscalation(XYZ scale) - { - throw new System.NotImplementedException(); - } - - public override void ApplyTranslation(XYZ translation) - { - throw new System.NotImplementedException(); - } } } From b58cccbcde979f9123f5a281e03b5abd13529a68 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 16:09:35 +0100 Subject: [PATCH 09/17] line translation --- src/ACadSharp.Tests/Entities/LineTests.cs | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/ACadSharp.Tests/Entities/LineTests.cs b/src/ACadSharp.Tests/Entities/LineTests.cs index 572e8ae4..dddfc05d 100644 --- a/src/ACadSharp.Tests/Entities/LineTests.cs +++ b/src/ACadSharp.Tests/Entities/LineTests.cs @@ -1,4 +1,5 @@ using ACadSharp.Entities; +using ACadSharp.Tests.Common; using CSMath; using Xunit; @@ -6,6 +7,47 @@ namespace ACadSharp.Tests.Entities { public class LineTests { + private CSMathRandom _random = new CSMathRandom(); + + [Fact] + public void TranslationTest() + { + var start = XYZ.Zero; + var end = new XYZ(1, 1, 0); + Line line = new Line + { + StartPoint = start, + EndPoint = end, + }; + + XYZ move = new XYZ(5, 5, 0); + Transform translation = Transform.CreateTranslation(move); + line.ApplyTransform(translation); + + AssertUtils.AreEqual(start.Add(move), line.StartPoint); + AssertUtils.AreEqual(end.Add(move), line.EndPoint); + } + + [Fact] + public void RandomTranslationTest() + { + XYZ start = this._random.Next(); + XYZ end = this._random.Next(); + Line line = new Line + { + StartPoint = start, + EndPoint = end, + }; + + XYZ move = this._random.Next(); + Transform translation = Transform.CreateTranslation(move); + line.ApplyTransform(translation); + + AssertUtils.AreEqual(start.Add(move), line.StartPoint); + AssertUtils.AreEqual(end.Add(move), line.EndPoint); + } + + [Fact] public void GetBoundingBoxTest() { From 2214de902d3b4ca0a90251117a3de37ec38aaa2b Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 16:12:09 +0100 Subject: [PATCH 10/17] EscalationTest --- src/ACadSharp.Tests/Entities/LineTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ACadSharp.Tests/Entities/LineTests.cs b/src/ACadSharp.Tests/Entities/LineTests.cs index dddfc05d..3086e993 100644 --- a/src/ACadSharp.Tests/Entities/LineTests.cs +++ b/src/ACadSharp.Tests/Entities/LineTests.cs @@ -28,6 +28,25 @@ public void TranslationTest() AssertUtils.AreEqual(end.Add(move), line.EndPoint); } + [Fact] + public void EscalationTest() + { + var start = new XYZ(-1, -1, 0); + var end = new XYZ(1, 1, 0); + Line line = new Line + { + StartPoint = start, + EndPoint = end, + }; + + XYZ scale = new XYZ(2, 2, 1); + Transform translation = Transform.CreateEscalation(scale); + line.ApplyTransform(translation); + + AssertUtils.AreEqual(start.Multiply(scale), line.StartPoint); + AssertUtils.AreEqual(end.Multiply(scale), line.EndPoint); + } + [Fact] public void RandomTranslationTest() { From 6bda832ca2c16a4a9f82c6c111bc23e3b8ab2c54 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 18:53:20 +0100 Subject: [PATCH 11/17] line transform --- src/ACadSharp.Tests/Entities/LineTests.cs | 25 +++++++++++-- src/ACadSharp/Entities/Entity.cs | 10 ++++-- src/ACadSharp/Entities/Line.cs | 2 +- src/ACadSharp/Entities/Point.cs | 43 +++++++++++------------ src/CSUtilities | 2 +- 5 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/ACadSharp.Tests/Entities/LineTests.cs b/src/ACadSharp.Tests/Entities/LineTests.cs index 3086e993..ee369d02 100644 --- a/src/ACadSharp.Tests/Entities/LineTests.cs +++ b/src/ACadSharp.Tests/Entities/LineTests.cs @@ -26,6 +26,26 @@ public void TranslationTest() AssertUtils.AreEqual(start.Add(move), line.StartPoint); AssertUtils.AreEqual(end.Add(move), line.EndPoint); + AssertUtils.AreEqual(XYZ.AxisZ, line.Normal); + } + + [Fact] + public void RotationTest() + { + var start = XYZ.Zero; + var end = new XYZ(1, 1, 0); + Line line = new Line + { + StartPoint = start, + EndPoint = end, + }; + + Transform translation = Transform.CreateRotation(XYZ.AxisX, MathHelper.DegToRad(90)); + line.ApplyTransform(translation); + + AssertUtils.AreEqual(start, line.StartPoint); + AssertUtils.AreEqual(new XYZ(1, 0, 1), line.EndPoint); + AssertUtils.AreEqual(XYZ.AxisY, line.Normal); } [Fact] @@ -40,11 +60,12 @@ public void EscalationTest() }; XYZ scale = new XYZ(2, 2, 1); - Transform translation = Transform.CreateEscalation(scale); - line.ApplyTransform(translation); + Transform transform = Transform.CreateScaling(scale); + line.ApplyTransform(transform); AssertUtils.AreEqual(start.Multiply(scale), line.StartPoint); AssertUtils.AreEqual(end.Multiply(scale), line.EndPoint); + AssertUtils.AreEqual(XYZ.AxisZ, line.Normal); } [Fact] diff --git a/src/ACadSharp/Entities/Entity.cs b/src/ACadSharp/Entities/Entity.cs index 3899bcb5..806763cc 100644 --- a/src/ACadSharp/Entities/Entity.cs +++ b/src/ACadSharp/Entities/Entity.cs @@ -139,9 +139,15 @@ public void ApplyRotation(XYZ axis, double rotation) /// Apply a scale to this entity. /// /// - public void ApplyEscalation(XYZ scale) + public void ApplyScaling(XYZ scale) { - Transform transform = Transform.CreateEscalation(scale); + Transform transform = Transform.CreateScaling(scale); + this.ApplyTransform(transform); + } + + public void ApplyScaling(XYZ scale, XYZ origin) + { + Transform transform = Transform.CreateScaling(scale, origin); this.ApplyTransform(transform); } diff --git a/src/ACadSharp/Entities/Line.cs b/src/ACadSharp/Entities/Line.cs index a20c5d76..440590d2 100644 --- a/src/ACadSharp/Entities/Line.cs +++ b/src/ACadSharp/Entities/Line.cs @@ -77,7 +77,7 @@ public override void ApplyTransform(Transform transform) { this.StartPoint = transform.ApplyTransform(this.StartPoint); this.EndPoint = transform.ApplyTransform(this.EndPoint); - this.Normal = transform.ApplyTransform(this.Normal); + this.Normal = transform.Rotate(this.Normal).Normalize(); } } } diff --git a/src/ACadSharp/Entities/Point.cs b/src/ACadSharp/Entities/Point.cs index 251541f8..27964ff4 100644 --- a/src/ACadSharp/Entities/Point.cs +++ b/src/ACadSharp/Entities/Point.cs @@ -1,6 +1,5 @@ using ACadSharp.Attributes; using CSMath; -using System; namespace ACadSharp.Entities { @@ -15,33 +14,24 @@ namespace ACadSharp.Entities [DxfSubClass(DxfSubclassMarker.Point)] public class Point : Entity { - /// - public override ObjectType ObjectType => ObjectType.POINT; - - /// - public override string ObjectName => DxfFileToken.EntityPoint; - - /// - public override string SubclassMarker => DxfSubclassMarker.Point; - /// /// Point location(in WCS) /// [DxfCodeValue(10, 20, 30)] public XYZ Location { get; set; } = XYZ.Zero; - /// - /// Specifies the distance a 2D object is extruded above or below its elevation. - /// - [DxfCodeValue(39)] - public double Thickness { get; set; } = 0.0; - /// /// Specifies the three-dimensional normal unit vector for the object. /// [DxfCodeValue(210, 220, 230)] public XYZ Normal { get; set; } = XYZ.AxisZ; + /// + public override string ObjectName => DxfFileToken.EntityPoint; + + /// + public override ObjectType ObjectType => ObjectType.POINT; + /// /// Specifies the rotation angle for the object. /// @@ -51,6 +41,15 @@ public class Point : Entity [DxfCodeValue(DxfReferenceType.IsAngle, 50)] public double Rotation { get; set; } = 0.0; + /// + public override string SubclassMarker => DxfSubclassMarker.Point; + + /// + /// Specifies the distance a 2D object is extruded above or below its elevation. + /// + [DxfCodeValue(39)] + public double Thickness { get; set; } = 0.0; + /// /// Default constructor /// @@ -66,16 +65,16 @@ public Point(XYZ location) : base() } /// - public override BoundingBox GetBoundingBox() + public override void ApplyTransform(Transform transform) { - return new BoundingBox(this.Location); + this.Location = transform.ApplyTransform(this.Location); + this.Normal = transform.ApplyTransform(this.Normal); } /// - public override void ApplyTransform(Transform transform) + public override BoundingBox GetBoundingBox() { - this.Location = transform.ApplyTransform(this.Location); - this.Normal = transform.ApplyTransform(this.Normal); + return new BoundingBox(this.Location); } } -} +} \ No newline at end of file diff --git a/src/CSUtilities b/src/CSUtilities index c1fb0e4a..0d4b57f3 160000 --- a/src/CSUtilities +++ b/src/CSUtilities @@ -1 +1 @@ -Subproject commit c1fb0e4acde28ca7ca856971b4bde0b749d19121 +Subproject commit 0d4b57f3977f151d2a5b78c53a31050acab48210 From 00e44372a0fac6f493fb43f0c3284227f306a401 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sat, 15 Feb 2025 19:17:22 +0100 Subject: [PATCH 12/17] point --- src/ACadSharp.Tests/Entities/LineTests.cs | 2 +- src/ACadSharp.Tests/Entities/PointTests.cs | 23 +++++++++-- src/ACadSharp/Entities/Entity.cs | 5 +++ src/ACadSharp/Entities/Line.cs | 48 +++++++++++----------- src/ACadSharp/Entities/Point.cs | 2 +- 5 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/ACadSharp.Tests/Entities/LineTests.cs b/src/ACadSharp.Tests/Entities/LineTests.cs index ee369d02..8a2bfdc6 100644 --- a/src/ACadSharp.Tests/Entities/LineTests.cs +++ b/src/ACadSharp.Tests/Entities/LineTests.cs @@ -5,7 +5,7 @@ namespace ACadSharp.Tests.Entities { - public class LineTests + public class LineTests : CommonEntityTests { private CSMathRandom _random = new CSMathRandom(); diff --git a/src/ACadSharp.Tests/Entities/PointTests.cs b/src/ACadSharp.Tests/Entities/PointTests.cs index 8267a388..a465cbec 100644 --- a/src/ACadSharp.Tests/Entities/PointTests.cs +++ b/src/ACadSharp.Tests/Entities/PointTests.cs @@ -13,14 +13,31 @@ public class PointTests : CommonEntityTests public void TranslateTest() { XYZ init = _random.Next(); - XYZ translation = _random.Next(); - XYZ result = init + translation; + XYZ transform = _random.Next(); + XYZ result = init + transform; Point point = new Point(init); - point.ApplyTranslation(translation); + point.ApplyTranslation(transform); AssertUtils.AreEqual(result, point.Location, "Point Location"); + AssertUtils.AreEqual(XYZ.AxisZ, point.Normal); + } + + + [Fact] + public void RotationTest() + { + XYZ init = new(5, 5, 0); + + Point point = new Point(init); + + Transform translation = Transform.CreateRotation(new XYZ(1, 0, 0), MathHelper.DegToRad(90)); + point.ApplyTransform(translation); + + //Rotation around origin + AssertUtils.AreEqual(new XYZ(5, 0, 5), point.Location, "Point Location"); + AssertUtils.AreEqual(XYZ.AxisY, point.Normal); } } } diff --git a/src/ACadSharp/Entities/Entity.cs b/src/ACadSharp/Entities/Entity.cs index 806763cc..b28d2bac 100644 --- a/src/ACadSharp/Entities/Entity.cs +++ b/src/ACadSharp/Entities/Entity.cs @@ -220,6 +220,11 @@ internal override void UnassignDocument() this.LineType = (LineType)this.LineType.Clone(); } + protected XYZ transformNormal(Transform transform, XYZ normal) + { + return transform.Rotate(normal).Normalize(); + } + protected virtual void tableOnRemove(object sender, CollectionChangedEventArgs e) { if (e.Item.Equals(this.Layer)) diff --git a/src/ACadSharp/Entities/Line.cs b/src/ACadSharp/Entities/Line.cs index 440590d2..c93c9779 100644 --- a/src/ACadSharp/Entities/Line.cs +++ b/src/ACadSharp/Entities/Line.cs @@ -14,20 +14,11 @@ namespace ACadSharp.Entities [DxfSubClass(DxfSubclassMarker.Line)] public class Line : Entity { - /// - public override ObjectType ObjectType => ObjectType.LINE; - - /// - public override string ObjectName => DxfFileToken.EntityLine; - - /// - public override string SubclassMarker => DxfSubclassMarker.Line; - /// - /// Specifies the distance a 2D object is extruded above or below its elevation. + /// A 3D coordinate representing the end point of the object. /// - [DxfCodeValue(39)] - public double Thickness { get; set; } = 0.0; + [DxfCodeValue(11, 21, 31)] + public XYZ EndPoint { get; set; } = XYZ.Zero; /// /// Specifies the three-dimensional normal unit vector for the object. @@ -35,17 +26,26 @@ public class Line : Entity [DxfCodeValue(210, 220, 230)] public XYZ Normal { get; set; } = XYZ.AxisZ; + /// + public override string ObjectName => DxfFileToken.EntityLine; + + /// + public override ObjectType ObjectType => ObjectType.LINE; + /// /// A 3D coordinate representing the start point of the object. /// [DxfCodeValue(10, 20, 30)] public XYZ StartPoint { get; set; } = XYZ.Zero; + /// + public override string SubclassMarker => DxfSubclassMarker.Line; + /// - /// A 3D coordinate representing the end point of the object. + /// Specifies the distance a 2D object is extruded above or below its elevation. /// - [DxfCodeValue(11, 21, 31)] - public XYZ EndPoint { get; set; } = XYZ.Zero; + [DxfCodeValue(39)] + public double Thickness { get; set; } = 0.0; /// /// Default constructor @@ -63,6 +63,14 @@ public Line(XYZ start, XYZ end) : base() this.EndPoint = end; } + /// + public override void ApplyTransform(Transform transform) + { + this.StartPoint = transform.ApplyTransform(this.StartPoint); + this.EndPoint = transform.ApplyTransform(this.EndPoint); + this.Normal = this.transformNormal(transform, this.Normal); + } + /// public override BoundingBox GetBoundingBox() { @@ -71,13 +79,5 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } - - /// - public override void ApplyTransform(Transform transform) - { - this.StartPoint = transform.ApplyTransform(this.StartPoint); - this.EndPoint = transform.ApplyTransform(this.EndPoint); - this.Normal = transform.Rotate(this.Normal).Normalize(); - } } -} +} \ No newline at end of file diff --git a/src/ACadSharp/Entities/Point.cs b/src/ACadSharp/Entities/Point.cs index 27964ff4..4236af11 100644 --- a/src/ACadSharp/Entities/Point.cs +++ b/src/ACadSharp/Entities/Point.cs @@ -68,7 +68,7 @@ public Point(XYZ location) : base() public override void ApplyTransform(Transform transform) { this.Location = transform.ApplyTransform(this.Location); - this.Normal = transform.ApplyTransform(this.Normal); + this.Normal = this.transformNormal(transform, this.Normal); } /// From 106dd6846ad1ac06dd57fa5ecd7bf5520bdc966f Mon Sep 17 00:00:00 2001 From: DomCR Date: Mon, 17 Feb 2025 09:41:53 +0100 Subject: [PATCH 13/17] circle --- src/ACadSharp.Tests/Entities/CircleTests.cs | 65 ++++++++++++++++++++- src/ACadSharp.Tests/Entities/LineTests.cs | 6 +- src/ACadSharp/Entities/Circle.cs | 15 +++++ src/CSUtilities | 2 +- 4 files changed, 83 insertions(+), 5 deletions(-) diff --git a/src/ACadSharp.Tests/Entities/CircleTests.cs b/src/ACadSharp.Tests/Entities/CircleTests.cs index 5944f84e..d9aea9e3 100644 --- a/src/ACadSharp.Tests/Entities/CircleTests.cs +++ b/src/ACadSharp.Tests/Entities/CircleTests.cs @@ -1,11 +1,74 @@ using ACadSharp.Entities; +using ACadSharp.Tests.Common; using CSMath; using Xunit; namespace ACadSharp.Tests.Entities { - public class CircleTests + public class CircleTests : CommonEntityTests { + private CSMathRandom _random = new CSMathRandom(); + + [Fact] + public void TranslationTest() + { + double radius = 5; + XYZ center = new XYZ(1, 1, 0); + Circle circle = new Circle + { + Radius = radius, + Center = center + }; + + XYZ move = new XYZ(5, 5, 0); + Transform transform = Transform.CreateTranslation(move); + circle.ApplyTransform(transform); + + AssertUtils.AreEqual(XYZ.AxisZ, circle.Normal); + AssertUtils.AreEqual(center.Add(move), circle.Center); + Assert.Equal(radius, circle.Radius); + } + + [Fact] + public void RotationTest() + { + double radius = 5; + XYZ center = new XYZ(1, 1, 0); + Circle circle = new Circle + { + Radius = radius, + Center = center + }; + + Transform transform = Transform.CreateRotation(XYZ.AxisX, MathHelper.DegToRad(90)); + //{| 1, 0, 0, 0 || 0, 6.123233995736766E-17, -1, 0 || 0, 1, 6.123233995736766E-17, 0 || 0, 0, 0, 1 |} + circle.ApplyTransform(transform); + + AssertUtils.AreEqual(new XYZ(1, 0, 1), circle.Center); + Assert.Equal(radius, circle.Radius); + AssertUtils.AreEqual(XYZ.AxisY, circle.Normal); + } + + [Fact] + public void ScalingTest() + { + double radius = 5; + XYZ center = new XYZ(1, 1, 0); + Circle circle = new Circle + { + Radius = radius, + Center = center + }; + + XYZ scale = new XYZ(2, 2, 1); + Transform transform = Transform.CreateScaling(scale, center); + circle.ApplyTransform(transform); + + AssertUtils.AreEqual(XYZ.AxisZ, circle.Normal); + AssertUtils.AreEqual(center, circle.Center); + Assert.Equal(10, circle.Radius); + } + [Fact] public void GetBoundingBoxTest() { diff --git a/src/ACadSharp.Tests/Entities/LineTests.cs b/src/ACadSharp.Tests/Entities/LineTests.cs index 8a2bfdc6..6d4553c9 100644 --- a/src/ACadSharp.Tests/Entities/LineTests.cs +++ b/src/ACadSharp.Tests/Entities/LineTests.cs @@ -21,8 +21,8 @@ public void TranslationTest() }; XYZ move = new XYZ(5, 5, 0); - Transform translation = Transform.CreateTranslation(move); - line.ApplyTransform(translation); + Transform transform = Transform.CreateTranslation(move); + line.ApplyTransform(transform); AssertUtils.AreEqual(start.Add(move), line.StartPoint); AssertUtils.AreEqual(end.Add(move), line.EndPoint); @@ -49,7 +49,7 @@ public void RotationTest() } [Fact] - public void EscalationTest() + public void ScalingTest() { var start = new XYZ(-1, -1, 0); var end = new XYZ(1, 1, 0); diff --git a/src/ACadSharp/Entities/Circle.cs b/src/ACadSharp/Entities/Circle.cs index 2cc1e70c..bce6230c 100644 --- a/src/ACadSharp/Entities/Circle.cs +++ b/src/ACadSharp/Entities/Circle.cs @@ -77,7 +77,22 @@ public override BoundingBox GetBoundingBox() /// public override void ApplyTransform(Transform transform) { + var center = this.Center; + var normal = this.Normal; + this.Center = transform.ApplyTransform(this.Center); + this.Normal = this.transformNormal(transform, this.Normal); + + Matrix3 trans = new Matrix3(transform.Matrix); + Matrix3 transOW = Matrix3.ArbitraryAxis(normal); + Matrix3 transWO = Matrix3.ArbitraryAxis(this.Normal).Transpose(); + + XYZ axis = transOW * new XYZ(this.Radius, 0.0, 0.0); + axis = trans * axis; + axis = transWO * axis; + + XY axisPoint = new XY(axis.X, axis.Y); + this._radius = axisPoint.GetLength(); } } } \ No newline at end of file diff --git a/src/CSUtilities b/src/CSUtilities index 0d4b57f3..fdf684fa 160000 --- a/src/CSUtilities +++ b/src/CSUtilities @@ -1 +1 @@ -Subproject commit 0d4b57f3977f151d2a5b78c53a31050acab48210 +Subproject commit fdf684fa912918cb027670d4083c8b21aafee31a From 7790c038c06c839145ba6146b4fe42c6f1e3270a Mon Sep 17 00:00:00 2001 From: DomCR Date: Mon, 17 Feb 2025 11:16:03 +0100 Subject: [PATCH 14/17] arc --- src/ACadSharp.Tests/Entities/ArcTests.cs | 67 ++++++++++++++++++++- src/ACadSharp.Tests/Entities/CircleTests.cs | 1 - src/ACadSharp/Entities/Arc.cs | 40 ++++++++++++ src/ACadSharp/Entities/Circle.cs | 11 +++- 4 files changed, 114 insertions(+), 5 deletions(-) diff --git a/src/ACadSharp.Tests/Entities/ArcTests.cs b/src/ACadSharp.Tests/Entities/ArcTests.cs index a9460fff..7fe1d2b0 100644 --- a/src/ACadSharp.Tests/Entities/ArcTests.cs +++ b/src/ACadSharp.Tests/Entities/ArcTests.cs @@ -6,7 +6,7 @@ namespace ACadSharp.Tests.Entities { - public class ArcTests + public class ArcTests : CommonEntityTests { [Fact] public void CreateFromBulgeTest() @@ -93,5 +93,70 @@ public void GetEndVerticesTest() AssertUtils.AreEqual(start, s1, "start point"); AssertUtils.AreEqual(end, e2, "end point"); } + + [Fact] + public void TranslationTest() + { + double radius = 5; + XYZ center = new XYZ(1, 1, 0); + Arc arc = new Arc + { + Radius = radius, + Center = center, + }; + + XYZ move = new XYZ(5, 5, 0); + Transform transform = Transform.CreateTranslation(move); + arc.ApplyTransform(transform); + + AssertUtils.AreEqual(XYZ.AxisZ, arc.Normal); + AssertUtils.AreEqual(center.Add(move), arc.Center); + Assert.Equal(radius, arc.Radius); + Assert.Equal(0, arc.StartAngle); + Assert.Equal(Math.PI, arc.EndAngle); + } + + [Fact] + public void RotationTest() + { + double radius = 5; + XYZ center = new XYZ(1, 1, 0); + Arc arc = new Arc + { + Radius = radius, + Center = center + }; + + Transform transform = Transform.CreateRotation(XYZ.AxisX, MathHelper.DegToRad(90)); + arc.ApplyTransform(transform); + + AssertUtils.AreEqual(new XYZ(1, 0, 1), arc.Center); + Assert.Equal(radius, arc.Radius); + Assert.Equal(Math.PI, arc.StartAngle); + Assert.Equal(0, arc.EndAngle); + AssertUtils.AreEqual(XYZ.AxisY, arc.Normal); + } + + [Fact] + public void ScalingTest() + { + double radius = 5; + XYZ center = new XYZ(1, 1, 0); + Arc arc = new Arc + { + Radius = radius, + Center = center + }; + + XYZ scale = new XYZ(2, 2, 1); + Transform transform = Transform.CreateScaling(scale, center); + arc.ApplyTransform(transform); + + AssertUtils.AreEqual(XYZ.AxisZ, arc.Normal); + AssertUtils.AreEqual(center, arc.Center); + Assert.Equal(10, arc.Radius); + Assert.Equal(0, arc.StartAngle); + Assert.Equal(Math.PI, arc.EndAngle); + } } } \ No newline at end of file diff --git a/src/ACadSharp.Tests/Entities/CircleTests.cs b/src/ACadSharp.Tests/Entities/CircleTests.cs index d9aea9e3..497dd1de 100644 --- a/src/ACadSharp.Tests/Entities/CircleTests.cs +++ b/src/ACadSharp.Tests/Entities/CircleTests.cs @@ -41,7 +41,6 @@ public void RotationTest() }; Transform transform = Transform.CreateRotation(XYZ.AxisX, MathHelper.DegToRad(90)); - //{| 1, 0, 0, 0 || 0, 6.123233995736766E-17, -1, 0 || 0, 1, 6.123233995736766E-17, 0 || 0, 0, 0, 1 |} circle.ApplyTransform(transform); AssertUtils.AreEqual(new XYZ(1, 0, 1), circle.Center); diff --git a/src/ACadSharp/Entities/Arc.cs b/src/ACadSharp/Entities/Arc.cs index c5149cad..898ce73d 100644 --- a/src/ACadSharp/Entities/Arc.cs +++ b/src/ACadSharp/Entities/Arc.cs @@ -110,6 +110,46 @@ public static XY GetCenter(XY start, XY end, double bulge, out double radius) return new XY(start.X + radius * CSMath.MathHelper.Cos(phi), start.Y + radius * CSMath.MathHelper.Sin(phi)); } + /// + public override void ApplyTransform(Transform transform) + { + var center = this.Center; + var normal = this.Normal; + var radius = this.Radius; + + base.ApplyTransform(transform); + + Matrix3 trans = getWorldMatrix(transform, normal, this.Normal, out Matrix3 transOW, out Matrix3 transWO); + + XY start = XY.Rotate(new XY(this.Radius, 0.0), this.StartAngle); + XY end = XY.Rotate(new XY(this.Radius, 0.0), this.EndAngle); + + XYZ vStart = transOW * new XYZ(start.X, start.Y, 0.0); + vStart = trans * vStart; + vStart = transWO * vStart; + + XYZ vEnd = transOW * new XYZ(end.X, end.Y, 0.0); + vEnd = trans * vEnd; + vEnd = transWO * vEnd; + + XY startPoint = new XY(vStart.X, vStart.Y); + XY endPoint = new XY(vEnd.X, vEnd.Y); + + if (Math.Sign(trans.m00 * trans.m11 * trans.m22) < 0) + { + this.EndAngle = startPoint.GetAngle(); + this.StartAngle = endPoint.GetAngle(); + } + else + { + this.StartAngle = startPoint.GetAngle(); + this.EndAngle = endPoint.GetAngle(); + } + + this.StartAngle = MathHelper.FixZero(this.StartAngle); + this.EndAngle = MathHelper.FixZero(this.EndAngle); + } + /// public override BoundingBox GetBoundingBox() { diff --git a/src/ACadSharp/Entities/Circle.cs b/src/ACadSharp/Entities/Circle.cs index bce6230c..40aaa940 100644 --- a/src/ACadSharp/Entities/Circle.cs +++ b/src/ACadSharp/Entities/Circle.cs @@ -83,9 +83,7 @@ public override void ApplyTransform(Transform transform) this.Center = transform.ApplyTransform(this.Center); this.Normal = this.transformNormal(transform, this.Normal); - Matrix3 trans = new Matrix3(transform.Matrix); - Matrix3 transOW = Matrix3.ArbitraryAxis(normal); - Matrix3 transWO = Matrix3.ArbitraryAxis(this.Normal).Transpose(); + Matrix3 trans = getWorldMatrix(transform, normal, this.Normal, out Matrix3 transOW, out Matrix3 transWO); XYZ axis = transOW * new XYZ(this.Radius, 0.0, 0.0); axis = trans * axis; @@ -94,5 +92,12 @@ public override void ApplyTransform(Transform transform) XY axisPoint = new XY(axis.X, axis.Y); this._radius = axisPoint.GetLength(); } + + protected Matrix3 getWorldMatrix(Transform transform, XYZ normal, XYZ newNormal, out Matrix3 transOW, out Matrix3 transWO) + { + transOW = Matrix3.ArbitraryAxis(normal); + transWO = Matrix3.ArbitraryAxis(newNormal).Transpose(); + return new Matrix3(transform.Matrix); + } } } \ No newline at end of file From dd1cb370fe5ddb02f86f1f550fab0a697d51ac78 Mon Sep 17 00:00:00 2001 From: DomCR Date: Mon, 17 Feb 2025 12:25:38 +0100 Subject: [PATCH 15/17] insert --- src/ACadSharp/Entities/Ellipse.cs | 1 + src/ACadSharp/Entities/Insert.cs | 230 +++++++++++++++++------------- 2 files changed, 134 insertions(+), 97 deletions(-) diff --git a/src/ACadSharp/Entities/Ellipse.cs b/src/ACadSharp/Entities/Ellipse.cs index f0b773a3..45584188 100644 --- a/src/ACadSharp/Entities/Ellipse.cs +++ b/src/ACadSharp/Entities/Ellipse.cs @@ -184,6 +184,7 @@ public List PolygonalVertexes(int precision) return points; } + /// public override void ApplyTransform(Transform transform) { throw new NotImplementedException(); diff --git a/src/ACadSharp/Entities/Insert.cs b/src/ACadSharp/Entities/Insert.cs index 796582fe..be60243c 100644 --- a/src/ACadSharp/Entities/Insert.cs +++ b/src/ACadSharp/Entities/Insert.cs @@ -18,27 +18,13 @@ namespace ACadSharp.Entities [DxfSubClass(DxfSubclassMarker.Insert)] public class Insert : Entity { - /// - public override ObjectType ObjectType - { - get - { - if (this.RowCount > 1 || this.ColumnCount > 1) - { - return ObjectType.MINSERT; - } - else - { - return ObjectType.INSERT; - } - } - } - - /// - public override string ObjectName => DxfFileToken.EntityInsert; - - /// - public override string SubclassMarker => DxfSubclassMarker.Insert; + /// + /// Attributes from the block reference + /// + /// + /// If an attribute should be added in this collection a definition will be added into the block reference as well + /// + public SeqendCollection Attributes { get; private set; } /// /// Gets the insert block definition. @@ -47,37 +33,29 @@ public override ObjectType ObjectType public BlockRecord Block { get; internal set; } /// - /// A 3D WCS coordinate representing the insertion or origin point. - /// - [DxfCodeValue(10, 20, 30)] - public XYZ InsertPoint { get; set; } = XYZ.Zero; - - /// - /// X scale factor. + /// Column count /// - [DxfCodeValue(41)] - public double XScale { get; set; } = 1; + [DxfCodeValue(DxfReferenceType.Optional, 70)] + public ushort ColumnCount { get; set; } = 1; /// - /// Y scale factor. + /// Column spacing /// - [DxfCodeValue(42)] - public double YScale { get; set; } = 1; + [DxfCodeValue(DxfReferenceType.Optional, 44)] + public double ColumnSpacing { get; set; } = 0; /// - /// Z scale factor. + /// True if the insert has attribute entities in it /// - [DxfCodeValue(43)] - public double ZScale { get; set; } = 1; + [DxfCodeValue(DxfReferenceType.Ignored, 66)] + public bool HasAttributes + { get { return this.Attributes.Any(); } } /// - /// Specifies the rotation angle for the object. + /// A 3D WCS coordinate representing the insertion or origin point. /// - /// - /// The rotation angle in radians. - /// - [DxfCodeValue(DxfReferenceType.IsAngle, 50)] - public double Rotation { get; set; } = 0.0; + [DxfCodeValue(10, 20, 30)] + public XYZ InsertPoint { get; set; } = XYZ.Zero; /// /// Specifies the three-dimensional normal unit vector for the object. @@ -85,11 +63,33 @@ public override ObjectType ObjectType [DxfCodeValue(210, 220, 230)] public XYZ Normal { get; set; } = XYZ.AxisZ; + /// + public override string ObjectName => DxfFileToken.EntityInsert; + + /// + public override ObjectType ObjectType + { + get + { + if (this.RowCount > 1 || this.ColumnCount > 1) + { + return ObjectType.MINSERT; + } + else + { + return ObjectType.INSERT; + } + } + } + /// - /// Column count + /// Specifies the rotation angle for the object. /// - [DxfCodeValue(DxfReferenceType.Optional, 70)] - public ushort ColumnCount { get; set; } = 1; + /// + /// The rotation angle in radians. + /// + [DxfCodeValue(DxfReferenceType.IsAngle, 50)] + public double Rotation { get; set; } = 0.0; /// /// Row count @@ -97,36 +97,32 @@ public override ObjectType ObjectType [DxfCodeValue(DxfReferenceType.Optional, 71)] public ushort RowCount { get; set; } = 1; - /// - /// Column spacing - /// - [DxfCodeValue(DxfReferenceType.Optional, 44)] - public double ColumnSpacing { get; set; } = 0; - /// /// Row spacing /// [DxfCodeValue(DxfReferenceType.Optional, 45)] public double RowSpacing { get; set; } = 0; + /// + public override string SubclassMarker => DxfSubclassMarker.Insert; + /// - /// True if the insert has attribute entities in it + /// X scale factor. /// - [DxfCodeValue(DxfReferenceType.Ignored, 66)] - public bool HasAttributes { get { return this.Attributes.Any(); } } + [DxfCodeValue(41)] + public double XScale { get; set; } = 1; /// - /// Attributes from the block reference + /// Y scale factor. /// - /// - /// If an attribute should be added in this collection a definition will be added into the block reference as well - /// - public SeqendCollection Attributes { get; private set; } + [DxfCodeValue(42)] + public double YScale { get; set; } = 1; - internal Insert() : base() - { - this.Attributes = new SeqendCollection(this); - } + /// + /// Z scale factor. + /// + [DxfCodeValue(43)] + public double ZScale { get; set; } = 1; /// /// Constructor to reference an insert to a block record @@ -149,31 +145,66 @@ public Insert(BlockRecord block) : this() this.UpdateAttributes(); } - /// - /// Updates all attribute definitions contained in the block reference as entitites in the insert - /// - public void UpdateAttributes() + internal Insert() : base() { - var atts = this.Attributes.ToArray(); + this.Attributes = new SeqendCollection(this); + } - foreach (AttributeEntity att in atts) + /// + public override void ApplyTransform(Transform transform) + { + XYZ newPosition = transform.ApplyTransform(this.InsertPoint); + XYZ newNormal = this.transformNormal(transform, this.Normal); + + Matrix3 transOW = Matrix3.ArbitraryAxis(this.Normal); + transOW *= Matrix3.RotationZ(this.Rotation); + + Matrix3 transWO = Matrix3.ArbitraryAxis(newNormal); + transWO = transWO.Transpose(); + + var transformation = new Matrix3(transform.Matrix); + XYZ v = transOW * XYZ.AxisX; + v = transformation * v; + v = transWO * v; + double newRotation = new XY(v.X, v.Y).GetAngle(); + + transWO = Matrix3.RotationZ(newRotation).Transpose() * transWO; + + XYZ s = transOW * new XYZ(this.XScale, this.YScale, this.ZScale); + s = transformation * s; + s = transWO * s; + XYZ newScale = new XYZ( + MathHelper.IsZero(s.X) ? MathHelper.Epsilon : s.X, + MathHelper.IsZero(s.Y) ? MathHelper.Epsilon : s.Y, + MathHelper.IsZero(s.Z) ? MathHelper.Epsilon : s.Z); + + this.Normal = newNormal; + this.InsertPoint = newPosition; + this.XScale = newScale.X; + this.YScale = newScale.Y; + this.ZScale = newScale.Z; + this.Rotation = newRotation; + + foreach (AttributeEntity att in this.Attributes) { - //Tags are not unique, is it needed? check how the different applications link the atts - if (!this.Block.AttributeDefinitions.Select(d => d.Tag).Contains(att.Tag)) - { - this.Attributes.Remove(att); - } + att.ApplyTransform(transform); } + } - foreach (AttributeDefinition attdef in this.Block.AttributeDefinitions) - { - if (!this.Attributes.Select(d => d.Tag).Contains(attdef.Tag)) - { - AttributeEntity att = new AttributeEntity(attdef); + /// + public override CadObject Clone() + { + Insert clone = (Insert)base.Clone(); - this.Attributes.Add(att); - } + clone.Block = (BlockRecord)this.Block?.Clone(); + + clone.Attributes = new SeqendCollection(clone); + foreach (var att in this.Attributes) + { + clone.Attributes.Add((AttributeEntity)att.Clone()); } + + return clone; } /// @@ -188,20 +219,31 @@ public override BoundingBox GetBoundingBox() return new BoundingBox(min, max); } - /// - public override CadObject Clone() + /// + /// Updates all attribute definitions contained in the block reference as entitites in the insert + /// + public void UpdateAttributes() { - Insert clone = (Insert)base.Clone(); - - clone.Block = (BlockRecord)this.Block?.Clone(); + var atts = this.Attributes.ToArray(); - clone.Attributes = new SeqendCollection(clone); - foreach (var att in this.Attributes) + foreach (AttributeEntity att in atts) { - clone.Attributes.Add((AttributeEntity)att.Clone()); + //Tags are not unique, is it needed? check how the different applications link the atts + if (!this.Block.AttributeDefinitions.Select(d => d.Tag).Contains(att.Tag)) + { + this.Attributes.Remove(att); + } } - return clone; + foreach (AttributeDefinition attdef in this.Block.AttributeDefinitions) + { + if (!this.Attributes.Select(d => d.Tag).Contains(attdef.Tag)) + { + AttributeEntity att = new AttributeEntity(attdef); + + this.Attributes.Add(att); + } + } } internal override void AssignDocument(CadDocument doc) @@ -231,11 +273,5 @@ internal override void UnassignDocument() base.UnassignDocument(); } - - /// - public override void ApplyTransform(Transform transform) - { - throw new NotImplementedException(); - } } -} +} \ No newline at end of file From 2757c6169d8d634f44dd2e3757623b285d32d584 Mon Sep 17 00:00:00 2001 From: DomCR Date: Mon, 17 Feb 2025 12:30:31 +0100 Subject: [PATCH 16/17] submodule --- src/CSUtilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CSUtilities b/src/CSUtilities index fdf684fa..1e3de533 160000 --- a/src/CSUtilities +++ b/src/CSUtilities @@ -1 +1 @@ -Subproject commit fdf684fa912918cb027670d4083c8b21aafee31a +Subproject commit 1e3de533c17f18dfefcbe72d41e2894291337d07 From 15328584b3fb6b23cc56efd2f69b1e6d8e1d19b0 Mon Sep 17 00:00:00 2001 From: DomCR Date: Mon, 17 Feb 2025 14:59:30 +0100 Subject: [PATCH 17/17] aligned --- src/ACadSharp/Entities/Circle.cs | 7 - src/ACadSharp/Entities/Dimension.cs | 195 +++++++++++---------- src/ACadSharp/Entities/DimensionAligned.cs | 8 +- src/ACadSharp/Entities/Entity.cs | 16 ++ 4 files changed, 128 insertions(+), 98 deletions(-) diff --git a/src/ACadSharp/Entities/Circle.cs b/src/ACadSharp/Entities/Circle.cs index 40aaa940..1870b56b 100644 --- a/src/ACadSharp/Entities/Circle.cs +++ b/src/ACadSharp/Entities/Circle.cs @@ -92,12 +92,5 @@ public override void ApplyTransform(Transform transform) XY axisPoint = new XY(axis.X, axis.Y); this._radius = axisPoint.GetLength(); } - - protected Matrix3 getWorldMatrix(Transform transform, XYZ normal, XYZ newNormal, out Matrix3 transOW, out Matrix3 transWO) - { - transOW = Matrix3.ArbitraryAxis(normal); - transWO = Matrix3.ArbitraryAxis(newNormal).Transpose(); - return new Matrix3(transform.Matrix); - } } } \ No newline at end of file diff --git a/src/ACadSharp/Entities/Dimension.cs b/src/ACadSharp/Entities/Dimension.cs index eff30a33..f50539c3 100644 --- a/src/ACadSharp/Entities/Dimension.cs +++ b/src/ACadSharp/Entities/Dimension.cs @@ -17,14 +17,11 @@ namespace ACadSharp.Entities [DxfSubClass(DxfSubclassMarker.Dimension)] public abstract class Dimension : Entity { - /// - public override string SubclassMarker => DxfSubclassMarker.Dimension; - /// - /// Version number + /// Attachment point /// - [DxfCodeValue(280)] - public byte Version { get; set; } + [DxfCodeValue(71)] + public AttachmentPointType AttachmentPoint { get; set; } /// /// Block that contains the entities that make up the dimension picture @@ -38,24 +35,6 @@ public abstract class Dimension : Entity [DxfCodeValue(10, 20, 30)] public XYZ DefinitionPoint { get; set; } - /// - /// Middle point of dimension text(in OCS) - /// - [DxfCodeValue(11, 21, 31)] - public XYZ TextMiddlePoint { get; set; } - - /// - /// Insertion point for clones of a dimension-Baseline and Continue(in OCS) - /// - [DxfCodeValue(12, 22, 32)] - public XYZ InsertionPoint { get; set; } - - /// - /// Specifies the three-dimensional normal unit vector for the object. - /// - [DxfCodeValue(210, 220, 230)] - public XYZ Normal { get; set; } = XYZ.AxisZ; - /// /// Dimension type /// @@ -72,6 +51,47 @@ internal set } } + /// + /// Gets or sets a value indicating whether the first arrow + /// is to be flipped. + /// + /// + /// true if the arrow is to be flipped; otherwise, false. + /// + /// + /// Arrows are by default drawn inside the extension lines if there is enough + /// space; otherwise, outside. This flag overrules the standard behavior. + /// + [DxfCodeValue(74)] + public bool FlipArrow1 { get; set; } + + /// + /// Gets or sets a value indicating whether the second arrow + /// to be flipped. + /// + /// + /// true if the arrow is to be flipped; otherwise, false. + /// + /// + /// Arrows are by default drawn inside the extension lines if there is enough + /// space; otherwise, outside. This flag overrules the standard behavior. + /// + [DxfCodeValue(75)] + public bool FlipArrow2 { get; set; } + + /// + /// All dimension types have an optional 51 group code, which indicates the horizontal direction for the dimension entity.The dimension entity determines the orientation of dimension text and lines for horizontal, vertical, and rotated linear dimensions + /// This group value is the negative of the angle between the OCS X axis and the UCS X axis. It is always in the XY plane of the OCS + /// + [DxfCodeValue(DxfReferenceType.Optional | DxfReferenceType.IsAngle, 51)] + public double HorizontalDirection { get; set; } + + /// + /// Insertion point for clones of a dimension-Baseline and Continue(in OCS) + /// + [DxfCodeValue(12, 22, 32)] + public XYZ InsertionPoint { get; set; } + /// /// Indicates if the dimension text has been positioned at a user-defined location rather than at the default location /// @@ -94,18 +114,6 @@ public bool IsTextUserDefinedLocation } } - /// - /// Attachment point - /// - [DxfCodeValue(71)] - public AttachmentPointType AttachmentPoint { get; set; } - - /// - /// Dimension text line-spacing style - /// - [DxfCodeValue(DxfReferenceType.Optional, 72)] - public LineSpacingStyleType LineSpacingStyle { get; set; } - /// /// Dimension text-line spacing factor /// @@ -118,6 +126,12 @@ public bool IsTextUserDefinedLocation [DxfCodeValue(DxfReferenceType.Optional, 41)] public double LineSpacingFactor { get; set; } + /// + /// Dimension text line-spacing style + /// + [DxfCodeValue(DxfReferenceType.Optional, 72)] + public LineSpacingStyleType LineSpacingStyle { get; set; } + /// /// Actual measurement /// @@ -125,32 +139,38 @@ public bool IsTextUserDefinedLocation public abstract double Measurement { get; } /// - /// Gets or sets a value indicating whether the first arrow - /// is to be flipped. + /// Specifies the three-dimensional normal unit vector for the object. /// - /// - /// true if the arrow is to be flipped; otherwise, false. - /// - /// - /// Arrows are by default drawn inside the extension lines if there is enough - /// space; otherwise, outside. This flag overrules the standard behavior. - /// - [DxfCodeValue(74)] - public bool FlipArrow1 { get; set; } + [DxfCodeValue(210, 220, 230)] + public XYZ Normal { get; set; } = XYZ.AxisZ; /// - /// Gets or sets a value indicating whether the second arrow - /// to be flipped. + /// Dimension style /// - /// - /// true if the arrow is to be flipped; otherwise, false. - /// - /// - /// Arrows are by default drawn inside the extension lines if there is enough - /// space; otherwise, outside. This flag overrules the standard behavior. - /// - [DxfCodeValue(75)] - public bool FlipArrow2 { get; set; } + [DxfCodeValue(DxfReferenceType.Name, 3)] + public DimensionStyle Style + { + get { return this._style; } + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + if (this.Document != null) + { + this._style = this.updateTable(value, this.Document.DimensionStyles); + } + else + { + this._style = value; + } + } + } + + /// + public override string SubclassMarker => DxfSubclassMarker.Dimension; /// /// Gets or sets an explicit dimension text to be displayed instead of the standard @@ -158,12 +178,18 @@ public bool IsTextUserDefinedLocation /// dimension-style properties. /// /// - /// If null or empty, the dimension created from the measurement is to be displayed. + /// If null or empty, the dimension created from the measurement is to be displayed. /// If " " (one blank space), the text is to be suppressed. Anything else is drawn as the text. /// [DxfCodeValue(DxfReferenceType.Optional, 1)] public string Text { get; set; } + /// + /// Middle point of dimension text(in OCS) + /// + [DxfCodeValue(11, 21, 31)] + public XYZ TextMiddlePoint { get; set; } + /// /// rotation angle of the dimension text away from its default orientation (the direction of the dimension line) /// @@ -174,39 +200,12 @@ public bool IsTextUserDefinedLocation public double TextRotation { get; set; } /// - /// All dimension types have an optional 51 group code, which indicates the horizontal direction for the dimension entity.The dimension entity determines the orientation of dimension text and lines for horizontal, vertical, and rotated linear dimensions - /// This group value is the negative of the angle between the OCS X axis and the UCS X axis. It is always in the XY plane of the OCS + /// Version number /// - [DxfCodeValue(DxfReferenceType.Optional | DxfReferenceType.IsAngle, 51)] - public double HorizontalDirection { get; set; } + [DxfCodeValue(280)] + public byte Version { get; set; } //This group value is the negative of the angle between the OCS X axis and the UCS X axis.It is always in the XY plane of the OCS - - /// - /// Dimension style - /// - [DxfCodeValue(DxfReferenceType.Name, 3)] - public DimensionStyle Style - { - get { return this._style; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - if (this.Document != null) - { - this._style = this.updateTable(value, this.Document.DimensionStyles); - } - else - { - this._style = value; - } - } - } - protected DimensionType _flags; private DimensionStyle _style = DimensionStyle.Default; @@ -217,6 +216,22 @@ protected Dimension(DimensionType type) this._flags |= DimensionType.BlockReference; } + /// + public override void ApplyTransform(Transform transform) + { + XYZ newNormal = this.transformNormal(transform, this.Normal); + this.getWorldMatrix(transform, Normal, newNormal, out Matrix3 transOW, out Matrix3 transWO); + + this.DefinitionPoint = applyWorldMatrix(this.DefinitionPoint, transform, transOW, transWO); + + if (this.IsTextUserDefinedLocation) + { + this.TextMiddlePoint = applyWorldMatrix(this.TextMiddlePoint, transform, transOW, transWO); + } + + this.Normal = newNormal; + } + /// public override CadObject Clone() { @@ -255,4 +270,4 @@ protected override void tableOnRemove(object sender, CollectionChangedEventArgs } } } -} +} \ No newline at end of file diff --git a/src/ACadSharp/Entities/DimensionAligned.cs b/src/ACadSharp/Entities/DimensionAligned.cs index cd6a91e3..0d6f8fc7 100644 --- a/src/ACadSharp/Entities/DimensionAligned.cs +++ b/src/ACadSharp/Entities/DimensionAligned.cs @@ -68,7 +68,13 @@ public override BoundingBox GetBoundingBox() /// public override void ApplyTransform(Transform transform) { - throw new System.NotImplementedException(); + XYZ newNormal = this.transformNormal(transform, this.Normal); + this.getWorldMatrix(transform, Normal, newNormal, out Matrix3 transOW, out Matrix3 transWO); + + base.ApplyTransform(transform); + + this.FirstPoint = applyWorldMatrix(this.FirstPoint, transform, transOW, transWO); + this.SecondPoint = applyWorldMatrix(this.SecondPoint, transform, transOW, transWO); } } } diff --git a/src/ACadSharp/Entities/Entity.cs b/src/ACadSharp/Entities/Entity.cs index b28d2bac..04cd631c 100644 --- a/src/ACadSharp/Entities/Entity.cs +++ b/src/ACadSharp/Entities/Entity.cs @@ -1,4 +1,5 @@ using ACadSharp.Attributes; +using ACadSharp.Entities; using ACadSharp.Objects; using ACadSharp.Tables; using CSMath; @@ -237,5 +238,20 @@ protected virtual void tableOnRemove(object sender, CollectionChangedEventArgs e this.LineType = this.Document.LineTypes[LineType.ByLayerName]; } } + + protected Matrix3 getWorldMatrix(Transform transform, XYZ normal, XYZ newNormal, out Matrix3 transOW, out Matrix3 transWO) + { + transOW = Matrix3.ArbitraryAxis(normal); + transWO = Matrix3.ArbitraryAxis(newNormal).Transpose(); + return new Matrix3(transform.Matrix); + } + + protected XYZ applyWorldMatrix(XYZ xyz, Transform transform, Matrix3 transOW, Matrix3 transWO) + { + XYZ v = transOW * xyz; + v = transform.ApplyTransform(v); + v = transWO * v; + return v; + } } }