예제 #1
0
        public ScalingWidget(Box targetObject)
            : base(3)
        {
            box = targetObject;

            YArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth)
            {
                Name = "YArrow"
            };
            XArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth) {

                Name = "XArrow"
            };
            ZArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth)
            {
                Name = "ZArrow"
            };

            Objects[0] = YArrow;
            Objects[1] = XArrow;
            Objects[2] = ZArrow;

            scaling = targetObject.ScalingValues;

            Material = new PhongMaterial() { DiffuseColor = Color.Yellow, AmbientCoefficient=1f};
            YArrow.PositionV3 = new Vector3(-scaling.X / 2 - ArrowLineWidth / 2, scaling.Y / 2, -scaling.Z / 2 - ArrowLineWidth / 2);
            XArrow.PositionV3 = new Vector3(scaling.X / 2 + ArrowLineWidth / 2, -scaling.Y / 2 + ArrowLineWidth / 2, -scaling.Z / 2 - ArrowLineWidth / 2);
            ZArrow.PositionV3 = new Vector3(-scaling.X / 2 - ArrowLineWidth / 2, -scaling.Y / 2 + ArrowLineWidth / 2, scaling.Z / 2 + ArrowLineWidth / 2);

            //YArrow.PositionV3 = new Vector3(-box.Scaling / 2 - ArrowLineWidth / 2, box.Height / 2, -box.Depth / 2 - ArrowLineWidth / 2);
            //XArrow.PositionV3 = new Vector3(box.Width / 2 + ArrowLineWidth / 2, -box.Height / 2 + ArrowLineWidth / 2, -box.Depth / 2 - ArrowLineWidth / 2);
            //ZArrow.PositionV3 = new Vector3(-box.Width / 2 - ArrowLineWidth / 2, -box.Height / 2 + ArrowLineWidth / 2, box.Depth / 2 + ArrowLineWidth / 2);
        }
 public override byte[] AsBytes(IBox box)
 {
     using (var memoryStream = new MemoryStream())
     {
         ToStream(box, memoryStream);
         return memoryStream.ToArray();
     }
 }
예제 #3
0
        public void Payout(List<IBox> boxes, IBox bank)
        {
            Rearrange(boxes, bank);

            PayoutTooMuch();
            PayoutBlackjacks();
            PayoutRest();
        }
 public override string AsString(IBox box)
 {
     return JsonConvert.SerializeObject(box, Formatting.Indented,
         new JsonSerializerSettings
             {
                 //TypeNameHandling = TypeNameHandling.All,
                 //TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple
             });
 }
예제 #5
0
        void Rearrange(List<IBox> boxes, IBox bank)
        {
            _blackjacks = boxes.FindAll(b => b.Hand.IsBlackjack);
            _tooMuch = boxes.FindAll(b => b.Hand.Value > 21);
            _rest = boxes.FindAll(b => !b.Hand.IsBlackjack).FindAll(b => b.Hand.Value <= 21);

            _bankHasBlackjack = bank.Hand.IsBlackjack;
            _bankHasTooMuch = bank.Hand.Value > 21;
            _bankValue = bank.Hand.Value;
        }
 //protected 
 public void ToFile(IBox box, string path)
 {
     Directory.CreateDirectory(Path.GetDirectoryName(path));
     File.Delete(path);
     using (var file = File.OpenWrite(path))
     {
         ToStream(box, file);
     }
     //File.WriteAllText(path, AsString());
 }
 public override void ToStream(IBox box, Stream stream)
 {
     using (TextWriter writer = new StreamWriter(stream))
     {
         Dumper.Dump(box, writer);
         foreach (var o in box)
         {
             Dumper.Dump(o, writer);
         }
     }
 }
예제 #8
0
        /// <summary>
        /// Constructs a new relative alignment.
        /// </summary>
        /// <param name="aligned">The object that should be aligned.</param>
        /// <param name="relativeTo">The box that the object should be aligned relative to.</param>
        /// <param name="relativeToContainsAligned">True if the aligned objects coordinates are relative to the coordinates of the box. If relativeTo is a parent (directly or indirectly) of aligned, then this should be set to true, otherwise this should be set to false.</param>
        public RelativeAlignment(IPosition aligned, IBox relativeTo, bool relativeToContainsAligned)
            : base(aligned)
        {
            alignmentBox = relativeTo;

            alignmentBoxContainsAligned = relativeToContainsAligned;

            alignmentBox.WidthChanged += updateX;
            alignmentBox.HeightChanged += updateY;
            if(!alignmentBoxContainsAligned)
            {
                alignmentBox.XChanged += updateX;
                alignmentBox.YChanged += updateY;
            }

            updateX();
            updateY();
        }
