[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view PopupMenu.java, 1.57, 1.58
Status: Pre-Alpha
Brought to you by:
henryml
From: Sebastian G. <sg...@us...> - 2012-03-06 09:28:18
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory vz-cvs-4.sog:/tmp/cvs-serv15613/src/net/sourceforge/bprocessor/gl/view Modified Files: PopupMenu.java Log Message: hanging chain tool - change weight and change restlength / selection implemented tool to aligh normals when faces are planar Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/PopupMenu.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** PopupMenu.java 29 Dec 2011 17:59:47 -0000 1.57 --- PopupMenu.java 6 Mar 2012 09:28:16 -0000 1.58 *************** *** 15,18 **** --- 15,19 ---- import java.util.LinkedList; import java.util.List; + import java.util.Map; import java.util.Set; *************** *** 58,61 **** --- 59,63 ---- import net.sourceforge.bprocessor.model.Command.BoundingSphere; import net.sourceforge.bprocessor.model.modellor.Modellor; + //import net.sourceforge.bprocessor.packages.physics.PhysicsParticle; import org.apache.log4j.Logger; *************** *** 543,546 **** --- 545,600 ---- menu.add(flip); } + //Submenu for normal flip algorithms + { + JMenu normalMenu = new JMenu("normals"); + { + AbstractAction flip = new GeometricMenuAction(arguments, "align planar") { + public void actionPerformed(ActionEvent arg0) { + //Selection.primary().clear(); + Collection<Vertex> normals = new LinkedList(); + for (Geometric current : entities) { + if (current instanceof Surface) { + Surface surface = (Surface) current; + Vertex n = surface.normal(); + //loop existing vertices + Boolean exists = false; + for (Vertex v : normals) { + if (exists==false) { + if (v.coincides(n)) { + exists = true; + } + Vertex flip = n.scale(-1); + if (v.coincides(flip)) { + exists = true; + } + } + } + if (exists==false) { + normals.add(n); + } + } + } + //loop backwards and align normals + for (Vertex v : normals) { + for (Geometric current : entities) { + if (current instanceof Surface) { + Surface surface = (Surface) current; + Vertex n = surface.normal(); + if (v.coincides(n)) { + //ok + } + Vertex flip = n.scale(-1); + if (v.coincides(flip)) { + surface.flip(); + } + } + } + } + } + }; + normalMenu.add(flip); + } + menu.add(normalMenu); + } //Submenu for subdivision algorithms *************** *** 928,931 **** --- 982,986 ---- AbstractAction catmullClark = new GeometricMenuAction(arguments, "CatmullClark") { //http://en.wikipedia.org/wiki/Catmull%E2%80%93Clark_subdivision_surface + //CLEANING OF NORMALS!2 Space owner; *************** *** 1077,1085 **** if ((f.coincides(corner)) || (corner.getEdges().size()>corner.getSurfaces().size())) { ! //this does not yet work... ! n = 5.0; ! x = (1 * r.getX() + (2) * corner.getX()) / 3; ! y = (1 * r.getY() + (2) * corner.getY()) / 3; ! z = (1 * r.getZ() + (2) * corner.getZ()) / 3; } else { x = (f.getX() + 2 * r.getX() + (n-3) * corner.getX()) / n; --- 1132,1157 ---- if ((f.coincides(corner)) || (corner.getEdges().size()>corner.getSurfaces().size())) { ! //subdivision as averaging along 2d edge ! r = new Vertex(0,0,0); ! double count = 0.0; ! Collection<Edge> cEdges = corner.getEdges(); ! for (Edge e : cEdges) { ! Collection<Surface> cSurfaces = e.getSurfaces(); ! if (cSurfaces.size()==1) { ! //only count in edge edges ! r = r.add(e.center()); ! count = count + 1.0; ! } ! } ! r = r.add(corner.copy()); ! r = r.scale(1/(count+1.0)); ! ! //x = (1 * r.getX() + (2) * corner.getX()) / 3; ! //y = (1 * r.getY() + (2) * corner.getY()) / 3; ! //z = (1 * r.getZ() + (2) * corner.getZ()) / 3; ! ! x = r.getX(); ! y = r.getY(); ! z = r.getZ(); } else { x = (f.getX() + 2 * r.getX() + (n-3) * corner.getX()) / n; |