[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Command.java, 1.95, 1.96 Project.jav
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2010-09-06 13:08:45
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9074/src/net/sourceforge/bprocessor/model Modified Files: Command.java Project.java Log Message: Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** Command.java 17 Jul 2010 21:19:32 -0000 1.95 --- Command.java 6 Sep 2010 13:08:36 -0000 1.96 *************** *** 18,21 **** --- 18,23 ---- import java.util.Set; + import net.sourceforge.bprocessor.model.plugin.NetCommand; + /** * Command *************** *** 23,26 **** --- 25,56 ---- public abstract class Command extends Entity implements Parametric { + private static List<Class<? extends Command>> commands; + + static { + commands = new LinkedList(); + } + + public static void register(Class<? extends Command> clarse) { + commands.add(clarse); + System.out.println("command: " + clarse.getSimpleName()); + } + + public static List<Class<? extends Command>> getCommands() { + return commands; + } + + public static Space invoke(Class<? extends Command> clarse) throws Exception { + Space union = Item.createUnion(clarse.getSimpleName()); + Space net = Space.createNet("Construction Geometry"); + union.add(net); + Command command = clarse.newInstance(); + if (command instanceof NetCommand) { + NetCommand nc = (NetCommand) command; + nc.initialize(net); + } + union.add(command); + return union; + } + /** * *************** *** 1801,2000 **** } - /** - * - */ - public static class Frame extends Command { - /** - * Constructs a frame command - * @param net Space - */ - public Frame(Space net) { - // Space net is the B-Net which is part of the construction space, it is saved as the parameter "net" - parameters.put("net", net); - parameters.put("frame-width", 0.035); - parameters.put("interior-width", 0.035); - parameters.put("depth", 0.07); - - parameters.put("frame name", "Frame"); - parameters.put("exterior name", "Exterior"); - parameters.put("hole name", "Hole"); - } - - /** - * {@inheritDoc} - */ - public String title() { - // this is the title shown on top of the parameters section - return "Frame Net"; - } - - private List<Edge> simplify(List<Edge> edges) { - // what exactly do you simplify here and why? - if (edges.size() > 3) { - List<Edge> result = new LinkedList(); - List<Vertex> vertices = Offset.vertices(edges); - LinkedList<Vertex> live = new LinkedList(); - { - int n = vertices.size(); - Vertex previous = vertices.get(n - 1); - Vertex current = vertices.get(0); - Vertex next = null; - for (int i = 0; i < n; i++) { - next = vertices.get((i + 1) % n); // the reuslt is always i+1, only if i is already the last edge in the list, the operation will return 0 - Vertex u = current.minus(previous); - Vertex v = next.minus(current); - Vertex cross = u.cross(v); - if (!cross.isZero()) { //this excludes parallel vectors and vectors of length 0 - live.add(current); - } - previous = current; - current = next; - } - } - Vertex previous = live.getLast(); - for (Vertex current : live) { - result.add(new Edge(previous, current)); - previous = current; - } - return result; - } else { - return edges; - } - } - - - /** {@inheritDoc} */ - @Override - public void evaluate() { - Space net = (Space) parameters.get("net"); - double inside = parameters.getDouble("frame-width"); - double delta = parameters.getDouble("interior-width"); - double depth = parameters.getDouble("depth"); - String frameName = (String) parameters.get("frame name"); - String exteriorName = (String) parameters.get("exterior name"); - String holeName = (String) parameters.get("hole name"); - List<Surface> surfaces = new LinkedList(); - - { - HashMap map = new HashMap(); - for (Surface current : net.getSurfaces()) { - surfaces.add((Surface) current.copy(map)); //what happens here? - } - } - List<Edge> boundary = new LinkedList(); - - { - Inverse inv = new Inverse(surfaces); // inverse? - - for (Edge current : inv.edges()) { - Collection<Surface> adjacant = inv.surfaces(current); - if (adjacant.size() == 1) { // if an edge only is adjacent to 1 surface it is a border edge - boundary.add(current); - } - } - - boundary = Offset.order(boundary); //order? does offset basically create a copy here? - } - - Offset.offsetIt(boundary, -inside + (delta / 2)); - - Space union = (Space) net.getOwner().find("Frame"); //check if the frame is created or redrawn... - - if (union == null) { - union = Item.createUnion("Frame"); - net.getOwner().add(union); - } else { - union.clear(); - } - - Collection<Surface> inserted = new LinkedList(); - - List<Edge> offset = Offset.offset(boundary, inside - (delta / 2)); //offset the boundary to the inside by the frame width minus half the interior width - Surface exterior = new Surface(simplify(offset)); - inserted.add(exterior); - //does this mean that the boundary edges are now basically moved inside and the next step is to move all edges inside? - - List<Surface> interior = new LinkedList(); - for (Surface current : surfaces) { - List<Edge> curve = Offset.offset(current.getEdges(), -delta / 2); //offset all surfaces by half the interior width - interior.add(new Surface(simplify(curve))); - } - inserted.addAll(interior); - - for (Surface current : interior) { - exterior.addHole(current); - } - - - Set<Surface> tops = new HashSet(); - - if (depth != 0) { - Collection<Surface> sides = new LinkedList(); - Surface top = exterior.extrusionall(depth, sides, tops); - inserted.addAll(sides); - inserted.addAll(tops); - inserted.add(top); - } - - Shape.addSurfacesTo(union, inserted); //add geometry to the space - - { - Space ext = Item.createFunctionalSpace(exteriorName); - Space frame = Item.createConstructionSpace(frameName); - // ?????????????? What happens here? Do you assign the surface sides to the adjacent spaces? These are named in the paramters, right? - if (depth > 0) { - exterior.assignBack(ext, true); - exterior.assignFront(frame, true); - } else { - exterior.assignFront(ext, true); - exterior.assignBack(frame, true); - } - union.add(ext); - union.add(frame); - Vertex n1 = exterior.normal(); - int i = 0; - for (Surface current : interior) { - i++; - Vertex n2 = current.normal(); - double sign; - if (n1.dot(n2) < 0) { - //what does the dot product of two vectors tell me? - sign = -depth; - } else { - sign = depth; - } - Space hole = Item.createFunctionalSpace(holeName + " " + i); - if (sign > 0) { - current.assignFront(hole, true); - current.setBackDomain(ext); - } else { - current.assignBack(hole, true); - current.setFrontDomain(ext); - } - for (Surface s : tops) { - if (s.getBackDomain().isVoid()) { - s.setBackDomain(ext); - } - if (s.getFrontDomain().isVoid()) { - s.setFrontDomain(ext); - } - } - for (Surface s : hole.getEnvelope()) { - if (s.getBackDomain().isVoid()) { - s.setBackDomain(frame); - } - if (s.getFrontDomain().isVoid()) { - s.setFrontDomain(frame); - } - } - - union.add(hole); - } - } - } - } - - - /** new command start ........................................................................................ * --- 1831,1834 ---- Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.196 retrieving revision 1.197 diff -C2 -d -r1.196 -r1.197 *** Project.java 31 Aug 2010 13:48:03 -0000 1.196 --- Project.java 6 Sep 2010 13:08:36 -0000 1.197 *************** *** 31,34 **** --- 31,35 ---- import javax.swing.SwingUtilities; + import net.sourceforge.bprocessor.model.plugin.FacadePackage; import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; import net.sourceforge.bprocessor.model.sense.core.Target; *************** *** 281,284 **** --- 282,286 ---- staticObservers = new LinkedList(); reset(); + new FacadePackage(); } |