Exemplo n.º 1
0
        private void SetHullVoronoiFromEdges(Plane3 <double> myPlane)
        {
            ///////////////////////
            int ii = 0;

            while (ii < Edges.Count)
            {
                if (Edges[ii].p1.Condition == 0 && Edges[ii].p2.Condition == 0)
                {
                    Edges.RemoveAt(ii);
                }
                else if (Edges[ii].p1.Condition == 1 && Edges[ii].p2.Condition == 0)
                {
                    Edges.RemoveAt(ii);
                }
                else if (Edges[ii].p1.Condition == 1 && Edges[ii].p2.Condition == 1)
                {
                    Edges.RemoveAt(ii);
                }
                else if (Edges[ii].p1.Condition == 0 && Edges[ii].p2.Condition == 1)
                {
                    Edges.RemoveAt(ii);
                }
                else if (Edges[ii].p1.Condition == 0 && Edges[ii].p2.Condition == 2)
                {
                    //double u;
                    Line3 <double>   line       = new Line3 <double>(Edges[ii].p1.Vector, Edges[ii].p2.Vector);
                    Vector3 <double> vIntersect = myPlane.Intersect(line);

                    //Rhino.Geometry.Intersect.Intersection.Line3<double>Plane(line, p, out u);
                    //pts.Add(new vertex(line.PointAt(u), this.center.DistanceTo(line.PointAt(u))));
                    Vertices.Add(new VertexHull(vIntersect, this.Center.DistanceTo(vIntersect, 1)));
                    VertexHull vert = new VertexHull(vIntersect, this.Center.DistanceTo(vIntersect, 1));
                    Vertices.Add(vert);

                    Edges[ii].p1 = Vertices[Vertices.Count - 1];
                    ii++;
                }
                else if (Edges[ii].p1.Condition == 2 && Edges[ii].p2.Condition == 0)
                {
                    //double u;
                    Line3 <double>   line       = new Line3 <double>(Edges[ii].p1.Vector, Edges[ii].p2.Vector);
                    Vector3 <double> vIntersect = myPlane.Intersect(line);
                    //TODO Rhino.Geometry.Intersect.Intersection.Line3<double>Plane(line, p, out u);
                    //pts.Add(new vertex(line.PointAt(u), this.center.DistanceTo(line.PointAt(u))));
                    Vertices.Add(new VertexHull(vIntersect, this.Center.DistanceTo(vIntersect, 1)));
                    Edges[ii].p2 = Vertices[Vertices.Count - 1];
                    ii++;
                }
                else
                {
                    ii++;
                }
            }
        }
 public Edge(VertexHull P1, VertexHull P2)
 {
     p1 = P1; p2 = P2;
 }