Beispiel #1
0
        /***************************************************/

        private static bool IsSameEdge(this RHG.Curve curve, RHG.BrepEdge edge)
        {
            double tolerance = BHG.Tolerance.Distance;

            RHG.Curve edgeCurve = edge.DuplicateCurve();
            edgeCurve.Reverse();

            RHG.BoundingBox bb1 = curve.GetBoundingBox(false);
            RHG.BoundingBox bb2 = edgeCurve.GetBoundingBox(false);
            if (bb1.Min.DistanceTo(bb2.Min) > tolerance || bb1.Max.DistanceTo(bb2.Max) > tolerance)
            {
                return(false);
            }

            int frameCount = 100;

            RHG.Point3d[] frames1, frames2;
            curve.DivideByCount(frameCount, false, out frames1);
            edgeCurve.DivideByCount(frameCount, false, out frames2);

            return(Enumerable.Range(0, frameCount - 1).All(i => frames1[i].DistanceTo(frames2[i]) <= tolerance));
        }
 public Mesh MeshLoft(Curve c1, Curve c2, int u, int v)
 {
     double[] uList1 = c1.DivideByCount(u, true);
     double[] uList2 = c2.DivideByCount(u, true);
     List<Polyline> input1 = new List<Polyline>();
     for (int i = 0; i < uList1.Length; i++)
     {
         Point3d p1 = c1.PointAt(uList1[i]);
         Point3d p2 = c2.PointAt(uList2[i]);
         Vector3d V = p2 - p1;
         V /= v;
         Polyline pl = new Polyline();
         for (int k = 0; k < v + 1; k++)
         {
             pl.Add(p1 + (V * k));
         }
         input1.Add(pl);
     }
     return MeshLoft(input1, false, false);
 }
 public Mesh TriangleMeshLoft2(Curve c1, Curve c2, int t1, int t2)
 {
     Vector3d v1 = c1.PointAtEnd - c1.PointAtStart;
     Vector3d v2 = c2.PointAtEnd - c2.PointAtStart;
     if (Vector3d.VectorAngle(v1, v2) > Math.PI / 2) { c2.Reverse(); }
     Mesh mesh = new Mesh();
     List<Point3d> ps = new List<Point3d>();
     int Count = t1 - t2;
     double[] t01 = c1.DivideByCount(Count, true);
     double[] t02 = c2.DivideByCount(Count, true);
     for (int i = t2; i <= t1; i++)
     {
         Point3d p1 = c1.PointAt(t01[i - t2]);
         Point3d p2 = c2.PointAt(t02[i - t2]);
         Vector3d v = p2 - p1;
         for (int k = 0; k < i; k++)
         {
             double t3 = 0;
             if (i > 1) { t3 = ((double)k / (double)(i - 1)); }
             ps.Add(p1 + v * t3);
         }
     }
     if (t2 > 1)
     {
         return TriangleMeshFromPoints(ps, t2, t1);
     }
     if (t2 == 1) { return TriangleMeshFromPoints(ps); }
     else return mesh;
 }
        public Mesh TriangleMeshLoft(Curve c1, Curve c2, int t1, int t2)
        {
            //t2>t1;
            Vector3d v1 = c1.PointAtEnd - c1.PointAtStart;
            Vector3d v2 = c2.PointAtEnd - c2.PointAtStart;
            if (Vector3d.VectorAngle(v1, v2) > Math.PI / 2) { c2.Reverse(); }

            List<Point3d> ps = new List<Point3d>();
            double[] t0 = c2.DivideByCount(t2 - 1, true);
            for (int i = 0; i < t0.Length; i++)
            { ps.Add(c2.PointAt(t0[i])); }

            for (int i = t2; i < t1; i++)
            {
                t0 = c2.DivideByCount(i, true);
                double[] t01 = c1.DivideByCount(i, true);
                for (int k = 0; k < t01.Length; k++)
                {
                    Vector3d v = c1.PointAt(t01[k]) - c2.PointAt(t0[k]);
                    v *= (double)((i - t2 + 1)) / (double)(t1 - t2);
                    ps.Add(c2.PointAt(t0[k]) + v);
                }
            }
            return TriangleMeshFromPoints(ps, t2, t1);
        }
 public Mesh TriangleMeshLoft(Curve c1, Point3d c2, int t)
 {
     List<Point3d> ps = new List<Point3d>();
     ps.Add(c2);
     for (int i = 2; i < t + 2; i++)
     {
         double[] t1 = c1.DivideByCount(i - 1, true);
         for (int k = 0; k < t1.Length; k++)
         {
             Vector3d v = c1.PointAt(t1[k]) - c2;
             v *= ((double)i - 1) / (double)t;
             ps.Add(c2 + v);
         }
     }
     return TriangleMeshFromPoints(ps, t + 1);
 }
 public Mesh MeshSweep1(Curve l, Curve l2, int Count, int Count2)
 {
     Polyline ls = new Polyline();
     double[] div = l2.DivideByCount(Count2, true);
     for (int i = 0; i < div.Length; i++)
     {
         ls.Add(l2.PointAt(div[i]));
     }
     return MeshSweep1(l, ls, Count);
 }
        public Mesh MeshSweep1(Curve l, Polyline ls, Plane SectionPos, int Count)
        {
            List<Polyline> ps = new List<Polyline>();
            Mesh mesh = new Mesh();
            double[] div = l.DivideByCount(Count, true);

            for (int i = 0; i < div.Length; i++)
            {
                Polyline l1 = new Polyline(ls);
                Plane plane;
                if (l.PerpendicularFrameAt(div[i], out plane))
                {
                    l1.Transform(Transform.PlaneToPlane(SectionPos, plane));
                    ps.Add(l1);
                }
            }
            mesh.Append(MeshLoft(ps, false, false));
            return mesh;
        }