protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Pick a mesh
            ObjRef obj_ref;
            Result rc = RhinoGet.GetOneObject("Select mesh", false, ObjectType.Mesh, out obj_ref);

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

            Rhino.Geometry.Mesh mesh = obj_ref.Mesh();
            if (null == mesh)
            {
                return(Result.Failure);
            }

            // Pick a point that is contrained to the mesh
            GetPoint gp = new GetPoint();

            gp.SetCommandPrompt("Pick point on mesh");
            gp.Constrain(mesh, false);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            Point3d point = gp.Point();

            doc.Objects.AddPoint(point);
            doc.Views.Redraw();

            return(Result.Success);
        }
예제 #2
0
파일: move.cs 프로젝트: Choi33/GrowGrow
 // Use this for initialization
 void Start()
 {
     rb   = GetComponent <Rigidbody2D>();
     Gp   = GameObject.Find("PrintPoint").GetComponent <GetPoint>();
     pro  = GameObject.Find("ProblemText").GetComponent <Problem>();
     pref = GameObject.Find("ApplePrefab").GetComponent <ApplePrefab>();
 }
예제 #3
0
        public static Result GetSpawn()
        {
            Point3d pt1;

            // string spawn = "0,0,0";

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Please select your character's spawn point");
                if (getPointAction.Get() != GetResult.Point)
                {
                    RhinoApp.WriteLine("No spawn point selected");
                    return(getPointAction.CommandResult());
                }
                pt1 = getPointAction.Point();
                //spawn = pt1.ToString();
                string username  = Environment.UserName;
                string directory = String.Format(@"C:\Users\{0}\AppData\Roaming\SecondStudio", username);
                System.IO.Directory.CreateDirectory(directory);
                string path = String.Format(@"C:\Users\{0}\AppData\Roaming\SecondStudio\spawn.xml", username);
                using (XmlWriter writer = XmlWriter.Create(path))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement("Spawn");

                    writer.WriteElementString("Location", pt1.ToString());


                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                }
            }
            RhinoApp.WriteLine(pt1.ToString());
            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var gp = new GetPoint();

            gp.SetCommandPrompt("Point to draw from");
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            var pt = gp.Point();

            var gd = new GetDirection();

            gd.SetCommandPrompt("Point to draw to");
            gd.SetBasePoint(pt, true);
            gd.DrawArrowFromPoint(pt, true, true);
            gd.Get();
            if (gd.CommandResult() != Result.Success)
            {
                return(gd.CommandResult());
            }

            // TODO...

            return(Result.Success);
        }
예제 #5
0
 public static int SceneSelect(object[] l, GetPoint getPoint, SetPoint setPoint, Event e, int psel, GUIStyle butStyle)
 {
     for (int i = 0; i < l.Length; i++)
     {
         Vector3 p  = getPoint(l[i]);
         Vector2 p2 = HandleUtility.WorldToGUIPoint(p);
         if (e.type == EventType.mouseDown && e.button == 0)
         {
             float d = Vector3.Distance(p2, e.mousePosition);
             if (d < 15)
             {
                 psel = i;
             }
         }
         if (psel == i)
         {
             Vector3 p0 = Handles.PositionHandle(p, Quaternion.identity);
             if ((p0 - p).magnitude > 1e-3)
             {
                 setPoint(p0, i);
             }
             Handles.BeginGUI();
             if (GUI.Button(new Rect(p2.x + 10, p2.y + 10, 20, 20), "X", butStyle))
             {
                 psel = -1;
             }
             Handles.EndGUI();
         }
     }
     return(psel);
 }
