[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Geometry.java, 1.27, 1.28
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-09-29 13:39:11
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10765/src/net/sourceforge/bprocessor/model Modified Files: Geometry.java Log Message: changed insert methods to return the surfaces created Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Geometry.java 18 Sep 2006 14:10:07 -0000 1.27 --- Geometry.java 29 Sep 2006 13:39:03 -0000 1.28 *************** *** 176,183 **** * surfaces etc. * @param edges The list of edges ! * @return Whether a new surface was added */ ! public static boolean insert(List edges) { ! Edge first = (Edge) edges.get(0); Vertex from = first.getFrom(); --- 176,183 ---- * surfaces etc. * @param edges The list of edges ! * @return a list of the surfaces created */ ! public static List insert(List edges) { ! List result = new LinkedList(); Edge first = (Edge) edges.get(0); Vertex from = first.getFrom(); *************** *** 185,189 **** Vertex to = last.getTo(); Surface exterior = null; ! boolean closed = false; { Set fromSurfaces = from.getSurfaces(); --- 185,191 ---- Vertex to = last.getTo(); Surface exterior = null; ! //Finding out if the edges are all contained in one surface with ! //endpoints of the chain of edges as vertices of the surface. ! //If such a surface exists it is set to extorior { Set fromSurfaces = from.getSurfaces(); *************** *** 201,229 **** } else { Iterator iter = shared.iterator(); ! while (iter.hasNext() && (exterior == null)) { Surface currentSurface = (Surface) iter.next(); ! if (edges.size() > 1) { ! Vertex currentVertex = first.otherVertex(from); ! int currentIndex = 1; ! Edge currentEdge = (Edge) edges.get(currentIndex); ! boolean outside = false; ! while ((currentVertex != to) && !outside) { ! outside = !currentSurface.surrounds(currentVertex); ! currentVertex = currentEdge.otherVertex(currentVertex); ! currentIndex++; ! if (currentIndex < edges.size()) { ! currentEdge = (Edge) edges.get(currentIndex); ! } else { ! currentEdge = null; ! } ! } ! if (!outside) { ! exterior = currentSurface; } } } } } ! Set siblings = to.getEdges(); siblings.remove(first); --- 203,229 ---- } else { Iterator iter = shared.iterator(); ! while (edges.size() > 1 && iter.hasNext() && (exterior == null)) { Surface currentSurface = (Surface) iter.next(); ! Vertex currentVertex = first.otherVertex(from); ! int currentIndex = 1; ! Edge currentEdge = (Edge) edges.get(currentIndex); ! boolean outside = false; ! while ((currentVertex != to) && !outside) { ! outside = !currentSurface.surrounds(currentVertex); ! currentVertex = currentEdge.otherVertex(currentVertex); ! currentIndex++; ! if (currentIndex < edges.size()) { ! currentEdge = (Edge) edges.get(currentIndex); ! } else { ! currentEdge = null; } } + if (!outside) { + exterior = currentSurface; + } } } } ! //Find the surfaces Set siblings = to.getEdges(); siblings.remove(first); *************** *** 240,248 **** siblings = node.insert(siblings); node.sort(); ! closed = findSurfaces(node, lastEdgeNode, edges, exterior); } } } ! return closed; } --- 240,248 ---- siblings = node.insert(siblings); node.sort(); ! result.addAll(findSurfaces(node, lastEdgeNode, edges, exterior)); } } } ! return result; } *************** *** 254,260 **** * @param edges The edges * @param exterior The exterior ! * @return Whether a surface was found */ ! private static boolean findSurfaces(VertexNode vertex, EdgeNode last, List edges, Surface exterior) { int count = 0; --- 254,260 ---- * @param edges The edges * @param exterior The exterior ! * @return a list of the surfaces found */ ! private static List findSurfaces(VertexNode vertex, EdgeNode last, List edges, Surface exterior) { int count = 0; *************** *** 262,269 **** Space mesh = ((Edge) edges.iterator().next()).getOwner(); { - Surface clockwise = clockwiseSurface(vertex, last, edges); ! if (clockwise != null) { ! if (clockwise.angle(vertex.system()) < 0) { mesh.insert(clockwise); --- 262,267 ---- Space mesh = ((Edge) edges.iterator().next()).getOwner(); { Surface clockwise = clockwiseSurface(vertex, last, edges); ! if (clockwise != null) { if (clockwise.angle(vertex.system()) < 0) { mesh.insert(clockwise); *************** *** 302,306 **** } } ! return !surfaces.isEmpty(); } --- 300,304 ---- } } ! return surfaces; } *************** *** 364,368 **** } ! /** * The VertexNode class is used for internal surface calculations --- 362,366 ---- } ! /** * The VertexNode class is used for internal surface calculations *************** *** 837,844 **** * Insert a number edges into the model * @param edges List of edges ! * @return Boolean indicating whether the edges are closed */ ! public static boolean insertEdges(List edges) { ! boolean closed = false; if (!edges.isEmpty()) { Vertex v = Edge.commonVertex((Edge) edges.get(0), (Edge) edges.get(edges.size() - 1)); --- 835,843 ---- * Insert a number edges into the model * @param edges List of edges ! * @return List of the surfaces created (empty list if none) */ ! public static List insertEdges(List edges) { ! //boolean closed = false; ! List result = new LinkedList(); if (!edges.isEmpty()) { Vertex v = Edge.commonVertex((Edge) edges.get(0), (Edge) edges.get(edges.size() - 1)); *************** *** 855,861 **** if (actual.size() > 2) { Surface surface = new Surface(actual); Project.getInstance().getActiveSpace().insert(surface); holeAnalysis(surface); - closed = true; } } else { --- 854,860 ---- if (actual.size() > 2) { Surface surface = new Surface(actual); + result.add(surface); Project.getInstance().getActiveSpace().insert(surface); holeAnalysis(surface); } } else { *************** *** 869,878 **** } } ! closed = insert(actual); } } Project.getInstance().changed(Project.getInstance()); Project.getInstance().checkpoint(); ! return closed; } --- 868,877 ---- } } ! result.addAll(insert(actual)); } } Project.getInstance().changed(Project.getInstance()); Project.getInstance().checkpoint(); ! return result; } |