示例#1
0
        public static Dictionary<string, object> ToSAP(StructuralModel StructuralModel, bool Bake, string Units = "kip_ft_F", bool Delete = true)
        {
            if (Bake)
            {
                // 1. Calculate Lenght Conversion Factor
                string fromUnit = "m"; // Dynamo API Units
                LengthUnit LU = new LengthUnit();
                   //LengthUnit LU= DynamoUnits.Length.LengthUnit; // Display Units

                //double LengthSF = SAPConnection.Utilities.UnitConversion(Units, fromUnit); // Lenght Conversion Factor
                double LengthSF = 1;
                // Clear Frame & Area Dictionaries to hold
                SAPFrmList.Clear();
                SAPAreaList.Clear();
                SAPJointList.Clear();
                report.Clear();

                // 2. Create new SAP Model and bake Stuctural Model
                if (StructuralModel != null)
                {
                    CreateorUpdateSAPModel(ref StructuralModel, Units, LengthSF, Delete);
                }
            }
            else
            {
                throw new Exception("Node not run. Please, set boolean to true");
            }
            //return StructuralModel;

            return new Dictionary<string, object>
            {
                {"Structural Model", StructuralModel},
                {"Report", report}
            };
        }
示例#2
0
 public Double GetAs(LengthUnit targetUnit)
 {
     if (this.Unit == targetUnit) return this.Value;
      // else
      var v = ConversionFactorTo(targetUnit);
      return this.Value * v;
 }
 public void LengthConversions(double value1, LengthUnit units1, double value2, LengthUnit units2)
 {
     new Length(value1, units1) {
         Units = units2
     }.Value.ShouldBeWithinEpsilonOf(value2);
     new Length(value2, units2) {
         Units = units1
     }.Value.ShouldBeWithinEpsilonOf(value1);
 }
示例#4
0
 /// <summary>
 /// Converts the specified from unit to the specified unit.
 /// </summary>
 /// <param name="fromUnit">Covert from unit.</param>
 /// <param name="toUnit">Covert to unit.</param>
 /// <param name="fromValue">Covert from value.</param>
 /// <returns>The converted value.</returns>
 public static double Convert(
     LengthUnit fromUnit,
     LengthUnit toUnit,
     double fromValue)
 {
     if (fromUnit == toUnit)
         return fromValue; 
     
     double fromFactor = factors[(int)fromUnit];
     double toFactor = factors[(int) toUnit];
     double result = fromFactor * fromValue / toFactor;
     return result;
 }
示例#5
0
 public double this[LengthUnit targetUnits]
 {
     get
     {
         return Convert(lengthValue, lengthUnit, targetUnits);
     }
     set
     {
         var newValue = Convert(value, targetUnits, lengthUnit);
         if (lengthValue != newValue)
         {
             lengthValue = newValue;
             NotifyPropertyChanged("Value");
         }
     }
 }
