[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool SpaceTool.java,1.10,1.11
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-30 15:20:30
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3097/src/net/sourceforge/bprocessor/gl/tool Modified Files: SpaceTool.java Log Message: Moved OffsetConstraint to model.constraints Index: SpaceTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SpaceTool.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SpaceTool.java 30 Jan 2006 14:48:44 -0000 1.10 --- SpaceTool.java 30 Jan 2006 15:20:18 -0000 1.11 *************** *** 18,22 **** import java.util.LinkedList; import java.util.List; - import java.util.Set; import javax.swing.JMenu; --- 18,21 ---- *************** *** 27,32 **** import net.sourceforge.bprocessor.gl.GLView; - import net.sourceforge.bprocessor.model.Constraint; - import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Modellor; --- 26,29 ---- *************** *** 35,38 **** --- 32,36 ---- import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.model.constraints.OffsetConstraint; /** *************** *** 113,191 **** } - - /** - * The OffsetConstraint maintains a distance between surfaces - * TODO move to model - */ - public class OffsetConstraint extends Constraint { - /** The offset */ - private double offset; - - /** - * Constructor for OffsetConstraint - * @param master The master - * @param slave The slave - */ - public OffsetConstraint(Surface master, Surface slave) { - super(master, slave); - updateOffset(); - } - - /** - * Update offset - */ - protected void updateOffset() { - Surface master = (Surface) getMaster(); - Surface slave = (Surface) getSlave(); - CoordinateSystem system = master.coordinateSystem(); - Vertex origin = system.origin(); - Vertex n = system.getN(); - n.scale(1 / n.length()); - Vertex v = slave.getFirstVertex(); - Vertex u = v.minus(origin); - double distance = n.dot(u); - this.offset = distance; - } - - /** - * Maintain offset - */ - protected void maintainOffset() { - Surface master = (Surface) getMaster(); - Surface slave = (Surface) getSlave(); - CoordinateSystem system = master.coordinateSystem(); - Vertex origin = system.origin(); - Vertex n = system.getN(); - n.scale(1 / n.length()); - Set vertices = new HashSet(); - - // List vertices = slave.getVertices(); - // vertices.remove(0); - collect(slave, vertices); - Iterator iter = vertices.iterator(); - while (iter.hasNext()) { - Vertex current = (Vertex) iter.next(); - Vertex p = system.translate(current); - p.setZ(offset); - p = system.unTranslate(p); - current.setX(p.getX()); - current.setY(p.getY()); - current.setZ(p.getZ()); - } - } - - /** - * Update - * @param entity The changed entity - */ - public void update(Object entity) { - if (entity == getSlave()) { - updateOffset(); - } else { - maintainOffset(); - } - } - } - /** * Add offset constraint to objects --- 111,114 ---- |