Пример #1
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MArgsRhinoGetCircle args   = new MArgsRhinoGetCircle();
            OnCircle            circle = new OnCircle();

            IRhinoCommand.result rc = RhUtil.RhinoGetCircle(args, ref circle);
            if (rc != IRhinoCommand.result.success)
            {
                return(rc);
            }

            SampleCsDrawCircleConduit conduit = new SampleCsDrawCircleConduit(circle);

            conduit.Enable();
            context.m_doc.Redraw();

            MRhinoGetString gs = new MRhinoGetString();

            gs.SetCommandPrompt("Press <Enter> to continue");
            gs.AcceptNothing();
            gs.GetString();

            conduit.Disable();
            context.m_doc.Redraw();

            return(IRhinoCommand.result.success);
        }
Пример #2
0
 bool CalculateCircle(MRhinoViewport vp, ref OnCircle circle)
 {
     if (null != vp)
     {
         double pixels_per_unit = 1.0;
         if (vp.m_v.m_vp.GetWorldToScreenScale(m_circle.Center(), ref pixels_per_unit))
         {
             double units_per_pixel = 1.0 / pixels_per_unit;
             circle.Create(m_circle.plane, m_circle.radius / pixels_per_unit);
             return(circle.IsValid());
         }
     }
     return(false);
 }
Пример #3
0
        public TResult Match <TResult>(OnCircle <TResult> circle,
                                       OnRectangle <TResult> rectangle)
        {
            switch (Tag)
            {
            case ShapeCase.Circle:
                return(circle(Radius));

            case ShapeCase.Rectangle:
                return(rectangle(Height, Width));

            default:
                throw new InvalidOperationException();
            }
        }
 public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate)
 {
     if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX)
       {
     MRhinoViewport vp = dp.GetRhinoVP();
     OnCircle circle = new OnCircle();
     if (CalculateCircle(vp, ref circle))
       m_pChannelAttrs.m_BoundingBox.Union(circle.BoundingBox());
       }
       else if (nChannel == MSupportChannels.SC_DRAWOVERLAY)
       {
     MRhinoViewport vp = dp.GetRhinoVP();
     OnCircle circle = new OnCircle();
     if (CalculateCircle(vp, ref circle))
       vp.DrawCircle(circle);
       }
       return true;
 }
Пример #5
0
 public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate)
 {
     if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX)
     {
         MRhinoViewport vp     = dp.GetRhinoVP();
         OnCircle       circle = new OnCircle();
         if (CalculateCircle(vp, ref circle))
         {
             m_pChannelAttrs.m_BoundingBox.Union(circle.BoundingBox());
         }
     }
     else if (nChannel == MSupportChannels.SC_DRAWOVERLAY)
     {
         MRhinoViewport vp     = dp.GetRhinoVP();
         OnCircle       circle = new OnCircle();
         if (CalculateCircle(vp, ref circle))
         {
             vp.DrawCircle(circle);
         }
     }
     return(true);
 }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MArgsRhinoGetCircle args = new MArgsRhinoGetCircle();
              OnCircle circle = new OnCircle();
              IRhinoCommand.result rc = RhUtil.RhinoGetCircle(args, ref circle);
              if (rc != IRhinoCommand.result.success)
            return rc;

              SampleCsDrawCircleConduit conduit = new SampleCsDrawCircleConduit(circle);
              conduit.Enable();
              context.m_doc.Redraw();

              MRhinoGetString gs = new MRhinoGetString();
              gs.SetCommandPrompt("Press <Enter> to continue");
              gs.AcceptNothing();
              gs.GetString();

              conduit.Disable();
              context.m_doc.Redraw();

              return IRhinoCommand.result.success;
        }
Пример #7
0
        public TResult Match <TResult>(OnCircle <TResult> circle,
                                       OnEquilateralTriangle <TResult> equilateralTriangle,
                                       OnSquare <TResult> onSquare,
                                       OnRectangle <TResult> rectangle)
        {
            switch (Tag)
            {
            case ShapeCase.Circle:
                return(circle(Radius));

            case ShapeCase.EquilateralTriangle:
                return(equilateralTriangle(SideLen));

            case ShapeCase.Square:
                return(onSquare(SideLen));

            case ShapeCase.Rectangle:
                return(rectangle(Height, Width));

            default:
                throw new InvalidOperationException();
            }
        }
Пример #8
0
 public SampleCsDrawCircleConduit(OnCircle circle)
     : base(new MSupportChannels(MSupportChannels.SC_CALCBOUNDINGBOX | MSupportChannels.SC_DRAWOVERLAY), false)
 {
     m_circle = circle;
 }
