bprocessor-commit Mailing List for B-processor (Page 45)
Status: Pre-Alpha
Brought to you by:
henryml
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(117) |
Aug
(151) |
Sep
(157) |
Oct
(81) |
Nov
(117) |
Dec
(119) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(183) |
Feb
(130) |
Mar
(117) |
Apr
(61) |
May
(82) |
Jun
(45) |
Jul
(149) |
Aug
(173) |
Sep
(199) |
Oct
(165) |
Nov
(107) |
Dec
(137) |
2007 |
Jan
(124) |
Feb
(58) |
Mar
(123) |
Apr
(80) |
May
(130) |
Jun
(64) |
Jul
(31) |
Aug
(42) |
Sep
(114) |
Oct
(167) |
Nov
(239) |
Dec
(200) |
2008 |
Jan
(43) |
Feb
(43) |
Mar
(4) |
Apr
(9) |
May
(5) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(13) |
Oct
(9) |
Nov
(12) |
Dec
|
2009 |
Jan
|
Feb
(20) |
Mar
(7) |
Apr
(12) |
May
(34) |
Jun
(72) |
Jul
|
Aug
(3) |
Sep
(31) |
Oct
(2) |
Nov
(8) |
Dec
(4) |
2010 |
Jan
(5) |
Feb
(32) |
Mar
(8) |
Apr
(7) |
May
(36) |
Jun
|
Jul
(11) |
Aug
(15) |
Sep
(7) |
Oct
(2) |
Nov
(13) |
Dec
(80) |
2011 |
Jan
|
Feb
|
Mar
(8) |
Apr
(12) |
May
(32) |
Jun
(9) |
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(8) |
2012 |
Jan
|
Feb
|
Mar
(3) |
Apr
(5) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(22) |
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael L. <he...@us...> - 2007-11-02 11:05:34
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13425/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: a step in elliminating Net Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.192 retrieving revision 1.193 diff -C2 -d -r1.192 -r1.193 *** Space.java 2 Nov 2007 10:49:57 -0000 1.192 --- Space.java 2 Nov 2007 11:05:34 -0000 1.193 *************** *** 2416,2419 **** --- 2416,2427 ---- /** + * Returns true if this space is a net + * @return true if this space is a net + */ + public boolean isNet() { + return level == NET_LEVEL; + } + + /** * The level of the space, is one of the static final values that resemples * space, element or part |
From: Michael L. <he...@us...> - 2007-11-02 10:50:03
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6963/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: Small stuff Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** PopupMenu.java 1 Nov 2007 12:02:42 -0000 1.61 --- PopupMenu.java 2 Nov 2007 10:50:04 -0000 1.62 *************** *** 408,412 **** menu.add(simplify); ! AbstractAction makeUnion = new GeometricMenuAction(arguments, "Make Union") { public void actionPerformed(ActionEvent e) { Collection<Space> interior = new HashSet<Space>(); --- 408,412 ---- menu.add(simplify); ! AbstractAction makeUnion = new GeometricMenuAction(arguments, "Make My Union") { public void actionPerformed(ActionEvent e) { Collection<Space> interior = new HashSet<Space>(); |
From: Michael L. <he...@us...> - 2007-11-02 10:50:03
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6931/src/net/sourceforge/bprocessor/model Modified Files: Space.java Net.java Log Message: Small stuff Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.191 retrieving revision 1.192 diff -C2 -d -r1.191 -r1.192 *** Space.java 1 Nov 2007 12:48:07 -0000 1.191 --- Space.java 2 Nov 2007 10:49:57 -0000 1.192 *************** *** 51,56 **** public static final int NET_LEVEL = 6; ! /** part Functional Type */ private boolean isUnion = false; /** The name */ private String name; --- 51,57 ---- public static final int NET_LEVEL = 6; ! /** union flag */ private boolean isUnion = false; + /** The name */ private String name; Index: Net.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Net.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Net.java 10 Apr 2007 20:54:09 -0000 1.2 --- Net.java 2 Nov 2007 10:49:57 -0000 1.3 *************** *** 7,11 **** package net.sourceforge.bprocessor.model; - import org.apache.log4j.Logger; /** * The B-Net class --- 7,10 ---- *************** *** 14,20 **** public class Net extends Space { - /** The logger */ - private static Logger log = Logger.getLogger(Net.class); - /** * Generic constructor --- 13,16 ---- |
From: Michael L. <he...@us...> - 2007-11-01 12:48:04
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24127/src/net/sourceforge/bprocessor/model Modified Files: Command.java Space.java Log Message: uses surface.erase in place of surface.delete in place.delete Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.190 retrieving revision 1.191 diff -C2 -d -r1.190 -r1.191 *** Space.java 31 Oct 2007 15:46:10 -0000 1.190 --- Space.java 1 Nov 2007 12:48:07 -0000 1.191 *************** *** 1546,1550 **** } for (Surface current : deletion) { ! current.delete(); } getOwner().remove(this); --- 1546,1550 ---- } for (Surface current : deletion) { ! current.erase(); } getOwner().remove(this); Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Command.java 1 Nov 2007 12:02:48 -0000 1.19 --- Command.java 1 Nov 2007 12:48:07 -0000 1.20 *************** *** 495,499 **** Collection<Surface> env = new LinkedList(space.getEnvelope()); for (Surface current : env) { ! current.delete(); } Space owner = space.getOwner(); --- 495,499 ---- Collection<Surface> env = new LinkedList(space.getEnvelope()); for (Surface current : env) { ! current.erase(); } Space owner = space.getOwner(); |
From: Michael L. <he...@us...> - 2007-11-01 12:02:51
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6373/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: Small change to subdivision command Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Command.java 29 Oct 2007 18:08:32 -0000 1.18 --- Command.java 1 Nov 2007 12:02:48 -0000 1.19 *************** *** 492,512 **** } ! space.clear(); ! ! for (Surface quad : faces) { ! for (Edge current : quad.getEdges()) { ! if (current.from.getOwner() == null) { ! space.add(current.from); ! } ! if (current.to.getOwner() == null) { ! space.add(current.to); ! } ! if (current.getOwner() == null) { ! space.add(current); } } - space.add(quad); } Project.getInstance().changed(Project.getInstance()); } --- 492,524 ---- } ! if (envelope) { ! Collection<Surface> env = new LinkedList(space.getEnvelope()); ! for (Surface current : env) { ! current.delete(); ! } ! Space owner = space.getOwner(); ! for (Surface quad : faces) { ! owner.insert(quad); ! } ! } else { ! space.clear(); ! for (Surface quad : faces) { ! for (Edge current : quad.getEdges()) { ! if (current.from.getOwner() == null) { ! space.add(current.from); ! } ! if (current.to.getOwner() == null) { ! space.add(current.to); ! } ! if (current.getOwner() == null) { ! space.add(current); ! } } + space.add(quad); } } + + Project.getInstance().changed(Project.getInstance()); } |
From: Michael L. <he...@us...> - 2007-11-01 12:02:49
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6365/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: Small change to subdivision command Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** PopupMenu.java 31 Oct 2007 15:45:17 -0000 1.60 --- PopupMenu.java 1 Nov 2007 12:02:42 -0000 1.61 *************** *** 280,284 **** { ! AbstractAction action = new SpaceMenuAction(sp, "Smooth...") { public void actionPerformed(ActionEvent event) { Command command = new Command.SmoothSpace(space); --- 280,284 ---- { ! AbstractAction action = new SpaceMenuAction(sp, "Subdivide...") { public void actionPerformed(ActionEvent event) { Command command = new Command.SmoothSpace(space); |
From: rimestad <rim...@us...> - 2007-10-31 15:46:31
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2966/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Log Message: small simplification Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.198 retrieving revision 1.199 diff -C2 -d -r1.198 -r1.199 *** Surface.java 29 Oct 2007 18:09:30 -0000 1.198 --- Surface.java 31 Oct 2007 15:46:28 -0000 1.199 *************** *** 567,573 **** HashMap map = new HashMap(); Surface surface = (Surface) copy(map); ! Collection<Surface> surfaces = new LinkedList<Surface>(); ! surfaces.add(surface); ! space.addAll(surfaces); return surface; } --- 567,571 ---- HashMap map = new HashMap(); Surface surface = (Surface) copy(map); ! space.addAll(surface); return surface; } |
From: rimestad <rim...@us...> - 2007-10-31 15:46:07
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2922/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: some minor fixes on the naming of functional spaces as well as a better implementation of makeUnion on a space Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.189 retrieving revision 1.190 diff -C2 -d -r1.189 -r1.190 *** Space.java 31 Oct 2007 11:33:23 -0000 1.189 --- Space.java 31 Oct 2007 15:46:10 -0000 1.190 *************** *** 1433,1437 **** */ public String getKindName() { ! if (this.isContainer()) { String lvl = getLevelName(); if (getClassification() != null) { --- 1433,1437 ---- */ public String getKindName() { ! if (this != getOwner().empty) { String lvl = getLevelName(); if (getClassification() != null) { *************** *** 2940,2944 **** public static void makeUnion(Collection<Space> interior) { Collection<Surface> boundary = new LinkedList<Surface>(); ! Collection<Surface> innerSurfs = new LinkedList<Surface>(); Space owner = null; for (Space s : interior) { --- 2940,2944 ---- public static void makeUnion(Collection<Space> interior) { Collection<Surface> boundary = new LinkedList<Surface>(); ! Collection<Surface> innerSurfs = new HashSet<Surface>(); Space owner = null; for (Space s : interior) { *************** *** 2957,3000 **** owner.add(union); - Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>(); - Map<Vertex, Vertex> copiedVertices = new HashMap<Vertex, Vertex>(); - Map<Edge, Edge> copiedEdges = new HashMap<Edge, Edge>(); - Map<Surface, Surface> copiedSurfaces = new HashMap<Surface, Surface>(); - Map<Space, Space> copiedSpaces = new HashMap<Space, Space>(); - for (Space space : interior) { - Space copy = space.copy(copiedVertices, copiedEdges, copiedSurfaces, copiedSpaces); - map.put(space, copy); - union.add(copy); - } - - for (Surface surface : innerSurfs) { - Surface copy = (Surface) surface.copy(map); - Space front = surface.getFrontDomain(); - if (front != owner.getEmpty()) { - Space newFront = (Space) map.get(front); - if (newFront != null) { - copy.setFrontDomain(newFront); - } - } - Space back = surface.getBackDomain(); - if (back != owner.getEmpty()) { - Space newBack = (Space) map.get(back); - if (newBack != null) { - copy.setBackDomain(newBack); - } - } - union.add(copy); - surface.erase(); - } - - Map<Geometric, Geometric> map2 = new HashMap<Geometric, Geometric>(); for (Surface surface : boundary) { ! Surface copy = copiedSurfaces.get(surface); Space front = surface.getFrontDomain(); if (!interior.contains(front)) { copy.setFrontDomain(union.getEmpty()); } else { - copy.setFrontDomain((Space)map.get(front)); surface.setFrontDomain(union); } Space back = surface.getBackDomain(); --- 2957,2968 ---- owner.add(union); for (Surface surface : boundary) { ! Surface copy = surface.copy(union); Space front = surface.getFrontDomain(); if (!interior.contains(front)) { copy.setFrontDomain(union.getEmpty()); } else { surface.setFrontDomain(union); + copy.setFrontDomain(front); } Space back = surface.getBackDomain(); *************** *** 3002,3013 **** copy.setBackDomain(union.getEmpty()); } else { - copy.setBackDomain((Space)map.get(back)); surface.setBackDomain(union); } ! union.add(copy); } ! for (Space s : interior) { ! s.delete(); } } --- 2970,3004 ---- copy.setBackDomain(union.getEmpty()); } else { surface.setBackDomain(union); + copy.setBackDomain(back); } ! } ! Set<Edge> danglingEdges = new HashSet<Edge>(); ! for (Surface surface : innerSurfs) { ! owner.remove(surface); ! danglingEdges.addAll(surface.getEdges()); ! union.add(surface); } ! Set<Vertex> danglingVertex = new HashSet<Vertex>(); ! for (Edge e : danglingEdges) { ! if (e.getSurfaces().isEmpty()) { ! danglingVertex.add(e.getFrom()); ! danglingVertex.add(e.getTo()); ! owner.remove(e); ! union.add(e); ! } ! } ! ! for (Vertex v : danglingVertex) { ! if (v.getEdges().isEmpty()) { ! owner.remove(v); ! union.add(v); ! } ! } ! ! for (Space space : interior) { ! owner.elements.remove(space.getId()); ! union.add(space); } } |
From: rimestad <rim...@us...> - 2007-10-31 15:45:22
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2495/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: removed unused code Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** PopupMenu.java 29 Oct 2007 18:13:04 -0000 1.59 --- PopupMenu.java 31 Oct 2007 15:45:17 -0000 1.60 *************** *** 410,416 **** AbstractAction makeUnion = new GeometricMenuAction(arguments, "Make Union") { public void actionPerformed(ActionEvent e) { - Collection<Surface> surfaces = new HashSet<Surface>(); Collection<Space> interior = new HashSet<Space>(); - Collection<Space> spaces = new HashSet<Space>(); Space owner = null; --- 410,414 ---- |
From: rimestad <rim...@us...> - 2007-10-31 11:35:50
|
Update of /cvsroot/bprocessor//gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31896/src/net/sourceforge/bprocessor/gui/actions Modified Files: ImportFileReader.java FileImportActionListener.java Log Message: coordinatesystems are added to unions at creation and envelope are calculated at import of obj Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor//gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FileImportActionListener.java 29 Oct 2007 18:16:21 -0000 1.11 --- FileImportActionListener.java 31 Oct 2007 11:35:17 -0000 1.12 *************** *** 112,115 **** --- 112,116 ---- ImportFileReader.importObjFile(lfile, s, info.objPanel.getScale(), info.objPanel.getDirection(), info.objPanel.getCalcNormals()); + s.computeEnvelope(); Project.getInstance().changed(s); Project.getInstance().checkpoint(); Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor//gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ImportFileReader.java 29 Oct 2007 18:16:21 -0000 1.10 --- ImportFileReader.java 31 Oct 2007 11:35:17 -0000 1.11 *************** *** 218,222 **** } into.setLocked(true); - into.add(new CoordinateSystem(new Vertex(0, 0, 0))); into.changed(); stream.close(); --- 218,221 ---- |
From: rimestad <rim...@us...> - 2007-10-31 11:33:37
|
Update of /cvsroot/bprocessor//gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31138/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java Log Message: changed unions in the model to be on same level as their owner Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor//gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** GenericTreeView.java 22 Oct 2007 06:55:01 -0000 1.116 --- GenericTreeView.java 31 Oct 2007 11:33:27 -0000 1.117 *************** *** 638,647 **** Set surfaces = space.getEnvelope(); add(new SurfaceContainer("Envelope", surfaces)); ! String lvlstr = ""; ! if (space.isUnion()) { ! lvlstr = Space.levelToString(space.getLevel()); ! } else { ! lvlstr = Space.levelToString(space.getLevel() + 1); ! } add(new ElementContainer(lvlstr, space.getElements())); add(new GeometryContainer("Geometry", space)); --- 638,642 ---- Set surfaces = space.getEnvelope(); add(new SurfaceContainer("Envelope", surfaces)); ! String lvlstr = Space.levelToString(space.getLevel() + 1); add(new ElementContainer(lvlstr, space.getElements())); add(new GeometryContainer("Geometry", space)); |
From: rimestad <rim...@us...> - 2007-10-31 11:33:27
|
Update of /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31130/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: changed unions in the model to be on same level as their owner Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.188 retrieving revision 1.189 diff -C2 -d -r1.188 -r1.189 *** Space.java 29 Oct 2007 18:10:15 -0000 1.188 --- Space.java 31 Oct 2007 11:33:23 -0000 1.189 *************** *** 248,252 **** s.add(new CoordinateSystem(new Vertex(0, 0, 0))); s.setUnion(true); ! s.setLevel(level--); return s; } --- 248,252 ---- s.add(new CoordinateSystem(new Vertex(0, 0, 0))); s.setUnion(true); ! s.setLevel(level); return s; } *************** *** 1299,1302 **** --- 1299,1303 ---- ArrayList<Attribute> res = new ArrayList<Attribute>(); res.add(new Attribute("Name", getName())); + res.add(new Attribute("Level", "" + getLevel())); if (getOwner() == Project.getInstance().world()) { if (isConstructionSpace()) { *************** *** 1384,1388 **** break; } ! return res.concat(Space.levelToString(level)); } --- 1385,1390 ---- break; } ! int lvl = level - (isUnion() ? 1 : 0); ! return res.concat(Space.levelToString(lvl)); } *************** *** 1873,1876 **** --- 1875,1887 ---- Vertex p2 = new Vertex(xmax, ymax, zmin); Vertex p1 = new Vertex(xmax, ymin, zmin); + if (isUnion()) { + CoordinateSystem cs = getCoordinateSystems().iterator().next(); + if (cs != null) { + p4 = cs.translate(p4); + p3 = cs.translate(p3); + p2 = cs.translate(p2); + p1 = cs.translate(p1); + } + } getOwner().add(p1); getOwner().add(p2); |
From: Michael L. <he...@us...> - 2007-10-31 07:33:37
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2152/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: fixed bug that caused envelope to contain interior surfaces Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Display.java 29 Oct 2007 18:14:37 -0000 1.43 --- Display.java 31 Oct 2007 07:33:32 -0000 1.44 *************** *** 1057,1061 **** Space space = (Space) current; ! Collection<Surface> envelope = space.getEnvelope(); if (envelope.isEmpty()) { envelope.addAll(space.getSurfaces()); --- 1057,1061 ---- Space space = (Space) current; ! Collection<Surface> envelope = new LinkedList(space.getEnvelope()); if (envelope.isEmpty()) { envelope.addAll(space.getSurfaces()); |
From: rimestad <rim...@us...> - 2007-10-29 18:16:18
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25598/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileImportActionListener.java ImportFileReader.java Log Message: added a calc normals checkbox to obj import window that make importer call calcSmoothNormals on all surfaces, if none is present in the file. Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FileImportActionListener.java 29 Oct 2007 09:05:18 -0000 1.10 --- FileImportActionListener.java 29 Oct 2007 18:16:21 -0000 1.11 *************** *** 17,20 **** --- 17,21 ---- import javax.swing.BoxLayout; + import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFileChooser; *************** *** 110,114 **** into.add(s); ImportFileReader.importObjFile(lfile, s, info.objPanel.getScale(), ! info.objPanel.getDirection()); Project.getInstance().changed(s); Project.getInstance().checkpoint(); --- 111,115 ---- into.add(s); ImportFileReader.importObjFile(lfile, s, info.objPanel.getScale(), ! info.objPanel.getDirection(), info.objPanel.getCalcNormals()); Project.getInstance().changed(s); Project.getInstance().checkpoint(); *************** *** 125,128 **** --- 126,130 ---- private JComboBox basis; private JTextField scale; + private JCheckBox generateNomals; public OBJJPanel() { *************** *** 136,139 **** --- 138,144 ---- scale.addActionListener(this); this.add(scale); + generateNomals = new JCheckBox("Calc normals"); + generateNomals.setSelected(false); + this.add(generateNomals); } *************** *** 158,161 **** --- 163,174 ---- /** + * Tell if normals should be calculated + * @return a boolean value + */ + public boolean getCalcNormals() { + return generateNomals.isSelected(); + } + + /** * Return a int beeing one of the static finals XY, ZX, YZ which * is the coords that should be treated as XY plane when importing *************** *** 263,267 **** */ private CVSinfo(JFileChooser fc) { ! setPreferredSize(new Dimension(100, 50)); csvPanel = new CSVJPanel(); objPanel = new OBJJPanel(); --- 276,280 ---- */ private CVSinfo(JFileChooser fc) { ! setPreferredSize(new Dimension(150, 50)); csvPanel = new CSVJPanel(); objPanel = new OBJJPanel(); Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ImportFileReader.java 29 Oct 2007 09:05:18 -0000 1.9 --- ImportFileReader.java 29 Oct 2007 18:16:21 -0000 1.10 *************** *** 67,74 **** * @param scale The scale to import in * @param basisPlane the plane to use as xy plane. Use one of the static final ints in * net.sourceforge.bprocessor.gui.actions.FileImportActionListener * @throws IOException a possible file read error */ ! public static void importObjFile(File f, Space into, double scale, int basisPlane) throws IOException { if (f.exists()) { --- 67,76 ---- * @param scale The scale to import in * @param basisPlane the plane to use as xy plane. Use one of the static final ints in + * @param calcNormals Should the import calc smooth normals if there aint any * net.sourceforge.bprocessor.gui.actions.FileImportActionListener * @throws IOException a possible file read error */ ! public static void importObjFile(File f, Space into, double scale, ! int basisPlane, boolean calcNormals) throws IOException { if (f.exists()) { *************** *** 86,89 **** --- 88,92 ---- Space currentGroup = into.createConstructionSpace("Object"); Material currentMaterial = null; + boolean missNormals = false; groups.add(currentGroup); int lineNum = 0; *************** *** 165,168 **** --- 168,173 ---- if (!normals.isEmpty()) { s.setNormals(normals); + } else { + missNormals = true; } surfaces.add(s); *************** *** 192,198 **** } for (Space s : groups) { ! if (!s.getVertices().isEmpty()) { into.add(s); } } for (Material m : materialMap.values()) { --- 197,204 ---- } for (Space s : groups) { ! if (!s.getEnvelope().isEmpty()) { into.add(s); } + s.setLocked(true); } for (Material m : materialMap.values()) { *************** *** 206,211 **** --- 212,222 ---- } for (Surface s : surfaces) { + if (calcNormals && missNormals) { + s.calcNormals(); + } into.addProtected(s); } + into.setLocked(true); + into.add(new CoordinateSystem(new Vertex(0, 0, 0))); into.changed(); stream.close(); |
From: rimestad <rim...@us...> - 2007-10-29 18:14:34
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24699/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: Added displaylists to display but deactivated them for now Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Display.java 26 Oct 2007 08:58:40 -0000 1.42 --- Display.java 29 Oct 2007 18:14:37 -0000 1.43 *************** *** 11,14 **** --- 11,15 ---- import java.util.Collection; import java.util.Collections; + import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; *************** *** 90,93 **** --- 91,102 ---- private static byte[] highlight = new byte[128]; + + + private static Map<Geometric, Integer> displayLists = + new HashMap<Geometric, Integer>(); + private static Map<Geometric, Integer> displayListsSelecting = + new HashMap<Geometric, Integer>(); + + private static final boolean USEDL = false; /** *************** *** 513,516 **** --- 522,535 ---- } glu.gluTessEndPolygon(tesselator); + /* + List<Vertex> vertices = surface.getVertices(); + int index = 0; + if (surface.getNormals() != null) { + for (Vertex v : surface.getNormals()) { + Vertex v0 = vertices.get(index); + draw(new Edge(v0.add(v), v0)); + index++; + } + }*/ } *************** *** 768,771 **** --- 787,824 ---- private static void draw(Space space, boolean inside) { + if (space.isUnion()) { + CoordinateSystem cs = space.getCoordinateSystems().iterator().next(); + Vertex translation = cs.center(); + gl.glPushMatrix(); + gl.glTranslated(translation.getX(), translation.getY(), translation.getZ()); + } + if (space.isLocked() && USEDL) { + if (selecting) { + Integer index = displayListsSelecting.get(space); + if (index != null) { + gl.glCallList(index); + return; + } else { + //if there aint any start generation of one + index = gl.glGenLists(1); + displayListsSelecting.put(space, index); + System.out.println(index + " for " + space); + gl.glNewList(index, GL.GL_COMPILE_AND_EXECUTE); + } + } else { + //Locate displaylist for space and draw it + Integer index = displayLists.get(space); + if (index != null) { + gl.glCallList(index); + return; + } else { + //if there aint any start generation of one + index = gl.glGenLists(1); + displayLists.put(space, index); + System.out.println(index + " for " + space); + gl.glNewList(index, GL.GL_COMPILE_AND_EXECUTE); + } + } + } Set<Geometric> hidden = new HashSet(); hidden.addAll(camera.getHiddenGeometrics()); *************** *** 885,893 **** } } ! ! for (Constructor current : space.getConstructors()) { ! if (!hidden.contains(current)) { ! constructors.add(current); } } } --- 938,949 ---- } } ! Space work = space; ! while (work != null) { ! for (Constructor current : work.getConstructors()) { ! if (!hidden.contains(current)) { ! constructors.add(current); ! } } + work = (Space)work.parent(); } } *************** *** 966,973 **** } } ! for (Space current : elements) { draw(current, inside || (current == active)); } } --- 1022,1035 ---- } } ! if (space.isLocked() && USEDL) { ! //will only reach here if a displaylist are being generated ! gl.glEndList(); ! } for (Space current : elements) { draw(current, inside || (current == active)); } + if (space.isUnion()) { + gl.glPopMatrix(); + } } |
From: rimestad <rim...@us...> - 2007-10-29 18:13:49
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24300/src/net/sourceforge/bprocessor/gl/tool Modified Files: SpaceTool.java Log Message: removed some code in space.copy() had to add it where it were used Index: SpaceTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SpaceTool.java,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** SpaceTool.java 19 Oct 2007 10:48:58 -0000 1.88 --- SpaceTool.java 29 Oct 2007 18:13:50 -0000 1.89 *************** *** 251,257 **** --- 251,259 ---- if (space != null) { Space spaceCopy = space.copy(); + space.getOwner().add(spaceCopy); Selection.primary().set(spaceCopy); glv.changeTool(Tool.MOVE_TOOL); space.getOwner().changed(); + Project.getInstance().checkpoint(); } } |
From: rimestad <rim...@us...> - 2007-10-29 18:13:01
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24125/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java GUI.java Log Message: changed make union operation to use method in space Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** PopupMenu.java 26 Oct 2007 13:01:24 -0000 1.58 --- PopupMenu.java 29 Oct 2007 18:13:04 -0000 1.59 *************** *** 9,17 **** import java.awt.event.ActionEvent; import java.util.Collection; - import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; - import java.util.Map; import java.util.Set; --- 9,15 ---- *************** *** 237,240 **** --- 235,239 ---- Space space = (Space)iter.next(); Space spaceCopy = space.copy(); + space.getOwner().add(spaceCopy); Selection.primary().set(spaceCopy); Project.getInstance().checkpoint(); *************** *** 419,517 **** if (ent instanceof Space) { interior.add((Space) ent); - } else if (ent instanceof Surface) { - surfaces.add((Surface)ent); } } ! for (Space space : interior) { ! surfaces.addAll(space.getEnvelope()); ! spaces.add(space); ! owner = space.getOwner(); ! } ! ! for (Surface surface : surfaces) { ! owner = surface.getOwner(); ! Space empty = owner.getEmpty(); ! if (surface.getFrontDomain() != empty) { ! spaces.add(surface.getFrontDomain()); ! } ! if (surface.getBackDomain() != empty) { ! spaces.add(surface.getBackDomain()); ! } ! } ! ! Collection<Surface> inside = new LinkedList<Surface>(); ! Collection<Surface> border = new LinkedList<Surface>(); ! for (Surface surface : surfaces) { ! if (interior.contains(surface.getFrontDomain()) && ! interior.contains(surface.getBackDomain())) { ! inside.add(surface); ! } else { ! border.add(surface); ! } ! } ! Space union = owner.createUnion("Union"); ! ! Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>(); ! ! for (Space space : spaces) { ! Space copy = space.simpleCopy(); ! map.put(space, copy); ! union.add(copy); ! } ! ! Collection<Surface> all = new LinkedList<Surface>(); ! Collection<Surface> deletion = new LinkedList<Surface>(); ! ! for (Surface surface : inside) { ! Surface copy = (Surface) surface.copy(map); ! Space front = surface.getFrontDomain(); ! if (front != owner.getEmpty()) { ! Space newFront = (Space) map.get(front); ! if (newFront != null) { ! copy.setFrontDomain(newFront); ! } ! } ! Space back = surface.getBackDomain(); ! if (back != owner.getEmpty()) { ! Space newBack = (Space) map.get(back); ! if (newBack != null) { ! copy.setBackDomain(newBack); ! } ! } ! all.add(copy); ! deletion.add(surface); ! } ! for (Surface surface : border) { ! Surface copy = (Surface) surface.copy(map); ! Space front = surface.getFrontDomain(); ! if (front != owner.getEmpty()) { ! Space newFront = (Space) map.get(front); ! if (newFront != null) { ! copy.setFrontDomain(newFront); ! } ! } ! Space back = surface.getBackDomain(); ! if (back != owner.getEmpty()) { ! Space newBack = (Space) map.get(back); ! if (newBack != null) { ! copy.setBackDomain(newBack); ! } ! } ! all.add(copy); ! if (front == owner.getEmpty() || back == owner.getEmpty()) { ! deletion.add(surface); ! } ! } ! union.addAll(all); ! for (Geometric geometric : deletion) { ! geometric.delete(); ! } ! for (Space space : spaces) { ! space.delete(); ! } ! owner.add(union); Project.getInstance().changed(owner); - Selection.primary().set(union); Project.getInstance().checkpoint(); } --- 418,426 ---- if (ent instanceof Space) { interior.add((Space) ent); } } ! Space.makeUnion(interior); Project.getInstance().changed(owner); Project.getInstance().checkpoint(); } Index: GUI.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/GUI.java,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** GUI.java 22 Oct 2007 10:00:17 -0000 1.78 --- GUI.java 29 Oct 2007 18:13:04 -0000 1.79 *************** *** 403,407 **** Geometric g = iter.next(); if (g instanceof Space) { ! copied.add(((Space)g).copy()); } else if (g instanceof Edge) { Edge copy = ((Edge)g).copy(); --- 403,409 ---- Geometric g = iter.next(); if (g instanceof Space) { ! Space copy = ((Space)g).copy(); ! g.getOwner().add(copy); ! copied.add(copy); } else if (g instanceof Edge) { Edge copy = ((Edge)g).copy(); *************** *** 430,433 **** --- 432,437 ---- } Selection.primary().set(copied); + Project.getInstance().changed(Project.getInstance()); + Project.getInstance().checkpoint(); } }); |
From: rimestad <rim...@us...> - 2007-10-29 18:10:19
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23069/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: added a lock on space, and a createUnion from a list of spaces Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.187 retrieving revision 1.188 diff -C2 -d -r1.187 -r1.188 *** Space.java 29 Oct 2007 09:04:29 -0000 1.187 --- Space.java 29 Oct 2007 18:10:15 -0000 1.188 *************** *** 66,69 **** --- 66,72 ---- private int level; + /** Tell if the space is finished and therefore cannot be edited */ + private boolean locked = false; + /** If the constructionspace is transparent */ private boolean transparent; *************** *** 172,175 **** --- 175,179 ---- */ protected Space() { + super(); envelope = new HashSet<Surface>(); transform = new TransformStack(); *************** *** 231,247 **** */ public Space createConstructionSpace(String name) { ! if (this.level == PART_LEVEL) { ! throw new Error("Not legal to make further levels of detail, max level is PART"); ! } ! if (this.level == ELEMENT_LEVEL) { ! return new Space(name, Space.CONSTRUCTION, PART_LEVEL, false); ! } ! if (this.level == SPACE_LEVEL) { ! return new Space(name, Space.CONSTRUCTION, ELEMENT_LEVEL, true); ! } ! if (this.level == PROJECT_LEVEL) { ! return new Space(name, Space.CONSTRUCTION, SPACE_LEVEL, true); ! } ! return null; } --- 235,240 ---- */ public Space createConstructionSpace(String name) { ! int lvl = this.level + 1; ! return new Space(name, Space.CONSTRUCTION, lvl, true); } *************** *** 253,258 **** public Space createUnion(String name) { Space s = createConstructionSpace(name); ! s.setLevel(this.getLevel()); s.setUnion(true); return s; } --- 246,252 ---- public Space createUnion(String name) { Space s = createConstructionSpace(name); ! s.add(new CoordinateSystem(new Vertex(0, 0, 0))); s.setUnion(true); + s.setLevel(level--); return s; } *************** *** 264,284 **** */ public Space createConstructionSpace(Classification cl) { ! Space cur; ! if (this.level == ELEMENT_LEVEL) { ! cur = new Space("", Space.CONSTRUCTION, PART_LEVEL, false); ! cur.setClassification(cl); ! return cur; ! } ! if (this.level == SPACE_LEVEL) { ! cur = new Space("", Space.CONSTRUCTION, ELEMENT_LEVEL, true); ! cur.setClassification(cl); ! return cur; ! } ! if (this.level == PROJECT_LEVEL) { ! cur = new Space("", Space.CONSTRUCTION, SPACE_LEVEL, true); cur.setClassification(cl); - return cur; } ! return null; } --- 258,266 ---- */ public Space createConstructionSpace(Classification cl) { ! Space cur = createConstructionSpace(""); ! if (cur != null) { cur.setClassification(cl); } ! return cur; } *************** *** 289,302 **** */ public Space createFunctionalSpace(String name) { ! if (this.level == ELEMENT_LEVEL) { ! return new Space(name, Space.FUNCTIONAL, PART_LEVEL, true); ! } ! if (this.level == SPACE_LEVEL) { ! return new Space(name, Space.FUNCTIONAL, ELEMENT_LEVEL, true); ! } ! if (this.level == PROJECT_LEVEL) { ! return new Space(name, Space.FUNCTIONAL, SPACE_LEVEL, true); } ! return null; } --- 271,279 ---- */ public Space createFunctionalSpace(String name) { ! int lvl = this.level + 1; ! if (isUnion()) { ! lvl--; } ! return new Space(name, Space.FUNCTIONAL, lvl, false); } *************** *** 305,331 **** * @param cl The classification * @return The space - * @throws Exception If a part is being extended */ ! public Space createFunctionalSpace(Classification cl) throws Exception { ! Space cur; ! if (this.level == PART_LEVEL) { ! throw new Exception("Not leagal to make further levels of detail, max level is PART"); ! } ! if (this.level == ELEMENT_LEVEL) { ! cur = new Space("", Space.FUNCTIONAL , PART_LEVEL, true); ! cur.setClassification(cl); ! return cur; ! } ! if (this.level == SPACE_LEVEL) { ! cur = new Space("", Space.FUNCTIONAL, ELEMENT_LEVEL, true); ! cur.setClassification(cl); ! return cur; ! } ! if (this.level == PROJECT_LEVEL) { ! cur = new Space("", Space.FUNCTIONAL, SPACE_LEVEL, true); cur.setClassification(cl); - return cur; } ! return null; } --- 282,292 ---- * @param cl The classification * @return The space */ ! public Space createFunctionalSpace(Classification cl) { ! Space cur = createFunctionalSpace(""); ! if (cur != null) { cur.setClassification(cl); } ! return cur; } *************** *** 1432,1460 **** */ public String getLevelName() { ! String lvl; ! switch (level) { case ELEMENT_LEVEL: ! lvl = "Elm"; break; case PART_LEVEL: ! lvl = "Prt"; break; case SPACE_LEVEL: ! lvl = "Spc"; break; case NET_LEVEL: ! lvl = "Net"; break; case PROJECT_LEVEL: ! lvl = "Proj"; break; default: ! lvl = "Unk"; break; } if (isUnion()) { ! return lvl + " Union " + id; } else { ! return lvl + id; } } --- 1393,1425 ---- */ public String getLevelName() { ! String res; ! int lvl = level; ! if (isUnion()) { ! lvl++; ! } ! switch (lvl) { case ELEMENT_LEVEL: ! res = "Elm"; break; case PART_LEVEL: ! res = "Prt"; break; case SPACE_LEVEL: ! res = "Spc"; break; case NET_LEVEL: ! res = "Net"; break; case PROJECT_LEVEL: ! res = "Proj"; break; default: ! res = "Unk"; break; } if (isUnion()) { ! return res + " Union " + id; } else { ! return res + id; } } *************** *** 1510,1515 **** result.addAll(s.collect()); } ! if (container) { ! result.addAll(collectInterior()); } return result; --- 1475,1484 ---- result.addAll(s.collect()); } ! if (isUnion()) { ! result.add(getConstructors().iterator().next().center()); ! } else { ! if (container) { ! result.addAll(collectInterior()); ! } } return result; *************** *** 1591,1596 **** Space copy = this.copy(copiedVertices, copiedEdges, copiedSurfaces, copiedSpaces); - this.getOwner().add(copy); - Project.getInstance().checkpoint(); return copy; } --- 1560,1563 ---- *************** *** 2937,2939 **** --- 2904,3003 ---- } } + + /** + * Tell if the space is locked or not + * @return the locked + */ + public boolean isLocked() { + return locked; + } + + /** + * Set a lock on the space to tell that it is finish + * @param locked the locked to set + */ + public void setLocked(boolean locked) { + this.locked = locked; + } + + /** + * Make a union out of a collection of spaces + * -All boundary surfaces are found and kept as envelope<br> + * -All geometry are copied into the union + * @param interior The spaces to make a union of + */ + public static void makeUnion(Collection<Space> interior) { + Collection<Surface> boundary = new LinkedList<Surface>(); + Collection<Surface> innerSurfs = new LinkedList<Surface>(); + Space owner = null; + for (Space s : interior) { + owner = s.getOwner(); + for (Surface surface : s.getEnvelope()) { + if (interior.contains(surface.getFrontDomain()) && + interior.contains(surface.getBackDomain())) { + innerSurfs.add(surface); + } else { + boundary.add(surface); + } + } + } + + Space union = owner.createUnion("unnamed"); + owner.add(union); + + Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>(); + Map<Vertex, Vertex> copiedVertices = new HashMap<Vertex, Vertex>(); + Map<Edge, Edge> copiedEdges = new HashMap<Edge, Edge>(); + Map<Surface, Surface> copiedSurfaces = new HashMap<Surface, Surface>(); + Map<Space, Space> copiedSpaces = new HashMap<Space, Space>(); + for (Space space : interior) { + Space copy = space.copy(copiedVertices, copiedEdges, copiedSurfaces, copiedSpaces); + map.put(space, copy); + union.add(copy); + } + + for (Surface surface : innerSurfs) { + Surface copy = (Surface) surface.copy(map); + Space front = surface.getFrontDomain(); + if (front != owner.getEmpty()) { + Space newFront = (Space) map.get(front); + if (newFront != null) { + copy.setFrontDomain(newFront); + } + } + Space back = surface.getBackDomain(); + if (back != owner.getEmpty()) { + Space newBack = (Space) map.get(back); + if (newBack != null) { + copy.setBackDomain(newBack); + } + } + union.add(copy); + surface.erase(); + } + + Map<Geometric, Geometric> map2 = new HashMap<Geometric, Geometric>(); + for (Surface surface : boundary) { + Surface copy = copiedSurfaces.get(surface); + Space front = surface.getFrontDomain(); + if (!interior.contains(front)) { + copy.setFrontDomain(union.getEmpty()); + } else { + copy.setFrontDomain((Space)map.get(front)); + surface.setFrontDomain(union); + } + Space back = surface.getBackDomain(); + if (!interior.contains(back)) { + copy.setBackDomain(union.getEmpty()); + } else { + copy.setBackDomain((Space)map.get(back)); + surface.setBackDomain(union); + } + union.add(copy); + } + + for (Space s : interior) { + s.delete(); + } + } } |
From: rimestad <rim...@us...> - 2007-10-29 18:09:27
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22693/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Log Message: First try on smoothnormals calc Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.197 retrieving revision 1.198 diff -C2 -d -r1.197 -r1.198 *** Surface.java 23 Oct 2007 07:20:48 -0000 1.197 --- Surface.java 29 Oct 2007 18:09:30 -0000 1.198 *************** *** 400,410 **** */ public void flip() { ! List lst = new ArrayList(edges.size()); ! Edge[] edges = new Edge[getEdges().size()]; ! getEdges().toArray(edges); ! for (int i = 0; i < edges.length; i++) { ! lst.add(edges[edges.length - i - 1]); } - setEdges(lst); Space holeBack = this.getBackDomain(); Space holeFront = this.getFrontDomain(); --- 400,413 ---- */ public void flip() { ! Collections.reverse(getEdges()); ! if (normals != null) { ! List<Vertex> toReverse = normals.subList(1, normals.size()); ! Collections.reverse(toReverse); ! int index = 1; ! for (Vertex v : toReverse) { ! normals.set(index, v); ! index++; ! } } Space holeBack = this.getBackDomain(); Space holeFront = this.getFrontDomain(); *************** *** 1977,1989 **** /** {@inheritDoc} */ public String getGeneralName() { ! if (getOwner() == Project.getInstance().world()) { ! return "Space Surface"; ! } ! ! if (getOwner().getOwner() == Project.getInstance().world()) { ! return "Element Surface"; ! } else { ! return "Part Surface"; } } --- 1980,2001 ---- /** {@inheritDoc} */ public String getGeneralName() { ! String res = ""; ! switch (getOwner().getLevel() + 1) { ! case Space.PROJECT_LEVEL: ! res = "Project Surface"; ! break; ! case Space.SPACE_LEVEL: ! res = "Space Surface"; ! break; ! case Space.ELEMENT_LEVEL: ! res = "Element Surface"; ! break; ! case Space.PART_LEVEL: ! res = "Part Surface"; ! break; ! default: ! break; } + return res; } *************** *** 2136,2138 **** --- 2148,2175 ---- this.normals = normals; } + + /** + * Calculate smooth normals for a surface + */ + public void calcNormals() { + List<Vertex> vertices = getVertices(); + List<Vertex> normals = new ArrayList<Vertex>(vertices.size()); + Vertex normal, other, addon; + for (Vertex v : vertices) { + double x = 0, y = 0, z = 0; + Set<Edge> edges = v.getEdges(); + for (Edge e : edges) { + other = e.otherVertex(v); + addon = v.minus(other); + addon.normalize(); + x += addon.getX(); + y += addon.getY(); + z += addon.getZ(); + } + normal = new Vertex(x, y, z); + normal.normalize(); + normals.add(normal); + } + this.setNormals(normals); + } } |
From: rimestad <rim...@us...> - 2007-10-29 18:08:30
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22295/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: Changed cylinder to insert into active space Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Command.java 28 Oct 2007 22:45:37 -0000 1.17 --- Command.java 29 Oct 2007 18:08:32 -0000 1.18 *************** *** 600,610 **** edges.add(new Edge(prev, first)); Surface bottom = new Surface(edges); ! Space inside = Project.getInstance().world().createConstructionSpace("Cylinder"); ! Space world = Project.getInstance().world(); bottom.setFrontDomain(inside); Set<Surface> sides = new HashSet<Surface>(); Surface top = bottom.extrusion(h, sides); ! world.add(inside); ! world.insert(bottom); for (Surface surface : sides) { List<Vertex> normals = new LinkedList<Vertex>(); --- 600,610 ---- edges.add(new Edge(prev, first)); Surface bottom = new Surface(edges); ! Space space = Project.getInstance().getActiveSpace(); ! Space inside = space.createConstructionSpace("Cylinder"); bottom.setFrontDomain(inside); Set<Surface> sides = new HashSet<Surface>(); Surface top = bottom.extrusion(h, sides); ! space.add(inside); ! space.insert(bottom); for (Surface surface : sides) { List<Vertex> normals = new LinkedList<Vertex>(); *************** *** 617,630 **** } surface.setNormals(normals); ! world.insert(surface); } Collection<Edge> visibleEdges = Surface.edges(sides); visibleEdges.removeAll(top.getEdges()); visibleEdges.removeAll(bottom.getEdges()); ! Project.getInstance().getCurrentCamera().getHiddenGeometrics().addAll(visibleEdges); sides.add(top); sides.add(bottom); ! world.insert(top); ! Project.getInstance().changed(world); Project.getInstance().checkpoint(); } --- 617,632 ---- } surface.setNormals(normals); ! space.insert(surface); } Collection<Edge> visibleEdges = Surface.edges(sides); visibleEdges.removeAll(top.getEdges()); visibleEdges.removeAll(bottom.getEdges()); ! for (Edge e : visibleEdges) { ! e.setSmooth(true); ! } sides.add(top); sides.add(bottom); ! space.insert(top); ! Project.getInstance().changed(space); Project.getInstance().checkpoint(); } |
From: rimestad <rim...@us...> - 2007-10-29 09:05:16
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24424/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileImportActionListener.java ImportFileReader.java Log Message: Made z-x plane and 1:100 default import param, and added spaces as normal geometry and not protected Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FileImportActionListener.java 22 Oct 2007 10:00:17 -0000 1.9 --- FileImportActionListener.java 29 Oct 2007 09:05:18 -0000 1.10 *************** *** 97,103 **** if (lfile.getName().endsWith(".csv")) { try { ! ImportFileReader.importCsvFile(lfile, Project.getInstance().world(), info.getSelectedFloor()); ! Project.getInstance().changed(Project.getInstance()); } catch (Exception ex) { log.error("Could not open file: " + lfile, ex); --- 97,104 ---- if (lfile.getName().endsWith(".csv")) { try { ! ImportFileReader.importCsvFile(lfile, Project.getInstance().getActiveSpace(), info.getSelectedFloor()); ! Project.getInstance().changed(Project.getInstance().getActiveSpace()); ! Project.getInstance().checkpoint(); } catch (Exception ex) { log.error("Could not open file: " + lfile, ex); *************** *** 105,112 **** } else if (lfile.getName().endsWith(".obj")) { try { ! Space s = Project.getInstance().world().createUnion(lfile.getName()); ImportFileReader.importObjFile(lfile, s, info.objPanel.getScale(), info.objPanel.getDirection()); ! Project.getInstance().world().add(s); } catch (Exception ex) { log.error("Could not open file: " + lfile, ex); --- 106,116 ---- } else if (lfile.getName().endsWith(".obj")) { try { ! Space into = Project.getInstance().getActiveSpace(); ! Space s = into.createUnion(lfile.getName()); ! into.add(s); ImportFileReader.importObjFile(lfile, s, info.objPanel.getScale(), info.objPanel.getDirection()); ! Project.getInstance().changed(s); ! Project.getInstance().checkpoint(); } catch (Exception ex) { log.error("Could not open file: " + lfile, ex); *************** *** 126,132 **** this.add(new JLabel("Baseplane")); basis = new JComboBox(new String[]{"X-Y", "Z-X", "Y-Z"}); this.add(basis); this.add(new JLabel("Scale")); ! scale = new JTextField("1:1", 5); scale.addActionListener(this); this.add(scale); --- 130,137 ---- this.add(new JLabel("Baseplane")); basis = new JComboBox(new String[]{"X-Y", "Z-X", "Y-Z"}); + basis.setSelectedIndex(1); this.add(basis); this.add(new JLabel("Scale")); ! scale = new JTextField("1:100", 5); scale.addActionListener(this); this.add(scale); Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ImportFileReader.java 24 Oct 2007 06:48:28 -0000 1.8 --- ImportFileReader.java 29 Oct 2007 09:05:18 -0000 1.9 *************** *** 187,194 **** } loadMaterials(new File(f.getParent() + "\\" + name), materialMap); } } for (Space s : groups) { ! into.addProtected(s); } for (Material m : materialMap.values()) { --- 187,198 ---- } loadMaterials(new File(f.getParent() + "\\" + name), materialMap); + } else { + log.warn("Did not understand line " + lineNum + " : " + line); } } for (Space s : groups) { ! if (!s.getVertices().isEmpty()) { ! into.add(s); ! } } for (Material m : materialMap.values()) { *************** *** 205,208 **** --- 209,215 ---- } into.changed(); + stream.close(); + br.close(); + reader.close(); } } *************** *** 412,415 **** --- 419,425 ---- throw new IOException("Problems in format at line " + line); } + bf.close(); + isr.close(); + fis.close(); } //check if there is something left to read |
From: rimestad <rim...@us...> - 2007-10-29 09:04:35
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24012/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: Made createUnion be placed on correct level Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.186 retrieving revision 1.187 diff -C2 -d -r1.186 -r1.187 *** Space.java 18 Oct 2007 13:47:47 -0000 1.186 --- Space.java 29 Oct 2007 09:04:29 -0000 1.187 *************** *** 253,256 **** --- 253,257 ---- public Space createUnion(String name) { Space s = createConstructionSpace(name); + s.setLevel(this.getLevel()); s.setUnion(true); return s; |
From: Michael L. <he...@us...> - 2007-10-28 22:45:43
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10047/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Command.java ParameterBlock.java Log Message: A smoothing operation is implemented on a collection of surfaces that are subdivided according to Catmull-clark rules Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** Edge.java 5 Oct 2007 13:30:49 -0000 1.97 --- Edge.java 28 Oct 2007 22:45:37 -0000 1.98 *************** *** 45,48 **** --- 45,51 ---- private boolean strippled; + /** Is smooth */ + private boolean smooth; + /** * Return the first vertex in a list of edges. *************** *** 198,201 **** --- 201,220 ---- strippled = c; } + + /** + * Returns the smooth flag + * @return isSmooth + */ + public boolean isSmooth() { + return smooth; + } + + /** + * Sets the smooth flag + * @param value new value of smooth + */ + public void setSmooth(boolean value) { + smooth = value; + } /** {@inheritDoc} */ *************** *** 661,664 **** --- 680,685 ---- } else if (a.getName().equals("Length")) { setLength(((Double)a.getValue()).doubleValue()); + } else if (a.getName().equals("Smooth")) { + setSmooth(((Boolean)a.getValue()).booleanValue()); } } *************** *** 673,676 **** --- 694,698 ---- res.add(new Attribute("Name", getName(), false)); res.add(new Attribute("Owner", getOwner(), false)); + res.add(new Attribute("Smooth", isSmooth(), true)); res.add(new Attribute("Length", new Double(getLength()))); return res; Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Command.java 26 Oct 2007 13:01:31 -0000 1.16 --- Command.java 28 Oct 2007 22:45:37 -0000 1.17 *************** *** 136,169 **** /** ! * */ ! public static class SmoothSpace extends Command { ! private Map<Vertex, List<Edge>> vmap; /** * ! * @param space Space */ ! public SmoothSpace(Space space) { ! parameters.put("space", space); } ! /** {@inheritDoc} */ ! public String getGeneralName() { ! return "Smooth"; } ! private Vertex common(Edge e1, Edge e2) { ! if (e2.contains(e1.from)) { ! return e1.from; ! } else { ! return e1.to; ! } } ! private Edge edge(Vertex v1, Vertex v2) { ! List<Edge> l1 = vmap.get(v1); ! List<Edge> l2 = vmap.get(v2); for (Edge current : l1) { if (current.otherVertex(v1) == v2) { --- 136,283 ---- /** ! * Inverse makes it possible to navigate the ! * Vertex-Edge-Surface relations in the ! * reverse direction. ! * */ ! public static class Inverse { ! private Collection<Vertex> vertices; ! private Collection<Edge> edges; ! private Collection<Surface> surfaces; ! private Map<Vertex, List<Edge>> v2e; ! private Map<Edge, List<Surface>> e2s; ! private Map<Vertex, List<Surface>> v2s; /** + * Constructs an Inverse object, which makes + * it possible to navigate geometry in reverse. * ! * @param surfaces Collection of surfaces */ ! public Inverse(List<Surface> surfaces) { ! this.surfaces = surfaces; ! edges = Surface.edges(surfaces); ! vertices = Edge.vertices(edges); ! ! v2e = new HashMap(); ! e2s = new HashMap(); ! v2s = new HashMap(); ! ! for (Vertex current : vertices) { ! v2e.put(current, new LinkedList()); ! } ! for (Edge current : edges) { ! List<Edge> fl = v2e.get(current.from); ! fl.add(current); ! List<Edge> tl = v2e.get(current.to); ! tl.add(current); ! e2s.put(current, new LinkedList()); ! } ! for (Surface current : surfaces) { ! for (Edge edge : current.getEdges()) { ! List<Surface> l = e2s.get(edge); ! l.add(current); ! } ! } ! for (Vertex current : vertices) { ! Set<Surface> set = new HashSet(); ! List<Edge> l = v2e.get(current); ! for (Edge edge : l) { ! set.addAll(e2s.get(edge)); ! } ! v2s.put(current, new LinkedList(set)); ! } } ! /** ! * Returns the vertices ! * @return the vertices ! */ ! public Collection<Vertex> vertices() { ! return vertices; } ! /** ! * Returns the edges ! * @return the edges ! */ ! public Collection<Edge> edges() { ! return edges; } + /** + * Returns the surfaces + * @return the surfaces + */ + public Collection<Surface> surfaces() { + return surfaces; + } ! /** ! * Returns the edges connected to specified vertex ! * @param vertex the vertex ! * @return the edges ! */ ! public List<Edge> edges(Vertex vertex) { ! return v2e.get(vertex); ! } ! ! /** ! * Returns the surfaces connected to specified edge ! * @param edge the edge ! * @return the surfaces ! */ ! public List<Surface> surfaces(Edge edge) { ! return e2s.get(edge); ! } ! ! /** ! * Returns the surfaces connected to the specified ! * vertex ! * @param vertex the vertex ! * @return the surfaces ! */ ! public List<Surface> surfaces(Vertex vertex) { ! return v2s.get(vertex); ! } ! } ! ! /** ! * Builder for building geometry ! * ! */ ! public static class Builder { ! private Map<Vertex, List<Edge>> v2e; ! ! /** ! * Constructs the builder ! * @param vertices collection of vertices ! */ ! public Builder(List<Vertex> vertices) { ! v2e = new HashMap(); ! for (Vertex current : vertices) { ! v2e.put(current, new LinkedList()); ! } ! } ! ! /** ! * Returns the edges connected to specified vertex ! * @param vertex the vertex ! * @return the edges ! */ ! public List<Edge> edges(Vertex vertex) { ! return v2e.get(vertex); ! } ! ! /** ! * Creates a new edge or returns an existing edge ! * between specified vertices ! * @param v1 Vertex 1 ! * @param v2 Vertex 2 ! * @return An edge between two vertices ! */ ! public Edge edge(Vertex v1, Vertex v2) { ! List<Edge> l1 = v2e.get(v1); ! List<Edge> l2 = v2e.get(v2); for (Edge current : l1) { if (current.otherVertex(v1) == v2) { *************** *** 177,195 **** } ! private Surface quad(Edge e1, Edge e2, Edge e3, Edge e4) { ! List edges = new ArrayList(); ! edges.add(e1); ! edges.add(e2); ! edges.add(e3); ! edges.add(e4); ! return new Surface(edges); } ! private Surface quad(Vertex v1, Vertex v2, Vertex v3, Vertex v4) { ! Edge e1 = edge(v1, v2); ! Edge e2 = edge(v2, v3); ! Edge e3 = edge(v3, v4); ! Edge e4 = edge(v4, v1); ! return quad(e1, e2, e3, e4); } --- 291,334 ---- } ! /** ! * Creates a surface with the specified array of edges ! * @param objects edges as arguments ! * @return new surface ! */ ! public Surface surface(Edge ...objects) { ! List<Edge> lst = new LinkedList(); ! for (Edge object : objects) { ! lst.add(object); ! } ! return new Surface(lst); } + } + + /** + * + */ + public static class SmoothSpace extends Command { ! /** ! * ! * @param space Space ! */ ! public SmoothSpace(Space space) { ! parameters.put("space", space); ! parameters.putDouble("n", 2); ! parameters.putBoolean("envelope", true); ! } ! ! /** {@inheritDoc} */ ! public String getGeneralName() { ! return "Subdivide"; ! } ! ! private Vertex common(Edge e1, Edge e2) { ! if (e2.contains(e1.from)) { ! return e1.from; ! } else { ! return e1.to; ! } } *************** *** 207,219 **** } ! /** {@inheritDoc} */ ! @Override ! public void evaluate() { ! Space space = (Space) parameters.get("space"); ! System.out.println("smooth " + space); ! List<Surface> faces = new ArrayList(space.getEnvelope()); ! List<Edge> edges = new ArrayList(Surface.edges(faces)); ! List<Vertex> vertices = new ArrayList(Edge.vertices(edges)); Map<Surface, Vertex> facemap = new HashMap(); --- 346,356 ---- } ! ! private List<Surface> subdivide(List<Surface> faces) { ! Inverse inv = new Inverse(faces); ! ! List<Edge> edges = new ArrayList(inv.edges()); ! List<Vertex> vertices = new ArrayList(inv.vertices()); Map<Surface, Vertex> facemap = new HashMap(); *************** *** 225,229 **** { - // Subdivision step for (Surface current : faces) { --- 362,365 ---- *************** *** 242,258 **** } - points.addAll(facemap.values()); points.addAll(edgemap.values()); points.addAll(vertexmap.values()); ! // Initialize vmap for speeding ! // up quad generation ! ! vmap = new HashMap(); ! for (Vertex current : points) { ! vmap.put(current, new LinkedList()); ! } ! for (Surface face : faces) { LinkedList<Edge> contour = new LinkedList(face.getEdges()); --- 378,389 ---- } points.addAll(facemap.values()); points.addAll(edgemap.values()); points.addAll(vertexmap.values()); + } ! Builder builder = new Builder(points); ! ! { for (Surface face : faces) { LinkedList<Edge> contour = new LinkedList(face.getEdges()); *************** *** 263,267 **** Vertex p1 = edgemap.get(previous); Vertex p2 = edgemap.get(current); ! quads.add(quad(f, p1, v, p2)); previous = current; } --- 394,406 ---- Vertex p1 = edgemap.get(previous); Vertex p2 = edgemap.get(current); ! Edge e1 = builder.edge(f, p1); ! e1.setSmooth(true); ! Edge e2 = builder.edge(p1, v); ! e2.setSmooth(previous.isSmooth()); ! Edge e3 = builder.edge(v, p2); ! e3.setSmooth(current.isSmooth()); ! Edge e4 = builder.edge(p2, f); ! e4.setSmooth(true); ! quads.add(builder.surface(e1, e2, e3, e4)); previous = current; } *************** *** 270,349 **** { - // Averaging step - - Map<Vertex, List<Edge>> v2e = new HashMap(); - Map<Edge, List<Surface>> e2s = new HashMap(); - Map<Vertex, List<Surface>> v2s = new HashMap(); - - for (Vertex current : vertices) { - v2e.put(current, new LinkedList()); - } for (Edge current : edges) { ! List<Edge> fl = v2e.get(current.from); ! fl.add(current); ! List<Edge> tl = v2e.get(current.to); ! tl.add(current); ! e2s.put(current, new LinkedList()); ! } ! for (Surface current : faces) { ! for (Edge edge : current.getEdges()) { ! List<Surface> l = e2s.get(edge); ! l.add(current); ! } ! } ! for (Vertex current : vertices) { ! Set<Surface> set = new HashSet(); ! List<Edge> l = v2e.get(current); ! for (Edge edge : l) { ! set.addAll(e2s.get(edge)); ! } ! v2s.put(current, new LinkedList(set)); ! } ! ! ! for (Edge current : edges) { ! Vertex edgepoint = edgemap.get(current); ! List<Edge> es = vmap.get(edgepoint); ! List<Vertex> vs = new LinkedList(); ! for (Edge edge : es) { ! vs.add(edge.otherVertex(edgepoint)); } - edgepoint.set(average(vs)); } for (Vertex current : vertices) { ! List<Edge> es = v2e.get(current); ! List<Surface> ss = v2s.get(current); int n = es.size(); ! List<Vertex> vs = new LinkedList(); for (Edge edge : es) { ! vs.add(edge.otherVertex(current)); ! } ! List<Vertex> fs = new LinkedList(); ! for (Surface surface : ss) { ! fs.add(facemap.get(surface)); } - Vertex a1 = average(vs); - Vertex a2 = average(fs); - double x = ((n - 2) * current.x) / n + a1.x / n + a2.x / n; - double y = ((n - 2) * current.y) / n + a1.y / n + a2.y / n; - double z = ((n - 2) * current.z) / n + a1.z / n + a2.z / n; - Vertex vertexpoint = vertexmap.get(current); ! vertexpoint.setX(x); ! vertexpoint.setY(y); ! vertexpoint.setZ(z); } } ! for (Vertex current : points) { ! space.add(current); } ! for (Surface quad : quads) { for (Edge current : quad.getEdges()) { ! space.add(current); } space.add(quad); --- 409,508 ---- { for (Edge current : edges) { ! if (current.isSmooth()) { ! Vertex edgepoint = edgemap.get(current); ! List<Edge> es = builder.edges(edgepoint); ! List<Vertex> vs = new LinkedList(); ! for (Edge edge : es) { ! vs.add(edge.otherVertex(edgepoint)); ! } ! edgepoint.set(average(vs)); } } for (Vertex current : vertices) { ! ! List<Edge> es = inv.edges(current); ! List<Surface> ss = inv.surfaces(current); int n = es.size(); ! ! List<Edge> crease = new LinkedList(); ! for (Edge edge : es) { ! if (!edge.isSmooth()) { ! crease.add(edge); ! } } Vertex vertexpoint = vertexmap.get(current); ! ! if (crease.size() < 2) { ! List<Vertex> vs = new LinkedList(); ! for (Edge edge : es) { ! vs.add(edge.otherVertex(current)); ! } ! List<Vertex> fs = new LinkedList(); ! for (Surface surface : ss) { ! fs.add(facemap.get(surface)); ! } ! ! Vertex a1 = average(vs); ! Vertex a2 = average(fs); ! double x = ((n - 2) * current.x) / n + a1.x / n + a2.x / n; ! double y = ((n - 2) * current.y) / n + a1.y / n + a2.y / n; ! double z = ((n - 2) * current.z) / n + a1.z / n + a2.z / n; ! vertexpoint.setX(x); ! vertexpoint.setY(y); ! vertexpoint.setZ(z); ! } else if (crease.size() == 2) { ! double x = 6 * current.x; ! double y = 6 * current.y; ! double z = 6 * current.z; ! for (Edge edge : crease) { ! Vertex v = edge.otherVertex(current); ! x += v.x; ! y += v.y; ! z += v.z; ! } ! vertexpoint.setX(x / 8); ! vertexpoint.setY(y / 8); ! vertexpoint.setZ(z / 8); ! } } } + return quads; + } + + /** {@inheritDoc} */ + @Override + public void evaluate() { + Space space = (Space) parameters.get("space"); + int n = (int) parameters.getDouble("n"); + boolean envelope = parameters.getBoolean("envelope"); ! List<Surface> faces; ! if (envelope) { ! faces = new ArrayList(space.getEnvelope()); ! } else { ! faces = new ArrayList(space.getSurfaces()); ! } ! for (int i = 0; i < n; i++) { ! faces = subdivide(faces); } ! space.clear(); ! ! for (Surface quad : faces) { for (Edge current : quad.getEdges()) { ! if (current.from.getOwner() == null) { ! space.add(current.from); ! } ! if (current.to.getOwner() == null) { ! space.add(current.to); ! } ! if (current.getOwner() == null) { ! space.add(current); ! } } space.add(quad); *************** *** 380,384 **** public void evaluate() { Edge edge = (Edge) parameters.get("edge"); ! int n = parameters.getDouble("n").intValue(); Vertex from = edge.from; Vertex to = edge.to; --- 539,543 ---- public void evaluate() { Edge edge = (Edge) parameters.get("edge"); ! int n = (int) parameters.getDouble("n"); Vertex from = edge.from; Vertex to = edge.to; *************** *** 422,426 **** double r = parameters.getDouble("radius"); double h = parameters.getDouble("height"); ! int s = parameters.getDouble("slices").intValue(); List<Edge> edges = new LinkedList<Edge>(); --- 581,585 ---- double r = parameters.getDouble("radius"); double h = parameters.getDouble("height"); ! int s = (int) parameters.getDouble("slices"); List<Edge> edges = new LinkedList<Edge>(); Index: ParameterBlock.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ParameterBlock.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ParameterBlock.java 22 Oct 2007 15:21:18 -0000 1.13 --- ParameterBlock.java 28 Oct 2007 22:45:37 -0000 1.14 *************** *** 80,84 **** * @return double value */ ! public Double getDouble(String key) { for (Attribute current : parameters) { if (current.getName().equals(key)) { --- 80,84 ---- * @return double value */ ! public double getDouble(String key) { for (Attribute current : parameters) { if (current.getName().equals(key)) { *************** *** 92,95 **** --- 92,109 ---- * * @param key String + * @return boolean value + */ + public boolean getBoolean(String key) { + for (Attribute current : parameters) { + if (current.getName().equals(key)) { + return ((Boolean)(current.getValue())).booleanValue(); + } + } + return false; + } + + /** + * + * @param key String * @param value Object */ |
From: Michael L. <he...@us...> - 2007-10-26 13:01:39
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8065/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: A subdivision algo Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Command.java 24 Oct 2007 16:04:54 -0000 1.15 --- Command.java 26 Oct 2007 13:01:31 -0000 1.16 *************** *** 10,16 **** --- 10,18 ---- import java.util.ArrayList; import java.util.Collection; + import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; + import java.util.Map; import java.util.Set; *************** *** 135,138 **** --- 137,360 ---- /** * + */ + public static class SmoothSpace extends Command { + private Map<Vertex, List<Edge>> vmap; + + /** + * + * @param space Space + */ + public SmoothSpace(Space space) { + parameters.put("space", space); + } + + /** {@inheritDoc} */ + public String getGeneralName() { + return "Smooth"; + } + + private Vertex common(Edge e1, Edge e2) { + if (e2.contains(e1.from)) { + return e1.from; + } else { + return e1.to; + } + } + + + private Edge edge(Vertex v1, Vertex v2) { + List<Edge> l1 = vmap.get(v1); + List<Edge> l2 = vmap.get(v2); + for (Edge current : l1) { + if (current.otherVertex(v1) == v2) { + return current; + } + } + Edge edge = new Edge(v1, v2); + l1.add(edge); + l2.add(edge); + return edge; + } + + private Surface quad(Edge e1, Edge e2, Edge e3, Edge e4) { + List edges = new ArrayList(); + edges.add(e1); + edges.add(e2); + edges.add(e3); + edges.add(e4); + return new Surface(edges); + } + + private Surface quad(Vertex v1, Vertex v2, Vertex v3, Vertex v4) { + Edge e1 = edge(v1, v2); + Edge e2 = edge(v2, v3); + Edge e3 = edge(v3, v4); + Edge e4 = edge(v4, v1); + return quad(e1, e2, e3, e4); + } + + private Vertex average(Collection<Vertex> vertices) { + double x = 0; + double y = 0; + double z = 0; + for (Vertex current : vertices) { + x += current.x; + y += current.y; + z += current.z; + } + int n = vertices.size(); + return new Vertex(x / n, y / n, z / n); + } + + /** {@inheritDoc} */ + @Override + public void evaluate() { + Space space = (Space) parameters.get("space"); + System.out.println("smooth " + space); + + List<Surface> faces = new ArrayList(space.getEnvelope()); + List<Edge> edges = new ArrayList(Surface.edges(faces)); + List<Vertex> vertices = new ArrayList(Edge.vertices(edges)); + + Map<Surface, Vertex> facemap = new HashMap(); + Map<Edge, Vertex> edgemap = new HashMap(); + Map<Vertex, Vertex> vertexmap = new HashMap(); + + LinkedList<Vertex> points = new LinkedList(); + List<Surface> quads = new LinkedList(); + + { + // Subdivision step + + for (Surface current : faces) { + Vertex vertex = current.center(); + facemap.put(current, vertex); + } + + for (Edge current : edges) { + Vertex vertex = current.center(); + edgemap.put(current, vertex); + } + + for (Vertex current : vertices) { + Vertex vertex = current.copy(); + vertexmap.put(current, vertex); + } + + + points.addAll(facemap.values()); + points.addAll(edgemap.values()); + points.addAll(vertexmap.values()); + + // Initialize vmap for speeding + // up quad generation + + vmap = new HashMap(); + for (Vertex current : points) { + vmap.put(current, new LinkedList()); + } + + for (Surface face : faces) { + LinkedList<Edge> contour = new LinkedList(face.getEdges()); + Edge previous = contour.getLast(); + Vertex f = facemap.get(face); + for (Edge current : contour) { + Vertex v = vertexmap.get(common(previous, current)); + Vertex p1 = edgemap.get(previous); + Vertex p2 = edgemap.get(current); + quads.add(quad(f, p1, v, p2)); + previous = current; + } + } + } + + { + // Averaging step + + Map<Vertex, List<Edge>> v2e = new HashMap(); + Map<Edge, List<Surface>> e2s = new HashMap(); + Map<Vertex, List<Surface>> v2s = new HashMap(); + + for (Vertex current : vertices) { + v2e.put(current, new LinkedList()); + } + for (Edge current : edges) { + List<Edge> fl = v2e.get(current.from); + fl.add(current); + List<Edge> tl = v2e.get(current.to); + tl.add(current); + e2s.put(current, new LinkedList()); + } + for (Surface current : faces) { + for (Edge edge : current.getEdges()) { + List<Surface> l = e2s.get(edge); + l.add(current); + } + } + for (Vertex current : vertices) { + Set<Surface> set = new HashSet(); + List<Edge> l = v2e.get(current); + for (Edge edge : l) { + set.addAll(e2s.get(edge)); + } + v2s.put(current, new LinkedList(set)); + } + + + for (Edge current : edges) { + Vertex edgepoint = edgemap.get(current); + List<Edge> es = vmap.get(edgepoint); + List<Vertex> vs = new LinkedList(); + for (Edge edge : es) { + vs.add(edge.otherVertex(edgepoint)); + } + edgepoint.set(average(vs)); + } + + for (Vertex current : vertices) { + List<Edge> es = v2e.get(current); + List<Surface> ss = v2s.get(current); + int n = es.size(); + List<Vertex> vs = new LinkedList(); + for (Edge edge : es) { + vs.add(edge.otherVertex(current)); + } + List<Vertex> fs = new LinkedList(); + for (Surface surface : ss) { + fs.add(facemap.get(surface)); + } + + Vertex a1 = average(vs); + Vertex a2 = average(fs); + double x = ((n - 2) * current.x) / n + a1.x / n + a2.x / n; + double y = ((n - 2) * current.y) / n + a1.y / n + a2.y / n; + double z = ((n - 2) * current.z) / n + a1.z / n + a2.z / n; + + Vertex vertexpoint = vertexmap.get(current); + vertexpoint.setX(x); + vertexpoint.setY(y); + vertexpoint.setZ(z); + } + } + + + for (Vertex current : points) { + space.add(current); + } + + for (Surface quad : quads) { + for (Edge current : quad.getEdges()) { + space.add(current); + } + space.add(quad); + } + + Project.getInstance().changed(Project.getInstance()); + } + } + + + /** + * * */ |
From: Michael L. <he...@us...> - 2007-10-26 13:01:24
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8049/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: A subdivision algo Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** PopupMenu.java 26 Oct 2007 09:10:50 -0000 1.57 --- PopupMenu.java 26 Oct 2007 13:01:24 -0000 1.58 *************** *** 226,232 **** */ public static JPopupMenu getSpaceMenu(Collection s) { ! JPopupMenu pm = PopupMenu.getGeometricMenu(s); ! pm.addSeparator(); AbstractAction copy = new CollectionMenuAction(s, "Duplicate") { --- 226,232 ---- */ public static JPopupMenu getSpaceMenu(Collection s) { ! JPopupMenu menu = PopupMenu.getGeometricMenu(s); ! menu.addSeparator(); AbstractAction copy = new CollectionMenuAction(s, "Duplicate") { *************** *** 243,247 **** } }; ! pm.add(copy); AbstractAction instantiate = new CollectionMenuAction(s, "Instantiate") { public void actionPerformed(ActionEvent arg0) { --- 243,247 ---- } }; ! menu.add(copy); AbstractAction instantiate = new CollectionMenuAction(s, "Instantiate") { public void actionPerformed(ActionEvent arg0) { *************** *** 262,266 **** } }; ! pm.add(instantiate); if (s.size() == 1) { // Some options do only apply to one space --- 262,266 ---- } }; ! menu.add(instantiate); if (s.size() == 1) { // Some options do only apply to one space *************** *** 277,283 **** } }; ! pm.add(edit); } if (CHECKS) { AbstractAction envelope = new SpaceMenuAction(sp, "Compute Envelope") { --- 277,292 ---- } }; ! menu.add(edit); } + { + AbstractAction action = new SpaceMenuAction(sp, "Smooth...") { + public void actionPerformed(ActionEvent event) { + Command command = new Command.SmoothSpace(space); + AttributeView.instance().display(command); + } + }; + menu.add(action); + } if (CHECKS) { AbstractAction envelope = new SpaceMenuAction(sp, "Compute Envelope") { *************** *** 290,294 **** } }; ! pm.add(envelope); AbstractAction check = new SpaceMenuAction(sp, "Consistency Check") { public void actionPerformed(ActionEvent arg0) { --- 299,303 ---- } }; ! menu.add(envelope); AbstractAction check = new SpaceMenuAction(sp, "Consistency Check") { public void actionPerformed(ActionEvent arg0) { *************** *** 296,300 **** } }; ! pm.add(check); AbstractAction modCheck = new SpaceMenuAction(sp, "Modellor Check") { public void actionPerformed(ActionEvent arg0) { --- 305,309 ---- } }; ! menu.add(check); AbstractAction modCheck = new SpaceMenuAction(sp, "Modellor Check") { public void actionPerformed(ActionEvent arg0) { *************** *** 302,309 **** } }; ! pm.add(modCheck); } ! pm.add(getTransformMenu(sp)); for (Modellor current : Modellor.getRegisteredModellors()) { --- 311,318 ---- } }; ! menu.add(modCheck); } ! menu.add(getTransformMenu(sp)); for (Modellor current : Modellor.getRegisteredModellors()) { *************** *** 317,321 **** } }; ! pm.add(action); } } --- 326,330 ---- } }; ! menu.add(action); } } *************** *** 329,335 **** mm.add(modellor); } ! pm.add(mm); } ! return pm; } --- 338,344 ---- mm.add(modellor); } ! menu.add(mm); } ! return menu; } |