Thread: [Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor FacadeModellor.java, 1.3
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-08-21 09:33:21
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2430/src/net/sourceforge/bprocessor/facade/modellor Modified Files: FacadeModellor.java Log Message: Some more work on the facade modellor Index: FacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/FacadeModellor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FacadeModellor.java 16 Aug 2006 09:32:31 -0000 1.3 --- FacadeModellor.java 21 Aug 2006 09:33:12 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- import net.sourceforge.bprocessor.model.Line; import net.sourceforge.bprocessor.model.Constructor; + import net.sourceforge.bprocessor.model.Geometry; import org.apache.log4j.Logger; *************** *** 39,52 **** /** Number of vertical posts */ ! private int vertPosts = -1; /** Number of horizontal posts */ ! private int horPosts = -1; /** Default vertical post width */ ! private double vertPostWidth; /** Default horizontal post width */ ! private double horPostWidth; /** The space this modellor is connected to */ --- 40,53 ---- /** Number of vertical posts */ ! private int vertPosts = 0; /** Number of horizontal posts */ ! private int horPosts = 0; /** Default vertical post width */ ! private double vertPostWidth = 0; /** Default horizontal post width */ ! private double horPostWidth = 0; /** The space this modellor is connected to */ *************** *** 61,65 **** /** The set of horizontal constructor lines */ private Set horCons = new HashSet(); ! /** The constructor */ public FacadeModellor() { --- 62,81 ---- /** The set of horizontal constructor lines */ private Set horCons = new HashSet(); ! ! /** Thickness of the frame */ ! private double frameThickness = 0; ! ! /** Facade depth */ ! private double depth = 0; ! ! /** The frame space */ ! private Space frame; ! ! /** The surfaces of the frame */ ! private Set frameSurfaces = new HashSet(); ! ! /** frame present */ ! private boolean present = false; ! /** The constructor */ public FacadeModellor() { *************** *** 94,145 **** */ public void update(Object entity) { ! if (this.front != null) { ! List edges = this.front.getEdges(); ! if (edges.size() == 4) { ! Iterator it = edges.iterator(); ! Edge vertEdge = null; ! 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; ! } ! } ! if (horEdge != null && vertEdge != null) { ! Vertex cross; ! if (horEdge.contains(vertEdge.getFrom())) { ! cross = vertEdge.getFrom(); ! } else { ! cross = vertEdge.getTo(); ! } ! Vertex horDir = horEdge.otherVertex(cross).minus(cross); ! Vertex vertDir = vertEdge.otherVertex(cross).minus(cross); ! removeConstructors(vertCons); ! removeConstructors(horCons); ! vertCons = new HashSet(); ! horCons = new HashSet(); ! double interval = horEdge.getLength() / (vertPosts + 1); ! for (int i = 1; i < vertPosts + 1; i++) { ! Vertex offset = horDir.copy(); ! offset.scale((interval * i) / offset.length()); ! Line l = new Line(cross.add(offset), vertDir.copy(), true); ! vertCons.add(l); ! space.add(l); ! } ! interval = vertEdge.getLength() / (horPosts + 1); ! for (int i = 1; i < horPosts + 1; i++) { ! Vertex offset = vertDir.copy(); ! offset.scale((interval * i) / offset.length()); ! Line l = new Line(cross.add(offset), horDir.copy(), true); ! horCons.add(l); ! space.add(l); ! } ! } ! } } } --- 110,116 ---- */ public void update(Object entity) { ! if (entity == front) { ! createPostConstructors(); ! createFrame(); } } *************** *** 165,179 **** Attribute a = (Attribute)it.next(); if (a.getName().equals("Name")) { name = (String)a.getValue(); } else if (a.getName().equals("Front")) { ! front = (Surface)a.getValue(); } else if (a.getName().equals("V-posts")) { ! vertPosts = ((Double)a.getValue()).intValue(); } else if (a.getName().equals("H-posts")) { ! horPosts = ((Double)a.getValue()).intValue(); } else if (a.getName().equals("V-postwidth")) { vertPostWidth = ((Double)a.getValue()).doubleValue(); } else if (a.getName().equals("H-postwidth")) { horPostWidth = ((Double)a.getValue()).doubleValue(); } } --- 136,184 ---- Attribute a = (Attribute)it.next(); if (a.getName().equals("Name")) { + Project.getInstance().checkpoint(); name = (String)a.getValue(); } else if (a.getName().equals("Front")) { ! Iterator sit = Project.getInstance().getSurfaces().iterator(); ! while (sit.hasNext()) { ! Project.getInstance().checkpoint(); ! Surface s = (Surface)sit.next(); ! if (s.getName().equals(a.getValue())) { ! front = s; ! } ! } } else if (a.getName().equals("V-posts")) { ! int n = ((Double)a.getValue()).intValue(); ! if (n != vertPosts) { ! Project.getInstance().checkpoint(); ! vertPosts = n; ! createPostConstructors(); ! } } else if (a.getName().equals("H-posts")) { ! int n = ((Double)a.getValue()).intValue(); ! if (n != horPosts) { ! Project.getInstance().checkpoint(); ! 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(); + if (n != frameThickness) { + Project.getInstance().checkpoint(); + frameThickness = n; + createFrame(); + createPostConstructors(); + } + } else if (a.getName().equals("Depth")) { + double n = ((Double)a.getValue()).doubleValue(); + if (n != depth) { + Project.getInstance().checkpoint(); + depth = n; + createFrame(); + createPostConstructors(); + } } } *************** *** 193,196 **** --- 198,203 ---- 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; } *************** *** 213,216 **** --- 220,374 ---- /** Delete */ public void delete() { + space.setModellor(null); + } + + /** + * Creates the frame for this facade based on frame thickness and depth. + */ + private void createFrame() { + if (front != null && + frameThickness > 0 && + depth > 0) { + removeFrame(); + 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()) { + 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); + 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(); + while (sidesIt.hasNext()) { + space.add((Surface)sidesIt.next()); + } + sides = new HashSet(); + Surface top = h.extrude(depth, sides); + frameSurfaces.add(top); + Geometry.holeAnalysis(top); + frameSurfaces.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(); + while (it.hasNext()) { + ((Surface)it.next()).delete(); + } + frameSurfaces = new HashSet(); + frame.delete(); + } + } + + /** + * Creates the post constructors for this facade based on the number of posts. + */ + private void createPostConstructors() { + if (this.front != null) { + List edges = this.front.getEdges(); + if (edges.size() == 4) { + Iterator it = edges.iterator(); + Edge vertEdge = null; + 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; + } + } + if (horEdge != null && vertEdge != null) { + Vertex cross; + if (horEdge.contains(vertEdge.getFrom())) { + cross = vertEdge.getFrom(); + } else { + cross = vertEdge.getTo(); + } + Vertex horDir = horEdge.otherVertex(cross).minus(cross); + Vertex vertDir = vertEdge.otherVertex(cross).minus(cross); + 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); + } + } + } + } + } + + /** + * Creates the posts for the facade based on the post constructors, + * the post width and the depth. + * + */ + private void createPosts() { + + } + /** + * + * + */ + private void createColumn() { + } } |