コード例 #1
0
    public static Rhino.Commands.Result Sweep1(Rhino.RhinoDoc doc)
    {
        Rhino.DocObjects.ObjRef rail_ref;
        var rc = RhinoGet.GetOneObject("Select rail curve", false, Rhino.DocObjects.ObjectType.Curve, out rail_ref);

        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        var rail_crv = rail_ref.Curve();

        if (rail_crv == null)
        {
            return(Rhino.Commands.Result.Failure);
        }

        var gx = new Rhino.Input.Custom.GetObject();

        gx.SetCommandPrompt("Select cross section curves");
        gx.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
        gx.EnablePreSelect(false, true);
        gx.GetMultiple(1, 0);
        if (gx.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gx.CommandResult());
        }

        var cross_sections = new List <Rhino.Geometry.Curve>();

        for (int i = 0; i < gx.ObjectCount; i++)
        {
            var crv = gx.Object(i).Curve();
            if (crv != null)
            {
                cross_sections.Add(crv);
            }
        }
        if (cross_sections.Count < 1)
        {
            return(Rhino.Commands.Result.Failure);
        }

        var sweep = new Rhino.Geometry.SweepOneRail();

        sweep.AngleToleranceRadians = doc.ModelAngleToleranceRadians;
        sweep.ClosedSweep           = false;
        sweep.SweepTolerance        = doc.ModelAbsoluteTolerance;
        sweep.SetToRoadlikeTop();
        var breps = sweep.PerformSweep(rail_crv, cross_sections);

        for (int i = 0; i < breps.Length; i++)
        {
            doc.Objects.AddBrep(breps[i]);
        }
        doc.Views.Redraw();
        return(Rhino.Commands.Result.Success);
    }
コード例 #2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve  iRail    = null;
            Curve  iProfile = null;
            double iX       = 0.0;
            double iY       = 0.0;

            if (!DA.GetData(0, ref iRail))
            {
                return;
            }
            if (!DA.GetData(0, ref iProfile))
            {
                return;
            }
            if (!DA.GetData(1, ref iX))
            {
                return;
            }
            if (!DA.GetData(2, ref iY))
            {
                return;
            }

            Plane pln = new Plane();

            iRail.PerpendicularFrameAt(0.0, out pln);
            var rect = new Rectangle3d(pln, iX, iY);

            Plane Orig   = new Plane(0, 0, 1, 0);
            var   xform1 = Rhino.Geometry.Transform.PlaneToPlane(Orig, pln);


            var rectC = rect.ToNurbsCurve();

            if (iProfile != null)
            {
                iProfile.Transform(xform1);
                rectC = iProfile.ToNurbsCurve();
            }

            var sweep = new Rhino.Geometry.SweepOneRail();

            sweep.AngleToleranceRadians = 0.017453;
            sweep.ClosedSweep           = false;
            sweep.SweepTolerance        = 0.001;
            sweep.SetToRoadlikeTop();
            var breps = sweep.PerformSweep(iRail, rectC);

            DA.SetDataList(0, breps);
        }
コード例 #3
0
ファイル: ex_sweep1.cs プロジェクト: austinlaw/rhinocommon
  public static Rhino.Commands.Result Sweep1(Rhino.RhinoDoc doc)
  {
    Rhino.DocObjects.ObjRef rail_ref;
    var rc = RhinoGet.GetOneObject("Select rail curve", false, Rhino.DocObjects.ObjectType.Curve, out rail_ref);
    if(rc!=Rhino.Commands.Result.Success)
      return rc;

    var rail_crv = rail_ref.Curve();
    if( rail_crv==null )
      return Rhino.Commands.Result.Failure;

    var gx = new Rhino.Input.Custom.GetObject();
    gx.SetCommandPrompt("Select cross section curves");
    gx.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
    gx.EnablePreSelect(false, true);
    gx.GetMultiple(1,0);
    if( gx.CommandResult() != Rhino.Commands.Result.Success )
      return gx.CommandResult();
    
    var cross_sections = new List<Rhino.Geometry.Curve>();
    for( int i=0; i<gx.ObjectCount; i++ )
    {
      var crv = gx.Object(i).Curve();
      if( crv!= null)
        cross_sections.Add(crv);
    }
    if( cross_sections.Count<1 )
      return Rhino.Commands.Result.Failure;

    var sweep = new Rhino.Geometry.SweepOneRail();
    sweep.AngleToleranceRadians = doc.ModelAngleToleranceRadians;
    sweep.ClosedSweep = false;
    sweep.SweepTolerance = doc.ModelAbsoluteTolerance;
    sweep.SetToRoadlikeTop();
    var breps = sweep.PerformSweep(rail_crv, cross_sections);
    for( int i=0; i<breps.Length; i++ )
      doc.Objects.AddBrep(breps[i]);
    doc.Views.Redraw();
    return Rhino.Commands.Result.Success;
  }