/// <summary>The split rebar.</summary> /// <param name="originalRebar">The original rebar.</param> /// <param name="section">The section.</param> /// <param name="barPosition">The bar position.</param> /// <param name="remainingOffset">The remaining offset.</param> /// <param name="splitRebarSet">The split reinforcement bar set.</param> /// <returns>The System.Boolean.</returns> private bool SplitRebar( SingleRebar originalRebar, SpliceSection section, BarPositions barPosition, ref double remainingOffset, out ArrayList splitRebarSet) { var result = true; double maxLength, totalOffset, remainingLength, hookLength, incrementalLength = 0.0; splitRebarSet = new ArrayList(); var totalRebarLength = Distance.PointToPoint((Point)originalRebar.Polygon.Points[1], (Point)originalRebar.Polygon.Points[0]); var splitPattern = new Vector((Point)originalRebar.Polygon.Points[1] - (Point)originalRebar.Polygon.Points[0]); this.GetRebarMaximumLength(FirstOrLastEnum.MiddleRebar, out maxLength); this.CalculateTotalOffset( totalRebarLength, section, barPosition, remainingOffset, out totalOffset, out remainingLength, out hookLength); for (var ii = 0; incrementalLength + this.GetRebarLengthEpsilon() < totalRebarLength; ii++) { if (ii == 0) { result &= this.CreateStartRebar(originalRebar, splitPattern, splitRebarSet, totalOffset, hookLength, ref incrementalLength); } else if (incrementalLength + maxLength + this.GetRebarLengthEpsilon() < totalRebarLength) { var centralBarsCount = (int)Math.Floor(totalRebarLength / maxLength); if (this.splitData.SpliceSymmetry == 2 && barPosition == BarPositions.First && centralBarsCount > 1 && incrementalLength < totalRebarLength / 2.0 && incrementalLength + maxLength > totalRebarLength / 2.0) { result &= this.CreateDifferentMiddleRebarInCenterSymmetry(remainingLength, originalRebar, ref splitPattern, ref incrementalLength, ref splitRebarSet); } else { result &= this.CreateMiddleRebar(originalRebar, splitPattern, splitRebarSet, ref incrementalLength); } } else { double lastSegment; result &= this.CreateEndRebar(originalRebar, maxLength, splitPattern, splitRebarSet, ref incrementalLength, out lastSegment); if (barPosition == BarPositions.First) { remainingOffset = lastSegment; } } } return(result); }
/// <summary>The calculate total offset.</summary> /// <param name="totalRebarLength">The total reinforcement bar length.</param> /// <param name="section">The section.</param> /// <param name="barPosition">The bar position.</param> /// <param name="remainingOffset">The remaining offset.</param> /// <param name="totalOffset">The total offset.</param> /// <param name="remainingLength">The remaining length.</param> /// <param name="hookLength">The hook length.</param> private void CalculateTotalOffset( double totalRebarLength, SpliceSection section, BarPositions barPosition, double remainingOffset, out double totalOffset, out double remainingLength, out double hookLength) { double maxLength; hookLength = 0.0; this.GetRebarMaximumLength(FirstOrLastEnum.MiddleRebar, out maxLength); remainingLength = totalRebarLength - (Math.Floor(totalRebarLength / maxLength) * maxLength); totalOffset = barPosition == BarPositions.First ? this.CalculateTotalOffsetForFirstRebar(totalRebarLength, maxLength, ref remainingLength, out hookLength) : this.CalculateTotalOffsetForFollowingRebar(totalRebarLength, maxLength, remainingOffset, section, barPosition, ref remainingLength); }
/// <summary>The calculate total offset for following rebar.</summary> /// <param name="totalRebarLength">The total reinforcement bar length.</param> /// <param name="maxLength">The max length.</param> /// <param name="remainingOffset">The remaining offset.</param> /// <param name="section">The section.</param> /// <param name="barPosition">The bar position.</param> /// <param name="remainingLength">The remaining length.</param> /// <returns>The System.Double.</returns> private double CalculateTotalOffsetForFollowingRebar( double totalRebarLength, double maxLength, double remainingOffset, SpliceSection section, BarPositions barPosition, ref double remainingLength) { var totalOffset = 0.0; double shortRebarOffset; switch (section) { case SpliceSection.EverySingle: Console.WriteLine("Error"); break; case SpliceSection.EverySecond: shortRebarOffset = this.GetShortRebarLength(maxLength, remainingOffset, 2.0); switch (barPosition) { case BarPositions.Second: var centralBarsCount = (int)Math.Floor(totalRebarLength / maxLength); switch (this.splitData.SpliceSymmetry) { case 0: totalOffset = shortRebarOffset; break; case 1: if (centralBarsCount % 2 == 1) { totalOffset = remainingLength / 2.0; } else { totalOffset = (maxLength / 2.0) + (remainingLength / 2.0); } break; case 2: if (centralBarsCount % 2 == 0) { totalOffset = remainingLength / 2.0; } else { totalOffset = (maxLength / 2.0) + (remainingLength / 2.0); } break; default: break; } break; default: Console.WriteLine("Error"); break; } break; case SpliceSection.EveryThird: shortRebarOffset = this.GetShortRebarLength(maxLength, remainingOffset, 3.0); switch (barPosition) { case BarPositions.Second: totalOffset = (shortRebarOffset + maxLength) / 2.0; break; case BarPositions.Third: totalOffset = shortRebarOffset; break; default: Console.WriteLine("Error"); break; } break; case SpliceSection.EveryForth: shortRebarOffset = this.GetShortRebarLength(maxLength, remainingOffset, 4.0); switch (barPosition) { case BarPositions.Second: totalOffset = (2 * (maxLength - shortRebarOffset) / 3.0) + shortRebarOffset; break; case BarPositions.Third: totalOffset = ((maxLength - shortRebarOffset) / 3.0) + shortRebarOffset; break; case BarPositions.Forth: totalOffset = shortRebarOffset; break; default: Console.WriteLine("Error"); break; } break; default: break; } return(totalOffset); }
/// <summary>The split rebar.</summary> /// <param name="originalRebar">The original rebar.</param> /// <param name="section">The section.</param> /// <param name="barPosition">The bar position.</param> /// <param name="rebarSegmentLengths">Lengths of all rebars segments.</param> /// <param name="remainingOffset">The remaining offset.</param> /// <param name="splitRebarSet">The split reinforcement bar set.</param> /// <returns>The System.Boolean.</returns> private bool SplitRebar( SingleRebar originalRebar, SpliceSection section, BarPositions barPosition, List <double> rebarSegmentLengths, ref double remainingOffset, out ArrayList splitRebarSet) { bool result = true; double maxLength; double totalOffset; double remainingLength; double hookLength; double incrementalLength = 0.0; double totalRebarLength = 0.0; double previousLength = 0.0; splitRebarSet = new ArrayList(); ArrayList previousPoints = new ArrayList(); foreach (double length in rebarSegmentLengths) { totalRebarLength += length; } CreateSingleRebar createSingleRebar = new CreateSingleRebar(originalRebar); for (int jj = 0; jj < originalRebar.Polygon.Points.Count - 1; jj++) { Vector splitPattern = new Vector((Point)originalRebar.Polygon.Points[jj + 1] - (Point)originalRebar.Polygon.Points[jj]); this.GetRebarMaximumLength(FirstOrLastEnum.MiddleRebar, out maxLength); this.CalculateTotalOffset( totalRebarLength, section, barPosition, remainingOffset, out totalOffset, out remainingLength, out hookLength); ArrayList splitRebarSegment = new ArrayList(); ArrayList rebarPoints = new ArrayList(); rebarPoints.Add(originalRebar.Polygon.Points[jj]); rebarPoints.Add(originalRebar.Polygon.Points[jj + 1]); SingleRebar segmentToSplit = createSingleRebar.GetSingleRebar(rebarPoints); if ((previousLength + rebarSegmentLengths[jj]) > maxLength) { for (int ii = 0; incrementalLength + this.GetRebarLengthEpsilon() < totalRebarLength; ii++) { if (ii == 0 && jj == 0) { result &= this.CreateStartRebar(segmentToSplit, splitPattern, splitRebarSegment, totalOffset, hookLength, ref incrementalLength); } else if (incrementalLength + maxLength + this.GetRebarLengthEpsilon() < totalRebarLength) { int centralBarsCount = (int)Math.Floor(totalRebarLength / maxLength); if (this.splitData.SpliceSymmetry == 2 && barPosition == BarPositions.First && centralBarsCount > 1 && incrementalLength < totalRebarLength / 2.0 && incrementalLength + maxLength > totalRebarLength / 2.0) { result &= this.CreateDifferentMiddleRebarInCenterSymmetry(remainingLength, segmentToSplit, ref splitPattern, ref incrementalLength, ref splitRebarSegment); } else { result &= this.CreateMiddleRebar(segmentToSplit, splitPattern, splitRebarSegment, ref incrementalLength); } } else { double lastSegment; double segmentLength; if (incrementalLength < maxLength + DistanceEpsilon) { segmentLength = rebarSegmentLengths[jj] - (maxLength - incrementalLength); } else { int multiplayer = (int)(incrementalLength / maxLength); segmentLength = rebarSegmentLengths[jj] - ((multiplayer + 1) * maxLength - incrementalLength); } result &= this.CreateEndRebar(segmentToSplit, maxLength, splitPattern, splitRebarSegment, ref segmentLength, out lastSegment); incrementalLength = segmentLength; if (barPosition == BarPositions.First) { remainingOffset = lastSegment; } } } } else { incrementalLength += rebarSegmentLengths[jj]; previousLength += rebarSegmentLengths[jj]; this.AddRebarPoint(originalRebar.Polygon.Points[jj] as Point, previousPoints); this.AddRebarPoint(originalRebar.Polygon.Points[jj + 1] as Point, previousPoints); DrawPoint(originalRebar.Polygon.Points[jj] as Point, jj.ToString()); DrawPoint(originalRebar.Polygon.Points[jj + 1] as Point, (jj + 1).ToString()); } if (splitRebarSegment.Count != 0 && previousPoints.Count > 0) { DrawPoint(((SingleRebar)splitRebarSegment[0]).Polygon.Points[0] as Point, "SP" + jj.ToString()); DrawPoint(((SingleRebar)splitRebarSegment[0]).Polygon.Points[1] as Point, "SP" + (jj + 1).ToString()); previousPoints.Add(((SingleRebar)splitRebarSegment[0]).Polygon.Points[0]); SingleRebar previousBar = createSingleRebar.GetSingleRebar(previousPoints); splitRebarSegment.Insert(0, previousBar); previousPoints.Clear(); previousLength = 0.0; } splitRebarSet.AddRange(splitRebarSegment); } return(result); }