Example #1
0
        /// <summary>
        /// Method to add Slab - SS
        /// </summary>
        /// <param name="name">name of Slab</param>
        /// <param name="instituteId">institute id</param>
        /// <returns>message</returns>
        public async Task <SharedLookUpResponse> AddSlabAsync(AddSlabManagementAc addSlab, int instituteId)
        {
            if (!await _iMSDbContext.Slabs.AnyAsync(x => x.InstituteId == instituteId && x.Code.ToLowerInvariant() == addSlab.Code.ToLowerInvariant()))
            {
                var Slab = new Slab()
                {
                    CreatedOn   = DateTime.UtcNow,
                    InstituteId = instituteId,
                    Name        = addSlab.Name,
                    Code        = addSlab.Code,
                    Description = addSlab.Description,
                    Status      = true
                };
                _iMSDbContext.Slabs.Add(Slab);
                await _iMSDbContext.SaveChangesAsync();

                return(new SharedLookUpResponse()
                {
                    HasError = false, Message = "Slab added successfully"
                });
            }
            else
            {
                return new SharedLookUpResponse()
                       {
                           HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Slab with the same name is already exist"
                       }
            };
        }
Example #2
0
 public KeyValuePair <string, List <Slab> > GetSlabRecord(string recordID, int page, int pageSize, string whereCondition, string sort)
 {
     try
     {
         Slab           Slab       = new Slab();
         SqlParameter[] Parameters = { new SqlParameter("@SlabMasterSNo", recordID), new SqlParameter("@PageNo", page), new SqlParameter("@PageSize", pageSize), new SqlParameter("@WhereCondition", whereCondition), new SqlParameter("@OrderBy", sort) };
         DataSet        ds         = SqlHelper.ExecuteDataset(DMLConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordSlab", Parameters);
         // return resultData.Tables[0].AsEnumerable().ToList();
         var SlabList = ds.Tables[0].AsEnumerable().Select(e => new Slab
         {
             SNo           = Convert.ToInt32(e["SNo"]),
             SlabMasterSNo = Convert.ToInt32(e["SlabMasterSNo"]),
             SlabName      = e["SlabName"].ToString(),
             StartWeight   = e["StartWeight"].ToString(),
             EndWeight     = e["EndWeight"].ToString(),
             CreatedBy     = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).UserSNo.ToString(),
             UpdatedBy     = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).UserSNo.ToString()
         });
         return(new KeyValuePair <string, List <Slab> >(ds.Tables[1].Rows[0][0].ToString(), SlabList.AsQueryable().ToList()));
     }
     catch (Exception ex)//
     {
         throw ex;
     }
 }
Example #3
0
        public void EdgeConnectionTest5()
        {
            var ec = new EdgeConnection(
                Releases.Motions.Define(xNeg: 123.4),
                Releases.Rotations.RigidLine(),
                "My library connection"
                );

            Slab slab = CreateDummySlab();

            slab = Slab.EdgeConnection(slab, ec, 0);

            var model = new Model(Country.S, new List <GenericClasses.IStructureElement> {
                slab
            });

            string output = "Shells/EdgeConnection_Out.struxml";

            model.SerializeModel(output);

            var deserialized = Model.DeserializeFromFilePath(output);

            Assert.IsTrue(deserialized.Entities.Slabs.Count == 1);
            var actualEdgeConnections = deserialized.Entities.Slabs.First().SlabPart.GetEdgeConnections();

            Assert.IsTrue(actualEdgeConnections.Where(e => e != null).Count() == 1);
            var first = actualEdgeConnections.First();

            Assert.IsTrue(first.IsLibraryItem);
            Assert.IsFalse(first.IsCustomItem);
            Assert.AreEqual("My library connection", first.LibraryName);
            Assert.IsNull(first.Rigidity);
            Assert.IsNotNull(first.PredefRigidity);
            Assert.AreEqual(123.4, first.PredefRigidity.Rigidity.Motions.XNeg, delta: 1e-6);
        }
Example #4
0
        private void PlaceSlab(Slab slab, int originX, int originY, int scale)
        {
            for (int x = 0; x < scale; ++x)
            {
                for (int y = 0; y < scale; ++y)
                {
                    Tile tile = GenBase._tiles[originX + x, originY + y];
                    if (TileID.Sets.Ore[tile.type])
                        tile.ResetToType(tile.type);
                    else
                        tile.ResetToType(367);

                    bool active = slab.State(x, y, scale);
                    tile.active(active);
                    if (slab.HasWall)
                        tile.wall = 178;

                    WorldUtils.TileFrame(originX + x, originY + y, true);
                    WorldGen.SquareWallFrame(originX + x, originY + y, true);
                    Tile.SmoothSlope(originX + x, originY + y, true);
                    if (WorldGen.SolidTile(originX + x, originY + y - 1) && GenBase._random.Next(4) == 0)
                        WorldGen.PlaceTight(originX + x, originY + y, 165, false);
                    if (WorldGen.SolidTile(originX + x, originY + y) && GenBase._random.Next(4) == 0)
                        WorldGen.PlaceTight(originX + x, originY + y - 1, 165, false);
                }
            }
        }
