[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Line.java, NONE, 1.1 Point.java, NON
Status: Pre-Alpha
Brought to you by:
henryml
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30570/src/net/sourceforge/bprocessor/model Modified Files: ClippingPlane.java Plane.java CoordinateSystem.java Entity.java Added Files: Line.java Point.java Constructor.java Log Message: Made Plane and coordinatesystem extend constructor, and created Point and Line. Made some adjustments to the existing files that uses Plane allready... --- NEW FILE: Constructor.java --- //--------------------------------------------------------------------------------- // $Id$ // // 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 java.util.Set; /** * The superclass for constructors * */ public abstract class Constructor extends Geometric implements Parametric { /** The origin of the constructor */ private Vertex origin; /** * The constructor method * @param origin The origin of the constructor */ public Constructor(Vertex origin) { this.origin = origin; } /** * Getter for the origin * @return The origin */ public Vertex getOrigin() { return origin; } /** * @see net.sourceforge.bprocessor.model.Geometric#collect() */ public abstract Set collect(); /** * @see net.sourceforge.bprocessor.model.Entity#center() */ public abstract Vertex center(); /** * @see net.sourceforge.bprocessor.model.Entity#delete() */ public abstract void delete(); } Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CoordinateSystem.java 5 May 2006 14:08:42 -0000 1.10 --- CoordinateSystem.java 4 Jul 2006 09:36:54 -0000 1.11 *************** *** 9,14 **** --- 9,16 ---- import java.util.ArrayList; + import java.util.HashSet; import java.util.Iterator; import java.util.List; + import java.util.Set; /** *************** *** 21,25 **** * to the global coordinate system. */ ! public class CoordinateSystem { /** The i unit vector (x-direction) */ --- 23,27 ---- * to the global coordinate system. */ ! public class CoordinateSystem extends Constructor { /** The i unit vector (x-direction) */ *************** *** 32,38 **** protected Vertex n; - /** The origin of the coordinate system */ - protected Vertex origin; - /** * Constructor --- 34,37 ---- *************** *** 43,51 **** */ public CoordinateSystem(Vertex i, Vertex j, Vertex n, Vertex origin) { ! super(); this.i = i; this.j = j; this.n = n; - this.origin = origin; } --- 42,49 ---- */ public CoordinateSystem(Vertex i, Vertex j, Vertex n, Vertex origin) { ! super(origin); this.i = i; this.j = j; this.n = n; } *************** *** 109,128 **** /** - * Return the origin - * @return The origin - */ - public Vertex origin() { - return origin; - } - - /** - * Set the origin - * @param origin The new origin - */ - public void setOrigin(Vertex origin) { - this.origin = origin; - } - - /** * Return the xy plane of this CoordinateSystem * @return The xy plane --- 107,110 ---- *************** *** 133,137 **** double b = n.getY(); double c = n.getZ(); ! d = -(a * origin.getX() + b * origin.getY() + c * origin.getZ()); return new Plane(a, b, c, d); } --- 115,119 ---- double b = n.getY(); double c = n.getZ(); ! d = -(a * getOrigin().getX() + b * getOrigin().getY() + c * getOrigin().getZ()); return new Plane(a, b, c, d); } *************** *** 168,172 **** */ public Vertex translate(Vertex vertex) { ! Vertex v = vertex.minus(origin); double x = i.dot(v); double y = j.dot(v); --- 150,154 ---- */ public Vertex translate(Vertex vertex) { ! Vertex v = vertex.minus(getOrigin()); double x = i.dot(v); double y = j.dot(v); *************** *** 191,195 **** Vertex nn = n.copy(); nn.scale(vertex.getZ()); ! return origin.add(ii).add(jj).add(nn); } --- 173,177 ---- Vertex nn = n.copy(); nn.scale(vertex.getZ()); ! return getOrigin().add(ii).add(jj).add(nn); } *************** *** 231,235 **** */ public String toString() { ! return "[i = " + i + " j = " + j + " n = " + n + " o = " + origin + "]"; } --- 213,263 ---- */ public String toString() { ! return "[i = " + i + " j = " + j + " n = " + n + " o = " + getOrigin() + "]"; ! } ! ! /** ! * @see net.sourceforge.bprocessor.model.Geometric#collect() ! */ ! public Set collect() { ! HashSet res = new HashSet(); ! res.add(getOrigin()); ! return res; ! } ! ! /** ! * @see net.sourceforge.bprocessor.model.Entity#center() ! */ ! public Vertex center() { ! return getOrigin(); ! } ! ! /** ! * @see net.sourceforge.bprocessor.model.Entity#delete() ! */ ! public void delete() { ! // TODO Auto-generated method stub ! } ! ! /** ! * @see net.sourceforge.bprocessor.model.Parametric#setAttributes() ! */ ! public void setAttributes(List attributes) { ! // TODO Auto-generated method stub ! } ! ! /** ! * @see net.sourceforge.bprocessor.model.Parametric#getAttributes() ! */ ! public List getAttributes() { ! // TODO Auto-generated method stub ! return null; ! } ! ! /** ! * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() ! */ ! public String getGeneralName() { ! // TODO Auto-generated method stub ! return null; } Index: ClippingPlane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ClippingPlane.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ClippingPlane.java 16 Jun 2006 09:43:37 -0000 1.2 --- ClippingPlane.java 4 Jul 2006 09:36:54 -0000 1.3 *************** *** 59,63 **** */ public Vertex origin() { ! Vertex origin = origin = system.origin(); // FIXME Interning the origin to give it an ID.. // It needs an ID to be in a hashtable, but this --- 59,63 ---- */ public Vertex origin() { ! Vertex origin = origin = system.getOrigin(); // FIXME Interning the origin to give it an ID.. // It needs an ID to be in a hashtable, but this Index: Plane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Plane.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Plane.java 5 May 2006 14:08:42 -0000 1.19 --- Plane.java 4 Jul 2006 09:36:54 -0000 1.20 *************** *** 9,12 **** --- 9,14 ---- import java.util.Collection; import java.util.Iterator; + import java.util.List; + import java.util.Set; import org.apache.log4j.Logger; *************** *** 20,24 **** * ax + by + cz - (ah + bi + cj) = 0 */ ! public class Plane { /** The logger */ private static Logger log = Logger.getLogger(Plane.class); --- 22,26 ---- * ax + by + cz - (ah + bi + cj) = 0 */ ! public class Plane extends Constructor { /** The logger */ private static Logger log = Logger.getLogger(Plane.class); *************** *** 54,58 **** */ public Plane(double a, double b, double c, double d) { ! super(); this.a = a; this.b = b; --- 56,60 ---- */ public Plane(double a, double b, double c, double d) { ! super(new Vertex(-d / a, 0, 0)); this.a = a; this.b = b; *************** *** 62,65 **** --- 64,83 ---- /** + * Constructor + * @param a the first vector in the plane + * @param b the second vector in the plane + * @param origin a point in the plane + */ + public Plane(Vertex a, Vertex b, Vertex origin) { + super(origin); + Vertex normal = b.cross(a); + normal.scale(1 / (normal.length())); + this.a = normal.getX(); + this.b = normal.getY(); + this.c = normal.getZ(); + this.d = -this.a * (origin.getX()) - this.b * (origin.getY()) - this.c * (origin.getZ()); + } + + /** * Return a doublearray {a,b,c,d} * @return The array *************** *** 323,325 **** --- 341,390 ---- log.info(info); } + + /** + * @see net.sourceforge.bprocessor.model.Geometric#collect() + */ + public Set collect() { + + // TODO Auto-generated method stub + return null; + } + + /** + * @see net.sourceforge.bprocessor.model.Entity#center() + */ + public Vertex center() { + // TODO Auto-generated method stub + return null; + } + + /** + * @see net.sourceforge.bprocessor.model.Entity#delete() + */ + public void delete() { + // TODO Auto-generated method stub + } + + /** + * @see net.sourceforge.bprocessor.model.Parametric#setAttributes() + */ + public void setAttributes(List attributes) { + // TODO Auto-generated method stub + } + + /** + * @see net.sourceforge.bprocessor.model.Parametric#getAttributes() + */ + public List getAttributes() { + // TODO Auto-generated method stub + return null; + } + + /** + * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() + */ + public String getGeneralName() { + // TODO Auto-generated method stub + return null; + } } --- NEW FILE: Point.java --- //--------------------------------------------------------------------------------- // $Id$ // // 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 java.util.HashSet; import java.util.List; import java.util.Set; /** * The constructor point */ public class Point extends Constructor { /** * The constructor * @param origin the point itself */ public Point(Vertex origin) { super(origin); } /** * Collects the set of vertices in this geometric * @return the set of vertices */ public Set collect() { Set res = new HashSet(); res.add(getOrigin()); return res; } /** * Return the center for the entity * @return The center as a vertex */ public Vertex center() { return getOrigin(); } /** * Delete the entity from the model */ public void delete() { //TODO implement delete } /** * @see net.sourceforge.bprocessor.model.Parametric#setAttributes() */ public void setAttributes(List attributes) { // TODO Auto-generated method stub } /** * @see net.sourceforge.bprocessor.model.Parametric#getAttributes() */ public List getAttributes() { // TODO Auto-generated method stub return null; } /** * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() */ public String getGeneralName() { // TODO Auto-generated method stub return null; } } --- NEW FILE: Line.java --- //--------------------------------------------------------------------------------- // $Id$ // // 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 java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; /** * The line constructor type */ public class Line extends Constructor { /** The rotation of the x - axis (arround the y axis) */ private int degreeX; /** The rotation of the y - axis (arround the z axis) */ private int degreeY; /** The rotation of the z - axis (arround the x axis) */ private int degreeZ; /** * Constuctor of Line with only the origin * @param origin The origin */ public Line(Vertex origin) { super(origin); this.degreeX = 0; this.degreeY = 0; this.degreeZ = 0; } /** * Constructor of the Line with orgin and three angles * @param origin The origin * @param degreeX The angle around the X axis * @param degreeY The angle around the Y axis * @param degreeZ The angle around the Z axis */ public Line(Vertex origin, int degreeX, int degreeY, int degreeZ) { super(origin); this.degreeX = degreeX; this.degreeY = degreeY; this.degreeZ = degreeZ; } /** * Get a direction vertex from the line * @return A non stored vertex in the direction of the line */ public Vertex getDirection() { Vertex dir = new Vertex(1, 0, 0); Geometry.rotate(degreeX, 0, 1, 0, dir, getOrigin()); Geometry.rotate(degreeY, 0, 0, 1, dir, getOrigin()); Geometry.rotate(degreeZ, 1, 0, 0, dir, getOrigin()); return dir.add(getOrigin()); } /** * Collects the set of vertices in this geometric * @return the set of vertices */ public Set collect() { HashSet res = new HashSet(); res.add(getOrigin()); return res; } /** * Return the center for the entity * @return The center as a vertex */ public Vertex center() { return getOrigin(); } /** * Delete the entity from the model */ public void delete() { // TODO implement delete } /** * @return Returns the degreeX. */ public int getDegreeX() { return degreeX; } /** * @param degreeX The degreeX to set. */ public void setDegreeX(int degreeX) { this.degreeX = degreeX; } /** * @return Returns the degreeY. */ public int getDegreeY() { return degreeY; } /** * @param degreeY The degreeY to set. */ public void setDegreeY(int degreeY) { this.degreeY = degreeY; } /** * @return Returns the degreeZ. */ public int getDegreeZ() { return degreeZ; } /** * @param degreeZ The degreeZ to set. */ public void setDegreeZ(int degreeZ) { this.degreeZ = degreeZ; } /** * @see net.sourceforge.bprocessor.model.Parametric#setAttributes() */ public void setAttributes(List attributes) { //TODO implement method } /** * @see net.sourceforge.bprocessor.model.Parametric#getAttributes() */ public List getAttributes() { //FIXME finish the method ArrayList res = new ArrayList(); res.add(new Attribute("Origin", getOrigin())); res.add(new Attribute("Angle X", new Double(getDegreeX()))); res.add(new Attribute("Angle Y", new Double(getDegreeY()))); res.add(new Attribute("Angle Z", new Double(getDegreeZ()))); return res; } /** * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() */ public String getGeneralName() { return "Constructor-Line"; } } Index: Entity.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Entity.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Entity.java 12 Apr 2006 14:29:27 -0000 1.7 --- Entity.java 4 Jul 2006 09:36:54 -0000 1.8 *************** *** 58,62 **** /** * Delete the entity from the model - * */ public abstract void delete(); --- 58,61 ---- |