Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometric transform #457

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/ACadSharp.Tests/Entities/CommonEntityTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using ACadSharp.Entities;
using Xunit;

namespace ACadSharp.Tests.Entities
{
public abstract class CommonEntityTests<T>
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);
}
}
}
26 changes: 26 additions & 0 deletions src/ACadSharp.Tests/Entities/PointTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using ACadSharp.Entities;
using ACadSharp.Tests.Common;
using CSMath;
using Xunit;

namespace ACadSharp.Tests.Entities
{
public class PointTests : CommonEntityTests<Point>
{
private CSMathRandom _random = new CSMathRandom();

[Fact]
public void TranslateTest()
{
XYZ init = _random.Next<XYZ>();
XYZ translation = _random.Next<XYZ>();
XYZ result = init + translation;

Point point = new Point(init);

point.Translate(translation);

AssertUtils.AreEqual(result, point.Location, "Point Location");
}
}
}
26 changes: 25 additions & 1 deletion src/ACadSharp/Blocks/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Block(BlockRecord record) : base()

/// <inheritdoc/>
/// <remarks>
/// Cloning a block will also unatach it from the record
/// Cloning a block will also unattached it from the record
/// </remarks>
public override CadObject Clone()
{
Expand All @@ -86,6 +86,30 @@ public override CadObject Clone()
return clone;
}

/// <inheritdoc/>
public override void Translate(XYZ translation)
{
throw new System.NotImplementedException();
}

/// <inheritdoc/>
public override void Rotate(double rotation, XYZ axis)
{
throw new System.NotImplementedException();
}

/// <inheritdoc/>
public override void Scale(XYZ scale)
{
throw new System.NotImplementedException();
}

public override void ApplyTransform(Transform transform)
{
throw new System.NotImplementedException();
}

/// <inheritdoc/>
public override BoundingBox GetBoundingBox()
{
BoundingBox box = BoundingBox.Null;
Expand Down
24 changes: 24 additions & 0 deletions src/ACadSharp/Blocks/BlockEnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,29 @@ public override BoundingBox GetBoundingBox()
{
return BoundingBox.Null;
}

/// <inheritdoc/>
public override void Translate(XYZ translation)
{
throw new System.NotImplementedException();
}

/// <inheritdoc/>
public override void Rotate(double rotation, XYZ axis)
{
throw new System.NotImplementedException();
}

/// <inheritdoc/>
public override void Scale(XYZ scale)
{
throw new System.NotImplementedException();
}

/// <inheritdoc/>
public override void ApplyTransform(Transform transform)
{
throw new System.NotImplementedException();
}
}
}
4 changes: 2 additions & 2 deletions src/ACadSharp/Entities/Arc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public List<XY> 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));
}
Expand Down
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/CadImageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/// <inheritdoc/>
public override BoundingBox GetBoundingBox()
{
Expand Down
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
8 changes: 4 additions & 4 deletions src/ACadSharp/Entities/Dimension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public bool IsTextUserDefinedLocation
/// <b>true</b> if the arrow is to be flipped; otherwise, <b>false</b>.
/// </value>
/// <remarks>
/// 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.
/// </remarks>
[DxfCodeValue(74)]
public bool FlipArrow1 { get; set; }
Expand All @@ -142,8 +142,8 @@ public bool IsTextUserDefinedLocation
/// <b>true</b> if the arrow is to be flipped; otherwise, <b>false</b>.
/// </value>
/// <remarks>
/// 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.
/// </remarks>
[DxfCodeValue(75)]
public bool FlipArrow2 { get; set; }
Expand Down
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/DimensionAligned.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/DimensionAngular2Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/DimensionAngular3Pt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/DimensionDiameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/DimensionOrdinate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/DimensionRadius.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
20 changes: 20 additions & 0 deletions src/ACadSharp/Entities/Ellipse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/// <inheritdoc/>
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();
}
}
}
Loading
Loading