Example #5
0
        private static Slab CreateDummySlab()
        {
            string input    = "Shells/EdgeConnection-model.struxml";
            var    template = Model.DeserializeFromFilePath(input);

            var p1 = new Geometry.FdPoint3d(0, 0, 0);
            var p2 = new Geometry.FdPoint3d(1, 0, 0);
            var p3 = new Geometry.FdPoint3d(1, 1, 0);
            var p4 = new Geometry.FdPoint3d(0, 1, 0);

            var edges = new List <Geometry.Edge> {
                new Geometry.Edge(p1, p2, Geometry.FdCoordinateSystem.Global()),
                new Geometry.Edge(p2, p3, Geometry.FdCoordinateSystem.Global()),
                new Geometry.Edge(p3, p4, Geometry.FdCoordinateSystem.Global()),
                new Geometry.Edge(p4, p1, Geometry.FdCoordinateSystem.Global())
            };
            var contour = new Geometry.Contour(edges);
            var region  = new Geometry.Region(new List <Geometry.Contour> {
                contour
            }, Geometry.FdCoordinateSystem.Global());
            var slab = Slab.Plate("S", template.Materials.Material[0], region, EdgeConnection.GetDefault(), ShellEccentricity.GetDefault(), ShellOrthotropy.GetDefault(), new List <Thickness> {
                new Thickness(Geometry.FdPoint3d.Origin(), 0.2)
            });

            return(slab);
        }
Example #6
0
        private IEnumerable <ThemeStyleResource> GetUserMouseThemedResources(UserContext userContext)
        {
            if (userContext == null || userContext.FeaturesManager == null)
            {
                return(new ThemeStyleResource[0]);
            }
            List <ThemeStyleResource> list   = new List <ThemeStyleResource>();
            string       owaVersion          = userContext.CurrentOwaVersion;
            SlabManifest slabManifest        = SlabManifestCollectionFactory.GetInstance(owaVersion).GetSlabManifest(SlabManifestType.Standard, LayoutType.Mouse);
            IDictionary <string, Slab> slabs = slabManifest.GetSlabs(userContext.FeaturesManager.GetClientEnabledFeatures(), LayoutType.Mouse);
            Slab bootSlab = null;

            if (slabs.ContainsKey("boot"))
            {
                bootSlab = slabs["boot"];
                list.AddRange(UserResourcesFinder.GetUserDataEmbededStylesLinks(bootSlab, owaVersion));
            }
            IEnumerable <SlabStyleFile> source = (from p in slabManifest.GetSlabs(userContext.FeaturesManager.GetClientEnabledFeatures(), LayoutType.Mouse)
                                                  where p.Value != bootSlab
                                                  select p).SelectMany((KeyValuePair <string, Slab> p) => p.Value.Styles);
            IEnumerable <ThemeStyleResource> collection = from style in source
                                                          where style.IsSprite()
                                                          select new ThemeStyleResource(style.Name, ResourceTarget.MouseOnly, owaVersion, ThemeManagerFactory.GetInstance(owaVersion).ShouldSkipThemeFolder);

            list.AddRange(collection);
            IEnumerable <LocalizedThemeStyleResource> collection2 = from style in source
                                                                    where !style.IsSprite()
                                                                    select new LocalizedThemeStyleResource(style.Name, ResourceTarget.MouseOnly, owaVersion, ThemeManagerFactory.GetInstance(owaVersion).ShouldSkipThemeFolder);

            list.AddRange(collection2);
            return(list);
        }
Example #7
0
 private void PlaceSlab(Slab slab, int originX, int originY, int scale)
 {
     for (var x = 0; x < scale; ++x)
     {
         for (var y = 0; y < scale; ++y)
         {
             var tile = _tiles[originX + x, originY + y];
             if (TileID.Sets.Ore[tile.type])
             {
                 tile.ResetToType(tile.type);
             }
             else
             {
                 tile.ResetToType(367);
             }
             var active = slab.State(x, y, scale);
             tile.active(active);
             if (slab.HasWall)
             {
                 tile.wall = 178;
             }
             WorldUtils.TileFrame(originX + x, originY + y, true);
             WorldGen.SquareWallFrame(originX + x, originY + y, true);
             Tile.SmoothSlope(originX + x, originY + y, true);
             if (WorldGen.SolidTile(originX + x, originY + y - 1) && _random.Next(4) == 0)
             {
                 WorldGen.PlaceTight(originX + x, originY + y, 165, false);
             }
             if (WorldGen.SolidTile(originX + x, originY + y) && _random.Next(4) == 0)
             {
                 WorldGen.PlaceTight(originX + x, originY + y - 1, 165, false);
             }
         }
     }
 }
Example #8
0
 private void PlaceSlab(Slab slab, int originX, int originY, int scale)
 {
     for (int i = 0; i < scale; i++)
     {
         for (int j = 0; j < scale; j++)
         {
             Tile tile = GenBase._tiles[originX + i, originY + j];
             if (TileID.Sets.Ore[tile.type])
             {
                 tile.ResetToType(tile.type);
             }
             else
             {
                 tile.ResetToType(367);
             }
             bool active = slab.State(i, j, scale);
             tile.active(active);
             if (slab.HasWall)
             {
                 tile.wall = 178;
             }
             WorldUtils.TileFrame(originX + i, originY + j, true);
             WorldGen.SquareWallFrame(originX + i, originY + j);
             Tile.SmoothSlope(originX + i, originY + j);
             if (WorldGen.SolidTile(originX + i, originY + j - 1) && GenBase._random.Next(4) == 0)
             {
                 WorldGen.PlaceTight(originX + i, originY + j, 165);
             }
             if (WorldGen.SolidTile(originX + i, originY + j) && GenBase._random.Next(4) == 0)
             {
                 WorldGen.PlaceTight(originX + i, originY + j - 1, 165);
             }
         }
     }
 }
Example #9
0
        /// <summary>
        /// Get a new pooled item.
        /// </summary>
        public IntPtr Get()
        {
            if (_freeListLength > 0)
            {
                _freeListLength -= 1;
                return((IntPtr)_freeList[_freeListLength]);
            }
            else
            {
                if (_slabs[_currentSlab].NextIndex == _itemsPerSlab)
                {
                    if (_currentSlab == _slabs.Length - 1)
                    {
                        var newSlabs = new Slab[_slabs.Length * 2];
                        for (var i = 0; i < _slabs.Length; ++i)
                        {
                            newSlabs[i] = _slabs[i];
                        }
                        _slabs = newSlabs;
                        for (var i = _currentSlab + 1; i < _slabs.Length; ++i)
                        {
                            newSlabs[i] = CreateSlab();
                        }
                    }

                    _currentSlab += 1;
                }

                return((IntPtr)(_slabs[_currentSlab].Ptr + _itemSize * (_slabs[_currentSlab].NextIndex++)));
            }
        }