예제 #6
0
    public static Result GetAngle(RhinoDoc doc)
    {
        var gp = new GetPoint();

        gp.SetCommandPrompt("Base point");
        gp.Get();
        if (gp.CommandResult() != Result.Success)
        {
            return(gp.CommandResult());
        }
        var base_point = gp.Point();

        gp.SetCommandPrompt("First reference point");
        gp.DrawLineFromPoint(base_point, true);
        gp.Get();
        if (gp.CommandResult() != Result.Success)
        {
            return(gp.CommandResult());
        }
        var first_point = gp.Point();

        double angle_radians;
        var    rc = RhinoGet.GetAngle("Second reference point", base_point, first_point, 0, out angle_radians);

        if (rc == Result.Success)
        {
            RhinoApp.WriteLine("Angle = {0} degrees", RhinoMath.ToDegrees(angle_radians));
        }

        return(rc);
    }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Point3d basePt;
            Result  rc = RhinoGet.GetPoint("Start of line", false, out basePt);

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

            GetPoint gp = new GetPoint();

            gp.SetCommandPrompt("End of line");
            gp.SetBasePoint(basePt, true);
            gp.DrawLineFromPoint(basePt, true);
            gp.DynamicDraw += new EventHandler <GetPointDrawEventArgs>(gp_DynamicDraw);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            Point3d endPt = gp.Point();

            Rhino.Geometry.Vector3d vector = endPt - basePt;
            if (vector.Length > doc.ModelAbsoluteTolerance)
            {
                Line line = new Line(basePt, endPt);
                doc.Objects.AddLine(line);
                doc.Views.Redraw();
            }

            return(Result.Success);
        }
예제 #8
0
        public override Line EnterLine(string startPointPrompt = "Enter start of line", string endPointPrompt = "Enter end of line", Vector?startPoint = null)
        {
            /*GetLine gL = new GetLine();
             * gL.FirstPointPrompt = startPointPrompt;
             * gL.SecondPointPrompt = endPointPrompt;
             * if (startPoint != null) gL.SetFirstPoint(FBtoRC.Convert(startPoint ?? Vector.Unset));
             * RC.Line output;
             * if (gL.Get(out output) == Result.Cancel) throw new OperationCanceledException("Operation cancelled by user");
             * return RCtoFB.Convert(output);*/
            GetPoint gP = new GetPoint();

            gP.SetCommandPrompt(startPointPrompt);
            if (gP.Get() == GetResult.Cancel)
            {
                throw new OperationCanceledException("Operation cancelled by user");
            }
            GetPoint gP2 = new GetPointDynamic();

            gP2.SetCommandPrompt(endPointPrompt);
            gP2.SetBasePoint(gP.Point(), true);
            gP2.EnableDrawLineFromPoint(true);
            gP2.DrawLineFromPoint(gP.Point(), true);
            if (gP2.Get() == GetResult.Cancel)
            {
                throw new OperationCanceledException("Operation cancelled by user");
            }
            return(new Line(FromRC.Convert(gP.Point()), FromRC.Convert(gP2.Point())));
        }
예제 #9
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var count = 0;

            var gp = new GetPoint();

            gp.AcceptNothing(true);
            for (; ;)
            {
                gp.SetCommandPrompt(0 == count ? "Location of text dot" : "Location of text dot. Press Enter when done");

                var res = gp.Get();

                if (res == GetResult.Point)
                {
                    var point = gp.Point();
                    var str   = count.ToString(CultureInfo.InvariantCulture);
                    var dot   = new TextDot(str, point);
                    doc.Objects.Add(dot);
                    doc.Views.Redraw();
                    count++;
                    continue;
                }

                break;
            }

            return(Result.Success);
        }
예제 #10
0
 public MainWindow()
 {
     CurrentPoint = new GetPoint(10, 20, 0);
     bgThread     = new Thread(handle);
     bgThread.Start();
     InitializeComponent();
 }
