コード例 #1
0
        public Pipes(List <Line> L, double tol, List <double> R0, List <double> R1, int Sides, List <Plane> EndPlanes0, List <Plane> EndPlanes1)
        {
            //Create pipie class instead of outputting too much stuff
            this._adj = new ClosestLinesT();
            List <Line> cpLines = L.ClosestLines(tol, ref this._adj, false);

            this._adj.cp = cpLines;

            //CreatePipes
            for (int i = 0; i < L.Count; i++)  //* Math.Sqrt(2)
            {
                _pipes.Add(L[i].CreatePipe(i, Plane.Unset, R0[Math.Min(i, R0.Count - 1)], Plane.Unset, Plane.Unset, Sides, R1[Math.Min(i, R1.Count - 1)]));
                _pipes[i].meshloft.FillHoles();
                _pipes[i].meshloft.WeldUsingRTree(0.01);
            }
        }
コード例 #2
0
        public static void ClosestLines(List <Line> L, double tolerance, double toleranceEnds, ref ClosestLinesT t)
        {
            t = new ClosestLinesT();

            HashSet <long> pairs = new HashSet <long>();

            for (int i = 0; i < L.Count; i++)
            {
                for (int j = 0; j < L.Count; j++)
                {
                    //In order to check the same pair again
                    if (i == j)
                    {
                        continue;
                    }

                    long key = (i < j) ? MathUtil.GetKey(i, j) : MathUtil.GetKey(j, i);

                    if (pairs.Contains(key))
                    {
                        continue;
                    }

                    pairs.Add(key);

                    //Check order

                    bool   checkEnds0 = L[i].From.DistanceToSquared(L[j].From) < toleranceEnds;
                    bool   checkEnds1 = L[i].From.DistanceToSquared(L[j].To) < toleranceEnds;
                    double t0, t1;

                    if (checkEnds0)
                    {
                        t.T0.Add(0);
                        t.T1.Add(0);
                        t.ID0.Add(-i);
                        t.ID1.Add(-j);
                        t.L0.Add(L[i]);
                        t.L1.Add(L[j]);
                    }
                    else if (checkEnds1)
                    {
                        t.T0.Add(0);
                        t.T1.Add(1);
                        t.ID0.Add(-i);
                        t.ID1.Add(-j);
                        t.L0.Add(L[i]);
                        t.L1.Add(L[j]);
                    }
                    else if (Rhino.Geometry.Intersect.Intersection.LineLine(L[i], L[j], out t0, out t1, tolerance, true))
                    {
                        Line line = new Line(L[i].PointAt(t0), L[j].PointAt(t1));

                        //Identify how lines are connected
                        int EndSide0 = (t0 < toleranceEnds || t0 > 1 - toleranceEnds) ? -1 : 1;
                        int EndSide1 = (t1 < toleranceEnds || t1 > 1 - toleranceEnds) ? -1 : 1;

                        t.T0.Add(t0);
                        t.T1.Add(t1);
                        t.ID0.Add(i * EndSide0);
                        t.ID1.Add(j * EndSide1);
                        t.L0.Add(L[i]);
                        t.L1.Add(L[j]);



                        //Touching - Not Touching
                        //Print(EndSide0.ToString() + " " + EndSide1.ToString());
                    }
                }
            }
        }
コード例 #3
0
        public static List <Line> ClosestLines(this List <Line> L, double tolerance, ref ClosestLinesT t, bool Bbox = true)
        {
            List <Line> lines = new List <Line>();

            HashSet <long> pairs = new HashSet <long>();

            List <int>    pairA   = new List <int>();
            List <int>    pairB   = new List <int>();
            List <double> pairA_T = new List <double>();
            List <double> pairB_T = new List <double>();

            List <Line> pairA_L = new List <Line>();
            List <Line> pairB_L = new List <Line>();


            t = new ClosestLinesT();


            for (int i = 0; i < L.Count; i++)
            {
                for (int j = 0; j < L.Count; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }



                    long key0 = MathUtil.GetKey(i, j);
                    long key1 = MathUtil.GetKey(j, i);

                    if (pairs.Contains(key0))
                    {
                        continue;
                    }

                    pairs.Add(key0);
                    pairs.Add(key1);

                    if (Bbox)
                    {
                        BoundingBox bbox0 = L[i].BoundingBox;
                        BoundingBox bbox1 = L[j].BoundingBox;
                        if (!BoundingBoxUtil.Intersects(bbox0, bbox1))
                        {
                            continue;
                        }
                    }

                    double t0, t1;
                    if (Rhino.Geometry.Intersect.Intersection.LineLine(L[i], L[j], out t0, out t1, tolerance, true))
                    {
                        Line line = new Line(L[i].PointAt(t0), L[j].PointAt(t1));
                        //if(line.Length < tolerance)
                        lines.Add(line);


                        t.T0.Add(t0);
                        t.T1.Add(t1);
                        t.ID0.Add(i);
                        t.ID1.Add(j);
                        t.L0.Add(L[i]);
                        t.L1.Add(L[j]);
                    }
                }
            }



            return(lines);
        }