[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor NetFacadeModellor.java,
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Nordholt <nor...@us...> - 2006-12-04 11:51:39
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2407/src/net/sourceforge/bprocessor/facade/modellor Modified Files: NetFacadeModellor.java Log Message: now makes single posted facades Index: NetFacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/NetFacadeModellor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NetFacadeModellor.java 28 Nov 2006 17:53:05 -0000 1.3 --- NetFacadeModellor.java 4 Dec 2006 11:51:29 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; + import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.modellor.Modellor; *************** *** 148,152 **** } else if (att.getName().equals("Framewidth")) { setFrameWidth(((Double)att.getValue()).doubleValue()); ! } } } --- 149,155 ---- } else if (att.getName().equals("Framewidth")) { setFrameWidth(((Double)att.getValue()).doubleValue()); ! } else if (att.getName().equals("Depth")) { ! setDepth(((Double)att.getValue()).doubleValue()); ! } } } *************** *** 211,218 **** */ private void regenerate() { ! space.setEdges(new HashMap()); ! space.setSurfaces(new HashMap()); ! space.setVertices(new HashMap()); ! createFacade(net); } --- 214,220 ---- */ private void regenerate() { ! space.clear(); ! space.add(net); ! createSingleFacade(net); } *************** *** 221,225 **** * @param net the net */ ! private void createFacade(Net net) { if (frame == null) { frame = new Space("Frame", Space.CONSTRUCTION, --- 223,227 ---- * @param net the net */ ! private void createDoubleFacade(Net net) { if (frame == null) { frame = new Space("Frame", Space.CONSTRUCTION, *************** *** 232,243 **** Surface field = (Surface)fields.next(); Surface fcopy = field.copyall(space); ! Surface h = null; ! Iterator edge = fcopy.getEdges().iterator(); ! if (edge.hasNext()) { ! Edge e = (Edge)edge.next(); ! h = new Surface(e.offset(fcopy.getEdges(), fcopy, -frameWidth)); ! h = space.insert(h); ! Geometry.holeAnalysis(h); ! } assignSame(front, fcopy, space, frame); Set sides = new HashSet(); --- 234,240 ---- Surface field = (Surface)fields.next(); Surface fcopy = field.copyall(space); ! Surface h = new Surface(Edge.offset(fcopy.getEdges(), fcopy, -frameWidth)); ! h = space.insert(h); ! Geometry.holeAnalysis(h); assignSame(front, fcopy, space, frame); Set sides = new HashSet(); *************** *** 250,253 **** --- 247,353 ---- /** + * Creates a facade from a net. + * @param net the net + */ + private void createSingleFacade(Net net) { + if (frame == null) { + frame = new Space("Frame", Space.CONSTRUCTION, + Space.ELEMENT_LEVEL, true); + space.add(frame); + } + if (net != null) { + List outlineCopies = new LinkedList(); + Iterator outline = netOutline(net).iterator(); + while (outline.hasNext()) { + outlineCopies.add(((Edge)outline.next()).copy()); + } + if (!outlineCopies.isEmpty()) { + log.info("there is a outline"); + /* make the shell of the facade */ + Surface frameSurface = new Surface(outlineCopies); + space.insert(frameSurface); + assignSame(front, frameSurface, space, frame); + Set sides1 = new HashSet(); + extrudeIntoSpace(frameSurface, depth, sides1); + /* Put holes int the shell */ + Iterator fields = net.getSurfaces().iterator(); + while (fields.hasNext()) { + Surface field = (Surface)fields.next(); + Surface fcopy = field.copyall(space); + fcopy.delete(); + Surface hole = new Surface(Edge.offset(fcopy.getEdges(), fcopy, -frameWidth)); + hole = space.insert(hole); + Geometry.holeAnalysis(hole); + Set sides2 = new HashSet(); + Geometry.holeAnalysis(space.insert(extrudeIntoSpace(hole, depth, sides2))); + } + } + } + } + + /** + * Finds the outline of a net, if it makes sence. + * The outline most be a sequence of connected outer edges, so that + * the last edge is connected to the first. Also all outer edges most be + * in the outline. + * @param net a net + * @return a list of connected edges making up the net outline + */ + private List netOutline(Net net) { + log.info("finding outline"); + /*Find outer edges*/ + Iterator edges = net.getEdges().iterator(); + Set outer = new HashSet(); + while (edges.hasNext()) { + Edge current = (Edge)edges.next(); + if (current.getSurfaces().size() == 1) { + outer.add(current); + } + Iterator it = current.getSurfaces().iterator(); + while (it.hasNext()) { + log.info(current + " surface:" + it.next()); + } + } + /*If there are outer edges sort them in order*/ + if (!outer.isEmpty()) { + LinkedList outline = new LinkedList(); + Edge first = (Edge)outer.iterator().next(); + outline.add(first); + outer.remove(first); + Vertex nextVertex = first.getTo(); + boolean doneAll = false; + while (!doneAll) { + Edge next = null; + 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; + } + } + if (next != null) { + outer.remove(next); + nextVertex = next.otherVertex(nextVertex); + outline.add(next); + } else { + doneAll = true; + } + } + /*If all outer edges are in the outline, + * and the last edge is connected to the first, + * return the outline */ + if (outer.isEmpty() && + first.getFrom().getEdges().contains(outline.getLast())) { + return outline; + } else { + log.warn("Outline not well defined"); + } + } + return new LinkedList(); + } + + /** * Creates a net the size of a suface. * @param front the front surface *************** *** 319,321 **** --- 419,437 ---- } } + + /** + * Gets the depth of the facade + * @return the depth of this facade + */ + public double getDepth() { + return depth; + } + + /** + * Set the facade depth + * @param depth the new depth + */ + public void setDepth(double depth) { + this.depth = depth; + } } |