예제 #11
0
        public void RegisterOnETEventTest()
        {
            ManualResetEvent recieved = new ManualResetEvent(false);
            GetPoint         point    = new GetPoint(-1, -1, -1);

            Assert.AreEqual(-1, point.X);
            Assert.AreEqual(-1, point.Y);
            Assert.AreEqual(-1, point.Timestamp);

            tracker.RegisterOnETEvent(delegate(GetPoint p)
            {
                point = p;
                recieved.Set();
            }
                                      );

            tracker.Enable(null);

            recieved.WaitOne();
            Assert.IsTrue(point.X >= 0);
            Assert.IsTrue(point.X <= 1);

            Assert.IsTrue(point.Y >= 0);
            Assert.IsTrue(point.Y <= 1);

            // Beware of this test. Depending on the implementation,
            // the "zero" point might be in the future.
            // No implementation I know of has this, but the possibility exists.
            // If this is the case, disregard this test.
            Assert.IsTrue(point.Timestamp > 0);
        }
예제 #12
0
        bool SelectHeight()
        {
            using (var cmd = new GetPoint())
            {
                cmd.SetCommandPrompt("Select the Height");
                cmd.AcceptNumber(true, true);
                cmd.SetDefaultNumber(DefaultHeight);

                var r = cmd.Get();
                switch (r)
                {
                case Rhino.Input.GetResult.Number:
                    m_height      = cmd.Number();
                    DefaultHeight = m_height;
                    break;

                case Rhino.Input.GetResult.Point:
                    m_height = cmd.Point().Z - m_basePoint.Z;
                    break;

                default:
                    return(false);
                }

                return(true);
            }
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Point3d base_pt;
            var     rc = RhinoGet.GetPoint("Start of line", false, out base_pt);

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

            var gp = new GetPoint();

            gp.SetCommandPrompt("End of line");
            gp.SetBasePoint(base_pt, true);
            gp.DrawLineFromPoint(base_pt, true);
            gp.DynamicDraw += gp_DynamicDraw;
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            var end_pt = gp.Point();
            var vector = end_pt - base_pt;

            if (vector.Length > doc.ModelAbsoluteTolerance)
            {
                var line = new Line(base_pt, end_pt);
                doc.Objects.AddLine(line);
                doc.Views.Redraw();
            }

            return(Result.Success);
        }
예제 #14
0
        private GetPoint Henshin(IGazeDataItem gazeDataItem)
        {
            int      leftValidity  = gazeDataItem.LeftValidity;
            int      rightValidity = gazeDataItem.RightValidity;
            Point2D  left          = gazeDataItem.LeftGazePoint2D;
            Point2D  right         = gazeDataItem.RightGazePoint2D;
            GetPoint answer        = new GetPoint();

            if (leftValidity == BEST_VALIDITY && rightValidity == BEST_VALIDITY)
            {
                eye_distance = new Point2D(right.X - left.X, right.Y - left.Y);
            }
            else if (leftValidity == BEST_VALIDITY)
            {
                right.X = left.X + eye_distance.X;
                right.Y = left.Y + eye_distance.Y;
            }
            else if (rightValidity == BEST_VALIDITY)
            {
                left.X = right.X - eye_distance.X;
                left.Y = right.Y - eye_distance.Y;
            }
            else
            {
            }

            answer.X = (left.X + right.X) / 2;
            answer.Y = (left.Y + right.Y) / 2;
            return(answer);
        }
예제 #15
0
        public static Vector3 catmullRomGetPt(
            GetPoint getFromCollection, int collectionLength, int i, float percentage, bool pathClosed
            )
        {
            if (collectionLength < 4)
            {
                pathClosed = false;
            }
            var maxASegmentIndex = collectionLength - 1;
            var a1 = pathClosed ? i - 1 < 0 ? maxASegmentIndex : i - 1 : Mathf.Clamp(i - 1, 0, maxASegmentIndex);
            var a2 = i;
            var a3 = pathClosed ? (i + 1) % maxASegmentIndex : Mathf.Clamp(i + 1, 0, maxASegmentIndex);
            var a4 = pathClosed ? (i + 2) % maxASegmentIndex : Mathf.Clamp(i + 2, 0, maxASegmentIndex);

            if (i == collectionLength - 2 && pathClosed)
            {
                a1 = collectionLength - 3;
                a2 = i;
                a3 = 0;
                a4 = 1;
            }
            if (i == 0 && pathClosed)
            {
                a1 = collectionLength - 2;
                a2 = 0;
                a3 = 1;
                a4 = 2;
            }

            return(new Vector3(
                       catmullRom(getFromCollection(a1).x, getFromCollection(a2).x, getFromCollection(a3).x, getFromCollection(a4).x, percentage),
                       catmullRom(getFromCollection(a1).y, getFromCollection(a2).y, getFromCollection(a3).y, getFromCollection(a4).y, percentage),
                       catmullRom(getFromCollection(a1).z, getFromCollection(a2).z, getFromCollection(a3).z, getFromCollection(a4).z, percentage)
                       ));
        }
