Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29116/src/net/sourceforge/bprocessor/model
Modified Files:
Command.java
Log Message:
controlled option added
Index: Command.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** Command.java 28 Nov 2007 21:25:41 -0000 1.43
--- Command.java 28 Nov 2007 22:37:08 -0000 1.44
***************
*** 142,145 ****
--- 142,146 ----
this.surface = surface;
parameters.put("distance", 1.0);
+ parameters.put("controlled", true);
}
***************
*** 155,166 ****
public void evaluate() {
double distance = parameters.getDouble("distance");
Space owner = surface.getOwner();
HashMap map = new HashMap();
Surface copy = (Surface) surface.copy(map);
Vertex normal = surface.normal();
! Vertex direction = normal.scale(distance);
! for (Vertex current : copy.getVertices()) {
! current.set(current.add(direction));
}
Geometry.insertEdges(copy.getEdges());
}
--- 156,203 ----
public void evaluate() {
double distance = parameters.getDouble("distance");
+ boolean controlled = parameters.getBoolean("controlled");
Space owner = surface.getOwner();
HashMap map = new HashMap();
Surface copy = (Surface) surface.copy(map);
Vertex normal = surface.normal();
!
! if (controlled) {
! List<Vertex> vertices = surface.getVertices();
! Map<Vertex, Collection<Edge>> edgemap = owner.edgeMap(vertices);
! Map<Vertex, Vertex> directions = new HashMap();
! for (Vertex current : vertices) {
! Collection<Edge> edges = edgemap.get(current);
! Collection<Edge> candidates = new LinkedList();
! for (Edge edge : edges) {
! Vertex other = edge.otherVertex(current);
! Vertex direction = other.minus(current);
! double dot = direction.dot(normal);
! if (Math.abs(dot) > 0.0000001) {
! candidates.add(edge);
! }
! }
! if (candidates.size() == 1) {
! Edge edge = candidates.iterator().next();
! Vertex other = edge.otherVertex(current);
! Vertex direction = other.minus(current);
! directions.put(current, direction);
! } else {
! directions.put(current, normal);
! }
! }
! for (Vertex original : vertices) {
! Vertex direction = directions.get(original);
! Vertex current = (Vertex) map.get(original);
! double factor = direction.dot(normal);
! double t = distance / factor;
! current.set(current.add(direction.scale(t)));
! }
! } else {
! Vertex direction = normal.scale(distance);
! for (Vertex current : copy.getVertices()) {
! current.set(current.add(direction));
! }
}
+
Geometry.insertEdges(copy.getEdges());
}
|