Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Line.java, 1.16, 1.17 Point.java, 1.
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-07-31 11:25:55
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11071/src/net/sourceforge/bprocessor/model Modified Files: Line.java Point.java Persistence.java CoordinateSystem.java Constructor.java Log Message: Added xml schema for constructors and added interlizing and externalizing of constructors to persistens.java, Added checkpoint call to ConstructorTool and added empty constructor to Line Point and Coordinatesystem Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Persistence.java 15 May 2006 10:31:45 -0000 1.3 --- Persistence.java 31 Jul 2006 11:25:51 -0000 1.4 *************** *** 9,21 **** --- 9,28 ---- import net.sourceforge.bprocessor.model.xml.Bmodel; + import net.sourceforge.bprocessor.model.xml.ConstructorType; + import net.sourceforge.bprocessor.model.xml.CoordinateSystemType; import net.sourceforge.bprocessor.model.xml.EdgeType; import net.sourceforge.bprocessor.model.xml.EntityType; + import net.sourceforge.bprocessor.model.xml.LineType; import net.sourceforge.bprocessor.model.xml.MaterialType; + import net.sourceforge.bprocessor.model.xml.PointType; import net.sourceforge.bprocessor.model.xml.SpaceType; import net.sourceforge.bprocessor.model.xml.SurfaceType; import net.sourceforge.bprocessor.model.xml.VertexType; import net.sourceforge.bprocessor.model.xml.impl.BmodelImpl; + import net.sourceforge.bprocessor.model.xml.impl.CoordinateSystemTypeImpl; import net.sourceforge.bprocessor.model.xml.impl.EdgeImpl; + import net.sourceforge.bprocessor.model.xml.impl.LineTypeImpl; import net.sourceforge.bprocessor.model.xml.impl.MaterialImpl; + import net.sourceforge.bprocessor.model.xml.impl.PointTypeImpl; import net.sourceforge.bprocessor.model.xml.impl.SpaceImpl; import net.sourceforge.bprocessor.model.xml.impl.SurfaceImpl; *************** *** 79,82 **** --- 86,91 ---- } Project.getInstance().setWorld(world); + Project.getInstance().setActiveCoordinateSystem( + (CoordinateSystem) get(document.getCs(), mapper)); Project.getInstance().setActiveSpace((Space) get(document.getActive(), mapper)); } *************** *** 174,180 **** --- 183,237 ---- } } + { + Iterator iter = xml.getConstructor().iterator(); + while (iter.hasNext()) { + ConstructorType current = (ConstructorType) iter.next(); + space.add(internalizeConstructor(current, mapper, xmls)); + } + } return space; } + + /** + * + * @param xml The ConstructorType + * @param mapper The mapper + * @param xmls The xmls + * @return The Constructor + */ + private static Constructor internalizeConstructor(ConstructorType xml, + Map mapper, Collection xmls) { + Constructor res; + if (xml instanceof PointType) { + res = new Point(); + } else if (xml instanceof LineType) { + Line l = new Line(); + l.setDirection(internalizeVertex(((LineType)xml).getDirection(), + new HashMap(), new LinkedList())); + res = l; + } else if (xml instanceof CoordinateSystemType) { + CoordinateSystem cs = new CoordinateSystem(); + CoordinateSystemType cst = (CoordinateSystemType)xml; + cs.onlyPlane(cst.isOnlyplane()); + List ijn = cst.getIjn(); + Vertex i = internalizeVertex((VertexType)ijn.get(0), new HashMap(), new LinkedList()); + Vertex j = internalizeVertex((VertexType)ijn.get(1), new HashMap(), new LinkedList()); + Vertex n = internalizeVertex((VertexType)ijn.get(2), new HashMap(), new LinkedList()); + cs.setIJN(i, j, n); + res = cs; + } else { + log.error(xml + " were not a known constructor"); + return null; + } + res.setActive(xml.isActive()); + res.setEditable(xml.isEditable()); + res.setId(new Long(xml.getProgid())); + mapper.put(new Long(xml.getId()), res); + res.setOrigin(internalizeVertex(xml.getOrigin(), new HashMap(), new LinkedList())); + xmls.add(xml); + return res; + } + /** * *************** *** 217,221 **** private static Vertex internalizeVertex(VertexType xml, Map mapper, Collection xmls) { Vertex vertex = new Vertex(); ! vertex.setId(new Long(xml.getProgid())); mapper.put(new Long(xml.getId()), vertex); xmls.add(xml); --- 274,280 ---- private static Vertex internalizeVertex(VertexType xml, Map mapper, Collection xmls) { Vertex vertex = new Vertex(); ! if (xml.getProgid() != 0) { ! vertex.setId(new Long(xml.getProgid())); ! } mapper.put(new Long(xml.getId()), vertex); xmls.add(xml); *************** *** 386,389 **** --- 445,449 ---- } } + document.setCs(id(mapper, Project.getInstance().getActiveCoordinateSystem())); document.setActive(id(mapper, Project.getInstance().getActiveSpace())); return document; *************** *** 471,474 **** --- 531,578 ---- } } + { + Iterator iter = space.getConstructors().iterator(); + while (iter.hasNext()) { + Constructor current = (Constructor) iter.next(); + xml.getConstructor().add(externalizeConstructor(current, map)); + } + } + return xml; + } + + /** + * Create an xml ConstructorImpl and place it in the map + * @param constructor The constructor + * @param map The map + * @return The ConstructorImpl + */ + private static ConstructorType externalizeConstructor(Constructor constructor, Map map) { + ConstructorType xml; + if (constructor instanceof Point) { + xml = new PointTypeImpl(); + } else if (constructor instanceof Line) { + xml = new LineTypeImpl(); + ((LineType)xml).setDirection(externalizeVertex(((Line)constructor).getDirection(), + new HashMap())); + } else if (constructor instanceof CoordinateSystem) { + CoordinateSystem cs = (CoordinateSystem)constructor; + CoordinateSystemType cst = new CoordinateSystemTypeImpl(); + cst.setOnlyplane(((CoordinateSystem)constructor).onlyPlane()); + List ijn = cst.getIjn(); + ijn.add(0, externalizeVertex(cs.getI(), new HashMap())); + ijn.add(1, externalizeVertex(cs.getJ(), new HashMap())); + ijn.add(2, externalizeVertex(cs.getN(), new HashMap())); + xml = cst; + } else { + log.error(constructor + " were of unknown type"); + return null; + } + xml.setId(counter++); + xml.setProgid(constructor.getId().longValue()); + xml.setActive(constructor.isActive()); + xml.setEditable(constructor.isEditable()); + VertexType orig = externalizeVertex(constructor.getOrigin(), new HashMap()); + xml.setOrigin(orig); + map.put(constructor, xml); return xml; } *************** *** 513,517 **** VertexType xml = new VertexImpl(); xml.setId(counter++); ! xml.setProgid(vertex.getId().longValue()); map.put(vertex, xml); xml.setX(vertex.getX()); --- 617,623 ---- VertexType xml = new VertexImpl(); xml.setId(counter++); ! if (vertex.getId() != null) { ! xml.setProgid(vertex.getId().longValue()); ! } map.put(vertex, xml); xml.setX(vertex.getX()); *************** *** 588,593 **** } else if (object instanceof Vertex) { externalizeReferences((Vertex) object, (VertexType) xml, map); ! } else if (object instanceof Material) { externalizeMaterial((Material) object, (MaterialType) xml, map); } } --- 694,701 ---- } else if (object instanceof Vertex) { externalizeReferences((Vertex) object, (VertexType) xml, map); ! } else if (object instanceof Material) { externalizeMaterial((Material) object, (MaterialType) xml, map); + } else if (object instanceof Constructor) { + externalizeReferences((Constructor) object, (ConstructorType) xml, map); } } *************** *** 646,649 **** --- 754,766 ---- * @param map The map */ + private static void externalizeReferences(Constructor object, ConstructorType xml, Map map) { + } + + /** + * Externalize references + * @param object The object + * @param xml The xml entity + * @param map The map + */ private static void externalizeMaterial(Material object, MaterialType xml, Map map) { } Index: Point.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Point.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Point.java 27 Jul 2006 08:05:21 -0000 1.6 --- Point.java 31 Jul 2006 11:25:51 -0000 1.7 *************** *** 25,28 **** --- 25,36 ---- /** + * A persistence constructor + * Constructor + */ + public Point() { + super(); + } + + /** * Collects the set of vertices in this geometric * @return the set of vertices Index: Constructor.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Constructor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Constructor.java 27 Jul 2006 10:27:02 -0000 1.6 --- Constructor.java 31 Jul 2006 11:25:51 -0000 1.7 *************** *** 22,40 **** /** Specify wether the constructor is changable */ private boolean editable; - /** - * True if the constructor is active - * @return Returns the active. - */ - public boolean isActive() { - return active; - } /** ! * @param active The active to set. */ ! public void setActive(boolean active) { ! this.active = active; } ! /** * The constructor method --- 22,32 ---- /** Specify wether the constructor is changable */ private boolean editable; /** ! * Do not use, for persistence use only */ ! public Constructor() { } ! /** * The constructor method *************** *** 60,63 **** --- 52,70 ---- /** + * True if the constructor is active + * @return Returns the active. + */ + public boolean isActive() { + return active; + } + + /** + * @param active The active to set. + */ + public void setActive(boolean active) { + this.active = active; + } + + /** * Getter for the origin * @return The origin Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CoordinateSystem.java 27 Jul 2006 08:05:21 -0000 1.19 --- CoordinateSystem.java 31 Jul 2006 11:25:51 -0000 1.20 *************** *** 39,42 **** --- 39,49 ---- /** + * Empty constructor for persistence only + */ + public CoordinateSystem() { + super(); + } + + /** * Constructor secure that they all are orthogonal to each other and normalized * @param i The i vector *************** *** 381,383 **** --- 388,418 ---- return "CS-" + getId(); } + + /** + * Set the I and J vectors + * @param i the I vector + * @param j the J vector + */ + public void setIJ(Vertex i, Vertex j) { + this.i = i; + this.j = j; + this.i.normalize(); + this.j.normalize(); + this.n = this.i.cross(this.j); + } + + /** + * Set the I, J and N vectors + * @param i the I vector + * @param j the J vector + * @param n the N vector + */ + public void setIJN(Vertex i, Vertex j, Vertex n) { + this.i = i; + this.j = j; + this.n = n; + this.i.normalize(); + this.j.normalize(); + this.n.normalize(); + } } Index: Line.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Line.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Line.java 27 Jul 2006 10:27:02 -0000 1.16 --- Line.java 31 Jul 2006 11:25:51 -0000 1.17 *************** *** 20,23 **** --- 20,30 ---- /** + * Empty constructor for persistence only + */ + public Line() { + super(); + } + + /** * Constuctor of Line with only the origin and a standard direction of (1,0,0) * @param origin The origin |