Example #10
0
        private int Items(Server current, Slab slab)
        {
            int rc = 0;

            try
            {
                if (slab != null)
                {
                    Dictionary <string, Item> items = slab.Items;
                    if (items != null)
                    {
                        foreach (Item item in items.Values)
                        {
                            if (IsValid(item))
                            {
                                log.Trace(string.Format("Found valid item {0}", item.Name));
                                DoOperation(current, item);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Items", ex);
                rc = 4;
            }
            return(rc);
        }
Example #11
0
 public SlabStateMoving(SlabManager.Settings settings, Slab slab, Controls controls, SlabManager slabManager)
 {
     this.slab        = slab;
     this.controls    = controls;
     this.slabManager = slabManager;
     this.settings    = settings;
 }
        public void GenerateFirstSlabsStack()
        {
            int start = 0;
            int end   = MAX_SIZE * MAX_SIZE;

            int basePosX = 80;
            int basePosY = -80;

            int[] numbers = Enumerable.Range(start + 1, end).ToArray();
            numbers.GenerateEnum(start, end);

            for (int i = 0; i < MAX_SIZE; i++)
            {
                for (int j = 0; j < MAX_SIZE; j++)
                {
                    Slabs[i, j] = new Slab();
                    Slabs[i, j].Initialize(numbers[_slabIndex], basePosX, basePosY, i, j);

                    _slabIndex++;
                    basePosX += 110;
                }

                basePosY -= 110;
                basePosX  = 80;
            }
        }
Example #13
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Surface surface    = new GH_Surface();
            GH_String  lvlbtm     = new GH_String("");
            GH_String  style      = new GH_String("");
            GH_String  layer      = new GH_String("");
            GH_Number  taperAng   = new GH_Number(0);
            GH_Number  height     = new GH_Number();
            GH_Point   stop       = new GH_Point();
            GH_Point   sbtm       = new GH_Point();
            GH_Boolean structural = new GH_Boolean(true);

            List <Parameter> param = new List <Parameter>();

            if (!DA.GetDataList <Parameter>("Parameters", param))
            {
                param = new List <Parameter>();
            }
            DA.GetData <GH_Surface>("Surface", ref surface);

            DA.GetData <GH_String>("Layer", ref layer);
            //DA.GetData<GH_String>("Style", ref style);
            DA.GetData <GH_Number>("taperAngle", ref taperAng);
            DA.GetData <GH_Number>("height", ref height);

            Slab s = new Slab();

            s.FamilyOrStyle   = style.Value;
            s.TypeOrLayer     = layer.Value;
            s.levelbottom     = lvlbtm.Value;
            s.structural      = structural.Value;
            s.surface         = new Profile();
            s.surface.profile = new List <Loop>();
            Loop loop = new Loop()
            {
                outline = new List <Component>()
            };

            foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges)
            {
                loop.outline.Add(be.ToNurbsCurve().ToGrevitCurve());
            }
            s.surface.profile.Add(loop);


            s.height     = height.Value;
            s.parameters = param;
            //s.top = ComponentUtilities.GHPoint2Point(stop);
            //s.bottom = ComponentUtilities.GHPoint2Point(sbtm);
            s.slope = taperAng.Value;
            s.GID   = this.InstanceGuid.ToString();


            //SetPreview(s.GID, surface.Value);
            DA.SetData("GrevitComponent", s);
        }
Example #14
0
 /// <summary>
 /// Create a new slab pool.
 /// </summary>
 /// <param name="itemSize">The size of the items.</param>
 /// <param name="itemsPerSlab">The number of items per slab.</param>
 /// <param name="initialSlabs">The initiual slab count.</param>
 public SlabPool(int itemSize, int itemsPerSlab = 1024, int initialSlabs = 1)
 {
     _itemSize     = itemSize;
     _itemsPerSlab = itemsPerSlab;
     _slabs        = new Slab[initialSlabs];
     for (int i = 0; i < initialSlabs; ++i)
     {
         _slabs[i] = CreateSlab();
     }
 }
Example #15
0
 public static void RegSlabForID(int id, Slab slab)
 {
     if (SlabDic.ContainsKey(id))
     {
         SlabDic[id] = slab;
     }
     else
     {
         SlabDic.Add(id, slab);
     }
 }
        private void PlaceSlab(Slab slab, int originX, int originY, int scale)
        {
            ushort num  = 367;
            ushort wall = 178;

            if (WorldGen.drunkWorldGen)
            {
                num  = 368;
                wall = 180;
            }
            int num2 = -1;
            int num3 = scale + 1;
            int num4 = 0;
            int num5 = scale;

            for (int i = num2; i < num3; i++)
            {
                if ((i == num2 || i == num3 - 1) && WorldGen.genRand.Next(2) == 0)
                {
                    continue;
                }
                if (WorldGen.genRand.Next(2) == 0)
                {
                    num4--;
                }
                if (WorldGen.genRand.Next(2) == 0)
                {
                    num5++;
                }
                for (int j = num4; j < num5; j++)
                {
                    Tile tile = GenBase._tiles[originX + i, originY + j];
                    tile.ResetToType(TileID.Sets.Ore[tile.type] ? tile.type : num);
                    bool active = slab.State(i, j, scale);
                    tile.active(active);
                    if (slab.HasWall)
                    {
                        tile.wall = wall;
                    }
                    WorldUtils.TileFrame(originX + i, originY + j, frameNeighbors: true);
                    WorldGen.SquareWallFrame(originX + i, originY + j);
                    Tile.SmoothSlope(originX + i, originY + j);
                    if (WorldGen.SolidTile(originX + i, originY + j - 1) && GenBase._random.Next(4) == 0)
                    {
                        WorldGen.PlaceTight(originX + i, originY + j);
                    }
                    if (WorldGen.SolidTile(originX + i, originY + j) && GenBase._random.Next(4) == 0)
                    {
                        WorldGen.PlaceTight(originX + i, originY + j - 1);
                    }
                }
            }
        }
        public void Initialize()
        {
            Slabs         = new Slab[MAX_SIZE, MAX_SIZE];
            _currentIndex = 1;
            _slabIndex    = 0;
            _countSpawned = 25;
            IsGameStart   = false;
            IsGameLose    = false;

            Player       = new Player(3, 0);
            _speedElapse = 1.5f;
        }
        public void DesignSlabs()
        {
            TotalPanelsFloor = CalcTotalPanels(internalData);
            CalcUniquePanels(internalData.GridX, internalData.GridY);
            //i think iterating slab objects is the best strategy
            FloorSlabCollection = new List<Slab>();

            for (int i = 0; i < UniquePanels; i++)
            {
                Slab newSlab = new Slab();
                newSlab.Design(internalData);
                FloorSlabCollection.Add(newSlab);
            }
        }
Example #19
0
        public async Task <ActionResult> SlabCreate([Bind(Include = "SlabId,SlabName,Description,IsActive,CreatedBy,CreatedDate,ModifiedBy,ModifiedDate")] Slab slab)
        {
            slab.CreatedBy    = 1;
            slab.ModifiedBy   = 1;
            slab.CreatedDate  = DateTime.Now;
            slab.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.slabs.Add(slab);
                await db.SaveChangesAsync();

                return(Json(new { success = true }));
            }

            return(PartialView("_SlabCreate", slab));
        }
Example #20
0
    public Score(int index, string score)
    {
        var slab = new Slab();

        var leftPartition = new VisualElement {
            style = { flexGrow = 0.4f }
        };
        var rightPartition = new VisualElement {
            style = { flexGrow = 1f }
        };

        leftPartition.AddToClassList("partition");
        rightPartition.AddToClassList("partition");
        rightPartition.AddToClassList("partition-underline");

        var ranking = new Label {
            text = (index + 1).ToString()
        };
        var avatar = new Image();

        leftPartition.Add(ranking);
        leftPartition.Add(avatar);

        var name = new Label {
            text = score, style = { flexGrow = 1 }
        };
        var kills = new Label {
            text = 7.ToString()
        };
        var time = new Label {
            text = DateTime.UtcNow.Hour + ":" + DateTime.UtcNow.Minute
        };

        rightPartition.Add(name);
        rightPartition.Add(kills);
        rightPartition.Add(time);

        slab.Add(leftPartition);
        slab.Add(rightPartition);
        Add(slab);
        this.AddManipulator(new ScoreManipulator(slab));
    }
Example #21
0
        public static Slab GetSelectedSlab()
        {
            try
            {
                var test = (SlabBuilderBoardTool)SingletonBehaviour <SlabBuilderBoardTool> .Instance;
            }
            catch { }
            var flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static;

            if (SingletonBehaviour <BoardToolManager> .HasInstance && (SingletonBehaviour <BoardToolManager> .Instance.IsCurrentTool <SlabBuilderBoardTool>()))
            {
                var  sbbt = (SlabBuilderBoardTool)SingletonBehaviour <SlabBuilderBoardTool> .Instance;
                Slab slab = (Slab)sbbt.GetType().GetField("_slab", flags).GetValue(sbbt);
                return(slab);
            }
            else
            {
                return(null);
            }
        }
Example #22
0
        private void RotateSelected(double amount)
        {
            try
            {
                // We have to first grab the CameraController._targetZoomLerpValue to disable the movement when our rotate is happening. This is the only way to prevent zooming while we are rotating
                var flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static;
                if (SingletonBehaviour <BoardToolManager> .HasInstance && (SingletonBehaviour <BoardToolManager> .Instance.IsCurrentTool <SingleBuilderBoardTool>()))
                {
                    var   btm   = (SingleBuilderBoardTool)SingletonBehaviour <SingleBuilderBoardTool> .Instance;
                    float angle = (float)btm.GetType().GetField("_angle", flags).GetValue(btm);
                    angle = (float)(((double)angle + amount) % 360.0);

                    // After adjusting don't forget to push it back to TaleSpire so they can keep track of it.
                    btm.GetType().GetField("_angle", flags).SetValue(btm, angle);
                    var selectedAsset = (TilePreviewBoardAsset)btm.GetType().GetField("_selectedTileBoardAsset", flags).GetValue(btm);
                    selectedAsset.Rotate(angle);

                    // Next we need to counter the heightPlaneOffset that is set in the CallUpdate when left shift is pressed
                    float heightPlaneOffset = (float)btm.GetType().GetField("heightPlaneOffset", flags).GetValue(btm);
                    heightPlaneOffset -= (float)((double)Input.mouseScrollDelta.y * (double)Time.deltaTime * 8.0);
                    btm.GetType().GetField("heightPlaneOffset", flags).SetValue(btm, heightPlaneOffset);
                }
                if (SingletonBehaviour <BoardToolManager> .HasInstance && (SingletonBehaviour <BoardToolManager> .Instance.IsCurrentTool <SlabBuilderBoardTool>()))
                {
                    var  sbbt = (SlabBuilderBoardTool)SingletonBehaviour <SlabBuilderBoardTool> .Instance;
                    Slab slab = (Slab)sbbt.GetType().GetField("_slab", flags).GetValue(sbbt);
                    slab.Rotate90();
                }
            }
            catch (System.Exception ex)
            {
                UnityEngine.Debug.Log("Crash in r for rotate Plugin");
                UnityEngine.Debug.Log(ex.Message);
                UnityEngine.Debug.Log(ex.StackTrace);
                UnityEngine.Debug.Log(ex.InnerException);
                UnityEngine.Debug.Log(ex.Source);
            }
        }
Example #23
0
        private void SmoothSlope(int x, int y)
        {
            Slab slab = _slabs[x, y];

            if (slab.IsSolid)
            {
                bool ısSolid  = _slabs[x, y - 1].IsSolid;
                bool ısSolid2 = _slabs[x, y + 1].IsSolid;
                bool ısSolid3 = _slabs[x - 1, y].IsSolid;
                bool ısSolid4 = _slabs[x + 1, y].IsSolid;
                switch (((ısSolid ? 1 : 0) << 3) | ((ısSolid2 ? 1 : 0) << 2) | ((ısSolid3 ? 1 : 0) << 1) | (ısSolid4 ? 1 : 0))
                {
                case 10:
                    _slabs[x, y] = slab.WithState(SlabStates.TopLeftFilled);
                    break;

                case 9:
                    _slabs[x, y] = slab.WithState(SlabStates.TopRightFilled);
                    break;

                case 6:
                    _slabs[x, y] = slab.WithState(SlabStates.BottomLeftFilled);
                    break;

                case 5:
                    _slabs[x, y] = slab.WithState(SlabStates.BottomRightFilled);
                    break;

                case 4:
                    _slabs[x, y] = slab.WithState(SlabStates.HalfBrick);
                    break;

                default:
                    _slabs[x, y] = slab.WithState(SlabStates.Solid);
                    break;
                }
            }
        }
Example #24
0
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                if (isset.slab)
                {
                    hashcode = (hashcode * 397) + Slab.GetHashCode();
                }
                if (isset.start_page)
                {
                    hashcode = (hashcode * 397) + Start_page.GetHashCode();
                }
                if (isset.num_pages)
                {
                    hashcode = (hashcode * 397) + Num_pages.GetHashCode();
                }
                if (isset.touch)
                {
                    hashcode = (hashcode * 397) + Touch.GetHashCode();
                }
                if (isset.chunk_key)
                {
                    hashcode = (hashcode * 397) + TCollections.GetHashCode(Chunk_key);
                }
                if (isset.buffer_epoch)
                {
                    hashcode = (hashcode * 397) + Buffer_epoch.GetHashCode();
                }
                if (isset.is_free)
                {
                    hashcode = (hashcode * 397) + Is_free.GetHashCode();
                }
            }
            return(hashcode);
        }