예제 #16
0
        public static Vector3 hermiteGetPt(
            GetPoint getFromCollection, int collectionLength, int i, float aPercentage, bool aClosed, float aTension = 0, float aBias = 0
            )
        {
            if (collectionLength < 4)
            {
                aClosed = false;
            }

            var a1 = aClosed ? i - 1 < 0 ? collectionLength - 2 : i - 1 : Mathf.Clamp(i - 1, 0, collectionLength - 1);
            var a2 = i;
            var a3 = aClosed ? (i + 1) % collectionLength : Mathf.Clamp(i + 1, 0, collectionLength - 1);
            var a4 = aClosed ? (i + 2) % collectionLength : Mathf.Clamp(i + 2, 0, collectionLength - 1);

            if (i == collectionLength - 2 && aClosed)
            {
                a1 = collectionLength - 3;
                a2 = i;
                a3 = 0;
                a4 = 1;
            }
            if (i == 0 && aClosed)
            {
                a1 = collectionLength - 2;
                a2 = 0;
                a3 = 1;
                a4 = 2;
            }

            return(new Vector3(
                       hermite(getFromCollection(a1).x, getFromCollection(a2).x, getFromCollection(a3).x, getFromCollection(a4).x, aPercentage, aTension, aBias),
                       hermite(getFromCollection(a1).y, getFromCollection(a2).y, getFromCollection(a3).y, getFromCollection(a4).y, aPercentage, aTension, aBias),
                       hermite(getFromCollection(a1).z, getFromCollection(a2).z, getFromCollection(a3).z, getFromCollection(a4).z, aPercentage, aTension, aBias)));
        }
예제 #17
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            UsefulFunctions.XSelectCurves("Select curves for linear dimensioning", out CurveList curves);

            //var lines = new RhinoList<Line>();

            //for (var i = 0; i < curves.Count; i++)
            //{
            //    lines.Add(new Line(curves[i].PointAtStart, curves[i].PointAtEnd));
            //}



            //get the user to select a point

            var gp = new GetPoint();

            string prompt;

            prompt = "Pick a point";

            gp.SetCommandPrompt(prompt);


            gp.Get();

            Point3d pt = gp.Point();

            foreach (var curve in curves)
            {
                Point3d origin = curve.PointAtStart;
                Point3d offset = curve.PointAtEnd;

                //Vector3d linevec = new Vector3d(offset - origin);

                // you can rotate vector so its perp. with the line...


                Plane plane = Plane.WorldXY;

                plane.Origin = origin;

                double u, v;
                plane.ClosestParameter(origin, out u, out v);
                Point2d ext1 = new Point2d(u, v);

                plane.ClosestParameter(offset, out u, out v);
                Point2d ext2 = new Point2d(u, v);

                plane.ClosestParameter(pt, out u, out v);
                Point2d linePt = new Point2d(u, v);

                LinearDimension lindim = new LinearDimension(plane, ext1, ext2, linePt);

                doc.Objects.AddLinearDimension(lindim);
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var conduit = new SampleCsGetMultiplePointsConduit {
                Enabled = true
            };

            Result rc;

            var gp = new GetPoint();

            while (true)
            {
                if (0 == conduit.PointCount)
                {
                    gp.SetCommandPrompt("Location of point object.");
                    gp.AcceptNothing(false);
                    gp.AcceptUndo(false);
                }
                else
                {
                    gp.SetCommandPrompt("Location of point object. Press Enter when done");
                    gp.AcceptNothing(true);
                    gp.AcceptUndo(true);
                }

                var res = gp.Get();

                if (res == GetResult.Point)
                {
                    conduit.AddPoint(gp.Point());
                    doc.Views.Redraw();
                }
                else if (res == GetResult.Undo)
                {
                    conduit.RemoveLastPoint();
                    doc.Views.Redraw();
                }
                else if (res == GetResult.Nothing)
                {
                    rc = Result.Success;
                    break;
                }
                else
                {
                    rc = Result.Cancel;
                    break;
                }
            }

            if (rc == Result.Success && conduit.PointCount > 0)
            {
                doc.Objects.AddPoints(conduit.Points);
            }

            conduit.Enabled = false;
            doc.Views.Redraw();

            return(rc);
        }
