[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model/plugin NetCommand.java, NONE, 1.1 F
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2010-09-06 13:08:44
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9074/src/net/sourceforge/bprocessor/model/plugin Added Files: NetCommand.java FacadePackage.java Log Message: --- NEW FILE: NetCommand.java --- package net.sourceforge.bprocessor.model.plugin; import net.sourceforge.bprocessor.model.Command; import net.sourceforge.bprocessor.model.Space; public abstract class NetCommand extends Command { public abstract void initialize(Space net); } --- NEW FILE: FacadePackage.java --- package net.sourceforge.bprocessor.model.plugin; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import net.sourceforge.bprocessor.model.Command; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Item; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; public class FacadePackage { /** * */ public static class Frame extends NetCommand { public void initialize(Space net) { parameters.put("net", net); parameters.put("frame-width", 0.035); parameters.put("interior-width", 0.035); parameters.put("depth", 0.07); parameters.put("frame name", "Frame"); parameters.put("exterior name", "Exterior"); parameters.put("hole name", "Hole"); } /** * {@inheritDoc} */ public String title() { // this is the title shown on top of the parameters section return "Frame Net"; } private List<Edge> simplify(List<Edge> edges) { // what exactly do you simplify here and why? if (edges.size() > 3) { List<Edge> result = new LinkedList(); List<Vertex> vertices = Offset.vertices(edges); LinkedList<Vertex> live = new LinkedList(); { int n = vertices.size(); Vertex previous = vertices.get(n - 1); Vertex current = vertices.get(0); Vertex next = null; for (int i = 0; i < n; i++) { next = vertices.get((i + 1) % n); // the reuslt is always i+1, only if i is already the last edge in the list, the operation will return 0 Vertex u = current.minus(previous); Vertex v = next.minus(current); Vertex cross = u.cross(v); if (!cross.isZero()) { //this excludes parallel vectors and vectors of length 0 live.add(current); } previous = current; current = next; } } Vertex previous = live.getLast(); for (Vertex current : live) { result.add(new Edge(previous, current)); previous = current; } return result; } else { return edges; } } /** {@inheritDoc} */ @Override public void evaluate() { Space net = (Space) parameters.get("net"); double inside = parameters.getDouble("frame-width"); double delta = parameters.getDouble("interior-width"); double depth = parameters.getDouble("depth"); String frameName = (String) parameters.get("frame name"); String exteriorName = (String) parameters.get("exterior name"); String holeName = (String) parameters.get("hole name"); List<Surface> surfaces = new LinkedList(); { HashMap map = new HashMap(); for (Surface current : net.getSurfaces()) { surfaces.add((Surface) current.copy(map)); //what happens here? } } List<Edge> boundary = new LinkedList(); { Inverse inv = new Inverse(surfaces); // inverse? for (Edge current : inv.edges()) { Collection<Surface> adjacant = inv.surfaces(current); if (adjacant.size() == 1) { // if an edge only is adjacent to 1 surface it is a border edge boundary.add(current); } } boundary = Offset.order(boundary); //order? does offset basically create a copy here? } if (boundary.size() > 0) { Offset.offsetIt(boundary, -inside + (delta / 2)); Space union = (Space) net.getOwner().find("Frame"); //check if the frame is created or redrawn... if (union == null) { union = Item.createUnion("Frame"); net.getOwner().add(union); } else { union.clear(); } Collection<Surface> inserted = new LinkedList(); Surface exterior = null; List<Edge> offset = Offset.offset(boundary, inside - (delta / 2)); //offset the boundary to the inside by the frame width minus half the interior width exterior = new Surface(simplify(offset)); inserted.add(exterior); List<Surface> interior = new LinkedList(); for (Surface current : surfaces) { List<Edge> curve = Offset.offset(current.getEdges(), -delta / 2); //offset all surfaces by half the interior width interior.add(new Surface(simplify(curve))); } inserted.addAll(interior); for (Surface current : interior) { exterior.addHole(current); } Set<Surface> tops = new HashSet(); if (depth != 0) { Collection<Surface> sides = new LinkedList(); Surface top = exterior.extrusionall(depth, sides, tops); inserted.addAll(sides); inserted.addAll(tops); inserted.add(top); } Shape.addSurfacesTo(union, inserted); //add geometry to the space { Space ext = Item.createFunctionalSpace(exteriorName); Space frame = Item.createConstructionSpace(frameName); // ?????????????? What happens here? Do you assign the surface sides to the adjacent spaces? These are named in the paramters, right? if (depth > 0) { exterior.assignBack(ext, true); exterior.assignFront(frame, true); } else { exterior.assignFront(ext, true); exterior.assignBack(frame, true); } union.add(ext); union.add(frame); Vertex n1 = exterior.normal(); int i = 0; for (Surface current : interior) { i++; Vertex n2 = current.normal(); double sign; if (n1.dot(n2) < 0) { //what does the dot product of two vectors tell me? sign = -depth; } else { sign = depth; } Space hole = Item.createFunctionalSpace(holeName + " " + i); if (sign > 0) { current.assignFront(hole, true); current.setBackDomain(ext); } else { current.assignBack(hole, true); current.setFrontDomain(ext); } for (Surface s : tops) { if (s.getBackDomain().isVoid()) { s.setBackDomain(ext); } if (s.getFrontDomain().isVoid()) { s.setFrontDomain(ext); } } for (Surface s : hole.getEnvelope()) { if (s.getBackDomain().isVoid()) { s.setBackDomain(frame); } if (s.getFrontDomain().isVoid()) { s.setFrontDomain(frame); } } union.add(hole); } } } } } public FacadePackage() { Command.register(Frame.class); } } |