示例#6
0
 public static double ReturnMeters(LengthUnit unit, double number)
 {
     switch (unit)
     {
         case LengthUnit.Mile:
             return number * MeterPerMile;
         case LengthUnit.Kilometer:
             return number * MeterPerKilometer;
         case LengthUnit.Meter:
             return number ;
         case LengthUnit.Centimeter:
             return number*MeterPerCentimeter;
         default:
             throw new ArgumentOutOfRangeException(nameof(unit), unit, null);
     }
 }
 public Length ConvertTo(LengthUnit units)
 {
     return(new Length {
         Value = _convertValueTo(units), Units = units
     });
 }
 public bool IsMetric(LengthUnit units)
 {
     return(units < LengthUnit.METRIC_END);
 }
 /// <summary>
 ///     Dynamically convert from value and unit enum <see cref="LengthUnit" /> to <see cref="Length" />.
 /// </summary>
 /// <param name="value">Value to convert from.</param>
 /// <param name="fromUnit">Unit to convert from.</param>
 /// <returns>Length unit value.</returns>
 public static Length?From(QuantityValue?value, LengthUnit fromUnit)
 {
     return(value.HasValue ? new Length((double)value.Value, fromUnit) : default(Length?));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FormPage"/> class.
 /// </summary>
 /// <param name="pageNumber">The 1-based page number in the input document.</param>
 /// <param name="width">The width of the image/PDF in pixels/inches, respectively.</param>
 /// <param name="height">The height of the image/PDF in pixels/inches, respectively.</param>
 /// <param name="textAngle">The general orientation of the text in clockwise direction, measured in degrees between (-180, 180].</param>
 /// <param name="unit">The unit used by the width, height and <see cref="FieldBoundingBox"/> properties. For images, the unit is pixel. For PDF, the unit is inch.</param>
 /// <param name="lines">A list of recognized lines of text.</param>
 /// <param name="tables">A list of recognized tables contained in this page.</param>
 /// <param name="selectionMarks">A list of recognized selection marks contained in this page.</param>
 internal FormPage(int pageNumber, float width, float height, float textAngle, LengthUnit unit, IReadOnlyList <FormLine> lines, IReadOnlyList <FormTable> tables, IReadOnlyList <FormSelectionMark> selectionMarks)
 {
     PageNumber     = pageNumber;
     Width          = width;
     Height         = height;
     TextAngle      = textAngle;
     Unit           = unit;
     Lines          = lines;
     Tables         = tables;
     SelectionMarks = selectionMarks;
 }
示例#11
0
 public QuantityRangeAttribute(double minimum, double maximum, LengthUnit unit) : this(minimum, maximum, (int)unit, o => ((Length)o).As(unit))
 {
 }
示例#12
0
        public void UpdateUnitSystem(UnitSystem unitSystem)
        {
            this.unitSystem = unitSystem;
            this.TextBox.Clear();
            if (unitSystem != null)
            {
                this.textBoxUnitSystem.ScrollBars = System.Windows.Forms.ScrollBars.None;

                string temperature        = "Temperature: \t\t" + TemperatureUnit.GetUnitAsString(unitSystem.TemperatureUnitType);
                string pressure           = "Pressure: \t\t\t" + PressureUnit.GetUnitAsString(unitSystem.PressureUnitType);
                string massFlowRate       = "Mass Flow Rate: \t\t" + MassFlowRateUnit.GetUnitAsString(unitSystem.MassFlowRateUnitType);
                string volumeFlowRate     = "Volume Flow Rate: \t\t" + VolumeFlowRateUnit.GetUnitAsString(unitSystem.VolumeFlowRateUnitType);
                string moistureContent    = "Moisture Content: \t\t" + MoistureContentUnit.GetUnitAsString(unitSystem.MoistureContentUnitType);
                string relativeHumidity   = "Fraction: \t\t\t" + FractionUnit.GetUnitAsString(unitSystem.FractionUnitType);
                string enthalpy           = "Specific Energy: \t\t" + SpecificEnergyUnit.GetUnitAsString(unitSystem.SpecificEnergyUnitType);
                string specificHeat       = "Specific Heat: \t\t" + SpecificHeatUnit.GetUnitAsString(unitSystem.SpecificHeatUnitType);
                string energy             = "Energy: \t\t\t" + EnergyUnit.GetUnitAsString(unitSystem.EnergyUnitType);
                string power              = "Power: \t\t\t" + PowerUnit.GetUnitAsString(unitSystem.PowerUnitType);
                string density            = "Density: \t\t\t" + DensityUnit.GetUnitAsString(unitSystem.DensityUnitType);
                string dynamicViscosity   = "Dynamic Viscosity: \t\t" + DynamicViscosityUnit.GetUnitAsString(unitSystem.DynamicViscosityUnitType);
                string kinematicViscosity = "Kinematic Viscosity: \t" + KinematicViscosityUnit.GetUnitAsString(unitSystem.KinematicViscosityUnitType);
                string conductivity       = "Thermal Conductivity: \t" + ThermalConductivityUnit.GetUnitAsString(unitSystem.ThermalConductivityUnitType);
                string diffusivity        = "Diffusivity: \t\t" + DiffusivityUnit.GetUnitAsString(unitSystem.DiffusivityUnitType);
                string mass                          = "Mass: \t\t\t" + MassUnit.GetUnitAsString(unitSystem.MassUnitType);
                string length                        = "Length: \t\t\t" + LengthUnit.GetUnitAsString(unitSystem.LengthUnitType);
                string area                          = "Area: \t\t\t" + AreaUnit.GetUnitAsString(unitSystem.AreaUnitType);
                string volume                        = "Volume: \t\t\t" + VolumeUnit.GetUnitAsString(unitSystem.VolumeUnitType);
                string time                          = "Time: \t\t\t" + TimeUnit.GetUnitAsString(unitSystem.TimeUnitType);
                string smallLength                   = "Small Length: \t\t" + SmallLengthUnit.GetUnitAsString(unitSystem.SmallLengthUnitType);
                string microLength                   = "Micro Length: \t\t" + MicroLengthUnit.GetUnitAsString(unitSystem.MicroLengthUnitType);
                string liquidHead                    = "Liquid Head: \t\t" + LiquidHeadUnit.GetUnitAsString(unitSystem.LiquidHeadUnitType);
                string volumeRateFlowLiquids         = "Volume Rate Flow Liquids: \t" + VolumeRateFlowLiquidsUnit.GetUnitAsString(unitSystem.VolumeRateFlowLiquidsUnitType);
                string volumeRateFlowGases           = "Volume Rate Flow Gases: \t" + VolumeRateFlowGasesUnit.GetUnitAsString(unitSystem.VolumeRateFlowGasesUnitType);
                string heatTransferCoeff             = "Heat Transfer Coeff.: \t" + HeatTransferCoefficientUnit.GetUnitAsString(unitSystem.HeatTransferCoefficientUnitType);
                string surfaceTension                = "Surface Tension: \t\t" + SurfaceTensionUnit.GetUnitAsString(unitSystem.SurfaceTensionUnitType);
                string velocity                      = "Velocity: \t\t\t" + VelocityUnit.GetUnitAsString(unitSystem.VelocityUnitType);
                string foulingFactor                 = "Fouling Factor: \t\t" + FoulingFactorUnit.GetUnitAsString(unitSystem.FoulingFactorUnitType);
                string specificVolume                = "Specific Volume: \t\t" + SpecificVolumeUnit.GetUnitAsString(unitSystem.SpecificVolumeUnitType);
                string massVolumeConcentration       = "Mass Volume Concentration: \t" + MassVolumeConcentrationUnit.GetUnitAsString(unitSystem.MassVolumeConcentrationUnitType);
                string planeAngle                    = "Plane Angle: \t\t" + PlaneAngleUnit.GetUnitAsString(unitSystem.PlaneAngleUnitType);
                string volumeHeatTransferCoefficient = "Volume Heat Transfer Coeff.: \t" + VolumeHeatTransferCoefficientUnit.GetUnitAsString(unitSystem.VolumeHeatTransferCoefficientUnitType);

                this.TextBox.AppendText(temperature + "\r\n");
                this.TextBox.AppendText(pressure + "\r\n");
                this.TextBox.AppendText(massFlowRate + "\r\n");
                this.TextBox.AppendText(volumeFlowRate + "\r\n");
                this.TextBox.AppendText(moistureContent + "\r\n");
                this.TextBox.AppendText(relativeHumidity + "\r\n");
                this.TextBox.AppendText(enthalpy + "\r\n");
                this.TextBox.AppendText(specificHeat + "\r\n");
                this.TextBox.AppendText(energy + "\r\n");
                this.TextBox.AppendText(power + "\r\n");
                this.TextBox.AppendText(density + "\r\n");
                this.TextBox.AppendText(dynamicViscosity + "\r\n");
                this.TextBox.AppendText(kinematicViscosity + "\r\n");
                this.TextBox.AppendText(conductivity + "\r\n");
                this.TextBox.AppendText(diffusivity + "\r\n");
                this.TextBox.AppendText(mass + "\r\n");
                this.TextBox.AppendText(length + "\r\n");
                this.TextBox.AppendText(area + "\r\n");
                this.TextBox.AppendText(volume + "\r\n");
                this.TextBox.AppendText(time + "\r\n");
                this.TextBox.AppendText(smallLength + "\r\n");
                this.TextBox.AppendText(microLength + "\r\n");
                this.TextBox.AppendText(liquidHead + "\r\n");
                this.TextBox.AppendText(volumeRateFlowLiquids + "\r\n");
                this.TextBox.AppendText(volumeRateFlowGases + "\r\n");
                this.TextBox.AppendText(heatTransferCoeff + "\r\n");
                this.TextBox.AppendText(surfaceTension + "\r\n");
                this.TextBox.AppendText(velocity + "\r\n");
                this.TextBox.AppendText(foulingFactor + "\r\n");
                this.TextBox.AppendText(specificVolume + "\r\n");
                this.TextBox.AppendText(massVolumeConcentration + "\r\n");
                this.TextBox.AppendText(planeAngle + "\r\n");
                this.TextBox.AppendText(volumeHeatTransferCoefficient + "\r\n");

                this.textBoxUnitSystem.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            }
        }
示例#13
0
 public Length(Double value, LengthUnit unit, int power)
 {
     Value = value;
      Unit = unit;
      Power = power;
 }
 /// <summary>Converts a Length from one unit to another.</summary>
 /// <param name = "value" >The value of the property to be converted.</param>
 /// <param name = "fromUnit" >The unit of the property to be converted.</param>
 /// <param name = "toUnit" >The unit to convert the property's value to.</param>
 /// <returns>The value of the property in the target unit.</returns>
 public static BigDecimal Convert( decimal value ,
                                    LengthUnit fromUnit ,
                                    LengthUnit toUnit )
 {
     return value * ( Length.Value ( fromUnit ) / Length.Value ( toUnit ) );
 }
		public Length(int value, LengthUnit unit)
		{
			Value = value;
			Unit = unit;
		}
 protected abstract LengthUnit __DoSubstraction(LengthUnit right);
 public static double getConversionFactor(LengthUnit from,LengthUnit to)
 {
     return factors[from.getIndex(),to.getIndex()];
 }
示例#18
0
 public Length(double value, LengthUnit units) { lengthValue = value; lengthUnit = units; }
        private double _convertValueTo(LengthUnit units)
        {
            switch (units)
            {
            case LengthUnit.Yoctometers:
                return(ToMeters() * Math.Pow(10, 24));

            case LengthUnit.Zeptometers:
                return(ToMeters() * Math.Pow(10, 21));

            case LengthUnit.Attometers:
                return(ToMeters() * Math.Pow(10, 18));

            case LengthUnit.Femtometers:
                return(ToMeters() * Math.Pow(10, 15));

            case LengthUnit.Picometers:
                return(ToMeters() * Math.Pow(10, 12));

            case LengthUnit.Nanometers:
                return(ToNanometers());

            case LengthUnit.Micrometers:
                return(ToMicrometers());

            case LengthUnit.Millimeters:
                return(ToMillimeters());

            case LengthUnit.Centimeters:
                return(ToCentimeters());

            case LengthUnit.Meters:
                return(ToMeters());

            case LengthUnit.Dekameters:
                return(ToMeters() / Math.Pow(10, 1));

            case LengthUnit.Hectometers:
                return(ToMeters() / Math.Pow(10, 2));

            case LengthUnit.Kilometers:
                return(ToMeters() / Math.Pow(10, 3));

            case LengthUnit.Megameters:
                return(ToMeters() / Math.Pow(10, 6));

            case LengthUnit.Gigameters:
                return(ToMeters() / Math.Pow(10, 9));

            case LengthUnit.Terameters:
                return(ToMeters() / Math.Pow(10, 12));

            case LengthUnit.Petameters:
                return(ToMeters() / Math.Pow(10, 15));

            case LengthUnit.Exameters:
                return(ToMeters() / Math.Pow(10, 18));

            case LengthUnit.Zettameters:
                return(ToMeters() / Math.Pow(10, 21));

            case LengthUnit.Yottameters:
                return(ToMeters() / Math.Pow(10, 24));

            case LengthUnit.Inches:
                return(ToInches());

            case LengthUnit.Hands:
                return(ToFeet() * 3.0);

            case LengthUnit.Feet:
                return(ToFeet());

            case LengthUnit.Yards:
                return(ToFeet() / 3.0);

            case LengthUnit.Fathoms:
                return(ToFeet() / 6.0);

            case LengthUnit.Perch:
                return(ToFeet() / 16.5);

            case LengthUnit.Poles:
                return(_convertValueTo(LengthUnit.Rods));

            case LengthUnit.Rods:
                return(ToFeet() / 5.5);

            case LengthUnit.Chains:
                return(ToFeet() / 66.0);

            case LengthUnit.Furlongs:
                return(_convertValueTo(LengthUnit.Rods) / 40.0);

            case LengthUnit.Miles:
                return(_convertValueTo(LengthUnit.Furlongs) / 8.0);

            case LengthUnit.Leagues:
                return(_convertValueTo(LengthUnit.Miles) / 3.0);

            case LengthUnit.Angstrom:
                return(ToInches() * 3.9 * Math.Pow(10, -5));

            case LengthUnit.NauticalMiles:
                return(_convertValueTo(LengthUnit.Kilometers) / 1.9);

            case LengthUnit.LightYears:
                return(_convertValueTo(LengthUnit.AstronomicalUnits) / 63000.0);

            case LengthUnit.AstronomicalUnits:
                return(_convertValueTo(LengthUnit.Kilometers) / 150000000.0);

            case LengthUnit.PlankLength:
                return(ToNanometers() * 6.25e+25);

            default:
                throw new ArgumentException("Invalid units: " + units.ToString());
            }
        }
 protected abstract LengthUnit __DoAddition(LengthUnit right);
 /// <summary>Calculates the ratio of the given unit to base unit.</summary>
 /// <param name = "aUnit" >The given unit.</param>
 /// <returns>The ratio of the given unit to base unit.</returns>
 public static BigDecimal Value( LengthUnit aUnit )
 {
     if ( _lengthUnitMap != null )
     {
         return _lengthUnitMap [ aUnit ];
     }
     if ( _lengthUnitMap != null )
     {
         return _lengthUnitMap [ BaseUnit ];
     }
     return BigDecimal.Zero;
 }
示例#22
0
 public static double Convert(double value, LengthUnit valueUnits, LengthUnit desiredUnits) => value * conversionToMeters[valueUnits] / conversionToMeters[desiredUnits];
示例#23
0
 protected Double ConversionFactorTo(LengthUnit targetUnit)
 {
     return getConversionFactorFromTo(this.Unit, targetUnit);
 }
示例#24
0
        /// <summary>
        ///     Parse a unit string.
        /// </summary>
        /// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
        /// <param name="unit">The parsed unit if successful.</param>
        /// <returns>True if successful, otherwise false.</returns>
        /// <example>
        ///     Length.TryParseUnit("m", new CultureInfo("en-US"));
        /// </example>
        /// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
        public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LengthUnit unit)
        {
            IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);

            return(UnitParser.Default.TryParse <LengthUnit>(str, provider, out unit));
        }
 protected override LengthUnit __DoAddition(LengthUnit right)
 {
     return new Meter(ConvertToBase().Value + right.ConvertToBase().Value);
 }
