/// <summary>
        /// Public constructor
        /// </summary>
        public SampleCsDrawArrowheadConduit(OnPlane plane, OnLine line, double scale)
            : base(new MSupportChannels(MSupportChannels.SC_CALCBOUNDINGBOX | MSupportChannels.SC_DRAWOVERLAY), false)
        {
            m_bDraw     = false;
            m_plane     = plane;
            m_line      = line;
            m_arrowhead = new On3dPointArray();

            double x = 0, y = 0;

            m_plane.ClosestPointTo(line.from, ref x, ref y);
            On2dPoint from = new On2dPoint(x, y);

            m_plane.ClosestPointTo(line.to, ref x, ref y);
            On2dPoint to = new On2dPoint(x, y);

            On2dVector dir = new On2dVector(from - to);

            dir.Unitize();

            m_bDraw = GetArrowHead(dir, from, scale, ref m_arrowhead);
        }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            OnLine  line  = new OnLine();
            OnPlane plane = new OnPlane();

            MRhinoGetPoint gp = new MRhinoGetPoint();

            gp.SetCommandPrompt("Start of line");
            gp.GetPoint();
            if (gp.CommandResult() != IRhinoCommand.result.success)
            {
                return(gp.CommandResult());
            }

            line.from = gp.Point();
            plane     = new OnPlane(RhUtil.RhinoActiveCPlane());
            plane.SetOrigin(line.from);

            gp.SetCommandPrompt("End of line");
            gp.Constrain(plane);
            gp.SetBasePoint(line.from);
            gp.DrawLineFromPoint(line.from, true);
            gp.GetPoint();
            if (gp.CommandResult() != IRhinoCommand.result.success)
            {
                return(gp.CommandResult());
            }

            line.to = plane.ClosestPointTo(gp.Point());
            if (!line.IsValid())
            {
                return(IRhinoCommand.result.nothing);
            }

            SampleCsDrawArrowheadConduit conduit = new SampleCsDrawArrowheadConduit(plane, line, 1.0);

            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);
        }
Example #3
0
        private static double GetCurveArea(IOnCurve crv, double tol)
        {
            double area = 0.0;

            if (null != crv && crv.IsClosed())
            {
                OnPlane plane = new OnPlane();
                if (crv.IsPlanar(plane, tol))
                {
                    OnBoundingBox    bbox  = crv.BoundingBox();
                    On3dPoint        point = plane.ClosestPointTo(bbox.Center());
                    OnMassProperties mp    = new OnMassProperties();
                    if (crv.AreaMassProperties(point, plane.Normal(), ref mp))
                    {
                        area = Math.Abs(mp.Area());
                    }
                }
            }
            return(area);
        }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            OnLine line = new OnLine();
              OnPlane plane = new OnPlane();

              MRhinoGetPoint gp = new MRhinoGetPoint();
              gp.SetCommandPrompt("Start of line");
              gp.GetPoint();
              if (gp.CommandResult() != IRhinoCommand.result.success)
            return gp.CommandResult();

              line.from = gp.Point();
              plane = new OnPlane(RhUtil.RhinoActiveCPlane());
              plane.SetOrigin(line.from);

              gp.SetCommandPrompt("End of line");
              gp.Constrain(plane);
              gp.SetBasePoint(line.from);
              gp.DrawLineFromPoint(line.from, true);
              gp.GetPoint();
              if (gp.CommandResult() != IRhinoCommand.result.success)
            return gp.CommandResult();

              line.to = plane.ClosestPointTo(gp.Point());
              if (!line.IsValid())
            return IRhinoCommand.result.nothing;

              SampleCsDrawArrowheadConduit conduit = new SampleCsDrawArrowheadConduit(plane, line, 1.0);
              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;
        }
        /// <summary>
        /// Public constructor
        /// </summary>
        public SampleCsDrawArrowheadConduit(OnPlane plane, OnLine line, double scale)
            : base(new MSupportChannels(MSupportChannels.SC_CALCBOUNDINGBOX | MSupportChannels.SC_DRAWOVERLAY), false)
        {
            m_bDraw = false;
              m_plane = plane;
              m_line = line;
              m_arrowhead = new On3dPointArray();

              double x = 0, y = 0;

              m_plane.ClosestPointTo(line.from, ref x, ref y);
              On2dPoint from = new On2dPoint(x, y);

              m_plane.ClosestPointTo(line.to, ref x, ref y);
              On2dPoint to = new On2dPoint(x, y);

              On2dVector dir = new On2dVector(from - to);
              dir.Unitize();

              m_bDraw = GetArrowHead(dir, from, scale, ref m_arrowhead);
        }
 private static double GetCurveArea(IOnCurve crv, double tol)
 {
     double area = 0.0;
       if (null != crv && crv.IsClosed())
       {
     OnPlane plane = new OnPlane();
     if (crv.IsPlanar(plane, tol))
     {
       OnBoundingBox bbox = crv.BoundingBox();
       On3dPoint point = plane.ClosestPointTo(bbox.Center());
       OnMassProperties mp = new OnMassProperties();
       if (crv.AreaMassProperties(point, plane.Normal(), ref mp))
     area = Math.Abs(mp.Area());
     }
       }
       return area;
 }