[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Surface.java,1.40,1.41 Geometry.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-10-21 08:40:19
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Geometry.java Log Message: Implemented first version of Geometry.insert(edges), that calculates surfaces Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Surface.java 18 Oct 2005 08:17:07 -0000 1.40 --- Surface.java 21 Oct 2005 08:40:11 -0000 1.41 *************** *** 276,282 **** */ public double angle() { List vertexlist = getVertices(); - CoordinateSystem coordinateSystem = coordinateSystem(); vertexlist = coordinateSystem.translate(vertexlist); --- 276,290 ---- */ public double angle() { + return angle(coordinateSystem()); + } + + /** + * Compute the traversed angle of this Surface + * @param coordinateSystem The CoordinateSystem + * @return The angle + */ + public double angle(CoordinateSystem coordinateSystem) { List vertexlist = getVertices(); vertexlist = coordinateSystem.translate(vertexlist); *************** *** 775,780 **** */ public String toString() { ! return "Surface[id=" + id + ",name=" + name + ",constructor=" + constructor + ! ",edges=" + edges == null ? "0" : edges.size() + "]"; } } --- 783,787 ---- */ public String toString() { ! return "Surface[id=" + id + " " + name + " #" + edges.size() + "]"; } } Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Geometry.java 18 Oct 2005 08:17:07 -0000 1.1 --- Geometry.java 21 Oct 2005 08:40:11 -0000 1.2 *************** *** 30,36 **** Edge first = (Edge) edges.get(0); Edge last = (Edge) edges.get(edges.size() - 1); ! Vertex from = first.getFrom(); ! Set siblings = from.getEdges(); siblings.remove(first); siblings.remove(last); --- 30,36 ---- Edge first = (Edge) edges.get(0); Edge last = (Edge) edges.get(edges.size() - 1); ! Vertex to = last.getTo(); ! Set siblings = to.getEdges(); siblings.remove(first); siblings.remove(last); *************** *** 40,50 **** System.out.println(siblings); Edge current = (Edge) siblings.iterator().next(); ! CoordinateSystem system = new CoordinateSystem(first, current); ! VertexNode node = new VertexNode(from, system); ! node.insert(first); siblings = node.insert(siblings); node.sort(); System.out.println("-- NODE --"); System.out.println(node); System.out.println("----------"); } --- 40,51 ---- System.out.println(siblings); Edge current = (Edge) siblings.iterator().next(); ! CoordinateSystem system = new CoordinateSystem(last, current); ! VertexNode node = new VertexNode(to, system); ! EdgeNode lastEdgeNode = node.insert(last); siblings = node.insert(siblings); node.sort(); System.out.println("-- NODE --"); System.out.println(node); + findSurfaces(node, lastEdgeNode, edges); System.out.println("----------"); } *************** *** 55,64 **** * of the VertexNode * @param vertex The Vertex ! * @param first The first EdgeNode * @param edges The edges */ ! private static void findSurfaces(VertexNode vertex, EdgeNode first, List edges) { ! Surface clockwise = clockwiseSurface(vertex, first, edges); ! Project.getInstance().intern(clockwise); } --- 56,91 ---- * of the VertexNode * @param vertex The Vertex ! * @param last The first EdgeNode * @param edges The edges */ ! private static void findSurfaces(VertexNode vertex, EdgeNode last, List edges) { ! { ! Surface clockwise = clockwiseSurface(vertex, last, edges); ! if (clockwise != null) { ! Project.getInstance().intern(clockwise); ! System.out.println("interning " + clockwise); ! List vertices = clockwise.getVertices(); ! Iterator iter = vertices.iterator(); ! while (iter.hasNext()) { ! Vertex current = (Vertex) iter.next(); ! System.out.println(current); ! } ! System.out.println("angle = " + clockwise.angle(vertex.system())); ! } ! } ! { ! Surface counterclockwise = counterclockwiseSurface(vertex, last, edges); ! if (counterclockwise != null) { ! Project.getInstance().intern(counterclockwise); ! System.out.println("interning " + counterclockwise); ! List vertices = counterclockwise.getVertices(); ! Iterator iter = vertices.iterator(); ! while (iter.hasNext()) { ! Vertex current = (Vertex) iter.next(); ! System.out.println(current); ! } ! System.out.println("angle = " + counterclockwise.angle(vertex.system())); ! } ! } } *************** *** 67,75 **** * the VertexNode * @param vertex The Vertex ! * @param first The first EdgeNode * @param edges The edges * @return The Surface */ ! private static Surface clockwiseSurface(VertexNode vertex, EdgeNode first, List edges) { ArrayList result = new ArrayList(); result.addAll(edges); --- 94,102 ---- * the VertexNode * @param vertex The Vertex ! * @param last The first EdgeNode * @param edges The edges * @return The Surface */ ! private static Surface clockwiseSurface(VertexNode vertex, EdgeNode last, List edges) { ArrayList result = new ArrayList(); result.addAll(edges); *************** *** 78,90 **** Vertex to = ((Edge) edges.get(edges.size() - 1)).getTo(); ! EdgeNode currentEdge = first; VertexNode current = vertex; ! while (current.vertex() != to) { ! currentEdge = current.clockwise(currentEdge); result.add(currentEdge.edge()); current = currentEdge.other(current); } ! return new Surface("", result); } --- 105,149 ---- Vertex to = ((Edge) edges.get(edges.size() - 1)).getTo(); ! EdgeNode currentEdge = last; VertexNode current = vertex; ! while (current.vertex() != from) { ! currentEdge = current.clockwise(currentEdge.edge()); ! if (result.contains(currentEdge.edge())) { ! return null; ! } result.add(currentEdge.edge()); current = currentEdge.other(current); } ! return new Surface("Clockwise Surface", result); ! } ! ! /** ! * Find the counterclockwise surface that edges forms in the coordinate system of ! * the VertexNode ! * @param vertex The Vertex ! * @param last The first EdgeNode ! * @param edges The edges ! * @return The Surface ! */ ! private static Surface counterclockwiseSurface(VertexNode vertex, EdgeNode last, List edges) { ! ArrayList result = new ArrayList(); ! result.addAll(edges); ! ! Vertex from = ((Edge) edges.get(0)).getFrom(); ! Vertex to = ((Edge) edges.get(edges.size() - 1)).getTo(); ! ! EdgeNode currentEdge = last; ! VertexNode current = vertex; ! ! while (current.vertex() != from) { ! currentEdge = current.counterclockwise(currentEdge.edge()); ! if (result.contains(currentEdge.edge())) { ! return null; ! } ! result.add(currentEdge.edge()); ! current = currentEdge.other(current); ! } ! return new Surface("Counterclockwise Surface", result); } *************** *** 123,127 **** while (iter.hasNext()) { Edge current = (Edge) iter.next(); ! if (insert(current) != null) { result.add(current); } --- 182,186 ---- while (iter.hasNext()) { Edge current = (Edge) iter.next(); ! if (insert(current) == null) { result.add(current); } *************** *** 203,210 **** LinkedList result = new LinkedList(); for (int i = 0; i < rights.length; i++) { ! result.addLast(((EdgeNode) rights[i]).edge); } for (int i = 0; i < lefts.length; i++) { ! result.addLast(((EdgeNode) lefts[i]).edge); } edgenodes = result; --- 262,269 ---- LinkedList result = new LinkedList(); for (int i = 0; i < rights.length; i++) { ! result.addLast(((EdgeNode) rights[i])); } for (int i = 0; i < lefts.length; i++) { ! result.addLast(((EdgeNode) lefts[i])); } edgenodes = result; *************** *** 216,224 **** * @return The counterclockwise edgenode */ ! public EdgeNode counterclockwise(EdgeNode edge) { Object[] sorted = edgenodes.toArray(); int index = 0; for (int i = 0; i < sorted.length; i++) { ! if (sorted[i] == edge) { index = i; } --- 275,283 ---- * @return The counterclockwise edgenode */ ! public EdgeNode counterclockwise(Edge edge) { Object[] sorted = edgenodes.toArray(); int index = 0; for (int i = 0; i < sorted.length; i++) { ! if (((EdgeNode) sorted[i]).edge() == edge) { index = i; } *************** *** 234,245 **** /** * Return the edgenode clockwise around the vertex from the edge ! * @param edge The edgenode * @return The clockwise edgenode */ ! public EdgeNode clockwise(EdgeNode edge) { Object[] sorted = edgenodes.toArray(); int index = 0; for (int i = 0; i < sorted.length; i++) { ! if (sorted[i] == edge) { index = i; } --- 293,304 ---- /** * Return the edgenode clockwise around the vertex from the edge ! * @param edge The edgen * @return The clockwise edgenode */ ! public EdgeNode clockwise(Edge edge) { Object[] sorted = edgenodes.toArray(); int index = 0; for (int i = 0; i < sorted.length; i++) { ! if (((EdgeNode) sorted[i]).edge() == edge) { index = i; } *************** *** 310,316 **** VertexNode result = new VertexNode(other, system); Set edges = other.getEdges(); - edges.remove(edge); result.insert(edges); - result.insert(this); result.sort(); return result; --- 369,373 ---- |