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/Blocks/Block.cs b/src/ACadSharp/Blocks/Block.cs index 84e1be2b..41572f96 100644 --- a/src/ACadSharp/Blocks/Block.cs +++ b/src/ACadSharp/Blocks/Block.cs @@ -75,7 +75,7 @@ public Block(BlockRecord record) : base() /// /// - /// 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/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/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/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(); 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/DXF/DxfStreamReader/DxfSectionReaderBase.cs b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs index d303be4e..5573bc27 100644 --- a/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs +++ b/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs @@ -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/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/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) diff --git a/src/ACadSharp/MathUtils.cs b/src/ACadSharp/MathUtils.cs index e593616a..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 _);