예제 #19
0
        public string GetPoint(int caseid)
        {
            string   username = User.Identity.Name;
            GetPoint dbpoint  = new GetPoint();
            string   result   = dbpoint.GetSinglePoint(username, caseid);

            return(result);
        }
예제 #20
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var gp = new GetPoint();

            gp.SetCommandPrompt("Location of point object");
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            var point = gp.Point();

            var point_id = MooseCommon.Utility.AddPoint(point);

            if (!Equals(point_id, Guid.Empty))
            {
                doc.Views.Redraw();

                var uuid_str = point_id.ToString();
                var str      = $"Identifier of point object is \"{uuid_str}\"";
                MooseCommon.Utility.Print(str);
            }


            var       sphere = new Sphere(Point3d.Origin, 5);
            var       brep   = sphere.ToBrep();
            const int x      = 1;
            const int y      = 2;
            var       rc     = MooseCommon.Utility.ExampleFunction(brep, x, y, out var points, out var lines);

            if (rc > 0)
            {
                foreach (var p in points)
                {
                    doc.Objects.AddPoint(p);
                }
                foreach (var l in lines)
                {
                    doc.Objects.AddLine(l);
                }
                doc.Views.Redraw();
            }


            var polylines = MooseCommon.Utility.ExampleGetPolylines();

            foreach (var pline in polylines)
            {
                doc.Objects.AddPolyline(pline);
            }
            doc.Views.Redraw();

            return(Result.Success);
        }
예제 #21
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var gp = new GetPoint();

            gp.SetCommandPrompt("Start point");
            gp.AddOptionEnumList("Justification", m_justification);
            gp.ConstrainToConstructionPlane(false);
            for (;;)
            {
                var res = gp.Get();
                if (res == GetResult.Option)
                {
                    var option = gp.Option();
                    if (null != option)
                    {
                        var list = Enum.GetValues(typeof(TextJustification)).Cast <TextJustification>().ToList();
                        m_justification = list[option.CurrentListOptionIndex];
                    }
                    continue;
                }
                if (res != GetResult.Point)
                {
                    return(Result.Cancel);
                }
                break;
            }

            var point = gp.Point();

            var plane = gp.View().ActiveViewport.ConstructionPlane();

            plane.Origin = point;

            var text = new TextEntity
            {
                Plane         = plane,
                Justification = m_justification
            };

            text.PlainText = text.Justification.ToString();

            var attr = new ObjectAttributes
            {
                ColorSource = ObjectColorSource.ColorFromObject,
                ObjectColor = Color.FromArgb(0, 0, 255)
            };

            var object_id = doc.Objects.AddText(text, attr);

            RhinoApp.WriteLine("{0}", object_id.ToString());

            doc.Views.Redraw();

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var go = new GetObject();

            go.SetCommandPrompt("Select grips to move");
            go.GeometryFilter = ObjectType.Grip;
            go.EnablePreSelect(true, true);
            go.GetMultiple(1, 0);
            if (go.CommandResult() != Result.Success)
            {
                return(go.CommandResult());
            }

            var gp = new GetPoint();

            gp.SetCommandPrompt("Point to move from");
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            var from = gp.Point();

            gp.SetCommandPrompt("Point to move to");
            gp.SetBasePoint(from, true);
            gp.DrawLineFromPoint(from, true);
            gp.Get();
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            var to = gp.Point();

            var dir = to - from;

            if (dir.IsTiny(doc.ModelAbsoluteTolerance))
            {
                return(Result.Nothing);
            }

            var xform = Transform.Translation(dir);

            var helper = new SampleCsGripHelper(doc);

            helper.AddGripObjects(go);
            helper.TransformAndUpdate(xform);

            doc.Views.Redraw();

            return(Result.Success);
        }
