示例#1
0
文件: CAD.cs 项目: xeon-ye/GSYGeo
        /// <summary>
        /// 方法,向模型空间添加一个图案填充
        /// </summary>
        /// <param name="_model">模型空间</param>
        /// <param name="_hatchName">填充名称</param>
        /// <param name="_startX">起点X坐标</param>
        /// <param name="_startY">起点Y坐标</param>
        /// <param name="_endX">终点X坐标</param>
        /// <param name="_endY">终点Y坐标</param>
        /// <returns></returns>
        public DxfHatch AddRecHatch(string _hatchName, double _startX, double _startY, double _endX, double _endY)
        {
            DxfHatch hatch = new DxfHatch();

            DxfHatch.BoundaryPath boundary = new DxfHatch.BoundaryPath();
            boundary.Type = BoundaryPathType.Polyline;
            hatch.BoundaryPaths.Add(boundary);

            DxfHatch.BoundaryPath.Polyline.Vertex[] vertexs = new DxfHatch.BoundaryPath.Polyline.Vertex[4]
            {
                new DxfHatch.BoundaryPath.Polyline.Vertex(_startX, _startY),
                new DxfHatch.BoundaryPath.Polyline.Vertex(_endX, _startY),
                new DxfHatch.BoundaryPath.Polyline.Vertex(_endX, _endY),
                new DxfHatch.BoundaryPath.Polyline.Vertex(_startX, _endY)
            };
            boundary.PolylineData        = new DxfHatch.BoundaryPath.Polyline(vertexs);
            boundary.PolylineData.Closed = true;

            DxfPatternStore.Add(PatternReader.ReadPatterns("acad.pat"));
            hatch.Pattern = DxfPatternStore.GetPatternWithName(_hatchName);
            hatch.Scale   = 0.5;

            Model.Entities.Add(hatch);
            return(hatch);
        }
示例#2
0
文件: CAD.cs 项目: xeon-ye/GSYGeo
        /// <summary>
        /// 方法,向模型空间添加一个圆
        /// </summary>
        /// <param name="_centerX">圆心的X坐标</param>
        /// <param name="_centerY">圆心的Y坐标</param>
        /// <param name="_radius">圆的半径</param>
        /// <param name="_isSolid">实心或空心,true为实心</param>
        /// <returns></returns>
        public DxfCircle AddCircle(double _centerX, double _centerY, double _radius, bool _isSolid)
        {
            DxfCircle circle = new DxfCircle(new Point2D(_centerX, _centerY), _radius);

            Model.Entities.Add(circle);

            if (_isSolid)
            {
                DxfHatch hatch = new DxfHatch();

                DxfHatch.BoundaryPath boundary = new DxfHatch.BoundaryPath();
                boundary.Type = BoundaryPathType.Outermost;
                hatch.BoundaryPaths.Add(boundary);
                DxfHatch.BoundaryPath.ArcEdge arcEdge = new DxfHatch.BoundaryPath.ArcEdge();
                arcEdge.Center     = new Point2D(_centerX, _centerY);
                arcEdge.Radius     = 1;
                arcEdge.StartAngle = 0;
                arcEdge.EndAngle   = System.Math.PI * 2;
                boundary.Edges.Add(arcEdge);

                Model.Entities.Add(hatch);
            }

            return(circle);
        }