Example #25
0
        private void SmoothSlope(int x, int y)
        {
            Slab slab = _slabs[x, y];

            if (!slab.IsSolid)
            {
                return;
            }

            switch ((_slabs[x, y - 1].IsSolid ? 1 : 0) << 3 | (_slabs[x, y + 1].IsSolid ? 1 : 0) << 2 | (_slabs[x - 1, y].IsSolid ? 1 : 0) << 1 | (_slabs[x + 1, y].IsSolid ? 1 : 0))
            {
            case 4:
                _slabs[x, y] = slab.WithState(new SlabState(SlabStates.HalfBrick));
                break;

            case 5:
                _slabs[x, y] = slab.WithState(new SlabState(SlabStates.BottomRightFilled));
                break;

            case 6:
                _slabs[x, y] = slab.WithState(new SlabState(SlabStates.BottomLeftFilled));
                break;

            case 9:
                _slabs[x, y] = slab.WithState(new SlabState(SlabStates.TopRightFilled));
                break;

            case 10:
                _slabs[x, y] = slab.WithState(new SlabState(SlabStates.TopLeftFilled));
                break;

            default:
                _slabs[x, y] = slab.WithState(new SlabState(SlabStates.Solid));
                break;
            }
        }
Example #26
0
        public static ComponentCollection ParseDocument(string filename, double conversion)
        {
            ComponentCollection collection = new ComponentCollection();

            collection.scale  = conversion;
            collection.delete = false;

            using (var ms = new System.IO.MemoryStream())
            {
                PdfReader     myPdfReader = new PdfReader(filename);
                PdfDictionary pageDict    = myPdfReader.GetPageN(1);
                PdfArray      annotArray  = pageDict.GetAsArray(PdfName.ANNOTS);



                for (int i = 0; i < annotArray.Size; i++)
                {
                    PdfDictionary curAnnot = annotArray.GetAsDict(i);
                    PdfName       subject  = curAnnot.GetAsName(PdfName.SUBTYPE);
                    if (subject != null)
                    {
                        if (subject == PdfName.CIRCLE)
                        {
                            PdfArray arr = curAnnot.GetAsArray(PdfName.RECT);

                            Point a = new Point(arr[0].ToDouble(), arr[1].ToDouble(), 0);
                            Point b = new Point(arr[0].ToDouble(), arr[1].ToDouble(), 5);

                            Column column = new Column("", "", null, a, b, "", false);
                            collection.Items.Add(column);
                        }

                        else if (subject == PdfName.LINE)
                        {
                            PdfArray arr2 = curAnnot.GetAsArray(PdfName.L);
                            Line     line = new Line()
                            {
                                from = new Point(arr2[0].ToDouble(), arr2[1].ToDouble(), 0),
                                to   = new Point(arr2[2].ToDouble(), arr2[3].ToDouble(), 0)
                            };

                            Wall wall = new Wall("", "", null, line, "", 5, false, false);
                            collection.Items.Add(wall);
                        }

                        else if (subject == PdfName.POLYGON)
                        {
                            PdfArray arr3 = curAnnot.GetAsArray(PdfName.VERTICES);
                            Profile  p    = new Profile();
                            Loop     l    = new Loop()
                            {
                                outline = new List <Component>()
                            };
                            for (int j = 0; j < arr3.Size - 2; j = j + 2)
                            {
                                Point a = new Point(arr3[j].ToDouble(), arr3[j + 1].ToDouble(), 0);
                                Point b = new Point(arr3[j + 2].ToDouble(), arr3[j + 3].ToDouble(), 0);
                                l.outline.Add(new Line()
                                {
                                    from = a, to = b
                                });
                            }
                            p.profile = new List <Loop>()
                            {
                                l
                            };
                            Slab s = new Slab()
                            {
                                surface = p
                            };
                            collection.Items.Add(s);
                        }
                    }
                }
            }

            return(collection);
        }
        /// <summary>
        /// gets the Slab form the _area and add it to  modelcontroller.
        /// </summary>
        /// <param name="_area"></param>
        public void CreateSlab(Area area)
        {
            Slab _slab = new Slab(area);
            //_presenter.RequestAddition<StructuralElement>(_slab);
            /*
              Command addSlab = new AddObjectCommand<StructuralElement>(_mainModel, _slab);

            if (addSlab.Execute())
                _mainPresenter.AddCommand(addSlab);
            else
                throw new Exception ("could not add Slab to Models ");
             * */
        }