예제 #23
0
        public override Vector EnterVector(string prompt = "Enter vector")
        {
            //TODO: Get direction
            GetPoint gP = new GetPoint();

            gP.SetCommandPrompt(prompt);
            if (gP.Get() == GetResult.Cancel)
            {
                throw new OperationCanceledException("Operation cancelled by user");
            }
            return(FromRC.Convert(gP.Point()));
        }
    public static Result DetermineNormalDirectionOfBrepFace(RhinoDoc doc)
    {
        // select a surface
        var gs = new GetObject();

        gs.SetCommandPrompt("select surface");
        gs.GeometryFilter = ObjectType.Surface;
        gs.DisablePreSelect();
        gs.SubObjectSelect = false;
        gs.Get();
        if (gs.CommandResult() != Result.Success)
        {
            return(gs.CommandResult());
        }
        // get the selected face
        var face = gs.Object(0).Face();

        if (face == null)
        {
            return(Result.Failure);
        }

        // pick a point on the surface.  Constain
        // picking to the face.
        var gp = new GetPoint();

        gp.SetCommandPrompt("select point on surface");
        gp.Constrain(face, false);
        gp.Get();
        if (gp.CommandResult() != Result.Success)
        {
            return(gp.CommandResult());
        }

        // get the parameters of the point on the
        // surface that is clesest to gp.Point()
        double u, v;

        if (face.ClosestPoint(gp.Point(), out u, out v))
        {
            var direction = face.NormalAt(u, v);
            if (face.OrientationIsReversed)
            {
                direction.Reverse();
            }
            RhinoApp.WriteLine(
                string.Format(
                    "Surface normal at uv({0:f},{1:f}) = ({2:f},{3:f},{4:f})",
                    u, v, direction.X, direction.Y, direction.Z));
        }
        return(Result.Success);
    }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Loop loop = new Loop();

            loop.Run(doc);

            return(Result.Success);

            // TODO: start here modifying the behaviour of your command.
            // ---
            RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName);

            Point3d pt0;

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Please select the start point");
                if (getPointAction.Get() != GetResult.Point)
                {
                    RhinoApp.WriteLine("No start point was selected.");
                    return(getPointAction.CommandResult());
                }
                pt0 = getPointAction.Point();
            }

            Point3d pt1;

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Please select the end point");
                getPointAction.SetBasePoint(pt0, true);
                getPointAction.DynamicDraw +=
                    (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed);
                if (getPointAction.Get() != GetResult.Point)
                {
                    RhinoApp.WriteLine("No end point was selected.");
                    return(getPointAction.CommandResult());
                }
                pt1 = getPointAction.Point();
            }

            doc.Objects.AddLine(pt0, pt1);
            doc.Views.Redraw();
            RhinoApp.WriteLine("The {0} command added one line to the document.", EnglishName);

            // ---

            return(Result.Success);
        }
예제 #26
0
        private void et_GazeDataRecieved(object sender, GazeDataEventArgs e)
        {
            if (e.GazeDataItem.RightValidity != BEST_VALIDITY && e.GazeDataItem.LeftValidity != BEST_VALIDITY)
            {
                return;
            }

            GetPoint point = Henshin(e.GazeDataItem);

            point.Timestamp = e.GazeDataItem.Timestamp;

            if (EtEventHandlers != null)
            {
                EtEventHandlers(point);
            }
        }
