[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor NetFacadeModellor.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2010-03-05 10:43:42
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv29134/src/net/sourceforge/bprocessor/facade/modellor Modified Files: NetFacadeModellor.java Log Message: Index: NetFacadeModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/NetFacadeModellor.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** NetFacadeModellor.java 5 Feb 2010 13:32:46 -0000 1.50 --- NetFacadeModellor.java 5 Mar 2010 10:43:34 -0000 1.51 *************** *** 32,90 **** import net.sourceforge.bprocessor.model.modellor.Modellor; - import org.apache.log4j.Logger; - /** ! * The new facade modellor using nets. ! * */ public class NetFacadeModellor extends Modellor { - /** Thickness of a generic door frame */ private static final double DOOR_FRAME = 0.12; - - /** Thickness of a generic window frame */ private static final double WINDOW_FRAME = 0.05; - - /** identation of the window and door frames into the main frame*/ private static final double FRAME_IDENTATION = 0.02; - - /** The depth of window and door frames */ private static final double FRAME_DEPTH = 0.05; ! /** The classification id for exterior */ ! public static final String EXTERIOR = "-1.-80"; ! ! /** The classification id for window frames */ ! public static final String FRAME = "-1.-205.02.01.01"; ! ! /** The classification id for window glass */ ! public static final String GLASS = "-1.-205.02.01.02"; ! ! /** serial id */ private static final long serialVersionUID = 1L; - - /** The space of the facade */ private Space space; - - /** The frame space */ private Space frame; - - /** The net for this facade */ private Space net; - - /** The framewidth of the facade */ private double frameWidth = 0.045; - - /** The depth of the facade */ private double depth = 0.12; - - /** The front surface of the facade */ private Surface front; - - /** Is the facade single posted or not */ private boolean single = true; - /** The logger */ - private static Logger log = Logger.getLogger(NetFacadeModellor.class); - /** * Empty constructor for the net facade --- 32,56 ---- import net.sourceforge.bprocessor.model.modellor.Modellor; /** ! * Net Facade Modellor */ public class NetFacadeModellor extends Modellor { private static final double DOOR_FRAME = 0.12; private static final double WINDOW_FRAME = 0.05; private static final double FRAME_IDENTATION = 0.02; private static final double FRAME_DEPTH = 0.05; + private static final String EXTERIOR = "-1.-80"; ! private static final String FRAME = "-1.-205.02.01.01"; ! private static final String GLASS = "-1.-205.02.01.02"; private static final long serialVersionUID = 1L; private Space space; private Space frame; private Space net; private double frameWidth = 0.045; private double depth = 0.12; private Surface front; private boolean single = true; /** * Empty constructor for the net facade *************** *** 166,206 **** /** ! * Update when an entity changes ! * @param entity the changed entity */ public void update(Object entity) { ! if (this.isActive()) { ! boolean update = false; ! if (entity instanceof Geometric) { ! Geometric geo = (Geometric)entity; ! if (geo == net || geo.getOwner() == net) { ! update = true; ! } ! } ! if (!update && ! (entity == this || ! entity == Project.getInstance())) { ! update = true; ! } ! if (!space.getEnvelope().contains(front)) { ! update = false; ! } ! if (space.getModellor() != this) { //sanity check ! update = false; ! delete(); ! } ! if (update) { ! regenerate(); ! } ! } ! } ! ! /** ! * Delete this modellor ! */ ! public void delete() { ! Project.getInstance().removeObserver(this); ! if (space.getModellor() == this) { ! space.setModellor(null); } } --- 132,140 ---- /** ! * {@inheritDoc} */ public void update(Object entity) { ! if (isActive()) { ! regenerate(); } } *************** *** 209,220 **** * {@inheritDoc} */ ! public void getAttributes(List<Attribute> l) { ! l.add(new Attribute("Net", net, true)); ! l.add(new Attribute("Front", front, true)); if (single) { ! l.add(new Attribute("Framewidth", new Double(frameWidth), true)); ! l.add(new Attribute("Depth", new Double(depth), true)); } ! l.add(new Attribute("Single", Boolean.valueOf(single), true)); } --- 143,154 ---- * {@inheritDoc} */ ! public void getAttributes(List<Attribute> lst) { ! lst.add(new Attribute("Net", net, true)); ! lst.add(new Attribute("Front", front, true)); if (single) { ! lst.add(new Attribute("Framewidth", new Double(frameWidth), true)); ! lst.add(new Attribute("Depth", new Double(depth), true)); } ! lst.add(new Attribute("Single", Boolean.valueOf(single), true)); } *************** *** 231,241 **** setFrameWidth(((Double)a.getValue()).doubleValue()); } - a = attributes.get("Framewidth"); - if (a != null) { - setFrameWidth(((Double)a.getValue()).doubleValue()); - } a = attributes.get("Depth"); if (a != null) { ! setDepth(((Double)a.getValue()).doubleValue()); } a = attributes.get("Single"); --- 165,171 ---- setFrameWidth(((Double)a.getValue()).doubleValue()); } a = attributes.get("Depth"); if (a != null) { ! depth = ((Double)a.getValue()).doubleValue(); } a = attributes.get("Single"); *************** *** 264,287 **** } ! /** ! *@return the space ! */ ! public Space getSpace() { ! return space; ! } ! ! /** ! * Set the space of this modellor ! * @param space the space ! */ ! public void setSpace(Space space) { this.space = space; } ! /** ! * get the net of the modellor ! * @return the net of this modellor ! */ ! public Space getNet() { return this.net; } --- 194,202 ---- } ! private void setSpace(Space space) { this.space = space; } ! private Space getNet() { return this.net; } *************** *** 291,295 **** * @param net the net */ ! public void setNet(Space net) { if (net.isNet()) { if (this.net != null) { --- 206,210 ---- * @param net the net */ ! private void setNet(Space net) { if (net.isNet()) { if (this.net != null) { *************** *** 300,317 **** } } - - /** - * Gets the framewidth of the facade - * @return the frameWidth - */ - public double getFrameWidth() { - return frameWidth; - } ! /** ! * Sets the framewidth of the facade ! * @param frameWidth the framewidth ! */ ! public void setFrameWidth(double frameWidth) { this.frameWidth = frameWidth; for (Edge e : net.getEdges()) { --- 215,220 ---- } } ! private void setFrameWidth(double frameWidth) { this.frameWidth = frameWidth; for (Edge e : net.getEdges()) { *************** *** 590,597 **** first.getFrom().getEdges().contains(outline.getLast())) { return outline; - } else { - log.warn("Outline not well defined, " + - " outer edges left: " + outer.size() + - " outline connected: " + first.getFrom().getEdges().contains(outline.getLast())); } } --- 493,496 ---- *************** *** 616,620 **** * @return front surface */ ! public Surface getFront() { return front; } --- 515,519 ---- * @return front surface */ ! private Surface getFront() { return front; } *************** *** 624,628 **** * @param front the front surface */ ! public void setFront(Surface front) { this.front = front; setNet(createNet(front)); --- 523,527 ---- * @param front the front surface */ ! private void setFront(Surface front) { this.front = front; setNet(createNet(front)); *************** *** 695,714 **** s2.setBackDomain(sp2); } - } - - /** - * 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; } --- 594,597 ---- *************** *** 725,729 **** * @param single if the facade should be single or not */ ! public void setSingle(boolean single) { this.single = single; } --- 608,612 ---- * @param single if the facade should be single or not */ ! private void setSingle(boolean single) { this.single = single; } *************** *** 740,851 **** } - private Set<Surface> generateFrame2(Surface cut, - Surface contourSurf, - Space frameSpace, - Vertex out) { - Set<Surface> generatedSurfaces = new HashSet<Surface>(); - if (contourSurf.getEdges().size() < 3) { - return generatedSurfaces; - } - if (!rightHand(contourSurf, out)) { - contourSurf.flip(); - } - List<Edge> contour = contourSurf.getEdges(); - - Edge first = contour.get(0); - Edge second = contour.get(1); - Vertex common = Edge.commonVertex(first, second); - Vertex unCommon = first.otherVertex(common); - Vertex firstDir = common.minus(unCommon); - if (cut.normal().dot(firstDir) > 0) { - cut.setFrontDomain(frameSpace); - } else { - cut.setBackDomain(frameSpace); - } - Vertex i = out.cross(firstDir); - firstDir.normalize(); - out.normalize(); - i.normalize(); - CoordinateSystem cs = new CoordinateSystem(i, out, firstDir, unCommon); - List<Edge> cutEdges = cut.getEdges(); - Geometry.unTranslateGeometry(Geometric.collect(cutEdges), cs); - - Edge current = first; - for (Edge next : contour) { - if (next == first) { - continue; - } - Collection<Surface> extrusion = makeExtrusion(current, next, cutEdges); - cutEdges = findNewCutEdges(cutEdges, extrusion); - generatedSurfaces.addAll(extrusion); - current = next; - } - Collection<Surface> extrusion = makeExtrusion(contour.get(contour.size() - 1), - first, cutEdges); - cutEdges = findNewCutEdges(cutEdges, extrusion); - for (int k = 0; k < cutEdges.size(); k++) { - Edge oldEdge = cut.getEdges().get(k); - for (Surface s : oldEdge.getSurfaces()) { - s.replace(oldEdge, cutEdges.get(k)); - } - } - generatedSurfaces.addAll(extrusion); - return generatedSurfaces; - } - - private static Collection<Surface> makeExtrusion(Edge e1, Edge e2, - List<Edge> cutEdges) { - double angle = Geometry.angle(e1, e2); - Vertex shared = Edge.commonVertex(e1, e2); - Vertex i = e2.otherVertex(shared).minus(shared); - Vertex j = e1.otherVertex(shared).minus(shared); - Vertex n = i.cross(j); - j = n.cross(i); - n.normalize(); - j.normalize(); - i.normalize(); - CoordinateSystem local = new CoordinateSystem(i, j, n, new Vertex(0, 0, 0)); - Vertex angleV = new Vertex(Math.sin(angle / 2), -Math.cos(angle / 2), 0); - angleV = local.unTranslate(angleV); - Plane plane = new Plane(angleV.getX(), angleV.getY(), angleV.getZ(), shared); - j.scaleIt(-1); - Collection<Surface> extrusion = Edge.extrude(cutEdges, j, plane); - return extrusion; - } - - private static List<Edge> findNewCutEdges(List<Edge> contour, Collection<Surface> extrusion) { - Map<Edge, Edge> old2new = new HashMap<Edge, Edge>(); - for (Surface s : extrusion) { - List<Edge> edges = s.getEdges(); - Edge contourEdge = null; - for (Edge e : edges) { - if (contour.contains(e)) { - contourEdge = e; - } - } - if (contourEdge == null) { - log.error("Surface: " + s + " was not extruded from contour: " + contour); - continue; - } - for (Edge e : edges) { - if (Edge.commonVertex(e, contourEdge) == null) { - old2new.put(contourEdge, e); - } - } - } - List<Edge> newContour = new LinkedList<Edge>(); - for (Edge old : contour) { - Edge edge = old2new.get(old); - if (edge != null) { - newContour.add(edge); - } else { - log.error("Contour edge: " + old + - " does not have an adjacent edge in: " + extrusion); - } - } - return newContour; - } - - /** * Generates a frame based an a surface descibing a cut of the frame --- 623,626 ---- *************** *** 1015,1017 **** --- 790,796 ---- return determinant > 0; } + + /** {@inheritDoc} */ + public void delete() { + } } |