Example #28
0
 public ReinforcedCadSlab(Slab _slab)
 {
     Slab = _slab;
     ReinforcementPopulate();
 }
Example #29
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (_slabs == null)
            {
                _slabs = new Slab[56, 26];
            }
            int num  = GenBase._random.Next(80, 150) / 3;
            int num2 = GenBase._random.Next(40, 60) / 3;
            int num3 = (num2 * 3 - GenBase._random.Next(20, 30)) / 3;

            origin.X -= num * 3 / 2;
            origin.Y -= num2 * 3 / 2;
            for (int i = -1; i < num + 1; i++)
            {
                float num4 = (float)(i - num / 2) / (float)num + 0.5f;
                int   num5 = (int)((0.5f - Math.Abs(num4 - 0.5f)) * 5f) - 2;
                for (int j = -1; j < num2 + 1; j++)
                {
                    bool hasWall = true;
                    bool flag    = false;
                    bool flag2   = IsGroupSolid(i * 3 + origin.X, j * 3 + origin.Y, 3);
                    int  num6    = Math.Abs(j - num2 / 2);
                    int  num7    = num6 - num3 / 4 + num5;
                    if (num7 > 3)
                    {
                        flag    = flag2;
                        hasWall = false;
                    }
                    else if (num7 > 0)
                    {
                        flag    = (j - num2 / 2 > 0 || flag2);
                        hasWall = (j - num2 / 2 < 0 || num7 <= 2);
                    }
                    else if (num7 == 0)
                    {
                        flag = (GenBase._random.Next(2) == 0 && (j - num2 / 2 > 0 || flag2));
                    }
                    if (Math.Abs(num4 - 0.5f) > 0.35f + GenBase._random.NextFloat() * 0.1f && !flag2)
                    {
                        hasWall = false;
                        flag    = false;
                    }
                    _slabs[i + 1, j + 1] = Slab.Create(flag ? new SlabState(SlabStates.Solid) : new SlabState(SlabStates.Empty), hasWall);
                }
            }
            for (int k = 0; k < num; k++)
            {
                for (int l = 0; l < num2; l++)
                {
                    SmoothSlope(k + 1, l + 1);
                }
            }
            int   num8   = num / 2;
            int   num9   = num2 / 2;
            int   num10  = (num9 + 1) * (num9 + 1);
            float value  = GenBase._random.NextFloat() * 2f - 1f;
            float num11  = GenBase._random.NextFloat() * 2f - 1f;
            float value2 = GenBase._random.NextFloat() * 2f - 1f;
            float num12  = 0f;

            for (int m = 0; m <= num; m++)
            {
                float num13 = (float)num9 / (float)num8 * (float)(m - num8);
                int   num14 = Math.Min(num9, (int)Math.Sqrt(Math.Max(0f, (float)num10 - num13 * num13)));
                num12 = ((m >= num / 2) ? (num12 + MathHelper.Lerp(num11, value2, (float)m / (float)(num / 2) - 1f)) : (num12 + MathHelper.Lerp(value, num11, (float)m / (float)(num / 2))));
                for (int n = num9 - num14; n <= num9 + num14; n++)
                {
                    PlaceSlab(_slabs[m + 1, n + 1], m * 3 + origin.X, n * 3 + origin.Y + (int)num12, 3);
                }
            }
            return(true);
        }
