[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Relation.java, NONE, 1.1 CoordinateS
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-03-04 23:34:29
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10284/src/net/sourceforge/bprocessor/model Modified Files: CoordinateSystem.java Constructor.java Added Files: Relation.java Log Message: Improved hitdetection of surface/edge intersections slightly. Fixed problem with overlarge CoordinateSystems in hitdetection. Implemented an alternative movetool that is an experiment in moving vertices to a plane, sliding on binding edges. Started implementation of relations, that contains an offset in the form of an expression. Index: Constructor.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Constructor.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Constructor.java 8 Feb 2007 12:23:39 -0000 1.17 --- Constructor.java 4 Mar 2007 23:14:45 -0000 1.18 *************** *** 26,30 **** /** The origin of the constructor */ ! private Vertex origin; /** Tells if the constructor is extended for hit or not */ --- 26,30 ---- /** The origin of the constructor */ ! protected Vertex origin; /** Tells if the constructor is extended for hit or not */ Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** CoordinateSystem.java 2 Jan 2007 17:48:58 -0000 1.33 --- CoordinateSystem.java 4 Mar 2007 23:14:45 -0000 1.34 *************** *** 24,33 **** */ public class CoordinateSystem extends Constructor { - - /** - * - */ - private static final long serialVersionUID = 1L; - /** The i unit vector (x-direction) */ protected Vertex i; --- 24,27 ---- *************** *** 42,45 **** --- 36,42 ---- private boolean onlyPlane; + /** Relations */ + protected Collection<Relation> relations; + /** * Empty constructor for persistence only *************** *** 60,63 **** --- 57,61 ---- n = new Vertex(0, 0, 1); onlyPlane = false; + relations = new LinkedList<Relation>(); } *************** *** 71,83 **** public CoordinateSystem(Vertex i, Vertex j, Vertex n, Vertex origin) { super(origin); - //i.normalize(); - //j.normalize(); - //n.normalize(); this.i = i; this.j = j; this.n = n; onlyPlane = false; } /** {@inheritDoc} */ public Vertex canMove(double x, double y, double z, Collection entities) { --- 69,104 ---- public CoordinateSystem(Vertex i, Vertex j, Vertex n, Vertex origin) { super(origin); this.i = i; this.j = j; this.n = n; onlyPlane = false; + relations = new LinkedList<Relation>(); } + /** + * + * @return relations + */ + public Collection<Relation> relations() { + return relations; + } + + /** + * + * @param relation Relation + */ + public void add(Relation relation) { + relations.add(relation); + relation.setId(new Long(relations.size() + 1)); + } + + /** + * + * @param relation Relation + */ + public void remove(Relation relation) { + relations.remove(relation); + } + /** {@inheritDoc} */ public Vertex canMove(double x, double y, double z, Collection entities) { *************** *** 241,244 **** --- 262,292 ---- /** + * Return the projection of the vertex in the xy plane + * of this CoordinateSystem. + * @param vertex The vertex to project. + * @return The projected vertex. + */ + public Vertex project(Vertex vertex) { + Vertex vector = vertex.minus(origin); + double t = vector.dot(n); + Vertex normal = n.copy(); + normal.scale(t); + vector = vector.minus(normal); + return origin.add(vector); + } + + /** + * Slide the vertex along the given vector to the xy plane + * of this CoordinateSystem. + * @param vertex The vertex to slide + * @param vector The vector to slide on + * @return The resulting vertex. + */ + public Vertex slide(Vertex vertex, Vertex vector) { + Plane plane = plane(); + return plane.intersection(vertex, vector, true); + } + + /** * Return the vertex translated to this CoordinateSystem * @param vertex The vertex to translate --- NEW FILE: Relation.java --- //--------------------------------------------------------------------------------- // $Id: Relation.java,v 1.1 2007/03/04 23:14:45 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 java.util.LinkedList; import java.util.List; /** * Relation */ public class Relation extends Entity implements Parametric { private Geometric geometric; private String offset; /** * Constructs a Relation * @param geometric Geomtric * @param offset Expression */ public Relation(Geometric geometric, String offset) { this.geometric = geometric; this.offset = offset; } /** {@inheritDoc} */ public List getAttributes() { LinkedList attributes = new LinkedList(); attributes.add(new Attribute("Object", geometric)); attributes.add(new Attribute("Offset", offset)); return attributes; } /** {@inheritDoc} */ public String getGeneralName() { return "Relation"; } /** {@inheritDoc} */ public void setAttributes(List attributes) { // TODO Auto-generated method stub } /** {@inheritDoc} */ @Override public void delete() { // TODO Auto-generated method stub } } |