Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Surface.java, 1.140, 1.141 Line.java
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-03-13 15:21:41
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12205/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Line.java Point.java CoordinateSystem.java Constructor.java Log Message: Refactored code related to relations Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.140 retrieving revision 1.141 diff -C2 -d -r1.140 -r1.141 *** Surface.java 12 Mar 2007 15:58:01 -0000 1.140 --- Surface.java 13 Mar 2007 15:21:23 -0000 1.141 *************** *** 1530,1534 **** if (j != null) { j.scale(1 / j.length()); ! return new CoordinateSystem(i, j, n, origin); } } --- 1530,1534 ---- if (j != null) { j.scale(1 / j.length()); ! return new CoordinateSystem(i, j, n, origin.copy()); } } Index: Point.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Point.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Point.java 2 Jan 2007 17:48:58 -0000 1.14 --- Point.java 13 Mar 2007 15:21:24 -0000 1.15 *************** *** 36,47 **** return new Vertex(x, y, z); } - - /** - * Return the center for the entity - * @return The center as a vertex - */ - public Vertex center() { - return getOrigin(); - } /** --- 36,39 ---- Index: Constructor.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Constructor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Constructor.java 4 Mar 2007 23:14:45 -0000 1.18 --- Constructor.java 13 Mar 2007 15:21:24 -0000 1.19 *************** *** 115,119 **** /** {@inheritDoc} */ ! public abstract Vertex center(); /** {@inheritDoc} */ --- 115,122 ---- /** {@inheritDoc} */ ! @Override ! public Vertex center() { ! return origin; ! } /** {@inheritDoc} */ Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** CoordinateSystem.java 13 Mar 2007 09:49:05 -0000 1.43 --- CoordinateSystem.java 13 Mar 2007 15:21:24 -0000 1.44 *************** *** 48,71 **** if (geometrics.size() > 0) { Geometric leader = geometrics.iterator().next(); ! if (leader instanceof Surface) { ! Surface surface = (Surface) leader; ! CoordinateSystem system = surface.coordinateSystem(); ! system.setOrigin(system.getOrigin().copy()); ! for (Geometric geometric : geometrics) { ! if (geometric instanceof Surface) { ! Surface current = (Surface) geometric; ! Vertex origin = current.getFirstVertex(); ! double distance = system.plane().distance(origin); ! Relation relation = new Relation(current, String.valueOf(distance)); ! system.add(relation); ! } ! } ! Project.getInstance().world().add(system); ! Project.getInstance().changed(Project.getInstance().world()); } } } /** * Empty constructor for persistence only */ --- 48,83 ---- if (geometrics.size() > 0) { Geometric leader = geometrics.iterator().next(); ! CoordinateSystem system = systemFor(leader); ! for (Geometric geometric : geometrics) { ! system.relate(geometric); } + Project.getInstance().world().add(system); + Project.getInstance().changed(Project.getInstance().world()); + } + } + + /** + * Returns a CoordinateSystem for the given geometric object. + * @param geometric The geometric object to return a CoordinateSystem for + * @return CoordinateSystem for the given geometric object. + */ + public static CoordinateSystem systemFor(Geometric geometric) { + if (geometric instanceof Surface) { + return systemFor((Surface) geometric); + } else { + return new CoordinateSystem(geometric.center().copy()); } } /** + * Returns a CoordinateSystem for the given surface. + * @param surface The surface to return a CoordinateSystem for. + * @return A CoordinateSystem for the given surface. + */ + public static CoordinateSystem systemFor(Surface surface) { + return surface.coordinateSystem(); + } + + /** * Empty constructor for persistence only */ *************** *** 130,133 **** --- 142,169 ---- } + /** + * Relate the geometric to this CoordinateSystem. + * @param geometric Geometric object to relate to this CoordinateSystem + */ + public void relate(Geometric geometric) { + if (geometric instanceof Surface) { + relate((Surface) geometric); + } else { + + } + } + + /** + * Relate a surface to this CoordinateSystem + * @param surface Surface to relate to this CoordinateSystem + */ + public void relate(Surface surface) { + Vertex origin = surface.getFirstVertex(); + double distance = plane().distance(origin); + Relation relation = new Relation(surface, String.valueOf(distance)); + add(relation); + } + + /** {@inheritDoc} */ public Vertex canMove(double x, double y, double z, Collection entities) { *************** *** 423,431 **** /** {@inheritDoc} */ - public Vertex center() { - return getOrigin(); - } - - /** {@inheritDoc} */ public void delete() { getOwner().remove(this); --- 459,462 ---- Index: Line.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Line.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Line.java 2 Jan 2007 17:48:58 -0000 1.30 --- Line.java 13 Mar 2007 15:21:24 -0000 1.31 *************** *** 104,115 **** /** - * Return the center for the entity - * @return The center as a vertex - */ - public Vertex center() { - return getOrigin(); - } - - /** * Delete the entity from the model */ --- 104,107 ---- |