Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29674/src/net/sourceforge/bprocessor/model
Modified Files:
Surface.java
Log Message:
Moved direction(edges, system) from PencilTool to Surface
Index: Surface.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v
retrieving revision 1.121
retrieving revision 1.122
diff -C2 -d -r1.121 -r1.122
*** Surface.java 7 Dec 2006 00:24:50 -0000 1.121
--- Surface.java 7 Dec 2006 23:05:58 -0000 1.122
***************
*** 22,62 ****
/**
! * The surface
! * @hibernate.class
! * table="SURFACE"
! * lazy="false"
! * @hibernate.cache
! * usage="read-write"
*/
public class Surface extends Geometric implements Parametric {
- /** Default */
private static final long serialVersionUID = 1L;
!
! /** The logger */
private static Logger log = Logger.getLogger(Surface.class);
!
! /** Constructor */
private boolean constructor;
!
! /** The edges relationship */
private List edges;
! /** The holes of this surface */
private Set holes;
- /** The domain in front of the surface */
private Space frontDomain;
- /** The domain behind the surface */
private Space backDomain;
- /** The material on the frontside of the surface */
private Material frontMaterial;
- /** The material on the backside of the surface */
private Material backMaterial;
! /** The exterior surface if this is a hole */
! private Surface exterior;
/**
--- 22,112 ----
/**
! * Surface is defined by its list of boundary edges, and are related
! * to other surfaces through a hole-exterior relationship.
! *
! * The front and back spaces are the spaces on each side of the surface.
! * The front is defined as the space at the side the normal points into.
! * When viewing the surface from the side of the normal, the edges runs
! * counterclockwise around the surface.
! *
! * The front and back material specifies the color front and back side
! * of the surface (and possibly texture etc.
! * in a future version).
*/
public class Surface extends Geometric implements Parametric {
private static final long serialVersionUID = 1L;
!
private static Logger log = Logger.getLogger(Surface.class);
!
private boolean constructor;
!
private List edges;
! private Surface exterior;
!
private Set holes;
private Space frontDomain;
private Space backDomain;
private Material frontMaterial;
private Material backMaterial;
!
! /** LEFT means counterclockwise */
! public static final int LEFT = 1;
! /** RIGHT means clockwise */
! public static final int RIGHT = 2;
! /** PARALLEL means not turning */
! public static final int PARALLEL = 3;
!
! /**
! * Find the turn direction of the edges
! * @param edges list of Edge
! * @param system CoordinateSystem
! * @return direction (LEFT or RIGHT)
! */
! public static int direction(List edges, CoordinateSystem system) {
! double y = Double.MAX_VALUE;
! Edge e1 = null;
! Edge e2 = null;
! Edge previous = (Edge) edges.get(edges.size() - 1);
! Iterator iter = edges.iterator();
! while (iter.hasNext()) {
! Edge current = (Edge) iter.next();
! Vertex v = Edge.commonVertex(previous, current);
! v = system.translate(v);
! if (v.getY() <= y) {
! y = v.getY();
! e1 = previous;
! e2 = current;
! }
! previous = current;
! }
! Vertex common = Edge.commonVertex(e1, e2);
! Vertex from = e1.otherVertex(common);
! Vertex to = e2.otherVertex(common);
! from = system.translate(from);
! common = system.translate(common);
! to = system.translate(to);
! Vertex u = common.minus(from);
! Vertex v = to.minus(common);
! Vertex cross = u.cross(v);
! double determinant = cross.getZ();
! // if the cross points into the screen (along the negative z),
! // the vectors are doing a right turn. Otherwise they are doing
! // a left turn. If the cross are zero, they er parallel, but the
! // above code should ensure that does not happen assuming the
! // edges has a nonzero area.
! if (determinant < 0) {
! return RIGHT;
! }
! if (determinant > 0) {
! return LEFT;
! }
! return PARALLEL;
! }
/**
|