Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27771/src/net/sourceforge/bprocessor/model
Modified Files:
Edge.java Surface.java
Log Message:
small refactoring to generics
Index: Surface.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v
retrieving revision 1.144
retrieving revision 1.145
diff -C2 -d -r1.144 -r1.145
*** Surface.java 21 Mar 2007 11:58:06 -0000 1.144
--- Surface.java 22 Mar 2007 11:44:29 -0000 1.145
***************
*** 236,241 ****
* @return An ordered list of vertices around this Surface
*/
! public List getVertices() {
! ArrayList vertices = new ArrayList();
List edges = getEdges();
if (edges.size() == 1) {
--- 236,241 ----
* @return An ordered list of vertices around this Surface
*/
! public List<Vertex> getVertices() {
! ArrayList<Vertex> vertices = new ArrayList<Vertex>();
List edges = getEdges();
if (edges.size() == 1) {
***************
*** 1662,1667 ****
* @return the set of vertices
*/
! public Set collect() {
! Set result = new HashSet(this.getVertices());
if (holes != null) {
Iterator it = holes.iterator();
--- 1662,1667 ----
* @return the set of vertices
*/
! public Set<Vertex> collect() {
! Set<Vertex> result = new HashSet<Vertex>(this.getVertices());
if (holes != null) {
Iterator it = holes.iterator();
***************
*** 1953,1955 ****
--- 1953,1982 ----
return top;
}
+
+ /**
+ * Find the last hit vertex, when the given edge is used as sweepline across the surface
+ * @precondtion The given edge is in the surface
+ * @param e the edge to use as sweepline
+ * @return the vertex farest away (if there are several vertexes with the same distance the
+ * last is returned
+ */
+ public Vertex oppositeVertex(Edge e) {
+ if (!edges.contains(e)) {
+ return null;
+ }
+ Vertex result = null;
+ double maxdist = 0;
+ Vertex i = e.getDirection().cross(normal());
+ CoordinateSystem translation =
+ new CoordinateSystem(i, e.getDirection(), normal(), e.getFrom());
+ Set<Vertex> vertexes = collect();
+ for (Vertex v : vertexes) {
+ Vertex translatedVertex = translation.translate(v);
+ if (Math.abs(translatedVertex.getX()) >= maxdist) {
+ result = v;
+ maxdist = Math.abs(translatedVertex.getX());
+ }
+ }
+ return result;
+ }
}
Index: Edge.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** Edge.java 12 Mar 2007 16:01:26 -0000 1.75
--- Edge.java 22 Mar 2007 11:44:29 -0000 1.76
***************
*** 449,454 ****
* @return the set of surfaces
*/
! public Set getSurfaces() {
! Set result = new HashSet();
if (getOwner() != null) {
Collection surfaces = getOwner().getSurfaces();
--- 449,454 ----
* @return the set of surfaces
*/
! public Set<Surface> getSurfaces() {
! Set<Surface> result = new HashSet<Surface>();
if (getOwner() != null) {
Collection surfaces = getOwner().getSurfaces();
|