GeometryGym.Ifc.ParserIfc.parseMeasureValue C# (CSharp) Méthode

parseMeasureValue() static private méthode

static private parseMeasureValue ( string str ) : IfcMeasureValue
str string
Résultat IfcMeasureValue
        internal static IfcMeasureValue parseMeasureValue(string str)
        {
            try
            {
                if (string.IsNullOrEmpty(str))
                    return null;
                int len = str.Length;
                if (str.EndsWith(")"))
                    len--;
                int icounter = 0;
                char c = str[icounter];
                while (!char.IsDigit(c) && c != '-' && c != '.' && icounter < str.Length)
                    c = str[icounter++];
                if (icounter == str.Length)
                    return null;
                icounter--;
                if (icounter > 1)
                {
                    string kw = str.Substring(0, icounter - 1).ToLower();
                    if (kw.All(Char.IsLetter))
                    {
                        Dictionary<string, Type> types = MeasureValueTypes;
                        if (types.ContainsKey(kw))
                        {
                            Type type = types[kw];
                            if (type != null)
                            {
                                if (type.GetInterfaces().Contains(typeof(IfcMeasureValue)))
                                    return extractMeasureValue(type, str.Substring(icounter, len - icounter));
                            }
                        }
                    }
                }
            }
            catch(Exception) { }
            return null;
        }

Usage Example

Exemple #1
0
        internal override void parse(string str, ref int pos, ReleaseVersion release, int len, ConcurrentDictionary <int, BaseClassIfc> dictionary)
        {
            base.parse(str, ref pos, release, len, dictionary);
            Directrix = dictionary[ParserSTEP.StripLink(str, ref pos, len)] as IfcCurve;
            string field = ParserSTEP.StripField(str, ref pos, len);

            if (field.StartsWith("I"))
            {
                mStartParam = ParserIfc.parseMeasureValue(field) as IfcCurveMeasureSelect;
            }
            else
            {
                double d = ParserSTEP.ParseDouble(field);
                if (!double.IsNaN(d))
                {
                    mStartParam = new IfcParameterValue(d);
                }
            }
            field = ParserSTEP.StripField(str, ref pos, len);
            if (field.StartsWith("I"))
            {
                mEndParam = ParserIfc.parseMeasureValue(field) as IfcCurveMeasureSelect;
            }
            else
            {
                double d = ParserSTEP.ParseDouble(field);
                if (!double.IsNaN(d))
                {
                    mEndParam = new IfcParameterValue(d);
                }
            }
        }
All Usage Examples Of GeometryGym.Ifc.ParserIfc::parseMeasureValue