Ejemplo n.º 1
0
        public DxfDocument DrawSectionMarks(List <Section> sections)
        {
            List <LwPolylineVertex> vertexes = new List <LwPolylineVertex>()
            {
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this._SectionMarkOffsetH, Beam.I.Height + 3 * this._SectionMarkOffsetV),
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this._SectionMarkOffsetH, Beam.I.Height + 1 * this._SectionMarkOffsetV),
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this._SectionMarkOffsetH, -3 * this._SectionMarkOffsetV),
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this._SectionMarkOffsetH, -5 * this._SectionMarkOffsetV),
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this.SpanLength - this._SectionMarkOffsetH, Beam.I.Height + 3 * this._SectionMarkOffsetV),
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this.SpanLength - this._SectionMarkOffsetH, Beam.I.Height + 1 * this._SectionMarkOffsetV),
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this.SpanLength - this._SectionMarkOffsetH, -3 * this._SectionMarkOffsetV),
                new LwPolylineVertex(this._Translation + this.LeftSupportWidth + this.SpanLength - this._SectionMarkOffsetH, -5 * this._SectionMarkOffsetV),
            };

            Vector2[] textLocations =
            {
                new Vector2(this._Translation + this.LeftSupportWidth + this._SectionMarkOffsetH + 2,                   Beam.I.Height + 2 * this._SectionMarkOffsetV - 4),
                new Vector2(this._Translation + this.LeftSupportWidth + this._SectionMarkOffsetH + 2,                                  -4 * this._SectionMarkOffsetV - 4),
                new Vector2(this._Translation + this.LeftSupportWidth + this.SpanLength - this._SectionMarkOffsetH + 2, Beam.I.Height + 2 * this._SectionMarkOffsetV - 4),
                new Vector2(this._Translation + this.LeftSupportWidth + this.SpanLength - this._SectionMarkOffsetH + 2,                -4 * this._SectionMarkOffsetV - 4),
            };

            Section sectionL = new Section(
                this._TopLeftRbarDiameter / 10,
                this._NumberOfTopLeftRbars,
                this._BottomRbarDiameter / 10,
                this._NumberOfBottomRbars,
                string.Format("{0} - {0}L", this._Id));

            sections.Add(sectionL);

            Section sectionR = new Section(
                this._TopRightRbarDiameter / 10,
                this._NumberOfTopRightRbars,
                this._BottomRbarDiameter / 10,
                this._NumberOfBottomRbars,
                string.Format("{0} - {0}P", this._Id));

            sections.Add(sectionR);

            if (this.DrawLeftSection == true)
            {
                sectionL.Draw = true;

                LwPolyline markUpL = new LwPolyline(vertexes.GetRange(0, 2));
                markUpL.SetConstantWidth(this._SectionMarkWidth);
                Beam.I.Dxf.AddEntity(markUpL);

                Beam.I.Dxf.AddEntity(new Text(
                                         string.Format("{0}L", this._Id),
                                         textLocations[0],
                                         this._SectionMarkTextHeight));

                LwPolyline markDownL = new LwPolyline(vertexes.GetRange(2, 2));
                markDownL.SetConstantWidth(this._SectionMarkWidth);
                Beam.I.Dxf.AddEntity(markDownL);

                Beam.I.Dxf.AddEntity(new Text(
                                         string.Format("{0}L", this._Id),
                                         textLocations[1],
                                         this._SectionMarkTextHeight));
            }

            if (this.DrawRightSection == true)
            {
                sectionR.Draw = true;

                LwPolyline markUpR = new LwPolyline(vertexes.GetRange(4, 2));
                markUpR.SetConstantWidth(this._SectionMarkWidth);
                Beam.I.Dxf.AddEntity(markUpR);

                Beam.I.Dxf.AddEntity(new Text(
                                         string.Format("{0}P", this._Id),
                                         textLocations[2],
                                         this._SectionMarkTextHeight));

                LwPolyline markDownR = new LwPolyline(vertexes.GetRange(6, 2));
                markDownR.SetConstantWidth(this._SectionMarkWidth);
                Beam.I.Dxf.AddEntity(markDownR);

                Beam.I.Dxf.AddEntity(new Text(
                                         string.Format("{0}P", this._Id),
                                         textLocations[3],
                                         this._SectionMarkTextHeight));
            }
            return(Beam.I.Dxf);
        }
