Example #1
0
        /// <summary>
        /// Get dependencies for part1
        /// </summary>
        /// <returns></returns>
        public IList <IFigure> GetPart2Dependencies()
        {
            List <IFigure> result = new List <IFigure>();

            switch (this.ViewDirection)
            {
            case Reinforcement.ViewDirection.Top:
            case Reinforcement.ViewDirection.Front:
            {
                switch (Transform)
                {
                case Reinforcement.Transform.Normal:
                {
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, 0, -this.Dimensions.A)));                 // Điểm chèn ban đầu
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, this.Dimensions.B, -this.Dimensions.A)));
                    return(result);
                }

                case Reinforcement.Transform.FlipHorizontal:
                {
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, 0, -this.Dimensions.A)));                 // Điểm chèn ban đầu
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, -this.Dimensions.B, -this.Dimensions.A)));
                    return(result);
                }

                case Reinforcement.Transform.FlipVertical:
                {
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, 0, this.Dimensions.A)));                 // Điểm chèn ban đầu
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, this.Dimensions.B, this.Dimensions.A)));
                    return(result);
                }

                case Reinforcement.Transform.Rotate90CCW:
                {
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, this.Dimensions.A, 0)));                 // Điểm chèn ban đầu
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, this.Dimensions.A, this.Dimensions.B)));
                    return(result);
                }

                case Reinforcement.Transform.Rotate90CW:
                {
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, -this.Dimensions.A, 0)));                 // Điểm chèn ban đầu
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, -this.Dimensions.A, -this.Dimensions.B)));
                    return(result);
                }

                case Reinforcement.Transform.Rotate180:
                {
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, 0, this.Dimensions.A)));                 // Điểm chèn ban đầu
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, -this.Dimensions.B, this.Dimensions.A)));
                    return(result);
                }

                default: return(null);
                }
            }

            default: return(null);
            }
        }
Example #2
0
        public override void Recalculate()
        {
            IPoint point = (IPoint)MainBound.Dependencies[0];

            point       = Factory.CreateFreePoint(Drawing, PointsHelper.Offset(point.Coordinates, 0, 0));
            InsertPoint = PointsHelper.Offset(point.Coordinates, 0, 0);
            base.Recalculate();
        }
        /// <summary>
        /// See BS 8666:2005
        /// </summary>
        /// <returns></returns>
        public List <IFigure> CalculateBarDependencies()
        {
            List <IFigure> result    = new List <DynamicGeometry.IFigure>();
            Point          basePoint = new System.Windows.Point(0, 0);

            result.Add(Factory.CreateFreePoint(this.Drawing, basePoint)); // Điểm chèn ban đầu

            switch (this.ShapeCode)
            {
            case BarShape2D.Shape00:
            {
                switch (ViewDirection)
                {
                case Reinforcement.ViewDirection.Top:
                {
                    switch (Transform)
                    {
                    case Reinforcement.Transform.Normal:
                        result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(basePoint, this.Dimensions.A, 0)));
                        return(result);

                    case Reinforcement.Transform.Rotate90CW:
                        result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(basePoint, 0, -this.Dimensions.A)));
                        return(result);

                    case Reinforcement.Transform.Rotate90CCW:
                        result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(basePoint, 0, this.Dimensions.A)));
                        return(result);

                    case Reinforcement.Transform.Rotate180:
                        result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(basePoint, -this.Dimensions.A, 0)));
                        return(result);

                    case Reinforcement.Transform.FlipHorizontal:                     // ??
                        return(null);

                    case Reinforcement.Transform.FlipVertical:                     // ??
                        return(null);

                    default: return(null);
                    }
                }

                case Reinforcement.ViewDirection.Cross:
                {
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(basePoint, this.Diameter, 0)));
                    return(result);
                }

                default: return(null);
                }
            }

            // so on...
            default: return(null);
            }
        }
Example #4
0
 private void RegisterComponent(PointsHelper helper)
 {
     if (helper)
     {
         helper.Points
         .Skip(1)
         .Subscribe(f => _config.PointsText.text = Math.Floor(f).ToString(CultureInfo.InvariantCulture));
     }
 }
