Пример #1
0
        public void MySort(ref List <JoinEnt> jes)
        {
            if (jes.Count < 2)
            {
                return;
            }

            for (int i = 0; i < jes.Count; i++)
            {
                for (int j = i + 1; j < jes.Count; j++)
                {
                    if (1 == jes[i].CompareTo(jes[j]))
                    {
                        JoinEnt tmp = jes[i];

                        jes[i] = jes[j];
                        jes[j] = tmp;
                    }
                }
            }
        }
Пример #2
0
        //1 if obj is smaller than this item
        //0 if equal
        //-1 if obj is bigger

        public int CompareTo(object obj)
        {
            JoinEnt tmp = obj as JoinEnt;

            return(tmp.pos.Y.CompareTo(pos.Y));
        }
Пример #3
0
        public void JoinText2()
        {
            var ent_ids = AcadFuncs.PickEnts();

            if (0 == ent_ids.Count)
            {
                return;
            }

            AcadGeo.Point3d ins_pnt = new AcadGeo.Point3d();
            if (!AcadFuncs.GetPoint(ref ins_pnt, "Chon vi tri text:"))
            {
                return;
            }

            var watch = System.Diagnostics.Stopwatch.StartNew();
            //C5.IntervalHeap<JoinEnt> data = new C5.IntervalHeap<JoinEnt>();
            List <JoinEnt> data = new List <JoinEnt>();

            for (int i = 0; i < ent_ids.Count; i++)
            {
                bool    valid = true;
                JoinEnt je    = new JoinEnt(ent_ids[i], GetPosition(ent_ids[i], out valid));
                if (valid)
                {
                    data.Add(je);
                }
            }

            //data.Sort((item1, item2) => item1.pos.Y.CompareTo(item2.pos.Y));
            data.Sort();

            while (data.Count > 0)
            {
                JoinEnt je = data.Min();
                //data.DeleteMin();
                data.RemoveAt(0);

                List <JoinEnt> ents = new List <JoinEnt>();
                ents.Add(je);
                while (data.Count > 0)
                {
                    bool export = false;
                    if (Math.Abs(data.Min().pos.Y - je.pos.Y) < delta_y)
                    {
                        ents.Add(data.Min());
                        //data.DeleteMin();
                    }
                    else
                    {
                        export = true;
                    }

                    if (0 == data.Count || export)
                    {
                        ents.Sort((item1, item2) => item1.pos.X.CompareTo(item2.pos.X));

                        DBText text = new DBText();
                        text.TextString += GetContent(ents[0].id);
                        text.TextString += "_";

                        for (int i = 1; i < ents.Count; i++)
                        {
                            text.TextString += GetContent(ents[i].id);
                            text.TextString += "x";
                        }

                        text.TextString = text.TextString.Substring(0, text.TextString.Count() - 1);
                        text.Position   = ins_pnt;
                        text.Height     = 1.0;
                        ins_pnt         = new AcadGeo.Point3d(ins_pnt.X, ins_pnt.Y + text.Height * 2.0, ins_pnt.Z);
                        AcadFuncs.AddNewEnt(text);
                        break;
                    }
                }
            }

            AcadFuncs.GetEditor().WriteMessage("\nDone By [email protected]\n");
            watch.Stop();
            AcadFuncs.GetEditor().WriteMessage(watch.ElapsedMilliseconds.ToString());
        }