[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.55, 1.56 Vertex.java, 1
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-09-05 11:01:48
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30459/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Vertex.java ClippingPlane.java Surface.java Line.java Space.java Geometric.java Point.java CoordinateSystem.java Constructor.java Log Message: Added canMove to all geometric objects that are supposed to given a direction check how much of is is leagal to move. Made vectorMove check the geometry for the possible move distance before moving. The move method in the movetools now return a vector that is the actual moved vector. When there are only one selected object then the object is moved otherwise the collection of affected vertices are. Index: Constructor.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Constructor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Constructor.java 11 Aug 2006 12:44:21 -0000 1.9 --- Constructor.java 5 Sep 2006 11:01:37 -0000 1.10 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.bprocessor.model; + import java.util.Collection; import java.util.LinkedList; import java.util.List; *************** *** 127,133 **** * @param z the movement in z */ ! public void move(double x, double y, double z) { ! getOrigin().add(new Vertex(x, y, z)); ! } /** --- 128,132 ---- * @param z the movement in z */ ! public abstract void move(double x, double y, double z); /** *************** *** 179,182 **** --- 178,191 ---- return "Handle{" + parent() + "}"; } + + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public void move(double x, double y, double z) { + parent().move(x, y, z); + } + + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + return parent().canMove(x, y, z, entities); + } } } Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** CoordinateSystem.java 14 Aug 2006 08:27:16 -0000 1.25 --- CoordinateSystem.java 5 Sep 2006 11:01:37 -0000 1.26 *************** *** 9,12 **** --- 9,13 ---- import java.util.ArrayList; + import java.util.Collection; import java.util.HashSet; import java.util.Iterator; *************** *** 76,79 **** --- 77,93 ---- } + /** + * @see net.sourceforge.bprocessor.model.Constructor#move(double, double, double) + */ + public void move(double x, double y, double z) { + getOrigin().move(x, y, z); + } + + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + // TODO Think it through + return new Vertex(x, y, z); + } + /** * normalize vectors Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** Surface.java 29 Aug 2006 10:05:11 -0000 1.107 --- Surface.java 5 Sep 2006 11:01:36 -0000 1.108 *************** *** 892,898 **** } } ! if (exterior != null) { if (!exterior.surrounds(this)) { //The inner surface has been moved out of its outer surface //this can not happen so here we move the inner surface back --- 892,899 ---- } } ! /* NOT THE JOB FOR SURFACE if (exterior != null) { if (!exterior.surrounds(this)) { + log.info("Did move the surface back"); //The inner surface has been moved out of its outer surface //this can not happen so here we move the inner surface back *************** *** 915,921 **** } } ! } } /** * Tests if a surface is a hole in this surface --- 916,934 ---- } } ! }*/ } + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + Vertex dir = new Vertex(x, y, z); + if (this.getExterior() != null) { + if (!entities.contains(this.getExterior())) { + // Restricted to be in plane of the exterior surface + dir = getExterior().plane().project(dir); + } + } + return dir; + } + /** * Tests if a surface is a hole in this surface *************** *** 933,936 **** --- 946,964 ---- } } + iter = hole.getEdges().iterator(); + while (iter.hasNext()) { + Edge current = (Edge) iter.next(); + Iterator inner = getEdges().iterator(); + while (inner.hasNext()) { + Edge e = (Edge) inner.next(); + Edge inter = e.intersection(current); + if (inter != null && inter.getLength() < 0.00001) { + boolean res = (current.coincides(inter.getFrom()) && e.coincides(inter.getFrom())); + if (res) { + return false; + } + } + } + } return true; } Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Edge.java 29 Aug 2006 10:05:11 -0000 1.55 --- Edge.java 5 Sep 2006 11:01:36 -0000 1.56 *************** *** 221,224 **** --- 221,230 ---- } + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + // TODO Think it through + return new Vertex(x, y, z); + } + /** * Find the intersection between this Edge and the Other. *************** *** 429,433 **** t = (q.getZ() - p0.getZ()) / r.getZ(); } ! if ((t > 0 && t < 1)) { r.scale(t); Vertex p = p0.add(r).minus(q); --- 435,439 ---- t = (q.getZ() - p0.getZ()) / r.getZ(); } ! if ((t >= 0 && t <= 1)) { r.scale(t); Vertex p = p0.add(r).minus(q); *************** *** 539,543 **** * Create a offset from a list of lines and a surface * PRECONDITION: all the edges have to be in the given surface and the edges ! * in the surface have to be counter clockwise drawn. * @param which The list of edges in inner that are going to be offset * @param inner The surface --- 545,550 ---- * Create a offset from a list of lines and a surface * PRECONDITION: all the edges have to be in the given surface and the edges ! * in the surface have to be counter clockwise drawn. If the edges are drawn clockwise ! * the offset will be negative outside and positive inside * @param which The list of edges in inner that are going to be offset * @param inner The surface Index: ClippingPlane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ClippingPlane.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ClippingPlane.java 21 Aug 2006 14:18:50 -0000 1.7 --- ClippingPlane.java 5 Sep 2006 11:01:36 -0000 1.8 *************** *** 281,283 **** --- 281,288 ---- center().move(x, y, z); } + + /** @see net.sourceforge.bprocessor.model.Geometric#canMove(double, double, double, Collection) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + return new Vertex(x, y, z).projectOnto(plane.normal()); + } } Index: Point.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Point.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Point.java 31 Jul 2006 11:25:51 -0000 1.7 --- Point.java 5 Sep 2006 11:01:37 -0000 1.8 *************** *** 8,11 **** --- 8,12 ---- import java.util.ArrayList; + import java.util.Collection; import java.util.HashSet; import java.util.List; *************** *** 31,34 **** --- 32,48 ---- super(); } + + /** + * @see net.sourceforge.bprocessor.model.Constructor#move(double, double, double) + */ + public void move(double x, double y, double z) { + getOrigin().move(x, y, z); + } + + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + // TODO Think it through + return new Vertex(x, y, z); + } /** Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** Space.java 5 Sep 2006 09:44:08 -0000 1.56 --- Space.java 5 Sep 2006 11:01:37 -0000 1.57 *************** *** 1699,1703 **** /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double)*/ public void move(double x, double y, double z) { ! Iterator iter = getVertices().iterator(); while (iter.hasNext()) { ((Vertex)iter.next()).move(x, y, z); --- 1699,1703 ---- /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double)*/ public void move(double x, double y, double z) { ! Iterator iter = collect().iterator(); while (iter.hasNext()) { ((Vertex)iter.next()).move(x, y, z); *************** *** 1705,1708 **** --- 1705,1714 ---- } + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + // TODO Think it through + return new Vertex(x, y, z); + } + /** * Perform a consistency check of the geometry. Index: Line.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Line.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Line.java 29 Aug 2006 09:30:57 -0000 1.21 --- Line.java 5 Sep 2006 11:01:37 -0000 1.22 *************** *** 8,11 **** --- 8,12 ---- import java.util.ArrayList; + import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; *************** *** 30,33 **** --- 31,37 ---- private Vertex dir; + /** The edge the center of this Line is to be moved on */ + private Edge constraint; + /** * Empty constructor for persistence only *************** *** 79,82 **** --- 83,99 ---- this.dir = dir; } + + /** + * Constructor of the Line with orgin and three angles + * @param origin The origin + * @param dir The vector of direction + * @param constraint The bounded placements + * @param active If the constructor is active + * @param editable If the constructor is editable + */ + public Line(Vertex origin, Vertex dir, Edge constraint, boolean active, boolean editable) { + this(origin, dir, active, editable); + this.constraint = constraint; + } /** *************** *** 382,384 **** --- 399,420 ---- return "L-" + getId(); } + + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public void move(double x, double y, double z) { + Vertex move = new Vertex(x, y, z); + if (constraint != null) { + move = move.projectOnto(constraint.getDirection()); + if (!constraint.coincides(getOrigin().add(move))) { + // If the movement is outside the constraint don't move the edge + move = new Vertex(0, 0, 0); + } + } + getOrigin().move(move.getX(), move.getY(), move.getZ()); + } + + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + // TODO Think it through + return new Vertex(x, y, z); + } } Index: Geometric.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometric.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Geometric.java 21 Aug 2006 14:18:50 -0000 1.10 --- Geometric.java 5 Sep 2006 11:01:37 -0000 1.11 *************** *** 8,11 **** --- 8,12 ---- package net.sourceforge.bprocessor.model; + import java.util.Collection; import java.util.Set; *************** *** 83,85 **** --- 84,96 ---- */ public abstract void move(double x, double y, double z); + + /** + * Check how much of the give direction this object can move + * @param x the x distance + * @param y the y distance + * @param z the z distance + * @param entities The other entities that are to be moved as well + * @return The possible distance vector this object can move + */ + public abstract Vertex canMove(double x, double y, double z, Collection entities); } Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Vertex.java 29 Aug 2006 10:05:11 -0000 1.44 --- Vertex.java 5 Sep 2006 11:01:36 -0000 1.45 *************** *** 335,339 **** * @param dx The x distance * @param dy The y distance ! * @param dz The z distance */ public void move(double dx, double dy, double dz) { --- 335,339 ---- * @param dx The x distance * @param dy The y distance ! * @param dz The z distance. */ public void move(double dx, double dy, double dz) { *************** *** 477,479 **** --- 477,485 ---- return null; } + + /** @see net.sourceforge.bprocessor.model.Geometric#move(double, double, double) */ + public Vertex canMove(double x, double y, double z, Collection entities) { + // TODO Think it through + return new Vertex(x, y, z); + } } |