[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model CoordinateSystem.java, 1.45, 1.46
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-03-22 11:45:38
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28166/src/net/sourceforge/bprocessor/model Modified Files: CoordinateSystem.java Log Message: added a update call after setAttributes and moved some inner classes to the bottom of the file Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** CoordinateSystem.java 14 Mar 2007 10:22:13 -0000 1.45 --- CoordinateSystem.java 22 Mar 2007 11:45:31 -0000 1.46 *************** *** 536,539 **** --- 536,540 ---- onlyPlane(((Boolean)(((Attribute)attributes.get(17)).getValue())).booleanValue()); } + update(); } *************** *** 686,715 **** return list; } - /** - * Guide - */ - private class Guide extends Edge { - /** */ - private static final long serialVersionUID = 1L; - - /** - * Constructor - * @param from Vertex - * @param to Vertex - */ - public Guide(Vertex from, Vertex to) { - super(from, to); - setStrippled(true); - } - - /** - * Parent - * @return This line - */ - public Geometric parent() { - return CoordinateSystem.this; - } - } - /** --- 687,690 ---- *************** *** 726,729 **** --- 701,754 ---- return list; } + + /** + * make a copy of the coordinatsystem + * @return the copy + */ + public CoordinateSystem copy() { + CoordinateSystem n = new CoordinateSystem(); + n.setAttributes(this.getAttributes()); + return n; + } + + /** + * flip the coordinatesystem on its head; + */ + public void flip() { + Vertex tmp = i; + i = j; + j = tmp; + n.scale(-1); + } + + /** + * {@inheritDoc} + * + */ + public void update() { + Map<Relation, Map<Vertex, Vertex>> directions = new HashMap<Relation, Map<Vertex, Vertex>>(); + 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); + Vertex project = plane.intersection(vertex, vector, true); + vertex.set(project); + } + } + } /** *************** *** 768,819 **** } } ! /** ! * make a copy of the coordinatsystem ! * @return the copy */ ! public CoordinateSystem copy() { ! CoordinateSystem n = new CoordinateSystem(); ! n.setAttributes(this.getAttributes()); ! return n; ! } ! /** ! * flip the coordinatesystem on its head; ! */ ! public void flip() { ! Vertex tmp = i; ! i = j; ! j = tmp; ! n.scale(-1); } ! /** ! * {@inheritDoc} */ ! 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); ! Vertex project = plane.intersection(vertex, vector, true); ! vertex.set(project); ! } ! } } } --- 793,836 ---- } } ! /** ! * Guide */ ! private class Guide extends Edge { ! /** */ ! private static final long serialVersionUID = 1L; ! /** ! * Constructor ! * @param from Vertex ! * @param to Vertex ! */ ! public Guide(Vertex from, Vertex to) { ! super(from, to); ! setStrippled(true); ! } ! ! /** ! * Parent ! * @return This line ! */ ! public Geometric parent() { ! return CoordinateSystem.this; ! } } ! /** ! * rotate a coordinatesystem about a line ! * rotate all axis about 0,0,0 and the origin about line.origin ! * @param angle the angle to rotate ! * @param line the line to rotate about */ ! public void rotate(double angle, Line line) { ! Vertex dir = line.getDirection(); ! Geometry.rotate(angle, dir.getX(), dir.getY(), dir.getZ(), getOrigin(), line.getOrigin()); ! Vertex zero = new Vertex(0, 0, 0); ! Geometry.rotate(angle, dir.getX(), dir.getY(), dir.getZ(), getI(), zero); ! Geometry.rotate(angle, dir.getX(), dir.getY(), dir.getZ(), getJ(), zero); ! Geometry.rotate(angle, dir.getX(), dir.getY(), dir.getZ(), getN(), zero); } } |