Пример #1
0
        /// <summary>
        /// Convert a Nucleus line to a netDXF one
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static nDE.Line Convert(Line line)
        {
            var result = new nDE.Line(Convert(line.StartPoint), Convert(line.EndPoint));

            SetAttributes(result, line.Attributes);
            return(result);
        }
Пример #2
0
        private Line ILineToLine(netDxf.Entities.Line iline, double unit, double scale)
        {
            Point spt = iPointToPoint(iline.StartPoint, unit, scale);
            Point ept = iPointToPoint(iline.EndPoint, unit, scale);

            return(new Line(spt, ept));
        }
Пример #3
0
    void AddLine(netDxf.Entities.Line l)
    {
        var        s    = l.StartPoint;
        var        e    = l.EndPoint;
        LineEntity line = new LineEntity(DetailEditor.instance.currentSketch.GetSketch());

        line.p0.SetPosition(new UnityEngine.Vector3((float)s.X, (float)s.Y, (float)s.Z));
        line.p1.SetPosition(new UnityEngine.Vector3((float)e.X, (float)e.Y, (float)e.Z));
    }
Пример #4
0
        public static LineDXF.Line[] createLines(List <coordinatesVect> CoordinatesDXF, LineDXF.Line[] line, int picHeight)
        {
            for (int i = 0, j = 0; i < CoordinatesDXF.Count /* - 1*/; j++, i = i + 2)        // vytvaram z bodov ciary
            {
                line[j]            = new LineDXF.Line();
                line[j].StartPoint = new Vector3(CoordinatesDXF[i].X, picHeight - CoordinatesDXF[i].Y, 0);
                line[j].EndPoint   = new Vector3(CoordinatesDXF[i + 1].X, picHeight - CoordinatesDXF[i + 1].Y, 0);
            }

            return(line);
        }
Пример #5
0
		/*Draw Line*/
		public static void DrawLine(netDxf.Entities.Line xLine, Canvas mainCanvas)
		{
			double X1 = xLine.StartPoint.X;
			double Y1 = mainCanvas.Height - xLine.StartPoint.Y;
			double X2 = xLine.EndPoint.X;
			double Y2 = mainCanvas.Height - xLine.EndPoint.Y;
			getMaxPt(xLine.StartPoint);
			getMaxPt(xLine.EndPoint);
			System.Windows.Shapes.Line wLine = DrawUtils.GetLine(X1, Y1, X2, Y2);
			TypeConverter.Entity2Shape(xLine, wLine);
			mainCanvas.Children.Add(wLine);
		}
Пример #6
0
        public Line(double x1, double y1, double x2, double y2)
        {
            Length = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
            var tempMin = new Vector3();
            var tempMax = new Vector3();

            tempMin.X = Math.Min(x1, x2);
            tempMax.X = Math.Max(x1, x2);

            tempMin.Y = Math.Min(y1, y2);
            tempMax.Y = Math.Max(y1, y2);
            InputLine = new netDxf.Entities.Line(tempMin, tempMax);
            MinXMinY  = tempMin;
            MaxXMaxY  = tempMax;
        }
Пример #7
0
        public Line(LwPolylineVertex vertex1, LwPolylineVertex vertex2)
        {
            InputLine = new netDxf.Entities.Line(vertex1.Position, vertex2.Position);
            Length    = (InputLine.EndPoint - InputLine.StartPoint).Modulus();
            var tempMin = new Vector3();
            var tempMax = new Vector3();

            tempMin.X = Math.Min(InputLine.StartPoint.X, InputLine.EndPoint.X);
            tempMax.X = Math.Max(InputLine.StartPoint.X, InputLine.EndPoint.X);

            tempMin.Y = Math.Min(InputLine.StartPoint.Y, InputLine.EndPoint.Y);
            tempMax.Y = Math.Max(InputLine.StartPoint.Y, InputLine.EndPoint.Y);

            MinXMinY = tempMin;
            MaxXMaxY = tempMax;
        }
Пример #8
0
        public Line(netDxf.Entities.Line inputLine)
        {
            InputLine = inputLine;
            Length    = (inputLine.EndPoint - inputLine.StartPoint).Modulus();
            var tempMin = new Vector3();
            var tempMax = new Vector3();

            tempMin.X = Math.Min(inputLine.StartPoint.X, inputLine.EndPoint.X);
            tempMax.X = Math.Max(inputLine.StartPoint.X, inputLine.EndPoint.X);

            tempMin.Y = Math.Min(inputLine.StartPoint.Y, inputLine.EndPoint.Y);
            tempMax.Y = Math.Max(inputLine.StartPoint.Y, inputLine.EndPoint.Y);

            MinXMinY = tempMin;
            MaxXMaxY = tempMax;
        }
