Ejemplo n.º 1
0
        public Pillar AddPillarBetween(List <int> ids, FaultSettings fsettings)
        {
            if (ids.Count < 2)
            {
                return(null);
            }
            ids.Sort();
            if (ids[1] != ids[0] + 1)
            {
                return(null);
            }
            PrecisedVertex        top   = (Items[ids[0]][0] + Items[ids[1]][0]) / 2.0;
            PrecisedVertex        bot   = (Items[ids[0]][Items[ids[0]].Count - 1] + Items[ids[1]][Items[ids[1]].Count - 1]) / 2.0;
            double                len   = top.DistanceTo(bot);
            double                step  = len / 5;
            double                vx    = (bot.X - top.X) / 4;
            double                vy    = (bot.Y - top.Y) / 4;
            double                vz    = (bot.Z - top.Z) / 4;
            PrecisedVertex        vec   = new PrecisedVertex(vx, vy, vz);
            PrecisedVertex        nv    = top;
            List <PrecisedVertex> nlist = new List <PrecisedVertex>(5);

            nlist.Add(top);
            for (int i = 0; i < 3; i++)
            {
                nv = nv + vec;
                nlist.Add(nv);
            }
            nlist.Add(bot);
            Pillar pillar = new Pillar(Project, "Adding", nlist, fsettings.Impl);

            if (pillar != null)
            {
                Insert(ids[1], pillar);
            }
            return(pillar);
            //return null;
        }
Ejemplo n.º 2
0
        public Pillar AddPillarToEnd(List <int> ids, FaultSettings fsettings, double distance)
        {
            if (ids.Count == 0)
            {
                return(null);
            }
            bool isFirst = false;

            ids.Sort();
            if (ids[0] == 0)
            {
                isFirst = true;
            }
            else
            {
                if (ids[ids.Count - 1] != Count - 1)
                {
                    return(null);
                }
            }
            List <PrecisedVertex> v = new List <PrecisedVertex>();

            foreach (var item in Items)
            {
                v.Add(item[0]);
            }
            //foreach (var id in ids)
            //{
            //    v.Add(Items[id][0]);
            //}
            PrecisedVertex[] data;
            PrecisedVertex[] P1 = new PrecisedVertex[v.Count];
            PrecisedVertex[] P2 = new PrecisedVertex[v.Count];
            data = v.ToArray();
            try
            {
                MathFunctions.GetControlPoints(v.ToArray(), out P1, out P2);
                PrecisedVertex top = AddNewPillarToEnd(distance, isFirst, ref data, ref P1, ref P2);
                v.Clear();
                //foreach (var id in ids)
                //{
                //    v.Add(Items[id][Items[id].Count - 1]);
                //}
                foreach (var item in Items)
                {
                    v.Add(item[item.Count - 1]);
                }
                data = v.ToArray();
                MathFunctions.GetControlPoints(v.ToArray(), out P1, out P2);
                PrecisedVertex        bot   = AddNewPillarToEnd(distance, isFirst, ref data, ref P1, ref P2);
                double                len   = top.DistanceTo(bot);
                double                step  = len / 5;
                double                vx    = (bot.X - top.X) / 4;
                double                vy    = (bot.Y - top.Y) / 4;
                double                vz    = (bot.Z - top.Z) / 4;
                PrecisedVertex        vec   = new PrecisedVertex(vx, vy, vz);
                PrecisedVertex        nv    = top;
                List <PrecisedVertex> nlist = new List <PrecisedVertex>(5);
                nlist.Add(top);
                for (int i = 0; i < 3; i++)
                {
                    nv = nv + vec;
                    nlist.Add(nv);
                }
                nlist.Add(bot);
                Pillar pillar = new Pillar(Project, "Adding", nlist, fsettings.Impl);
                if (isFirst)
                {
                    Insert(0, pillar);
                }
                else
                {
                    Add(pillar);
                }
                //Insert(isFirst ? 0 : Count - 1, pillar);
                return(pillar);
            }
            catch
            {
                return(null);
            }
        }