예제 #9
0
        public IBox AddBox(t_MapObjectData BoxData, uint nlefttime)
        {
            if (BoxData == null)
            {
                return(null);
            }
            //Engine.Utility.Log.Info("创建box{0}", BoxData.dwObjectID);
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

            if (es == null)
            {
                Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
                return(null);
            }

//            if (es.FindBox(BoxData.qwThisID) == null)
            {
                //AddPetEntity(petdata);
                // 创建box
                //MapVector2 mapPos = MapVector2.FromCoordinate(BoxData.x, BoxData.y);
                Vector3 pos = new Vector3(BoxData.cur_pos.x * 0.01f, 0, -BoxData.cur_pos.y * 0.01f); // 服务器到客户端坐标转换

                EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityType_Box, BoxData);
                IBox             box  = es.FindBox(BoxData.qwThisID);
                if (box != null)
                {
                    box.UpdateProp(data);
                }
                else
                {
                    box = es.CreateEntity(EntityType.EntityType_Box, data, true) as IBox;
                }

                box.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos);
                box.AddTrigger(new BoxOnTrigger());
                return(box);
            }
            return(null);
        }
예제 #10
0
                public override string ToString()
                {
                    if (!string.IsNullOrEmpty(ToStringFile))
                    {
                        ToCanvas(ToStringFile);
                    }

                    var  sb = new StringBuilder();
                    IBox x0 = _master._searchingTree._mainBox;

                    if (_searchingTile != null)
                    {
                        sb.Append("X: ");
                        TileToString(sb, x0, _master._searchingTree.GetBox(_searchingTile));
                    }
                    else
                    {
                        sb.Append("X-Tile not initialized.");
                    }

                    if (_neighbourTiles != null)
                    {
                        var iTile = 0;
                        foreach (BoxTile yTile in _neighbourTiles)
                        {
                            sb.AppendFormat(" Y[{0}]: ", iTile);
                            TileToString(sb, _master._neighbourTree._mainBox,
                                         _master._neighbourTree.GetBox(yTile));
                            iTile++;
                        }
                    }
                    else
                    {
                        sb.Append("  Y-Tiles not initialized.");
                    }

                    return(sb.ToString());
                }
        private void setCurrentCollisions(Animation animation, Entity entity, AnimationTracker current)
        {
            animation.CurrentCollisions = new Dictionary <string, BoxCollision>();
            foreach (KeyValuePair <string, BoxCollision> pair in current.Frames[current.FrameNumber].Colliders)
            {
                if (pair.Key == "Collision")
                {
                    BoxCollision        boxCollision = entity.GetComponent <BoxCollision>();
                    Componets.Transform transform    = entity.GetComponent <Componets.Transform>();

                    List <IBox> newBoxes = new List <IBox>();

                    for (int i = 0; i < pair.Value.Boxes.Count; i++)
                    {
                        BoxData boxData = (BoxData)pair.Value.Boxes[i].Data;
                        IBox    newIbox = boxCollision.World.Create(transform.Position.X + transform.Scale.X * boxData.Position.X,
                                                                    transform.Position.Y + transform.Scale.Y * boxData.Position.Y,
                                                                    transform.Scale.X * boxData.Scale.X,
                                                                    transform.Scale.Y * boxData.Scale.Y).AddTags(boxData.Layer);
                        newIbox.Data = boxData;

                        if (boxCollision.Boxes.Count > i)
                        {
                            boxCollision.World.Remove(boxCollision.Boxes[i]);
                            boxCollision.Boxes.Remove(boxCollision.Boxes[i]);
                        }

                        newBoxes.Add(newIbox);
                    }

                    boxCollision.Boxes = newBoxes;
                }
                else
                {
                    animation.CurrentCollisions.Add(pair.Key, pair.Value);
                }
            }
        }