Пример #9
0
        // convert list of points to a polyline
        private static IEnumerable <EntityObject> getPolylineFromPoints(List <MWPoint2D> points, Layer layer, bool close = true)
        {
            int n = close ? points.Count : points.Count - 1;

            for (int i = 0; i < n; i++)
            {
                int k       = i == points.Count - 1 ? 0 : i + 1;
                var dxfLine = new netDxf.Entities.Line(
                    new netDxf.Vector2(points[i].X * 1e3, points[i].Y * 1e3),
                    new netDxf.Vector2(points[k].X * 1e3, points[k].Y * 1e3))
                {
                    Layer = layer
                };
                yield return(dxfLine);
            }
        }
Пример #10
0
        public static void CreateDxfFile(string path, List <int[]> elements, Dictionary <int, double[]> points)
        {
            DxfDocument doc         = new DxfDocument(DxfVersion.AutoCad2010);
            Layer       layerShells = new Layer("SHELLS");
            Layer       layerFrames = new Layer("FRAMES");

            foreach (int[] element in elements)
            {
                double[] firstNode    = points[element[0]];
                double[] secondNode   = points[element[1]];
                Vector3  firstVertex  = new Vector3(firstNode[0], firstNode[1], firstNode[2]);
                Vector3  secondVertex = new Vector3(secondNode[0], secondNode[1], secondNode[2]);

                if (element.Length == 2) // LINE
                {
                    Line line = new Line(firstVertex, secondVertex)
                    {
                        Layer = layerFrames
                    };
                    doc.AddEntity(line);
                }
                else
                {
                    double[] thirdNode  = points[element[2]];
                    double[] fourthNode = element.Length == 4
                        ? points[element[3]]
                        : points[element[0]];

                    Face3d face = new Face3d
                    {
                        FirstVertex  = firstVertex,
                        SecondVertex = secondVertex,
                        ThirdVertex  = new Vector3(thirdNode[0], thirdNode[1], thirdNode[2]),
                        FourthVertex = new Vector3(fourthNode[0], fourthNode[1], fourthNode[2]),
                        Layer        = layerShells,
                    };

                    doc.AddEntity(face);
                }
            }

            File.Delete(path);
            doc.Save(path);
        }
