[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.107, 1.108 Vertex.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2008-01-21 13:37:27
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21030/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Vertex.java Surface.java Geometric.java Log Message: Connected geometry Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.216 retrieving revision 1.217 diff -C2 -d -r1.216 -r1.217 *** Surface.java 11 Jan 2008 09:22:08 -0000 1.216 --- Surface.java 21 Jan 2008 13:37:25 -0000 1.217 *************** *** 2122,2124 **** --- 2122,2140 ---- this.setNormals(normals); } + + /** + * {@inheritDoc} + */ + public Collection<Geometric> connected(Command.Inverse inv, boolean all) { + Collection<Geometric> result = super.connected(inv, all); + result.addAll(edges); + if (all) { + if (exterior != null) { + result.add(exterior); + } + result.addAll(getHoles()); + } + return result; + } + } Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** Edge.java 15 Jan 2008 15:43:40 -0000 1.107 --- Edge.java 21 Jan 2008 13:37:25 -0000 1.108 *************** *** 1298,1301 **** --- 1298,1312 ---- return run; } + + /** + * {@inheritDoc} + */ + public Collection<Geometric> connected(Command.Inverse inv, boolean all) { + Collection<Geometric> result = super.connected(inv, all); + result.addAll(inv.surfaces(this)); + result.add(from); + result.add(to); + return result; + } /** Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Vertex.java 14 Jan 2008 14:00:25 -0000 1.77 --- Vertex.java 21 Jan 2008 13:37:25 -0000 1.78 *************** *** 616,619 **** --- 616,628 ---- /** + * {@inheritDoc} + */ + public Collection<Geometric> connected(Command.Inverse inv, boolean all) { + Collection<Geometric> result = super.connected(inv, all); + result.addAll(inv.edges(this)); + return result; + } + + /** * Info * @param object Object Index: Geometric.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometric.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Geometric.java 13 Dec 2007 12:00:31 -0000 1.21 --- Geometric.java 21 Jan 2008 13:37:25 -0000 1.22 *************** *** 12,15 **** --- 12,16 ---- import java.util.LinkedList; import java.util.Map; + import java.util.Queue; import java.util.Set; /** *************** *** 24,100 **** private boolean protect; /** * 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(); ! Set<Surface> env = new HashSet(surfaces); ! 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); ! env.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; ! } } ! ! Set<Container> spaces = new HashSet(); ! for (Surface current : env) { ! spaces.add(current.getFrontDomain()); ! spaces.add(current.getBackDomain()); } ! for (Container current : spaces) { ! if (current != current.getOwner().empty) { ! if (env.containsAll(current.getEnvelope())) { mark.add(current); } } --- 25,55 ---- private boolean protect; + /** * Returns collection of all connected geometry of specified * collection of geometric objects. * @param geometrics Collecion of Geometric objects ! * @param all consider hole/exterior relations as well ! * @return connected geometry */ ! public static Collection<Geometric> connected(Collection<Geometric> geometrics, boolean all) { ! Set<Geometric> mark = new HashSet(geometrics); ! Container owner = null; ! if (geometrics.size() > 0) { ! owner = geometrics.iterator().next().getOwner(); } ! Command.Inverse inv = null; ! if (owner != null) { ! inv = new Command.Inverse(new LinkedList(owner.getSurfaces())); } ! ! Queue<Geometric> queue = new LinkedList(geometrics); ! while (!queue.isEmpty()) { ! Geometric geometric = queue.remove(); ! Collection<Geometric> connected = geometric.connected(inv, all); ! for (Geometric current : connected) { ! if (!mark.contains(current)) { mark.add(current); + queue.add(current); } } *************** *** 196,199 **** --- 151,165 ---- public abstract Vertex center(); + + /** + * Returns the geometric objects that are connected to this geometric object + * @param inv Inverse relations + * @param all consider hole/exterior relations as well + * @return Connected geometric objects + */ + public Collection<Geometric> connected(Command.Inverse inv, boolean all) { + return new LinkedList(); + } + /** * Move the geometric object x,y,z |