[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor FacadeModellor.java, 1.1
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-09-29 13:41:36
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11883/src/net/sourceforge/bprocessor/facade/modellor Modified Files: FacadeModellor.java Log Message: New way of drawing windows to make it possible to remove post segments Index: FacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/FacadeModellor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** FacadeModellor.java 26 Sep 2006 10:01:11 -0000 1.16 --- FacadeModellor.java 29 Sep 2006 13:41:27 -0000 1.17 *************** *** 367,375 **** private void createPostConstructors() { if (front != null && front.getEdges().size() == 4 && depth > 0) { - //Finding horizontal and vertical edge - List edges = front.getEdges(); removeConstructors(); vertCons = new LinkedList(); horCons = new LinkedList(); Iterator it = edges.iterator(); Edge vertEdge = null; --- 367,375 ---- private void createPostConstructors() { if (front != null && front.getEdges().size() == 4 && depth > 0) { removeConstructors(); vertCons = new LinkedList(); horCons = new LinkedList(); + //Finding horizontal and vertical edge + List edges = front.getEdges(); Iterator it = edges.iterator(); Edge vertEdge = null; *************** *** 478,482 **** horSegs[i][j] = hSeg; vertSegs[i][j] = vSeg; ! drawSeg.put(hSeg, Boolean.TRUE); drawSeg.put(vSeg, Boolean.TRUE); h.connect(hSeg); --- 478,487 ---- horSegs[i][j] = hSeg; vertSegs[i][j] = vSeg; ! if (j > 0 && i < vertPosts + 1 && j < horPosts + 1 && ! i % 2 == 0) { ! drawSeg.put(hSeg, Boolean.FALSE); ! } else { ! drawSeg.put(hSeg, Boolean.TRUE); ! } drawSeg.put(vSeg, Boolean.TRUE); h.connect(hSeg); *************** *** 512,516 **** drawSeg = new HashMap(); } ! /** * Creates the holes for windows in the facade based on the post constructors, --- 517,521 ---- drawSeg = new HashMap(); } ! /** * Creates the holes for windows in the facade based on the post constructors, *************** *** 519,664 **** private void createWindows() { if (front != null && depth > 0) { ! removeWindows(); ! Vertex horDir = topBound.getDirection().copy(); ! horDir.scale(vertPostWidth / 2); ! Line oldV = leftBound; ! Line currentV = null; ! Iterator vIt = vertCons.iterator(); ! int i = 0; ! while (vIt.hasNext()) { ! Line vL = (Line)vIt.next(); ! currentV = new Line(vL.getOrigin().minus(horDir), vL.getDirection()); ! horizontalRun(oldV, currentV, i); ! oldV = new Line(vL.getOrigin().add(horDir), vL.getDirection()); ! //vL.connect(currentV); ! //vL.connect(oldV); ! i++; ! } ! horizontalRun(oldV, rightBound, i); ! } ! } ! ! /** ! * Runs through the horizontal constructors to create holes for windows. ! * @param oldV left boundry ! * @param currentV right boundry ! * @param i index of oldv ! */ ! private void horizontalRun(Line oldV, Line currentV, int i) { ! Line currentH; ! Vertex vertDir = leftBound.getDirection().copy(); ! vertDir.scale(horPostWidth / 2); ! Line oldH = topBound; ! int j = 0; ! Iterator hIt = horCons.iterator(); ! while (hIt.hasNext()) { ! Line hL = (Line)hIt.next(); ! Line copyOldV = new Line(oldV.getOrigin().copy(), oldV.getDirection().copy()); ! Line copyCurrentV = new Line(currentV.getOrigin().copy(), currentV.getDirection().copy()); ! currentH = new Line(hL.getOrigin().minus(vertDir), hL.getDirection()); ! createHole(copyOldV, copyCurrentV, oldH, currentH); ! horSegs[i][j].connect(oldH); ! horSegs[i][j + 1].connect(currentH); ! vertSegs[i][j].connect(copyOldV); ! vertSegs[i + 1][j].connect(copyCurrentV); ! oldH = new Line(hL.getOrigin().add(vertDir), hL.getDirection()); ! //hL.connect(currentH); ! //hL.connect(oldH); ! j++; ! } ! Line copyOldV = new Line(oldV.getOrigin().copy(), oldV.getDirection().copy()); ! Line copyCurrentV = new Line(currentV.getOrigin().copy(), currentV.getDirection().copy()); ! createHole(copyOldV, copyCurrentV, oldH, bottomBound); ! horSegs[i][j].connect(oldH); ! vertSegs[i][j].connect(copyOldV); ! vertSegs[i + 1][j].connect(copyCurrentV); ! } ! ! /** ! * 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); ! space.add(c1); ! Vertex c2 = top.intersection(right); ! space.add(c2); ! Vertex c3 = bottom.intersection(right); ! space.add(c3); ! Vertex c4 = bottom.intersection(left); ! space.add(c4); ! if (c1 != null && c2 != null && c3 != null && c4 != null) { ! List edges = new LinkedList(); ! Edge e1 = new Edge(c1, c2); ! space.add(e1); ! edges.add(e1); ! Edge e2 = new Edge(c2, c3); ! space.add(e2); ! edges.add(e2); ! Edge e3 = new Edge(c3, c4); ! space.add(e3); ! edges.add(e3); ! Edge e4 = new Edge(c4, c1); ! space.add(e4); ! edges.add(e4); ! Surface s = new Surface(edges); ! windows.add(s); ! space.add(s); ! Geometry.holeAnalysis(s); ! if (type == DOUBLE_BAR) { ! Vertex sn = s.normal(); ! Vertex fn = front.normal(); ! Space wf = new Space("Window", Space.CONSTRUCTION, Space.ELEMENT_LEVEL, true); ! space.add(wf); ! windowElements.add(wf); ! if (sn.dot(fn) > 0) { ! if (front.getFrontDomain() == space) { ! s.setFrontDomain(wf); ! } else { ! s.setBackDomain(wf); ! } ! } else { ! if (front.getBackDomain() == space) { ! s.setFrontDomain(wf); ! } else { ! s.setBackDomain(wf); ! } ! } ! Modellor wm = new WindowModellor(wf, s); ! wf.setModellor(wm); ! windowModellors.add(wm); ! top.connect(e1); ! right.connect(e2); ! bottom.connect(e3); ! left.connect(e4); ! } else { ! Set sides = new HashSet(); ! Surface t = extrudeIntoSpace(s, depth, sides); ! windows.add(t); ! windows.addAll(sides); ! Iterator it = sides.iterator(); ! while (it.hasNext()) { ! Surface side = (Surface)it.next(); ! if (side.contains(e1)) { ! top.connect(side); ! } else if (side.contains(e2)) { ! right.connect(side); ! } else if (side.contains(e3)) { ! bottom.connect(side); ! } else if (side.contains(e4)) { ! left.connect(side); } - space.add(side); } ! Geometry.holeAnalysis(t); ! } ! } else { ! log.warn("Unable to create windows, some intersections were NULL"); } } ! /** * Removes the windows of the facade. --- 524,649 ---- private void createWindows() { if (front != null && depth > 0) { ! Space oldActive = Project.getInstance().getActiveSpace(); ! Project.getInstance().setActiveSpace(space); ! Vertex vDir = vertSegs[0][0].getDirection(); ! vDir = vDir.copy((vertPostWidth / 2) / vDir.length()); ! Vertex hDir = horSegs[0][0].getDirection(); ! hDir = hDir.copy((horPostWidth / 2) / hDir.length()); ! //List slist = new LinkedList(); ! for (int i = 0; i < vertPosts + 1; i++) { ! for (int j = 0; j < horPosts + 1; j++) { ! Line v = vertSegs[i][j]; ! Line h = horSegs[i][j]; ! boolean drawV = ((Boolean)drawSeg.get(v)).booleanValue(); ! boolean drawH = ((Boolean)drawSeg.get(h)).booleanValue(); ! if (drawV && drawH) { ! List edges = new LinkedList(); ! int di = 1; ! int dj = 0; ! int stepI = 1; ! int stepJ = 0; ! Vertex start = h.intersection(v); ! start = start.add(vDir).add(hDir); ! Vertex last = start = Geometry.insertVertex(start, false); ! Vertex next = vertSegs[i + di][j].intersection(h); ! next = Geometry.insertVertex(next.add(vDir), false); ! Map connectMap = new HashMap(); ! //make edges till we are back at the start-vertex ! while (di != 0 || dj != 0) { ! boolean dirChanged = false; ! next = Geometry.insertVertex(next, false); ! Edge e = new Edge(last, next); ! edges.add(e); ! if (stepI == 1) { ! //stepped right ! if (((Boolean)drawSeg.get(vertSegs[i + di][j + dj])).booleanValue()) { ! //step down ! stepJ = 1; ! stepI = 0; ! dirChanged = true; ! } else if (((Boolean)drawSeg.get(horSegs[i + di][j + dj])).booleanValue()) { ! //step right ! stepJ = 0; ! stepI = 1; ! } ! connectMap.put(e, horSegs[i + di - 1][j + dj]); ! } else if (stepJ == 1) { ! //stepped down ! if (((Boolean)drawSeg.get(horSegs[i + di - 1][j + dj])).booleanValue()) { ! //step left ! stepJ = 0; ! stepI = -1; ! dirChanged = true; ! } else if (((Boolean)drawSeg.get(vertSegs[i + di][j + dj])).booleanValue()) { ! //step down ! stepJ = 1; ! stepI = 0; ! } ! connectMap.put(e, vertSegs[i + di][j + dj - 1]); ! } else if (stepI == -1) { ! //stepped left ! if (((Boolean)drawSeg.get(vertSegs[i + di][j + dj - 1])).booleanValue()) { ! //step up ! stepJ = -1; ! stepI = 0; ! dirChanged = true; ! } else if (((Boolean)drawSeg.get(horSegs[i + di - 1][j + dj])).booleanValue()) { ! //step left ! stepJ = 0; ! stepI = -1; ! } ! connectMap.put(e, horSegs[i + di][j + dj]); ! } else if (stepJ == -1) { ! //stepped up - the only option here is to step up even further. ! stepJ = -1; ! stepI = 0; ! connectMap.put(e, vertSegs[i + di][j + dj]); ! } else { ! log.info("NO STEP WAS MADE:" + " si:" + stepI + ! " sj:" + stepJ + ! " i:" + (i + di) + ! " j:" + (j + dj)); ! } ! if (dirChanged) { ! next.move((hDir.copy(-stepJ)).add(vDir.copy(stepI)).getX(), ! (hDir.copy(-stepJ)).add(vDir.copy(stepI)).getY(), ! (hDir.copy(-stepJ)).add(vDir.copy(stepI)).getZ()); ! } ! last = next; ! di += stepI; ! dj += stepJ; ! next = vertSegs[i + di][j + dj].intersection(horSegs[i + di][j + dj]); ! next = next.add(hDir.copy(-stepJ)).add(vDir.copy(stepI)); ! } ! Edge e = new Edge(last, start); ! connectMap.put(e, vertSegs[i + di][j + dj]); ! edges.add(e); ! List surface = Geometry.insertEdges(edges); ! if (surface.isEmpty()) { ! log.info("NO SURFACE FROM EDGES :'-("); ! } else { ! Set sides = new HashSet(); ! Geometry.holeAnalysis(extrudeIntoSpace((Surface)surface.iterator().next(), ! depth, ! sides)); ! Iterator it = sides.iterator(); ! while (it.hasNext()) { ! Surface side = (Surface)it.next(); ! Iterator sIt = side.getEdges().iterator(); ! while (sIt.hasNext()) { ! Line seg = (Line)connectMap.get(sIt.next()); ! if (seg != null) { ! seg.connect(side); ! } ! } ! } ! } } } ! } ! Project.getInstance().setActiveSpace(oldActive); } } ! /** * Removes the windows of the facade. |