示例#3
0
文件: Form2.cs 项目: Spritutu/ntxx
        public void Test()
        {
            DxfModel model = new DxfModel(DxfVersion.Dxf14);

            DxfHatch hatch = new DxfHatch();
            hatch.Color = EntityColors.Green;
            hatch.ElevationPoint = new Point3D(10,10, 0);
            hatch.ZAxis = new Vector3D(0, 0, 0);

            // A boundary path bounded by lines.
            DxfHatch.BoundaryPath boundaryPath1 = new DxfHatch.BoundaryPath();
            boundaryPath1.Type = BoundaryPathType.None;
            hatch.BoundaryPaths.Add(boundaryPath1);
            boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(0, 0), new Point2D(1, 0)));
            boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(1, 0), new Point2D(1, 1)));
            boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(1, 1), new Point2D(0, 1)));
            boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(0, 1), new Point2D(0, 0)));

            // Define the hatch fill pattern.
            // Don't set a pattern for solid fill.
            hatch.Pattern = new DxfPattern();
            DxfPattern.Line patternLine = new DxfPattern.Line();
            hatch.Pattern.Lines.Add(patternLine);
            patternLine.Angle = System.Math.PI / 4d;
            patternLine.Offset = new Vector2D(0.02, -0.01d);
            patternLine.DashLengths.Add(0.02d);
            patternLine.DashLengths.Add(-0.01d);
            patternLine.DashLengths.Add(0d);
            patternLine.DashLengths.Add(-0.01d);

            model.Entities.Add(hatch);

            DxfWriter.Write("DxfWriteHatchTest.dxf", model, false);
        }
示例#4
0
        /// <summary>
        /// 根据花纹库编号将相应的花纹插入到图表中
        /// </summary>
        public DxfHatch getPatternHatch(double X1, double X2, double startDeep, double endDeep)
        {
            string        path          = AppDomain.CurrentDomain.BaseDirectory + "Drill\\patternLibrary\\";
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            FileInfo[] fileInfo = directoryInfo.GetFiles("*.pat");
            //获得pat文档的个数
            int fileLength = fileInfo.Length;

            //遍历所有的已经存在的pat文件
            foreach (FileInfo file in fileInfo)
            {
                //解决中文乱码问题
                StreamReader  str      = new StreamReader(path + file, Encoding.Default);
                char[]        s        = { ',' };             //定义分隔符为逗号
                StringBuilder rockName = new StringBuilder(); //存储岩石名称的数组
                string        readLine = str.ReadLine();      //读取一行数据
                while (!string.IsNullOrEmpty(readLine))       //如果数据不为空)
                {
                    string[] record = readLine.Split(s);
                    rockName.Append(record[1]);
                    string strRockName = rockName.ToString().Trim();
                    //strRockName = strRockName.Replace(" ", "");
                    if (string.Equals(strRockName, mrockName))//找到名字相同的花纹
                    {
                        //读取花纹库
                        DxfModel model = new DxfModel();
                        DxfPatternStore.Add(PatternReader.ReadPatterns(path + file));
                        DxfHatch hatch = new DxfHatch();
                        hatch.Pattern = DxfPatternStore.GetPatternWithName("" + Path.GetFileNameWithoutExtension(file.Name));
                        DxfHatch.BoundaryPath boundaryPath = new DxfHatch.BoundaryPath();
                        boundaryPath.Type = BoundaryPathType.Polyline;
                        hatch.BoundaryPaths.Add(boundaryPath);
                        boundaryPath.PolylineData =
                            new DxfHatch.BoundaryPath.Polyline(
                                new DxfHatch.BoundaryPath.Polyline.Vertex[] {
                            new DxfHatch.BoundaryPath.Polyline.Vertex(X1, -23d - startDeep),
                            new DxfHatch.BoundaryPath.Polyline.Vertex(X2, -23d - startDeep),
                            new DxfHatch.BoundaryPath.Polyline.Vertex(X2, -23d - endDeep),
                            new DxfHatch.BoundaryPath.Polyline.Vertex(X1, -23d - endDeep)
                        }
                                );

                        boundaryPath.PolylineData.Closed = true;
                        return(hatch);
                    }
                    break;
                }
            }
            return(null);
        }
示例#5
0
        internal override void Read(Class434 or, Class259 ob)
        {
            base.Read(or, ob);
            Interface30 objectBitStream = or.ObjectBitStream;

            this.dxfPattern_0 = new DxfPattern();
            this.dxfPattern_0.Read(objectBitStream);
            this.double_0   = objectBitStream.imethod_8();
            this.vector3D_0 = objectBitStream.imethod_51();
            int num = objectBitStream.imethod_11();

            for (int index = 0; index < num; ++index)
            {
                DxfHatch.BoundaryPath boundaryPath = new DxfHatch.BoundaryPath();
                boundaryPath.Read(or, false);
                this.list_0.Add(boundaryPath);
            }
        }
