[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Project.java, 1.165, 1.166
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-05-12 11:02:18
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2027/src/net/sourceforge/bprocessor/model Modified Files: Project.java Log Message: New exporter for PPLM Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** Project.java 30 Apr 2009 11:55:08 -0000 1.165 --- Project.java 12 May 2009 11:02:03 -0000 1.166 *************** *** 1345,1352 **** } private Location createLocationModel(Container space, int level, ! Map<Surface, Location> locations, Map<Edge, List<Opening>> openings) { Location location = new Location(); ! location.setId(space.getName()); if (level == 1) { location.setDescription("Site"); --- 1345,1383 ---- } + + private List<Edge> bounds(List<Surface> surfaces) { + Command.Inverse inv = new Command.Inverse(surfaces); + Collection<Edge> soup = Surface.edges(surfaces); + List<Edge> loners = new LinkedList(); + for (Edge current : soup) { + List<Surface> lst = inv.surfaces(current); + if (lst.size() == 1) { + loners.add(current); + } + } + return Command.Offset.order(loners); + } + + private List<Location> createLocationModel(Container space, int level, + Map<Surface, Location> locations, Map<Edge, List<Opening>> openings) { + List<Location> locs = new LinkedList(); + List<Surface> envelope = new LinkedList(space.getEnvelope()); + int no = 0; + if (envelope.size() > 0) { + for (Surface current : envelope) { + no++; + locs.add(createLocationModel(space, level, locations, openings, current, no)); + } + } else { + locs.add(createLocationModel(space, level, locations, openings, null, no)); + } + return locs; + } + private Location createLocationModel(Container space, int level, ! Map<Surface, Location> locations, Map<Edge, List<Opening>> openings, ! Surface surface, int no) { Location location = new Location(); ! location.setId(space.getName() + no); if (level == 1) { location.setDescription("Site"); *************** *** 1359,1440 **** } ! { ! Set<Surface> envelope = space.getEnvelope(); ! ! if (envelope.size() == 1) { ! Surface surface = envelope.iterator().next(); ! List<Edge> all = new LinkedList(surface.getEdges()); ! List<Vertex> vertices = surface.getVertices(); ! Boundary boundary = new Boundary(convert(vertices)); ! location.setExternalBoundary(boundary); ! ! { ! List<Surface> holes = new LinkedList(surface.getHoles()); ! if (holes.size() > 0) { ! Command.Inverse inv = new Command.Inverse(holes); ! Collection<Edge> soup = Surface.edges(holes); ! List<Edge> loners = new LinkedList(); ! for (Edge current : soup) { ! List<Surface> lst = inv.surfaces(current); ! if (lst.size() == 1) { ! loners.add(current); ! } } ! ! all.addAll(loners); ! ! List<List<Edge>> internals = new LinkedList(); ! Set<Edge> bag = new HashSet(loners); ! while (!bag.isEmpty()) { ! List<Edge> partition = new LinkedList(); ! Queue<Edge> queue = new LinkedList(); ! Edge leader = bag.iterator().next(); ! bag.remove(leader); ! queue.add(leader); ! partition.add(leader); ! while (!queue.isEmpty()) { ! Edge current = queue.remove(); ! List<Edge> fl = inv.edges(current.from); ! List<Edge> tl = inv.edges(current.to); ! List<Edge> lst = new LinkedList(); ! lst.addAll(fl); ! lst.addAll(tl); ! for (Edge adjacant : lst) { ! if (bag.contains(adjacant)) { ! bag.remove(adjacant); ! partition.add(adjacant); ! queue.add(adjacant); ! } } } - internals.add(partition); - } - for (List<Edge> partition : internals) { - List<Edge> internal = Command.Offset.order(partition); - List<Vertex> verts = Command.Offset.vertices(internal); - Boundary b = new Boundary(convert(verts)); - location.addInternalBoundary(b); } } ! } ! ! ! locations.put(surface, location); ! int count = 1; ! for (Edge edge : all) { ! if (edge.isSmooth()) { ! Segment segment = convert(edge); ! segment = find(location, segment); ! Opening opening = new Opening(); ! opening.setId(String.valueOf(count++)); ! opening.setDistance(0.0); ! opening.setWidth(segment.getLength()); ! opening.setSegment(segment); ! location.addOpening(opening); ! List<Opening> lst = openings.get(edge); ! lst.add(opening); } } } } --- 1390,1474 ---- } ! if (surface != null) { ! List<Edge> all = new LinkedList(surface.getEdges()); ! List<Vertex> vertices = surface.getVertices(); ! ! { ! Vertex first = vertices.get(0); ! double z = first.getZ(); ! location.setFloor(z); ! location.setHeight(4); ! } ! ! Boundary boundary = new Boundary(convert(vertices)); ! location.setExternalBoundary(boundary); ! ! { ! List<Surface> holes = new LinkedList(surface.getHoles()); ! if (holes.size() > 0) { ! Command.Inverse inv = new Command.Inverse(holes); ! Collection<Edge> soup = Surface.edges(holes); ! List<Edge> loners = new LinkedList(); ! for (Edge current : soup) { ! List<Surface> lst = inv.surfaces(current); ! if (lst.size() == 1) { ! loners.add(current); } ! } ! ! all.addAll(loners); ! ! List<List<Edge>> internals = new LinkedList(); ! Set<Edge> bag = new HashSet(loners); ! while (!bag.isEmpty()) { ! List<Edge> partition = new LinkedList(); ! Queue<Edge> queue = new LinkedList(); ! Edge leader = bag.iterator().next(); ! bag.remove(leader); ! queue.add(leader); ! partition.add(leader); ! while (!queue.isEmpty()) { ! Edge current = queue.remove(); ! List<Edge> fl = inv.edges(current.from); ! List<Edge> tl = inv.edges(current.to); ! List<Edge> lst = new LinkedList(); ! lst.addAll(fl); ! lst.addAll(tl); ! for (Edge adjacant : lst) { ! if (bag.contains(adjacant)) { ! bag.remove(adjacant); ! partition.add(adjacant); ! queue.add(adjacant); } } } + internals.add(partition); } ! for (List<Edge> partition : internals) { ! List<Edge> internal = Command.Offset.order(partition); ! List<Vertex> verts = Command.Offset.vertices(internal); ! Boundary b = new Boundary(convert(verts)); ! location.addInternalBoundary(b); } } } + + + locations.put(surface, location); + int count = 1; + for (Edge edge : all) { + if (edge.isSmooth()) { + Segment segment = convert(edge); + segment = find(location, segment); + Opening opening = new Opening(); + opening.setId(String.valueOf(count++)); + opening.setDistance(0.0); + opening.setWidth(segment.getLength()); + opening.setSegment(segment); + location.addOpening(opening); + List<Opening> lst = openings.get(edge); + lst.add(opening); + } + } } *************** *** 1451,1456 **** for (Space element : space.getElements()) { if (!element.isVoid()) { ! Location child = createLocationModel((Container) element, level + 1, s2l, e2o); ! location.addChild(child); } } --- 1485,1492 ---- for (Space element : space.getElements()) { if (!element.isVoid()) { ! List<Location> children = createLocationModel((Container) element, level + 1, s2l, e2o); ! for (Location child : children) { ! location.addChild(child); ! } } } *************** *** 1569,1573 **** public void exportPPLM(OutputStream out) { world().setName(getName()); ! Location root = createLocationModel(world(), 1, new HashMap(), new HashMap()); LocationModel model = new LocationModel(); model.setLocation(root); --- 1605,1610 ---- public void exportPPLM(OutputStream out) { world().setName(getName()); ! List<Location> roots = createLocationModel(world(), 1, new HashMap(), new HashMap()); ! Location root = roots.get(0); LocationModel model = new LocationModel(); model.setLocation(root); |