示例#26
0
        public static void ParseSuccess(string text, string expected)
        {
            var lengthUnit = LengthUnit.Parse(text);

            Assert.AreEqual(expected, lengthUnit.ToString());
        }
示例#27
0
 public static double getConversionFactor(LengthUnit from, LengthUnit to)
 {
     return(factors[from.getIndex(), to.getIndex()]);
 }
示例#28
0
 public static void ParseError(string text)
 {
     Assert.Throws <FormatException>(() => LengthUnit.Parse(text));
     Assert.AreEqual(false, LengthUnit.TryParse(text, out var _));
 }
示例#29
0
        internal static ReadResult DeserializeReadResult(JsonElement element)
        {
            int        page                = default;
            float      angle               = default;
            float      width               = default;
            float      height              = default;
            LengthUnit unit                = default;
            Language?  language            = default;
            IReadOnlyList <TextLine> lines = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("page"))
                {
                    page = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("angle"))
                {
                    angle = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("width"))
                {
                    width = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("height"))
                {
                    height = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = property.Value.GetString().ToLengthUnit();
                    continue;
                }
                if (property.NameEquals("language"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    language = new Language(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lines"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <TextLine> array = new List <TextLine>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(TextLine.DeserializeTextLine(item));
                        }
                    }
                    lines = array;
                    continue;
                }
            }
            return(new ReadResult(page, angle, width, height, unit, language, lines));
        }
