[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model/plugin PhysicsNet.java, 1.1, 1.2 Ph
Status: Pre-Alpha
Brought to you by:
henryml
From: Sebastian G. <sg...@us...> - 2011-05-02 12:39:10
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin In directory vz-cvs-2.sog:/tmp/cvs-serv30448/src/net/sourceforge/bprocessor/model/plugin Modified Files: PhysicsNet.java PhysicsPackage.java Log Message: Physics Net linked to b net Index: PhysicsPackage.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin/PhysicsPackage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PhysicsPackage.java 26 Apr 2011 06:23:02 -0000 1.1 --- PhysicsPackage.java 2 May 2011 12:39:06 -0000 1.2 *************** *** 15,21 **** * 2. Change to original net -> changes new net * 3. Parameters, toggles and sliders ! * 4. Planarity and regularity of panels * 5. Add parameters to b-net and save them! * 6. Subdivision */ --- 15,23 ---- * 2. Change to original net -> changes new net * 3. Parameters, toggles and sliders ! * 4. Planarity and regularity of panels, add bending stiffness! * 5. Add parameters to b-net and save them! * 6. Subdivision + * 7. Selection => parameter changes to vertices and edges, not only global + * */ *************** *** 27,30 **** --- 29,35 ---- Space cNet; + HashMap<Edge, Edge> edges = new HashMap(); + HashMap<Vertex, Vertex> vertices = new HashMap(); + //parameters double gravity; *************** *** 41,44 **** --- 46,51 ---- double planeDamping; double normalForce; + boolean editNet; + public void initialize(Space net) { *************** *** 52,58 **** cDamp = 2.0; parameters.put("Spring Damping [N sec/m]",cDamp); ! restLengthFactor = 1.1; parameters.put("Spring Restlength Factor",restLengthFactor); ! springConstant = 2.0; parameters.put("Spring Constant c [N/m]",springConstant); equalConstant = 0.0; --- 59,65 ---- cDamp = 2.0; parameters.put("Spring Damping [N sec/m]",cDamp); ! restLengthFactor = 0.5; parameters.put("Spring Restlength Factor",restLengthFactor); ! springConstant = 20.0; parameters.put("Spring Constant c [N/m]",springConstant); equalConstant = 0.0; *************** *** 70,73 **** --- 77,82 ---- normalForce = 0.0; parameters.put("Normal Surface Force [N]", normalForce); + editNet = true; + parameters.putBoolean("Edit B-Net", editNet); *************** *** 84,87 **** --- 93,107 ---- if (nV.coincides(cV)) { cV.setCorner(nV.isCorner()); + vertices.put(nV,cV); + } + } + } + //create Edges HashMap + Collection<Edge> nEdges = net.getEdges(); + Collection<Edge> bEdges = cNet.getEdges(); + for (Edge nE : nEdges) { + for (Edge cE : bEdges) { + if (nE.equivalent(cE)) { + edges.put(nE,cE); } } *************** *** 94,97 **** --- 114,118 ---- //remove all elements of last iteration //clear(); + ////////////////////////////////////////////////////////////////// //get changed parameters //gravity *************** *** 111,119 **** pN.spring_d = cDamp; //spring restlength factor ! Double oldRLF = restLengthFactor; restLengthFactor = (Double) parameters.getDouble("Spring Restlength Factor"); ! if (oldRLF!=restLengthFactor) { ! pN.updateRestLength(restLengthFactor); ! } //spring constant Double oldSpringConstant = springConstant; --- 132,140 ---- pN.spring_d = cDamp; //spring restlength factor ! //Double oldRLF = restLengthFactor; restLengthFactor = (Double) parameters.getDouble("Spring Restlength Factor"); ! //if (oldRLF!=restLengthFactor) { ! // pN.updateRestLengthFactor(restLengthFactor); ! //} //spring constant Double oldSpringConstant = springConstant; *************** *** 133,136 **** --- 154,178 ---- //normal Force normalForce = (Double) parameters.get("Normal Surface Force [N]"); + //boolean parameters + editNet = (Boolean) parameters.getBoolean("Edit B-Net"); + ///////////////////////////////////////////////////////////////////////////////////////////// + //track changes of bNet and modify Physics Net accordingly + //update vertices + Collection<Vertex> bVertices = net.getVertices(); + for (Vertex bV : bVertices) { + if (bV.isCorner()) { + Vertex pV = vertices.get(bV); + pV.setX(bV.getX()); + pV.setY(bV.getY()); + pV.setZ(bV.getZ()); + pN.updatePos(pV); + } + } + //update edges + Collection<Edge> bEdges = net.getEdges(); + for (Edge bE : bEdges) { + pN.updateRestLength(edges.get(bE), bE.getLength(), restLengthFactor); + } + //add a union space containing all new elements *************** *** 149,153 **** //change p-net ! cNet.edit(); pN.update(guides, 0.02, equalConstant, equalDamping, rectConstant, rectDamping, planeConstant, planeDamping, normalForce); union.add(cNet); --- 191,199 ---- //change p-net ! if (editNet) { ! net.edit(); ! } else { ! cNet.edit(); ! } pN.update(guides, 0.02, equalConstant, equalDamping, rectConstant, rectDamping, planeConstant, planeDamping, normalForce); union.add(cNet); Index: PhysicsNet.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin/PhysicsNet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PhysicsNet.java 26 Apr 2011 06:23:02 -0000 1.1 --- PhysicsNet.java 2 May 2011 12:39:06 -0000 1.2 *************** *** 22,26 **** PhysicsNet(Space bNet, double gravity, double spring_constant, double spring_damping, double particle_damping, double mass, double restLengthFactor) { Map pMap = new HashMap(); ! this.bNet = (Space) bNet.copy(pMap); this.spring_c = spring_constant; this.spring_d = spring_damping; --- 22,27 ---- PhysicsNet(Space bNet, double gravity, double spring_constant, double spring_damping, double particle_damping, double mass, double restLengthFactor) { Map pMap = new HashMap(); ! //this.bNet = (Space) bNet.copy(pMap); ! this.bNet = bNet; this.spring_c = spring_constant; this.spring_d = spring_damping; *************** *** 67,70 **** --- 68,79 ---- } } + + void updatePos(Vertex cV) { + PhysicsParticle pA = particles.get(cV); + pA.pos = new Vertex(cV.getX(),cV.getY(), cV.getZ()); + pA.nPos = new Vertex(cV.getX(),cV.getY(), cV.getZ()); + pA.lastPos = new Vertex(cV.getX(),cV.getY(), cV.getZ()); + } + void updateMass(double mass) { Iterator it = particles.entrySet().iterator(); *************** *** 76,80 **** } ! void updateRestLength(double restLengthFactor) { Iterator it = springs.entrySet().iterator(); while (it.hasNext()) { --- 85,89 ---- } ! void updateRestLengthFactor(double restLengthFactor) { Iterator it = springs.entrySet().iterator(); while (it.hasNext()) { *************** *** 85,88 **** --- 94,102 ---- } + void updateRestLength(Edge e, double eql, double restLengthFactor) { + PhysicsSpring s = (PhysicsSpring)springs.get(e); + s.eql = eql * restLengthFactor; + } + void updateSpringConstant(double springConstant) { Iterator it = springs.entrySet().iterator(); |