예제 #1
0
        /// <summary>
        /// Create the new RC calculation object.
        /// </summary>
        /// <param name="type">The type of the cross-section</param>
        /// <param name="rcGeometry">Set of geometry parameters.</param>
        /// <param name="coverTop">The top cover - to the reinforcement ceneter.</param>
        /// <param name="coverBottom">The top cover - to the reinforcement ceneter.</param>
        /// <returns>New RcVerificationHelperUtility object.</returns>
        public static RcVerificationHelperUtility CreateRcVerificationHelperUtility(SectionShapeType type, ref Geometry rcGeometry, double coverTop, double coverBottom)
        {
            if (SectionShapeType.RectangularBar != type && SectionShapeType.T != type)
            {
                throw new Exception("CreateRcVerificationHelperUtility.Unhandled cross section type. 3th party parameterization are necessary.");
            }
            // If you need to take into account other section you should modyfy SetReinforcementAsBar & GetReinforcementLine before you remove this exception!
            RcVerificationHelperUtility newUtility = new RcVerificationHelperUtility(type, ref rcGeometry, coverTop, coverBottom);

            return(newUtility);
        }
        public void DoBinding(SectionShapeType shapeType, ElementSectionsInfo sectionsInfo, bool isSteel = false)
        {
            sectionTypeName.Content = Tools.SectionShapeTypeName(shapeType);

            BitmapImage source = new BitmapImage();

            source.BeginInit();
            string uriString = "/SectionPropertiesExplorer;component/Resources/Images/section";
            string typeName  = Tools.SectionShapeTypeName(shapeType);
            string steelTxt  = "";

            if (shapeType == SectionShapeType.Z && isSteel)
            {
                steelTxt = "steel";
            }
            uriString       += typeName + steelTxt + ".png";
            source.UriSource = new Uri(uriString, UriKind.Relative);
            source.EndInit();
            sectionDefinition.Source = source;

            AddShapesToRender(sectionsInfo);
        }
예제 #3
0
        static public string SectionShapeTypeName(SectionShapeType shapeType)
        {
            string secName = "";

            switch (shapeType)
            {
            case SectionShapeType.RectangularHollowNotConstant:
                secName += "RectangularHollowNotConstant";
                break;

            case SectionShapeType.BoxBiSymmetrical:
                secName += "BoxBiSymmetrical";
                break;

            case SectionShapeType.BoxMonoSymmetrical:
                secName += "BoxMonoSymmetrical";
                break;

            case SectionShapeType.C:
                secName += "C";
                break;

            case SectionShapeType.CompoundSection:
                secName += "CompoundSection";
                break;

            case SectionShapeType.CrossBiSymmetrical:
                secName += "CrossBiSymmetrical";
                break;

            case SectionShapeType.DoubleRectangularBar:
                secName += "DoubleRectangularBar";
                break;

            case SectionShapeType.DoubleSection:
                secName += "DoubleSection";
                break;

            case SectionShapeType.I:
                secName += "I";
                break;

            case SectionShapeType.IASymmetrical:
                secName += "IASymmetrical";
                break;

            case SectionShapeType.L:
                secName += "L";
                break;

            case SectionShapeType.PolygonalBar:
                secName += "PolygonalBar";
                break;

            case SectionShapeType.PolygonalHollow:
                secName += "PolygonalHollow";
                break;

            case SectionShapeType.RectangularBar:
                secName += "RectangularBar";
                break;

            case SectionShapeType.RectangularHollowConstant:
                secName += "RectangularHollowConstant";
                break;

            case SectionShapeType.RoundBar:
                secName += "RoundBar";
                break;

            case SectionShapeType.HalfRoundBar:
                secName += "HalfRoundBar";
                break;

            case SectionShapeType.QuarterRoundBar:
                secName += "QuarterRoundBar";
                break;

            case SectionShapeType.T:
                secName += "T";
                break;

            case SectionShapeType.TAsymmetrical:
                secName += "TAsymmetrical";
                break;

            case SectionShapeType.RoundTube:
                secName += "RoundTube";
                break;

            case SectionShapeType.Unusual:
                secName += "Unusual";
                break;

            case SectionShapeType.Z:
                secName += "Z";
                break;

            default:
                break;
            }

            return(secName);
        }