예제 #27
0
        static float getApproxSegmentLength(int resolution, GetPoint getPt)
        {
            var oldPoint     = getPt(0f);
            var splineLength = 0f;

            for (var i = 1; i <= resolution; i++)
            {
                var percentage = (float)i / resolution;
                var newPoint   = getPt(percentage);
                var dist       = Vector3.Distance(oldPoint, newPoint);
                splineLength += dist;
                oldPoint      = newPoint;
            }

            return(splineLength);
        }
예제 #28
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef objref;
            var    rc = RhinoGet.GetOneObject("Select object to move", false, ObjectType.AnyObject, out objref);

            if (rc != Result.Success)
            {
                return(rc);
            }
            if (null == objref)
            {
                return(Result.Failure);
            }

            Point3d first_point;

            rc = RhinoGet.GetPoint("Point to move from", false, out first_point);
            if (rc != Result.Success)
            {
                return(rc);
            }

            var gp = new GetPoint();

            gp.SetCommandPrompt("Point to move to");
            gp.SetBasePoint(first_point, true);
            gp.DrawLineFromPoint(first_point, true);
            gp.Get();
            rc = gp.CommandResult();
            if (rc != Result.Success)
            {
                return(rc);
            }

            var second_point = gp.Point();

            var dir = second_point - first_point;

            if (dir.Length > RhinoMath.ZeroTolerance)
            {
                var xform = Transform.Translation(dir);
                doc.Objects.Transform(objref, xform, true);
                doc.Views.Redraw();
            }

            return(rc);
        }
예제 #29
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Point3d pt0;

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Please select the plane origin.");

                if (getPointAction.Get() != GetResult.Point)
                {
                    RhinoApp.WriteLine("No plane origin was selected.");
                    return(getPointAction.CommandResult());
                }
                pt0 = getPointAction.Point();
            }

            Point3d pt1;

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Please select a point on the new X-axis.");
                if (getPointAction.Get() != GetResult.Point)
                {
                    RhinoApp.WriteLine("No point was selected.");
                    return(getPointAction.CommandResult());
                }
                pt1 = getPointAction.Point();
            }

            Point3d pt2;

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Please select a point on the new Y-axis.");
                if (getPointAction.Get() != GetResult.Point)
                {
                    RhinoApp.WriteLine("No point was selected.");
                    return(getPointAction.CommandResult());
                }
                pt2 = getPointAction.Point();
            }

            Plane plane = new Plane(pt0, pt1, pt2);

            RNNPlugin.Instance.rnn.SetPlane(plane);
            return(Result.Success);
        }
예제 #30
0
        private Tuple <Point3d, Point3d> GetSpine()
        {
            // Get user input for spine
            bool    unsucessfulGetSpine = false;
            Point3d pt0 = new Point3d(0, 0, 0);

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Spine: start point");
                if (getPointAction.Get() != GetResult.Point)
                {
                    unsucessfulGetSpine = true;
                    //RhinoApp.WriteLine("No start point was selected.");
                    //return getPointAction.CommandResult();
                }
                if (!unsucessfulGetSpine)
                {
                    pt0 = getPointAction.Point();
                }
            }

            Point3d pt1 = new Point3d(0, 0, 0);

            using (GetPoint getPointAction = new GetPoint())
            {
                getPointAction.SetCommandPrompt("Spine: end point");
                getPointAction.SetBasePoint(pt0, true);
                getPointAction.DynamicDraw +=
                    (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed);
                if (getPointAction.Get() != GetResult.Point)
                {
                    unsucessfulGetSpine = true;
                    //RhinoApp.WriteLine("No end point was selected.");
                    //return getPointAction.CommandResult();
                }
                if (!unsucessfulGetSpine)
                {
                    pt1 = getPointAction.Point();
                }
            }
            if (unsucessfulGetSpine)
            {
                return(null);
            }
            return(new Tuple <Point3d, Point3d>(pt0, pt1));
        }