[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Instance.java, 1.7, 1.8 Space.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-12-20 14:19:52
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26410/src/net/sourceforge/bprocessor/model Modified Files: Instance.java Space.java Mesh.java Entity.java Container.java Log Message: Mesh.copy now works with instances Index: Instance.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Instance.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Instance.java 19 Dec 2007 11:39:04 -0000 1.7 --- Instance.java 20 Dec 2007 14:19:55 -0000 1.8 *************** *** 121,123 **** --- 121,141 ---- return edges; } + + /** + * {@inheritDoc} + */ + public Space shallowCopy() { + Instance copy = new Instance(name); + copy.classification = classification; + copy.container = container; + copy.description = description; + copy.isNet = isNet; + copy.isUnion = isUnion; + copy.transparent = transparent; + copy.type = type; + copy.anchor = anchor.copy(); + copy.proto = proto; + return copy; + } + } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.230 retrieving revision 1.231 diff -C2 -d -r1.230 -r1.231 *** Space.java 18 Dec 2007 08:02:53 -0000 1.230 --- Space.java 20 Dec 2007 14:19:55 -0000 1.231 *************** *** 16,19 **** --- 16,20 ---- import java.util.LinkedList; import java.util.List; + import java.util.Map; import java.util.Set; *************** *** 648,662 **** * @return new space */ ! public Container shallowCopy() { ! Container copy = new Container(); ! copy.classification = classification; ! copy.container = container; ! copy.description = description; ! copy.name = name; ! copy.isNet = isNet; ! copy.isUnion = isUnion; ! copy.transparent = transparent; ! copy.type = type; ! return copy; } --- 649,662 ---- * @return new space */ ! public Space shallowCopy() { ! return null; ! } ! ! /** ! * ! * @param map map ! * @param to to ! */ ! public void copyInterior(Map map, Space to) { } Index: Mesh.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Mesh.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Mesh.java 20 Dec 2007 12:26:24 -0000 1.28 --- Mesh.java 20 Dec 2007 14:19:55 -0000 1.29 *************** *** 9,13 **** import java.util.Collection; - import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; --- 9,12 ---- *************** *** 22,26 **** private Collection<Edge> edges; private Collection<Surface> surfaces; ! private Collection<Container> elements; /** --- 21,25 ---- private Collection<Edge> edges; private Collection<Surface> surfaces; ! private Collection<Space> elements; /** *************** *** 53,57 **** * @param vertices Collection of vertices */ ! public Mesh(Collection<Container> elements, Collection<Surface> surfaces, Collection<Edge> edges, --- 52,56 ---- * @param vertices Collection of vertices */ ! public Mesh(Collection<Space> elements, Collection<Surface> surfaces, Collection<Edge> edges, *************** *** 71,78 **** Collection<Edge> edges = new HashSet<Edge>(); Collection<Surface> surfaces = new HashSet<Surface>(); ! Collection<Container> elements = new HashSet<Container>(); for (Geometric current : geometrics) { ! if (current instanceof Container) { ! elements.add((Container) current); } else if (current instanceof Surface) { surfaces.add((Surface) current); --- 70,77 ---- Collection<Edge> edges = new HashSet<Edge>(); Collection<Surface> surfaces = new HashSet<Surface>(); ! Collection<Space> elements = new HashSet<Space>(); for (Geometric current : geometrics) { ! if (current instanceof Space) { ! elements.add((Space) current); } else if (current instanceof Surface) { surfaces.add((Surface) current); *************** *** 119,123 **** * @return elements */ ! public Collection<Container> elements() { return elements; } --- 118,122 ---- * @return elements */ ! public Collection<Space> elements() { return elements; } *************** *** 146,157 **** } - private static HashMap map(Collection<? extends Entity> entities) { - HashMap map = new HashMap(); - for (Entity current : entities) { - map.put(current.getId(), current); - } - return map; - } - /** * @param owner Container --- 145,148 ---- *************** *** 294,299 **** public Mesh copy(Map map) { Mesh copy = copyGeometry(map); ! for (Container current : elements) { ! Container shallow = current.shallowCopy(); map.put(current, shallow); copy.elements().add(shallow); --- 285,290 ---- public Mesh copy(Map map) { Mesh copy = copyGeometry(map); ! for (Space current : elements) { ! Space shallow = current.shallowCopy(); map.put(current, shallow); copy.elements().add(shallow); *************** *** 316,328 **** } } ! for (Container current : elements) { ! Container container = (Container) map.get(current); ! Mesh mesh = current.mesh().copy(map); ! mesh.identify(container); ! container.setElements(map(mesh.elements)); ! container.setSurfaces(map(mesh.surfaces)); ! container.setEdges(map(mesh.edges)); ! container.setVertices(map(mesh.vertices)); ! container.setEmpty((Container) map.get(current.empty)); } return copy; --- 307,313 ---- } } ! for (Space current : elements) { ! Space to = (Space) map.get(current); ! current.copyInterior(map, to); } return copy; Index: Entity.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Entity.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Entity.java 19 Oct 2007 12:11:34 -0000 1.22 --- Entity.java 20 Dec 2007 14:19:55 -0000 1.23 *************** *** 11,16 **** --- 11,18 ---- import java.util.Collections; import java.util.Comparator; + import java.util.HashMap; import java.util.Iterator; import java.util.List; + import java.util.Map; import org.apache.log4j.Logger; *************** *** 86,89 **** --- 88,104 ---- Collections.sort(entities, comparator); } + + /** + * Returns a map of the specified entities + * @param entities collection of entities + * @return map binding ids to entities + */ + public static Map<Long, ? extends Entity> asMap(Collection<? extends Entity> entities) { + HashMap map = new HashMap(); + for (Entity current : entities) { + map.put(current.getId(), current); + } + return map; + } /** Index: Container.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Container.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Container.java 20 Dec 2007 10:24:18 -0000 1.9 --- Container.java 20 Dec 2007 14:19:55 -0000 1.10 *************** *** 1446,1450 **** */ public Mesh mesh() { ! Collection<Container> elements = (Collection) getElements(); Collection<Surface> surfaces = getSurfaces(); Collection<Edge> edges = getEdges(); --- 1446,1450 ---- */ public Mesh mesh() { ! Collection<Space> elements = (Collection) getElements(); Collection<Surface> surfaces = getSurfaces(); Collection<Edge> edges = getEdges(); *************** *** 1452,1454 **** --- 1452,1486 ---- return new Mesh(elements, surfaces, edges, vertices); } + /** + * {@inheritDoc} + */ + public Space shallowCopy() { + Container copy = new Container(); + copy.classification = classification; + copy.container = container; + copy.description = description; + copy.name = name; + copy.isNet = isNet; + copy.isUnion = isUnion; + copy.transparent = transparent; + copy.type = type; + return copy; + } + + /** + * + * @param map map + * @param to to + */ + public void copyInterior(Map map, Space to) { + Container container = (Container) to; + Mesh mesh = mesh().copy(map); + mesh.identify(container); + container.setElements((HashMap) Entity.asMap(mesh.elements())); + container.setSurfaces((HashMap) Entity.asMap(mesh.surfaces())); + container.setEdges((HashMap) Entity.asMap(mesh.edges())); + container.setVertices((HashMap) Entity.asMap(mesh.vertices())); + container.setEmpty((Container) map.get(empty)); + } + } |