//
// (C) Copyright 2003-2013 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
namespace CodeCheckingConcreteExample.Utility
{
///
/// Type of results for rc section
///
public enum ResultTypeLinear
{
///
/// linear position(absolute)
///
X,
///
/// linear position(relative)
///
X_Rel,
///
/// Bending moment , x-axis, min value
///
MxMin,
///
/// Bending moment , x-axis, max value
///
MxMax,
///
/// Bending moment , y-axis, min value
///
MyMin,
///
/// Bending moment , y-axis, max value
///
MyMax,
///
/// Bending moment , z-axis, min value
///
MzMin,
///
/// Bending moment , z-axis, max value
///
MzMax,
///
/// Transversal force , x-direction, min value
///
FxMin,
///
/// Transversal force , x-direction, max value
///
FxMax,
///
/// Transversal force , y-direction, min value
///
FyMin,
///
/// Transversal force , y-direction, max value
///
FyMax,
///
/// Transversal force , z-direction, min value
///
FzMin,
///
/// Transversal force , z-direction, max value
///
FzMax,
///
/// Longitudinal reinforcement, bottom
///
Abottom,
///
/// Longitudinal reinforcement, top
///
Atop,
///
/// Longitudinal reinforcement, left
///
Aleft,
///
/// Longitudinal reinforcement, right
///
Aright,
///
/// Stirrups spacing
///
StirrupsSpacing,
///
/// Transversal reinforcement density
///
TransversalReinforcemenDensity,
///
/// Deflection, x-direction, min value
///
UxMin,
///
/// Deflection, x-direction, max value
///
UxMax,
///
/// Deflection, y-direction, min value
///
UyMin,
///
/// Deflection, y-direction, max value
///
UyMax,
///
/// Deflection, z-direction, min value
///
UzMin,
///
/// Deflection, z-direction, max value
///
UzMax,
///
/// Calculated deflection, x-direction, max value
///
UxRealMin,
///
/// Calculated deflection, x-direction, min value
///
UxRealMax,
///
/// Calculated deflection, y-direction, max value
///
UyRealMin,
///
/// Calculated deflection, y-direction, min value
///
UyRealMax,
///
/// Calculated deflection, z-direction, max value
///
UzRealMin,
///
/// Calculated deflection, z-direction, min value
///
UzRealMax,
}
static class ResultTypeLinearHelper
{
///
/// Converts value from cref="ResultTypeLinear" into value from cref="ResultType".
///
/// Type of force.
/// Type of result.
static public Autodesk.Revit.DB.CodeChecking.Engineering.ResultType GetResultType(this ResultTypeLinear forceType)
{
Autodesk.Revit.DB.CodeChecking.Engineering.ResultType resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.Unknown;
switch (forceType)
{
// reinforcement
case ResultTypeLinear.Abottom: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.Abottom; break;
case ResultTypeLinear.Atop: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.Atop; break;
case ResultTypeLinear.Aleft: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.Aleft; break;
case ResultTypeLinear.Aright: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.Aright; break;
// deflection
case ResultTypeLinear.UxRealMax: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UxMax; break;
case ResultTypeLinear.UxRealMin: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UxMin; break;
case ResultTypeLinear.UyRealMax: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UyMax; break;
case ResultTypeLinear.UyRealMin: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UyMin; break;
case ResultTypeLinear.UzRealMax: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UzMax; break;
case ResultTypeLinear.UzRealMin: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UzMin; break;
}
return resultType;
}
///
/// Gets unit for a specific Result type
///
///
///
static public UnitType GetUnitType(this ResultTypeLinear forceType)
{
return ResultInPointLinear.ValueType[(int)forceType];
}
///
/// Gets reinforcement result types
///
static public List ReinforcementResults
{
get { return new List { ResultTypeLinear.Abottom, ResultTypeLinear.Aleft, ResultTypeLinear.Aright, ResultTypeLinear.Atop, ResultTypeLinear.StirrupsSpacing, ResultTypeLinear.TransversalReinforcemenDensity }; }
}
///
/// Gets displacement result types
///
static public List DisplacementResults
{
get
{
return new List
{
ResultTypeLinear.UxMax, ResultTypeLinear.UxMin,
ResultTypeLinear.UyMax, ResultTypeLinear.UyMin,
ResultTypeLinear.UzMax, ResultTypeLinear.UzMin,
};
}
}
///
/// Gets real deflection result types
///
static public List RealDeflectionResults
{
get
{
return new List
{
ResultTypeLinear.UxRealMax, ResultTypeLinear.UxRealMin,
ResultTypeLinear.UyRealMax, ResultTypeLinear.UyRealMin,
ResultTypeLinear.UzRealMax, ResultTypeLinear.UzRealMin
};
}
}
///
/// Gets internal forces result types
///
static public List InternalForcesResults
{
get
{
return new List
{
ResultTypeLinear.FxMin, ResultTypeLinear.FxMax, ResultTypeLinear.FyMin, ResultTypeLinear.FyMax, ResultTypeLinear.FzMin, ResultTypeLinear.FzMax,
};
}
}
///
/// Gets internal moments result types
///
static public List InternalMomentsResults
{
get
{
return new List
{
ResultTypeLinear.MxMin, ResultTypeLinear.MxMax, ResultTypeLinear.MyMin, ResultTypeLinear.MyMax, ResultTypeLinear.MzMin, ResultTypeLinear.MzMax,
};
}
}
}
///
/// Result Format
///
public enum ResultFormat
{
///
/// Internal format in which data is stored internally
///
Internal,
///
/// External format in which data is presented on UI
///
External
};
///
/// Container representing analitical results in RC bar section
/// Results are represented as numbers along with their respective units
///
public class ResultInPointLinear
{
private double[] data = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
static internal UnitType[] ValueType = new UnitType[] { UnitType.UT_Length,
UnitType.UT_Number,
UnitType.UT_Moment,
UnitType.UT_Moment,
UnitType.UT_Moment,
UnitType.UT_Moment,
UnitType.UT_Moment,
UnitType.UT_Moment,
UnitType.UT_Force,
UnitType.UT_Force,
UnitType.UT_Force,
UnitType.UT_Force,
UnitType.UT_Force,
UnitType.UT_Force,
UnitType.UT_Reinforcement_Area,
UnitType.UT_Reinforcement_Area,
UnitType.UT_Reinforcement_Area,
UnitType.UT_Reinforcement_Area,
UnitType.UT_Section_Dimension,
UnitType.UT_Reinforcement_Area_per_Unit_Length,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
};
///
/// Creates default ResultInPointLinear
///
public ResultInPointLinear() { }
///
/// Creates default ResultInPointLinear
///
/// List of result according to ResultTypeLinear order
public ResultInPointLinear(IEnumerable data) { DataRaw = data.ToArray(); }
///
/// Access to the raw format of section results
///
public double[] DataRaw
{
get { return data; }
set
{
int reqSize = Enum.GetValues(typeof(ResultTypeLinear)).Length;
if (value.Count() != reqSize)
{
throw new ArgumentException("Value list lenght should be equal to " + reqSize);
}
else
{
data = value;
}
}
}
///
/// Access to a specific result
///
/// Result type
/// Formatted result value
public double this[ResultTypeLinear type]
{
get { return data[(int)type]; }
set
{
if (Double.IsNaN(value))
{
throw new ArgumentOutOfRangeException(type.ToString() + "Cannot be NAN");
}
data[(int)type] = value;
}
}
}
}