Example #1
0
 private static void WriteLines(StreamWriter writer, IgesSectionType sectionType, List <string> lines)
 {
     for (int i = 0; i < lines.Count; i++)
     {
         writer.Write(MakeFileLine(sectionType, lines[i], i + 1));
     }
 }
Example #2
0
        private static string MakeFileLine(IgesSectionType sectionType, string line, int lineNumber)
        {
            line = line ?? string.Empty;
            if (line.Length > 72)
            {
                throw new IgesException("Line is too long");
            }

            var fullLine = string.Format("{0,-72}{1}{2,7}\n", line, SectionTypeChar(sectionType), lineNumber);

            return(fullLine);
        }
Example #3
0
 internal override void OnAfterRead(IgesDirectoryData directoryData)
 {
     base.OnAfterRead(directoryData);
     if (FormNumber >= 1 && FormNumber <= 3)
     {
         Debug.Assert((int)PointFormat == FormNumber);
         _dataType = IgesCopiousDataType.PointSet;
     }
     else if (FormNumber >= 11 && FormNumber <= 13)
     {
         Debug.Assert((int)PointFormat == FormNumber - 10);
         Debug.Assert(DataPoints.Count >= 2);
         _dataType = IgesCopiousDataType.LinearPath;
     }
     else if (FormNumber >= 20 && FormNumber <= 21)
     {
         Debug.Assert(EntityUseFlag == IgesEntityUseFlag.Annotation);
         Debug.Assert(PointFormat == IgesCopiousDataPointFormat.CommonZ);
         Debug.Assert(DataPoints.Count % 2 == 0);
         _dataType       = IgesCopiousDataType.CenterLine;
         _centerlineType = (IgesCenterlineType)FormNumber;
     }
     else if (FormNumber >= 31 && FormNumber <= 38)
     {
         Debug.Assert(EntityUseFlag == IgesEntityUseFlag.Annotation);
         Debug.Assert(PointFormat == IgesCopiousDataPointFormat.CommonZ);
         Debug.Assert(DataPoints.Count % 2 == 0);
         _dataType    = IgesCopiousDataType.Section;
         _sectionType = (IgesSectionType)FormNumber;
     }
     else if (FormNumber == 40)
     {
         Debug.Assert(EntityUseFlag == IgesEntityUseFlag.Annotation);
         Debug.Assert(PointFormat == IgesCopiousDataPointFormat.CommonZ);
         Debug.Assert(DataPoints.Count >= 3);
         Debug.Assert(DataPoints.Count % 2 == 1);
         _dataType = IgesCopiousDataType.WitnessLine;
     }
     else if (FormNumber == 63)
     {
         Debug.Assert(DataPoints.Count >= 2);
         _dataType = IgesCopiousDataType.ClosedCurve;
     }
     else
     {
         Debug.Assert(false, "unexpected form number " + FormNumber);
     }
 }
Example #4
0
        private static char SectionTypeChar(IgesSectionType type)
        {
            switch (type)
            {
            case IgesSectionType.Start: return('S');

            case IgesSectionType.Global: return('G');

            case IgesSectionType.Directory: return('D');

            case IgesSectionType.Parameter: return('P');

            case IgesSectionType.Terminate: return('T');

            default:
                throw new IgesException("Unexpected section type " + type);
            }
        }