[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor WindowModellor.java, 1.2
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-08-28 16:44:53
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8613/src/net/sourceforge/bprocessor/facade/modellor Modified Files: WindowModellor.java Log Message: made windmodellor, there are some bugs, will be worked out, there are one bug in offset as well. Index: WindowModellor.java =================================================================== RCS file: /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor/WindowModellor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WindowModellor.java 22 Aug 2006 14:15:15 -0000 1.2 --- WindowModellor.java 28 Aug 2006 16:44:44 -0000 1.3 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.bprocessor.facade.modellor; + import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; *************** *** 15,18 **** --- 16,20 ---- import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Space; *************** *** 24,31 **** public class WindowModellor extends Modellor { /** The width of the frame */ ! private double framewidth = 0.1; /** The depth of the frame */ ! private double framedepth = 0.075; /** The offset in the window */ --- 26,33 ---- public class WindowModellor extends Modellor { /** The width of the frame */ ! private double framewidth = 0.054; /** The depth of the frame */ ! private double framedepth = 0.125; /** The offset in the window */ *************** *** 61,64 **** --- 63,67 ---- space = s; surface = sur; + drawWindow(); } *************** *** 67,72 **** */ public void update(Object entity) { ! if (entity == space || entity == surface) { drawWindow(); } } --- 70,78 ---- */ public void update(Object entity) { ! if (entity == surface || entity == this) { ! System.out.println("did a update on the surface"); ! cleanUp(); drawWindow(); + Project.getInstance().checkpoint(); } } *************** *** 74,88 **** /** Draw the window */ public void drawWindow() { Space frame = new Space("Frame", Space.CONSTRUCTION, true); Space glass = new Space("Glass", Space.CONSTRUCTION, true); ! Surface inner = surface.copy(frame); Vertex normal = surface.normal(); normal.scale(-offset); ! inner.move(normal.getX(), normal.getY(), normal.getZ()); ! List offset = Edge.offset(inner.getEdges(), inner, framewidth); ! Surface glasssurface = new Surface(offset); inner.addHole(glasssurface); ! inner.setBackDomain(frame); space.add(frame); } --- 80,114 ---- /** Draw the window */ public void drawWindow() { + if (surface.getBackDomain() == space) { + surface.extrude(-(offset + framewidth), new HashSet()); + } else { + surface.extrude(offset + framewidth, new HashSet()); + } + Space frame = new Space("Frame", Space.CONSTRUCTION, true); Space glass = new Space("Glass", Space.CONSTRUCTION, true); ! glass.setTransparent(true); ! Surface inner = surface.copy(space); ! inner.setFrontDomain(frame); ! //make hole in frame Vertex normal = surface.normal(); normal.scale(-offset); ! inner.move(normal.getX(), normal.getY(), normal.getZ()); ! List holeedges = Edge.offset(inner.getEdges(), inner, -framewidth); ! Iterator iter = holeedges.iterator(); ! space.add(((Edge)holeedges.get(0)).getTo()); ! while (iter.hasNext()) { ! Edge e = (Edge)iter.next(); ! space.add(e.getFrom()); ! space.add(e); ! } ! Surface glasssurface = new Surface(holeedges); inner.addHole(glasssurface); ! space.add(glasssurface); ! glasssurface.setFrontDomain(glass); ! Surface frametop = inner.extrude(framedepth, new HashSet()); ! frametop.addHole(glasssurface.extrude(framedepth, new HashSet())); space.add(frame); + space.add(glass); } *************** *** 93,99 **** if (s.getSurfaces().size() == 1) { Surface sur = (Surface)s.getSurfaces().iterator().next(); ! opposite = sur.extrude(framedepth, new HashSet()); } ! return new WindowModellor(s, (Surface)s.getSurfaces().iterator().next()); } --- 119,159 ---- if (s.getSurfaces().size() == 1) { Surface sur = (Surface)s.getSurfaces().iterator().next(); ! Surface ext = sur.getExterior(); ! double minDist = Double.NaN; ! if (sur != null) { ! Collection tryout = new ArrayList(0); ! if (sur.getFrontDomain() == s) { ! Space front = ext.getFrontDomain(); ! if (front != null) { ! tryout = front.getEnvelope(); ! } ! System.out.println("frontdomain " + ext.getFrontDomain()); ! } else { ! Space back = ext.getBackDomain(); ! if (back != null) { ! tryout = back.getEnvelope(); ! } ! System.out.println("backdomain " + ext.getBackDomain()); ! } ! Iterator iter = tryout.iterator(); ! while (iter.hasNext()) { ! Surface cur = (Surface)iter.next(); ! Vertex center = cur.center(); ! Plane p = cur.plane(); ! Vertex inter = p.intersection(cur.center(), cur.normal(), true); ! System.out.println("Were here and internersection " + inter); ! double dist = center.distance(inter); ! if (inter != null && dist < minDist) { ! minDist = dist; ! System.out.println("Found a surface with dist " + dist); ! } ! } ! } ! if (Double.isNaN(minDist)) { ! minDist = framedepth + offset; ! } ! opposite = sur.extrude(minDist, new HashSet()); } ! return new WindowModellor(s, (Surface)(s.getEnvelope().iterator().next())); } *************** *** 102,105 **** --- 162,173 ---- */ public void delete() { + cleanUp(); + space.setModellor(null); + } + + /** + * Clean up the constructed geometry + */ + private void cleanUp() { Collection added = space.getElements(); Iterator iter = added.iterator(); *************** *** 118,124 **** } } - space.setModellor(null); } ! /** * @see net.sourceforge.bprocessor.model.Parametric#setAttributes(List) --- 186,191 ---- } } } ! /** * @see net.sourceforge.bprocessor.model.Parametric#setAttributes(List) *************** *** 157,161 **** */ public String getName() { ! return "Window-" + id; } --- 224,228 ---- */ public String getName() { ! return "Window"; } |