예제 #12
0
파일: IOutBox.cs 프로젝트: wxtech/forjava
        public static IBox MasterReplicate(IDatabase self, long dest, params BoxData[] data)
        {
            if (data == null || data.Length < 1)
            {
                return(null);
            }
            IBox box = null;

            foreach (var d in data)
            {
                var actions = d.GetActions();
                if (actions != null && actions.Count > 0)
                {
                    box = box == null?self.Cube(dest) : box;

                    foreach (var e in actions)
                    {
                        MasterAction(e, (ILocalBox)box);
                    }
                }
            }
            return(box);
        }
        private static ExceptionsBoxTree CreateBoxTree(
            [NotNull] ICollection <ExceptionObject> exceptionObjects,
            double expansionDistance)
        {
            IBox box = GetBox(exceptionObjects, expansionDistance);

            var result = new ExceptionsBoxTree();

            if (box != null)
            {
                result.InitSize(new IGmtry[] { box });
            }

            foreach (ExceptionObject exceptionObject in exceptionObjects)
            {
                if (exceptionObject.ShapeEnvelope != null)
                {
                    result.Add(exceptionObject.ShapeEnvelope, exceptionObject);
                }
            }

            return(result);
        }
예제 #14
0
                internal IEnumerable <Neighborhood> GetNeighborhoods(double searchDistance)
                {
                    if (_searchingTile.ElemsCount <= 0)
                    {
                        yield break;
                    }

                    if (!HasNeighbourTiles())
                    {
                        yield break;
                    }

                    List <INeighbourEntryEnumerable> neighbourEntryEnumerators =
                        GetNeighbourEntryEnumerators();

                    if (neighbourEntryEnumerators == null)
                    {
                        yield break;
                    }

                    foreach (TileEntry searchEntry in _searchingTile.EnumElems())
                    {
                        IBox search =
                            GetSearchBox(searchEntry.Box, searchDistance, _master._common);
                        if (search == null)
                        {
                            continue;
                        }

                        yield return(new Neighborhood
                        {
                            Entry = searchEntry,
                            Neighbours =
                                GetNeighbours(search, neighbourEntryEnumerators)
                        });
                    }
                }
        /// <summary>
        /// moov.udta:
        /// -3gpp boxes
        /// -meta
        /// --ilst
        /// --tags
        /// --meta (no container!)
        /// --tseg
        /// ---tshd
        /// </summary>
        /// <param name="udta"></param>
        /// <param name="meta"></param>
        public void parse(IBox udta, IBox meta)
        {
            // --- standard boxes ---
            if (meta.hasChild(BoxType.COPYRIGHT_BOX))
            {
                throw new NotImplementedException();
                //var cprt = (CopyrightBox)meta.getChild(BoxType.COPYRIGHT_BOX);
                //put(Field.LANGUAGE, new Locale(cprt.getLanguageCode()));
                //put(Field.COPYRIGHT, cprt.getNotice());
            }

            // --- 3gpp user data ---
            if (udta != null)
            {
                parse3GPPData(udta);
            }

            // --- id3, TODO: can be present in different languages ---
            if (meta.hasChild(BoxType.ID3_TAG_BOX))
            {
                throw new NotImplementedException();
                // parseID3((ID3TagBox)meta.getChild(BoxType.ID3_TAG_BOX));
            }

            // --- itunes ---
            if (meta.hasChild(BoxType.ITUNES_META_LIST_BOX))
            {
                parseITunesMetaData(meta.getChild(BoxType.ITUNES_META_LIST_BOX));
            }

            // --- nero tags ---
            if (meta.hasChild(BoxType.NERO_METADATA_TAGS_BOX))
            {
                throw new NotImplementedException();
                // parseNeroTags((NeroMetadataTagsBox)meta.getChild(BoxType.NERO_METADATA_TAGS_BOX));
            }
        }
예제 #16
0
                public void Reset()
                {
                    IBox box = _enum.SearchBox.Clone();

                    box.Max.X = box.Min.X;
                    var entry = new TileEntry(box, null);

                    _iPos = _elemList.BinarySearch(entry, _comparer);

                    if (_iPos < 0)
                    {
                        _iPos = ~_iPos;
                    }
                    else
                    {
                        if (_excludeEqual)
                        {
                            _iPos++;
                            while (_iPos < _nElems &&
                                   _comparer.Compare(_elemList[_iPos], entry) == 0)
                            {
                                _iPos++;
                            }
                        }
                        else
                        {
                            _iPos--;
                            while (_iPos >= 0 &&
                                   _comparer.Compare(_elemList[_iPos], entry) == 0)
                            {
                                _iPos--;
                            }

                            _iPos++;
                        }
                    }
                }
