Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool FinalMoveTool.java, 1.17, 1.18
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-08-30 13:57:51
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3260/src/net/sourceforge/bprocessor/gl/tool Modified Files: FinalMoveTool.java Log Message: progress on the move tool Index: FinalMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/FinalMoveTool.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** FinalMoveTool.java 27 Aug 2007 13:39:05 -0000 1.17 --- FinalMoveTool.java 30 Aug 2007 13:57:46 -0000 1.18 *************** *** 18,21 **** --- 18,22 ---- import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.View; + import net.sourceforge.bprocessor.model.Direction; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; *************** *** 35,45 **** private Collection<Vertex> vertices; private Collection<Geometric> affected; - private Vertex from; private Vertex last; - private Vertex to; private boolean copy; private Mesh mesh; private Vertex direction; --- 36,46 ---- private Collection<Vertex> vertices; private Collection<Geometric> affected; private Vertex last; private boolean copy; private Mesh mesh; private Vertex direction; + private Map<Vertex, Vertex> originals; + private Map<Vertex, Direction> slide; *************** *** 55,60 **** private Map<Vertex, Vertex> computeMap(Collection<Vertex> vertices) { ! ! return null; } --- 56,110 ---- private Map<Vertex, Vertex> computeMap(Collection<Vertex> vertices) { ! if (vertices.size() > 0) { ! Space space = vertices.iterator().next().getOwner(); ! return space.directionMap(vertices); ! } else { ! return null; ! } ! } ! ! private Map<Vertex, Direction> computeDirectionMap(Collection<Vertex> vertices) { ! if (vertices.size() > 0) { ! Space space = vertices.iterator().next().getOwner(); ! Map<Vertex, Direction> slidemap = new HashMap(); ! Map<Vertex, Collection<Edge>> edgemap = space.edgeMap(vertices); ! System.out.println("-- map --"); ! for (Vertex current : vertices) { ! Collection<Edge> edges = edgemap.get(current); ! Direction direction; ! if (edges.size() == 0) { ! System.out.println(" free"); ! direction = new Direction(current.copy(), null); ! } else if (edges.size() == 1) { ! System.out.println(" constrained"); ! Edge edge = edges.iterator().next(); ! Vertex to = edge.otherVertex(current); ! Vertex v = to.minus(current); ! double length = v.length(); ! v.scale(1 / length); ! direction = new Direction(current.copy(), v, Double.NEGATIVE_INFINITY, length); ! } else { ! System.out.println(" bound"); ! direction = new Direction(current.copy(), null, 0, 0); ! } ! slidemap.put(current, direction); ! } ! return slidemap; ! } else { ! return null; ! } ! } ! ! private Map<Vertex, Direction> computeSlideMap(Collection<Vertex> vertices) { ! Map<Vertex, Vertex> edgemap = computeMap(vertices); ! if (edgemap != null) { ! Map<Vertex, Direction> slidemap = new HashMap(); ! for (Vertex current : vertices) { ! slidemap.put(current, new Direction(current.copy(), edgemap.get(current))); ! } ! return slidemap; ! } else { ! return null; ! } } *************** *** 69,76 **** } else { if (current != null) { - Edge edge = new Edge(from, to); - edge.setStrippled(true); Collection feedback = new LinkedList(); ! feedback.add(edge); feedback(feedback); makeTarget(current); --- 119,128 ---- } else { if (current != null) { Collection feedback = new LinkedList(); ! for (Vertex vertex : vertices) { ! Edge edge = new Edge(current.vertex(), vertex); ! edge.setStrippled(true); ! feedback.add(edge); ! } feedback(feedback); makeTarget(current); *************** *** 82,88 **** private void move() { current = current.copy(); ! to = current.vertex(); ! move(vertices, to.minus(last)); ! last = to; updateFeedback(); } --- 134,139 ---- private void move() { current = current.copy(); ! last = current.vertex(); ! move(vertices, current.vertex().minus(start.vertex())); updateFeedback(); } *************** *** 91,95 **** private void move(Collection<Vertex> vertices, Vertex delta) { for (Vertex current : vertices) { ! current.move(delta.getX(), delta.getY(), delta.getZ()); } } --- 142,164 ---- private void move(Collection<Vertex> vertices, Vertex delta) { for (Vertex current : vertices) { ! Vertex original = originals.get(current); ! current.set(original.add(delta)); ! if (slide != null) { ! Direction direction = slide.get(current); ! Vertex n = direction.getDirection(); ! if (n != null) { ! Vertex v = current.minus(original); ! double t = n.dot(v); ! if (t > direction.upper()) { ! t = direction.upper(); ! } ! if (t < direction.lower()) { ! t = direction.lower(); ! } ! Vertex u = n.copy(); ! u.scale(t); ! current.set(original.add(u)); ! } ! } } } *************** *** 170,178 **** vertices = Geometry.collect(geometrics); affected = getAffected(geometrics); current = findIntersection(e); start = current.copy(); ! from = current.vertex(); ! last = from; updateFeedback(); setTip(secondClickTip()); --- 239,251 ---- vertices = Geometry.collect(geometrics); + originals = new HashMap(); + for (Vertex current : vertices) { + originals.put(current, current.copy()); + } + slide = computeDirectionMap(vertices); affected = getAffected(geometrics); current = findIntersection(e); start = current.copy(); ! last = current.vertex(); updateFeedback(); setTip(secondClickTip()); *************** *** 232,237 **** public void cleanUp() { if (start != null) { ! current = start; ! move(); } super.cleanUp(); --- 305,312 ---- public void cleanUp() { if (start != null) { ! for (Vertex current : vertices) { ! Vertex original = originals.get(current); ! current.set(original); ! } } super.cleanUp(); *************** *** 244,247 **** --- 319,324 ---- affected = null; copy = false; + originals = null; + slide = null; } |