[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/actions ImportFileReader.java, 1.22, 1.
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-11-17 09:57:07
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20232/src/net/sourceforge/bprocessor/gui/actions Modified Files: ImportFileReader.java FileImportActionListener.java Log Message: Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** FileImportActionListener.java 29 Jun 2009 08:37:40 -0000 1.27 --- FileImportActionListener.java 17 Nov 2009 09:56:55 -0000 1.28 *************** *** 192,196 **** this.add(basis); this.add(new JLabel("Scale")); ! scale = new JTextField("1:100", 5); scale.addActionListener(this); this.add(scale); --- 192,196 ---- this.add(basis); this.add(new JLabel("Scale")); ! scale = new JTextField("0.0254", 5); scale.addActionListener(this); this.add(scale); *************** *** 216,220 **** */ public double getScale() { ! return 1.0 / Integer.parseInt(scale.getText().substring(2)); } --- 216,222 ---- */ public double getScale() { ! String txt = scale.getText(); ! double value = Double.valueOf(txt); ! return value; } Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ImportFileReader.java 25 Jun 2009 23:28:46 -0000 1.22 --- ImportFileReader.java 17 Nov 2009 09:56:55 -0000 1.23 *************** *** 28,31 **** --- 28,32 ---- import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Item; import net.sourceforge.bprocessor.model.Material; import net.sourceforge.bprocessor.model.Project; *************** *** 35,39 **** /** ! * A singleton class with stitic methods for loading different file formats into the model */ public class ImportFileReader { --- 36,40 ---- /** ! * A singleton class with static methods for loading different file formats into the model */ public class ImportFileReader { *************** *** 87,91 **** List<Space> groups = new LinkedList<Space>(); Map<String, Material> materialMap = new HashMap<String, Material>(); ! Space currentGroup = into.createConstructionSpace("Object"); Material currentMaterial = null; boolean missNormals = false; --- 88,92 ---- List<Space> groups = new LinkedList<Space>(); Map<String, Material> materialMap = new HashMap<String, Material>(); ! Space currentGroup = Item.createConstructionSpace("Object"); Material currentMaterial = null; boolean missNormals = false; *************** *** 166,169 **** --- 167,173 ---- edge.add(findEdge(prev, first, v2es)); Surface s = new Surface(edge); + if (currentGroup.getMaterial() == null) { + currentGroup.setMaterial(currentMaterial); + } s.setBackDomain(currentGroup); if (!normals.isEmpty()) { *************** *** 173,184 **** } surfaces.add(s); ! if (currentMaterial == null) { ! currentMaterial = new Material("Object", new float[]{0.9f, 0.9f, 0.9f}); ! materialMap.put("default", currentMaterial); } - s.setFrontMaterial(currentMaterial); edges.addAll(edge); } else if (lineContent[0].equals("g")) { ! currentGroup = into.createConstructionSpace(lineContent[1]); groups.add(currentGroup); } else if (lineContent[0].equals("usemtl")) { --- 177,186 ---- } surfaces.add(s); ! if (currentGroup.getMaterial() != currentMaterial) { ! s.setBackMaterial(currentMaterial); } edges.addAll(edge); } else if (lineContent[0].equals("g")) { ! currentGroup = Item.createConstructionSpace(lineContent[1]); groups.add(currentGroup); } else if (lineContent[0].equals("usemtl")) { *************** *** 192,198 **** name += " " + lineContent[i]; } ! loadMaterials(new File(f.getParent() + "\\" + name), materialMap); } else if (lineContent[0].equals("") || lineContent[0].equals("#")) { ! //Just comments continue; } else { --- 194,201 ---- name += " " + lineContent[i]; } ! ! loadMaterials(new File(f.getParent(), name), materialMap); } else if (lineContent[0].equals("") || lineContent[0].equals("#")) { ! // Just comments continue; } else { *************** *** 262,265 **** --- 265,269 ---- private static void loadMaterials(File file, Map<String, Material> materialMap) throws FileNotFoundException, IOException { + if (file.exists() && file.canRead()) { FileInputStream stream = new FileInputStream(file); *************** *** 269,276 **** --- 273,282 ---- while (br.ready()) { String line = br.readLine().trim(); + String[] content = line.split("\\s"); if (content[0].equals("newmtl")) { currentMaterial = new Material(); currentMaterial.setName(content[1]); + materialMap.put(currentMaterial.getName(), currentMaterial); } else { |