[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor FacadeModellor.java, 1.4
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-08-29 09:29:19
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3779/src/net/sourceforge/bprocessor/facade/modellor Modified Files: FacadeModellor.java Log Message: more work on facade modellor, still has problems with surfaces drawn in some ways. Index: FacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/FacadeModellor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FacadeModellor.java 21 Aug 2006 09:33:12 -0000 1.4 --- FacadeModellor.java 29 Aug 2006 09:29:10 -0000 1.5 *************** *** 55,65 **** /** The front surface of the facade */ ! private Surface front; /** The set of vertical constructor lines */ ! private Set vertCons = new HashSet(); /** The set of horizontal constructor lines */ ! private Set horCons = new HashSet(); /** Thickness of the frame */ --- 55,68 ---- /** The front surface of the facade */ ! private Surface front = null; ! ! /** A copy of the front surface but on element-level */ ! private Surface eFront = null; /** The set of vertical constructor lines */ ! private List vertCons = new LinkedList(); /** The set of horizontal constructor lines */ ! private List horCons = new LinkedList(); /** Thickness of the frame */ *************** *** 72,80 **** private Space frame; /** The surfaces of the frame */ private Set frameSurfaces = new HashSet(); ! /** frame present */ ! private boolean present = false; /** The constructor */ --- 75,95 ---- private Space frame; + /** Set of surfaces that forms the holes for windows*/ + private Set windows = new HashSet(); + /** The surfaces of the frame */ private Set frameSurfaces = new HashSet(); ! /** edge marking leftmost boundry of the facade */ ! private Line leftBound; ! ! /** edge marking rightmost boundry of the facade */ ! private Line rightBound; ! ! /** edge marking top boundry of the facade */ ! private Line topBound; ! ! /** edge marking leftmost boundry of the facade */ ! private Line bottomBound; /** The constructor */ *************** *** 113,116 **** --- 128,136 ---- createPostConstructors(); createFrame(); + createWindows(); + } + if (horCons.contains(entity) || vertCons.contains(entity)) { + createPostConstructors(); + createWindows(); } } *************** *** 120,124 **** * @param cons the constructors */ ! private void removeConstructors(Set cons) { Iterator it = cons.iterator(); while (it.hasNext()) { --- 140,144 ---- * @param cons the constructors */ ! private void removeConstructors(List cons) { Iterator it = cons.iterator(); while (it.hasNext()) { *************** *** 152,156 **** Project.getInstance().checkpoint(); vertPosts = n; ! createPostConstructors(); } } else if (a.getName().equals("H-posts")) { --- 172,177 ---- Project.getInstance().checkpoint(); vertPosts = n; ! createPostConstructors(); ! createWindows(); } } else if (a.getName().equals("H-posts")) { *************** *** 160,168 **** horPosts = n; createPostConstructors(); } } else if (a.getName().equals("V-postwidth")) { ! vertPostWidth = ((Double)a.getValue()).doubleValue(); } else if (a.getName().equals("H-postwidth")) { ! horPostWidth = ((Double)a.getValue()).doubleValue(); } else if (a.getName().equals("Frame thickness")) { double n = ((Double)a.getValue()).doubleValue(); --- 181,202 ---- horPosts = n; createPostConstructors(); + createWindows(); } } else if (a.getName().equals("V-postwidth")) { ! double d = ((Double)a.getValue()).doubleValue(); ! if (d != vertPostWidth) { ! Project.getInstance().checkpoint(); ! vertPostWidth = d; ! createPostConstructors(); ! createWindows(); ! } } else if (a.getName().equals("H-postwidth")) { ! double d = ((Double)a.getValue()).doubleValue(); ! if (d != horPostWidth) { ! Project.getInstance().checkpoint(); ! horPostWidth = d; ! createPostConstructors(); ! createWindows(); ! } } else if (a.getName().equals("Frame thickness")) { double n = ((Double)a.getValue()).doubleValue(); *************** *** 172,175 **** --- 206,210 ---- createFrame(); createPostConstructors(); + createWindows(); } } else if (a.getName().equals("Depth")) { *************** *** 180,183 **** --- 215,219 ---- createFrame(); createPostConstructors(); + createWindows(); } } *************** *** 233,245 **** frame = new Space("Frame", Space.CONSTRUCTION, true); space.add(frame); ! Surface s = front.copy(space); ! frameSurfaces.add(s); if (front.getBackDomain() == space) { ! s.setBackDomain(frame); } else { ! s.setFrontDomain(frame); } List edges = new LinkedList(); ! Iterator it = s.getVertices().iterator(); Vertex oldV = null; while (it.hasNext()) { --- 269,281 ---- frame = new Space("Frame", Space.CONSTRUCTION, true); space.add(frame); ! eFront = front.copy(space); ! frameSurfaces.add(eFront); if (front.getBackDomain() == space) { ! eFront.setBackDomain(frame); } else { ! eFront.setFrontDomain(frame); } List edges = new LinkedList(); ! Iterator it = eFront.getVertices().iterator(); Vertex oldV = null; while (it.hasNext()) { *************** *** 264,274 **** edges.add(e); Surface h = new Surface(edges); ! frameSurfaces.add(h); space.add(h); ! s.addHole(h); h.setBackDomain(space.getEmpty()); h.setFrontDomain(space.getEmpty()); Set sides = new HashSet(); ! frameSurfaces.add(s.extrude(depth, sides)); frameSurfaces.addAll(sides); Iterator sidesIt = sides.iterator(); --- 300,310 ---- 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(eFront.extrude(depth, sides)); frameSurfaces.addAll(sides); Iterator sidesIt = sides.iterator(); *************** *** 278,284 **** sides = new HashSet(); Surface top = h.extrude(depth, sides); ! frameSurfaces.add(top); Geometry.holeAnalysis(top); ! frameSurfaces.addAll(sides); sidesIt = sides.iterator(); while (sidesIt.hasNext()) { --- 314,320 ---- sides = new HashSet(); Surface top = h.extrude(depth, sides); ! windows.add(top); Geometry.holeAnalysis(top); ! windows.addAll(sides); sidesIt = sides.iterator(); while (sidesIt.hasNext()) { *************** *** 299,302 **** --- 335,339 ---- frameSurfaces = new HashSet(); frame.delete(); + removeWindows(); } } *************** *** 334,355 **** removeConstructors(vertCons); removeConstructors(horCons); ! vertCons = new HashSet(); ! horCons = new HashSet(); ! double interval = (horEdge.getLength() - (frameThickness * 2)) / (vertPosts + 1); for (int i = 1; i < vertPosts + 1; i++) { ! Vertex offset = horDir.copy(); ! offset.scale((interval * i + frameThickness) / offset.length()); Line l = new Line(cross.add(offset), vertDir.copy(), true); vertCons.add(l); space.add(l); } ! interval = (vertEdge.getLength() - (frameThickness * 2)) / (horPosts + 1); for (int i = 1; i < horPosts + 1; i++) { ! Vertex offset = vertDir.copy(); ! offset.scale((interval * i + frameThickness) / offset.length()); Line l = new Line(cross.add(offset), horDir.copy(), true); horCons.add(l); space.add(l); } } } --- 371,416 ---- removeConstructors(vertCons); removeConstructors(horCons); ! vertCons = new LinkedList(); ! horCons = new LinkedList(); ! Vertex offset = horDir.copy(); ! double intervalV = ((horEdge.getLength() - frameThickness * 2) + vertPostWidth) ! / (vertPosts + 1); for (int i = 1; i < vertPosts + 1; i++) { ! if (i > 1) { ! offset.scale((intervalV * i + frameThickness) / offset.length()); ! } else { ! offset.scale(((intervalV - vertPostWidth / 2) * i + frameThickness) ! / offset.length()); ! } Line l = new Line(cross.add(offset), vertDir.copy(), true); vertCons.add(l); space.add(l); } ! offset = vertDir.copy(); ! double intervalH = (vertEdge.getLength() - (frameThickness * 2) + horPostWidth) ! / (horPosts + 1); for (int i = 1; i < horPosts + 1; i++) { ! if (i > 1) { ! offset.scale((intervalH * i + frameThickness) / offset.length()); ! } else { ! offset.scale(((intervalH - horPostWidth / 2) * i + frameThickness) ! / offset.length()); ! } Line l = new Line(cross.add(offset), horDir.copy(), true); horCons.add(l); space.add(l); } + { + offset = vertDir.copy(); + offset.scale(frameThickness / offset.length()); + topBound = new Line(cross.add(offset), horDir); + offset.scale((vertEdge.getLength() - frameThickness) / offset.length()); + bottomBound = new Line(cross.add(offset), horDir); + offset = horDir.copy(); + offset.scale(frameThickness / offset.length()); + leftBound = new Line(cross.add(offset), vertDir); + offset.scale((horEdge.getLength() - frameThickness) / offset.length()); + rightBound = new Line(cross.add(offset), vertDir); + } } } *************** *** 358,374 **** /** ! * Creates the posts for the facade based on the post constructors, * the post width and the depth. - * */ ! private void createPosts() { ! } /** ! * ! * */ ! private void createColumn() { ! } } --- 419,503 ---- /** ! * Creates the holes for windows in the facade based on the post constructors, * the post width and the depth. */ ! private void createWindows() { ! if (eFront != null) { ! removeWindows(); ! Vertex horDir = topBound.getDirection().copy(); ! horDir.scale(vertPostWidth / 2); ! Line oldV = leftBound; ! Line currentV = null; ! Iterator vIt = vertCons.iterator(); ! while (vIt.hasNext()) { ! Line vL = (Line)vIt.next(); ! currentV = new Line(vL.getOrigin().minus(horDir), vL.getDirection()); ! horizontalRun(oldV, currentV); ! oldV = new Line(vL.getOrigin().add(horDir), vL.getDirection()); ! } ! horizontalRun(oldV, rightBound); ! } } + /** ! * Runs through the horizontal constructors to create holes for windows. ! * @param oldV left boundry ! * @param currentV right boundry */ ! private void horizontalRun(Line oldV, Line currentV) { ! Line currentH; ! Vertex vertDir = leftBound.getDirection().copy(); ! vertDir.scale(horPostWidth / 2); ! Line oldH = topBound; ! Iterator hIt = horCons.iterator(); ! while (hIt.hasNext()) { ! Line hL = (Line)hIt.next(); ! currentH = new Line(hL.getOrigin().minus(vertDir), hL.getDirection()); ! createHole(oldV, currentV, oldH, currentH); ! oldH = new Line(hL.getOrigin().add(vertDir), hL.getDirection()); ! } ! createHole(oldV, currentV, oldH, bottomBound); ! } ! ! /** ! * Creates a hole based on four boundry lines ! * @param left left line ! * @param right right line ! * @param top top line ! * @param bottom bottom line ! */ ! private void createHole(Line left, Line right, Line top, Line bottom) { ! Vertex c1 = top.intersection(left); ! Vertex c2 = top.intersection(right); ! Vertex c3 = bottom.intersection(right); ! Vertex c4 = bottom.intersection(left); ! List edges = new LinkedList(); ! edges.add(new Edge(c1, c2)); ! edges.add(new Edge(c2, c3)); ! edges.add(new Edge(c3, c4)); ! edges.add(new Edge(c4, c1)); ! Surface s = new Surface(edges); ! windows.add(s); ! space.add(s); ! Geometry.holeAnalysis(s); ! Set sides = new HashSet(); ! Surface t = s.extrude(depth, sides); ! windows.add(t); ! windows.addAll(sides); ! Iterator it = sides.iterator(); ! while (it.hasNext()) { ! space.add((Surface)it.next()); ! } ! Geometry.holeAnalysis(t); ! } ! ! /** ! * Removes the windows of the facade. ! */ ! private void removeWindows() { ! Iterator it = windows.iterator(); ! while (it.hasNext()) { ! ((Surface)it.next()).delete(); ! } } } |