Ejemplo n.º 2
0
        public DxfDocument DrawRbar(int id, bool inside, double offset)
        {
            //decides where to put the rbar to avoid overlaping
            double factor, shift = Math.Max(Math.Abs(this.Y1 - this.Y0), Math.Abs(this.Y3 - this.Y2)) + 10;

            if (inside == true)
            {
                factor = 0;
            }
            else
            {
                factor = -Convert.ToInt32(id) % 2;
            }

            //checks if there are any hooks
            double shiftLeft = 0, bulgeLeft = 0, shiftRight = 0, bulgeRight = 0,
                   flipLeft = 1, flipRight = 1;

            if (this.Y1 - this.Y0 != 0)
            {
                shiftLeft = 2 * this.Diameter / 10;
                bulgeLeft = 0.4;
            }
            if (this.Y3 - this.Y2 != 0)
            {
                shiftRight = 2 * this.Diameter / 10;
                bulgeRight = 0.4;
            }
            if (this.Y0 < this.Y1)
            {
                flipLeft = -1;
            }
            if (this.Y3 < this.Y2)
            {
                flipRight = -1;
            }

            //find rbar boundary to draw
            List <netDxf.Entities.LwPolylineVertex> vertexes = new List <netDxf.Entities.LwPolylineVertex>()
            {
                new netDxf.Entities.LwPolylineVertex(this.X0, this.Y0 + offset - shift * factor),
                new netDxf.Entities.LwPolylineVertex(this.X1, this.Y1 + offset + flipLeft * shiftLeft - shift * factor, flipLeft * bulgeLeft),
                new netDxf.Entities.LwPolylineVertex(this.X1 + shiftLeft, this.Y1 + offset - shift * factor),
                new netDxf.Entities.LwPolylineVertex(this.X2 - shiftRight, this.Y2 + offset - shift * factor, flipRight * bulgeRight),
                new netDxf.Entities.LwPolylineVertex(this.X2, this.Y2 + offset + flipRight * shiftRight - shift * factor),
                new netDxf.Entities.LwPolylineVertex(this.X3, this.Y3 + offset - shift * factor),
            };

            //draw rbar
            LwPolyline rbar = new LwPolyline(vertexes.GetRange(0, 6));

            rbar.SetConstantWidth(this.Diameter / 10);
            Beam.I.Dxf.AddEntity(rbar);

            //if inside of the beam, return
            if (inside)
            {
                return(Beam.I.Dxf);
            }

            //find rbar points to annotate
            Vector2[] points =
            {
                new Vector2(this.X0, this.Y0 + offset - shift * factor),
                new Vector2(this.X1, this.Y1 + offset - shift * factor),
                new Vector2(this.X2, this.Y2 + offset - shift * factor),
                new Vector2(this.X3, this.Y3 + offset - shift * factor),
            };

            //generate description text
            string descriptionText = "(" + id + ") " + this.NumberOfRbars.ToString() + "#" + this.Diameter.ToString() + " L=";

            descriptionText += (Math.Abs(this.Y0 - this.Y1) + Math.Abs(this.X0 - this.X2) + Math.Abs(this.Y3 - this.Y2)).ToString();

            //add description of a rbar
            LinearDimension dim = new LinearDimension(
                points[1],
                points[2],
                1.8,
                0,
                Beam.I.DimensionStyles.Annotation);

            dim.UserText = descriptionText;
            Beam.I.Dxf.AddEntity(dim);

            //check if there's a left hook and dim
            if (this.Y0 != this.Y1)
            {
                LinearDimension leftHookDim = new LinearDimension(
                    points[0],
                    points[1],
                    -5.4,
                    90,
                    Beam.I.DimensionStyles.Rbars);
                Beam.I.Dxf.AddEntity(leftHookDim);
            }

            //draw dimension of the main part of a rbar
            LinearDimension rbarDim = new LinearDimension(
                points[1],
                points[2],
                -5.4,
                0,
                Beam.I.DimensionStyles.Rbars);

            Beam.I.Dxf.AddEntity(rbarDim);

            //check if there's a right hook and dim
            if (this.Y2 != this.Y3)
            {
                LinearDimension rightHookDim = new LinearDimension(
                    points[2],
                    points[3],
                    -5.4,
                    90,
                    Beam.I.DimensionStyles.Rbars);
                Beam.I.Dxf.AddEntity(rightHookDim);
            }
            return(Beam.I.Dxf);
        }