[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor NetFacadeModellor.java,
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Nordholt <nor...@us...> - 2007-02-16 09:57:56
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6858/src/net/sourceforge/bprocessor/facade/modellor Modified Files: NetFacadeModellor.java Log Message: uses the extrusion method instead of extrude. Did some other refactoring Index: NetFacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/NetFacadeModellor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NetFacadeModellor.java 7 Feb 2007 16:59:22 -0000 1.16 --- NetFacadeModellor.java 16 Feb 2007 09:57:55 -0000 1.17 *************** *** 36,39 **** --- 36,51 ---- */ public class NetFacadeModellor extends Modellor { + /** Thickness of a generic door frame */ + private static final double DOOR_FRAME = 0.12; + + /** Thickness of a generic window frame */ + private static final double WINDOW_FRAME = 0.05; + + /** identation of the window and door frames into the main frame*/ + private static final double FRAME_IDENTATION = 0.02; + + /** The depth of window and door frames */ + private static final double FRAME_DEPTH = 0.05; + /** serial id */ private static final long serialVersionUID = 1L; *************** *** 208,216 **** while (sit.hasNext()) { Surface s = (Surface)sit.next(); ! if (s.getName().equals(att.getValue())) { ! if (front != s) { ! this.setFront(s); ! this.setNet(createNet(front)); ! } } } --- 220,226 ---- while (sit.hasNext()) { Surface s = (Surface)sit.next(); ! if (s.getName().equals(att.getValue()) && front != s) { ! this.setFront(s); ! this.setNet(createNet(front)); } } *************** *** 316,320 **** if (env.get("type") == null) { List options = new LinkedList(); - options.add("Empty"); options.add("Glass"); options.add("Window"); --- 326,329 ---- *************** *** 378,385 **** outlineCopies.add(((Edge)it.next()).copy()); } ! if (!outlineCopies.isEmpty()) { /* make the shell of the facade */ Surface frameSurface = new Surface(outlineCopies); ! space.insert(frameSurface); assignSame(front, frameSurface, space, frame); Set sides1 = new HashSet(); --- 387,394 ---- outlineCopies.add(((Edge)it.next()).copy()); } ! if (!outlineCopies.isEmpty()) { /* make the shell of the facade */ Surface frameSurface = new Surface(outlineCopies); ! frameSurface = space.insert(frameSurface); assignSame(front, frameSurface, space, frame); Set sides1 = new HashSet(); *************** *** 404,476 **** } } Surface hole = new Surface(Edge.placeOffset(field.getEdges(), field, offsetMap)); hole = space.insert(hole); Geometry.holeAnalysis(hole); Set sides2 = new HashSet(); Surface holeEx = space.insert(extrudeIntoSpace(hole, depth, sides2)); Geometry.holeAnalysis(holeEx); ! Double extraFrame = 0.0; ! if (envF.get("type") instanceof Selector) { ! Selector sel = (Selector)envF.get("type"); ! if (sel.getCurrentValue().equals("Empty")) { ! extraFrame = 0.0; ! } else if (sel.getCurrentValue().equals("Glass")) { ! extraFrame = 0.0; ! } else if (sel.getCurrentValue().equals("Window")) { ! extraFrame = 0.05; ! } else if (sel.getCurrentValue().equals("Door")) { ! extraFrame = 0.12; ! } ! } ! if (extraFrame > 0) { ! Map offmap1 = new HashMap<Edge, Double>(); ! Map offmap2 = new HashMap<Edge, Double>(); ! for (Object o : hole.getEdges()) { ! Edge e = (Edge)o; ! offmap1.put(e, 0.02); ! offmap2.put(e, -(extraFrame - 0.02)); ! } ! Surface in = new Surface(Edge.placeOffset(hole.getEdges(), hole, offmap1)); ! Surface out = new Surface(Edge.placeOffset(hole.getEdges(), hole, offmap2)); ! hole.getExterior().removeHole(hole); ! pushIntoSpace(hole, 0.05); ! Geometry.holeAnalysis(hole); ! in = space.insert(in); ! out = space.insert(out); ! Geometry.holeAnalysis(in); ! Geometry.holeAnalysis(out); ! ! Space wf = new Space("Window Frame", ! Space.CONSTRUCTION, ! Space.ELEMENT_LEVEL, ! true); ! Space g = new Space("Glass", ! Space.CONSTRUCTION, ! Space.ELEMENT_LEVEL, ! true); ! g.setTransparent(true); ! space.add(g); ! space.add(wf); ! assignSame(front, in, space, wf); ! assignSame(front, out, space, g); ! ! Set sides = new HashSet(); ! Surface inEx = extrudeIntoSpace(in, 0.05, sides); ! assignSame(front, inEx, space, frame); ! space.add(inEx); ! assignSame(front, inEx, space, frame); ! Geometry.holeAnalysis(inEx); ! sides = new HashSet(); ! Surface outEx = extrudeIntoSpace(out, 0.05, sides); ! outEx = space.insert(outEx); ! assignOpposite(front, outEx, space, g); ! assignOpposite(front, hole, space, wf); ! Geometry.holeAnalysis(outEx); ! Geometry.holeAnalysis(hole); ! } } } } } /** --- 413,493 ---- } } + Surface hole = new Surface(Edge.placeOffset(field.getEdges(), field, offsetMap)); hole = space.insert(hole); Geometry.holeAnalysis(hole); + Set sides2 = new HashSet(); Surface holeEx = space.insert(extrudeIntoSpace(hole, depth, sides2)); Geometry.holeAnalysis(holeEx); ! detailField(envF, hole); } } } } + + /** + * Generates door or window frames in the field + * @param envF the parameters for the field + * @param hole the hole in the frame for the field + */ + private void detailField(Map envF, Surface hole) { + double frameSize = 0.0; + if (envF.get("type") instanceof Selector) { + Selector sel = (Selector)envF.get("type"); + if (sel.getCurrentValue().equals("Window")) { + frameSize = WINDOW_FRAME; + } else if (sel.getCurrentValue().equals("Door")) { + frameSize = DOOR_FRAME; + } + } + if (frameSize > 0) { + Map offmap1 = new HashMap<Edge, Double>(); + Map offmap2 = new HashMap<Edge, Double>(); + for (Object o : hole.getEdges()) { + Edge e = (Edge)o; + offmap1.put(e, FRAME_IDENTATION); + offmap2.put(e, -(frameSize - FRAME_IDENTATION)); + } + Surface in = new Surface(Edge.placeOffset(hole.getEdges(), hole, offmap1)); + Surface out = new Surface(Edge.placeOffset(hole.getEdges(), hole, offmap2)); + hole.getExterior().removeHole(hole); + pushIntoSpace(hole, FRAME_DEPTH); + Geometry.holeAnalysis(hole); + in = space.insert(in); + out = space.insert(out); + Geometry.holeAnalysis(in); + Geometry.holeAnalysis(out); + + Space f = new Space(envF.get("type") + " Frame", + Space.CONSTRUCTION, + Space.ELEMENT_LEVEL, + true); + Space g = new Space("Glass", + Space.CONSTRUCTION, + Space.ELEMENT_LEVEL, + true); + g.setTransparent(true); + space.add(g); + space.add(f); + assignSame(front, in, space, f); + assignSame(front, out, space, g); + + Set sides = new HashSet(); + Surface inEx = extrudeIntoSpace(in, FRAME_DEPTH, sides); + space.add(inEx); + assignSame(front, inEx, space, frame); + Geometry.holeAnalysis(inEx); + + sides = new HashSet(); + Surface outEx = extrudeIntoSpace(out, FRAME_DEPTH, sides); + //outEx = space.insert(outEx); + assignOpposite(front, outEx, space, g); + assignOpposite(front, hole, space, f); + + Geometry.holeAnalysis(outEx); + Geometry.holeAnalysis(hole); + } + } /** *************** *** 485,489 **** /*Find outer edges*/ Iterator edges = net.getEdges().iterator(); ! Set outer = new HashSet(); while (edges.hasNext()) { Edge current = (Edge)edges.next(); --- 502,506 ---- /*Find outer edges*/ Iterator edges = net.getEdges().iterator(); ! Set<Edge> outer = new HashSet<Edge>(); while (edges.hasNext()) { Edge current = (Edge)edges.next(); *************** *** 494,498 **** /*If there are outer edges sort them in order*/ if (!outer.isEmpty()) { ! LinkedList outline = new LinkedList(); Edge first = (Edge)outer.iterator().next(); outline.add(first); --- 511,515 ---- /*If there are outer edges sort them in order*/ if (!outer.isEmpty()) { ! LinkedList<Edge> outline = new LinkedList<Edge>(); Edge first = (Edge)outer.iterator().next(); outline.add(first); *************** *** 577,581 **** deltaCorrection *= -1; } ! return s.extrude(delta * deltaCorrection, sides); } --- 594,613 ---- deltaCorrection *= -1; } ! Set tops = new HashSet(); ! Surface top = s.extrusionall(delta * deltaCorrection, sides, tops); ! ! tops.addAll(sides); ! for (Object o1 : tops) { ! Surface surface = (Surface)o1; ! for (Object o2 : surface.getEdges()) { ! Edge edge = (Edge)o2; ! space.add(edge.getTo()); ! space.add(edge.getFrom()); ! space.add(edge); ! } ! space.add(surface); ! } ! space.add(top); ! return top; } |