[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool FinalMoveTool.java, 1.24, 1.25
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-09-17 13:58:52
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14296/src/net/sourceforge/bprocessor/gl/tool Modified Files: FinalMoveTool.java Log Message: Progress on move tool: plane relations are now maintained Index: FinalMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/FinalMoveTool.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** FinalMoveTool.java 11 Sep 2007 11:00:05 -0000 1.24 --- FinalMoveTool.java 17 Sep 2007 13:58:40 -0000 1.25 *************** *** 80,88 **** * */ ! public class SystemRelation { private CoordinateSystem system; private Collection<Vertex> vertices; /** * Constructor * @param system CoordinateSystem --- 80,101 ---- * */ ! public static class SystemRelation { ! private Vertex original; private CoordinateSystem system; private Collection<Vertex> vertices; /** + * Returns a system relation for the specified surface + * @param surface Surface to create system relation for + * @return a system relation for the specified surface + */ + public static SystemRelation relationFor(Surface surface) { + Collection<Vertex> vertices = surface.collect(); + CoordinateSystem system = surface.coordinateSystem(); + SystemRelation relation = new SystemRelation(system, vertices); + return relation; + } + + /** * Constructor * @param system CoordinateSystem *************** *** 92,95 **** --- 105,148 ---- this.system = system; this.vertices = vertices; + this.original = system.getOrigin().copy(); + } + + /** + * Returns the origin of this relation + * @return the origin + */ + public Vertex origin() { + return system.getOrigin(); + } + + /** + * Returns a collection of the vertices in this system relation + * @return a collection of vertices in this system relation + */ + public Collection<Vertex> collect() { + return vertices; + } + + /** + * Move vertices so the stay on the plane of this system relation + * while sliding on the direction given by the direction map + * @param delta How much to move + * @param directions Direction map + * @param originals Originals positions + */ + public void slide(Vertex delta, Map<Vertex, Direction> directions, + Map<Vertex, Vertex> originals) { + system.setOrigin(original.add(delta)); + for (Vertex current : vertices) { + Direction direction = directions.get(current); + Vertex original = originals.get(current); + Vertex vector = direction.getDirection(); + if (vector == null) { + current.set(original.add(delta)); + } else { + Vertex to = system.slide(original, vector); + current.set(to); + } + } } } *************** *** 141,144 **** --- 194,200 ---- private Map<Vertex, Vertex> originals; private Map<Vertex, Direction> slide; + private Collection<SystemRelation> relations; + private Map<SystemRelation, Vertex> origins; + private Collection<Vertex> free; private void computePlanes(Collection<Vertex> vertices) { *************** *** 159,162 **** --- 215,236 ---- } } + relations = new LinkedList(); + for (Surface current : surfaces) { + SystemRelation relation = SystemRelation.relationFor(current); + relations.add(relation); + } + origins = new HashMap(); + mark.clear(); + for (SystemRelation relation : relations) { + mark.addAll(relation.collect()); + origins.put(relation, relation.origin().copy()); + } + free = new LinkedList(); + for (Vertex current : vertices) { + if (!mark.contains(current)) { + free.add(current); + } + } + System.out.println("free = " + free); } } *************** *** 208,212 **** */ public void move(Vertex delta) { ! for (Vertex current : vertices) { Vertex original = originals.get(current); current.set(original.add(delta)); --- 282,286 ---- */ public void move(Vertex delta) { ! for (Vertex current : free) { Vertex original = originals.get(current); current.set(original.add(delta)); *************** *** 229,232 **** --- 303,309 ---- } } + for (SystemRelation current : relations) { + current.slide(delta, slide, originals); + } } |