예제 #4
0
        RCSolver solver;                     // solver
        /// <summary>
        /// Initializes a new instance of the new RC calculation helper object.
        /// </summary>
        /// <param name="type">The type of the cross-section</param>
        /// <param name="rcGeometry">Set of geometry parameters.</param>
        /// <param name="coverTop">The top cover - to the reinforcement ceneter.</param>
        /// <param name="coverBottom">The top cover - to the reinforcement ceneter.</param>
        private RcVerificationHelperUtility(SectionShapeType type, ref Geometry rcGeometry, double coverTop, double coverBottom)
        {
            double totalHeight = 0;                             // the height of the cross section
            double totalWidth  = 0;                             // the width of the cross section

            noTopBottom      = 5;                               // initial value of the number of bars on top and bottom
            noLeftRight      = noTopBottom - 2;                 // initial value of the number of bars on left and right
            solverGeometry   = new Geometry();                  // initialization of new geometry
            rebars           = new List <Rebar>();              // initialization of rebars list
            rebarsSide       = new List <CrossSectionSide>();   // initialization of bars position list
            crossSectionType = type;                            // set of section type
            rebarCover       = Math.Max(coverTop, coverBottom); // set of maximum cover
            rebarCoverTop    = coverTop;                        // set of top cover
            rebarCoverBottom = coverBottom;                     // set of bottom cover
            // In the input geometry left bottom corner is searched.
            // The maximum and minimum values for x and y coordinates
            int     leftBottomIndex = 0;
            double  x     = Double.MaxValue;
            double  y     = Double.MaxValue;
            double  xMin  = Double.MaxValue;
            double  yMin  = Double.MaxValue;
            double  xMax  = Double.MinValue;
            double  yMax  = Double.MinValue;
            int     i     = 0;
            int     count = rcGeometry.Count;
            Point2D p     = new Point2D(0, 0);

            for (i = 0; i < count; i++)
            {
                p    = rcGeometry.Point(i);
                xMin = Math.Min(xMin, p.X);
                yMin = Math.Min(yMin, p.Y);
                xMax = Math.Max(xMax, p.X);
                yMax = Math.Max(yMax, p.Y);
                if ((p.X - x) < geometryEpsilon)
                {
                    if ((p.Y - y) < geometryEpsilon)
                    {
                        y = p.Y;
                        x = p.X;
                        leftBottomIndex = i;
                    }
                }
            }
            totalHeight = (yMax - yMin);
            totalWidth  = (xMax - xMin);
            // The first point of new geometry will be in the bottom left point of geometry.
            // This is made for easy detailing.
            if (0 != leftBottomIndex)
            {
                solverGeometry.Clear();
                for (i = leftBottomIndex; i < count; i++)
                {
                    p = rcGeometry.Point(i);
                    solverGeometry.Add(p.X, p.Y);
                }
                count = leftBottomIndex;
                for (i = 0; i < count; i++)
                {
                    p = rcGeometry.Point(i);
                    solverGeometry.Add(p.X, p.Y);
                }
            }
            else
            {
                solverGeometry = rcGeometry;
            }
            // The orientation is changed if it is necessary.
            if (solverGeometry.isClockwiseOrientation()) // clockwise direction
            {
                count = solverGeometry.Count - 1;
                Geometry tmpGeometry = new Geometry();
                p = solverGeometry.Point(0);
                tmpGeometry.Add(p.X, p.Y);
                for (i = count; i > 0; i--)
                {
                    p = solverGeometry.Point(i);
                    tmpGeometry.Add(p.X, p.Y);
                }
                solverGeometry = tmpGeometry;
            }
            solver = RCSolver.CreateNewSolver(solverGeometry); // solver with geometry redy to use.
        }
        /// </structural_toolkit_2015>

        /// <summary>
        /// Initializes a new instance of the new RC calculation helper object.
        /// </summary>
        /// <param name="type">The type of the cross-section</param>
        /// <param name="rcGeometry">Set of geometry parameters.</param>
        /// <param name="coverTop">The top cover - to the reinforcement ceneter.</param>
        /// <param name="coverBottom">The top cover - to the reinforcement ceneter.</param>
        private RcVerificationHelperUtility(SectionShapeType type, ref Geometry rcGeometry, double coverTop, double coverBottom)
        {
            totalHeight      = 0;                               // initial value of the height of the cross section
            totalWidth       = 0;                               // initial value of the width of the cross section
            noTopBottom      = 5;                               // initial value of the number of bars on top and bottom
            noLeftRight      = noTopBottom - 2;                 // initial value of the number of bars on left and right
            solverGeometry   = new Geometry();                  // initialization of new geometry
            rebars           = new List <Rebar>();              // initialization of rebars list
            rebarsSide       = new List <CrossSectionSide>();   // initialization of bars position list
            crossSectionType = type;                            // set of section type
            rebarCover       = Math.Max(coverTop, coverBottom); // set of maximum cover
            rebarCoverTop    = coverTop;                        // set of top cover
            rebarCoverBottom = coverBottom;                     // set of bottom cover
            /// <structural_toolkit_2015>
            edgesForReinforcement = new Dictionary <CrossSectionSide, Tuple <int, int> >();
            geometryMinX          = Double.MaxValue;
            geometryMinY          = Double.MaxValue;
            geometryMaxX          = Double.MinValue;
            geometryMaxY          = Double.MinValue;
            /// </structural_toolkit_2015>
            // Top,bottom, lreft and right edges are searched, based on maximum and minimum values for x and y coordinates
            /// <structural_toolkit_2015>
            solverGeometry = rcGeometry;
            int     count = solverGeometry.Count;
            Point2D p     = new Point2D(0, 0);

            // The orientation is changed if it is necessary.
            if (solverGeometry.isClockwiseOrientation()) // clockwise direction
            {
                Geometry tmpGeometry = new Geometry();
                p = solverGeometry.Point(0);
                tmpGeometry.Add(p.X, p.Y);
                for (int i = count - 1; i > 0; i--)
                {
                    p = solverGeometry.Point(i);
                    tmpGeometry.Add(p.X, p.Y);
                }
                solverGeometry = tmpGeometry;
            }
            foreach (Point2D p2D in solverGeometry)
            {
                geometryMinX = Math.Min(geometryMinX, p2D.X);
                geometryMinY = Math.Min(geometryMinY, p2D.Y);
                geometryMaxX = Math.Max(geometryMaxX, p2D.X);
                geometryMaxY = Math.Max(geometryMaxY, p2D.Y);
            }
            Tuple <int, int> curentTuple = null;

            for (int i = 0; i < count; i++)
            {
                p = solverGeometry.Point(i);
                // Left
                if (CompareGeomety(geometryMinX, p.X) >= 0)
                {
                    if (!edgesForReinforcement.ContainsKey(CrossSectionSide.Left) || CompareGeomety(geometryMinX, p.X) > 0)
                    {
                        curentTuple = new Tuple <int, int>(i, i);
                    }
                    else
                    {
                        if (CompareGeomety(p.Y, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Left].Item2).Y) > 0)
                        {
                            curentTuple = new Tuple <int, int>(edgesForReinforcement[CrossSectionSide.Left].Item1, i);
                        }
                        else if (CompareGeomety(p.Y, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Left].Item1).Y) < 0)
                        {
                            curentTuple = new Tuple <int, int>(i, edgesForReinforcement[CrossSectionSide.Left].Item2);
                        }
                    }
                    edgesForReinforcement.Remove(CrossSectionSide.Left);
                    edgesForReinforcement.Add(CrossSectionSide.Left, curentTuple);
                }
                // Right
                if (CompareGeomety(geometryMaxX, p.X) <= 0)
                {
                    if (!edgesForReinforcement.ContainsKey(CrossSectionSide.Right) || CompareGeomety(geometryMaxX, p.X) < 0)
                    {
                        curentTuple = new Tuple <int, int>(i, i);
                    }
                    else
                    {
                        if (CompareGeomety(p.Y, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Right].Item2).Y) > 0)
                        {
                            curentTuple = new Tuple <int, int>(edgesForReinforcement[CrossSectionSide.Right].Item1, i);
                        }
                        else if (CompareGeomety(p.Y, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Right].Item1).Y) < 0)
                        {
                            curentTuple = new Tuple <int, int>(i, edgesForReinforcement[CrossSectionSide.Right].Item2);
                        }
                    }
                    edgesForReinforcement.Remove(CrossSectionSide.Right);
                    edgesForReinforcement.Add(CrossSectionSide.Right, curentTuple);
                }
                // Top
                if (CompareGeomety(geometryMaxY, p.Y) <= 0)
                {
                    if (!edgesForReinforcement.ContainsKey(CrossSectionSide.Top) || CompareGeomety(geometryMaxY, p.Y) < 0)
                    {
                        curentTuple = new Tuple <int, int>(i, i);
                    }
                    else
                    {
                        if (CompareGeomety(p.X, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Top].Item2).X) > 0)
                        {
                            curentTuple = new Tuple <int, int>(edgesForReinforcement[CrossSectionSide.Top].Item1, i);
                        }
                        else if (CompareGeomety(p.X, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Top].Item1).X) < 0)
                        {
                            curentTuple = new Tuple <int, int>(i, edgesForReinforcement[CrossSectionSide.Top].Item2);
                        }
                    }
                    edgesForReinforcement.Remove(CrossSectionSide.Top);
                    edgesForReinforcement.Add(CrossSectionSide.Top, curentTuple);
                }
                // Bottom
                if (CompareGeomety(geometryMinY, p.Y) >= 0)
                {
                    if (!edgesForReinforcement.ContainsKey(CrossSectionSide.Bottom) || CompareGeomety(geometryMinY, p.Y) > 0)
                    {
                        curentTuple = new Tuple <int, int>(i, i);
                    }
                    else
                    {
                        if (CompareGeomety(p.X, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Bottom].Item2).X) > 0)
                        {
                            curentTuple = new Tuple <int, int>(edgesForReinforcement[CrossSectionSide.Bottom].Item1, i);
                        }
                        else if (CompareGeomety(p.X, solverGeometry.Point(edgesForReinforcement[CrossSectionSide.Bottom].Item1).X) < 0)
                        {
                            curentTuple = new Tuple <int, int>(i, edgesForReinforcement[CrossSectionSide.Bottom].Item2);
                        }
                    }
                    edgesForReinforcement.Remove(CrossSectionSide.Bottom);
                    edgesForReinforcement.Add(CrossSectionSide.Bottom, curentTuple);
                }
            }
            /// </structural_toolkit_2015>

            totalHeight = (geometryMaxY - geometryMinY);
            totalWidth  = (geometryMaxX - geometryMinX);
            solver      = RCSolver.CreateNewSolver(solverGeometry); // solver with geometry redy to use.
        }
        //--------------------------------------------------------------
        #endregion

        #region public methods
        //--------------------------------------------------------------

        public void DataBinding(Autodesk.Revit.DB.Element revitElement)
        {
            UnitsAssignment.RevitUnits = revitElement.Document.GetUnits();

            if (null == revitElementAnalyser)
            {
                revitElementAnalyser = revitUnitsUI ? new ElementAnalyser() : new ElementAnalyser(unitSystem);
                revitElementAnalyser.TSectionAnalysis = true;
            }

            ElementInfo elementInfo = revitElementAnalyser.Analyse(revitElement);

            switch (elementInfo.Type)
            {
            case ElementType.Beam:
            case ElementType.Column:
                elementSizeLabel.Content = "Length:";
                if (revitUnitsUI)
                {
                    elementSizeValue.Content = UnitsAssignment.FormatToRevitUI("GeomLength", elementInfo.GeomLength(), ElementInfoUnits.Assignments, true);
                }
                else
                {
                    elementSizeValue.Content  = elementInfo.GeomLength().ToString();
                    elementSizeValue.Content += "  " + UnitsAssignment.GetUnitSymbol("GeomLength", ElementInfoUnits.Assignments, unitSystem);
                }

                SectionShapeType shapeType = SectionShapeType.Unusual;
                if (elementInfo.SectionsParams != null)
                {
                    shapeType = elementInfo.SectionsParams.ShapeType;
                }

                bool tSectionCollapsedWhenSelected = false;
                tabSlab.Visibility = System.Windows.Visibility.Collapsed;
                tabWall.Visibility = System.Windows.Visibility.Collapsed;
                if (elementInfo.Slabs != null && elementInfo.Slabs.TSection != null)
                {
                    tabTSection.Visibility = System.Windows.Visibility.Visible;
                    tSectionDescription.DoBinding(elementInfo.Slabs, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem, elementInfo.GeomLength());
                }
                else
                {
                    if (tabTSection.IsSelected)
                    {
                        tSectionCollapsedWhenSelected = true;
                    }

                    tabTSection.Visibility = System.Windows.Visibility.Collapsed;
                }
                tabProfile.Visibility = System.Windows.Visibility.Visible;

                if (tabSlab.IsSelected || true == tSectionCollapsedWhenSelected || tabWall.IsSelected)
                {
                    IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
                    tabProfile.Focus();
                    if (previousFocusedElement != null)
                    {
                        previousFocusedElement.Focus();
                    }
                }

                sectionDescription.DoBinding(shapeType,
                                             elementInfo.Sections,
                                             elementInfo.Material != null ? elementInfo.Material.Category == MaterialCategory.Metal : false);
                sectionParameters.DoBinding(revitElement.Name, elementInfo.SectionsParams, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
                break;

            case ElementType.Slab:
                elementSizeLabel.Content = "Thickness:";
                if (revitUnitsUI)
                {
                    if (elementInfo.Slabs.AsElement != null)
                    {
                        elementSizeValue.Content = UnitsAssignment.FormatToRevitUI("SlabThickness", elementInfo.Slabs.AsElement.Thickness(), ElementInfoUnits.Assignments, true);
                    }
                }
                else
                {
                    if (elementInfo.Slabs.AsElement != null)
                    {
                        elementSizeValue.Content  = elementInfo.Slabs.AsElement.Thickness().ToString();
                        elementSizeValue.Content += "  " + UnitsAssignment.GetUnitSymbol("SlabThickness", ElementInfoUnits.Assignments, unitSystem);
                    }
                }

                tabProfile.Visibility  = System.Windows.Visibility.Collapsed;
                tabTSection.Visibility = System.Windows.Visibility.Collapsed;
                tabWall.Visibility     = System.Windows.Visibility.Collapsed;
                tabSlab.Visibility     = System.Windows.Visibility.Visible;

                if (tabProfile.IsSelected || tabTSection.IsSelected || tabWall.IsSelected)
                {
                    IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
                    tabSlab.Focus();
                    if (previousFocusedElement != null)
                    {
                        previousFocusedElement.Focus();
                    }
                }

                slabDescription.DoBinding(elementInfo.Slabs, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
                break;

            case ElementType.Wall:
                elementSizeLabel.Content = "Thickness:";
                if (revitUnitsUI)
                {
                    elementSizeValue.Content = UnitsAssignment.FormatToRevitUI("WallThickness", elementInfo.Walls.AsElement.Thickness(), ElementInfoUnits.Assignments, true);
                }
                else
                {
                    elementSizeValue.Content  = elementInfo.Walls.AsElement.Thickness().ToString();
                    elementSizeValue.Content += "  " + UnitsAssignment.GetUnitSymbol("SlabThickness", ElementInfoUnits.Assignments, unitSystem);
                }

                tabProfile.Visibility  = System.Windows.Visibility.Collapsed;
                tabTSection.Visibility = System.Windows.Visibility.Collapsed;
                tabSlab.Visibility     = System.Windows.Visibility.Collapsed;
                tabWall.Visibility     = System.Windows.Visibility.Visible;

                if (tabProfile.IsSelected || tabSlab.IsSelected || tabTSection.IsSelected)
                {
                    IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
                    tabWall.Focus();
                    if (previousFocusedElement != null)
                    {
                        previousFocusedElement.Focus();
                    }
                }

                wallDescription.DoBinding(elementInfo.Walls.AsElement, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
                break;

            case ElementType.Unknown:
            default:
                elementSizeLabel.Content = "";
                elementSizeValue.Content = "";

                tabProfile.Visibility  = System.Windows.Visibility.Collapsed;
                tabSlab.Visibility     = System.Windows.Visibility.Collapsed;
                tabTSection.Visibility = System.Windows.Visibility.Collapsed;
                tabWall.Visibility     = System.Windows.Visibility.Collapsed;

                if (tabProfile.IsSelected || tabSlab.IsSelected || tabTSection.IsSelected || tabWall.IsSelected)
                {
                    IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
                    tabMaterial.Focus();
                    if (previousFocusedElement != null)
                    {
                        previousFocusedElement.Focus();
                    }
                }

                break;
            }

            MaterialLayerDescription layerDescription = null;
            Layer structuralLayer = null;

            if (elementInfo.Type == ElementType.Slab)
            {
                if (elementInfo.Slabs.AsElement != null)
                {
                    structuralLayer = elementInfo.Slabs.AsElement.StructuralLayer();
                }
            }
            if (elementInfo.Type == ElementType.Wall)
            {
                structuralLayer = elementInfo.Walls.AsElement.StructuralLayer();
            }

            if (structuralLayer != null)
            {
                layerDescription = new MaterialLayerDescription(structuralLayer.Thickness, structuralLayer.Offset);
            }

            materialParameters.DoBinding(elementInfo.Material, layerDescription, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
        }