示例#1
0
 public DXFPolyline(DXFData aData, int aIndex) : base(aData)
 {
     if (aData.count > 0 && aIndex < aData.count)
     {
         this.Clear();
         this.data.count = this.data.points.Count;
         ArrayList arrayLists = new ArrayList();
         for (int i = 0; i < ((ArrayList)aData.points[aIndex]).Count; i++)
         {
             DXFPoint item = (DXFPoint)((ArrayList)aData.points[aIndex])[i];
             if (item.X < this.data.point.X)
             {
                 this.data.point.X = item.X;
             }
             if (item.Y < this.data.point.Y)
             {
                 this.data.point.Y = item.Y;
             }
             if (item.X > this.data.point1.X)
             {
                 this.data.point1.X = item.X;
             }
             if (item.Y > this.data.point1.Y)
             {
                 this.data.point1.Y = item.Y;
             }
             this.Points.Add(item);
         }
     }
 }
示例#2
0
        public override void ExportAsDXF(DXFExport ADXFExport)
        {
            DXFPoint dXFPoint = new DXFPoint();

            if ((this.boundaries != null || this.boundaryType != HatchBoundaryType.hbtPolyPolyline) &&
                (this.boundaries.Count != 0 || this.boundaryType != HatchBoundaryType.hbtPolyPolyline))
            {
                dXFPoint.X = 0f;
                dXFPoint.Y = 0f;
                float aDXFExport = 0.05f;
                if (!DXFExport.use01MM)
                {
                    aDXFExport = aDXFExport * ADXFExport.fOffset;
                }
                ADXFExport.AddName(DXFTables.sHatchEntity, "AcDbHatch");
                ADXFExport.AddColor(this.data);
                ADXFExport.Add3DPoint(10, dXFPoint);
                ADXFExport.AddFloat(30, 0f);
                ADXFExport.AddFloat(210, 0f);
                ADXFExport.AddFloat(220, 0f);
                ADXFExport.AddFloat(230, 1f);
                ADXFExport.AddString(2, this.patternName);
                ADXFExport.AddInt(70, this.data.flags);
                ADXFExport.AddInt(71, 0);
                this.AddBoundaryPathData(ADXFExport);
                ADXFExport.AddInt(75, 0);
                ADXFExport.AddInt(76, 1);
                if (this.data.flags == 0)
                {
                    this.AddPatternData(aDXFExport, ADXFExport);
                }
                ADXFExport.AddInt(98, 1);
                ADXFExport.AddPoint(10, dXFPoint);
            }
        }
示例#3
0
        public override void ParseToLines(ArrayList NewElemes)
        {
            float    single;
            float    single1;
            DXFPoint dXFPoint = new DXFPoint();
            DXFLine  dXFLine  = new DXFLine();
            float    x        = this.data.point.X;
            float    y        = this.data.point.Y;

            if (this.ellipse)
            {
                single  = Math.Abs(this.data.point1.X);
                single1 = Math.Abs(this.data.point1.Y);
                if (single == 0f)
                {
                    single = single1 * this.data.radius;
                }
                if (single1 == 0f)
                {
                    single1 = single * this.data.radius;
                }
            }
            else
            {
                single  = this.data.radius;
                single1 = single;
            }
            float single2 = this.data.startAngle * 3.141593f / 180f;
            float single3 = this.data.endAngle * 3.141593f / 180f;
            int   num     = (int)Math.Round((double)((single3 - single2) / 3.141593f * 16f));

            if (num < 4)
            {
                num = 4;
            }
            float single4 = (single3 - single2) / (float)(num - 1);

            for (int i = 0; i < num - 2; i++)
            {
                dXFLine.Layer = base.Layer;
                float single5 = (float)Math.Sin((double)single2);
                float single6 = (float)Math.Cos((double)single2);
                dXFPoint.X         = x + single * single6;
                dXFPoint.Y         = y + single1 * single5;
                dXFLine.StartPoint = (DXFPoint)dXFPoint.Clone();
                single2            = single2 + single4;
                single5            = (float)Math.Sin((double)single2);
                single6            = (float)Math.Cos((double)single2);
                dXFPoint.X         = x + single * single6;
                dXFPoint.Y         = y + single1 * single5;
                dXFLine.EndPoint   = (DXFPoint)dXFPoint.Clone();
                NewElemes.Add(dXFLine.Clone());
            }
        }
