/// <summary>
 /// Performs intersection-equality testing on two objects
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Object to test against</param>
 /// <param name="customEqualityComparers">Objects implementing IEqualityComparer&lt;TProperty&gt;
 /// for customising equality testing for properties of type TProperty</param>
 /// <typeparam name="T">Original type</typeparam>
 public static void Equal <T>(
     this IIntersection <T> continuation,
     object expected,
     params object[] customEqualityComparers
     )
 {
     continuation.Equal(expected, NULL_STRING, customEqualityComparers);
 }
 /// <summary>
 /// Performs intersection-equality testing on two objects
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Object to test against</param>
 /// <param name="customMessage"></param>
 /// <param name="customEqualityComparers">Objects implementing IEqualityComparer&lt;TProperty&gt;
 /// for customising equality testing for properties of type TProperty</param>
 /// <typeparam name="T">Original type</typeparam>
 public static void Equal <T>(
     this IIntersection <T> continuation,
     object expected,
     string customMessage,
     params object[] customEqualityComparers
     )
 {
     continuation.Equal(expected, () => customMessage, customEqualityComparers);
 }
            public EntityView(
                IIntersection <ViewIntersectionModel, ViewIntersectionField, EntityModel, EntityField> classToEntityModelIntersection,
                IIntersection <EntityModel, EntityField, TypeModel, PropertyInfoField> entityToClassIntersection
                )
            {
                ClassToEntityIntersection = classToEntityModelIntersection;
                EntityToClassIntersection = entityToClassIntersection;

                var mappingFactory = new DefaultMappingFactory <EntityModel, EntityField, TypeModel, PropertyInfoField>();

                Mapping = mappingFactory.CreateMapping(entityToClassIntersection);
            }
Ejemplo n.º 4
0
        public void triangle_IntersectsTriPlane_testFalseOK()
        {
            var           v0  = new Vector3(2, 1, 0);
            var           v1  = new Vector3(4, 2, 0);
            var           v2  = new Vector3(2, 4, 0);
            var           pt  = new Vector3(4, 4, 1);
            var           dir = new Vector3(1, 1, 0);
            var           ray = new Ray3(pt, dir);
            Triangle      tri = new Triangle(v0, v1, v2);
            IIntersection ir  = tri.IntersectsTriPlane(ray);

            Assert.IsFalse(ir.Intersects);
        }
 /// <summary>
 /// Performs intersection-equality testing on two objects
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Object to test against</param>
 /// <param name="customMessageGenerator">Generates a custom message to add to failure messages</param>
 /// <param name="customEqualityComparers">Objects implementing IEqualityComparer&lt;TProperty&gt;
 /// for customising equality testing for properties of type TProperty</param>
 /// <typeparam name="T">Original type</typeparam>
 public static void Equal <T>(
     this IIntersection <T> continuation,
     object expected,
     Func <string> customMessageGenerator,
     params object[] customEqualityComparers
     )
 {
     RunIntersectioEqualityTest(
         continuation,
         expected,
         customMessageGenerator,
         customEqualityComparers
         );
 }
Ejemplo n.º 6
0
        public void triangle_intersectedByTest_testOK()
        {
            IVector3      v0  = new Vector3(2, 1, 0);
            IVector3      v1  = new Vector3(4, 2, 0);
            IVector3      v2  = new Vector3(2, 4, 0);
            IVector3      pt  = new Vector3(3, 2, 1);
            IVector3      dir = new Vector3(0, 0, -1);
            var           ray = new Ray3(pt, dir);
            Triangle      tri = new Triangle(v0, v1, v2);
            IIntersection ir  = tri.IntersectedBy(ray);

            Assert.IsTrue(ir.Intersects);
            Assert.AreEqual(3.0, ir.Point.X, .001);
            Assert.AreEqual(2.0, ir.Point.Y, .001);
            Assert.AreEqual(0.0, ir.Point.Z, .001);
        }
Ejemplo n.º 7
0
        public void triangle_IntersectsTriPlane_testOK()
        {
            IVector3      v0  = new Vector3(2, 1, 0.5);
            IVector3      v1  = new Vector3(4, 2, 0.5);
            IVector3      v2  = new Vector3(2, 4, 0.5);
            IVector3      pt  = new Vector3(4, 4, 1);
            IVector3      dir = new Vector3(0, 0, -1);
            var           ray = new Ray3(pt, dir);
            Triangle      tri = new Triangle(v0, v1, v2);
            IIntersection ir  = tri.IntersectsTriPlane(ray);

            Assert.IsTrue(ir.Intersects);
            Assert.AreEqual(4.0, ir.Point.X, .001);
            Assert.AreEqual(4.0, ir.Point.Y, .001);
            Assert.AreEqual(0.5, ir.Point.Z, .001);
            IIntersection irt = tri.IntersectedBy(ray);

            Assert.IsFalse(irt.Intersects);
        }
