예제 #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));
        }
예제 #2
0
 public override void Reverse()
 {
     curve.Reverse();
 }
예제 #3
0
 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;
 }
예제 #4
0
        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);
        }
예제 #5
0
    /// <example>
    /// <code source='examples\vbnet\ex_sweep1.vb' lang='vbnet'/>
    /// <code source='examples\cs\ex_sweep1.cs' lang='cs'/>
    /// <code source='examples\py\ex_sweep1.py' lang='py'/>
    /// </example>
    public Brep[] PerformSweep(Curve rail, IEnumerable<Curve> crossSections)
    {
      List<double> rail_params = new List<double>();
      Interval domain = rail.Domain;
      foreach (Curve c in crossSections)
      {
        Point3d point_at_start = c.PointAtStart;
        double t;
        rail.ClosestPoint(point_at_start, out t);
        if (t == domain.Max)
          t = domain.Max - RhinoMath.SqrtEpsilon;
        rail_params.Add(t);
      }

      if (rail_params.Count == 1 && Math.Abs(rail_params[0]-rail.Domain.Max)<=RhinoMath.SqrtEpsilon )
      {
        // 27 May 2011 - S. Baer
        // I had to dig through source for quite a while to figure out what is going on, but
        // if there is only one cross section and we are NOT using start/end points, then a
        // rail_param at rail.Domain.Max is appended which completely messes things up when the
        // only shape curve is already at the max domain of the rail.
        rail.Reverse();
        rail_params[0] = rail.Domain.Min;
      }
      return PerformSweep(rail, crossSections, rail_params);
    }