[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Command.java, 1.37, 1.38
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-11-24 09:01:41
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11062/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: Layer command in progress Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Command.java 23 Nov 2007 08:34:05 -0000 1.37 --- Command.java 24 Nov 2007 09:01:37 -0000 1.38 *************** *** 1108,1111 **** --- 1108,1128 ---- } + + /** + * Offset the boundary curve + * @param boundary connected list of edges to offset + * @param distance distance of offset + */ + public static void offsetIt(List<Edge> boundary, double distance) { + List<Vertex> vertices = vertices(boundary); + Vertex normal = Surface.normalOf(boundary); + List<Vertex> offset = Offset.offset(vertices, normal, distance); + for (int i = 0; i < vertices.size(); i++) { + Vertex original = vertices.get(i); + Vertex other = offset.get(i); + original.set(other); + } + } + /** {@inheritDoc} */ @Override *************** *** 1169,1182 **** } ! { ! 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("Frame", Space.CONSTRUCTION, true); --- 1186,1190 ---- } ! Offset.offsetIt(boundary, -inside + (delta / 2)); Space union = new Space("Frame", Space.CONSTRUCTION, true); *************** *** 1221,1224 **** --- 1229,1266 ---- private Space net; + private static class Prism { + protected Surface top; + protected Surface bottom; + protected List<Surface> sides; + + + public Prism (Surface top, Surface bottom, List<Surface> sides) { + this.top = top; + this.bottom = bottom; + this.sides = sides; + } + + public Prism offset(double distance) { + HashMap map = new HashMap(); + Surface t = (Surface) top.copy(map); + Surface b = (Surface) bottom.copy(map); + List<Surface> s = new LinkedList(); + for (Surface current : sides) { + s.add((Surface) current.copy(map)); + } + Offset.offsetIt(t.getEdges(), distance); + Offset.offsetIt(b.getEdges(), distance); + return new Prism(t, b, s); + } + + public Collection<Surface> surfaces() { + Collection<Surface> surfaces = new LinkedList(); + surfaces.add(top); + surfaces.add(bottom); + surfaces.addAll(sides); + return surfaces; + } + } + /** * Constructs a frame command *************** *** 1250,1253 **** --- 1292,1296 ---- Space floor = find((String) parameters.get("bottom")); Space exterior = find((String) parameters.get("side")); + double distance = parameters.getDouble("offset"); Surface top = null; *************** *** 1270,1274 **** } } ! Selection.primary().set((List) sides); } --- 1313,1341 ---- } } ! ! Prism p0 = new Prism(top, bottom, sides); ! ! List<Prism> prisms = new LinkedList(); ! { ! Prism current = p0.offset(0); ! prisms.add(current); ! for (int i = 0; i < 3; i++) { ! Prism next = current.offset(distance); ! prisms.add(next); ! if (distance > 0) { ! next.top.addHole(current.top); ! next.bottom.addHole(current.bottom); ! } else { ! current.top.addHole(next.top); ! current.bottom.addHole(next.bottom); ! } ! current = next; ! } ! } ! Space union = new Space("Layer", Space.CONSTRUCTION, true); ! for (Prism current : prisms) { ! Shape.addTo(union, current.surfaces()); ! } ! net.getOwner().add(union); } |