[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Geometry.java, 1.31, 1.32 Space.java
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-10-09 14:03:18
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21047/src/net/sourceforge/bprocessor/model Modified Files: Geometry.java Space.java Log Message: Implemented Space.insert(Surface) Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** Space.java 9 Oct 2006 06:52:34 -0000 1.74 --- Space.java 9 Oct 2006 14:03:15 -0000 1.75 *************** *** 502,507 **** */ public Vertex insert(Vertex vertex, boolean split) { ! add(vertex); ! return vertex; } --- 502,540 ---- */ public Vertex insert(Vertex vertex, boolean split) { ! Space space = this; ! if (vertex.getOwner() != null) { ! if (vertex.getOwner() == space) { ! return vertex; ! } else { ! vertex = vertex.copy(); ! } ! } ! ! Vertex actual = null; ! { ! Set vertices = ! space.findByLocation (vertex.getX(), vertex.getY(), vertex.getZ(), 0.0000001); ! if (!vertices.isEmpty()) { ! actual = (Vertex) vertices.iterator().next(); ! } ! } ! ! if (actual == null) { ! actual = vertex; ! space.add(actual); ! if (split) { ! Set es = space.findEdge(actual); ! if (es.size() > 0) { ! Iterator iter = es.iterator(); ! while (iter.hasNext()) { ! Edge e = (Edge) iter.next(); ! if (!e.getStrippled()) { ! e.split(actual); ! } ! } ! } ! } ! } ! return actual; } *************** *** 581,589 **** * Insert a edge * @param edge The edge * @return The edge */ ! public Edge insert(Edge edge) { ! add(edge); ! return edge; } --- 614,650 ---- * Insert a edge * @param edge The edge + * @param split Split edges * @return The edge */ ! public Edge insert(Edge edge, boolean split) { ! Space space = this; ! ! Edge actual = edge; ! if (edge.getLength() == 0) { ! return null; ! } ! Vertex from = space.insert(edge.getFrom(), split); ! Vertex to = space.insert(edge.getTo(), split); ! edge.setFrom(from); ! edge.setTo(to); ! { ! Collection edges = space.getEdges(); ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! if (current.getFrom() == edge.getFrom() && current.getTo() == edge.getTo()) { ! actual = current; ! break; ! } ! if (current.getFrom() == edge.getTo() && current.getTo() == edge.getFrom()) { ! actual = current; ! break; ! } ! } ! } ! if (actual == edge) { ! space.add(edge); ! } ! return actual; } *************** *** 804,813 **** * Insert a surface * @param surface The surface * @return The surface */ ! public Surface insert(Surface surface) { add(surface); - surface.setBackDomain(empty); - surface.setFrontDomain(empty); return surface; } --- 865,881 ---- * Insert a surface * @param surface The surface + * @param split Allow splits * @return The surface */ ! public Surface insert(Surface surface, boolean split) { ! List edges = surface.getEdges(); ! List actual = new LinkedList(); ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! actual.add(insert(current, split)); ! } ! surface.setEdges(actual); add(surface); return surface; } Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Geometry.java 9 Oct 2006 13:26:15 -0000 1.31 --- Geometry.java 9 Oct 2006 14:03:15 -0000 1.32 *************** *** 745,794 **** /** - * Insert a vertex into model - * @param vertex Vertex - * @param split Split - * @return Vertex from model - */ - public static Vertex insertVertex(Vertex vertex, boolean split) { - Project p = Project.getInstance(); - Space space = p.getActiveSpace(); - - if (vertex.getOwner() != null) { - if (vertex.getOwner() == space) { - return vertex; - } else { - vertex = vertex.copy(); - } - } - - Vertex actual = null; - { - Set vertices = - space.findByLocation (vertex.getX(), vertex.getY(), vertex.getZ(), 0.0000001); - if (!vertices.isEmpty()) { - actual = (Vertex) vertices.iterator().next(); - } - } - - if (actual == null) { - actual = vertex; - space.add(actual); - if (split) { - Set es = space.findEdge(actual); - if (es.size() > 0) { - Iterator iter = es.iterator(); - while (iter.hasNext()) { - Edge e = (Edge) iter.next(); - if (!e.getStrippled()) { - e.split(actual); - } - } - } - } - } - return actual; - } - - /** * Insert a Constructor into model * @param c the constructor --- 745,748 ---- *************** *** 801,843 **** /** - * Insert an edge into model - * @param edge Edge - * @param split Split - * @return Edge from model null if to and from were the same - */ - public static Edge insertEdge(Edge edge, boolean split) { - Edge actual = edge; - if (edge.getLength() == 0) { - return null; - } - Vertex from = insertVertex(edge.getFrom(), split); - Vertex to = insertVertex(edge.getTo(), split); - edge.setFrom(from); - edge.setTo(to); - if (edge.getLength() == 0.0) { - return null; - } - { - Collection edges = Project.getInstance().getActiveSpace().getEdges(); - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - Edge current = (Edge) iter.next(); - if (current.getFrom() == edge.getFrom() && current.getTo() == edge.getTo()) { - actual = current; - break; - } - if (current.getFrom() == edge.getTo() && current.getTo() == edge.getFrom()) { - actual = current; - break; - } - } - } - if (actual == edge) { - Project.getInstance().getActiveSpace().add(edge); - } - return actual; - } - - /** * Insert a number edges into the model * @param edges List of edges --- 755,758 ---- *************** *** 845,849 **** */ public static List insertEdges(List edges) { ! //boolean closed = false; List result = new LinkedList(); if (!edges.isEmpty()) { --- 760,764 ---- */ public static List insertEdges(List edges) { ! Space space = Project.getInstance().getActiveSpace(); List result = new LinkedList(); if (!edges.isEmpty()) { *************** *** 854,858 **** while (iter.hasNext()) { Edge current = (Edge) iter.next(); ! Edge edge = insertEdge(current, false); if (edge != null) { actual.add(edge); --- 769,773 ---- while (iter.hasNext()) { Edge current = (Edge) iter.next(); ! Edge edge = space.insert(current, false); if (edge != null) { actual.add(edge); *************** *** 862,866 **** Surface surface = new Surface(actual); result.add(surface); ! Project.getInstance().getActiveSpace().add(surface); holeAnalysis(surface); } --- 777,781 ---- Surface surface = new Surface(actual); result.add(surface); ! space.add(surface); holeAnalysis(surface); } *************** *** 870,874 **** while (iter.hasNext()) { Edge current = (Edge) iter.next(); ! Edge edge = insertEdge(current, true); if (edge != null) { actual.add(edge); --- 785,789 ---- while (iter.hasNext()) { Edge current = (Edge) iter.next(); ! Edge edge = space.insert(current, true); if (edge != null) { actual.add(edge); |