예제 #17
0
        private int Check([NotNull] PlaneHelper planeHelper,
                          [NotNull] IPointsEnumerator points,
                          [NotNull] IFeature feature,
                          [NotNull] IFeature related)
        {
            var errorCount = 0;

            if (ReportNonCoplanarity)
            {
                errorCount += planeHelper.ReportErrors(feature);
            }

            if (!planeHelper.IsPlaneDefined)
            {
                return(errorCount);
            }

            if (IgnoreNonCoplanarFaces && !planeHelper.IsCoplanar)
            {
                return(errorCount);
            }

            if (_minimumSlopeTan2 > 0 && planeHelper.GetSlopeTan2() < _minimumSlopeTan2)
            {
                return(errorCount);
            }

            IBox box = planeHelper.GetSearchBox();

            foreach (Pnt point in points.GetPoints(box))
            {
                errorCount += Check(planeHelper, point, points.XYTolerance, CheckMethod,
                                    feature, related);
            }

            return(errorCount);
        }
예제 #18
0
        /// <summary>
        /// Updates data.
        /// </summary>
        /// <typeparam name="T">The type definition of data.</typeparam>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="values">The list of data.</param>
        /// <returns><c>true</c> if update the list of data success, <c>false</c> otherwise.</returns>
        public bool Update <T>(string tableName, params T[] values) where T : class
        {
            CheckDisposed();

            try
            {
                if (database != null && values != null)
                {
                    using (IBox box = database.Cube())
                    {
                        for (int i = 0, length = values.Length; i < length; ++i)
                        {
                            T data = values[i];
                            box.Bind(tableName).Update <T>(data);
                        }

                        CommitResult result = box.Commit();

                        if (result.Equals(CommitResult.OK))
                        {
                            return(true);
                        }
                        else
                        {
                            Debug.LogError(result.GetErrorMsg(box));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.LogException(exception);
            }

            return(false);
        }
예제 #19
0
        /// <summary>
        /// Deletes data by the given primary key value.
        /// </summary>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="primaryKeyValues">The primary key values.</param>
        /// <returns><c>true</c> if delete data success, <c>false</c> otherwise.</returns>
        public bool Delete(string tableName, params object[] primaryKeyValues)
        {
            CheckDisposed();

            try
            {
                if (database != null && primaryKeyValues != null)
                {
                    using (IBox box = database.Cube())
                    {
                        for (int i = 0, length = primaryKeyValues.Length; i < length; ++i)
                        {
                            object primaryKeyValue = primaryKeyValues[i];
                            box.Bind(tableName, primaryKeyValue).Delete();
                        }

                        CommitResult result = box.Commit();

                        if (result.Equals(CommitResult.OK))
                        {
                            return(true);
                        }
                        else
                        {
                            Debug.LogError(result.GetErrorMsg(box));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.LogException(exception);
            }

            return(false);
        }
예제 #20
0
        public void UpdateCollisions()
        {
            foreach (IBox box in CollisionTiles)
            {
                World.Remove(box);
            }
            CollisionTiles.Clear();

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    AddTileCollisions(Tiles[x, y]);
                }
            }

            IBox leftBox  = World.Create(-16 + 1, 0, 16, Height * 16);
            IBox rightBox = World.Create(Width * 16 - 1, 0, 16, Height * 16);
            IBox baseBox  = World.Create(0, Height * 16 - 1, Width * 16, 16);

            CollisionTiles.Add(leftBox);
            CollisionTiles.Add(rightBox);
            CollisionTiles.Add(baseBox);
        }
        void readContent()
        {
            // --- read all boxes ---
            while (inStream.hasLeft())
            {
                var box = BoxFactory.parseBox(null, inStream);
                if (boxes.Count == 0 && box.getType() != BoxType.FILE_TYPE_BOX)
                {
                    throw new MP4Exception("no MP4 signature found");
                }
                boxes.Add(box);

                var type = box.getType();
                if (type == BoxType.FILE_TYPE_BOX)
                {
                    if (ftyp == null)
                    {
                        ftyp = (FileTypeBox)box;
                    }
                }
                else if (type == BoxType.MOVIE_BOX)
                {
                    if (movie == null)
                    {
                        moov = box;
                    }
                }
                else if (type == BoxType.PROGRESSIVE_DOWNLOAD_INFORMATION_BOX)
                {
                    if (pdin == null)
                    {
                        pdin = (ProgressiveDownloadInformationBox)box;
                    }
                }
            }
        }
예제 #22
0
        public long indexTextNoTran(AutoBox auto, int commitCount, long id, String str, bool isRemove)
        {
            if (id == -1)
            {
                return(-1);
            }
            long itCount = 0;

            char[]         cs  = sUtil.clear(str);
            List <KeyWord> map = sUtil.fromString(id, cs, true);


            IBox box    = null;
            int  ccount = 0;

            foreach (KeyWord kw in map)
            {
                if (box == null)
                {
                    box    = auto.Cube();
                    ccount = commitCount;
                }
                insertToBox(box, kw, isRemove);
                itCount++;
                if (--ccount < 1)
                {
                    box.Commit().Assert();
                    box = null;
                }
            }
            if (box != null)
            {
                box.Commit().Assert();
            }
            return(itCount);
        }
예제 #23
0
        private Rect Simulate(List <IHit> hits, List <IObstacle> ignoring, IBox box, Rect origin, Rect destination, Func <ICollision, ICollisionResponse> filter)
        {
            var nearest = this.Hit(origin, destination, ignoring);

            if (nearest != null)
            {
                hits.Add(nearest);

                var impact    = new Rect(nearest.Position, origin.Size);
                var collision = new Collision()
                {
                    Box = box, Hit = nearest, Goal = destination, Origin = origin
                };
                var response = filter(collision);

                if (response != null && destination != response.Destination)
                {
                    ignoring.Add(nearest.Box);
                    return(this.Simulate(hits, ignoring, box, impact, response.Destination, filter));
                }
            }

            return(destination);
        }
 public void ToFile(IBox box, string path)
 {
     NonGenericInstance.ToFile(box, path);
 }
 public byte[] AsBytes(IBox box)
 {
     return(NonGenericInstance.AsBytes(box));
 }
 public abstract IEnumerable <Proximity> GetProximities([NotNull] Pnt point,
                                                        bool as3D,
                                                        [NotNull] IBox box);
예제 #27
0
 public void Create(float x, float y)
 {
     Box = World.Create(x - 4, y - 4, 8, 8);
     Box.AddTags(CollisionTag.Character);
     Box.Data = this;
 }
예제 #28
0
 public static IObservable <Envelope> Observe(this IBox box, string channel, string topic)
 {
     return(new PostalObservable(box, channel, topic));
 }
 public abstract string AsString(IBox box);
예제 #30
0
 public ConstructSiteseer(IBox outbox, IBox collection, List<string> ns, Dictionary<object, object> symtab, Dictionary<string, string> aliases)
 {
     m_collection = collection;
     m_outbox = outbox;
     m_ns = ns;
     m_symtab = symtab;
     m_aliases = aliases;
 }
예제 #31
0
 public IEnumerable <KeyWord> search(IBox box, String str)
 {
     return(search(box, str, long.MaxValue));
 }
예제 #32
0
 public BoxViewContext(string boxName)
 {
     this.box = BoxHelper.GetBox(boxName);
 }
예제 #33
0
 public void print(IBox box)
 {
     object o = box.get();
     string typename = o != null ? o.GetType().FullName : typeof(void).FullName;
     Console.WriteLine(" => <{0}> {1}", typename, Literal.try_format(o));
 }
예제 #34
0
 public TopLevelVectInterpreter(Environment env, TxtLocation loc, Print print, IBox outbox)
     : base(env, loc, outbox)
 {
     m_print = print;
 }
        private void SetNHibernateTransformation(IBox box, string typename)
        {
            var bType = Type.GetType(typename);
            var eType = _repoFinder.Mappings.First(t => t.Item2 == bType).Item1;

            var dataTransType = typeof(NHibernateBoxTransformation<,>).MakeGenericType(bType, eType);
            var dataTrans = _componentContext.Resolve(dataTransType);
            dataTransType.GetProperty("ImportStrategy").SetValue(dataTrans, BoxImporterStrategy.UpdateExisting, null);
            dataTransType.GetMethod("Transform").Invoke(dataTrans, new[] { box });
        }
예제 #36
0
 public Block(IBox box, BlockType type) : base(box)
 {
     box.Data  = this;
     this.type = type;
 }
 public override void ToStream(IBox box, Stream stream)
 {
     var serializer = new XmlSerializer(box.GetType());
     serializer.Serialize(stream, box);
 }
예제 #38
0
 public static void CancelDelegate(IBox box)
 {
     WorkflowService.WfcInstance.CancelDelegate();
     WorkflowService.IsMyAllDelegated = false;
     box.RefreshData();
 }
 public abstract byte[] AsBytes(IBox box);
예제 #40
0
 public void TestCleanup()
 {
     _box = null;
 }
 public override string AsString(IBox box)
 {
     return Encoding.Default.GetString(AsBytes(box));
 }
예제 #42
0
 public void TestInit()
 {
     _box = _BOX_BUILDER
             .Build();
 }
예제 #43
0
 public static IDisposable Observe(this IBox box, string channel, string topic, IObserver <Envelope> observer)
 {
     return(new PostalObservable(box, channel, topic).Subscribe(observer));
 }
예제 #44
0
 Table(IBoxBuilder boxBuilder)
 {
     _bank = boxBuilder.Build();
     _boxes.Add(boxBuilder.Build());
 }
예제 #45
0
 protected bool IgnoresCollision(IBox box)
 {
     return(Incorporeal || box.HasTag(CollisionTag.NoCollision) || box.HasTag(CollisionTag.Character));
 }
예제 #46
0
        /*
         * Ray-box intersection using IEEE numerical properties to ensure that the
         * test is both robust and efficient, as described in:
         *
         *      Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley
         *      "An Efficient and Robust Ray-Box Intersection Algorithm"
         *      Journal of graphics tools, 10(1):49-54, 2005
         *
         */
        public static bool RayAABBTest(Ray r, IBox box)
        {
            const float t0 = float.NegativeInfinity;
            const float t1 = float.PositiveInfinity;
            Vector3[] bounds = new[] {box.Min, box.Max};
            Vector3 rInvDir = new Vector3(1 / r.Direction.X, 1 / r.Direction.Y, 1 / r.Direction.Z);
            int rSignX = rInvDir.X < 0 ? 1 : 0;
            int rSignY = rInvDir.Y < 0 ? 1 : 0;
            int rSignZ = rInvDir.Z < 0 ? 1 : 0;

            float tMin = (bounds[rSignX].X - r.Position.X) * rInvDir.X;
            float tMax = (bounds[1 - rSignX].X - r.Position.X) * rInvDir.X;
            float tyMin = (bounds[rSignY].Y - r.Position.Y) * rInvDir.Y;
            float tyMax = (bounds[1 - rSignY].Y - r.Position.Y) * rInvDir.Y;

            if ((tMin > tyMax) || (tyMin > tMax))
                return false;
            if (tyMin > tMin)
                tMin = tyMin;
            if (tyMax < tMax)
                tMax = tyMax;

            float tzMin = (bounds[rSignZ].Z - r.Position.Z)*rInvDir.Z;
            float tzMax = (bounds[1 - rSignZ].Z - r.Position.Z)*rInvDir.Z;

            if ((tMin > tzMax) || (tzMin > tMax))
                return false;
            if (tzMin > tMin)
                tMin = tzMin;
            if (tzMax < tMax)
                tMax = tzMax;
            return ((tMin < t1) && (tMax > t0));
        }
 public string AsString(IBox box)
 {
     return(NonGenericInstance.AsString(box));
 }
 public override void ToStream(IBox box, Stream stream)
 {
     serializer.Serialize(stream, box);
 }
 public void ToStream(IBox box, Stream stream)
 {
     NonGenericInstance.ToStream(box, stream);
 }
예제 #50
0
 public void SetFrame(IBox frame)
 {
     this.frame = frame;
 }
예제 #51
0
 public BoxConsumer(IBox b)
 {
     this.TheString = b.Name;
 }
 public abstract void ToStream(IBox box, Stream stream);
예제 #53
0
        public SortedSet <String> discover(IBox box,
                                           char efrom, char eto, int elength,
                                           char nfrom, char nto, int nlength)
        {
            SortedSet <String> list = new SortedSet <String>();
            Random             ran  = new Random();

            if (elength > 0)
            {
                int    len = ran.Next(KeyWord.MAX_WORD_LENGTH) + 1;
                char[] cs  = new char[len];
                for (int i = 0; i < cs.Length; i++)
                {
                    cs[i] = (char)(ran.Next(eto - efrom) + efrom);
                }
                KeyWordE kw = new KeyWordE();
                kw.setKeyWord(new String(cs));
                foreach (KeyWord tkw in lessMatch(box, kw))
                {
                    String str = tkw.getKeyWord().ToString();
                    if (str.Length < 3)
                    {
                        continue;
                    }
                    int c = list.Count;
                    list.Add(str);
                    if (list.Count > c)
                    {
                        elength--;
                        if (elength <= 0)
                        {
                            break;
                        }
                    }
                }
            }
            if (nlength > 0)
            {
                char[] cs = new char[2];
                for (int i = 0; i < cs.Length; i++)
                {
                    cs[i] = (char)(ran.Next(nto - nfrom) + nfrom);
                }
                KeyWordN kw = new KeyWordN();
                kw.longKeyWord(cs[0], cs[1], (char)0);
                foreach (KeyWord tkw in lessMatch(box, kw))
                {
                    int c = list.Count;
                    list.Add(((KeyWordN)tkw).toKString());
                    if (list.Count > c)
                    {
                        nlength--;
                        if (nlength <= 0)
                        {
                            break;
                        }
                    }
                }
            }
            return(list);
        }
예제 #54
0
 public VectInterpreter(Environment env, TxtLocation loc, IBox outbox)
     : base(outbox)
 {
     m_env = env;
     m_loc = loc;
 }
예제 #55
0
        private static IEnumerable <KeyWord> search(IBox box,
                                                    KeyWord kw, KeyWord con, MaxID maxId)
        {
            String ql = kw is KeyWordE
                ? "from /E where K==? & I<=?"
                    : "from /N where K==? & I<=?";


            int linkPos = kw.isLinked ? (con.getPosition() + con.size()
                                         + (kw is KeyWordE ? 1 : 0)) : -1;

            long    currentMaxId       = long.MaxValue;
            KeyWord cache              = null;
            IEnumerator <KeyWord> iter = null;
            bool isLinkEndMet          = false;

            return(new Iterable <KeyWord>()
            {
                iterator = new EngineIterator <KeyWord>()
                {
                    hasNext = () =>
                    {
                        if (maxId.id == -1)
                        {
                            return false;
                        }

                        if (currentMaxId > (maxId.id + 1))
                        {
                            currentMaxId = maxId.id;
                            iter = kw is KeyWordE ?
                                   (IEnumerator <KeyWord>)box.Select <KeyWordE>(ql, kw.getKeyWord(), maxId.id).GetEnumerator() :
                                   box.Select <KeyWordN>(ql, kw.getKeyWord(), maxId.id).GetEnumerator();
                        }

                        while (iter.MoveNext())
                        {
                            cache = iter.Current;

                            maxId.id = cache.getID();
                            currentMaxId = maxId.id;
                            if (con != null && con.I != maxId.id)
                            {
                                return false;
                            }

                            if (isLinkEndMet)
                            {
                                continue;
                            }

                            if (linkPos == -1)
                            {
                                return true;
                            }

                            int cpos = cache.getPosition();
                            if (cpos > linkPos)
                            {
                                continue;
                            }
                            if (cpos == linkPos)
                            {
                                if (kw.isLinkedEnd)
                                {
                                    isLinkEndMet = true;
                                }
                                return true;
                            }
                            return false;
                        }

                        maxId.id = -1;
                        return false;
                    },

                    next = () =>
                    {
                        return cache;
                    }
                }
            });
        }
 public override byte[] AsBytes(IBox box)
 {
     return Encoding.Default.GetBytes(AsString(box));
 }
예제 #57
0
 /// <summary>
 /// Returns a Postal.NET box implementation that uses a default set of conventions.
 /// </summary>
 /// <param name="box">A Postal.NET box implementation.</param>
 /// <returns>A Postal.NET box implementation that uses conventions.</returns>
 public static IConventionsBox WithDefaultConventions(this IBox box)
 {
     return(WithConventions(box)
            .AddChannelConvention <object>((data) => data.GetType().Namespace)
            .AddTopicConvention <object>((data) => data.GetType().Name));
 }
 public override void ToStream(IBox box, System.IO.Stream stream)
 {
     var bytes = AsBytes(box);
     stream.Write(bytes, 0, bytes.Length);
 }