示例#4
0
文件: DXFData.cs 项目: secondii/Yutai
 public DXFData()
 {
     this.text   = "";
     this.point  = new DXFPoint();
     this.point1 = new DXFPoint();
     this.point2 = new DXFPoint();
     this.point3 = new DXFPoint();
     this.scale  = new DXFPoint();
     this.points = new ArrayList();
     this.name   = "";
 }
示例#5
0
        public void ParseToTexts(Rect aRect, ArrayList NewElemes)
        {
            int     num;
            float   x;
            string  pourStr  = "";
            string  str      = "";
            string  str1     = "";
            DXFData dXFDatum = new DXFData();

            if (this.data.rotation == 0f)
            {
                dXFDatum = (DXFData)this.data.Clone();
                if ((float)aRect.X1 > dXFDatum.point.X)
                {
                    pourStr = DXFExport.GetPourStr(dXFDatum.text);
                    str1    = dXFDatum.text.Substring(0, dXFDatum.text.Length - pourStr.Length);
                    num     =
                        (int)
                        Math.Round(
                            (double)((float)pourStr.Length * (((float)aRect.X1 - dXFDatum.point.X) / dXFDatum.rWidth)));
                    for (int i = 0; i < num; i++)
                    {
                        str = string.Concat(str, pourStr[i]);
                    }
                    pourStr         = string.Concat(str1, str);
                    dXFDatum.rWidth = this.data.rWidth * (float)num / (float)pourStr.Length;
                    dXFDatum.text   = pourStr;
                    NewElemes.Add(new DXFMText(dXFDatum));
                }
                dXFDatum = (DXFData)this.data.Clone();
                str      = "";
                if ((float)aRect.X2 < dXFDatum.point.X + dXFDatum.rWidth)
                {
                    pourStr = DXFExport.GetPourStr(dXFDatum.text);
                    str1    = dXFDatum.text.Substring(0, dXFDatum.text.Length - pourStr.Length);
                    x       = (dXFDatum.point.X + dXFDatum.rWidth - (float)aRect.X2) / dXFDatum.rWidth;
                    num     = (int)Math.Round((double)((float)pourStr.Length * x));
                    DXFPoint dXFPoint = dXFDatum.point;
                    dXFPoint.X = dXFPoint.X + (dXFDatum.rWidth - dXFDatum.rWidth * x);
                    for (int j = pourStr.Length; j < pourStr.Length - num + 1; j--)
                    {
                        str = string.Concat(pourStr[j], str);
                    }
                    pourStr         = string.Concat(str1, str);
                    dXFDatum.rWidth = dXFDatum.rWidth * (float)num / (float)pourStr.Length;
                    dXFDatum.text   = pourStr;
                    NewElemes.Add(new DXFMText(dXFDatum));
                }
            }
            if (this.data.rotation == 90f)
            {
                dXFDatum = (DXFData)this.data.Clone();
                if ((float)aRect.X1 > dXFDatum.point.X)
                {
                    pourStr = DXFExport.GetPourStr(dXFDatum.text);
                    str1    = dXFDatum.text.Substring(0, dXFDatum.text.Length - pourStr.Length);
                    num     =
                        (int)
                        Math.Round(
                            (double)((float)pourStr.Length * (((float)aRect.X1 - dXFDatum.point.X) / dXFDatum.rWidth)));
                    for (int k = 0; k < num; k++)
                    {
                        str = string.Concat(str, pourStr[k]);
                    }
                    pourStr         = string.Concat(str1, str);
                    dXFDatum.rWidth = dXFDatum.rWidth * (float)num / (float)pourStr.Length;
                    dXFDatum.text   = pourStr;
                    NewElemes.Add(new DXFMText(dXFDatum));
                }
                dXFDatum = (DXFData)this.data.Clone();
                str      = "";
                if ((float)aRect.X2 < dXFDatum.point.X + dXFDatum.rWidth)
                {
                    pourStr = DXFExport.GetPourStr(dXFDatum.text);
                    str1    = dXFDatum.text.Substring(0, dXFDatum.text.Length - pourStr.Length);
                    x       = (dXFDatum.point.X + dXFDatum.rWidth - (float)aRect.X2) / dXFDatum.rWidth;
                    num     = (int)Math.Round((double)((float)pourStr.Length * x));
                    DXFPoint x1 = dXFDatum.point;
                    x1.X = x1.X + (dXFDatum.rWidth - dXFDatum.rWidth * x);
                    DXFPoint y = dXFDatum.point;
                    y.Y = y.Y + (dXFDatum.rWidth - dXFDatum.rWidth * x);
                    for (int l = pourStr.Length; l < pourStr.Length - num + 1; l--)
                    {
                        str = string.Concat(pourStr[l], str);
                    }
                    pourStr         = string.Concat(str1, str);
                    dXFDatum.rWidth = dXFDatum.rWidth * (float)num / (float)pourStr.Length;
                    dXFDatum.text   = pourStr;
                    NewElemes.Add(new DXFMText(dXFDatum));
                }
            }
            if (this.data.rotation == 270f)
            {
                dXFDatum = (DXFData)this.data.Clone();
                if ((float)aRect.Y2 < dXFDatum.point.Y)
                {
                    pourStr = DXFExport.GetPourStr(dXFDatum.text);
                    str1    = dXFDatum.text.Substring(0, dXFDatum.text.Length - pourStr.Length);
                    num     =
                        (int)
                        Math.Round(
                            (double)((float)pourStr.Length * ((dXFDatum.point.Y - (float)aRect.Y2) / dXFDatum.rWidth)));
                    for (int m = 0; m < num; m++)
                    {
                        str = string.Concat(str, pourStr[m]);
                    }
                    dXFDatum.rWidth = dXFDatum.rWidth * (float)num / (float)pourStr.Length;
                    pourStr         = string.Concat(str1, str);
                    dXFDatum.text   = pourStr;
                    NewElemes.Add(new DXFMText(dXFDatum));
                }
                dXFDatum = this.data;
                str      = "";
                if ((float)aRect.Y1 > dXFDatum.point.Y - dXFDatum.rWidth)
                {
                    pourStr = DXFExport.GetPourStr(dXFDatum.text);
                    str1    = dXFDatum.text.Substring(0, dXFDatum.text.Length - pourStr.Length);
                    x       = (dXFDatum.rWidth - dXFDatum.point.Y + (float)aRect.Y1) / dXFDatum.rWidth;
                    num     = (int)Math.Round((double)((float)pourStr.Length * x));
                    DXFPoint y1 = dXFDatum.point;
                    y1.Y = y1.Y - (dXFDatum.rWidth - dXFDatum.rWidth * x);
                    for (int n = pourStr.Length; n < pourStr.Length - num + 1; n--)
                    {
                        str = string.Concat(pourStr[n], str);
                    }
                    dXFDatum.rWidth = dXFDatum.rWidth * (float)num / (float)pourStr.Length;
                    pourStr         = string.Concat(str1, str);
                    dXFDatum.text   = pourStr;
                    NewElemes.Add(new DXFMText(dXFDatum));
                }
            }
        }