Example #30
0
        public void GetSlab()
        {
            GetFooting();

            this.lstSlab = new List <Slab>();
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;


            ObjectId lyrSlabId = ObjectId.Null;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                //wall layer
                LayerTable lyrTbl = trans.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
                if (!lyrTbl.Has("Slab"))
                {
                    return;
                }
                lyrSlabId = lyrTbl["Slab"];



                BlockTable blkTbl = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;

                BlockTableRecord blkTblModelSpaceRec = trans.GetObject(blkTbl[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;

                foreach (ObjectId objId in blkTblModelSpaceRec)
                {
                    Entity   plEnt = trans.GetObject(objId, OpenMode.ForRead) as Entity;
                    Polyline pline = plEnt as Polyline;
                    if (pline == null)
                    {
                        continue;
                    }
                    if (pline.LayerId == lyrSlabId && pline.Closed == true)
                    {
                        double         width       = double.MaxValue;
                        double         length      = 0;
                        List <Point2d> lstVertices = new List <Point2d>();

                        Point3d widthMidPt = Point3d.Origin;
                        for (int i = 0; i < pline.NumberOfVertices; i++)
                        {
                            if (i + 1 == pline.NumberOfVertices)
                            {
                                break;
                            }
                            double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(pline.GetPoint3dAt(i), pline.GetPoint3dAt(i + 1));
                            width = Math.Min(width, dist);
                            if (width == dist)
                            {
                                widthMidPt = MathHelper.MidPoint(pline.GetPoint3dAt(i), pline.GetPoint3dAt(i + 1));
                            }
                            length = Math.Max(length, dist);
                        }
                        Extents3d extents = pline.GeometricExtents;
                        Point3d   center  = extents.MinPoint + (extents.MaxPoint - extents.MinPoint) / 2.0;

                        Slab slab = new Slab(width, length, center, widthMidPt, pline.GetPoint3dAt(0).Z);
                        lstSlab.Add(slab);
                    }
                }


                trans.Commit();
            }



            //XbimCreateWall xbimWall = new XbimCreateWall(this.lstWalls, this.lstColumns, lstFooting);
            //XbimCreateWall xbimWall = new XbimCreateWall(this.lstWalls);
        }
Example #31
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (_slabs == null)
            {
                _slabs = new Slab[56, 26];
            }

            int num1 = GenBase._random.Next(80, 150) / 3;
            int num2 = GenBase._random.Next(40, 60) / 3;
            int num3 = (num2 * 3 - GenBase._random.Next(20, 30)) / 3;

            origin.X -= num1 * 3 / 2;
            origin.Y -= num2 * 3 / 2;
            for (int index1 = -1; index1 < num1 + 1; ++index1)
            {
                float num4 = (float)((index1 - num1 / 2) / num1 + 0.5);
                int   num5 = (int)((0.5 - (double)Math.Abs(num4 - 0.5f)) * 5.0) - 2;
                for (int index2 = -1; index2 < num2 + 1; ++index2)
                {
                    bool hasWall = true;
                    bool flag1   = false;
                    bool flag2   = IsGroupSolid(index1 * 3 + origin.X, index2 * 3 + origin.Y, 3);
                    int  num6    = Math.Abs(index2 - num2 / 2) - num3 / 4 + num5;
                    if (num6 > 3)
                    {
                        flag1   = flag2;
                        hasWall = false;
                    }
                    else if (num6 > 0)
                    {
                        flag1   = index2 - num2 / 2 > 0 || flag2;
                        hasWall = index2 - num2 / 2 < 0 || num6 <= 2;
                    }
                    else if (num6 == 0)
                    {
                        flag1 = GenBase._random.Next(2) == 0 && (index2 - num2 / 2 > 0 || flag2);
                    }

                    if ((double)Math.Abs(num4 - 0.5f) > 0.349999994039536 + (double)Utils.NextFloat(GenBase._random) * 0.100000001490116 && !flag2)
                    {
                        hasWall = false;
                        flag1   = false;
                    }

                    _slabs[index1 + 1, index2 + 1] = Slab.Create(flag1 ? new SlabState(SlabStates.Solid) : new SlabState(SlabStates.Empty), hasWall);
                }
            }

            for (int index1 = 0; index1 < num1; ++index1)
            {
                for (int index2 = 0; index2 < num2; ++index2)
                {
                    SmoothSlope(index1 + 1, index2 + 1);
                }
            }

            int   num7  = num1 / 2;
            int   val1  = num2 / 2;
            int   num8  = (val1 + 1) * (val1 + 1);
            float num9  = (float)(Utils.NextFloat(GenBase._random) * 2.0 - 1.0);
            float num10 = (float)(Utils.NextFloat(GenBase._random) * 2.0 - 1.0);
            float num11 = (float)(Utils.NextFloat(GenBase._random) * 2.0 - 1.0);
            float num12 = 0.0f;

            for (int index1 = 0; index1 <= num1; ++index1)
            {
                float num4 = (float)val1 / (float)num7 * (float)(index1 - num7);
                int   num5 = Math.Min(val1, (int)Math.Sqrt(Math.Max(0.0f, (float)num8 - num4 * num4)));
                if (index1 < num1 / 2)
                {
                    num12 += MathHelper.Lerp(num9, num10, (float)index1 / (float)(num1 / 2));
                }
                else
                {
                    num12 += MathHelper.Lerp(num10, num11, (float)(index1 / (num1 / 2) - 1.0));
                }

                for (int index2 = val1 - num5; index2 <= val1 + num5; ++index2)
                {
                    PlaceSlab(_slabs[index1 + 1, index2 + 1], index1 * 3 + origin.X, index2 * 3 + origin.Y + (int)num12, 3);
                }
            }

            return(true);
        }
