[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model SurfaceAnalysis.java, 1.6, 1.7
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-03-29 09:38:39
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23246/src/net/sourceforge/bprocessor/model Modified Files: SurfaceAnalysis.java Log Message: Finished improved geometry insertion algorithm Index: SurfaceAnalysis.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/SurfaceAnalysis.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SurfaceAnalysis.java 28 Mar 2007 13:52:06 -0000 1.6 --- SurfaceAnalysis.java 29 Mar 2007 09:38:38 -0000 1.7 *************** *** 236,240 **** for (Surface current : surfaces) { if (keys.containsAll(current.getEdges())) { - SurfaceNode surfacenode = new SurfaceNode(current); int direction = Surface.direction(current.getEdges(), system); if (direction == Surface.RIGHT) { --- 236,239 ---- *************** *** 243,247 **** EdgeNode node = emap.get(edge); VertexNode to = node.other(from); ! node.setRight(to, surfacenode); from = to; } --- 242,246 ---- EdgeNode node = emap.get(edge); VertexNode to = node.other(from); ! node.addRight(to, current); from = to; } *************** *** 252,256 **** EdgeNode node = (EdgeNode) emap.get(edge); VertexNode to = node.other(from); ! node.setLeft(to, surfacenode); from = to; } --- 251,255 ---- EdgeNode node = (EdgeNode) emap.get(edge); VertexNode to = node.other(from); ! node.addLeft(to, current); from = to; } *************** *** 264,270 **** for (Edge current : start) { if (emap.containsKey(current)) { ! EdgeNode node = emap.get(current); ! node.left = null; ! node.right = null; } } --- 263,269 ---- for (Edge current : start) { if (emap.containsKey(current)) { ! //EdgeNode node = emap.get(current); ! //node.left = null; ! //node.right = null; } } *************** *** 323,348 **** private void assign(Surface surface, Collection<Surface> surfaces) { ! if (!surfaces.isEmpty()) { ! Surface other = surfaces.iterator().next(); ! Vertex n1 = surface.normal(); Vertex n2 = other.normal(); if (n1.dot(n2) > 0) { ! surface.setBackDomain(other.getBackDomain()); ! surface.setBackMaterial(other.getBackMaterial()); ! surface.setFrontDomain(other.getFrontDomain()); ! surface.setFrontMaterial(other.getFrontMaterial()); } else { ! surface.setBackDomain(other.getFrontDomain()); ! surface.setBackMaterial(other.getFrontMaterial()); ! surface.setFrontDomain(other.getBackDomain()); ! surface.setFrontMaterial(other.getBackMaterial()); } } } private void surfaceAnalysis (EdgeNode start, CoordinateSystem system, Set<Surface> added, Set<Surface> removed) { ! if (start.left == null) { SurfaceNode s = new SurfaceNode(); VertexNode to = start.to; EdgeNode current = start; --- 322,371 ---- private void assign(Surface surface, Collection<Surface> surfaces) { ! Space back = null; ! Material backmaterial = null; ! Space front = null; ! Material frontmaterial = null; ! Vertex n1 = surface.normal(); ! for (Surface other : surfaces) { Vertex n2 = other.normal(); if (n1.dot(n2) > 0) { ! if (back == null) { ! back = other.getBackDomain(); ! backmaterial = other.getBackMaterial(); ! } ! if (front == null) { ! front = other.getFrontDomain(); ! frontmaterial = other.getFrontMaterial(); ! } } else { ! if (back == null) { ! back = other.getFrontDomain(); ! backmaterial = other.getFrontMaterial(); ! } ! if (front == null) { ! front = other.getBackDomain(); ! frontmaterial = other.getBackMaterial(); ! } } } + surface.setBackDomain(back); + surface.setBackMaterial(backmaterial); + surface.setFrontDomain(front); + surface.setFrontMaterial(frontmaterial); + } + + private boolean marked(SurfaceNode node) { + if (node == null) { + return false; + } else { + return node.mark; + } } private void surfaceAnalysis (EdgeNode start, CoordinateSystem system, Set<Surface> added, Set<Surface> removed) { ! if (!marked(start.left)) { SurfaceNode s = new SurfaceNode(); + s.mark = true; VertexNode to = start.to; EdgeNode current = start; *************** *** 366,371 **** } } ! if (start.right == null) { SurfaceNode s = new SurfaceNode(); VertexNode to = start.to; EdgeNode current = start; --- 389,395 ---- } } ! if (!marked(start.right)) { SurfaceNode s = new SurfaceNode(); + s.mark = true; VertexNode to = start.to; EdgeNode current = start; *************** *** 669,672 **** --- 693,726 ---- /** + * + * @param end VertexNode + * @param surface Surface + */ + public void addRight(VertexNode end, Surface surface) { + SurfaceNode right = getRight(end); + if (right != null) { + right.add(surface); + } else { + right = new SurfaceNode(surface); + setRight(end, right); + } + } + + /** + * + * @param end VertexNode + * @param surface Surface + */ + public void addLeft(VertexNode end, Surface surface) { + SurfaceNode left = getLeft(end); + if (left != null) { + left.add(surface); + } else { + left = new SurfaceNode(surface); + setLeft(end, left); + } + } + + /** * @return String */ *************** *** 698,701 **** --- 752,760 ---- /** + * Mark used while visiting all sides of adjacent edges. + */ + private boolean mark; + + /** * Constructs this SurfaceNode with an empty set of surfaces */ *************** *** 703,706 **** --- 762,766 ---- super(); surfaces = new HashSet(); + mark = false; } /** *************** *** 713,716 **** --- 773,777 ---- surfaces = new HashSet(); surfaces.add(surface); + mark = false; } *************** *** 726,729 **** --- 787,798 ---- } } + + /** + * Adds the surface to the set of surfaces of this SurfaceNode. + * @param surface The surface to add. + */ + public void add(Surface surface) { + surfaces.add(surface); + } } } |