Example #5
0
        public IList <IFigure> GetCrossPartDependencies()
        {
            switch (this.ViewDirection)
            {
            case Reinforcement.ViewDirection.Cross:
            {
                List <IFigure> result = new List <IFigure>();
                result.Add(Factory.CreateFreePoint(this.Drawing, InsertPoint));
                result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(InsertPoint, 0.5 * Diameter, 0)));
                return(result);
            }

            default: return(null);
            }
        }
Example #6
0
        /// <summary>
        /// Tính toán các điểm Dependencies của Bound
        /// </summary>
        protected List <IFigure> GetBoundDependencies()
        {
            //this.Dependencies.Clear();
            var boundDependencies = new List <IFigure>();

            #region Bệ mố
            // bệ
            System.Windows.Point p1 = this.InsertPoint;
            System.Windows.Point p2 = PointsHelper.Offset(p1, 0, PileCapDeep);
            // thân
            System.Windows.Point p3  = PointsHelper.Offset(p2, PileCapBackLength, 0);
            System.Windows.Point p4  = PointsHelper.Offset(p3, 0, BodyHeight + HeadWallHeight - AppBlockFromTop - 2 * AppBlockDeep);
            System.Windows.Point p5  = PointsHelper.Offset(p4, -AppBlockWidth, AppBlockDeep);
            System.Windows.Point p6  = PointsHelper.Offset(p5, 0, AppBlockDeep);
            System.Windows.Point p7  = PointsHelper.Offset(p6, AppBlockWidth, 0);
            System.Windows.Point p8  = PointsHelper.Offset(p7, 0, AppBlockFromTop);
            System.Windows.Point p9  = PointsHelper.Offset(p8, HeadWallDeep, 0);
            System.Windows.Point p10 = PointsHelper.Offset(p9, 0, -HeadWallHeight);
            System.Windows.Point p11 = PointsHelper.Offset(p10, BodyDeep - HeadWallDeep, 0);
            System.Windows.Point p12 = PointsHelper.Offset(p11, 0, -BodyHeight);
            System.Windows.Point p13 = PointsHelper.Offset(p12, PileCapFrontLength, 0);
            System.Windows.Point p14 = PointsHelper.Offset(p13, 0, -PileCapDeep);

            var pp1  = Factory.CreateFreePoint(Drawing, p1);
            var pp2  = Factory.CreateFreePoint(Drawing, p2);
            var pp3  = Factory.CreateFreePoint(Drawing, p3);
            var pp4  = Factory.CreateFreePoint(Drawing, p4);
            var pp5  = Factory.CreateFreePoint(Drawing, p5);
            var pp6  = Factory.CreateFreePoint(Drawing, p6);
            var pp7  = Factory.CreateFreePoint(Drawing, p7);
            var pp8  = Factory.CreateFreePoint(Drawing, p8);
            var pp9  = Factory.CreateFreePoint(Drawing, p9);
            var pp10 = Factory.CreateFreePoint(Drawing, p10);
            var pp11 = Factory.CreateFreePoint(Drawing, p11);
            var pp12 = Factory.CreateFreePoint(Drawing, p12);
            var pp13 = Factory.CreateFreePoint(Drawing, p13);
            var pp14 = Factory.CreateFreePoint(Drawing, p14);
            #endregion


            boundDependencies.Add(pp1, pp2, pp3, pp4, pp5, pp6, pp7, pp8, pp9, pp10, pp11, pp12, pp13, pp14, pp1);
            foreach (IPoint p in boundDependencies)
            {
                this.Dependencies.Add(p);
            }
            return(boundDependencies);
        }
Example #7
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.LabelField("Please select root of the prefab and type of points.");

        base.OnInspectorGUI();
        PointsHelper trg = (PointsHelper)target;

        if (trg.target != null && trg.pointsType == PointsType.Custom && trg.target.GetType() == typeof(Transform))
        {
            IPointsAssignable[] components = trg.target.gameObject.GetComponents <IPointsAssignable>();

            List <string> options = new List <string>(components.Length + 1);
            options.Add("Ambiguous target. Please select");
            string lastOption = "";
            int    count      = 0;
            foreach (IPointsAssignable component in components)
            {
                if (component.GetType().Name.Equals(lastOption))
                {
                    count++;
                    options.Add(component.GetType().Name + $" ({count})");
                }
                else
                {
                    lastOption = component.GetType().Name;
                    count      = 0;
                    options.Add(lastOption);
                }
            }

            selected = EditorGUILayout.Popup(selected, options.ToArray());
            if (selected > 0 && selected - 1 < components.Length)
            {
                trg.target = (Component)components[selected - 1];
            }
        }

        if (GUILayout.Button("Apply points"))
        {
            trg.Assign();
        }
    }