示例#6
0
        public DxfHatch getHatch_Deck(decimal percentfill, double[] x, double[] y, EntityColor hatchcolor)
        {
            DxfHatch hatch = new DxfHatch();

            hatch.Color = hatchcolor;

            if (percentfill != 0)
            {
                #region hatch
                DxfHatch.BoundaryPath.Polyline.Vertex[] Ver = new DxfHatch.BoundaryPath.Polyline.Vertex[13];

                if ((Convert.ToInt32(percentfill) > 0) & (Convert.ToInt32(percentfill) <= 100))
                {
                    for (int i = 1; i <= 12; i++)
                    {
                        Ver[i] = new DxfHatch.BoundaryPath.Polyline.Vertex(x[i], y[i]);
                    }
                }

                DxfHatch.BoundaryPath bp = new DxfHatch.BoundaryPath();
                bp.Type = BoundaryPathType.Polyline;
                hatch.BoundaryPaths.Add(bp);


                bp.PolylineData =
                    new DxfHatch.BoundaryPath.Polyline(
                        new DxfHatch.BoundaryPath.Polyline.Vertex[] {
                    Ver[1], Ver[2], Ver[3], Ver[4], Ver[5], Ver[6], Ver[7], Ver[8], Ver[9], Ver[10], Ver[11], Ver[12]
                }

                        );


                bp.PolylineData.Closed = true;

                #endregion hatch
            }

            return(hatch);
        }
示例#7
0
        internal override void Read(DxfReader r, Class259 objectBuilder)
        {
            base.Read(r, objectBuilder);
            if (r.CurrentGroup.Code != 100 || (string)r.CurrentGroup.Value != "AcDbHatchObjectContextData")
            {
                throw new DxfException("Expected subclass marker.");
            }
            r.method_85();
            bool             flag1 = true;
            BoundaryPathType type  = BoundaryPathType.None;
            bool             flag2 = true;

            while (!r.method_92("AcDbHatchScaleContextData"))
            {
                switch (r.CurrentGroup.Code)
                {
                case 10:
                    this.vector3D_0.X = (double)r.CurrentGroup.Value;
                    break;

                case 20:
                    this.vector3D_0.Y = (double)r.CurrentGroup.Value;
                    break;

                case 30:
                    this.vector3D_0.Z = (double)r.CurrentGroup.Value;
                    break;

                case 40:
                    this.double_0 = (double)r.CurrentGroup.Value;
                    break;

                case 78:
                    short num = (short)r.CurrentGroup.Value;
                    if (num > (short)0)
                    {
                        r.method_85();
                        this.dxfPattern_0 = new DxfPattern();
                        this.dxfPattern_0.Read(r, (int)num);
                        flag2 = false;
                        break;
                    }
                    break;

                case 90:
                    if (flag1)
                    {
                        flag1 = false;
                        break;
                    }
                    type = (BoundaryPathType)r.CurrentGroup.Value;
                    break;

                case 290:
                    if (!(bool)r.CurrentGroup.Value)
                    {
                        DxfHatch.BoundaryPath boundaryPath = new DxfHatch.BoundaryPath(type);
                        if ((boundaryPath.Type & BoundaryPathType.IsAnnotative) != BoundaryPathType.None && boundaryPath.IsPolyline)
                        {
                            boundaryPath.PolylineData = new DxfHatch.BoundaryPath.Polyline();
                            r.method_85();
                            boundaryPath.PolylineData.Read(r);
                        }
                        else if (!boundaryPath.IsPolyline)
                        {
                            r.method_85();
                            int nrOfEdges = (int)r.CurrentGroup.Value;
                            r.method_85();
                            boundaryPath.method_0(nrOfEdges, r);
                        }
                        this.list_0.Add(boundaryPath);
                        flag2 = false;
                        break;
                    }
                    break;
                }
                if (flag2)
                {
                    r.method_85();
                }
                else
                {
                    flag2 = true;
                }
            }
        }
示例#8
0
 public Class659(DxfHatch.BoundaryPath boundaryPath)
 {
     this.boundaryPath_0 = boundaryPath;
 }