[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Space.java, 1.123, 1.124 Attribute.j
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-03-12 08:32:55
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9267/src/net/sourceforge/bprocessor/model Modified Files: Space.java Attribute.java Relation.java CoordinateSystem.java Log Message: Relation demo ready Index: Attribute.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Attribute.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Attribute.java 9 Mar 2007 12:59:49 -0000 1.17 --- Attribute.java 12 Mar 2007 08:32:47 -0000 1.18 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.bprocessor.model; + import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; *************** *** 191,194 **** --- 192,201 ---- } } + // FIXME: the above update should only update relations + // that depends on this attribute. + Collection<CoordinateSystem> systems = Project.getInstance().world().getCoordinateSystems(); + for (CoordinateSystem current : systems) { + current.update(); + } Project.getInstance().changed(this); } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.123 retrieving revision 1.124 diff -C2 -d -r1.123 -r1.124 *** Space.java 7 Mar 2007 09:47:13 -0000 1.123 --- Space.java 12 Mar 2007 08:32:47 -0000 1.124 *************** *** 2701,2703 **** --- 2701,2723 ---- } + /** + * Returns a direction-map for the given collection a vertices. + * @param vertices Collection of vertices for which to compute a direction-map + * @return A direction-map for the collection of vertices. + */ + public Map<Vertex, Vertex> directionMap(Collection<Vertex> vertices) { + Map <Vertex, Collection<Edge>> binding = edgeMap(vertices); + Map<Vertex, Vertex> map = new HashMap(); + for (Vertex vertex : vertices) { + Collection<Edge> edges = binding.get(vertex); + if (edges.size() > 0) { + Edge edge = edges.iterator().next(); + Vertex direction = edge.getDirection(); + direction.normalize(); + map.put(vertex, direction); + } + } + return map; + } + } Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** CoordinateSystem.java 8 Mar 2007 10:05:19 -0000 1.40 --- CoordinateSystem.java 12 Mar 2007 08:32:47 -0000 1.41 *************** *** 10,13 **** --- 10,14 ---- import java.util.ArrayList; import java.util.Collection; + import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; *************** *** 710,726 **** */ public void update() { for (Relation relation : relations) { - double distance = relation.evaluate(); Geometric geometric = relation.geometric(); Space space = geometric.getOwner(); Collection<Vertex> vertices = geometric.collect(); ! Map<Vertex, Collection<Edge>> map = space.edgeMap(vertices); for (Vertex vertex : vertices) { ! Vertex vector = getN(); ! Collection<Edge> binding = map.get(vertex); ! if (!binding.isEmpty()) { ! Edge bind = binding.iterator().next(); ! vector = bind.getDirection(); ! vector.normalize(); } Plane plane = plane(distance); --- 711,731 ---- */ public void update() { + Map<Relation, Map<Vertex, Vertex>> directions = new HashMap(); for (Relation relation : relations) { Geometric geometric = relation.geometric(); Space space = geometric.getOwner(); Collection<Vertex> vertices = geometric.collect(); ! Map<Vertex, Vertex> map = space.directionMap(vertices); ! directions.put(relation, map); ! } ! for (Relation relation : relations) { ! double distance = relation.evaluate(); ! Geometric geometric = relation.geometric(); ! Collection<Vertex> vertices = geometric.collect(); ! Map<Vertex, Vertex> map = directions.get(relation); for (Vertex vertex : vertices) { ! Vertex vector = map.get(vertex); ! if (vector == null) { ! vector = getN(); } Plane plane = plane(distance); Index: Relation.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Relation.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Relation.java 7 Mar 2007 09:47:13 -0000 1.5 --- Relation.java 12 Mar 2007 08:32:47 -0000 1.6 *************** *** 10,13 **** --- 10,14 ---- import java.io.Reader; import java.io.StringReader; + import java.util.Collection; import java.util.HashMap; import java.util.Iterator; *************** *** 105,108 **** --- 106,115 ---- } } + //FIXME: the above update should only update relations + // that contains on this relations. + Collection<CoordinateSystem> systems = Project.getInstance().world().getCoordinateSystems(); + for (CoordinateSystem current : systems) { + current.update(); + } } |