Exemplo n.º 1
0
        public override List <Curve> Visit(PointSite ps)
        {
            List <Curve> bisectors = new List <Curve>();

            double distance = this.Distance(ps.Contact);

            if (distance > Constants.tol)
            {
                bisectors.Add(new Parabola(ps.Contact, line));
            }
            else
            {
                bisectors.Add(new Line(ps.Contact, line.IHat));
            }

            return(bisectors);
        }
Exemplo n.º 2
0
        private void AddSite(Point tail, Point head)
        {
            PointSite ps = new PointSite(tail, pointSitePrefab, spheres);

            if (!pointSites.ContainsNear(ps))
            {
                pointSites.Add(ps);
                sites.Add(ps);
            }

            LineSite ls = new LineSite(tail, head, lineSitePrefab, cylinders);

            if (!lineSites.Contains(ls))
            {
                lineSites.Add(ls);
                sites.Add(ls);
            }
        }
Exemplo n.º 3
0
        public void InitializeNodes()
        {
            // lower left, lower right, upper right, upper left
            Point[] dummy = new Point[4];

            dummy[0] = new Point(double.MaxValue, 0.0, double.MaxValue);
            dummy[2] = new Point(double.MinValue, 0.0, double.MinValue);

            // find bounding box of point sites
            foreach (PointSite ps in pointSites)
            {
                if (ps.Contact.X < dummy[0].X)
                {
                    dummy[0].X = ps.Contact.X;
                }

                if (ps.Contact.X > dummy[2].X)
                {
                    dummy[2].X = ps.Contact.X;
                }

                if (ps.Contact.Z < dummy[0].Z)
                {
                    dummy[0].Z = ps.Contact.Z;
                }

                if (ps.Contact.Z > dummy[2].Z)
                {
                    dummy[2].Z = ps.Contact.Z;
                }
            }

            dummy[1] = new Point(dummy[2].X, 0.0, dummy[0].Z);
            dummy[3] = new Point(dummy[0].X, 0.0, dummy[2].Z);

            double scale = 2.0;
            Point  c     = 0.5 * (dummy[0] + dummy[2]);

            for (int idummy = 0; idummy < 4; ++idummy)
            {
                Vector delta = dummy[idummy] - c;
                dummy[idummy] = c + scale * delta;
            }

            // create dummy sites
            PointSite[] dummyPoint = new PointSite[4];
            for (int idummy = 0; idummy < 4; ++idummy)
            {
                PointSite ps = new PointSite(dummy[idummy], pointSitePrefab, spheres);
                dummyPoint[idummy] = ps;
                if (!sites.Contains(ps))
                {
                    sites.Add(ps);
                    displaySites.Add(ps);
                }
            }

            // place node at center
            Node center = AddNodeNear(0.5 * (dummy[0] + dummy[2]));

            center.Connected = true;

            // add four corner nodes
            for (int idummy = 0; idummy < 4; ++idummy)
            {
                int jdummy = (idummy + 1) % 4;

                Site   left  = dummyPoint[idummy];
                Site   right = dummyPoint[jdummy];
                Point  mid   = 0.5 * (left.Contact + right.Contact);
                Vector delta = mid - c;

                Node n = AddNodeNear(c + scale * delta);
                n.Connected = true;

                List <Curve> bisectors = left.GetBisectors(right);
                if (bisectors.Count > 0)
                {
                    new Edge(left, right, bisectors[0], center, n, edgePrefab, cylinders);
                }
            }
        }
Exemplo n.º 4
0
 public abstract List <Curve> Visit(PointSite ps);