Пример #11
0
        private System.Windows.Shapes.Line GetCanvasLine(netDxf.Entities.Line line, Vector3 StartVector,
                                                         double canvasHeight)
        {
            var tempLine = new System.Windows.Shapes.Line();

            tempLine.X1 = line.StartPoint.X - StartVector.X;
            tempLine.Y1 = -line.StartPoint.Y + StartVector.Y;
            tempLine.X2 = line.EndPoint.X - StartVector.X;
            tempLine.Y2 = -line.EndPoint.Y + StartVector.Y;

            tempLine.X1 = tempLine.X1;
            tempLine.Y1 = tempLine.Y1 + canvasHeight;
            tempLine.X2 = tempLine.X2;
            tempLine.Y2 = tempLine.Y2 + canvasHeight;

            tempLine.Stroke          = Brushes.Black;
            tempLine.StrokeThickness = 1;
            return(tempLine);
        }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <c>AlignedDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public AlignedDimension(Line referenceLine, double offset, DimensionStyle style)
     : this(referenceLine, offset, Vector3.UnitZ, style)
 {
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <c>AlignedDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public AlignedDimension(Line referenceLine, double offset)
     : this(referenceLine, offset, Vector3.UnitZ, DimensionStyle.Default)
 {
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <c>LinearDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="rotation">Rotation in degrees of the dimension line.</param>
 /// <param name="normal">Normal vector of the plane where the dimension is defined.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public LinearDimension(Line referenceLine, double offset, double rotation, Vector3 normal)
     : this(referenceLine, offset, rotation, normal, DimensionStyle.Default)
 {
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <c>LinearDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="rotation">Rotation in degrees of the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public LinearDimension(Line referenceLine, double offset, double rotation, DimensionStyle style)
     : this(referenceLine, offset, rotation, Vector3.UnitZ, style)
 {
 }
Пример #16
0
 public static Line3D ToLine3D(this netDxf.Entities.Line line)
 {
     return(new Line3D(line.StartPoint, line.EndPoint));
 }
Пример #17
0
        /// <summary>
        /// Gets the the block that contains the entities that make up the dimension picture.
        /// </summary>
        /// <param name="name">Name to be asigned to the generated block.</param>
        /// <returns>The block that represents the actual dimension.</returns>
        internal override Block BuildBlock(string name)
        {
            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 refPoint = MathHelper.Transform(this.start, this.normal,
                                                    MathHelper.CoordinateSystem.World,
                                                    MathHelper.CoordinateSystem.Object);

            Vector2 firstRef = new Vector2(refPoint.X, refPoint.Y);

            refPoint = MathHelper.Transform(this.end, this.normal,
                                            MathHelper.CoordinateSystem.World,
                                            MathHelper.CoordinateSystem.Object);

            Vector2 secondRef = new Vector2(refPoint.X, refPoint.Y);

            double measurement = this.Value;
            double dimRot      = this.rotation * MathHelper.DegToRad;
            double elev        = refPoint.Z;

            Vector2 midRef = Vector2.MidPoint(firstRef, secondRef);

            Vector2 midDimLine = Vector2.Polar(midRef, this.offset, dimRot + MathHelper.HalfPI);


            Vector2 startDimLine = Vector2.Polar(midDimLine, measurement * 0.5, dimRot + MathHelper.PI);
            Vector2 endDimLine   = Vector2.Polar(midDimLine, measurement * 0.5, dimRot);

            // reference points
            Layer defPoints = new Layer("Defpoints")
            {
                Plot = false
            };
            Point startRef = new Point(firstRef)
            {
                Layer = defPoints
            };
            Point endRef = new Point(secondRef)
            {
                Layer = defPoints
            };
            Point defPoint = new Point(endDimLine)
            {
                Layer = defPoints
            };

            // dimension lines
            Line startBorder = new Line(Vector2.Polar(firstRef, this.style.DIMEXO, dimRot + MathHelper.HalfPI),
                                        Vector2.Polar(startDimLine, this.style.DIMEXE, dimRot + MathHelper.HalfPI));

            Line endBorder = new Line(Vector2.Polar(secondRef, this.style.DIMEXO, dimRot + MathHelper.HalfPI),
                                      Vector2.Polar(endDimLine, this.style.DIMEXE, dimRot + MathHelper.HalfPI));

            Line dimLine = new Line(startDimLine, endDimLine);

            this.definitionPoint = MathHelper.Transform(new Vector3(endDimLine.X, endDimLine.Y, elev), this.normal,
                                                        MathHelper.CoordinateSystem.Object,
                                                        MathHelper.CoordinateSystem.World);


            // dimension arrows
            Vector2 arrowRefBegin = Vector2.Polar(startDimLine, this.style.DIMASZ, dimRot);
            Solid   arrowBegin    = new Solid(startDimLine,
                                              Vector2.Polar(arrowRefBegin, -this.style.DIMASZ / 6, dimRot + MathHelper.HalfPI),
                                              Vector2.Polar(arrowRefBegin, this.style.DIMASZ / 6, dimRot + MathHelper.HalfPI),
                                              startDimLine);

            Vector2 arrowRefEnd = Vector2.Polar(endDimLine, -this.style.DIMASZ, dimRot);
            Solid   arrowEnd    = new Solid(endDimLine,
                                            Vector2.Polar(arrowRefEnd, this.style.DIMASZ / 6, dimRot + MathHelper.HalfPI),
                                            Vector2.Polar(arrowRefEnd, -this.style.DIMASZ / 6, dimRot + MathHelper.HalfPI),
                                            endDimLine);

            // dimension text
            this.midTextPoint = new Vector3(midDimLine.X, midDimLine.Y, elev); // this value is in OCS
            MText text = new MText(this.FormatDimensionText(this.Value),
                                   Vector2.Polar(midDimLine, this.style.DIMGAP, dimRot + MathHelper.HalfPI),
                                   this.style.DIMTXT, 0.0, this.style.TextStyle)
            {
                AttachmentPoint = MTextAttachmentPoint.BottomCenter,
                Rotation        = this.rotation
            };

            // drawing block
            Block dim = new Block(name, false);

            dim.Entities.Add(startRef);
            dim.Entities.Add(endRef);
            dim.Entities.Add(defPoint);
            dim.Entities.Add(startBorder);
            dim.Entities.Add(endBorder);
            dim.Entities.Add(dimLine);
            dim.Entities.Add(arrowBegin);
            dim.Entities.Add(arrowEnd);
            dim.Entities.Add(text);
            this.block = dim;
            return(dim);
        }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <c>AlignedDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="normal">Normal vector of the plane where the dimension is defined.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public AlignedDimension(Line referenceLine, double offset, Vector3 normal)
     : this(referenceLine, offset, normal, DimensionStyle.Default)
 {
 }
Пример #19
0
        private void SetInternalInfo(IEnumerable <EntityObject> contourn, bool clearEdges)
        {
            bool containsPolyline = false;

            if (clearEdges)
            {
                this.edges.Clear();
            }

            foreach (EntityObject entity in contourn)
            {
                if (containsPolyline)
                {
                    throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                }

                // it seems that AutoCad does not have problems on creating loops that theoretically does not make sense,
                // like, for example, an internal loop that is made of a single arc.
                // so if AutoCAD is OK with that I am too, the program that make use of this information will take care of this inconsistencies
                switch (entity.Type)
                {
                case EntityType.Arc:
                    this.edges.Add(Arc.ConvertFrom(entity));
                    break;

                case EntityType.Circle:
                    this.edges.Add(Arc.ConvertFrom(entity));
                    break;

                case EntityType.Ellipse:
                    this.edges.Add(Ellipse.ConvertFrom(entity));
                    break;

                case EntityType.Line:
                    this.edges.Add(Line.ConvertFrom(entity));
                    break;

                case EntityType.LwPolyline:
                    Entities.LwPolyline lwpoly = (Entities.LwPolyline)entity;
                    if (lwpoly.IsClosed)
                    {
                        if (this.edges.Count != 0)
                        {
                            throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                        }
                        this.edges.Add(Polyline.ConvertFrom(entity));
                        this.pathType   |= HatchBoundaryPathTypeFlags.Polyline;
                        containsPolyline = true;
                    }
                    else
                    {
                        this.SetInternalInfo(lwpoly.Explode(), false);     // open polylines will always be exploded, only one polyline can be present in a path
                    }
                    break;

                case EntityType.Polyline:
                    Entities.Polyline poly = (Entities.Polyline)entity;
                    if (poly.IsClosed)
                    {
                        if (this.edges.Count != 0)
                        {
                            throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                        }
                        this.edges.Add(Polyline.ConvertFrom(entity));
                        this.pathType   |= HatchBoundaryPathTypeFlags.Polyline;
                        containsPolyline = true;
                    }
                    else
                    {
                        this.SetInternalInfo(poly.Explode(), false);     // open polylines will always be exploded, only one polyline can be present in a path
                    }
                    break;

                case EntityType.Spline:
                    this.edges.Add(Spline.ConvertFrom(entity));
                    break;

                default:
                    throw new ArgumentException(string.Format("The entity type {0} cannot be part of a hatch boundary. Only Arc, Circle, Ellipse, Line, LwPolyline, and Spline entities are allowed.", entity.Type));
                }
            }
        }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <c>Angular2LineDimension</c> class.
 /// </summary>
 /// <param name="firstLine">First <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="secondLine">Second <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="offset">Distance between the center point and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 public Angular2LineDimension(Line firstLine, Line secondLine, double offset, DimensionStyle style)
     : this(firstLine, secondLine, offset, Vector3.UnitZ, style)
 {
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <c>Angular2LineDimension</c> class.
 /// </summary>
 /// <param name="firstLine">First <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="secondLine">Second <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="offset">Distance between the center point and the dimension line.</param>
 /// <param name="normal">Normal vector of the plane where the dimension is defined.</param>
 public Angular2LineDimension(Line firstLine, Line secondLine, double offset, Vector3 normal)
     : this(firstLine, secondLine, offset, normal, DimensionStyle.Default)
 {
 }
        /// <summary>
        /// Decompose the actual polyface mesh faces in <see cref="Point">points</see> (one vertex polyface mesh face),
        /// <see cref="Line">lines</see> (two vertexes polyface mesh face) and <see cref="Face3d">3d faces</see> (three or four vertexes polyface mesh face).
        /// </summary>
        /// <returns>A list of <see cref="Face3d">3d faces</see> that made up the polyface mesh.</returns>
        public List <EntityObject> Explode()
        {
            List <EntityObject> entities = new List <EntityObject>();

            foreach (PolyfaceMeshFace face in this.Faces)
            {
                if (face.VertexIndexes.Length == 1)
                {
                    Point point = new Point
                    {
                        Location      = this.Vertexes[Math.Abs(face.VertexIndexes[0]) - 1].Location,
                        Color         = this.Color,
                        IsVisible     = this.IsVisible,
                        Layer         = this.Layer,
                        LineType      = this.LineType,
                        LineTypeScale = this.LineTypeScale,
                        Lineweight    = this.Lineweight,
                        XData         = this.XData
                    };
                    entities.Add(point);
                    continue;
                }
                if (face.VertexIndexes.Length == 2)
                {
                    Line line = new Line
                    {
                        StartPoint    = this.Vertexes[Math.Abs(face.VertexIndexes[0]) - 1].Location,
                        EndPoint      = this.Vertexes[Math.Abs(face.VertexIndexes[1]) - 1].Location,
                        Color         = this.Color,
                        IsVisible     = this.IsVisible,
                        Layer         = this.Layer,
                        LineType      = this.LineType,
                        LineTypeScale = this.LineTypeScale,
                        Lineweight    = this.Lineweight,
                        XData         = this.XData
                    };
                    entities.Add(line);
                    continue;
                }

                EdgeFlags edgeVisibility = EdgeFlags.Visibles;

                int indexV1 = face.VertexIndexes[0];
                int indexV2 = face.VertexIndexes[1];
                int indexV3 = face.VertexIndexes[2];
                // Polyface mesh faces are made of 3 or 4 vertexes, we will repeat the third vertex if the face vertexes is three
                int indexV4 = face.VertexIndexes.Length == 3 ? face.VertexIndexes[2] : face.VertexIndexes[3];

                if (indexV1 < 0)
                {
                    edgeVisibility = edgeVisibility | EdgeFlags.First;
                }
                if (indexV2 < 0)
                {
                    edgeVisibility = edgeVisibility | EdgeFlags.Second;
                }
                if (indexV3 < 0)
                {
                    edgeVisibility = edgeVisibility | EdgeFlags.Third;
                }
                if (indexV4 < 0)
                {
                    edgeVisibility = edgeVisibility | EdgeFlags.Fourth;
                }

                Vector3 v1 = this.Vertexes[Math.Abs(indexV1) - 1].Location;
                Vector3 v2 = this.Vertexes[Math.Abs(indexV2) - 1].Location;
                Vector3 v3 = this.Vertexes[Math.Abs(indexV3) - 1].Location;
                Vector3 v4 = this.Vertexes[Math.Abs(indexV4) - 1].Location;

                Face3d face3d = new Face3d
                {
                    FirstVertex   = v1,
                    SecondVertex  = v2,
                    ThirdVertex   = v3,
                    FourthVertex  = v4,
                    EdgeFlags     = edgeVisibility,
                    Color         = this.Color,
                    IsVisible     = this.IsVisible,
                    Layer         = this.Layer,
                    LineType      = this.LineType,
                    LineTypeScale = this.LineTypeScale,
                    Lineweight    = this.Lineweight,
                    XData         = this.XData
                };

                entities.Add(face3d);
            }
            return(entities);
        }
Пример #23
0
 /// <summary>
 /// Initializes a new instance of the <c>LinearDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="rotation">Rotation in degrees of the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The reference line define the distance to be measure.</remarks>
 public LinearDimension(Line referenceLine, double offset, double rotation, DimensionStyle style)
     : this(referenceLine.StartPoint, referenceLine.EndPoint, offset, rotation, style)
 {
     this.normal = referenceLine.Normal;
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <c>LinearDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="rotation">Rotation in degrees of the dimension line.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public LinearDimension(Line referenceLine, double offset, double rotation)
     : this(referenceLine, offset, rotation, DimensionStyle.Default)
 {
 }
Пример #25
0
 /// <summary>
 /// Convert a netDXF Line to a Nucleus one
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public static Line Convert(netDxf.Entities.Line line)
 {
     return(new Line(Convert(line.StartPoint), Convert(line.EndPoint), ExtractAttributes(line)));
 }
Пример #26
0
        /// <summary>
        /// Creates a new Line that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Line that is a copy of this instance.</returns>
        public override object Clone()
        {
            Line entity = new Line
            {
                //EntityObject properties
                Layer = (Layer)this.layer.Clone(),
                LineType = (LineType)this.lineType.Clone(),
                Color = (AciColor)this.color.Clone(),
                Lineweight = (Lineweight)this.lineweight.Clone(),
                Transparency = (Transparency)this.transparency.Clone(),
                LineTypeScale = this.lineTypeScale,
                Normal = this.normal,
                //Line properties
                StartPoint = this.start,
                EndPoint = this.end,
                Thickness = this.thickness,
            };

            foreach (XData data in this.XData.Values)
                entity.XData.Add((XData)data.Clone());

            return entity;

        }
Пример #27
0
        /// <summary>
        /// Gets the the block that contains the entities that make up the dimension picture.
        /// </summary>
        /// <param name="name">Name to be asigned to the generated block.</param>
        /// <returns>The block that represents the actual dimension.</returns>
        internal override Block BuildBlock(string name)
        {
            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 refPoint = MathHelper.Transform(this.center, this.normal,
                                                    MathHelper.CoordinateSystem.World,
                                                    MathHelper.CoordinateSystem.Object);

            Vector2 centerRef = new Vector2(refPoint.X, refPoint.Y);

            double elev        = refPoint.Z;
            double refRotation = this.rotation * MathHelper.DegToRad;

            Vector2 firstRef = Vector2.Polar(centerRef, this.diameter * 0.5, refRotation);

            this.definitionPoint = MathHelper.Transform(new Vector3(firstRef.X, firstRef.Y, elev), this.normal,
                                                        MathHelper.CoordinateSystem.Object,
                                                        MathHelper.CoordinateSystem.World);

            Vector2 secondRef = Vector2.Polar(centerRef, -this.diameter * 0.5, refRotation);

            this.circunferenceRef = MathHelper.Transform(new Vector3(secondRef.X, secondRef.Y, elev), this.normal,
                                                         MathHelper.CoordinateSystem.Object,
                                                         MathHelper.CoordinateSystem.World);
            // reference points
            Layer defPoints = new Layer("Defpoints")
            {
                Plot = false
            };
            Point startRef = new Point(firstRef)
            {
                Layer = defPoints
            };
            Point endRef = new Point(secondRef)
            {
                Layer = defPoints
            };

            // dimension lines
            Line dimLine = new Line(firstRef, secondRef);

            // center cross
            double  dist       = Math.Abs(this.style.DIMCEN);
            Vector2 c1         = new Vector2(0, -dist) + centerRef;
            Vector2 c2         = new Vector2(0, dist) + centerRef;
            Line    crossLine1 = new Line(c1, c2);

            c1 = new Vector2(-dist, 0) + centerRef;
            c2 = new Vector2(dist, 0) + centerRef;
            Line crossLine2 = new Line(c1, c2);

            // dimension arrows
            Vector2 arrowRef1 = Vector2.Polar(secondRef, this.style.DIMASZ, refRotation);
            Solid   arrow1    = new Solid(secondRef,
                                          Vector2.Polar(arrowRef1, -this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                          Vector2.Polar(arrowRef1, this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                          secondRef);
            Vector2 arrowRef2 = Vector2.Polar(firstRef, -this.style.DIMASZ, refRotation);
            Solid   arrow2    = new Solid(firstRef,
                                          Vector2.Polar(arrowRef2, this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                          Vector2.Polar(arrowRef2, -this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                          firstRef);

            // dimension text
            this.midTextPoint = new Vector3(centerRef.X, centerRef.Y, elev); // this value is in OCS
            MText text = new MText(this.FormatDimensionText(this.Value),
                                   Vector2.Polar(centerRef, this.style.DIMGAP, refRotation + MathHelper.HalfPI),
                                   this.style.DIMTXT, 0.0, this.style.TextStyle)
            {
                AttachmentPoint = MTextAttachmentPoint.BottomCenter,
                Rotation        = refRotation * MathHelper.RadToDeg
            };

            Block dim = new Block(name, false);

            dim.Entities.Add(startRef);
            dim.Entities.Add(endRef);
            dim.Entities.Add(dimLine);
            dim.Entities.Add(crossLine1);
            dim.Entities.Add(crossLine2);
            dim.Entities.Add(arrow1);
            dim.Entities.Add(arrow2);
            dim.Entities.Add(text);
            this.block = dim;
            return(dim);
        }
Пример #28
0
        /// <summary>
        /// Gets the the block that contains the entities that make up the dimension picture.
        /// </summary>
        /// <param name="name">Name to be asigned to the generated block.</param>
        /// <returns>The block that represents the actual dimension.</returns>
        internal override Block BuildBlock(string name)
        {
            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 localPoint = MathHelper.Transform(this.center, this.normal, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object);
            Vector2 refCenter  = new Vector2(localPoint.X, localPoint.Y);

            localPoint = MathHelper.Transform(this.start, this.normal, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object);
            Vector2 refStart = new Vector2(localPoint.X, localPoint.Y);

            localPoint = MathHelper.Transform(this.end, this.normal, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object);
            Vector2 refEnd = new Vector2(localPoint.X, localPoint.Y);

            double elev = localPoint.Z;

            // reference points
            Layer defPoints = new Layer("Defpoints")
            {
                Plot = false
            };
            Point startRef = new Point(refStart)
            {
                Layer = defPoints
            };
            Point endRef = new Point(refEnd)
            {
                Layer = defPoints
            };
            Point centerPoint = new Point(refCenter)
            {
                Layer = defPoints
            };

            // dimension lines
            double startAngle = Vector2.Angle(refCenter, refStart);
            double endAngle   = Vector2.Angle(refCenter, refEnd);

            Vector2 startArc    = Vector2.Polar(refCenter, this.offset, startAngle);
            Line    startBorder = new Line(Vector2.Polar(refStart, this.style.DIMEXO, startAngle),
                                           Vector2.Polar(startArc, this.style.DIMEXE, startAngle));

            Vector2 endArc    = Vector2.Polar(refCenter, this.offset, endAngle);
            Line    endBorder = new Line(Vector2.Polar(refEnd, this.style.DIMEXO, endAngle),
                                         Vector2.Polar(endArc, this.style.DIMEXE, endAngle));

            Arc dimArc = new Arc(refCenter, this.offset, startAngle * MathHelper.RadToDeg, endAngle * MathHelper.RadToDeg);


            // dimension arrows
            Vector2 arrowRefBegin = Vector2.Polar(startArc, this.style.DIMASZ, startAngle + MathHelper.HalfPI);
            Solid   arrowBegin    = new Solid(startArc,
                                              Vector2.Polar(arrowRefBegin, -this.style.DIMASZ / 6, startAngle),
                                              Vector2.Polar(arrowRefBegin, this.style.DIMASZ / 6, startAngle),
                                              startArc);

            Vector2 arrowRefEnd = Vector2.Polar(endArc, -this.style.DIMASZ, endAngle + MathHelper.HalfPI);
            Solid   arrowEnd    = new Solid(endArc,
                                            Vector2.Polar(arrowRefEnd, this.style.DIMASZ / 6, endAngle),
                                            Vector2.Polar(arrowRefEnd, -this.style.DIMASZ / 6, endAngle),
                                            endArc);

            // dimension text
            double  aperture = this.Value;
            double  rotText  = Vector2.Angle(endArc, startArc);
            Vector2 midText  = Vector2.Polar(refCenter, this.offset + this.style.DIMGAP, startAngle + aperture * MathHelper.DegToRad * 0.5);

            this.definitionPoint = MathHelper.Transform(new Vector3(midText.X, midText.Y, elev), this.normal,
                                                        MathHelper.CoordinateSystem.Object,
                                                        MathHelper.CoordinateSystem.World);

            this.midTextPoint = new Vector3(midText.X, midText.Y, elev); // this value is in OCS

            MText text = new MText(this.FormatDimensionText(aperture),
                                   this.midTextPoint,
                                   this.style.DIMTXT, 0.0, this.style.TextStyle)
            {
                AttachmentPoint = MTextAttachmentPoint.BottomCenter,
                Rotation        = rotText * MathHelper.RadToDeg
            };

            // drawing block
            Block dim = new Block(name, false);

            dim.Entities.Add(startRef);
            dim.Entities.Add(endRef);
            dim.Entities.Add(centerPoint);
            dim.Entities.Add(startBorder);
            dim.Entities.Add(endBorder);
            dim.Entities.Add(dimArc);
            dim.Entities.Add(arrowBegin);
            dim.Entities.Add(arrowEnd);
            dim.Entities.Add(text);
            this.block = dim;
            return(dim);
        }