Esempio n. 1
0
        public static PointSet interpolation_partial(PPDictionary ppd)
        {
            PointSet result = new PointSet();
            int      count  = ppd.index.Count;
            List <InterpolatedPoint> lip = new List <InterpolatedPoint>();

            for (int i = 0; i < count; i++)
            {
                KeyValuePair <Point, List <Point> > kv  = ppd.index[i];
                List <InterpolatedPoint>            tps = interp2(MyConvert.toPoint3d(kv.Key), MyConvert.toPoint3dList(kv.Value));
                if (tps != null)
                {
                    lip.AddRange(tps);
                }
            }
            lip.Sort(new InterpolatedPointComparer());
            count = lip.Count / 5;
            for (int i = 0; i < count; i++)
            {
                result.Add(lip[i].point);
            }
            return(result);
        }
Esempio n. 2
0
        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);
            }
        }