Example #8
0
        /// <summary>
        /// Get dependencies for part3
        /// </summary>
        /// <returns></returns>
        protected IList <IFigure> GetPart3Dependencies()
        {
            switch (ViewDirection)
            {
            case Reinforcement.ViewDirection.Front:
            {
                switch (Transform)
                {
                case Reinforcement.Transform.Normal:
                {
                    List <IFigure> result = new List <IFigure>();
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(this.InsertPoint,
                                                                                         -(Dimensions.C - 0.5 * Dimensions.B) * M.Cos(RotateRAD) + Dimensions.B * M.Sin(RotateRAD),
                                                                                         -(Dimensions.C - 0.5 * Dimensions.B) * M.Sin(RotateRAD) - Dimensions.B * M.Cos(RotateRAD))));

                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(this.InsertPoint,
                                                                                         -(Dimensions.C - 0.5 * Dimensions.B) * M.Cos(RotateRAD) + Dimensions.B * M.Sin(RotateRAD) + (Dimensions.A - 0.5 * Dimensions.B) * M.Cos(RotateRAD),
                                                                                         -(Dimensions.C - 0.5 * Dimensions.B) * M.Sin(RotateRAD) - Dimensions.B * M.Cos(RotateRAD) + (Dimensions.A - 0.5 * Dimensions.B) * M.Sin(RotateRAD))));

                    return(result);
                }

                case Reinforcement.Transform.FlipHorizontal:
                {
                    List <IFigure> result = new List <IFigure>();
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(this.InsertPoint,
                                                                                         (this.Dimensions.C - 0.5 * Dimensions.B) * M.Cos(RotateRAD) + this.Dimensions.B * M.Sin(RotateRAD),
                                                                                         (this.Dimensions.C - 0.5 * Dimensions.B) * M.Sin(RotateRAD) - this.Dimensions.B * M.Cos(RotateRAD))));
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(this.InsertPoint, this.Dimensions.C * M.Cos(RotateRAD) + this.Dimensions.B * M.Sin(RotateRAD) - this.Dimensions.A * M.Cos(RotateRAD),
                                                                                         this.Dimensions.C * M.Sin(RotateRAD) - this.Dimensions.B * M.Cos(RotateRAD) - this.Dimensions.A * M.Sin(RotateRAD))));
                    return(result);
                }

                case Reinforcement.Transform.FlipVertical:
                {
                    List <IFigure> result = new List <IFigure>();
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(this.InsertPoint,
                                                                                         -(this.Dimensions.C - 0.5 * Dimensions.B) * M.Cos(RotateRAD) - Dimensions.B * M.Sin(RotateRAD),
                                                                                         -(this.Dimensions.C - 0.5 * Dimensions.B) * M.Sin(RotateRAD) + Dimensions.B * M.Cos(RotateRAD))));
                    result.Add(Factory.CreateFreePoint(this.Drawing, PointsHelper.Offset(this.InsertPoint,
                                                                                         -(this.Dimensions.C - 0.5 * Dimensions.B) * M.Cos(RotateRAD) - Dimensions.B * M.Sin(RotateRAD)
                                                                                         + (Dimensions.A + 0.5 * Dimensions.B) * M.Cos(RotateRAD),
                                                                                         -(this.Dimensions.C - 0.5 * Dimensions.B) * M.Sin(RotateRAD) + Dimensions.B * M.Cos(RotateRAD)
                                                                                         + (Dimensions.A + 0.5 * Dimensions.B) * M.Sin(RotateRAD))));
                    return(result);
                }

                case Reinforcement.Transform.Rotate180:
                {
                    goto case Reinforcement.Transform.Normal;
                }

                case Reinforcement.Transform.Rotate90CCW:
                {
                    goto case Reinforcement.Transform.Normal;
                }

                case Reinforcement.Transform.Rotate90CW:
                {
                    goto case Reinforcement.Transform.Normal;
                }

                default: return(null);
                }
            }

            case Reinforcement.ViewDirection.Top:
            {
                switch (Transform)
                {
                case Reinforcement.Transform.Normal:
                case Reinforcement.Transform.FlipHorizontal:
                case Reinforcement.Transform.FlipVertical:
                {
                    List <IFigure> result = new List <IFigure>();
                    result.Add(Factory.CreateFreePoint(Drawing, PointsHelper.Offset(this.InsertPoint,
                                                                                    -0.5 * Dimensions.A * M.Cos(RotateRAD), -0.5 * Dimensions.A * M.Sin(RotateRAD))));
                    result.Add(Factory.CreateFreePoint(Drawing, PointsHelper.Offset(this.InsertPoint,
                                                                                    0.5 * Dimensions.A * M.Cos(RotateRAD), 0.5 * Dimensions.A * M.Sin(RotateRAD))));
                    return(result);
                }

                case Reinforcement.Transform.Rotate180:
                {
                    Rotate += 90;                 // Gọi phương thức này 2 lần
                    goto case Reinforcement.Transform.Normal;
                }

                case Reinforcement.Transform.Rotate90CCW:
                {
                    Rotate += 45;                 // Gọi phương thức này 2 lần
                    goto case Reinforcement.Transform.Normal;
                }

                case Reinforcement.Transform.Rotate90CW:
                {
                    Rotate += -45;                 // Gọi phương thức này 2 lần
                    goto case Reinforcement.Transform.Normal;
                }

                default: return(null);
                }
            }

            case Reinforcement.ViewDirection.Left:
                return(null);

            default: return(null);
            }
        }
