コード例 #1
0
        public static PointSet interpolation(PointSet ps, ObjectId[] ids)
        {
            List <LineSegment3d> ll    = MyDBUtility.getLines(ids);
            PLDictionary2        plDic = new PLDictionary2();

            plDic.Add(ll);
            return(interpolation(ps, plDic));
        }
コード例 #2
0
        public void draw()
        {
            ObjectId  layerId = LayerUtil.CreateLayer("coordinate", 0, false);
            Extents3d bounds  = MyDBUtility.getExtents(mydb.getAllLine());

            double zlen = 0;
            double minz = -10;

            if (mydb.TEDicList.Count > 0)
            {
                TEDictionary ted = mydb.TEDicList[0];
                zlen  = ted.maxMaxZ - ted.minMaxZ;
                zlen += 10;
                minz  = ted.minMaxZ - 5;
            }


            Point3d ori = bounds.MinPoint.Add(new Vector3d(-10, -10, 0));

            ori = ori.Add(new Vector3d(0, 0, (minz - ori.Z)));
            double xlen = bounds.MaxPoint.X - bounds.MinPoint.X + 20;
            double ylen = bounds.MaxPoint.Y - bounds.MinPoint.Y + 20;

            MyDBUtility.line(ori, new Point3d(ori.X + xlen, ori.Y, ori.Z), layerId);
            MyDBUtility.line(ori, new Point3d(ori.X, ori.Y + ylen, ori.Z), layerId);
            Point3d zstart = ori.Add(new Vector3d(0, ylen, 0));
            Point3d zend   = zstart.Add(new Vector3d(0, 0, zlen));

            MyDBUtility.line(zstart, zend, layerId);
            int xcount = (int)xlen / 10;
            int ycount = (int)ylen / 10;
            int zcount = (int)zlen / 5;

            for (int i = 0; i < xcount; i++)
            {
                Point3d s = ori.Add(new Vector3d(i * 10, 0, 0));
                Point3d e = s.Add(new Vector3d(0, -5, 0));
                MyDBUtility.line(s, e, layerId);
                MyDBUtility.text(e, ((int)s.X).ToString(), -Math.PI / 2, layerId);
            }
            for (int i = 0; i < ycount; i++)
            {
                Point3d s = ori.Add(new Vector3d(0, i * 10, 0));
                Point3d e = s.Add(new Vector3d(-5, 0, 0));
                MyDBUtility.line(s, e, layerId);
                MyDBUtility.text(e.Add(new Vector3d(-5, 0, 0)), ((int)s.Y).ToString(), 0, layerId);
            }

            for (int i = 0; i < zcount; i++)
            {
                Point3d s = ori.Add(new Vector3d(0, ylen, i * 5));
                Point3d e = s.Add(new Vector3d(0, 5, 0));
                MyDBUtility.line(s, e, layerId);
                MyDBUtility.text(e.Add(new Vector3d(0, 10, 0)), ((int)s.Z).ToString(), 0, layerId);
            }
        }
コード例 #3
0
ファイル: UserCmd.cs プロジェクト: 1833183060/autocad-dev
        public void tri()
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                ObjectId   boundaryLayerId = LayerUtil.CreateLayer(boundaryLayerName, 127, false);
                PointSet   ps       = mydb.getAllPoint();
                ObjectId[] ids      = mydb.LineIds;
                ObjectId[] bidArray = Selection.getBoundarys();

                List <ObjectId> boundaryIds = null;
                if (bidArray == null || bidArray.Length <= 0)
                {
                    boundaryIds = new List <ObjectId>();
                }
                else
                {
                    boundaryIds = bidArray.ToList();
                }

                if (boundaryIds.Count <= 0)
                {
                    List <Point3d> pl = PreProcess.getOuterBoundaryFromLine(ids, null);
                    //List<ObjectId> plineIds = new List<ObjectId>();

                    ObjectId?plineId = MyDBUtility.addPolyline3d(pl, boundaryLayerId, true);

                    if (plineId != null)
                    {
                        boundaryIds.Add(plineId.Value);
                    }
                    List <Edge> el = MyConvert.ToEdgeList(pl);
                    if (el == null)
                    {
                        ed.WriteMessage("\nel==null");
                    }

                    for (int i = 0; i < el.Count; i++)
                    {
                        //boundary.Add(new Constraint(el[i], Constraint.ConstraintType.Boundary));
                    }
                    List <Point3d> pl2      = this.getInnerBo(ids);
                    ObjectId?      plineId2 = MyDBUtility.addPolyline3d(pl2, boundaryLayerId, true);
                    if (plineId2 != null)
                    {
                        boundaryIds.Add(plineId2.Value);
                    }
                    List <Edge> el2 = MyConvert.ToEdgeList(pl);
                    if (el2 == null)
                    {
                        ed.WriteMessage("\nel2==null");
                    }
                    else
                    {
                        for (int i = 0; i < el2.Count; i++)
                        {
                            //boundary.Add(new Constraint(el2[i], Constraint.ConstraintType.Boundary));
                        }
                    }
                }
                else
                {
                }
                List <Constraint> boundary = new List <Constraint>();
                List <Edge>       list4    = Conversions.ToCeometricEdgeList(boundaryIds.ToArray());
                for (int j = 0; j < list4.Count; j++)
                {
                    boundary.Add(new Constraint(list4[j], Constraint.ConstraintType.Boundary));
                }

                Triangulate tri = new Triangulate();
                //tri.TriangulateInternal(ps, new List<Constraint>(), new List<Constraint>());
                LayerUtil.setLayerProp(mydb.getFaceLayerName(), false);
                List <Triangle> tris = tri.TriangulateInternal(ps, new List <Constraint>(), boundary, mydb.getFaceLayerName());
                mydb.setTris(tris);
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("UserCmd 144 " + ex.Message);
            }
        }