/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector3">point</see> in world coordinates of the ordinate dimension.</param> /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Local axis that measures the ordinate dimension.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector3 origin, Vector2 referencePoint, double length, OrdinateDimensionAxis axis, double rotation, DimensionStyle style) : base(DimensionType.Ordinate) { this.origin = origin; this.rotation = MathHelper.NormalizeAngle(rotation); this.length = length; this.referencePoint = referencePoint; this.axis = axis; this.style = style; }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector3">point</see> in world coordinates of the ordinate dimension.</param> /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Local axis that measures the ordinate dimension.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector3 origin, Vector2 referencePoint, double length, OrdinateDimensionAxis axis, double rotation, DimensionStyle style) : base(DimensionType.Ordinate) { this.origin = origin; this.rotation = rotation; this.length = length; this.referencePoint = referencePoint; this.axis = axis; this.style = style; }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector2">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="featurePoint">Base location <see cref="Vector2">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="leaderEndPoint">Leader end <see cref="Vector2">point</see> in local coordinates of the ordinate dimension</param> /// <param name="axis">Length of the dimension line.</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> public OrdinateDimension(Vector2 origin, Vector2 featurePoint, Vector2 leaderEndPoint, OrdinateDimensionAxis axis, DimensionStyle style) : base(DimensionType.Ordinate) { this.defPoint = origin; this.firstPoint = featurePoint; this.secondPoint = leaderEndPoint; this.textRefPoint = leaderEndPoint; this.axis = axis; this.rotation = 0.0; this.Style = style ?? throw new ArgumentNullException(nameof(style)); }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector3">point</see> in world coordinates of the ordinate dimension.</param> /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Local axis that measures the ordinate dimension.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector2 origin, Vector2 referencePoint, double length, OrdinateDimensionAxis axis, double rotation, DimensionStyle style) : base(DimensionType.Ordinate) { this.origin = origin; this.rotation = MathHelper.NormalizeAngle(rotation); this.length = length; this.referencePoint = referencePoint; this.axis = axis; if (style == null) throw new ArgumentNullException(nameof(style)); this.Style = style; }
/// <summary> /// Moves, scales, and/or rotates the current entity given a 3x3 transformation matrix and a translation vector. /// </summary> /// <param name="transformation">Transformation matrix.</param> /// <param name="translation">Translation vector.</param> public override void TransformBy(Matrix3 transformation, Vector3 translation) { Vector2 newStart; Vector2 newEnd; Vector3 newNormal; double newElevation; double newRotation; newNormal = transformation * Normal; Matrix3 transOW = MathHelper.ArbitraryAxis(Normal); Matrix3 transWO = MathHelper.ArbitraryAxis(newNormal).Transpose(); Vector3 axis = transOW * Vector3.UnitX; axis = transformation * axis; axis = transWO * axis; double angle = Vector2.Angle(new Vector2(axis.X, axis.Y)); newRotation = angle * MathHelper.RadToDeg; Vector3 v = transOW * new Vector3(FeaturePoint.X, FeaturePoint.Y, Elevation); v = transformation * v + translation; v = transWO * v; newStart = new Vector2(v.X, v.Y); newElevation = v.Z; v = transOW * new Vector3(LeaderEndPoint.X, LeaderEndPoint.Y, Elevation); v = transformation * v + translation; v = transWO * v; newEnd = new Vector2(v.X, v.Y); v = transOW * new Vector3(textRefPoint.X, textRefPoint.Y, Elevation); v = transformation * v + translation; v = transWO * v; textRefPoint = new Vector2(v.X, v.Y); v = transOW * new Vector3(defPoint.X, defPoint.Y, Elevation); v = transformation * v + translation; v = transWO * v; defPoint = new Vector2(v.X, v.Y); Rotation += newRotation; FeaturePoint = newStart; LeaderEndPoint = newEnd; Elevation = newElevation; Normal = newNormal; }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector3">point</see> in world coordinates of the ordinate dimension.</param> /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Local axis that measures the ordinate dimension.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector2 origin, Vector2 referencePoint, double length, OrdinateDimensionAxis axis, double rotation, DimensionStyle style) : base(DimensionType.Ordinate) { this.origin = origin; this.rotation = MathHelper.NormalizeAngle(rotation); this.length = length; this.referencePoint = referencePoint; this.axis = axis; if (style == null) { throw new ArgumentNullException(nameof(style)); } this.Style = style; }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector2">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="featurePoint">Base location <see cref="Vector2">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="leaderEndPoint">Leader end <see cref="Vector2">point</see> in local coordinates of the ordinate dimension</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> /// <remarks> /// Uses the difference between the feature location and the leader endpoint to determine whether it is an X or a Y ordinate dimension. /// If the difference in the Y ordinate is greater, the dimension measures the X ordinate. Otherwise, it measures the Y ordinate. /// </remarks> public OrdinateDimension(Vector2 origin, Vector2 featurePoint, Vector2 leaderEndPoint, DimensionStyle style) : base(DimensionType.Ordinate) { this.defPoint = origin; this.firstPoint = featurePoint; this.secondPoint = leaderEndPoint; this.textRefPoint = leaderEndPoint; Vector2 vec = leaderEndPoint - featurePoint; this.axis = vec.Y > vec.X ? OrdinateDimensionAxis.X : OrdinateDimensionAxis.Y; this.rotation = 0.0; if (style == null) { throw new ArgumentNullException(nameof(style)); } this.Style = style; }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector3">point</see> in world coordinates of the ordinate dimension.</param> /// <param name="featurePoint">Base location <see cref="Vector2">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Local axis that measures the ordinate dimension.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector2 origin, Vector2 featurePoint, double length, OrdinateDimensionAxis axis, double rotation, DimensionStyle style) : base(DimensionType.Ordinate) { this.defPoint = origin; this.rotation = MathHelper.NormalizeAngle(rotation); this.firstPoint = featurePoint; this.axis = axis; this.Style = style ?? throw new ArgumentNullException(nameof(style)); double angle = rotation * MathHelper.DegToRad; if (this.Axis == OrdinateDimensionAxis.X) { angle += MathHelper.HalfPI; } this.secondPoint = Vector2.Polar(featurePoint, length, angle); this.textRefPoint = this.secondPoint; }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector2">point</see> of the ordinate dimension.</param> /// <param name="featurePoint">Base location <see cref="Vector2">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Length of the dimension line.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector2 origin, Vector2 featurePoint, double length, OrdinateDimensionAxis axis, double rotation) : this(origin, featurePoint, length, axis, rotation, DimensionStyle.Default) { }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector2">point</see> of the ordinate dimension.</param> /// <param name="featurePoint">Base location <see cref="Vector2">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Length of the dimension line.</param> /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector2 origin, Vector2 featurePoint, double length, OrdinateDimensionAxis axis, DimensionStyle style) : this(origin, featurePoint, length, axis, 0.0, style) { }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector3">point</see> of the ordinate dimension.</param> /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Length of the dimension line.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector3 origin, Vector2 referencePoint, double length, double rotation, OrdinateDimensionAxis axis) : this(origin, referencePoint, length, axis, rotation, DimensionStyle.Default) { }
/// <summary> /// Initializes a new instance of the <c>OrdinateDimension</c> class. /// </summary> /// <param name="origin">Origin <see cref="Vector2">point</see> of the ordinate dimension.</param> /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param> /// <param name="length">Length of the dimension line.</param> /// <param name="axis">Length of the dimension line.</param> /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param> /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks> public OrdinateDimension(Vector2 origin, Vector2 referencePoint, double length, double rotation, OrdinateDimensionAxis axis) : this(origin, referencePoint, length, axis, rotation, DimensionStyle.Default) { }
private OrdinateDimension ReadOrdinateDimension(Vector3 defPoint, OrdinateDimensionAxis axis, Vector3 normal, double rotation) { Vector3 firstPoint = Vector3.Zero; Vector3 secondPoint = Vector3.Zero; List<XData> xData = new List<XData>(); while (this.chunk.Code != 0) { switch (this.chunk.Code) { case 13: firstPoint.X = this.chunk.ReadDouble(); this.chunk.Next(); break; case 23: firstPoint.Y = this.chunk.ReadDouble(); this.chunk.Next(); break; case 33: firstPoint.Z = this.chunk.ReadDouble(); this.chunk.Next(); break; case 14: secondPoint.X = this.chunk.ReadDouble(); this.chunk.Next(); break; case 24: secondPoint.Y = this.chunk.ReadDouble(); this.chunk.Next(); break; case 34: secondPoint.Z = this.chunk.ReadDouble(); this.chunk.Next(); break; case 1001: string appId = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString()); XData data = this.ReadXDataRecord(this.GetApplicationRegistry(appId)); xData.Add(data); break; default: if (this.chunk.Code >= 1000 && this.chunk.Code <= 1071) throw new Exception("The extended data of an entity must start with the application registry code."); this.chunk.Next(); break; } } Vector3 localPoint = MathHelper.Transform(defPoint, normal, CoordinateSystem.World, CoordinateSystem.Object); Vector2 refCenter = new Vector2(localPoint.X, localPoint.Y); localPoint = MathHelper.Transform(firstPoint, normal, CoordinateSystem.World, CoordinateSystem.Object); Vector2 firstRef = MathHelper.Transform(new Vector2(localPoint.X, localPoint.Y) - refCenter, rotation*MathHelper.DegToRad, CoordinateSystem.World, CoordinateSystem.Object); localPoint = MathHelper.Transform(secondPoint, normal, CoordinateSystem.World, CoordinateSystem.Object); Vector2 secondRef = MathHelper.Transform(new Vector2(localPoint.X, localPoint.Y) - refCenter, rotation*MathHelper.DegToRad, CoordinateSystem.World, CoordinateSystem.Object); double length = axis == OrdinateDimensionAxis.X ? secondRef.Y - firstRef.Y : secondRef.X - firstRef.X; OrdinateDimension entity = new OrdinateDimension { Origin = refCenter, ReferencePoint = firstRef, Length = length, Rotation = rotation, Axis = axis }; entity.XData.AddRange(xData); return entity; }