[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Command.java, 1.35, 1.36
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-11-22 15:36:41
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19874/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: Command to show normals on surfaces in a space Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Command.java 22 Nov 2007 14:26:48 -0000 1.35 --- Command.java 22 Nov 2007 15:36:43 -0000 1.36 *************** *** 51,55 **** } ! protected List list(Object ...objects) { List result = new LinkedList(); for (Object object : objects) { --- 51,60 ---- } ! /** ! * Creates list of the arguments ! * @param objects objects ! * @return list ! */ ! public static List list(Object ...objects) { List result = new LinkedList(); for (Object object : objects) { *************** *** 626,634 **** } /** * * */ ! public static class Cube extends Command { /** * --- 631,748 ---- } + /** * * */ ! public abstract static class Shape extends Command { ! /** ! * Adds a collection surfaces to a space. ! * @param owner Space ! * @param surfaces surface ! */ ! public static void addTo(Space owner, Collection<Surface> surfaces) { ! Collection<Edge> edges = Surface.edges(surfaces); ! Collection<Vertex> vertices = Edge.vertices(edges); ! ! for (Vertex current : vertices) { ! owner.add(current); ! } ! ! for (Edge current : edges) { ! owner.add(current); ! } ! ! for (Surface current : surfaces) { ! owner.add(current); ! } ! } ! } ! ! /** ! * Pyramid ! */ ! public static class Pyramid extends Shape { ! ! /** ! * Create a pyramid ! * @param w width ! * @param h height ! * @param d depth ! * @return union ! */ ! public static Space pyramid(double w, double h, double d) { ! double x = -w / 2; ! double y = -h / 2; ! double z = 0; ! Vertex v0 = new Vertex(x, y, z); ! Vertex v1 = new Vertex(x + w, y, z); ! Vertex v2 = new Vertex(x + w, y + h, z); ! Vertex v3 = new Vertex(x, y + h, z); ! ! Edge e0 = new Edge(v0, v1); ! Edge e1 = new Edge(v1, v2); ! Edge e2 = new Edge(v2, v3); ! Edge e3 = new Edge(v3, v0); ! ! Surface s0 = new Surface(list(e0, e1, e2, e3)); ! ! Vertex top = new Vertex(0, 0, d); ! ! Edge l0 = new Edge(v0, top); ! Edge l1 = new Edge(v1, top); ! Edge l2 = new Edge(v2, top); ! Edge l3 = new Edge(v3, top); ! ! Surface side0 = new Surface(list(e0, l0, l1)); ! Surface side1 = new Surface(list(e1, l1, l2)); ! Surface side2 = new Surface(list(e2, l2, l3)); ! Surface side3 = new Surface(list(e3, l3, l0)); ! ! Space union = new Space("Pyramid", Space.CONSTRUCTION, true); ! ! addTo(union, list(s0, side0, side1, side2, side3)); ! ! return union; ! } ! ! /** ! * Constructs the Pyramid command ! * ! */ ! public Pyramid() { ! parameters.put("width", 1.0); ! parameters.put("height", 1.0); ! parameters.put("depth", 1.0); ! } ! ! /** {@inheritDoc}} */ ! @Override ! public String getGeneralName() { ! return "Create Pyramid"; ! } ! ! /** {@inheritDoc} */ ! @Override ! public void evaluate() { ! double w = parameters.getDouble("width"); ! double h = parameters.getDouble("height"); ! double d = parameters.getDouble("depth"); ! Space union = pyramid(w, h, d); ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! ! for (Vertex current : union.getVertices()) { ! current.set(system.unTranslate(current)); ! } ! ! Project.getInstance().getActiveSpace().add(union); ! } ! } ! ! ! /** ! * Cube ! */ ! public static class Cube extends Shape { /** * *************** *** 655,662 **** double y = -h / 2; double z = -d / 2; ! Vertex v0 = system.unTranslate(new Vertex(x, y, z)); ! Vertex v1 = system.unTranslate(new Vertex(x + w, y, z)); ! Vertex v2 = system.unTranslate(new Vertex(x + w, y + h, z)); ! Vertex v3 = system.unTranslate(new Vertex(x, y + h, z)); Edge e0 = new Edge(v0, v1); --- 769,776 ---- double y = -h / 2; double z = -d / 2; ! Vertex v0 = new Vertex(x, y, z); ! Vertex v1 = new Vertex(x + w, y, z); ! Vertex v2 = new Vertex(x + w, y + h, z); ! Vertex v3 = new Vertex(x, y + h, z); Edge e0 = new Edge(v0, v1); *************** *** 669,673 **** Surface top = s0.extrusion(d, sides); ! Space union = new Space("Union", Space.CONSTRUCTION, true); Collection<Surface> surfaces = new LinkedList(); surfaces.add(s0); --- 783,787 ---- Surface top = s0.extrusion(d, sides); ! Space union = new Space("Cube", Space.CONSTRUCTION, true); Collection<Surface> surfaces = new LinkedList(); surfaces.add(s0); *************** *** 675,691 **** surfaces.add(top); ! Collection<Edge> edges = Surface.edges(surfaces); ! Collection<Vertex> vertices = Edge.vertices(edges); ! ! for (Vertex current : vertices) { ! union.add(current); ! } ! ! for (Edge current : edges) { ! union.add(current); ! } ! for (Surface current : surfaces) { ! union.add(current); } --- 789,797 ---- surfaces.add(top); ! ! addTo(union, surfaces); ! for (Vertex current : union.getVertices()) { ! current.set(system.unTranslate(current)); } |