示例#6
0
        public void AddRect(Rectangle aRect)
        {
            int k;

            if (this.PointCount == 0)
            {
                this.Clear();
                ArrayList arrayLists = new ArrayList();
                DXFPoint  dXFPoint   = new DXFPoint()
                {
                    X = (float)aRect.Left,
                    Y = (float)aRect.Top
                };
                arrayLists.Add(dXFPoint);
                dXFPoint.X = (float)aRect.Right;
                dXFPoint.Y = (float)aRect.Top;
                arrayLists.Add(dXFPoint);
                dXFPoint.X = (float)aRect.Right;
                dXFPoint.Y = (float)aRect.Bottom;
                arrayLists.Add(dXFPoint);
                dXFPoint.X = (float)aRect.Left;
                dXFPoint.Y = (float)aRect.Bottom;
                arrayLists.Add(dXFPoint);
                return;
            }
            for (int i = 0; i < this.PointCount - 2; i++)
            {
                for (int j = 1; j < 4; j++)
                {
                    DXFPoint dXFPoint1 = new DXFPoint();
                    this.Points.Add(dXFPoint1);
                }
                if (((DXFPoint)this.Points[i]).X == (float)aRect.Left &&
                    ((DXFPoint)this.Points[i + 1]).X == (float)aRect.Left &&
                    (((DXFPoint)this.Points[i]).Y > (float)aRect.Top ||
                     ((DXFPoint)this.Points[i + 1]).Y > (float)aRect.Bottom) ||
                    ((DXFPoint)this.Points[i]).Y >= (float)aRect.Top &&
                    ((DXFPoint)this.Points[i + 1]).Y >= (float)aRect.Bottom)
                {
                    for (k = i + 1; k < this.PointCount - 1; k++)
                    {
                        this.Points[this.PointCount - 1 + 4 - (k - i - 1)] =
                            (DXFPoint)this.Points[this.PointCount - 1 - (k - i - 1)];
                    }
                    ((DXFPoint)this.Points[i + 1]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 1]).Y = (float)aRect.Bottom;
                    ((DXFPoint)this.Points[i + 2]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 2]).Y = (float)aRect.Bottom;
                    ((DXFPoint)this.Points[i + 3]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 3]).Y = (float)aRect.Top;
                    ((DXFPoint)this.Points[i + 4]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 4]).Y = (float)aRect.Top;
                    return;
                }
                if (((DXFPoint)this.Points[i]).Y == (float)aRect.Top &&
                    ((DXFPoint)this.Points[i + 1]).Y == (float)aRect.Top &&
                    (((DXFPoint)this.Points[i]).X > (float)aRect.Left ||
                     ((DXFPoint)this.Points[i + 1]).X > (float)aRect.Right) ||
                    ((DXFPoint)this.Points[i]).X >= (float)aRect.Left &&
                    ((DXFPoint)this.Points[i + 1]).X >= (float)aRect.Right)
                {
                    for (k = i + 1; k < this.PointCount - 1; k++)
                    {
                        this.Points[this.PointCount - 1 + 4 - (k - i - 1)] =
                            (DXFPoint)this.Points[this.PointCount - 1 - (k - i - 1)];
                    }
                    ((DXFPoint)this.Points[i + 1]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 1]).Y = (float)aRect.Top;
                    ((DXFPoint)this.Points[i + 2]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 2]).Y = (float)aRect.Bottom;
                    ((DXFPoint)this.Points[i + 3]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 3]).Y = (float)aRect.Bottom;
                    ((DXFPoint)this.Points[i + 4]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 4]).Y = (float)aRect.Top;
                    return;
                }
                if (((DXFPoint)this.Points[i]).X == (float)aRect.Right &&
                    ((DXFPoint)this.Points[i + 1]).X == (float)aRect.Right &&
                    (((DXFPoint)this.Points[i]).Y > (float)aRect.Top ||
                     ((DXFPoint)this.Points[i + 1]).Y > (float)aRect.Bottom) ||
                    ((DXFPoint)this.Points[i]).Y >= (float)aRect.Top &&
                    ((DXFPoint)this.Points[i]).Y >= (float)aRect.Bottom)
                {
                    for (k = i + 1; k < this.data.count - 1; k++)
                    {
                        this.Points[this.PointCount - 1 + 4 - (k - i - 1)] =
                            (DXFPoint)this.Points[this.PointCount - 1 - (k - i - 1)];
                    }
                    ((DXFPoint)this.Points[i + 1]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 1]).Y = (float)aRect.Top;
                    ((DXFPoint)this.Points[i + 2]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 2]).Y = (float)aRect.Top;
                    ((DXFPoint)this.Points[i + 3]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 3]).Y = (float)aRect.Bottom;
                    ((DXFPoint)this.Points[i + 4]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 4]).Y = (float)aRect.Bottom;
                    return;
                }
                if (((DXFPoint)this.Points[i]).Y == (float)aRect.Bottom &&
                    ((DXFPoint)this.Points[i + 1]).Y == (float)aRect.Bottom &&
                    (this.min(((DXFPoint)this.Points[i]).X, ((DXFPoint)this.Points[i + 1]).X) > (float)aRect.Left ||
                     this.min(((DXFPoint)this.Points[i]).X, ((DXFPoint)this.Points[i + 1]).X) < (float)aRect.Right) ||
                    this.max(((DXFPoint)this.Points[i]).X, ((DXFPoint)this.Points[i + 1]).X) <= (float)aRect.Left &&
                    this.max(((DXFPoint)this.Points[i]).X, ((DXFPoint)this.Points[i + 1]).X) <= (float)aRect.Right)
                {
                    for (k = i + 1; k < this.PointCount - 1; k++)
                    {
                        this.Points[this.PointCount - 1 + 4 - (k - i - 1)] =
                            (DXFPoint)this.Points[this.PointCount - 1 - (k - i - 1)];
                    }
                    ((DXFPoint)this.Points[i + 1]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 1]).Y = (float)aRect.Bottom;
                    ((DXFPoint)this.Points[i + 2]).X = (float)aRect.Left;
                    ((DXFPoint)this.Points[i + 2]).Y = (float)aRect.Top;
                    ((DXFPoint)this.Points[i + 3]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 3]).Y = (float)aRect.Top;
                    ((DXFPoint)this.Points[i + 4]).X = (float)aRect.Right;
                    ((DXFPoint)this.Points[i + 4]).Y = (float)aRect.Bottom;
                    return;
                }
            }
            if (this.Points != null)
            {
                Rectangle rectangle = new Rectangle();
                rectangle = aRect;
                this.Points.Add(rectangle);
            }
        }
