Exemplo n.º 1
0
 public void CurveCP(Brep x, Curve y, int V, int U)
 {
     int u = bitmap1.Size.Width;
     int v = bitmap1.Size.Height;
     Graphics g = Graphics.FromImage(bitmap1);
     g.FillRectangle(new SolidBrush(Color.White), 0, 0, u, v);
     System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(Color.Black);
     float step1 = u / U;
     float step2 = v / V;
     for (float i = 25; i < u - 25; i += step1)
     {
         for (float j = 25; j < v - 25; j += step2)
         {
             double Umin = x.Faces[0].Domain(0).Min;
             double Umax = x.Faces[0].Domain(0).Max;
             double Vmin = x.Faces[0].Domain(1).Min;
             double Vmax = x.Faces[0].Domain(1).Max;
             Point3d pos = x.Faces[0].PointAt(i / u * (Umax - Umin) + Umin, j / v * (Vmax - Vmin) + Vmin);
             double t; float R;
             if (y.ClosestPoint(pos, out t, 200))
             {
                 double dis = y.PointAt(t).DistanceTo(pos);
                 dis /= 200;
                 R = (float)(1 / dis * 2);
                 if (R > 40) R = 40;
             }
             else { R = 20; }
             g.FillEllipse(myBrush, i - R, v - j - R, R * 2, R * 2);
         }
     }
     myBrush.Dispose();
     g.Dispose();
 }
 private static void NextintersectParamAndPoint(Curve[] overlapCurves, Point3d[] intersectPoints,
 Curve curve, out double intersectParam, out Point3d intersectPoint)
 {
     var intersect_params_and_points = new Dictionary<double, Point3d>();
     foreach (var point in intersectPoints)
     {
       double curve_param;
       curve.ClosestPoint(point, out curve_param);
       intersect_params_and_points[curve_param] = point;
     }
     foreach (var overlap_curve in overlapCurves)
     {
       intersect_params_and_points[overlap_curve.Domain.Min] = overlap_curve.PointAt(overlap_curve.Domain.Min);
       intersect_params_and_points[overlap_curve.Domain.Max] = overlap_curve.PointAt(overlap_curve.Domain.Max);
     }
     var min_t = intersect_params_and_points.Keys.Min();
     intersectParam = min_t;
     intersectPoint = intersect_params_and_points[intersectParam];
 }
Exemplo n.º 3
0
 public Brep[] PerformSweepRebuild(Curve rail, IEnumerable<Curve> crossSections, int rebuildCount)
 {
   List<double> rail_params = new List<double>();
   foreach (Curve c in crossSections)
   {
     Point3d point_at_start = c.PointAtStart;
     double t;
     rail.ClosestPoint(point_at_start, out t);
     rail_params.Add(t);
   }
   return PerformSweepRebuild(rail, crossSections, rail_params, rebuildCount);
 }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
0
 public Brep[] PerformSweepRefit(Curve rail1, Curve rail2, IEnumerable<Curve> crossSections, double refitTolerance)
 {
   List<double> rail_params1 = new List<double>();
   List<double> rail_params2 = new List<double>();
   foreach (Curve c in crossSections)
   {
     Point3d point_at_start = c.PointAtStart;
     double t;
     rail1.ClosestPoint(point_at_start, out t);
     rail_params1.Add(t);
     rail2.ClosestPoint(point_at_start, out t);
     rail_params2.Add(t);
   }
   return PerformSweepRefit(rail1, rail2, crossSections, rail_params1, rail_params2, refitTolerance);
 }
Exemplo n.º 6
0
    public Brep[] PerformSweep(Curve rail1, Curve rail2, IEnumerable<Curve> crossSections)
    {
      List<double> rail_params1 = new List<double>();
      List<double> rail_params2 = new List<double>();
      Interval domain1 = rail1.Domain;
      Interval domain2 = rail2.Domain;
      foreach (Curve c in crossSections)
      {
        Point3d point_at_start = c.PointAtStart;
        double t;
        rail1.ClosestPoint(point_at_start, out t);
        if (t == domain1.Max)
          t = domain1.Max - RhinoMath.SqrtEpsilon;
        rail_params1.Add(t);

        rail2.ClosestPoint(point_at_start, out t);
        if (t == domain2.Max)
          t = domain2.Max - RhinoMath.SqrtEpsilon;
        rail_params2.Add(t);
      }

      // NOTE: See if we need to do anything special in a rail_params1.Count==1 case
      // like we do in the Sweep1 counterpart function
      return PerformSweep(rail1, rail2, crossSections, rail_params1, rail_params2);
    }
Exemplo n.º 7
0
    private void RunScript(Brep x, Curve y, int V, int U, ref object A)
    {
        Graphics g = Graphics.FromImage(bitmap1);
        g.FillRectangle(new SolidBrush(Color.White), 0, 0, u, v);
        System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(Color.Black);

        float step1 = u / U;
        float step2 = v / V;
        for (float i = 25; i < u - 25; i += step1)
        {
            for (float j = 25; j < v - 25; j += step2)
            {
                double Umin = x.Faces[0].Domain(0).Min;
                double Umax = x.Faces[0].Domain(0).Max;
                double Vmin = x.Faces[0].Domain(1).Min;
                double Vmax = x.Faces[0].Domain(1).Max;
                Point3d pos = x.Faces[0].PointAt(i / u * (Umax - Umin) + Umin, j / v * (Vmax - Vmin) + Vmin);
                double t; float R;
                if (y.ClosestPoint(pos, out t, 200))
                {
                    double dis = y.PointAt(t).DistanceTo(pos);
                    dis /= 200;
                    R = (float)(1 / dis * 2);
                    //  Print(R.ToString());
                    if (R > 40) R = 40;
                    ;
                }
                else { R = 20; }
                g.FillEllipse(myBrush, i - R, v - j - R, R * 2, R * 2);
            }
        }

        myBrush.Dispose();
        str = @"C:\maps\temp1.jpg";
        bitmap1.Save(str);
        Print(str);
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        Mesh[] meshes = Mesh.CreateFromBrep(x, MeshingParameters.Smooth);
        Mesh M = new Mesh();
        foreach (Mesh partialMesh in meshes)
        {
            M.Append(partialMesh);
        }
        m_shapes.Add(M);

        Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial();
        mat.SetTransparencyTexture(str, true);
        mat.BackTransparency = 0;
        m_materials.Clear();
        m_materials.Add(mat);
    }
        private Vector3d CalcDeformedTangent(Curve c, Point3d pt)
        {
            double t;
            if (!c.ClosestPoint(pt, out t))
                throw new Exception();

            else
                return c.TangentAt(t);
        }
        private double computeBiasHeight(Point3d P, bool biasApicalRegions, Curve boundaryCurve)
        {
            double t;
            boundaryCurve.ClosestPoint(P, out t);
            double minDist = Utils.Distance(P, boundaryCurve.PointAt(t));

            if (biasApicalRegions)
                foreach (Circle apical in iApicals)
                {
                    double dist = Utils.Distance(P, apical.Center) - (apical.Radius + 0.1);
                    if (dist < 0.0) dist = 0.0;

                    if (dist < minDist)
                        minDist = dist;
                }

            return iInitialCurvingBias * (1.0 - Math.Pow(0.9, minDist * 15.0));
        }