[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Command.java, 1.39, 1.40
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-11-26 10:51:04
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10808/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: extrude uses prism class Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Command.java 26 Nov 2007 07:28:59 -0000 1.39 --- Command.java 26 Nov 2007 10:51:00 -0000 1.40 *************** *** 77,80 **** --- 77,133 ---- /** + * Prism + */ + public static class Prism { + protected Surface top; + protected Surface bottom; + protected List<Surface> sides; + + + /** + * Constructs a Prism + * @param top top surface + * @param bottom bottom surface + * @param sides sides + */ + public Prism (Surface top, Surface bottom, List<Surface> sides) { + this.top = top; + this.bottom = bottom; + this.sides = sides; + } + + /** + * Returns a new prism, which is offset from this prism + * @param distance distance to offset + * @return a new offset prism + */ + 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); + } + + /** + * Returns the surfaces of this prism + * @return surfaces + */ + public Collection<Surface> surfaces() { + Collection<Surface> surfaces = new LinkedList(); + surfaces.add(top); + surfaces.add(bottom); + surfaces.addAll(sides); + return surfaces; + } + } + + + /** * * *************** *** 1229,1265 **** 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; ! } ! } /** --- 1282,1286 ---- private Space net; ! /** *************** *** 1357,1367 **** } ! ! /** {@inheritDoc} */ ! @Override ! public void evaluate() { ! double distance = parameters.getDouble("distance"); List<Surface> sides = new LinkedList(); ! Surface bottom = (Surface) surface.copy(new HashMap()); Vertex normal = bottom.normal(); normal.scaleInPlace(distance); --- 1378,1384 ---- } ! private Prism extrude(Surface bottom, double distance) { List<Surface> sides = new LinkedList(); ! Vertex normal = bottom.normal(); normal.scaleInPlace(distance); *************** *** 1413,1424 **** } ! List<Surface> surfaces = new LinkedList(); ! surfaces.add(bottom); ! surfaces.addAll(sides); ! surfaces.add(top); ! Space union = new Space("Extrusion", Space.CONSTRUCTION, true); ! Shape.addTo(union, surfaces); ! surface.getOwner().add(union); } --- 1430,1445 ---- } ! Prism prism = new Prism(top, bottom, sides); ! return prism; ! } ! ! /** {@inheritDoc} */ ! @Override ! public void evaluate() { ! double distance = parameters.getDouble("distance"); ! Surface bottom = (Surface) surface.copy(new HashMap()); ! Prism prism = extrude(bottom, distance); Space union = new Space("Extrusion", Space.CONSTRUCTION, true); ! Shape.addTo(union, prism.surfaces()); surface.getOwner().add(union); } |