Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3177/src/net/sourceforge/bprocessor/model
Modified Files:
Project.java
Log Message:
Save as jlma
Index: Project.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v
retrieving revision 1.157
retrieving revision 1.158
diff -C2 -d -r1.157 -r1.158
*** Project.java 4 Feb 2009 15:09:52 -0000 1.157
--- Project.java 12 Feb 2009 12:35:20 -0000 1.158
***************
*** 14,17 ****
--- 14,19 ----
import java.io.InputStream;
import java.io.OutputStream;
+ import java.io.PrintStream;
+
import java.net.InetAddress;
import java.net.InetSocketAddress;
***************
*** 43,46 ****
--- 45,53 ----
import org.apache.log4j.Logger;
+ import dk.au.perpos.spatialsupport.routefinding.Boundary;
+ import dk.au.perpos.spatialsupport.routefinding.Location;
+ import dk.au.perpos.spatialsupport.routefinding.Opening;
+ import dk.au.perpos.spatialsupport.routefinding.Segment;
+
/**
* The Project
***************
*** 1257,1260 ****
--- 1264,1362 ----
return library;
}
+
+ /**
+ *
+ */
+ public void export() {
+ Location root = new Location();
+ root.setId("building");
+ root.setDescription("none");
+ Map<Surface, Location> map = new HashMap();
+ Map<Edge, List<Surface>> e2s = new HashMap();
+ for (Edge edge : world().getEdges()) {
+ e2s.put(edge, new LinkedList());
+ }
+ for (Surface surface : world().getSurfaces()) {
+
+ for (Edge edge : surface.getEdges()) {
+ List<Surface> surfaces = e2s.get(edge);
+ surfaces.add(surface);
+ }
+ Location node = new Location();
+ map.put(surface, node);
+
+ List<dk.au.perpos.spatialsupport.routefinding.Point> points = new LinkedList();
+ for (Vertex vertex : surface.getVertices()) {
+ dk.au.perpos.spatialsupport.routefinding.Point point
+ = new dk.au.perpos.spatialsupport.routefinding.Point();
+ point.setX(vertex.getX());
+ point.setY(vertex.getY());
+ points.add(point);
+ }
+ Boundary area = new Boundary();
+ {
+ dk.au.perpos.spatialsupport.routefinding.Point previous = points.get(points.size() - 1);
+ for (dk.au.perpos.spatialsupport.routefinding.Point current : points) {
+ Segment segment = new Segment();
+ segment.setFrom(previous);
+ segment.setTo(current);
+ area.add(segment);
+ previous = current;
+ }
+ }
+
+ node.setExternalBoundary(area);
+ Space front = surface.getFrontDomain();
+ Space back = surface.getBackDomain();
+ String name = "room";
+ if (!front.isVoid()) {
+ name = front.getName();
+ }
+ if (!back.isVoid()) {
+ name = back.getName();
+ }
+ node.setId(name);
+ node.setDescription("cell");
+ root.addChild(node);
+ }
+ for (Edge edge : world.getEdges()) {
+ if (edge.isSmooth()) {
+ List<Surface> surfaces = e2s.get(edge);
+ Surface s1 = surfaces.get(0);
+ Surface s2 = surfaces.get(1);
+ Location n1 = map.get(s1);
+ Location n2 = map.get(s2);
+ Opening o1 = new Opening();
+ n1.addOpening(o1);
+ Opening o2 = new Opening();
+ n2.addOpening(o2);
+ dk.au.perpos.spatialsupport.routefinding.Connection connection
+ = new dk.au.perpos.spatialsupport.routefinding.Connection();
+ connection.setFrom(o1);
+ connection.setTo(o2);
+ }
+ }
+ PrintStream out = System.out;
+ out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
+ out.println("<GST>");
+ out.println("<GSTNode name=\"bygning\">");
+ for (Location node : root.getChildren()) {
+ out.println("<GSTNode name =\"" + node.getId() + "\">");
+ out.println("<Area>");
+ for (dk.au.perpos.spatialsupport.routefinding.Point point
+ : node.getExternalBoundary().getPoints()) {
+ out.println("<Point2D x=\"" + point.getX() + "\" y=\"" + point.getY() + "\" />");
+ }
+ out.println("</Area>");
+ out.println("<Type type=\"" + node.getDescription() + "\" />");
+ for (Location other : node.getConnected()) {
+ out.println("<Connected to=\"ali://bygning/" + other.getId() + "\" />");
+ }
+ out.println("</GSTNode>");
+
+ }
+ out.println("</GSTNode>");
+ out.println("</GST>");
+ }
/**
|