Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Command.java, 1.30, 1.31
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-11-18 19:14:44
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23509/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: frame command Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Command.java 16 Nov 2007 14:26:29 -0000 1.30 --- Command.java 18 Nov 2007 19:14:40 -0000 1.31 *************** *** 668,677 **** Collection<Surface> sides = new LinkedList(); Surface top = s0.extrusion(d, sides); ! Space world = Project.getInstance().world(); ! world.insert(s0); ! for (Surface current : sides) { ! world.insert(current); } ! world.insert(top); } } --- 668,694 ---- Collection<Surface> sides = new LinkedList(); Surface top = s0.extrusion(d, sides); ! ! Space union = new Space("Union", Space.CONSTRUCTION, true); ! Collection<Surface> surfaces = new LinkedList(); ! surfaces.add(s0); ! surfaces.addAll(sides); ! 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); ! } ! ! Project.getInstance().getActiveSpace().add(union); } } *************** *** 825,829 **** ! private List<Vertex> offset(List<Vertex> vertices, Vertex normal, double distance) { List<Vertex> result = new LinkedList(); int n = vertices.size(); --- 842,846 ---- ! private static List<Vertex> offset(List<Vertex> vertices, Vertex normal, double distance) { List<Vertex> result = new LinkedList(); int n = vertices.size(); *************** *** 867,871 **** } ! private List<Vertex> vertices(List<Edge> edges) { List<Vertex> vertices = new ArrayList(); if (edges.size() > 1) { --- 884,888 ---- } ! private static List<Vertex> vertices(List<Edge> edges) { List<Vertex> vertices = new ArrayList(); if (edges.size() > 1) { *************** *** 948,952 **** } ! private List<Edge> offset(List<Edge> edges, double distance) { List<Edge> contour = new LinkedList(); { --- 965,975 ---- } ! /** ! * ! * @param edges edges ! * @param distance distance ! * @return list of edges ! */ ! public static List<Edge> offset(List<Edge> edges, double distance) { List<Edge> contour = new LinkedList(); { *************** *** 988,990 **** --- 1011,1089 ---- } } + + /** + * + */ + public static class Frame extends Command { + private Space net; + + /** + * Constructs a frame command + * @param net Space + */ + public Frame(Space net) { + this.net = net; + parameters.put("outside-frame", 1.0); + parameters.put("inside-frame", 1.0); + parameters.put("interior", 1.0); + parameters.put("depth", 1.0); + } + + /** {@inheritDoc} */ + @Override + public void evaluate() { + double outside = parameters.getDouble("outside-frame"); + double inside = parameters.getDouble("inside-frame"); + double delta = parameters.getDouble("interior"); + + + List<Surface> surfaces = new LinkedList(); + + { + HashMap map = new HashMap(); + for (Surface current : net.getSurfaces()) { + surfaces.add((Surface) current.copy(map)); + } + } + List<Edge> boundary = new LinkedList(); + + { + Inverse inv = new Inverse(surfaces); + + for (Edge current : inv.edges()) { + Collection<Surface> adjacant = inv.surfaces(current); + if (adjacant.size() == 1) { + boundary.add(current); + } + } + + boundary = Offset.order(boundary); + } + + { + List<Vertex> vertices = Offset.vertices(boundary); + Vertex normal = Surface.normalOf(boundary); + List<Vertex> offset = Offset.offset(vertices, normal, -inside + (delta / 2)); + for (int i = 0; i < vertices.size(); i++) { + Vertex original = vertices.get(i); + Vertex other = offset.get(i); + original.set(other); + } + } + + Space union = new Space("Union", Space.CONSTRUCTION, true); + List<Edge> offset = Offset.offset(boundary, inside + outside - (delta / 2)); + + Surface exterior = new Surface(offset); + List<Surface> interior = new LinkedList(); + for (Surface current : surfaces) { + interior.add(new Surface(Offset.offset(current.getEdges(), -delta / 2))); + } + union.insert(exterior); + for (Surface current : interior) { + union.insert(current); + } + net.getOwner().add(union); + } + } } |