/// <summary> /// If the module is first in the execution queue, this function will be called on a series of /// filenames. /// Default behavior: Standard loading behavior for .jnt and .xml files /// </summary> /// <param name="filename">A filename to load</param> /// <returns>The sketch that is loaded.</returns> private static Sketch.Sketch loadFile(string filename) { Sketch.Sketch sketch; // Load if (Files.FUtil.FileType(filename) == Files.Filetype.XML) { try { ConverterXML.ReadXML xmlReader = new ConverterXML.ReadXML(filename); sketch = xmlReader.Sketch; } catch (Exception e) { Console.Error.WriteLine("oops, caught exception {0}", e); return(null); } } else if (Files.FUtil.FileType(filename) == Files.Filetype.JOURNAL) { int numPages = ConverterJnt.ReadJnt.NumberOfPages(filename); if (numPages > 1) { Console.WriteLine("WARNING: Detected more than one page in journal file '" + filename + "'. Just using the first one..."); } ConverterJnt.ReadJnt ink = new ConverterJnt.ReadJnt(filename, 1); sketch = ink.Sketch; } else { Console.WriteLine("WARNING: {0} is an unsupported filetype", filename); return(null); } // Fill in stroke classifications based on shape types, since this info // isn't saved in the XML or JNT files. foreach (Sketch.Shape shape in sketch.Shapes) { // In making this assignment we update the classification for the // substrokes and the shape itself. shape.Type = shape.Type; } return(sketch); }
/// <summary> /// If the module is first in the execution queue, this function will be called on a series of /// filenames. /// Default behavior: Standard loading behavior for .jnt and .xml files /// </summary> /// <param name="filename">A filename to load</param> /// <returns>The sketch that is loaded.</returns> private static Sketch.Sketch loadFile(string filename) { Sketch.Sketch sketch; // Load if (Files.FUtil.FileType(filename) == Files.Filetype.XML) { try { ConverterXML.ReadXML xmlReader = new ConverterXML.ReadXML(filename); sketch = xmlReader.Sketch; } catch (Exception e) { Console.Error.WriteLine("oops, caught exception {0}", e); return(null); } } else if (Files.FUtil.FileType(filename) == Files.Filetype.JOURNAL) { int numPages = ConverterJnt.ReadJnt.NumberOfPages(filename); if (numPages > 1) { Console.WriteLine("WARNING: Detected more than one page in journal file '" + filename + "'. Just using the first one..."); } ConverterJnt.ReadJnt ink = new ConverterJnt.ReadJnt(filename, 1); sketch = ink.Sketch; } else { Console.WriteLine("WARNING: {0} is an unsupported filetype", filename); return(null); } List <Sketch.Substroke> substrokesToRemove = new List <Sketch.Substroke>(); // Fill in stroke classifications based on shape types, since this info // isn't saved in the XML or JNT files. foreach (Sketch.Shape shape in sketch.Shapes) { if (shape.Type.Equals(new ShapeType())) { Console.WriteLine("Ignoring shape with unknown type: " + shape); substrokesToRemove.AddRange(shape.Substrokes); } else { // In making this assignment we update the classification for the // substrokes and the shape itself. shape.Type = shape.Type; // Make absolutely sure we are free to alter the shape shape.AlreadyLabeled = false; shape.AlreadyGrouped = false; shape.AlreadyOriented = false; } } // Remove shapes with unknown types foreach (Substroke substroke in substrokesToRemove) { sketch.RemoveSubstroke(substroke); } sketch.CheckConsistency(); return(sketch); }