Пример #1
0
        public static HatchModel Hatch2Model(Hatch dbText)
        {
            HatchModel dbModel = new HatchModel();

            int cont = dbText.NumberOfLoops;

            for (int i = 0; i < cont; i++)
            {
                dbModel.loopPoints.Add(i, new ColorAndPointItemModel());
                HatchLoop loop = dbText.GetLoopAt(i);

                ColorAndPointItemModel cpModel = new ColorAndPointItemModel();
                if (i == 0)
                {
                    cpModel.Color = dbText.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(dbText.LayerId) : System.Drawing.ColorTranslator.ToHtml(dbText.Color.ColorValue);
                }
                else
                {
                    cpModel.Color = "#FFFFFF";
                    //  cpModel.ZIndex = "1";
                }

                //if (loop.Polyline.Count == 3)
                //{
                //}

                if (loop.IsPolyline && loop.Polyline.Count > 3)
                {
                    for (int j = 0; j < loop.Polyline.Count - 1; j++)
                    {
                        BulgeVertex vertex  = loop.Polyline[j];
                        BulgeVertex vertex1 = loop.Polyline[j + 1];
                        if (vertex.Bulge != 0)
                        {
                            cpModel.loopPoints.AddRange(MethodCommand.GetArcPointsByBulge(vertex.Vertex, vertex1.Vertex, vertex.Bulge));
                        }
                        else
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(vertex.Vertex));
                        }
                    }


                    if (dbText.NumberOfHatchLines > 0)
                    {
                        Line2dCollection cl = dbText.GetHatchLinesData();
                    } //foreach (Line2d itemi in )
                      //{

                    //}
                }
                else
                {
                    Curve2dCollection col_cur2d = loop.Curves;
                    foreach (Curve2d item in col_cur2d)
                    {
                        Point2d[] M_point2d = item.GetSamplePoints(20);
                        foreach (Point2d point in M_point2d)
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(point));
                        }
                    }
                }

                if (cpModel.loopPoints[0] != cpModel.loopPoints[cpModel.loopPoints.Count - 1])
                {
                    cpModel.loopPoints.Add(cpModel.loopPoints[0]);
                }
                dbModel.loopPoints[i] = cpModel;
            }

            for (int i = 0; i < dbModel.loopPoints.Count; i++)
            {
                for (int j = 0; j < dbModel.loopPoints.Count; j++)
                {
                    if (i != j)
                    {
                        if (MethodCommand.PointsAllInPoints(dbModel.loopPoints[j].loopPoints, dbModel.loopPoints[i].loopPoints))
                        {
                            dbModel.loopPoints[j].ZIndex = "2";
                        }
                    }
                }
            }
            try
            {
                dbModel.Area = dbText.Area;
            }
            catch
            { }
            //   dbModel.Color =
            return(dbModel);
        }
Пример #2
0
        public static HatchModel Hatch2Model(Hatch dbText, AttributeModel atModel)
        {
            HatchModel dbModel = new HatchModel();

            try
            {
                dbModel.Area = dbText.Area;
            }
            catch
            { }

            int    cont  = dbText.NumberOfLoops;
            string color = "";

            for (int i = 0; i < cont; i++)
            {
                dbModel.loopPoints.Add(i, new ColorAndPointItemModel());
                HatchLoop loop = dbText.GetLoopAt(i);

                ColorAndPointItemModel cpModel = new ColorAndPointItemModel();
                if (i == 0)
                {
                    color = cpModel.Color = dbText.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(dbText.LayerId) : System.Drawing.ColorTranslator.ToHtml(dbText.Color.ColorValue);
                }
                else
                {
                    cpModel.Color = "#FFFFFF";
                    //  cpModel.ZIndex = "1";
                }
                if (loop.IsPolyline)
                {
                    for (int j = 0; j < loop.Polyline.Count - 1; j++)
                    {
                        BulgeVertex vertex  = loop.Polyline[j];
                        BulgeVertex vertex1 = loop.Polyline[j + 1];
                        if (vertex.Bulge != 0)
                        {
                            cpModel.loopPoints.AddRange(MethodCommand.GetArcPointsByBulge(vertex.Vertex, vertex1.Vertex, vertex.Bulge));
                        }
                        else
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(vertex.Vertex));
                        }
                    }


                    if (dbText.NumberOfHatchLines > 0)
                    {
                        Line2dCollection cl = dbText.GetHatchLinesData();
                    } //foreach (Line2d itemi in )
                      //{

                    //}
                }
                else
                {
                    Curve2dCollection col_cur2d = loop.Curves;
                    foreach (Curve2d item in col_cur2d)
                    {
                        Point2d[] M_point2d = item.GetSamplePoints(20);
                        foreach (Point2d point in M_point2d)
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(point));
                        }
                    }
                }

                if (cpModel.loopPoints[0] != cpModel.loopPoints[cpModel.loopPoints.Count - 1])
                {
                    cpModel.loopPoints.Add(cpModel.loopPoints[0]);
                }
                cpModel.attItemList = new List <AttributeItemModel>();
                foreach (AttributeItemModel item in atModel.attributeItems)
                {
                    string attValue = "";

                    switch (item.AtItemType)
                    {
                    case AttributeItemType.Area:
                        attValue = dbModel.Area.ToString();
                        break;

                    case AttributeItemType.TxtHeight:

                        break;

                    case AttributeItemType.Color:
                        attValue = color;
                        break;

                    case AttributeItemType.Content:

                        break;

                    case AttributeItemType.LayerName:
                        attValue = dbText.Layer;
                        break;

                    case AttributeItemType.LineScale:
                        attValue = dbText.LinetypeScale.ToString();
                        break;

                    case AttributeItemType.LineType:
                        attValue = GetLayerLineTypeByID(dbText);
                        break;

                    case AttributeItemType.Overallwidth:
                        break;

                    case AttributeItemType.TotalArea:
                        attValue = dbModel.Area.ToString();
                        break;
                    }
                    if (!string.IsNullOrEmpty(attValue))
                    {
                        item.AtValue = attValue;
                        cpModel.attItemList.Add(item);
                    }
                    else
                    {
                    }
                }
                dbModel.loopPoints[i] = cpModel;
            }

            for (int i = 0; i < dbModel.loopPoints.Count; i++)
            {
                for (int j = 0; j < dbModel.loopPoints.Count; j++)
                {
                    if (i != j)
                    {
                        if (MethodCommand.PointsAllInPoints(dbModel.loopPoints[j].loopPoints, dbModel.loopPoints[i].loopPoints))
                        {
                            dbModel.loopPoints[j].ZIndex = "2";
                        }
                    }
                }
            }

            //   dbModel.Color =
            return(dbModel);
        }