示例#30
0
 public static void TryParseSuccess(string text, string expected)
 {
     Assert.AreEqual(true, LengthUnit.TryParse(text, out var result));
     Assert.AreEqual(expected, result.ToString());
 }
示例#31
0
 public UnitSystem(ForceUnit forceUnit, LengthUnit lengthUnit, StressUnit stressUnit)
 {
     ForceUnit  = forceUnit;
     LengthUnit = lengthUnit;
     StressUnit = stressUnit;
 }
示例#32
0
 public static void TryParseError(string text)
 {
     Assert.AreEqual(false, LengthUnit.TryParse(text, out var _));
 }
示例#33
0
 public object LengthPost(LengthUnit value)
 {
     return(this.repo.LengthPost(value));
 }
 public static FormPage FormPage(int pageNumber, float width, float height, float textAngle, LengthUnit unit, IReadOnlyList <FormLine> lines, IReadOnlyList <FormTable> tables) =>
 FormPage(pageNumber, width, height, textAngle, unit, lines, tables, default);
示例#35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchData"/> class.
        /// </summary>
        /// <param name="searchValue">Исходная поисковая строка</param>
        /// <param name="matchType">Тип совпадения для строковых значений</param>
        /// <param name="quantityMap">Единицы получения величин</param>
        public SearchData(string searchValue, MatchType matchType, QuantityMap quantityMap)
        {
            _matchType          = matchType;
            _lengthUnit         = quantityMap.LengthUnit;
            _massUnit           = quantityMap.MassUnit;
            _areaUnit           = quantityMap.AreaUnit;
            _volumeUnit         = quantityMap.VolumeUnit;
            _tolerance          = quantityMap.Tolerance;
            _searchBoolValues   = new List <Value>();
            _searchDoubleValues = new List <Value>();
            _searchIntValues    = new List <Value>();
            _searchStringValues = new List <Value>();

            _searchValues = new List <string>();

            foreach (var str in searchValue.Split('*'))
            {
                var s    = str;
                var name = string.Empty;
                if (s.Contains("="))
                {
                    var split = s.Split('=');
                    name = split[0];
                    s    = split[1];
                }

                var op = Operator.Equal;
                if (str.StartsWith("!="))
                {
                    op = Operator.NotEqual;
                    s  = str.Substring(2);
                }
                else if (str.StartsWith("<"))
                {
                    op = Operator.Less;
                    s  = str.Substring(1);
                }
                else if (str.StartsWith(">"))
                {
                    op = Operator.More;
                    s  = str.Substring(1);
                }

                var addString = true;
                if (int.TryParse(s, out var i))
                {
                    _searchIntValues.Add(new Value(op, s, i, name, matchType));
                    addString = false;
                }

                if (double.TryParse(s, out var d))
                {
                    _searchDoubleValues.Add(new Value(op, s, d, name, matchType));
                    addString = false;
                }

                if (bool.TryParse(s, out var b))
                {
                    _searchBoolValues.Add(new Value(op, s, b, name, matchType));
                    addString = false;
                }

                if (addString)
                {
                    _searchStringValues.Add(new Value(op, s, name, matchType));
                }

                _searchValues.Add(s);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormRecognizer.Models.FormPage"/> class.
        /// </summary>
        /// <param name="pageNumber">The 1-based page number in the input document.</param>
        /// <param name="width">The width of the image/PDF in pixels/inches, respectively.</param>
        /// <param name="height">The height of the image/PDF in pixels/inches, respectively.</param>
        /// <param name="textAngle">The general orientation of the text in clockwise direction, measured in degrees between (-180, 180].</param>
        /// <param name="unit">The unit used by the width, height and <see cref="FieldBoundingBox"/> properties. For images, the unit is pixel. For PDF, the unit is inch.</param>
        /// <param name="lines">A list of recognized lines of text.</param>
        /// <param name="tables">A list of recognized tables contained in this page.</param>
        /// <param name="selectionMarks">A list of recognized selection marks contained in this page.</param>
        /// <returns>A new <see cref="FormRecognizer.Models.FormPage"/> instance for mocking.</returns>
        public static FormPage FormPage(int pageNumber, float width, float height, float textAngle, LengthUnit unit, IReadOnlyList <FormLine> lines, IReadOnlyList <FormTable> tables, IReadOnlyList <FormSelectionMark> selectionMarks)
        {
            lines          = lines?.ToList();
            tables         = tables?.ToList();
            selectionMarks = selectionMarks?.ToList();

            return(new FormPage(pageNumber, width, height, textAngle, unit, lines, tables, selectionMarks));
        }
 public bool IsImperial(LengthUnit units)
 {
     return(units > LengthUnit.METRIC_END && units < LengthUnit.IMPERIAL_END);
 }
示例#38
0
 public static Length From(double value, LengthUnit fromUnit)
        private LengthUnit _parseUnits(string value)
        {
            LengthUnit units = LengthUnit.Unknown;

            if (!string.IsNullOrEmpty(value))
            {
                value = value.Trim().ToLowerInvariant();
            }

            value = Regex.Replace(value, @"metre(s?)$", "meter$1");

            switch (value)
            {
            case "ym":
            case "yoctometer":
            case "yoctometers":
                units = LengthUnit.Yoctometers;
                break;

            case "zm":
            case "zeptometer":
            case "zeptometers":
                units = LengthUnit.Zeptometers;
                break;

            case "am":
            case "attometer":
            case "attometers":
                units = LengthUnit.Attometers;
                break;

            case "fm":
            case "femtometer":
            case "femtometers":
                units = LengthUnit.Femtometers;
                break;

            case "pm":
            case "picometer":
            case "picometers":
                units = LengthUnit.Picometers;
                break;

            case "nm":
            case "nanometer":
            case "nanometers":
                units = LengthUnit.Nanometers;
                break;

            case "μm":
            case "micrometer":
            case "micrometers":
                units = LengthUnit.Micrometers;
                break;

            case "mm":
            case "millimeter":
            case "millimeters":
                units = LengthUnit.Millimeters;
                break;

            case "cm":
            case "centimeter":
            case "centimeters":
                units = LengthUnit.Centimeters;
                break;

            case "dm":
            case "decimeter":
            case "decimeters":
                units = LengthUnit.Decimeters;
                break;

            case "m":
            case "meter":
            case "meters":
                units = LengthUnit.Meters;
                break;

            case "dam":
            case "dekameter":
            case "dekameters":
                units = LengthUnit.Dekameters;
                break;

            case "hm":
            case "hectometer":
            case "hectometers":
                units = LengthUnit.Hectometers;
                break;

            case "km":
            case "kilometer":
            case "kilometers":
                units = LengthUnit.Kilometers;
                break;

            case "Mm":
            case "megameter":
            case "megameters":
                units = LengthUnit.Megameters;
                break;

            case "Gm":
            case "gigameter":
            case "gigameters":
                units = LengthUnit.Gigameters;
                break;

            case "Tm":
            case "terameter":
            case "terameters":
                units = LengthUnit.Terameters;
                break;

            case "Pm":
            case "petameter":
            case "petameters":
                units = LengthUnit.Petameters;
                break;

            case "Em":
            case "exameter":
            case "exameters":
                units = LengthUnit.Exameters;
                break;

            case "Zm":
            case "zettameter":
            case "zettameters":
                units = LengthUnit.Zettameters;
                break;

            case "Ym":
            case "yottameter":
            case "yottameters":
                units = LengthUnit.Yottameters;
                break;

            case "in":
            case "inch":
            case "inches":
                units = LengthUnit.Inches;
                break;

            case "h":
            case "hand":
            case "hands":
                units = LengthUnit.Hands;
                break;

            case "ft":
            case "foot":
            case "feet":
                units = LengthUnit.Feet;
                break;

            case "yd":
            case "yard":
            case "yards":
                units = LengthUnit.Yards;
                break;

            case "fathom":
            case "fathoms":
                units = LengthUnit.Fathoms;
                break;

            case "perch":
            case "perches":
                units = LengthUnit.Perch;
                break;

            case "pole":
            case "poles":
                units = LengthUnit.Poles;
                break;

            case "rd":
            case "rod":
            case "rods":
                units = LengthUnit.Rods;
                break;

            case "chain":
            case "chains":
                units = LengthUnit.Chains;
                break;

            case "furlong":
            case "furlongs":
                units = LengthUnit.Furlongs;
                break;

            case "mi":
            case "mile":
            case "miles":
                units = LengthUnit.Miles;
                break;

            case "league":
            case "leagues":
                units = LengthUnit.Leagues;
                break;

            case "ångström":
            case "angstrom":
            case "Å":
                units = LengthUnit.Angstrom;
                break;

            case "nautical mile":
            case "nautical miles":
            case "nmi":
                units = LengthUnit.NauticalMiles;
                break;

            case "light-year":
            case "light year":
            case "light-years":
            case "light years":
            case "ly":
                units = LengthUnit.LightYears;
                break;

            case "astronomical unit":
            case "astronomical units":
            case "au":
                units = LengthUnit.AstronomicalUnits;
                break;

            case "planck length":
            case "planck lengths":
            case "plancks":
            case "planck":
            case "ℓp":
                units = LengthUnit.PlankLength;
                break;
            }

            return(units);
        }
示例#40
0
        public static Length From(QuantityValue value, LengthUnit fromUnit)
#endif
        {
            return(new Length((double)value, fromUnit));
        }
 public Length(double value, LengthUnit units)
 {
     Value = value;
     Units = units;
 }
示例#42
0
 public static string GetAbbreviation(LengthUnit unit)
 {
     return(GetAbbreviation(unit, null));
 }
示例#43
0
 public Length(Double value, LengthUnit unit)
     : this(value, unit, 1)
 {
 }
示例#44
0
        public static string GetAbbreviation(
            LengthUnit unit,
#if WINDOWS_UWP
            [CanBeNull] string cultureName)
示例#45
0
 Length(double numericValue, LengthUnit unit)
 {
     _value = numericValue;
     _unit  = unit;
 }
示例#46
0
        /// <summary>
        /// Calculates the volume between the two horizons
        /// and above the fluid contact
        /// </summary>
        /// <param name="baseHorizonRelativeDepth">Base Horizon depth in relation to top horizon in meters</param>
        /// <param name="fluidContactDepth">Fluid contact dept in meters</param>
        /// <param name="resultUnit"></param>
        /// <returns></returns>
        internal void CalculateVolume(double baseHorizonRelativeDepth, double fluidContactDepth, LengthUnit lengthUnit)
        {
            double totalVolume = 0;

            var cellArea     = TopHorizon.CellArea;
            var baseDepth    = LengthConverter.Convert(baseHorizonRelativeDepth, lengthUnit, TopHorizon.LengthUnit);
            var fluidContact = LengthConverter.Convert(fluidContactDepth, lengthUnit, TopHorizon.LengthUnit);

            foreach (var topNodeDepth in TopHorizon.Nodes)
            {
                //Step 1: Determine if base depth or fluid contact will be considered.
                double actualBaseDepth = Math.Min(topNodeDepth + baseDepth, fluidContact);

                //Step 2: Determine height between top horizon and actualBaseDepth.
                //Height greater than zero means there is oil & gas to be calculated
                //Negative value means top horizon is under fluid contact and will not be calculated
                double height = actualBaseDepth - topNodeDepth;

                if (height > 0) //top horizon is above
                {
                    totalVolume += height * cellArea;
                }
            }

            CalculatedVolume = totalVolume;
        }
示例#47
0
 static Double getConversionFactorFromTo(LengthUnit from, LengthUnit to)
 {
     var frm = ConversionFactors[from];
      var too = ConversionFactors[to];
      Double v = ConversionFactors[from] / ConversionFactors[to];
      return v;
 }
示例#48
0
 public static Membrane From(IParameters concreteParameters, WebReinforcement?reinforcement, double width, ConstitutiveModel model = ConstitutiveModel.MCFT, LengthUnit unit = LengthUnit.Millimeter, bool considerCrackSlip = true) =>
 From(concreteParameters, reinforcement, (Length)width.As(unit), model, considerCrackSlip);
示例#49
0
 public LengthUnits(double digitField, LengthUnit unit = LengthUnit.Meter)
     : base(digitField)
 {
     DigitField = LengthConvertor.ReturnMeters(unit, digitField);
     NameField = "Meter";
 }
示例#50
0
 protected Membrane(IParameters concreteParameters, WebReinforcement?reinforcement, double width, ConstitutiveModel model, LengthUnit unit = LengthUnit.Millimeter)
     : this(concreteParameters, reinforcement, (Length)width.As(unit), model)
 {
 }
 protected override LengthUnit __DoSubstraction(LengthUnit right)
 {
     return new Meter(ConvertToBase().Value - right.ConvertToBase().Value);
 }
 protected static string CreateSuffix(SymbolFormat format, LengthUnit unit)
 {
     return default(Length).ToString(unit, format).Trim('0');
 }