Example #9
0
    private void GenerateCustomMap()
    {
        List <RoomHelper> currentRoom = new List <RoomHelper>();

        currentRoom.Add(startingRoom.GetComponent <RoomHelper>());

        bool created;

        for (int i = 0; i < maxRooms; i++)
        {
            created = false;
            for (int r = 0; r < currentRoom.Count; r++)
            {
                Debug.Log(currentRoom.Count);
                if (created)
                {
                    break;
                }

                for (int j = 0; j < currentRoom[r].availablePoints.Count; j++)
                {
                    PointsHelper pointsHelper = currentRoom[r].availablePoints[j];

                    if (pointsHelper.inUse == false)
                    {
                        if (pointsHelper.roomTypeNeeded == 0)
                        {
                            int rng     = UnityEngine.Random.Range(0, upTileSets.Count);
                            var newRoom = Instantiate(upTileSets[rng], pointsHelper.transform.position,
                                                      upTileSets[rng].transform.rotation);

                            pointsHelper.inUse = true;
                            created            = true;
                            currentRoom.Add(newRoom.GetComponent <RoomHelper>());
                        }
                        else if (pointsHelper.roomTypeNeeded == 1)
                        {
                            int rng     = UnityEngine.Random.Range(0, downTileSets.Count);
                            var newRoom = Instantiate(downTileSets[rng], pointsHelper.transform.position,
                                                      downTileSets[rng].transform.rotation);

                            pointsHelper.inUse = true;
                            created            = true;
                            currentRoom.Add(newRoom.GetComponent <RoomHelper>());
                        }
                        else if (pointsHelper.roomTypeNeeded == 2)
                        {
                            int rng     = UnityEngine.Random.Range(0, leftTileSets.Count);
                            var newRoom = Instantiate(leftTileSets[rng], pointsHelper.transform.position,
                                                      leftTileSets[rng].transform.rotation);

                            pointsHelper.inUse = true;
                            created            = true;
                            currentRoom.Add(newRoom.GetComponent <RoomHelper>());
                        }
                        else if (pointsHelper.roomTypeNeeded == 3)
                        {
                            int rng     = UnityEngine.Random.Range(0, rightTileSets.Count);
                            var newRoom = Instantiate(rightTileSets[rng], pointsHelper.transform.position,
                                                      rightTileSets[rng].transform.rotation);

                            pointsHelper.inUse = true;
                            created            = true;
                            currentRoom.Add(newRoom.GetComponent <RoomHelper>());
                        }
                        else if (pointsHelper.roomTypeNeeded == 4)
                        {
                            int rng     = UnityEngine.Random.Range(0, roomPrefabs.Count);
                            var newRoom = Instantiate(roomPrefabs[rng], pointsHelper.transform.position,
                                                      roomPrefabs[rng].transform.rotation);

                            pointsHelper.inUse = true;
                            created            = true;
                            //currentRoom.Add(newRoom.GetComponent<RoomHelper>());
                        }
                        break;
                    }
                }
            }
        }
    }