[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor FacadeModellor.java, 1.8
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-09-07 11:41:28
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16933/src/net/sourceforge/bprocessor/facade/modellor Modified Files: FacadeModellor.java Log Message: some work on adding the ability to choose between single and double bar facades Index: FacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/FacadeModellor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FacadeModellor.java 5 Sep 2006 11:37:45 -0000 1.8 --- FacadeModellor.java 7 Sep 2006 11:41:26 -0000 1.9 *************** *** 32,35 **** --- 32,41 ---- private static final long serialVersionUID = 1L; + /** Dobbelt bar-type facade */ + private static final int DOUBLE_BAR = 1; + + /** Dobbelt bar-type facade */ + private static final int SINGLE_BAR = 2; + /** The logger */ private static Logger log = Logger.getLogger(FacadeModellor.class); *************** *** 92,97 **** --- 98,107 ---- private Line bottomBound; + /** Type facade */ + private int type; + /** The constructor */ public FacadeModellor() { + type = SINGLE_BAR; this.name = "Facade Modellor"; } *************** *** 101,104 **** --- 111,115 ---- */ public FacadeModellor(Space s) { + type = SINGLE_BAR; Project.getInstance().addObserver(this); this.space = s; *************** *** 125,146 **** public void update(Object entity) { if (entity == front) { ! createPostConstructors(); ! createFrame(); ! createWindows(); } if (horCons.contains(entity) || vertCons.contains(entity)) { ! createPostConstructors(); ! createWindows(); } } ! /** Removes a set of constructors from the facade ! * @param cons the constructors */ ! private void removeConstructors(List cons) { ! Iterator it = cons.iterator(); ! while (it.hasNext()) { ! space.remove((Constructor)it.next()); } } --- 136,176 ---- public void update(Object entity) { if (entity == front) { ! createFacade(); } if (horCons.contains(entity) || vertCons.contains(entity)) { ! createFacade(); } } + /** + * Creates the facade based on its type. + */ + private void createFacade() { + removeFacade(); + if (type == SINGLE_BAR) { + createFrame(); + } + createPostConstructors(); + createWindows(); + } ! ! /** ! * Removes constructors from the facade */ ! private void removeConstructors() { ! { ! Iterator it = vertCons.iterator(); ! while (it.hasNext()) { ! space.remove((Constructor)it.next()); ! } ! vertCons = new LinkedList(); ! } ! { ! Iterator it = horCons.iterator(); ! while (it.hasNext()) { ! space.remove((Constructor)it.next()); ! } ! horCons = new LinkedList(); } } *************** *** 203,209 **** Project.getInstance().checkpoint(); frameThickness = n; ! createFrame(); createPostConstructors(); ! createWindows(); } } else if (a.getName().equals("Depth")) { --- 233,241 ---- Project.getInstance().checkpoint(); frameThickness = n; ! if (type == SINGLE_BAR) { ! createFrame(); ! } createPostConstructors(); ! createWindows(); } } else if (a.getName().equals("Depth")) { *************** *** 212,218 **** --- 244,273 ---- Project.getInstance().checkpoint(); depth = n; + if (type == SINGLE_BAR) { + createFrame(); + } + createPostConstructors(); + createWindows(); + } + } else if (a.getName().equals("Single bars")) { + boolean b = ((Boolean)a.getValue()).booleanValue(); + if (b && type != SINGLE_BAR) { + type = SINGLE_BAR; + removeFacade(); + createFrame(); + createPostConstructors(); + createWindows(); + Project.getInstance().changed(this); + } + if (!b && type == SINGLE_BAR) { + type = DOUBLE_BAR; + vertPostWidth = 0; + horPostWidth = 0; + frameThickness = 0; + removeFacade(); createFrame(); createPostConstructors(); createWindows(); + Project.getInstance().changed(this); } } *************** *** 231,238 **** attributes.add(new Attribute("V-posts", new Double(vertPosts))); attributes.add(new Attribute("H-posts", new Double(horPosts))); ! attributes.add(new Attribute("V-postwidth", new Double(vertPostWidth))); ! attributes.add(new Attribute("H-postwidth", new Double(horPostWidth))); ! attributes.add(new Attribute("Frame thickness", new Double(frameThickness))); ! attributes.add(new Attribute("Depth", new Double(depth))); return attributes; } --- 286,301 ---- attributes.add(new Attribute("V-posts", new Double(vertPosts))); attributes.add(new Attribute("H-posts", new Double(horPosts))); ! boolean bars = (type == SINGLE_BAR); ! if (bars) { ! attributes.add(new Attribute("V-postwidth", new Double(vertPostWidth), bars)); ! attributes.add(new Attribute("H-postwidth", new Double(horPostWidth), bars)); ! attributes.add(new Attribute("Frame thickness", new Double(frameThickness), bars)); ! } else { ! attributes.add(new Attribute("V-postwidth", new Double(0), bars)); ! attributes.add(new Attribute("H-postwidth", new Double(0), bars)); ! attributes.add(new Attribute("Frame thickness", new Double(0), bars)); ! } ! attributes.add(new Attribute("Depth", new Double(depth))); ! attributes.add(new Attribute("Single bars", Boolean.valueOf(bars))); return attributes; } *************** *** 257,261 **** space.setModellor(null); } ! /** * Creates the frame for this facade based on frame thickness and depth. --- 320,324 ---- space.setModellor(null); } ! /** * Creates the frame for this facade based on frame thickness and depth. *************** *** 263,269 **** private void createFrame() { if (front != null && - frameThickness > 0 && depth > 0) { ! removeFrame(); frame = new Space("Frame", Space.CONSTRUCTION, true); space.add(frame); --- 326,331 ---- private void createFrame() { if (front != null && depth > 0) { ! removeFacade(); frame = new Space("Frame", Space.CONSTRUCTION, true); space.add(frame); *************** *** 275,307 **** eFront.setFrontDomain(frame); } - List edges = new LinkedList(); - Iterator it = eFront.getVertices().iterator(); - Vertex oldV = null; - while (it.hasNext()) { - Vertex v = (Vertex)it.next(); - Iterator eit = v.getEdges().iterator(); - Edge e1 = (Edge)eit.next(); - Edge e2 = (Edge)eit.next(); - Vertex e1Dir = e1.otherVertex(v).minus(v); - Vertex e2Dir = e2.otherVertex(v).minus(v); - e1Dir.scale(frameThickness / e1Dir.length()); - e2Dir.scale(frameThickness / e2Dir.length()); - Vertex vCopy = v.add(e1Dir).add(e2Dir); - if (oldV != null) { - Edge e = new Edge(oldV, vCopy); - space.add(e); - edges.add(e); - } - oldV = vCopy; - } - Edge e = new Edge(oldV, ((Edge)edges.get(0)).getFrom()); - space.add(e); - edges.add(e); - Surface h = new Surface(edges); - windows.add(h); - space.add(h); - eFront.addHole(h); - h.setBackDomain(space.getEmpty()); - h.setFrontDomain(space.getEmpty()); Set sides = new HashSet(); frameSurfaces.add(extrudeIntoSpace(eFront, depth, sides)); --- 337,340 ---- *************** *** 311,330 **** space.add((Surface)sidesIt.next()); } - sides = new HashSet(); - Surface top = extrudeIntoSpace(h, depth, sides); - windows.add(top); - Geometry.holeAnalysis(top); - windows.addAll(sides); - sidesIt = sides.iterator(); - while (sidesIt.hasNext()) { - space.add((Surface)sidesIt.next()); - } } } ! /** * Removes the current frame so a new one can be created. */ ! private void removeFrame() { if (frame != null) { Iterator it = frameSurfaces.iterator(); --- 344,354 ---- space.add((Surface)sidesIt.next()); } } } ! /** * Removes the current frame so a new one can be created. */ ! private void removeFacade() { if (frame != null) { Iterator it = frameSurfaces.iterator(); *************** *** 335,338 **** --- 359,363 ---- frame.delete(); removeWindows(); + removeConstructors(); } } *************** *** 342,347 **** */ private void createPostConstructors() { ! if (this.front != null) { ! List edges = this.front.getEdges(); if (edges.size() == 4) { Iterator it = edges.iterator(); --- 367,375 ---- */ private void createPostConstructors() { ! if (front != null && depth > 0) { ! List edges = front.getEdges(); ! removeConstructors(); ! vertCons = new LinkedList(); ! horCons = new LinkedList(); if (edges.size() == 4) { Iterator it = edges.iterator(); *************** *** 349,359 **** Edge horEdge = null; while (it.hasNext() && ! (vertEdge == null || ! horEdge == null)) { Edge e = (Edge)it.next(); if (Math.abs(e.getDirection().dot(new Vertex(0, 0, 1))) < 0.0001) { horEdge = e; } else if (Math.abs(e.getDirection().dot(new Vertex(1, 0, 0))) < 0.0001 && ! Math.abs(e.getDirection().dot(new Vertex(0, 1, 0))) < 0.0001) { vertEdge = e; } --- 377,387 ---- Edge horEdge = null; while (it.hasNext() && ! (vertEdge == null || ! horEdge == null)) { Edge e = (Edge)it.next(); if (Math.abs(e.getDirection().dot(new Vertex(0, 0, 1))) < 0.0001) { horEdge = e; } else if (Math.abs(e.getDirection().dot(new Vertex(1, 0, 0))) < 0.0001 && ! Math.abs(e.getDirection().dot(new Vertex(0, 1, 0))) < 0.0001) { vertEdge = e; } *************** *** 368,375 **** Vertex horDir = horEdge.otherVertex(cross).minus(cross); Vertex vertDir = vertEdge.otherVertex(cross).minus(cross); - removeConstructors(vertCons); - removeConstructors(horCons); - vertCons = new LinkedList(); - horCons = new LinkedList(); Vertex offset = horDir.copy(); double intervalV = ((horEdge.getLength() - frameThickness * 2) - --- 396,399 ---- *************** *** 396,410 **** space.add(l); } ! { ! offset = vertDir.copy(); ! offset.scale(frameThickness / offset.length()); ! topBound = new Line(cross.add(offset), horDir, vertEdge, true, true); ! offset.scale((vertEdge.getLength() - frameThickness) / offset.length()); ! bottomBound = new Line(cross.add(offset), horDir, vertEdge, true, true); ! offset = horDir.copy(); ! offset.scale(frameThickness / offset.length()); ! leftBound = new Line(cross.add(offset), vertDir, horEdge, true, true); ! offset.scale((horEdge.getLength() - frameThickness) / offset.length()); ! rightBound = new Line(cross.add(offset), vertDir, horEdge, true, true); } } --- 420,436 ---- space.add(l); } ! { ! Vertex topOffset = vertDir.copy(); ! topOffset.scale(frameThickness / topOffset.length()); ! topBound = new Line(cross.add(topOffset), horDir); ! Vertex bottomOffset = vertDir.copy(); ! bottomOffset.scale((vertEdge.getLength() - frameThickness) / bottomOffset.length()); ! bottomBound = new Line(cross.add(bottomOffset), horDir); ! Vertex leftOffset = horDir.copy(); ! leftOffset.scale(frameThickness / leftOffset.length()); ! leftBound = new Line(cross.add(leftOffset), vertDir); ! Vertex rightOffset = horDir.copy(); ! rightOffset.scale((horEdge.getLength() - frameThickness) / rightOffset.length()); ! rightBound = new Line(cross.add(rightOffset), vertDir); } } *************** *** 418,422 **** */ private void createWindows() { ! if (eFront != null) { removeWindows(); Vertex horDir = topBound.getDirection().copy(); --- 444,448 ---- */ private void createWindows() { ! if (front != null && depth > 0) { removeWindows(); Vertex horDir = topBound.getDirection().copy(); *************** *** 434,438 **** } } ! /** * Runs through the horizontal constructors to create holes for windows. --- 460,464 ---- } } ! /** * Runs through the horizontal constructors to create holes for windows. *************** *** 454,458 **** createHole(oldV, currentV, oldH, bottomBound); } ! /** * Creates a hole based on four boundry lines --- 480,484 ---- createHole(oldV, currentV, oldH, bottomBound); } ! /** * Creates a hole based on four boundry lines *************** *** 467,470 **** --- 493,500 ---- Vertex c3 = bottom.intersection(right); Vertex c4 = bottom.intersection(left); + //log.info("c1: " + c1); + // log.info("c2: " + c2); + // log.info("c3: " + c3); + // log.info("c4: " + c4); List edges = new LinkedList(); Edge e1 = new Edge(c1, c2); *************** *** 483,486 **** --- 513,520 ---- windows.add(s); space.add(s); + //log.info("left: " + left); + //log.info("right: " + right); + //log.info("top: " + top); + //log.info("bottom: " + bottom); Geometry.holeAnalysis(s); Set sides = new HashSet(); *************** *** 503,507 **** --- 537,543 ---- ((Surface)it.next()).delete(); } + windows = new HashSet(); } + /** * Makes sure to extrude the a surface to the right side |