Beispiel #1
0
        private static DatumReferenceValue ParseDatumReferenceValue(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return(null);
            }

            StringBuilder value            = new StringBuilder();
            ToleranceMaterialCondition mat = ToleranceMaterialCondition.None;

            CharEnumerator chars = s.GetEnumerator();

            while (chars.MoveNext())
            {
                char token = chars.Current;
                if (token == '{')
                {
                    char symbol = Symbol(chars);
                    mat = ParseMaterialCondition(symbol);
                }
                else
                {
                    value.Append(token);
                }
            }

            DatumReferenceValue d = new DatumReferenceValue
            {
                Value             = value.ToString(),
                MaterialCondition = mat
            };

            return(d);
        }
Beispiel #2
0
        private static string DatumValueToString(DatumReferenceValue datum)
        {
            StringBuilder value = new StringBuilder();

            value.Append("%%v");

            if (datum != null)
            {
                value.Append(datum.Value);
                switch (datum.MaterialCondition)
                {
                case ToleranceMaterialCondition.None:
                    break;

                case ToleranceMaterialCondition.Maximum:
                    value.Append("{\\Fgdt;m}");
                    break;

                case ToleranceMaterialCondition.Least:
                    value.Append("{\\Fgdt;l}");
                    break;

                case ToleranceMaterialCondition.Regardless:
                    value.Append("{\\Fgdt;s}");
                    break;
                }
            }

            return(value.ToString());
        }
 /// <summary>
 /// Initializes a new instance of the <c>ToleranceEntry</c> class.
 /// </summary>
 public ToleranceEntry()
 {
     this.geometricSymbol = ToleranceGeometricSymbol.None;
     this.tolerance1      = null;
     this.tolerance2      = null;
     this.datum1          = null;
     this.datum2          = null;
     this.datum3          = null;
 }
 /// <summary>
 /// Initializes a new instance of the <c>ToleranceEntry</c> class.
 /// </summary>
 public ToleranceEntry()
 {
     this.geometricSymbol = ToleranceGeometricSymbol.None;
     this.tolerance1 = null;
     this.tolerance2 = null;
     this.datum1 = null;
     this.datum2 = null;
     this.datum3 = null;
 }
Beispiel #5
0
        private static DatumReferenceValue ParseDatumReferenceValue(string s)
        {
            if (string.IsNullOrEmpty(s))
                return null;

            StringBuilder value = new StringBuilder();
            ToleranceMaterialCondition mat = ToleranceMaterialCondition.None;

            CharEnumerator chars = s.GetEnumerator();
            while (chars.MoveNext())
            {
                char token = chars.Current;
                if (token == '{')
                {
                    char symbol = Symbol(chars);
                    mat = ParseMaterialCondition(symbol);
                }
                else
                {
                    value.Append(token);
                }
            }

            DatumReferenceValue d = new DatumReferenceValue
            {
                Value = value.ToString(),
                MaterialCondition = mat
            };

            return d;
        }
Beispiel #6
0
        private static string DatumValueToString(DatumReferenceValue datum)
        {
            StringBuilder value = new StringBuilder();
            value.Append("%%v");

            if (datum != null)
            {
                value.Append(datum.Value);
                switch (datum.MaterialCondition)
                {
                    case ToleranceMaterialCondition.None:
                        break;
                    case ToleranceMaterialCondition.Maximum:
                        value.Append("{\\Fgdt;m}");
                        break;
                    case ToleranceMaterialCondition.Least:
                        value.Append("{\\Fgdt;l}");
                        break;
                    case ToleranceMaterialCondition.Regardless:
                        value.Append("{\\Fgdt;s}");
                        break;
                }
            }

            return value.ToString();
        }
Beispiel #7
0
        private static ToleranceEntry ParseToleranceEntry(string line)
        {
            string[] values = Regex.Split(line, "%%v");

            ToleranceGeometricSymbol geom = ToleranceGeometricSymbol.None;
            ToleranceValue           t1   = null;
            ToleranceValue           t2   = null;
            DatumReferenceValue      d1   = null;
            DatumReferenceValue      d2   = null;
            DatumReferenceValue      d3   = null;

            if (!string.IsNullOrEmpty(values[0]))
            {
                if (values[0].StartsWith("{"))
                {
                    // geometric symbol
                    CharEnumerator chars  = values[0].GetEnumerator();
                    char           symbol = Symbol(chars);
                    geom = ParseGeometricSymbol(symbol);
                }
            }

            for (int i = 1; i < values.Length; i++)
            {
                string value = values[i];

                switch (i)
                {
                case 1:
                    t1 = ParseToleranceValue(value);
                    break;

                case 2:
                    t2 = ParseToleranceValue(value);
                    break;

                case 3:
                    d1 = ParseDatumReferenceValue(value);
                    break;

                case 4:
                    d2 = ParseDatumReferenceValue(value);
                    break;

                case 5:
                    d3 = ParseDatumReferenceValue(value);
                    break;

                default:
                    throw new FormatException("The tolerance string representation is not well formatted");
                }
            }

            ToleranceEntry t = new ToleranceEntry
            {
                GeometricSymbol = geom,
                Tolerance1      = t1,
                Tolerance2      = t2,
                Datum1          = d1,
                Datum2          = d2,
                Datum3          = d3
            };

            return(t);
        }