示例#7
0
 public DXFPoint(DXFPoint dxfP)
 {
     this.X = dxfP.X;
     this.Y = dxfP.Y;
     this.Z = dxfP.Z;
 }
示例#8
0
        public DXFHatch(DXFData aData) : base(aData)
        {
            int j;

            this.boundaries   = new ArrayList();
            this.patternName  = "";
            this.boundaryType = (HatchBoundaryType)aData.selfType;
            DXFPoint dXFPoint = new DXFPoint();

            base.Layer = "0";
            this.SetStyle(aData);
            this.boundaries.Clear();
            switch (this.boundaryType)
            {
            case HatchBoundaryType.hbtPolyPolyline:
            {
                if (aData.count > 0)
                {
                    for (int i = 0; i < aData.points.Count; i++)
                    {
                        if (((ArrayList)aData.points[i]).Count >= 3)
                        {
                            this.boundaries.Add(new ArrayList());
                            for (j = 0; j < ((ArrayList)aData.points[i]).Count; j++)
                            {
                                dXFPoint = (DXFPoint)((ArrayList)aData.points[i])[j];
                                if (j < 2 || dXFPoint.X != ((DXFPoint)((ArrayList)aData.points[i])[j - 2]).X ||
                                    dXFPoint.Y != ((DXFPoint)((ArrayList)aData.points[i])[j - 2]).Y)
                                {
                                    ((ArrayList)this.boundaries[this.boundaries.Count - 1]).Add(dXFPoint.Clone());
                                }
                                else
                                {
                                    dXFPoint = null;
                                }
                            }
                            if (((ArrayList)this.boundaries[this.boundaries.Count - 1]).Count < 3)
                            {
                                for (j = 0;
                                     j < ((ArrayList)this.boundaries[this.boundaries.Count - 1]).Count - 1;
                                     j++)
                                {
                                    ((ArrayList)this.boundaries[this.boundaries.Count - 1])[j] = null;
                                }
                                this.boundaries.Remove((ArrayList)this.boundaries[this.boundaries.Count - 1]);
                            }
                        }
                    }
                }
                return;
            }

            case HatchBoundaryType.hbtCircle:
            {
                this.bndAmount = 1;
                return;
            }

            case HatchBoundaryType.hbtEllipse:
            {
                this.bndAmount = 1;
                return;
            }
            }
            this.bndAmount = 0;
        }