Ejemplo n.º 8
0
 public IIntersection IntersectedBy(IRay <IVector3> ray)
 {
     try
     {
         IIntersection pt = IntersectsTriPlane(ray);
         if (pt.Intersects && Contains(pt.Point))
         {
             pt.Intersects = true;
         }
         else
         {
             pt.Intersects = false;
         }
         return(pt);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 9
0
 public List <ITriangle> Split(IRay <IVector3> ray)
 {
     try
     {
         List <ITriangle> tris = new List <ITriangle>();
         IIntersection    pt   = IntersectedBy(ray);
         if (pt.Intersects)
         {
             tris.Add(new Triangle(vert[0], vert[1], pt.Point, index));
             tris.Add(new Triangle(vert[1], vert[2], pt.Point, index));
             tris.Add(new Triangle(vert[2], vert[0], pt.Point, index));
         }
         else
         {
             tris.Add(this);
         }
         return(tris);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 10
0
        public static Vector3 GetPosition(this IIntersection intersection)
        {
            Ensure.That(intersection, nameof(intersection)).IsNotNull();

            return((Vector3)intersection.RawData["position"]);
        }
Ejemplo n.º 11
0
 public static void Search(SeqTextIR seq, string q, IIntersection<int> ialg)
 {
     Console.WriteLine ("Query: '{0}'", q);
     long itime = DateTime.Now.Ticks;
     var res = seq.SearchPhrase (q, ialg);
     int i = 0;
     int max_len_snippet = 128;
     foreach (var occ in res) {
         if (i >= 10) {
             Console.WriteLine ("Too many results skipping to the end");
             break;
         }
         i++;
         string uri;
         int docid;
         int sp;
         int len;
         string snippet = seq.GetSnippet (occ, max_len_snippet, out uri, out docid, out sp, out len);
         Console.WriteLine ();
         Console.WriteLine ("=========== ResultID {0}, occpos: {1}, uri: {2}", i, occ, uri);
         Console.WriteLine ("=========== Start snippet, snippet len: {0}, docid: {1}, offset_file: {2}", snippet.Length, docid, sp);
         Console.WriteLine (snippet);
         Console.WriteLine ("=========== End snippet");
     }
     Console.WriteLine ("Total results: {0}", i);
     var tspan = TimeSpan.FromTicks (DateTime.Now.Ticks - itime);
     Console.WriteLine ("query time: {0}", tspan);
 }
Ejemplo n.º 12
0
 public ComparisonUI(IIntersection<int> alg)
 {
     this.ialg = alg;
 }
Ejemplo n.º 13
0
 protected virtual IEnumerable<int> GetCandidates(IList<IList<int>> posting_lists, IIntersection<int> ialg)
 {
     if (posting_lists.Count == 0) {
         return new int[0];
     } else if (posting_lists.Count == 1) {
         return posting_lists [0];
     } else {
         return ialg.Intersection (posting_lists);
     }
 }
Ejemplo n.º 14
0
 public virtual IList<int> SearchPhrase(IList<string> query, IIntersection<int> ialg)
 {
     var posting = this.GetPostingLists (query);
     var _r = this.GetCandidates (posting, ialg);
     var _s = _r as IList<int>;
     if (_s == null) {
         return new List<int> (_r);
     }
     return _s;
 }
Ejemplo n.º 15
0
        private async Task InitGpio(ConfigurationSettings cfg)
        {
            try
            {
                var gpio = GpioController.GetDefault();

                // Show an error if there is no GPIO controller
                if (gpio == null)
                {
                    _eventor.SendLogMessage(cfg.IntersectionId, true, "There is no GPIO controller on this device.", DateTime.UtcNow);
                    return;
                }

                //Construct the bulbs
                await BuildBulbs(gpio, cfg);

                //Construct the Lamps
                await BuildLamps(cfg);

                //Put them in sets (only one lamp sets for this case...)
                _nSet = new BasicLampSet(cfg.NorthLampSetId, new List <ILamp> {
                    _nLamp
                }, 0, false);
                _sSet = new BasicLampSet(cfg.SouthLampSetId, new List <ILamp> {
                    _sLamp
                }, 180, false);
                _eSet = new BasicLampSet(cfg.EastLampSetId, new List <ILamp> {
                    _eLamp
                }, 90, true);
                _wSet = new BasicLampSet(cfg.WestLampSetId, new List <ILamp> {
                    _wLamp
                }, 270, true);

                //Establish the lamp sets on traffic routes
                _nsRoute = new BasicTrafficRoute(cfg.NorthSouthRouteId, 5, false, new List <ILampSet> {
                    _nSet, _sSet
                });

                _nsRoute.TransitionRightOfWay().Wait();
                await Task.Delay(1000);

                _nsRoute.TransitionRightOfWay().Wait();
                await Task.Delay(1000);


                _ewRoute = new BasicTrafficRoute(cfg.EastWestRouteId, 0, true, new List <ILampSet> {
                    _eSet, _wSet
                });

                _ewRoute.TransitionRightOfWay().Wait();
                await Task.Delay(1000);

                _ewRoute.TransitionRightOfWay().Wait();
                await Task.Delay(1000);


                //Put the intersection together
                _theIntersection = new BasicFourWayIntersection(cfg.IntersectionId, 3, new List <ITrafficRoute>
                {
                    _nsRoute, _ewRoute
                });

                _eventor.SendLogMessage(cfg.IntersectionId, false, "POST completed.", DateTime.UtcNow);
            }
            catch (Exception ex)
            {
                _eventor.SendLogMessage(cfg.IntersectionId, true, ex.ToString(), DateTime.UtcNow);
                throw;
            }
        }
Ejemplo n.º 16
0
 public virtual IList<int> SearchPhrase(string query, IIntersection<int> ialg, Action<QueryParser> modify_query = null)
 {
     var qparser = new QueryParser (this.InputTokenizer);
     qparser.Parse (query);
     if (null != modify_query) {
         modify_query (qparser);
     }
     var posting = this.GetPostingLists (qparser);
     var _r = this.GetCandidates (qparser,  posting, ialg);
     var _s = _r as IList<int>;
     if (_s == null) {
         return new List<int> (_r);
     }
     return _s;
 }
Ejemplo n.º 17
0
        public static Vector3 GetNormal(this IIntersection intersection)
        {
            Ensure.That(intersection, nameof(intersection)).IsNotNull();

            return((Vector3)intersection.RawData["normal"]);
        }