[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Surface.java, 1.166, 1.167 Geometric
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-06-04 20:38:39
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18118/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Geometric.java Mesh.java Log Message: Improved copying of geometry Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** Surface.java 31 May 2007 12:52:14 -0000 1.166 --- Surface.java 4 Jun 2007 20:38:32 -0000 1.167 *************** *** 345,354 **** if (back != null) { back.removeSurface(this); ! setBackDomain(null); } Space front = getFrontDomain(); if (front != null) { front.removeSurface(this); ! setFrontDomain(null); } } --- 345,354 ---- if (back != null) { back.removeSurface(this); ! // setBackDomain(null); } Space front = getFrontDomain(); if (front != null) { front.removeSurface(this); ! // setFrontDomain(null); } } *************** *** 567,570 **** --- 567,571 ---- if (copy == null) { copy = new Surface(); + map.put(this, copy); List<Edge> edges = new ArrayList<Edge>(); Iterator iter = getEdges().iterator(); Index: Mesh.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Mesh.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Mesh.java 29 May 2007 21:08:43 -0000 1.17 --- Mesh.java 4 Jun 2007 20:38:32 -0000 1.18 *************** *** 10,13 **** --- 10,14 ---- import java.util.Collection; import java.util.HashMap; + import java.util.HashSet; import java.util.LinkedList; import java.util.List; *************** *** 45,48 **** --- 46,73 ---- /** * + * @param geometrics Collection of Geometric objects + */ + public Mesh(Collection<Geometric> geometrics) { + Collection<Vertex> vertices = new HashSet(); + Collection<Edge> edges = new HashSet(); + Collection<Surface> surfaces = new HashSet(); + for (Geometric current : geometrics) { + if (current instanceof Surface) { + surfaces.add((Surface) current); + } else if (current instanceof Edge) { + edges.add((Edge) current); + } else if (current instanceof Vertex) { + vertices.add((Vertex) current); + } + } + edges.addAll(Surface.edges(surfaces)); + vertices.addAll(Edge.vertices(edges)); + this.surfaces = surfaces; + this.edges = edges; + this.vertices = vertices; + } + + /** + * * @return vertices */ *************** *** 68,71 **** --- 93,108 ---- /** + * Returns all geometric objects in this Mesh + * @return collection of geometrics objects + */ + public Collection<Geometric> geometrics() { + Collection<Geometric> result = new LinkedList(); + result.addAll(surfaces); + result.addAll(edges); + result.addAll(vertices); + return result; + } + + /** * */ *************** *** 204,207 **** --- 241,253 ---- ss.add((Surface) current.copy(map)); } + for (Surface current : surfaces) { + if (current.getExterior() != null) { + Surface exterior = (Surface) map.get(current.getExterior()); + if (exterior != null) { + Surface surface = (Surface) map.get(current); + exterior.addHole(surface); + } + } + } return new Mesh(ss, es, vs); } Index: Geometric.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometric.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Geometric.java 29 May 2007 11:49:22 -0000 1.16 --- Geometric.java 4 Jun 2007 20:38:32 -0000 1.17 *************** *** 9,15 **** import java.util.Collection; import java.util.Map; import java.util.Set; - /** * The Geometric as a super class for geometric entities --- 9,16 ---- import java.util.Collection; + import java.util.HashSet; + import java.util.LinkedList; import java.util.Map; import java.util.Set; /** * The Geometric as a super class for geometric entities *************** *** 24,27 **** --- 25,92 ---- /** + * Returns collection of all connected geometry of specified + * collection of geometric objects. + * @param geometrics Collecion of Geometric objects + * @return all connected geometry + */ + public static Collection<Geometric> connected(Collection<Geometric> geometrics) { + Set<Geometric> mark = new HashSet(); + LinkedList<Surface> surfaces = new LinkedList(); + LinkedList<Edge> edges = new LinkedList(); + LinkedList<Vertex> vertices = new LinkedList(); + for (Geometric current : geometrics) { + if (current instanceof Surface) { + surfaces.offer((Surface) current); + } else if (current instanceof Edge) { + edges.offer((Edge) current); + } else if (current instanceof Vertex) { + vertices.offer((Vertex) current); + } + } + loop: + while (true) { + if (!surfaces.isEmpty()) { + Surface surface = surfaces.remove(); + mark.add(surface); + for (Edge current : surface.getEdges()) { + if (!mark.contains(current)) { + edges.offer(current); + } + } + for (Surface current : surface.getHoles()) { + if (!mark.contains(current)) { + surfaces.offer(current); + } + } + } else if (!edges.isEmpty()) { + Edge edge = edges.remove(); + mark.add(edge); + if (!mark.contains(edge.from)) { + vertices.offer(edge.from); + } + if (!mark.contains(edge.to)) { + vertices.offer(edge.to); + } + for (Surface current : edge.getSurfaces()) { + if (!mark.contains(current)) { + surfaces.offer(current); + } + } + } else if (!vertices.isEmpty()) { + Vertex vertex = vertices.remove(); + mark.add(vertex); + for (Edge current : vertex.getEdges()) { + if (!mark.contains(current)) { + edges.offer(current); + } + } + } else { + break loop; + } + } + return new LinkedList(mark); + } + + /** * Get the space * @return The space |