[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor NetFacadeModellor.java,
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Nordholt <nor...@us...> - 2007-03-13 09:31:51
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32206/src/net/sourceforge/bprocessor/facade/modellor Modified Files: NetFacadeModellor.java Log Message: new window frames for double posted facades Index: NetFacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/NetFacadeModellor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** NetFacadeModellor.java 16 Feb 2007 13:33:42 -0000 1.18 --- NetFacadeModellor.java 13 Mar 2007 09:31:44 -0000 1.19 *************** *** 17,20 **** --- 17,22 ---- import net.sourceforge.bprocessor.model.Attribute; + import net.sourceforge.bprocessor.model.Classification; + import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; *************** *** 22,25 **** --- 24,28 ---- import net.sourceforge.bprocessor.model.Net; import net.sourceforge.bprocessor.model.ParameterBlock; + import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selector; *************** *** 125,140 **** */ public Modellor newInstance(Space s) { NetFacadeModellor mod = new NetFacadeModellor(); mod.setSpace(s); Project.getInstance().scheduleObserver(mod); s.setModellor(mod); ! Iterator it = s.getEnvelope().iterator(); ! if (it.hasNext()) { ! mod.setFront((Surface)it.next()); ! } mod.setNet(mod.createNet(mod.getFront())); mod.regenerate(); return mod; } /** --- 128,165 ---- */ public Modellor newInstance(Space s) { + //genFrameTest(); NetFacadeModellor mod = new NetFacadeModellor(); mod.setSpace(s); Project.getInstance().scheduleObserver(mod); s.setModellor(mod); ! mod.setFront(findFront(s)); mod.setNet(mod.createNet(mod.getFront())); mod.regenerate(); return mod; } + + /** + * Finds a suitable surface for the front surface. + * @param s the space which envelope should be searched + * @return a suitable surface from the s' envelope + */ + private Surface findFront(Space s) { + Iterator it = s.getEnvelope().iterator(); + Surface frontCandidate = null; + if (it.hasNext()) { + frontCandidate = (Surface)it.next(); + } + while(it.hasNext()) { + Surface surface = (Surface)it.next(); + Classification frontClass = surface.getFrontDomain().getClassification(); + Classification backClass = surface.getBackDomain().getClassification(); + + if ((frontClass != null && frontClass.getFullId(null).equalsIgnoreCase("-80")) || + (backClass != null && backClass.getFullId(null).equalsIgnoreCase("-80"))) { + frontCandidate = surface; + } + } + return frontCandidate; + } /** *************** *** 352,367 **** while (fields.hasNext()) { Surface field = (Surface)fields.next(); ! Space window = new Space("Window", ! Space.CONSTRUCTION, ! space.getLevel() + 1, ! true); ! space.add(window); ! Surface fcopy = field.copyall(space); ! assignSame(front, fcopy, space, window); ! windows.add(window); ! NetFacadeModellor winModellor = (NetFacadeModellor)newInstance(window); ! winModellor.setFront(fcopy); ! winModellor.setDepth(depth); ! winModellor.setFrameWidth(frameWidth); } } --- 377,413 ---- while (fields.hasNext()) { Surface field = (Surface)fields.next(); ! //assuming here that each window is a rectangle. ! if (field.getEdges().size() == 4) { ! Surface cut1 = cutType1(); ! Surface cut2 = cutType2(); ! cut1.setBackDomain(frame); ! cut1.setFrontDomain(frame); ! cut2.setBackDomain(frame); ! cut2.setFrontDomain(frame); ! ! Iterator it = field.getEdges().iterator(); ! Edge e1 = (Edge)it.next(); ! Edge e2 = (Edge)it.next(); ! Set<Surface> frame1 = generateFrame(cut1, e2.getLength(), e1.getLength()); ! Set<Surface> frame2 = generateFrame(cut2, e2.getLength(), e1.getLength()); ! ! frame.removeSurface(cut1); ! frame.removeSurface(cut2); ! Vertex common = Edge.commonVertex(e1, e2); ! Vertex i = e1.otherVertex(common).minus(common); ! Vertex n = e2.otherVertex(common).minus(common); ! Vertex j = front.normal(); ! if (front.getBackDomain() == space) { ! j.scale(-1); ! } ! i.normalize(); ! j.normalize(); ! n.normalize(); ! CoordinateSystem anker = new CoordinateSystem(i, j, n, common); ! unTranslateGeometry(frame1, anker); ! unTranslateGeometry(frame2, anker); ! space.addAll(frame1); ! space.addAll(frame2); ! } } } *************** *** 416,425 **** 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); } } --- 462,478 ---- Surface hole = new Surface(Edge.placeOffset(field.getEdges(), field, offsetMap)); hole = space.insert(hole); + Space holeSpace = new Space("Facade Hole", + Space.FUNCTIONAL, + space.getLevel() + 1, + true); + space.add(holeSpace); + assignSame(front, hole, space, holeSpace); Geometry.holeAnalysis(hole); Set sides2 = new HashSet(); Surface holeEx = space.insert(extrudeIntoSpace(hole, depth, sides2)); + assignOpposite(front, holeEx, space, holeSpace); Geometry.holeAnalysis(holeEx); ! detailField(envF, hole, holeSpace); } } *************** *** 431,436 **** * @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; String type = ""; --- 484,490 ---- * @param envF the parameters for the field * @param hole the hole in the frame for the field + * @param holeSpace the space of the hole in the facade */ ! private void detailField(Map envF, Surface hole, Space holeSpace) { double frameSize = 0.0; String type = ""; *************** *** 454,465 **** 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(type + " Frame", Space.CONSTRUCTION, --- 508,511 ---- *************** *** 474,478 **** space.add(f); assignSame(front, in, space, f); ! assignSame(front, out, space, g); Set sides = new HashSet(); --- 520,533 ---- space.add(f); assignSame(front, in, space, f); ! assignSame(front, out, space, g); ! ! 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); Set sides = new HashSet(); *************** *** 517,525 **** boolean done = false; Iterator nextEdges = nextVertex.getEdges().iterator(); ! while (nextEdges.hasNext() && !done) { Object e = nextEdges.next(); if (outer.contains(e)) { next = (Edge)e; ! done = true; } } --- 572,580 ---- boolean done = false; Iterator nextEdges = nextVertex.getEdges().iterator(); ! while (nextEdges.hasNext()) { Object e = nextEdges.next(); if (outer.contains(e)) { next = (Edge)e; ! break; } } *************** *** 540,544 **** } else { log.warn("Outline not well defined, " + ! " all outer edges in outline: " + outer.size() + " outline connected: " + first.getFrom().getEdges().contains(outline.getLast())); } --- 595,599 ---- } else { log.warn("Outline not well defined, " + ! " outer edges left: " + outer.size() + " outline connected: " + first.getFrom().getEdges().contains(outline.getLast())); } *************** *** 707,709 **** --- 762,912 ---- return getGeneralName(); } + + public static void genFrameTest() { + Space test = new Space("test", + Space.CONSTRUCTION, + Space.SPACE_LEVEL, + true); + Project.getInstance().world().add(test); + { + Surface cut = cutType1(); + cut.setBackDomain(test); + cut.setFrontDomain(test); + Set<Surface> testFrame = generateFrame(cut, 1, 1); + for (Surface s: testFrame) { + Project.getInstance().world().add(s); + Iterator edgs = s.getEdges().iterator(); + while (edgs.hasNext()) { + Project.getInstance().world().add((Edge)edgs.next()); + } + } + } + { + Surface cut = cutType2(); + cut.setBackDomain(test); + cut.setFrontDomain(test); + Set<Surface> testFrame = generateFrame(cut, 1, 1); + for (Surface s: testFrame) { + Project.getInstance().world().add(s); + Iterator edgs = s.getEdges().iterator(); + while (edgs.hasNext()) { + Project.getInstance().world().add((Edge)edgs.next()); + } + } + } + + } + + private static Set<Surface> generateFrame(Surface cut, double height, double width) { + Set topPost = genFramePost(cut, width); + Set leftPost = genFramePost(cut, height); + Set rightPost = genFramePost(cut, height); + Set bottomPost = genFramePost(cut, width); + CoordinateSystem csTop = new CoordinateSystem(new Vertex(0, 0, -1), + new Vertex(0, 1, 0), + new Vertex(1, 0, 0), + new Vertex(0, 0, height)); + CoordinateSystem csRight = new CoordinateSystem(new Vertex(-1, 0, 0), + new Vertex(0, 1, 0), + new Vertex(0, 0, -1), + new Vertex(width, 0, height)); + CoordinateSystem csBottom = new CoordinateSystem(new Vertex(0, 0, 1), + new Vertex(0, 1, 0), + new Vertex(-1, 0, 0), + new Vertex(width, 0, 0)); + unTranslateGeometry(bottomPost, csBottom); + unTranslateGeometry(rightPost, csRight); + unTranslateGeometry(topPost, csTop); + + Set<Surface> surfaces = new HashSet<Surface>(); + HashSet surfs = new HashSet(leftPost); + surfs.addAll(rightPost); + surfs.addAll(topPost); + surfs.addAll(bottomPost); + Iterator it = surfs.iterator(); + while (it.hasNext()) { + Surface s = (Surface)it.next(); + surfaces.add(s); + } + return surfaces; + } + + /** + * untranslates a set of geometry. + * @param geometry the geometry + * @param system the coordinate system to untranslate according to + */ + private static void unTranslateGeometry(Set geometry, CoordinateSystem system) { + List<Vertex> vertices = new LinkedList<Vertex>(Geometry.collect(geometry)); + List<Vertex> unTranslatedVertices = system.unTranslate(vertices); + Iterator it = vertices.iterator(); + Iterator unTranslatedIt = unTranslatedVertices.iterator(); + while (it.hasNext() && unTranslatedIt.hasNext()) { + Vertex v = (Vertex)it.next(); + Vertex vUnTranslated = (Vertex)unTranslatedIt.next(); + v.setX(vUnTranslated.getX()); + v.setY(vUnTranslated.getY()); + v.setZ(vUnTranslated.getZ()); + } + } + + private static Surface cutType1() { + List<Vertex> vl = new LinkedList<Vertex>(); + Vertex first = new Vertex(0, 0, 0); + vl.add(new Vertex(0.050, 0, 0)); + vl.add(new Vertex(0.050, 0.016, 0)); + vl.add(new Vertex(0.008, 0.016, 0)); + vl.add(new Vertex(0.008, 0.125, 0)); + vl.add(new Vertex(0.000, 0.125, 0)); + List<Edge> el = new LinkedList<Edge>(); + Vertex prevV = first; + for (Vertex v: vl) { + el.add(new Edge(prevV, v)); + prevV = v; + } + el.add(new Edge(prevV, first)); + Surface cut = new Surface(el); + return cut; + } + + private static Surface cutType2() { + List<Vertex> vl = new LinkedList<Vertex>(); + Vertex first = new Vertex(0.004, 0, 0); + vl.add(new Vertex(0.050, 0, 0)); + vl.add(new Vertex(0.050, -0.035, 0)); + vl.add(new Vertex(0.004, -0.035, 0)); + List<Edge> el = new LinkedList<Edge>(); + Vertex prevV = first; + for (Vertex v: vl) { + el.add(new Edge(prevV, v)); + prevV = v; + } + el.add(new Edge(prevV, first)); + Surface cut = new Surface(el); + return cut; + } + + /** + * Generates one frame post. + * @param cut the cut of the post + * @param length the length of the post + * @return the surfaces of the new post + */ + private static Set genFramePost(Surface cut, double length) { + Surface copy = cut.copy(new HashMap()); + copy.setBackDomain(cut.getBackDomain()); + copy.setFrontDomain(cut.getFrontDomain()); + Plane topPlane = new Plane(1, 0, 1, new Vertex(0, 0, length / 2)); + Plane bottomPlane = new Plane(-1, 0, 1, new Vertex(0 , 0, - length / 2)); + + Set surfaces = new HashSet(); + surfaces.add(copy); + copy.extrusionAllOnto(topPlane, surfaces, surfaces); + copy.extrusionAllOnto(bottomPlane, surfaces, surfaces); + Set<Vertex> verts = Geometry.collect(surfaces); + for (Vertex v: verts) { + v.move(0, 0, length / 2); + } + return surfaces; + } } |