Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12817/src/net/sourceforge/bprocessor/model
Modified Files:
SurfaceAnalysis.java Sorter.java
Added Files:
EdgeSorter.java
Log Message:
Edge Sorting
--- NEW FILE: EdgeSorter.java ---
//---------------------------------------------------------------------------------
// $Id: EdgeSorter.java,v 1.1 2007/05/02 11:39:50 henryml Exp $
//
// Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net)
// Released under the Lesser GNU Public License v2.1
//---------------------------------------------------------------------------------
package net.sourceforge.bprocessor.model;
import net.sourceforge.bprocessor.model.SurfaceAnalysis.EdgeNode;
import net.sourceforge.bprocessor.model.SurfaceAnalysis.VertexNode;
/**
* @param <T> Type of node
*/
public class EdgeSorter<T extends EdgeNode> extends Sorter<T> {
private VertexNode node;
private CoordinateSystem system;
/**
* @param node VertexNode
* @param system CoordinateSystem
*/
public EdgeSorter(VertexNode node, CoordinateSystem system) {
this.node = node;
this.system = system;
}
/**
* {@inheritDoc}
*/
public Entry entryFor(T n) {
VertexNode other = n.other(node);
Vertex delta = other.vertex().minus(node.vertex());
double dx = system.getI().dot(delta);
double dy = system.getJ().dot(delta);
return new Entry(n, dx, dy);
}
}
Index: Sorter.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Sorter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Sorter.java 2 May 2007 07:45:26 -0000 1.1
--- Sorter.java 2 May 2007 11:39:50 -0000 1.2
***************
*** 12,35 ****
import java.util.List;
- import net.sourceforge.bprocessor.model.SurfaceAnalysis.EdgeNode;
- import net.sourceforge.bprocessor.model.SurfaceAnalysis.VertexNode;
-
-
/**
! *
*/
! public class Sorter {
! private VertexNode node;
! private CoordinateSystem system;
/**
! * Creater sorter
! * @param node VertexNode
! * @param system CoordinateSystem
*/
! public Sorter(VertexNode node, CoordinateSystem system) {
! this.node = node;
! this.system = system;
! }
/**
--- 12,26 ----
import java.util.List;
/**
! * @param <T> type of node
*/
! public class Sorter<T> {
/**
! * Create an entry for the a node
! * @param n The specified node
! * @return The entry
*/
! public Entry entryFor(T n) { return null; }
/**
***************
*** 39,43 ****
protected double dx;
protected double dy;
! protected EdgeNode node;
/**
--- 30,34 ----
protected double dx;
protected double dy;
! protected T node;
/**
***************
*** 47,51 ****
* @param dy double
*/
! public Entry(EdgeNode node, double dx, double dy) {
this.node = node;
this.dx = dx;
--- 38,42 ----
* @param dy double
*/
! public Entry(T node, double dx, double dy) {
this.node = node;
this.dx = dx;
***************
*** 77,81 ****
* @return Sorted list of edges
*/
! public List<EdgeNode> sort(List<EdgeNode> edges) {
List result = new LinkedList();
if (!edges.isEmpty()) {
--- 68,72 ----
* @return Sorted list of edges
*/
! public List<T> sort(List<T> edges) {
List result = new LinkedList();
if (!edges.isEmpty()) {
***************
*** 84,105 ****
List right = new LinkedList();
! for (EdgeNode current : edges) {
! VertexNode other = current.other(node);
! Vertex delta = other.vertex().minus(node.vertex());
! double dx = system.getI().dot(delta);
! double dy = system.getJ().dot(delta);
! Entry entry = new Entry(current, dx, dy);
! if (dx == 0) {
! if (dy < 0) {
right.add(entry);
}
! if (dy > 0) {
left.add(entry);
}
} else {
! if (dx > 0) {
right.add(entry);
}
! if (dx < 0) {
left.add(entry);
}
--- 75,92 ----
List right = new LinkedList();
! for (T current : edges) {
! Entry entry = entryFor(current);
! if (entry.dx == 0) {
! if (entry.dy < 0) {
right.add(entry);
}
! if (entry.dy > 0) {
left.add(entry);
}
} else {
! if (entry.dx > 0) {
right.add(entry);
}
! if (entry.dx < 0) {
left.add(entry);
}
Index: SurfaceAnalysis.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/SurfaceAnalysis.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** SurfaceAnalysis.java 2 May 2007 07:45:26 -0000 1.8
--- SurfaceAnalysis.java 2 May 2007 11:39:50 -0000 1.9
***************
*** 452,456 ****
*/
public void sort(CoordinateSystem system) {
! Sorter sorter = new Sorter(this, system);
edges = sorter.sort(edges);
{
--- 452,456 ----
*/
public void sort(CoordinateSystem system) {
! Sorter sorter = new EdgeSorter(this, system);
edges = sorter.sort(edges);
{
|