BesAsm.Swsp.PacSizingTool.Facility.CalculateVolume C# (CSharp) Method

CalculateVolume() private method

Utility method to calculate the volume of basins and flat planters
private CalculateVolume ( double depthIn ) : double
depthIn double
return double
        private double CalculateVolume(double depthIn)
        {
            double volume = 0;
              switch (_type)
              {
            case FacilityType.Basin:
              if (_facilityShape == FacilityShape.Rectangle)
              {
            volume = //L*W*D + (L+W)*X*D^2 + (1/3)*pi*D^3*X^2
                (_bottomAreaSqFt * depthIn / 12) //L*W*D
              +
                (_bottomWidthFt + _bottomAreaSqFt / _bottomWidthFt)
                * _sideSlopeRatio
                * Math.Pow(depthIn / 12, 2) //(L+W)*X*D^2
              +
                (1.0 / 3) * Math.PI * Math.Pow(depthIn / 12, 3) * Math.Pow(_sideSlopeRatio, 2) //(1/3) * pi * D^3 * X^2
            ;
            break;
              }
              else if (_facilityShape == FacilityShape.Amoeba)
              {
              volume = ((depthIn / 12) * _sideSlopeRatio * _bottomPerimeterLengthFt) / 2 + (_bottomAreaSqFt * (depthIn / 12));
              }
              else if (_facilityShape == FacilityShape.UserDefined)
              {
              if (depthIn <= _storageDepth1In)
              {
                  // Area at depth, linear interpolation
                  double areaAtDepth = SurfaceAreaAtDepth(depthIn);
                  volume = (depthIn / 12) * (_bottomAreaSqFt + areaAtDepth) / 2;
              }
              else if (_hasSecondaryOverflow)
              {
                  // Area at depth, linear interpolation
                  double areaAtDepth1 = SurfaceAreaAtDepth(_storageDepth1In);
                  volume = (_storageDepth1In / 12) * (_bottomAreaSqFt + areaAtDepth1) / 2; // volume up to depth 1.
                  double areaAtDepth2 = SurfaceAreaAtDepth(depthIn);
                  volume += ((depthIn - _storageDepth1In) / 12) * (areaAtDepth1 + areaAtDepth2) / 2;
              }
              else
              {
                  throw new ArgumentException("Volume calculation at depth '" + depthIn + "' not defined");
              }
              }
              break;
            case FacilityType.PlanterFlat:
              volume = depthIn / 12 * _bottomAreaSqFt;
              break;
            case FacilityType.PlanterSloped: // overridden in SlopedFacility class
              if (SANITIZEINPUT)
            throw new NotImplementedException();
              else
            return 0;
            case FacilityType.Swale: // overridden in SlopedFacility class
              if (SANITIZEINPUT)
            throw new NotImplementedException();
              else
            return 0;
            default:
              if (SANITIZEINPUT)
            throw new ArgumentException("Volume calculation not defined");
              else
            return 0;
              }
              return volume;
        }