1 package edu.berkeley.qfat;
2 import java.io.StreamTokenizer;
4 import java.io.IOException;
8 * Description: STL files loader (Supports ASCII and binary files) for Java3D
9 * Needs JDK 1.4 due to endian problems
10 * Copyright: Copyright (c) 2001
11 * Company: Universidad del Pais Vasco (UPV/EHU)
12 * @author: Carlos Pedrinaci Godoy
15 * Contact : xenicp@yahoo.es
18 * Extends StreamTokenizer
20 * Each token returned is checked in StlFile.java
21 * Format of an ASCII STL file:
23 * solid /users/vis/dru/wedge.stl
34 * endsolid /users/vis/dru/wedge.stl
36 * That Class is necessary because scientific numbers are not correctly readed by Tokenizer
37 * we must then extend that class and define another getNumber
40 public class StlFileParser extends StreamTokenizer
43 * Constructor: object creation and setup
45 * @param r The Reader instance
47 public StlFileParser(Reader r)
54 * Method that sets some params of the Tokenizer for reading the file correctly
59 eolIsSignificant(true); // The End Of Line is important
62 // All printable ascii characters
65 whitespaceChars(' ', ' ');
66 whitespaceChars('\n', '\n');
67 whitespaceChars('\r', '\r');
68 whitespaceChars('\t', '\t');
72 * Gets a number from the stream. Note that we don't recognize
73 * numbers in the tokenizer automatically because numbers might be in
74 * scientific notation, which isn't processed correctly by
75 * StreamTokenizer. The number is returned in nval.
86 throw new IOException("Expected number on line " + lineno());
87 nval = (Double.valueOf(sval)).doubleValue();
89 catch (IOException e) {
90 System.err.println(e.getMessage());
93 catch (NumberFormatException e) {
94 System.err.println(e.getMessage());
100 }// End of StlFileParser