Пример #9
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            // Define geometry for rail and shape curves
              On3dPoint start_point = new On3dPoint(0, 0, 0);
              On3dPoint end_point = new On3dPoint(10, 0, 0);
              OnPlane plane = new OnPlane(OnUtil.On_yz_plane);

              plane.SetOrigin(start_point);
              OnCircle circle0 = new OnCircle(plane, 5);

              plane.SetOrigin(end_point);
              OnCircle circle1 = new OnCircle(plane, 2);

              // Build rail and shape curves
              OnLineCurve line_curve = new OnLineCurve(start_point, end_point);
              OnArcCurve arc_curve0 = new OnArcCurve(circle0);
              OnArcCurve arc_curve1 = new OnArcCurve(circle1);

              // Build poly edge curve
              MRhinoPolyEdge rail_curve = new MRhinoPolyEdge();
              rail_curve.Create(line_curve);

              // Create sweep arguments
              MArgsRhinoSweep1 args = new MArgsRhinoSweep1();

              // Add rail curve and related settings
              args.m_rail_curve = rail_curve;
              args.m_bHaveRailPickPoint = false;
              args.m_bClosed = false;
              args.m_bUsePivotPoint = false;

              // Add shape curves
              List<OnCurve> shape_curves = new List<OnCurve>();
              shape_curves.Add(arc_curve0);
              shape_curves.Add(arc_curve1);
              args.m_shape_curves = shape_curves.ToArray();

              // Specify parameters on rail closest to shapes
              args.m_rail_params.Append(rail_curve.Domain()[0]);
              args.m_rail_params.Append(rail_curve.Domain()[1]);

              // No starting sweep point
              args.set_m_bUsePoints(0, 0);
              // No ending sweep point
              args.set_m_bUsePoints(1, 0);
              // 0 = Freeform
              args.m_style = 0;
              // 0 = Do Not Simplify
              args.m_simplify = 0;
              // Sample point count for rebuilding shapes
              args.m_rebuild_count = -1;
              // 0 = don't miter
              args.m_miter_type = 0;
              // Standard tolerances
              args.m_refit_tolerance = context.m_doc.AbsoluteTolerance();
              args.m_sweep_tolerance = context.m_doc.AbsoluteTolerance();
              args.m_angle_tolerance = context.m_doc.AngleToleranceRadians();

              OnBrep[] breps = null;
              if (RhUtil.RhinoSweep1(ref args, out breps))
              {
            for (int i = 0; i < breps.Length; i++)
              context.m_doc.AddBrepObject(breps[i]);
            context.m_doc.Redraw();
              }

              return IRhinoCommand.result.success;
        }
Пример #10
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            // Define geometry for rail and shape curves
            On3dPoint start_point = new On3dPoint(0, 0, 0);
            On3dPoint end_point   = new On3dPoint(10, 0, 0);
            OnPlane   plane       = new OnPlane(OnUtil.On_yz_plane);

            plane.SetOrigin(start_point);
            OnCircle circle0 = new OnCircle(plane, 5);

            plane.SetOrigin(end_point);
            OnCircle circle1 = new OnCircle(plane, 2);

            // Build rail and shape curves
            OnLineCurve line_curve = new OnLineCurve(start_point, end_point);
            OnArcCurve  arc_curve0 = new OnArcCurve(circle0);
            OnArcCurve  arc_curve1 = new OnArcCurve(circle1);

            // Build poly edge curve
            MRhinoPolyEdge rail_curve = new MRhinoPolyEdge();

            rail_curve.Create(line_curve);

            // Create sweep arguments
            MArgsRhinoSweep1 args = new MArgsRhinoSweep1();

            // Add rail curve and related settings
            args.m_rail_curve         = rail_curve;
            args.m_bHaveRailPickPoint = false;
            args.m_bClosed            = false;
            args.m_bUsePivotPoint     = false;

            // Add shape curves
            List <OnCurve> shape_curves = new List <OnCurve>();

            shape_curves.Add(arc_curve0);
            shape_curves.Add(arc_curve1);
            args.m_shape_curves = shape_curves.ToArray();

            // Specify parameters on rail closest to shapes
            args.m_rail_params.Append(rail_curve.Domain()[0]);
            args.m_rail_params.Append(rail_curve.Domain()[1]);

            // No starting sweep point
            args.set_m_bUsePoints(0, 0);
            // No ending sweep point
            args.set_m_bUsePoints(1, 0);
            // 0 = Freeform
            args.m_style = 0;
            // 0 = Do Not Simplify
            args.m_simplify = 0;
            // Sample point count for rebuilding shapes
            args.m_rebuild_count = -1;
            // 0 = don't miter
            args.m_miter_type = 0;
            // Standard tolerances
            args.m_refit_tolerance = context.m_doc.AbsoluteTolerance();
            args.m_sweep_tolerance = context.m_doc.AbsoluteTolerance();
            args.m_angle_tolerance = context.m_doc.AngleToleranceRadians();

            OnBrep[] breps = null;
            if (RhUtil.RhinoSweep1(ref args, out breps))
            {
                for (int i = 0; i < breps.Length; i++)
                {
                    context.m_doc.AddBrepObject(breps[i]);
                }
                context.m_doc.Redraw();
            }

            return(IRhinoCommand.result.success);
        }
 bool CalculateCircle(MRhinoViewport vp, ref OnCircle circle)
 {
     if (null != vp)
       {
     double pixels_per_unit = 1.0;
     if (vp.m_v.m_vp.GetWorldToScreenScale(m_circle.Center(), ref pixels_per_unit))
     {
       double units_per_pixel = 1.0 / pixels_per_unit;
       circle.Create(m_circle.plane, m_circle.radius / pixels_per_unit);
       return circle.IsValid();
     }
       }
       return false;
 }
 public SampleCsDrawCircleConduit(OnCircle circle)
     : base(new MSupportChannels(MSupportChannels.SC_CALCBOUNDINGBOX | MSupportChannels.SC_DRAWOVERLAY), false)
 {
     m_circle = circle;
 }