Ejemplo n.º 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var surface = new GH_Surface();

            if (DA.GetData(0, ref surface) && surface == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid surface. Operation canceled.");
                return;
            }

            var output = new List <GH_Point>();

            Continuity c = Continuity.C0_continuous | Continuity.C1_continuous | Continuity.C2_continuous |
                           Continuity.C0_locus_continuous | Continuity.C1_locus_continuous | Continuity.C2_locus_continuous |
                           Continuity.Cinfinity_continuous;

            // u direction
            var u = 0.0d;
            var v = 0.0d;

            surface.Face.GetNextDiscontinuity(1, c, 0, 1, out u);
            output.Add(new GH_Point(surface.Face.PointAt(u, 0)));
            output.Add(new GH_Point(surface.Face.PointAt(u, 1)));

            DA.SetDataList(0, output);
        }
Ejemplo n.º 2
0
        /**
         * divideCrvsByDeltaTan : Curve[] * double -> LinkedList<Plane>
         * REQUIRES: theta > 0
         * ENSURES: divideCrvsByDeltaTan(crvs, theta) returns a linked list of planes
         *          along the curves s.t. there is a plane at every point along
         *          the curve where the change in the tangent vector between
         *          two points is greater than theta.
         **/
        private IEnumerable <Point3d> DivByAngle(Curve crv, double angle)
        {
            //initialize parameters
            double   theta    = angle;
            Interval dom      = crv.Domain;
            double   stepSize = Math.Abs(dom.Length) * Constants.AbsoluteTolerance * Constants.AbsoluteTolerance;

            //initialize list
            List <Point3d> pts = new List <Point3d>();

            Continuity c = Continuity.C1_continuous;
            //initialize data

            double rover = dom.Min; //steps along the curve by stepSize

            //Add plane at start point of curve to list
            Point3d pt = crv.PointAt(rover);

            pts.Add(pt);

            //Increment
            Vector3d prevTan  = crv.TangentAt(rover);
            double   oldRover = rover; //stores the previous rover for comparison

            rover += stepSize;

            while (rover < dom.Max)
            {
                Vector3d currTan = crv.TangentAt(rover);
                //If there is a discontinuity between the oldRover and rover
                //then place a point at the discontinuity and update prevTan.
                double discontinuity;
                bool   isDisc = crv.GetNextDiscontinuity(c, oldRover, rover,
                                                         out discontinuity);
                if (isDisc)
                {
                    pt = crv.PointAt(discontinuity);
                    pts.Add(pt);
                    prevTan = crv.TangentAt(discontinuity);
                }

                //If the change in tangent vector is greater than theta,
                //then drop a target at the rover and update prevTan.
                double delta = RhinoMath.ToDegrees(Math.Abs(Vector3d.VectorAngle(prevTan, currTan)));
                if (delta > theta)
                {
                    pt = crv.PointAt(rover);
                    pts.Add(pt);
                    prevTan = currTan;
                }
                //Increment
                oldRover = rover;
                rover   += stepSize;
            }

            //Add target at end point of curve
            pt = crv.PointAt(dom.Max);
            pts.Add(pt);
            return(pts);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Add(AttendanceViewModel model)
        {
            if (model.Date > DateTime.Now)
            {
                ModelState.AddModelError("Date", "Gələcək tarixə qeyd aparmaq olmaz");
            }
            else
            {
                if (ModelState.IsValid)
                {
                    Continuity continuity = new Continuity()
                    {
                        Id         = model.Id,
                        WorkerId   = model.WorkerId,
                        Date       = model.Date,
                        Reason     = model.Reason,
                        Status     = model.Status,
                        ReasonName = model.ReasonName
                    };
                    await _dbContext.Continuities.AddAsync(continuity);

                    await _dbContext.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(View());
        }
Ejemplo n.º 4
0
	void Awake()
	{
		if (instance == null)
		{
			instance = this;
			Reset();
		}
	}
Ejemplo n.º 5
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         Reset();
     }
 }
Ejemplo n.º 6
0
 public override int GetHashCode()
 {
     return(
         Position.GetHashCode() ^
         Value.GetHashCode() ^
         TangentIn.GetHashCode() ^
         TangentOut.GetHashCode() ^
         Continuity.GetHashCode()
         );
 }
        public async Task StateIntent(IDialogContext context, LuisResult result)
        {
            string state = BillDialogUtil.GetEntityState(result);

            if (state != null && state != "" && state != "nothing")
            {
                Continuity.SetSavedState(context, state);
            }
            else
            {
                state = Continuity.GetSavedState(context);
            }
            await context.PostAsync("All hail the great state of " + state + ".");

            context.Wait(MessageReceived);
        }
Ejemplo n.º 8
0
            public ModulatorType(byte[] bytes, ref int i)
            {
                var data = Bit.ReadUInt16(bytes, ref i);

                type      = (Continuity)(data >> 10);
                polarity  = (Polarity)((data >> 9) & 0x01);
                direction = (Direction)((data >> 8) & 0x01);

                if (((data >> 7) & 0x01) == 0)
                {
                    controller = (Controller)(data & 0x3F);
                }
                else
                {
                    controller     = Controller.MidiController;
                    midiController = (byte)(data & 0x3F);
                }
            }
Ejemplo n.º 9
0
 /// <summary>
 /// Searches for a derivative, tangent, or curvature discontinuity.
 /// </summary>
 /// <param name="direction">
 /// If 0, then "u" parameter is checked. If 1, then the "v" parameter is checked.
 /// </param>
 /// <param name="continuityType">The desired continuity.</param>
 /// <param name="t0">
 /// Search begins at t0. If there is a discontinuity at t0, it will be ignored. 
 /// This makes it possible to repeatedly call GetNextDiscontinuity and step through the discontinuities.
 /// </param>
 /// <param name="t1">
 /// (t0 != t1) If there is a discontinuity at t1 is will be ingored unless c is a locus discontinuity
 /// type and t1 is at the start or end of the curve.
 /// </param>
 /// <param name="t">
 /// if a discontinuity is found, then t reports the parameter at the discontinuity.
 /// </param>
 /// <returns>
 /// Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
 /// TRUE if a parametric discontinuity was found strictly between t0 and t1.
 /// Note well that all curves are parametrically continuous at the ends of their domains.
 /// 
 /// Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
 /// TRUE if a locus discontinuity was found strictly between t0 and t1 or at t1 is the
 /// at the end of a curve. Note well that all open curves (IsClosed()=false) are locus
 /// discontinuous at the ends of their domains.  All closed curves (IsClosed()=true) are
 /// at least C0_locus_continuous at the ends of their domains.
 /// </returns>
 public bool GetNextDiscontinuity(int direction, Continuity continuityType, double t0, double t1, out double t)
 {
   IntPtr ptr = ConstPointer();
   t = 0;
   return UnsafeNativeMethods.ON_Surface_GetNextDiscontinuity(ptr, direction, (int)continuityType, t0, t1, ref t);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Tests continuity at a surface parameter value.
 /// </summary>
 /// <param name="continuityType">The continuity type to sample.</param>
 /// <param name="u">Surface u parameter to test.</param>
 /// <param name="v">Surface v parameter to test.</param>
 /// <returns>true if the surface has at least the specified continuity at the (u,v) parameter.</returns>
 public bool IsContinuous(Continuity continuityType, double u, double v)
 {
   IntPtr ptr = ConstPointer();
   return UnsafeNativeMethods.ON_Surface_IsContinuous(ptr, (int)continuityType, u, v);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Searches for a derivative, tangent, or curvature discontinuity.
 /// </summary>
 /// <param name="continuityType">Type of continuity to search for.</param>
 /// <param name="t0">
 /// Search begins at t0. If there is a discontinuity at t0, it will be ignored. This makes it
 /// possible to repeatedly call GetNextDiscontinuity() and step through the discontinuities.
 /// </param>
 /// <param name="t1">
 /// (t0 != t1)  If there is a discontinuity at t1 it will be ignored unless continuityType is
 /// a locus discontinuity type and t1 is at the start or end of the curve.
 /// </param>
 /// <param name="t">If a discontinuity is found, then t reports the parameter at the discontinuity.</param>
 /// <returns>
 /// Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
 ///  true if a parametric discontinuity was found strictly between t0 and t1. Note well that
 ///  all curves are parametrically continuous at the ends of their domains.
 /// 
 /// Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
 ///  true if a locus discontinuity was found strictly between t0 and t1 or at t1 is the at the end
 ///  of a curve. Note well that all open curves (IsClosed()=false) are locus discontinuous at the
 ///  ends of their domains.  All closed curves (IsClosed()=true) are at least C0_locus_continuous at 
 ///  the ends of their domains.
 /// </returns>
 public bool GetNextDiscontinuity(Continuity continuityType, double t0, double t1, out double t)
 {
   t = RhinoMath.UnsetValue;
   IntPtr ptr = ConstPointer();
   return UnsafeNativeMethods.ON_Curve_GetNextDiscontinuity(ptr, (int)continuityType, t0, t1, ref t);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Test continuity at a curve parameter value.
 /// </summary>
 /// <param name="continuityType">Type of continuity to test for.</param>
 /// <param name="t">Parameter to test.</param>
 /// <returns>
 /// true if the curve has at least the c type continuity at the parameter t.
 /// </returns>
 public bool IsContinuous(Continuity continuityType, double t)
 {
   IntPtr ptr = ConstPointer();
   return UnsafeNativeMethods.ON_Curve_IsContinuous(ptr, (int)continuityType, t);
 }
Ejemplo n.º 13
0
        public async Task FindIntent(IDialogContext context, LuisResult result)
        {
            try
            {
                string CurState;
                CurState = Continuity.GetSavedState(context);
                string SearchTerm = BillDialogUtil.GetSearchTerm(result);

                string CurVoter;
                CurVoter = Continuity.GetSavedLegislator(context);

                DateTime MinTime;
                DateTime MaxTime;
                bool     Ok = BillDialogUtil.GetEntityDateRange(result, out MinTime, out MaxTime);
                // if (Ok)
                {
                    // await context.PostAsync($"SearchTerm = {SearchTerm} MinTime = {MinTime}, MaxTime = {MaxTime}");
                    // // context.Wait(MessageReceived);

                    OpenStateClientLib.OpenStateClient cli = new OpenStateClientLib.OpenStateClient();

                    Newtonsoft.Json.Linq.JArray arr = await cli.GetBillsFilteredAsync(CurState, MinTime, MaxTime, SearchTerm, null, ExtraGuiActionBill);

                    int CurrentBill = 0;

                    bool WillBeMore;
                    int  MaxToShow = Continuity.NumBillsToShowInGroup;
                    if (MaxToShow >= arr.Count)
                    {
                        MaxToShow  = arr.Count;
                        WillBeMore = false;
                    }
                    else
                    {
                        WillBeMore = true;
                    }

                    bool MoreToDisplay = false;
                    for (int ii = 0; ii < MaxToShow; ii++)
                    {
                        CurrentBill   = ii;
                        MoreToDisplay = (ii >= (arr.Count - 1));
                        await BillDialogUtil.DisplayOneBill(context, arr[ii], CurState, CurVoter);
                    }
                    if (MoreToDisplay)
                    {
                        await context.PostAsync("Type 'More' to see more bills.\n");
                    }
                    // context.ConversationData.SetValue(KeyBillNumber, CurrentBill + 1);
                    Continuity.SetSavedBillNumber(context, CurrentBill + 1);
                    if (WillBeMore)
                    {
                        // context.ConversationData.SetValue(KeyBillResults, arr);
                        Continuity.SetSavedBills(context, arr);
                        if (SearchTerm != null && SearchTerm != "")
                        {
                            await context.PostAsync($"Type 'More' to see more '{SearchTerm}' bills.\n");
                        }
                        else
                        {
                            await context.PostAsync("Type 'More' to see more bills.\n");
                        }
                    }
                    else
                    {
                        Continuity.RemoveSavedBills(context);
                    }
                }
                context.Wait(MessageReceived);
            }
            catch (System.Exception)
            {
            }
        }
Ejemplo n.º 14
0
        public async Task LegislatorIntent(IDialogContext context, LuisResult result)
        {
            // await context.PostAsync("result.Query = " + result.Query);
            // context.Wait(MessageReceived);

            string State = Continuity.GetSavedState(context);

            if (State == null || State == "")
            {
                await context.PostAsync("No State selected" + ".");

                context.Wait(MessageReceived);
                return;
            }
            string SearchTerm = BillDialogUtil.GetSearchTerm(result);


            OpenStateClientLib.OpenStateClient cli = new OpenStateClientLib.OpenStateClient();

            OpenStateClientLib.LegeSet lset = await cli.GetStatePeopleAsync(State);

            if (lset == null)
            {
                await context.PostAsync("Cannot get legislator list" + ".");

                context.Wait(MessageReceived);
                return;
            }
            string Summary = lset.SummarizeLeges();

            if (SearchTerm == null || SearchTerm == "")
            {
                string OldLegislator = Continuity.GetSavedLegislator(context);
                if (OldLegislator != null && OldLegislator != "")
                {
                    Summary += "Selected Legislator is " + OldLegislator + "!\n";
                }
                // await context.PostAsync(Summary);
                await PostIt(context, Summary);

                context.Wait(MessageReceived);
                return;
            }

            if (SearchTerm != null || SearchTerm != "")
            {
                Continuity.SetSavedLegislator(context, SearchTerm);
                string Msg;
                if (SearchTerm.ToLower() == "all")
                {
                    string Msg2 = $"We will show the votes made by all legislators\nwhen you search for bills.";
                    Msg = Msg2;
                    await context.PostAsync(Msg);

                    context.Wait(MessageReceived);
                    return;
                }
                else if (SearchTerm.ToLower() == "none")
                {
                    string Msg2 = $"We will show no votes made by legislators\nwhen you search for bills.";
                    Msg = Msg2;
                    await context.PostAsync(Msg);

                    context.Wait(MessageReceived);
                    return;
                }
                else
                {
                    int NumFound = lset.FindLegislator(SearchTerm, out Msg);
                    if (NumFound == 1)
                    {
                        string Msg2 = $"We will show the votes made by this legislator\nwhen you search for bills.";
                        Msg += ("\n" + Msg2);
                        await context.PostAsync(Msg);

                        context.Wait(MessageReceived);
                        return;
                    }
                    if (NumFound >= 0)
                    {
                        string Msg2 = $"We will show the votes made by these legislators\nwhen you search for bills.";
                        Msg += ("\n" + Msg2);
                        await context.PostAsync(Msg);

                        context.Wait(MessageReceived);
                        return;
                    }
                    else
                    {
                        await context.PostAsync(Msg);

                        context.Wait(MessageReceived);
                        return;
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public async Task MoreIntent(IDialogContext context, LuisResult result)
        {
            int BillNumber = Continuity.GetSavedBillNumber(context);

            if (BillNumber < 0)
            {
                // none left
                await context.PostAsync("Not anymore bills to show.");

                context.Wait(MessageReceived);
                return;
            }
            string CurVoter = Continuity.GetSavedLegislator(context);

            Newtonsoft.Json.Linq.JArray arr = Continuity.GetSavedBills(context);
            string State = Continuity.GetSavedState(context);

            if (arr == null)
            {
                await context.PostAsync("No bills saved to show.");

                context.Wait(MessageReceived);
                return;
            }
            int NumLeft = arr.Count;

            if (BillNumber >= NumLeft)
            {
                // none left
                await context.PostAsync("No more bills to show.");

                context.Wait(MessageReceived);
                return;
            }
            int NumToShow = NumLeft;

            if (NumToShow > Continuity.NumBillsToShowInGroup)
            {
                NumToShow = Continuity.NumBillsToShowInGroup;
            }


            for (int i = BillNumber; i < BillNumber + NumToShow; i++)
            {
                if (arr != null && i < arr.Count)
                {
                    await BillDialogUtil.DisplayOneBill(context, arr[i], State, CurVoter);
                }
            }

            BillNumber += NumToShow;
            if (BillNumber < arr.Count)
            {
                Continuity.SetSavedBillNumber(context, BillNumber);
                await context.PostAsync("Type 'More' to see more bills.\n");
            }
            else
            {
                Continuity.SetSavedBills(context, null);
                Continuity.SetSavedBillNumber(context, -1);
            }
        }