Example #32
0
        private IfcSlab CreateIfcSlab(IfcStore model, Slab cadSlab)
        {
            //cadSlab.Length *= 1000;
            //cadSlab.Width *= 1000;
            //cadSlab.Thickness *= 1000;
            //cadSlab.CenterPt.X *= 1000;
            //cadSlab.CenterPt.Y *= 1000;

            //cadSlab.PtLengthDir.X *= 1000;
            //cadSlab.PtLengthDir.Y *= 1000;
            //
            double length = cadSlab.Length;
            double width  = cadSlab.Width;

            //begin a transaction
            using (ITransaction trans = model.BeginTransaction("Create Slab"))
            {
                IfcSlab slabToCreate = model.Instances.New <IfcSlab>();
                slabToCreate.Name = " Slab - Slab:UC305x305x97:" + random.Next(1000, 10000);

                //represent Element as a rectangular profile
                IfcRectangleProfileDef rectProf = IFCHelper.RectProfileCreate(model, length, width);

                //Profile insertion point
                rectProf.ProfileInsertionPointSet(model, 0, 0);


                //model as a swept area solid
                IfcDirection extrusionDir = model.Instances.New <IfcDirection>();
                extrusionDir.SetXYZ(0, 0, -1);

                IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, cadSlab.Thickness, rectProf, extrusionDir);


                //parameters to insert the geometry in the model
                body.BodyPlacementSet(model, 0, 0, 0);


                //Create a Definition shape to hold the geometry
                IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body");
                shape.Items.Add(body);



                //Create a Product Definition and add the model geometry to the wall
                IfcProductDefinitionShape prDefRep = model.Instances.New <IfcProductDefinitionShape>();
                prDefRep.Representations.Add(shape);
                slabToCreate.Representation = prDefRep;

                //Create Local axes system and assign it to the column
                IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>();
                location3D.SetXYZ(cadSlab.CenterPt.X, cadSlab.CenterPt.Y, cadSlab.CenterPt.Z);

                var uvColLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir);

                IfcDirection localXDir = model.Instances.New <IfcDirection>();
                localXDir.SetXYZ(uvColLongDir.X, uvColLongDir.Y, uvColLongDir.Z);

                IfcDirection localZDir = model.Instances.New <IfcDirection>();
                localZDir.SetXYZ(0, 0, 1);

                IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir);

                //now place the slab into the model
                IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D);
                slabToCreate.ObjectPlacement = lp;


                trans.Commit();
                return(slabToCreate);
            }
        }
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.BiomeTileCheck(origin.X, origin.Y))
            {
                return(false);
            }
            if (_slabs == null)
            {
                _slabs = new Slab[56, 26];
            }
            int num  = GenBase._random.Next(80, 150) / 3;
            int num2 = GenBase._random.Next(40, 60) / 3;
            int num3 = (num2 * 3 - GenBase._random.Next(20, 30)) / 3;

            origin.X -= num * 3 / 2;
            origin.Y -= num2 * 3 / 2;
            for (int i = -1; i < num + 1; i++)
            {
                double num4 = (double)(i - num / 2) / (double)num + 0.5;
                int    num5 = (int)((0.5 - Math.Abs(num4 - 0.5)) * 5.0) - 2;
                for (int j = -1; j < num2 + 1; j++)
                {
                    bool hasWall = true;
                    bool flag    = false;
                    bool flag2   = IsGroupSolid(i * 3 + origin.X, j * 3 + origin.Y, 3);
                    int  num6    = Math.Abs(j - num2 / 2) - num3 / 4 + num5;
                    if (num6 > 3)
                    {
                        flag    = flag2;
                        hasWall = false;
                    }
                    else if (num6 > 0)
                    {
                        flag    = j - num2 / 2 > 0 || flag2;
                        hasWall = j - num2 / 2 < 0 || num6 <= 2;
                    }
                    else if (num6 == 0)
                    {
                        flag = GenBase._random.Next(2) == 0 && (j - num2 / 2 > 0 || flag2);
                    }
                    if (Math.Abs(num4 - 0.5) > (double)(0.35f + GenBase._random.NextFloat() * 0.1f) && !flag2)
                    {
                        hasWall = false;
                        flag    = false;
                    }
                    _slabs[i + 1, j + 1] = Slab.Create(flag ? new SlabState(SlabStates.Solid) : new SlabState(SlabStates.Empty), hasWall);
                }
            }
            for (int k = 0; k < num; k++)
            {
                for (int l = 0; l < num2; l++)
                {
                    SmoothSlope(k + 1, l + 1);
                }
            }
            int   num7   = num / 2;
            int   num8   = num2 / 2;
            int   num9   = (num8 + 1) * (num8 + 1);
            float value  = GenBase._random.NextFloat() * 2f - 1f;
            float num10  = GenBase._random.NextFloat() * 2f - 1f;
            float value2 = GenBase._random.NextFloat() * 2f - 1f;
            float num11  = 0f;

            for (int m = 0; m <= num; m++)
            {
                float num12 = (float)num8 / (float)num7 * (float)(m - num7);
                int   num13 = Math.Min(num8, (int)Math.Sqrt(Math.Max(0f, (float)num9 - num12 * num12)));
                num11 = ((m >= num / 2) ? (num11 + MathHelper.Lerp(num10, value2, (float)m / (float)(num / 2) - 1f)) : (num11 + MathHelper.Lerp(value, num10, (float)m / (float)(num / 2))));
                for (int n = num8 - num13; n <= num8 + num13; n++)
                {
                    PlaceSlab(_slabs[m + 1, n + 1], m * 3 + origin.X, n * 3 + origin.Y + (int)num11, 3);
                }
            }
            structures.AddStructure(new Rectangle(origin.X, origin.Y, num * 3, num2 * 3), 8);
            return(true);
        }
        private void SetUp(Slab slab)
        {
            this.Slab = slab;
            boundingRect = Slab.Area.Polygon.BoundingCube(1.0f);

            IPoint p1 = new Point(boundingRect[0 ,0], Slab.Area.Polygon[0].Y, boundingRect[0, 2]);
            IPoint p2 = new Point(boundingRect[0, 0], Slab.Area.Polygon[0].Y, boundingRect[1, 2]);
            IPoint p3 = new Point(boundingRect[1, 0], Slab.Area.Polygon[0].Y, boundingRect[1, 2]);
            IPoint p4 = new Point(boundingRect[1, 0], Slab.Area.Polygon[0].Y, boundingRect[0, 2]);

            /*
            ConstructionLine line1 = new ConstructionLine();
            line1.SNode = p1;
            line1.ENode = p2;
            ConstructionLine line2 = new ConstructionLine();
            line2.SNode = p2;
            line2.ENode = p3;
            ConstructionLine line3 = new ConstructionLine();
            line3.SNode = p3;
            line3.ENode = p4;
            ConstructionLine line4 = new ConstructionLine();
            line4.SNode = p4;
            line4.ENode = p1;
            */
              //  _creator.CreateLine(line1);
               // _creator.CreateLine(line2);
              //  _creator.CreateLine(line3);
             //   _creator.CreateLine(line4);
        }