bprocessor-commit Mailing List for B-processor (Page 127)
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...> - 2006-04-05 09:36:35
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8430/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java PencilTool.java ExtrudeTool.java ToolFactory.java SpaceTool.java MultiExtrudeTool.java DomainPopupListener.java AbstractPencil.java CreateSpaceActionListener.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: CreateSpaceActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/CreateSpaceActionListener.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CreateSpaceActionListener.java 24 Jan 2006 14:10:32 -0000 1.6 --- CreateSpaceActionListener.java 5 Apr 2006 09:36:16 -0000 1.7 *************** *** 14,17 **** --- 14,18 ---- import java.awt.event.ActionListener; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Surface; *************** *** 55,67 **** public void actionPerformed(ActionEvent e) { String result; if (functional) { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Functional Space", JOptionPane.QUESTION_MESSAGE); } else { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Construction Space", JOptionPane.QUESTION_MESSAGE); } --- 56,75 ---- public void actionPerformed(ActionEvent e) { String result; + String category = null; + if (surface.getOwner() == Project.getInstance().world()) { + category = "Space"; + } else { + category = "Element"; + } + if (functional) { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Functional " + category, JOptionPane.QUESTION_MESSAGE); } else { result = JOptionPane.showInputDialog(GUI.getInstance(), "Name", ! "Create Construction " + category, JOptionPane.QUESTION_MESSAGE); } *************** *** 70,96 **** } if (result != null && !result.trim().equals("")) { Space space; if (functional) { space = Space.createFunctionalSpace(result.trim()); - Project.getInstance().add(space); } else { space = Space.createConstructionSpace(result.trim()); ! Project.getInstance().add(space); ! } - Space old; if (front) { - old = surface.getFrontDomain(); surface.setFrontDomain(space); } else { - old = surface.getBackDomain(); surface.setBackDomain(space); } ! space.addSurface(surface); ! space.changed(); ! if (old != null) { ! old.changed(); ! } } } --- 78,99 ---- } + Space owner = surface.getOwner(); + if (result != null && !result.trim().equals("")) { Space space; if (functional) { space = Space.createFunctionalSpace(result.trim()); } else { space = Space.createConstructionSpace(result.trim()); ! } ! ! owner.add(space); if (front) { surface.setFrontDomain(space); } else { surface.setBackDomain(space); } ! Project.getInstance().checkpoint(); } } Index: ExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrudeTool.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ExtrudeTool.java 12 Mar 2006 12:33:01 -0000 1.14 --- ExtrudeTool.java 5 Apr 2006 09:36:16 -0000 1.15 *************** *** 22,26 **** import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; --- 22,25 ---- *************** *** 31,34 **** --- 30,36 ---- public class ExtrudeTool extends AbstractTool { + /** Limit offset */ + static final boolean LIMIT = false; + /** The dragSurface */ private Surface top; *************** *** 92,110 **** prevY = e.getY(); number = new String(); ! if (!selection.isEmpty()) { ! Object object = selection.iterator().next(); ! if (object instanceof Surface) { ! sides = new HashSet(); ! extrudeSurface = (Surface) object; ! View view = glv.getView(); ! Transformation trans = view.transformation(); ! double x = prevX; ! double y = View.getHeight() - prevY; ! Vertex near = new Vertex(x, y, 0.0); ! Vertex far = new Vertex(x, y, 1.0); ! Edge ray = new Edge(near, far); ! ray = trans.unProject(ray); ! dragplane = extrudeSurface.plane().orthogonalPlane(ray); ! } } } --- 94,111 ---- prevY = e.getY(); number = new String(); ! findTarget(e); ! ! if (target instanceof Surface) { ! sides = new HashSet(); ! extrudeSurface = (Surface) target; ! View view = glv.getView(); ! Transformation trans = view.transformation(); ! double x = prevX; ! double y = View.getHeight() - prevY; ! Vertex near = new Vertex(x, y, 0.0); ! Vertex far = new Vertex(x, y, 1.0); ! Edge ray = new Edge(near, far); ! ray = trans.unProject(ray); ! dragplane = extrudeSurface.plane().orthogonalPlane(ray); } } *************** *** 140,156 **** /** ! * Apply extrusion ! * @param length The length */ ! private void apply(double length) { if (top != null) { ! Project.getInstance().delete(top); Iterator iter = sides.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); ! Project.getInstance().delete(current); } sides = null; } if (extrudeSurface != null) { sides = new HashSet(); --- 141,165 ---- /** ! * */ ! private void removeExtrusion() { if (top != null) { ! top.delete(); ! top = null; Iterator iter = sides.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); ! current.delete(); } sides = null; } + } + + /** + * Apply extrusion + * @param length The length + */ + private void apply(double length) { + removeExtrusion(); if (extrudeSurface != null) { sides = new HashSet(); *************** *** 160,164 **** top = extrudeSurface.extrude(length, sides); holeAnalysis(top); ! Selection.primary().set(top); } } --- 169,173 ---- top = extrudeSurface.extrude(length, sides); holeAnalysis(top); ! Project.getInstance().checkpoint(); } } *************** *** 178,206 **** lowerLimit = Double.NEGATIVE_INFINITY; } ! ! Collection surfaces = Project.getInstance().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! Vertex normal = top.normal(); ! Vertex origin = extrudeSurface.getFirstVertex(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != extrudeSurface && current != top) { ! Vertex n = current.normal(); ! Vertex cross = normal.cross(n); ! if (cross.isZero()) { ! Vertex o = current.getFirstVertex(); ! Vertex vector = o.minus(origin); ! double d = vector.dot(normal); ! if (direction > 0) { ! if (d > 0.0000001) { ! if (d < upperLimit) { ! upperLimit = d; } } ! } ! if (direction < 0) { ! if (d < -0.0000001) { ! if (d > lowerLimit) { ! lowerLimit = d; } } --- 187,216 ---- lowerLimit = Double.NEGATIVE_INFINITY; } ! if (LIMIT) { ! Collection surfaces = Project.getInstance().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! Vertex normal = top.normal(); ! Vertex origin = extrudeSurface.getFirstVertex(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != extrudeSurface && current != top) { ! Vertex n = current.normal(); ! Vertex cross = normal.cross(n); ! if (cross.isZero()) { ! Vertex o = current.getFirstVertex(); ! Vertex vector = o.minus(origin); ! double d = vector.dot(normal); ! if (direction > 0) { ! if (d > 0.0000001) { ! if (d < upperLimit) { ! upperLimit = d; ! } } } ! if (direction < 0) { ! if (d < -0.0000001) { ! if (d > lowerLimit) { ! lowerLimit = d; ! } } } *************** *** 216,219 **** --- 226,233 ---- */ protected void moved(MouseEvent e) { + findTarget(e); + if (target instanceof Surface) { + glv.getView().makeTarget(target); + } } *************** *** 235,241 **** Vertex delta = to.minus(from); double normDotDelta = normal.dot(delta); ! double x = e.getX(); ! double y = e.getY(); if (top == null) { if (x * x + y * y > 16) { top = extrudeSurface.extrude(normDotDelta, sides); --- 249,256 ---- Vertex delta = to.minus(from); double normDotDelta = normal.dot(delta); ! if (top == null) { + double x = e.getX() - prevX; + double y = e.getY() - prevY; if (x * x + y * y > 16) { top = extrudeSurface.extrude(normDotDelta, sides); *************** *** 249,252 **** --- 264,311 ---- } } else { + if (!LIMIT) { + Set elements = new HashSet(); + { + Set edges = new HashSet(); + elements.add(extrudeSurface); + elements.addAll(sides); + elements.add(top); + Iterator iter = elements.iterator(); + while (iter.hasNext()) { + Surface current = (Surface) iter.next(); + edges.addAll(current.getEdges()); + } + elements.addAll(edges); + } + findTarget(e, elements); + if (target instanceof Surface) { + Vertex origin = extrudeSurface.getFirstVertex(); + Surface surface = (Surface) target; + if (surface != extrudeSurface && surface != top && !elements.contains(surface)) { + Vertex n = surface.normal(); + Vertex cross = normal.cross(n); + if (cross.isZero()) { + Vertex o = surface.getFirstVertex(); + Vertex vector = o.minus(origin); + double d = vector.dot(normal); + if (Math.abs(d) > 0.0000001) { + moveTo(d); + return; + } + } + } + } + if (target instanceof Edge) { + Vertex origin = extrudeSurface.getFirstVertex(); + Edge edge = (Edge) target; + Vertex o = edge.center(); + Vertex vector = o.minus(origin); + double d = vector.dot(normal); + if (Math.abs(d) > 0.0000001) { + moveTo(d); + return; + } + } + } moveTo(normDotDelta); } *************** *** 260,273 **** protected void released(MouseEvent e) { if (Math.abs(t) < 0.0000001) { ! if (top != null) { ! Project.getInstance().delete(top); ! top = null; ! Iterator iter = sides.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! Project.getInstance().delete(current); ! } ! sides = null; ! } } else { holeAnalysis(top); --- 319,323 ---- protected void released(MouseEvent e) { if (Math.abs(t) < 0.0000001) { ! removeExtrusion(); } else { holeAnalysis(top); *************** *** 277,281 **** holeAnalysis(current); } ! Selection.primary().set(top); } } --- 327,331 ---- holeAnalysis(current); } ! Project.getInstance().checkpoint(); } } Index: DomainPopupListener.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/DomainPopupListener.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DomainPopupListener.java 4 Jan 2006 14:29:50 -0000 1.4 --- DomainPopupListener.java 5 Apr 2006 09:36:16 -0000 1.5 *************** *** 9,12 **** --- 9,14 ---- import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; *************** *** 71,74 **** --- 73,77 ---- } surface.changed(); + Project.getInstance().checkpoint(); } } Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ToolFactory.java 27 Mar 2006 14:41:03 -0000 1.40 --- ToolFactory.java 5 Apr 2006 09:36:16 -0000 1.41 *************** *** 181,185 **** move.setStrategy(vectorStrategy); rotation = new RotationTool(glv, pencilcursor); ! extrusion = new MultiExtrudeTool(glv, pencilcursor); clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasureTool(glv, pencilcursor); --- 181,185 ---- move.setStrategy(vectorStrategy); rotation = new RotationTool(glv, pencilcursor); ! extrusion = new ExtrudeTool(glv, pencilcursor); clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasureTool(glv, pencilcursor); Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** PencilTool.java 10 Mar 2006 16:41:25 -0000 1.63 --- PencilTool.java 5 Apr 2006 09:36:16 -0000 1.64 *************** *** 195,199 **** protected void intern(Surface surface) { if (surface.getId() == null) { ! Project.getInstance().add(surface); } } --- 195,199 ---- protected void intern(Surface surface) { if (surface.getId() == null) { ! Project.getInstance().world().insert(surface); } } Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** AbstractTool.java 29 Mar 2006 08:11:58 -0000 1.66 --- AbstractTool.java 5 Apr 2006 09:36:16 -0000 1.67 *************** *** 29,33 **** import java.net.URL; - import java.util.List; import java.util.Iterator; import java.util.Set; --- 29,32 ---- *************** *** 402,416 **** return edge; } - - /** - * Make and register a new Surface - * @param edges The list of edges in the surface - * @return The new Surface - */ - protected Surface createSurface(List edges) { - Surface surface = new Surface(edges); - Project.getInstance().add(surface); - return surface; - } /** --- 401,404 ---- Index: SpaceTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SpaceTool.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SpaceTool.java 26 Feb 2006 10:52:26 -0000 1.15 --- SpaceTool.java 5 Apr 2006 09:36:16 -0000 1.16 *************** *** 11,14 **** --- 11,15 ---- import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.Arrays; *************** *** 83,86 **** --- 84,103 ---- } + /** + * SpaceAction for making actions on spaces + */ + protected abstract class SpaceAction extends MenuAction { + /** The space to operate on */ + protected Space space; + + /** + * Constructor + * @param space The space to operate on + */ + public SpaceAction(Space space) { + this.space = space; + } + + } /** *************** *** 206,209 **** --- 223,229 ---- public class Cylinder extends Modellor { + /** Default */ + private static final long serialVersionUID = 1L; + /** radius */ private double radius = 1.0; *************** *** 215,224 **** private int axisDivisions = 12; - /** height divisions */ - private int heightDivisions = 1; - - /** cap divisions */ - private int capDivisions = 1; - /*** * Generate a Cylinder --- 235,238 ---- *************** *** 277,291 **** edges.add(se[i]); sf[i] = new Surface(edges); ! Project.getInstance().add(sf[i]); } { List edges = new LinkedList(Arrays.asList(be)); bottom = new Surface(edges); ! Project.getInstance().add(bottom); } { List edges = new LinkedList(Arrays.asList(te)); top = new Surface(edges); ! Project.getInstance().add(top); } } --- 291,305 ---- edges.add(se[i]); sf[i] = new Surface(edges); ! Project.getInstance().world().insert(sf[i]); } { List edges = new LinkedList(Arrays.asList(be)); bottom = new Surface(edges); ! Project.getInstance().world().insert(bottom); } { List edges = new LinkedList(Arrays.asList(te)); top = new Surface(edges); ! Project.getInstance().world().insert(top); } } *************** *** 363,372 **** */ private JPopupMenu spacePopup(String side) { ! JPopupMenu pp = new JPopupMenu(side); SpacePopupListener spl = new SpacePopupListener(side.equals("front"), glv.getView()); ! Collection domains = Project.getInstance().getSpaces(); ! Iterator domIt = domains.iterator(); Iterator selIt = new HashSet(selection).iterator(); Surface surface = null; if (selIt.hasNext()) { Object o = selIt.next(); --- 377,388 ---- */ private JPopupMenu spacePopup(String side) { ! JPopupMenu menu = new JPopupMenu(side); SpacePopupListener spl = new SpacePopupListener(side.equals("front"), glv.getView()); ! ! Iterator selIt = new HashSet(selection).iterator(); Surface surface = null; + Space space = null; + if (selIt.hasNext()) { Object o = selIt.next(); *************** *** 374,377 **** --- 390,403 ---- surface = (Surface)o; } + + if (surface != null) { + if (side.equals("front")) { + space = surface.getFrontDomain(); + } + if (side.equals("back")) { + space = surface.getBackDomain(); + } + } + JMenuItem noneItem = new JMenuItem("NONE"); ActionListener noneListener = new DomainPopupListener(null, *************** *** 380,384 **** noneItem.addActionListener(noneListener); ! JMenuItem createFuncItem = new JMenuItem("New Functional Space"); ActionListener funcListener = new CreateSpaceActionListener(surface, side.equals("front"), --- 406,421 ---- noneItem.addActionListener(noneListener); ! Collection domains = null; ! String category = null; ! if (surface.getOwner() == Project.getInstance().world()) { ! domains = Project.getInstance().getSpaces(); ! category = "Space"; ! } else { ! domains = surface.getOwner().getElements(); ! category = "Element"; ! } ! ! ! JMenuItem createFuncItem = new JMenuItem("New Functional " + category); ActionListener funcListener = new CreateSpaceActionListener(surface, side.equals("front"), *************** *** 386,390 **** createFuncItem.addActionListener(funcListener); ! JMenuItem createConstItem = new JMenuItem("New Construction Space"); ActionListener constListener = new CreateSpaceActionListener(surface, side.equals("front"), --- 423,427 ---- createFuncItem.addActionListener(funcListener); ! JMenuItem createConstItem = new JMenuItem("New Construction" + category); ActionListener constListener = new CreateSpaceActionListener(surface, side.equals("front"), *************** *** 392,399 **** createConstItem.addActionListener(constListener); ! JMenu funcMenu = new JMenu("Functional Spaces"); ! JMenu constMenu = new JMenu("Construction Spaces"); ! boolean funcEnabled = false; ! boolean constEnabled = false; while (domIt.hasNext()) { Space domain = (Space)domIt.next(); --- 429,451 ---- createConstItem.addActionListener(constListener); ! JMenuItem editSpaceItem = new JMenuItem("Edit Space"); ! editSpaceItem.addActionListener(new SpaceAction(space) { ! public void actionPerformed(ActionEvent arg0) { ! if (space != null) { ! selection.clear(); ! glv.getView().makeTarget(null); ! Project.getInstance().setActiveSpace(space); ! } ! } ! }); ! ! ! ! ! ! JMenu funcMenu = new JMenu("Functional " + category + "s"); ! JMenu constMenu = new JMenu("Construction " + category + "s"); ! ! Iterator domIt = domains.iterator(); while (domIt.hasNext()) { Space domain = (Space)domIt.next(); *************** *** 416,432 **** constMenu.addSeparator(); constMenu.add(createConstItem); ! pp.add(funcMenu); ! pp.add(constMenu); ! pp.addSeparator(); ! pp.add(noneItem); ! pp.addPopupMenuListener(spl); ! pp.pack(); ! return pp; } else { log.warn("Space popup menu has no surface"); return null; ! } } ! } --- 468,497 ---- constMenu.addSeparator(); constMenu.add(createConstItem); ! menu.add(funcMenu); ! menu.add(constMenu); ! menu.addSeparator(); ! menu.add(noneItem); ! menu.add(editSpaceItem); ! menu.addPopupMenuListener(spl); ! menu.pack(); ! return menu; } else { log.warn("Space popup menu has no surface"); return null; ! } } ! /** ! * Invoked when a key has been pressed. Lets user delete what is selected. ! * @param e The KeyEvent ! */ ! public void keyPressed(KeyEvent e) { ! if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { ! selection.clear(); ! glv.getView().makeTarget(null); ! Project.getInstance().setActiveSpace(null); ! } else { ! super.keyPressed(e); ! } ! } } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AbstractPencil.java 30 Mar 2006 07:41:27 -0000 1.20 --- AbstractPencil.java 5 Apr 2006 09:36:16 -0000 1.21 *************** *** 111,114 **** --- 111,121 ---- */ public Vertex insertVertex(Vertex vertex) { + + Space space = mesh(); + + if (vertex.getOwner() != space) { + vertex = vertex.copy(); + } + Vertex actual = null; { *************** *** 186,190 **** if (from == to) { Surface surface = new Surface(actual); ! mesh().add(surface); holeAnalysis(surface); } else { --- 193,197 ---- if (from == to) { Surface surface = new Surface(actual); ! mesh().insert(surface); holeAnalysis(surface); } else { *************** *** 316,319 **** --- 323,330 ---- constructors.add(parrallel); } + if (plane != null) { + info(plane); + info("origin = " + plane.origin()); + } } } *************** *** 425,428 **** --- 436,440 ---- case Intersection.SURFACE: target = intersection.object(); + plane = ((Surface) target).plane(); break; case Intersection.EDGE_MIDPOINT: *************** *** 437,440 **** --- 449,453 ---- case Intersection.PLANE_INTERSECTION: target = null; + plane = (Plane) intersection.object(); break; } *************** *** 596,598 **** --- 609,619 ---- timer.stop(); } + + /** + * info + * @param info Info + */ + public static void info(Object info) { + log.info(info); + } } Index: MultiExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MultiExtrudeTool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MultiExtrudeTool.java 29 Mar 2006 08:14:28 -0000 1.12 --- MultiExtrudeTool.java 5 Apr 2006 09:36:16 -0000 1.13 *************** *** 146,157 **** } ! if (direction == 0) { //we have never set the direction; ! direction = normDotDelta; ! } if (top == null) { // there are no extrusion make one if we move the mouse if ((e.getX() - pressX) * (e.getX() - pressX) + ! (e.getY() - pressY) * (e.getY() - pressY) > 16) { elements = makeExtrusion(surfaces); } --- 146,158 ---- } ! //if (direction == 0) { //we have never set the direction; ! //direction = normDotDelta; ! //} if (top == null) { // there are no extrusion make one if we move the mouse if ((e.getX() - pressX) * (e.getX() - pressX) + ! (e.getY() - pressY) * (e.getY() - pressY) > 32) { ! direction = normDotDelta; elements = makeExtrusion(surfaces); } *************** *** 219,222 **** --- 220,224 ---- */ private void moveTo(Collection which, double to) { + Project.info("move-to " + to); double delta = t - to; Iterator iter = which.iterator(); *************** *** 275,278 **** --- 277,281 ---- while (iter.hasNext()) { Surface cur = (Surface)iter.next(); + Project.info("extruding in " + direction); Surface s = cur.extrude(direction, elements, e2e, v2e, e2s, v2dir); if (cur == extrudeSurface) { |
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8430/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** View.java 30 Mar 2006 08:03:41 -0000 1.75 --- View.java 5 Apr 2006 09:36:17 -0000 1.76 *************** *** 900,918 **** private void drawEdges(GLDrawable gld) { drawGeneralEdges(gld, tempEdges); Space active = Project.getInstance().getActiveSpace(); if (active != null) { Set edges = new HashSet(); ! Collection envelope = active.getEnvelope(); ! Iterator iter = envelope.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! edges.addAll(current.getEdges()); } drawConstructionEdges(gld, edges); drawGeneralEdges(gld, active.getEdges()); } else { ! Collection edges = Project.getInstance().getEdges(); ! drawGeneralEdges(gld, edges); } } --- 900,929 ---- private void drawEdges(GLDrawable gld) { drawGeneralEdges(gld, tempEdges); + Collection all = Project.getInstance().getEdges(); Space active = Project.getInstance().getActiveSpace(); if (active != null) { Set edges = new HashSet(); ! { ! Iterator iter = all.iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! if (current.getConstructor()) { ! edges.add(current); ! } ! } ! } ! { ! Collection envelope = active.getEnvelope(); ! Iterator iter = envelope.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! edges.addAll(current.getEdges()); ! } } drawConstructionEdges(gld, edges); drawGeneralEdges(gld, active.getEdges()); } else { ! drawGeneralEdges(gld, all); } } *************** *** 1067,1071 **** //drawing the inner conturs ! Set innerSurfaces = s.getHoles(); if (innerSurfaces != null) { Iterator innerIt = innerSurfaces.iterator(); --- 1078,1082 ---- //drawing the inner conturs ! Collection innerSurfaces = s.getHoles(); if (innerSurfaces != null) { Iterator innerIt = innerSurfaces.iterator(); *************** *** 1904,1908 **** ray = transformation.unProject(ray); if (vertex != null) { ! return new Intersection(vertex, Intersection.VERTEX, null); } else { if (edge != null) { --- 1915,1919 ---- ray = transformation.unProject(ray); if (vertex != null) { ! return new Intersection(vertex, Intersection.VERTEX, vertex); } else { if (edge != null) { |
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:21
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8178/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Geometry.java Space.java Project.java Plane.java Added Files: Persistence.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Surface.java 25 Mar 2006 18:08:32 -0000 1.85 --- Surface.java 5 Apr 2006 09:35:58 -0000 1.86 *************** *** 299,304 **** * class="net.sourceforge.bprocessor.model.Surface" */ ! public Set getHoles() { ! return holes; } --- 299,308 ---- * class="net.sourceforge.bprocessor.model.Surface" */ ! public Collection getHoles() { ! if (holes == null) { ! return Space.EMPTY; ! } else { ! return holes; ! } } *************** *** 345,349 **** } surface.setEdges(edges); ! mesh.add(surface); return surface; } --- 349,353 ---- } surface.setEdges(edges); ! mesh.insert(surface); return surface; } *************** *** 454,458 **** facemap[i] = new Surface(newEdges); e2s.put(b, facemap[i]); ! getOwner().add(facemap[i]); } sides.add(facemap[i]); --- 458,462 ---- facemap[i] = new Surface(newEdges); e2s.put(b, facemap[i]); ! getOwner().insert(facemap[i]); } sides.add(facemap[i]); *************** *** 465,469 **** } top = new Surface(newEdges); ! getOwner().add(top); } --- 469,473 ---- } top = new Surface(newEdges); ! getOwner().insert(top); } *************** *** 959,968 **** if (isInner()) { res.add(new Attribute("Exterior", getExterior(), false)); ! } else { ! if (holes != null) { ! Iterator iterElems = holes.iterator(); ! while (iterElems.hasNext()) { ! res.add(new Attribute("Hole", iterElems.next(), false)); ! } } } --- 963,971 ---- if (isInner()) { res.add(new Attribute("Exterior", getExterior(), false)); ! } ! if (holes != null) { ! Iterator iterElems = holes.iterator(); ! while (iterElems.hasNext()) { ! res.add(new Attribute("Hole", iterElems.next(), false)); } } Index: Plane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Plane.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Plane.java 17 Mar 2006 09:30:34 -0000 1.16 --- Plane.java 5 Apr 2006 09:35:58 -0000 1.17 *************** *** 36,39 **** --- 36,48 ---- private double d; + /** X component in a double-array */ + public static final int X = 0; + + /** Y component in a double-array */ + public static final int Y = 1; + + /** Z component in a double-array */ + public static final int Z = 2; + /** *************** *** 204,207 **** --- 213,277 ---- return intersection(p0, p1); } + + + /** + * Return X, Y or Z based on + * which of the coefficients a, b and c are the largest + * @return Index indicating the largest coefficient + */ + public int largestCoefficient() { + int result = X; + double coefficient = Math.abs(a); + + if (Math.abs(b) > coefficient) { + result = Y; + coefficient = Math.abs(b); + }; + + if (Math.abs(c) > coefficient) { + result = Z; + coefficient = Math.abs(c); + }; + + return result; + } + + /** + * An appropriate origin is chosen as the + * crossing between an axis depending on the + * largest coefficient + * @return The origin + */ + public Vertex origin() { + double[] vector = new double[3]; + double[] values = getDoublev(); + vector[X] = 0; + vector[Y] = 0; + vector[Z] = 0; + int index = largestCoefficient(); + vector[index] = -d / values[index]; + return new Vertex(vector[X], vector[Y], vector[Z]); + } + + /** + * Project a vector into this plane + * @param vector The vector to project + * @return The projected vector + */ + public Vertex project(Vertex vector) { + double t = a * vector.getX() + b * vector.getY() + c * vector.getZ(); + Vertex n = new Vertex(t * a, t * b, t * c); + return vector.minus(n); + } + + /** + * Un-project a vector from this plane + * @param vector Vector + * @return The un-projected vector + */ + public Vertex unProject(Vertex vector) { + Vertex n = new Vertex(a, b, c); + return vector.add(n); + } /** Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** Project.java 30 Mar 2006 08:03:45 -0000 1.53 --- Project.java 5 Apr 2006 09:35:58 -0000 1.54 *************** *** 18,23 **** import java.util.Stack; ! import net.sourceforge.bprocessor.model.xml.Bprocessor; ! import net.sourceforge.bprocessor.model.xml.PersistenceManager; import org.apache.log4j.Logger; --- 18,22 ---- import java.util.Stack; ! import net.sourceforge.bprocessor.model.xml.Bmodel; import org.apache.log4j.Logger; *************** *** 42,51 **** private Space world; ! /** The spaces */ ! private HashMap spaces = new HashMap(); ! /** The space id */ ! private long spaceId; ! ! /** The domains */ private HashMap cameras = new HashMap(); --- 41,45 ---- private Space world; ! /** The cameras */ private HashMap cameras = new HashMap(); *************** *** 78,82 **** /** The current state */ ! private Bprocessor currentState; /** --- 72,76 ---- /** The current state */ ! private Bmodel currentState; /** *************** *** 101,105 **** addCams(); observers = new LinkedList(); ! world = new Space("Void", Space.FUNCTIONAL); constraints = new LinkedList(); } --- 95,99 ---- addCams(); observers = new LinkedList(); ! world = new Space("World", Space.FUNCTIONAL, true); constraints = new LinkedList(); } *************** *** 114,117 **** --- 108,119 ---- /** + * Set the world + * @param world The world + */ + public void setWorld(Space world) { + this.world = world; + } + + /** * Add observer * @param observer The observer *************** *** 146,150 **** */ public void clear() { - spaces.clear(); world.clear(); this.setActiveSpace(null); --- 148,151 ---- *************** *** 301,307 **** */ public void add(Space space) { ! space.setId(new Long(spaceId++)); ! spaces.put(space.getId(), space); ! changed(this); } --- 302,306 ---- */ public void add(Space space) { ! world.add(space); } *************** *** 312,316 **** public Collection getConstructionSpaces() { Collection result = new HashSet(); ! Iterator iter = spaces.values().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); --- 311,315 ---- public Collection getConstructionSpaces() { Collection result = new HashSet(); ! Iterator iter = world.getElements().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); *************** *** 327,331 **** */ public Collection getSpaces() { ! return spaces.values(); } --- 326,330 ---- */ public Collection getSpaces() { ! return world.getElements(); } *************** *** 371,392 **** */ public void remove(Space space) { ! Set surfaces = space.getEnvelope(); ! if (surfaces != null) { ! Iterator surfIt = surfaces.iterator(); ! while (surfIt.hasNext()) { ! Surface surface = (Surface)surfIt.next(); ! Space back = surface.getBackDomain(); ! if (back == space) { ! surface.setBackDomain(null); ! } else { ! Space front = surface.getFrontDomain(); ! if (front == space) { ! surface.setFrontDomain(null); ! } ! } ! } ! } ! spaces.remove(space.getId()); ! space.setId(null); } --- 370,374 ---- */ public void remove(Space space) { ! world.remove(space); } *************** *** 406,410 **** public Collection getFunctionalSpaces() { Collection result = new HashSet(); ! Iterator iter = spaces.values().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); --- 388,392 ---- public Collection getFunctionalSpaces() { Collection result = new HashSet(); ! Iterator iter = world.getElements().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); *************** *** 647,651 **** undoStack.push(currentState); } ! currentState = PersistenceManager.externalize(); } --- 629,633 ---- undoStack.push(currentState); } ! currentState = Persistence.externalize(); } *************** *** 674,680 **** redoStack.push(currentState); } ! currentState = (Bprocessor) undoStack.pop(); clear(); ! PersistenceManager.internalize(currentState); } } --- 656,662 ---- redoStack.push(currentState); } ! currentState = (Bmodel) undoStack.pop(); clear(); ! Persistence.internalize(currentState); } } *************** *** 688,694 **** undoStack.push(currentState); } ! currentState = (Bprocessor) redoStack.pop(); clear(); ! PersistenceManager.internalize(currentState); } } --- 670,676 ---- undoStack.push(currentState); } ! currentState = (Bmodel) redoStack.pop(); clear(); ! Persistence.internalize(currentState); } } *************** *** 717,721 **** */ public void saveAs(File file) throws Exception { ! PersistenceManager.save(file); makeClean(); resetHistory(); --- 699,703 ---- */ public void saveAs(File file) throws Exception { ! Persistence.save(file); makeClean(); resetHistory(); *************** *** 730,734 **** */ public void save() throws Exception { ! PersistenceManager.save(new File(getSavePath())); makeClean(); resetHistory(); --- 712,716 ---- */ public void save() throws Exception { ! Persistence.save(new File(getSavePath())); makeClean(); resetHistory(); *************** *** 744,748 **** Selection.primary().clear(); clear(); ! PersistenceManager.load(file); makeClean(); resetHistory(); --- 726,730 ---- Selection.primary().clear(); clear(); ! Persistence.load(file); makeClean(); resetHistory(); Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Space.java 25 Mar 2006 18:08:32 -0000 1.23 --- Space.java 5 Apr 2006 09:35:58 -0000 1.24 *************** *** 32,35 **** --- 32,38 ---- private static final long serialVersionUID = 1L; + /** An empty collection */ + protected static final Collection EMPTY = new LinkedList(); + /** Construction Type */ public static final int CONSTRUCTION = 0; *************** *** 46,54 **** /** The envelope (a set of surfaces) */ private Set envelope; /** The elements (a list of spaces) */ ! private List elements; /** The vertices */ private HashMap vertices; - /** The next vertex id */ private long nextVertexId; --- 49,71 ---- /** The envelope (a set of surfaces) */ private Set envelope; + + /** + * The next boolean specifies wether or not + * this space can contain other spaces. + * FIXME Should probably be handled by a class + * hierarchy + */ + private boolean container; + + /** The empty space in this space (also called void) */ + protected Space empty; + /** The elements (a list of spaces) */ ! private HashMap elements; ! /** The next element id */ ! private long nextElementId; ! /** The vertices */ private HashMap vertices; /** The next vertex id */ private long nextVertexId; *************** *** 56,60 **** /** The edges */ private HashMap edges; - /** The next edge id */ private long nextEdgeId; --- 73,76 ---- *************** *** 62,68 **** /** The surfaces */ private HashMap surfaces; - /** The next surface id */ private long nextSurfaceId; /** The modellor */ private Modellor modellor; --- 78,85 ---- /** The surfaces */ private HashMap surfaces; /** The next surface id */ private long nextSurfaceId; + + /** The modellor */ private Modellor modellor; *************** *** 81,93 **** * @param name The name * @param type The type */ ! public Space(String name, int type) { super(); setName(name); setType(type); description = new Description(""); ! vertices = new HashMap(); ! edges = new HashMap(); ! surfaces = new HashMap(); } --- 98,118 ---- * @param name The name * @param type The type + * @param container The container flag */ ! public Space(String name, int type, boolean container) { super(); setName(name); setType(type); + this.container = container; description = new Description(""); ! envelope = new HashSet(); ! if (container) { ! vertices = new HashMap(); ! edges = new HashMap(); ! surfaces = new HashMap(); ! elements = new HashMap(); ! empty = new Space("Void", FUNCTIONAL, false); ! this.add(empty); ! } } *************** *** 98,102 **** */ public static Space createConstructionSpace(String name) { ! return new Space(name, Space.CONSTRUCTION); } --- 123,127 ---- */ public static Space createConstructionSpace(String name) { ! return new Space(name, Space.CONSTRUCTION, true); } *************** *** 107,111 **** */ public static Space createFunctionalSpace(String name) { ! return new Space(name, Space.FUNCTIONAL); } --- 132,136 ---- */ public static Space createFunctionalSpace(String name) { ! return new Space(name, Space.FUNCTIONAL, true); } *************** *** 127,130 **** --- 152,171 ---- /** + * + * @return isContainer + */ + public boolean isContainer() { + return container; + } + + /** + * + * @param container isContainer + */ + public void setContainer(boolean container) { + this.container = container; + } + + /** * Get the name * @return The name *************** *** 142,145 **** --- 183,208 ---- this.name = name; } + + /** + * Sets the space serving as empty + * @param element Space + */ + public void setEmpty(Space element) { + if (empty != null) { + remove(empty); + } + empty = element; + if (empty != null) { + add(empty); + } + } + + /** + * Gets the space serving as empty + * @return Empty + */ + public Space getEmpty() { + return empty; + } *************** *** 166,175 **** */ public void clear() { ! vertices.clear(); ! nextVertexId = 0; ! edges.clear(); ! nextEdgeId = 0; ! surfaces.clear(); ! nextSurfaceId = 0; } --- 229,244 ---- */ public void clear() { ! if (container) { ! vertices.clear(); ! nextVertexId = 0; ! edges.clear(); ! nextEdgeId = 0; ! surfaces.clear(); ! nextSurfaceId = 0; ! elements.clear(); ! nextElementId = 0; ! empty = new Space("Void", FUNCTIONAL, false); ! this.add(empty); ! } } *************** *** 179,186 **** */ public void add(Vertex vertex) { ! Long id = new Long(nextVertexId++); ! vertex.setId(id); ! vertices.put(id, vertex); ! vertex.setOwner(this); } --- 248,259 ---- */ public void add(Vertex vertex) { ! if (container) { ! Long id = new Long(nextVertexId++); ! vertex.setId(id); ! vertices.put(id, vertex); ! vertex.setOwner(this); ! } else { ! throw new Error("adding vertex to non-container " + this); ! } } *************** *** 226,230 **** */ public Collection getVertices() { ! return vertices.values(); } --- 299,307 ---- */ public Collection getVertices() { ! if (container) { ! return vertices.values(); ! } else { ! return EMPTY; ! } } *************** *** 243,250 **** */ public void add(Edge edge) { ! Long id = new Long(nextEdgeId++); ! edge.setId(id); ! edges.put(id, edge); ! edge.setOwner(this); } --- 320,331 ---- */ public void add(Edge edge) { ! if (container) { ! Long id = new Long(nextEdgeId++); ! edge.setId(id); ! edges.put(id, edge); ! edge.setOwner(this); ! } else { ! throw new Error("adding edge to non-container " + this); ! } } *************** *** 366,370 **** edges1.addAll(edges2); Surface surface = new Surface(edges1); ! add(surface); if (s1.getExterior() != null) { s1.getExterior().addHole(surface); --- 447,451 ---- edges1.addAll(edges2); Surface surface = new Surface(edges1); ! insert(surface); if (s1.getExterior() != null) { s1.getExterior().addHole(surface); *************** *** 398,402 **** */ public Collection getEdges() { ! return edges.values(); } --- 479,487 ---- */ public Collection getEdges() { ! if (container) { ! return edges.values(); ! } else { ! return EMPTY; ! } } *************** *** 415,422 **** */ public void add(Surface surface) { ! Long id = new Long(nextSurfaceId++); ! surface.setId(id); ! surfaces.put(id, surface); ! surface.setOwner(this); } --- 500,511 ---- */ public void add(Surface surface) { ! if (container) { ! Long id = new Long(nextSurfaceId++); ! surface.setId(id); ! surfaces.put(id, surface); ! surface.setOwner(this); ! } else { ! throw new Error("adding surface to non-container " + this); ! } } *************** *** 452,455 **** --- 541,546 ---- public Surface insert(Surface surface) { add(surface); + surface.setBackDomain(empty); + surface.setFrontDomain(empty); return surface; } *************** *** 477,481 **** */ public Collection getSurfaces() { ! return surfaces.values(); } --- 568,576 ---- */ public Collection getSurfaces() { ! if (container) { ! return surfaces.values(); ! } else { ! return EMPTY; ! } } *************** *** 578,584 **** */ public void addSurface(Surface surface) { - if (envelope == null) { - envelope = new HashSet(); - } envelope.add(surface); changed(); --- 673,676 ---- *************** *** 590,599 **** */ public void removeSurface(Surface surface) { ! if (envelope != null) { ! envelope.remove(surface); ! changed(); ! } else { ! throw new Error("removing " + surface + " from " + this + " with no envelope"); ! } } --- 682,687 ---- */ public void removeSurface(Surface surface) { ! envelope.remove(surface); ! changed(); } *************** *** 603,610 **** */ public void add(Space element) { ! if (elements == null) { ! elements = new LinkedList(); } - elements.add(element); } --- 691,701 ---- */ public void add(Space element) { ! if (container) { ! Long id = new Long(nextElementId++); ! element.setId(id); ! elements.put(id, element); ! } else { ! throw new Error("adding element to non-container " + this); } } *************** *** 614,620 **** */ public void remove(Space element) { ! elements.remove(element); } /** --- 705,740 ---- */ public void remove(Space element) { ! Set surfaces = element.getEnvelope(); ! if (surfaces != null) { ! Iterator iter = surfaces.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface)iter.next(); ! Space back = current.getBackDomain(); ! if (back == element) { ! current.setBackDomain(null); ! } else { ! Space front = current.getFrontDomain(); ! if (front == element) { ! current.setFrontDomain(null); ! } ! } ! } ! } ! ! elements.remove(element.getId()); ! element.setId(null); } + /** + * Get elements + * @return Elements + */ + public Collection getElements() { + if (container) { + return elements.values(); + } else { + return EMPTY; + } + } /** Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Geometry.java 30 Mar 2006 08:03:45 -0000 1.18 --- Geometry.java 5 Apr 2006 09:35:58 -0000 1.19 *************** *** 263,267 **** if (clockwise.angle(vertex.system()) < 0) { ! mesh.add(clockwise); holeAnalysis(clockwise); surfaces.add(clockwise); --- 263,267 ---- if (clockwise.angle(vertex.system()) < 0) { ! mesh.insert(clockwise); holeAnalysis(clockwise); surfaces.add(clockwise); *************** *** 274,278 **** if (counterclockwise != null) { if (counterclockwise.angle(vertex.system()) > 0) { ! mesh.add(counterclockwise); holeAnalysis(counterclockwise); surfaces.add(counterclockwise); --- 274,278 ---- if (counterclockwise != null) { if (counterclockwise.angle(vertex.system()) > 0) { ! mesh.insert(counterclockwise); holeAnalysis(counterclockwise); surfaces.add(counterclockwise); *************** *** 612,615 **** --- 612,633 ---- /** + * Test if exterior contains interior + * @param exterior The exterior surface + * @param interior The interior surface + * @return True if exterior contains interior + */ + public static boolean contains(Surface exterior, Surface interior) { + if (interior == null) { + return false; + } else { + if (interior.getExterior() == exterior) { + return true; + } else { + return contains(exterior, interior.getExterior()); + } + } + } + + /** * See if surface has become a hole in a surface in * the project. *************** *** 617,629 **** */ public static void holeAnalysis(Surface surface) { ! Collection surfaces = surface.getOwner().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != surface) { ! if (current.surrounds(surface)) { ! current.addHole(surface); ! } else if (surface.surrounds(current)) { ! surface.addHole(current); } } --- 635,706 ---- */ public static void holeAnalysis(Surface surface) { ! Set exteriors = new HashSet(); ! Set interiors = new HashSet(); ! ! { ! Collection surfaces = surface.getOwner().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != surface) { ! if (current.surrounds(surface)) { ! exteriors.add(current); ! } else if (surface.surrounds(current)) { ! interiors.add(current); ! } ! } ! } ! } ! ! Surface exterior = null; ! { ! // Find exterior ! // The exterior is the surface among the candidates that does not ! // contain any of the other candidates. ! Iterator iter = exteriors.iterator(); ! search: ! while (iter.hasNext()) { ! Surface candidate = (Surface) iter.next(); ! Iterator inner = exteriors.iterator(); ! check: ! { ! while (inner.hasNext()) { ! Surface current = (Surface) inner.next(); ! if (current != candidate) { ! if (contains(candidate, current)) { ! // Discard current candidate and look at the next ! break check; ! } ! } ! } ! // Acecpt current candidate and break the search. ! exterior = candidate; ! break search; ! } ! } ! } ! if (exterior != null) { ! Project.info(exterior + " contains " + surface); ! exterior.addHole(surface); ! ! } ! { ! // Find interior ! if (exterior == null) { ! Iterator iter = interiors.iterator(); ! while (iter.hasNext()) { ! Surface candidate = (Surface) iter.next(); ! if (candidate.getExterior() == null) { ! surface.addHole(candidate); ! } ! } ! } else { ! Iterator iter = interiors.iterator(); ! while (iter.hasNext()) { ! Surface candidate = (Surface) iter.next(); ! if (candidate.getExterior() == exterior) { ! exterior.removeHole(candidate); ! surface.addHole(candidate); ! } } } --- NEW FILE: Persistence.java --- //--------------------------------------------------------------------------------- // $Id: Persistence.java,v 1.1 2006/04/05 09:35:58 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 net.sourceforge.bprocessor.model.xml.Bmodel; import net.sourceforge.bprocessor.model.xml.EdgeType; import net.sourceforge.bprocessor.model.xml.EntityType; import net.sourceforge.bprocessor.model.xml.SpaceType; import net.sourceforge.bprocessor.model.xml.SurfaceType; import net.sourceforge.bprocessor.model.xml.VertexType; import net.sourceforge.bprocessor.model.xml.impl.BmodelImpl; import net.sourceforge.bprocessor.model.xml.impl.EdgeImpl; import net.sourceforge.bprocessor.model.xml.impl.SpaceImpl; import net.sourceforge.bprocessor.model.xml.impl.SurfaceImpl; import net.sourceforge.bprocessor.model.xml.impl.VertexImpl; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.apache.log4j.Logger; /** * This class persist the model from/to an XML document */ public class Persistence { /** The logger */ private static Logger log = Logger.getLogger(Persistence.class); /** Mapper counter */ private static long counter; /** * Constructor */ private Persistence() { } /** * This method internalizes a b-processor document * @param document XML */ public static void internalize(Bmodel document) { HashMap mapper = new HashMap(); Collection xmls = new LinkedList(); Space world = internalizeSpace((SpaceType) document.getSpace().iterator().next(), mapper, xmls); { Iterator iter = xmls.iterator(); while (iter.hasNext()) { EntityType external = (EntityType) iter.next(); Object object = mapper.get(new Long(external.getId())); internalizeReferences(object, external, mapper); } } Project.getInstance().setWorld(world); Project.getInstance().setActiveSpace((Space) get(document.getActive(), mapper)); } /** * This method loads the Bmodel document from a file * @param file The input file * @exception Exception Thrown if an exception occurs */ public static void load(File file) throws Exception { FileInputStream fis = new FileInputStream(file); Bmodel bp = loadFile(fis); internalize(bp); fis.close(); } /** * This method loads the Bmodel document from a file * @param is The input stream * @return The Bmodel document * @exception Exception Thrown if an exception occurs */ private static Bmodel loadFile(InputStream is) throws Exception { JAXBContext jc = JAXBContext.newInstance("net.sourceforge.bprocessor.model.xml"); Unmarshaller u = jc.createUnmarshaller(); return (Bmodel)u.unmarshal(is); } /** * * @param xml The SpaceType * @param mapper The mapper * @param xmls The xmls * @return The Space */ private static Space internalizeSpace(SpaceType xml, Map mapper, Collection xmls) { String name = xml.getName(); Collection elements = new LinkedList(); int type = xml.getType(); long empty = xml.getVoidref(); boolean container = (empty != 0); Space space = new Space(name, type, container); space.setDescription(xml.getDescription()); mapper.put(new Long(xml.getId()), space); xmls.add(xml); { Iterator iter = xml.getSpace().iterator(); while (iter.hasNext()) { SpaceType current = (SpaceType) iter.next(); elements.add(internalizeSpace(current, mapper, xmls)); } } Space e = null; if (empty != 0) { e = (Space) mapper.get(new Long(empty)); space.setEmpty(e); } { Iterator iter = elements.iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); if (current != e) { space.add(current); } } } { Iterator iter = xml.getSurface().iterator(); while (iter.hasNext()) { SurfaceType current = (SurfaceType) iter.next(); space.add(internalizeSurface(current, mapper, xmls)); } } { Iterator iter = xml.getEdge().iterator(); while (iter.hasNext()) { EdgeType current = (EdgeType) iter.next(); space.add(internalizeEdge(current, mapper, xmls)); } } { Iterator iter = xml.getVertex().iterator(); while (iter.hasNext()) { VertexType current = (VertexType) iter.next(); space.add(internalizeVertex(current, mapper, xmls)); } } return space; } /** * * @param xml The SurfaceType * @param mapper The mapper * @param xmls The xmls * @return The Surface */ private static Surface internalizeSurface(SurfaceType xml, Map mapper, Collection xmls) { Surface surface = new Surface(); mapper.put(new Long(xml.getId()), surface); xmls.add(xml); return surface; } /** * * @param xml The EdgeType * @param mapper The mapper * @param xmls The xmls * @return The Edge */ private static Edge internalizeEdge(EdgeType xml, Map mapper, Collection xmls) { Edge edge = new Edge(); mapper.put(new Long(xml.getId()), edge); xmls.add(xml); edge.setConstructor(xml.isConstructor()); return edge; } /** * * @param xml The VertexType * @param mapper The mapper * @param xmls The xmls * @return The Vertex */ private static Vertex internalizeVertex(VertexType xml, Map mapper, Collection xmls) { Vertex vertex = new Vertex(); mapper.put(new Long(xml.getId()), vertex); xmls.add(xml); vertex.setX(xml.getX()); vertex.setY(xml.getY()); vertex.setZ(xml.getZ()); return vertex; } /** * * @param object The object * @param xml The xml * @param map The map */ private static void internalizeReferences(Object object, EntityType xml, Map map) { if (object instanceof Space) { internalizeReferences((Space) object, (SpaceType) xml, map); } else if (object instanceof Surface) { internalizeReferences((Surface) object, (SurfaceType) xml, map); } else if (object instanceof Edge) { internalizeReferences((Edge) object, (EdgeType) xml, map); } else if (object instanceof Vertex) { internalizeReferences((Vertex) object, (VertexType) xml, map); } } /** * * @param id The id * @param map The map * @return The object */ private static Object get(long id, Map map) { if (id == 0) { return null; } else { return map.get(new Long(id)); } } /** * * @param ids The ids * @param map The map * @return The list */ private static List asList(Collection ids, Map map) { List list = new LinkedList(); Iterator iter = ids.iterator(); while (iter.hasNext()) { list.add(map.get((Long) iter.next())); } return list; } /** * * @param ids The ids * @param map The map * @return The set */ private static Set asSet(Collection ids, Map map) { Set set = new HashSet(); Iterator iter = ids.iterator(); while (iter.hasNext()) { set.add(map.get((Long) iter.next())); } return set; } /** * * @param object The object * @param xml The xml * @param map The map */ private static void internalizeReferences(Space object, SpaceType xml, Map map) { object.setEnvelope(asSet(xml.getBoundary(), map)); } /** * * @param object The object * @param xml The xml * @param map The map */ private static void internalizeReferences(Surface object, SurfaceType xml, Map map) { object.setEdges(asList(xml.getEdgeref(), map)); object.setHoles(asSet(xml.getHole(), map)); object.setBackDomain((Space) get(xml.getBack(), map)); object.setFrontDomain((Space) get(xml.getFront(), map)); object.setExterior((Surface) get(xml.getExterior(), map)); } /** * * @param object The object * @param xml The xml * @param map The map */ private static void internalizeReferences(Edge object, EdgeType xml, Map map) { object.setFrom((Vertex) get(xml.getFrom(), map)); object.setTo((Vertex) get(xml.getTo(), map)); } /** * * @param object The object * @param xml The xml * @param map The map */ private static void internalizeReferences(Vertex object, VertexType xml, Map map) { } /** * This method externalizes the B-model to an XML structure. * @return XML */ public static Bmodel externalize() { Bmodel document = new BmodelImpl(); counter = 1; HashMap mapper = new HashMap(); document.getSpace().add(externalizeSpace(Project.getInstance().world(), mapper)); { Set entries = mapper.entrySet(); Iterator iter = entries.iterator(); while (iter.hasNext()) { Entry current = (Entry) iter.next(); Object object = current.getKey(); EntityType external = (EntityType) current.getValue(); externalizeReferences(object, external, mapper); } } document.setActive(id(mapper, Project.getInstance().getActiveSpace())); return document; } /** * This method saves the Bmodel document to a file * @param file The output file * @exception Exception Thrown if an exception occurs */ public static void save(File file) throws Exception { FileOutputStream fos = new FileOutputStream(file); Bmodel bp = externalize(); saveFile(bp, fos); fos.flush(); fos.close(); } /** * Save the document to an output stream * @param document The Bmodel document * @param stream The output stream * @exception Exception Thrown if an error occurs */ private static void saveFile(Bmodel document, OutputStream stream) throws Exception { JAXBContext jc = JAXBContext.newInstance("net.sourceforge.bprocessor.model.xml"); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(document, stream); } /** * Create an xml SpaceImpl and place it in the map * @param space The space * @param map The map * @return The SpaceImpl */ private static SpaceType externalizeSpace(Space space, Map map) { SpaceType xml = new SpaceImpl(); xml.setId(counter++); xml.setName(space.getName()); xml.setType(space.getType()); xml.setDescription(space.getDescription().toString()); map.put(space, xml); { Iterator iter = space.getElements().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); xml.getSpace().add(externalizeSpace(current, map)); } } { Iterator iter = space.getSurfaces().iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); xml.getSurface().add(externalizeSurface(current, map)); } } { Iterator iter = space.getEdges().iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); xml.getEdge().add(externalizeEdge(current, map)); } } { Iterator iter = space.getVertices().iterator(); while (iter.hasNext()) { Vertex current = (Vertex) iter.next(); xml.getVertex().add(externalizeVertex(current, map)); } } return xml; } /** * Create an xml SurfaceImpl and place it in the map * @param surface The surface * @param map The map * @return The SurfaceImpl */ private static SurfaceType externalizeSurface(Surface surface, Map map) { SurfaceType xml = new SurfaceImpl(); xml.setId(counter++); map.put(surface, xml); return xml; } /** * Create an xml EdgeImpl and place it in the map * @param edge The Edge * @param map The map * @return The EdgeImpl */ private static EdgeType externalizeEdge(Edge edge, Map map) { EdgeType xml = new EdgeImpl(); xml.setId(counter++); map.put(edge, xml); xml.setConstructor(edge.getConstructor()); return xml; } /** * Create an xml VertexImpl and place it in the map * @param vertex The Vertex * @param map The map * @return The VertexImpl */ private static VertexType externalizeVertex(Vertex vertex, Map map) { VertexType xml = new VertexImpl(); xml.setId(counter++); map.put(vertex, xml); xml.setX(vertex.getX()); xml.setY(vertex.getY()); xml.setZ(vertex.getZ()); return xml; } /** * Return the id of an xml entity by looking the entity up in the map * @param map The map * @param object The object * @return The id */ public static long id(Map map, Object object) { if (object == null) { return 0; } else { EntityType xml = (EntityType) map.get(object); if (xml == null) { return 0; } else { return xml.getId(); } } } /** * Return collection ids for objects * @param map The map * @param objects The objects * @return The ids */ public static Collection ids(Map map, Collection objects) { Collection ids = new LinkedList(); Iterator iter = objects.iterator(); while (iter.hasNext()) { Object current = iter.next(); ids.add(new Long(id(map, current))); } return ids; } /** * Externalize references * @param object The object * @param xml The xml entity * @param map The map */ private static void externalizeReferences(Object object, EntityType xml, Map map) { if (object instanceof Space) { externalizeReferences((Space) object, (SpaceType) xml, map); } else if (object instanceof Surface) { externalizeReferences((Surface) object, (SurfaceType) xml, map); } else if (object instanceof Edge) { externalizeReferences((Edge) object, (EdgeType) xml, map); } else if (object instanceof Vertex) { externalizeReferences((Vertex) object, (VertexType) xml, map); } } /** * Externalize references * @param object The object * @param xml The xml entity * @param map The map */ private static void externalizeReferences(Space object, SpaceType xml, Map map) { xml.setVoidref(id(map, object.getEmpty())); xml.getBoundary().addAll(ids(map, object.getEnvelope())); } /** * Externalize references * @param object The object * @param xml The xml entity * @param map The map */ private static void externalizeReferences(Surface object, SurfaceType xml, Map map) { xml.getEdgeref().addAll(ids(map, object.getEdges())); xml.getHole().addAll(ids(map, object.getHoles())); xml.setFront(id(map, object.getFrontDomain())); xml.setBack(id(map, object.getBackDomain())); xml.setExterior(id(map, object.getExterior())); } /** * Externalize references * @param object The object * @param xml The xml entity * @param map The map */ private static void externalizeReferences(Edge object, EdgeType xml, Map map) { xml.setFrom(id(map, object.getFrom())); xml.setTo(id(map, object.getTo())); } /** * Externalize references * @param object The object * @param xml The xml entity * @param map The map */ private static void externalizeReferences(Vertex object, VertexType xml, Map map) { } } |
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:08
|
Update of /cvsroot/bprocessor/model/src/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8178/src/etc Modified Files: bprocessor.xsd Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: bprocessor.xsd =================================================================== RCS file: /cvsroot/bprocessor/model/src/etc/bprocessor.xsd,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** bprocessor.xsd 1 Feb 2006 11:36:56 -0000 1.9 --- bprocessor.xsd 5 Apr 2006 09:35:58 -0000 1.10 *************** *** 8,17 **** <!-- Type definitions --> ! <xsd:complexType name="DomainType"> <xsd:sequence> <xsd:element name="id" type="xsd:long"/> - <xsd:element name="name" type="xsd:string"/> - <xsd:element name="description" type="xsd:string"/> - <xsd:element name="surfaceref" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> </xsd:complexType> --- 8,14 ---- <!-- Type definitions --> ! <xsd:complexType name="EntityType"> <xsd:sequence> <xsd:element name="id" type="xsd:long"/> </xsd:sequence> </xsd:complexType> *************** *** 19,25 **** <xsd:complexType name="SpaceType"> <xsd:complexContent> ! <xsd:extension base="DomainType"> <xsd:sequence> ! <xsd:element name="elementref" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> </xsd:extension> --- 16,31 ---- <xsd:complexType name="SpaceType"> <xsd:complexContent> ! <xsd:extension base="EntityType"> <xsd:sequence> ! <xsd:element name="name" type="xsd:string" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="type" type="xsd:int" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="description" type="xsd:string" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="boundary" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element name="voidref" type="xsd:long" maxOccurs="1" minOccurs="0"/> ! ! <xsd:element ref="space" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element ref="surface" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element ref="edge" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element ref="vertex" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> </xsd:extension> *************** *** 27,99 **** </xsd:complexType> ! <xsd:complexType name="ConstructionSpaceType"> ! <xsd:complexContent> ! <xsd:extension base="SpaceType"> ! </xsd:extension> ! </xsd:complexContent> ! </xsd:complexType> ! ! <xsd:complexType name="FunctionalSpaceType"> <xsd:complexContent> ! <xsd:extension base="SpaceType"> ! </xsd:extension> </xsd:complexContent> </xsd:complexType> ! <xsd:complexType name="ElementType"> <xsd:complexContent> ! <xsd:extension base="DomainType"> ! <xsd:sequence> ! <xsd:element name="partref" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> ! </xsd:sequence> ! </xsd:extension> </xsd:complexContent> </xsd:complexType> ! <xsd:complexType name="PartType"> <xsd:complexContent> ! <xsd:extension base="DomainType"> ! </xsd:extension> </xsd:complexContent> </xsd:complexType> - <xsd:complexType name="SurfaceType"> - <xsd:sequence> - <xsd:element name="id" type="xsd:long"/> - <xsd:element name="name" type="xsd:string"/> - <xsd:element name="constructor" type="xsd:boolean"/> - <xsd:element name="edgeref" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> - <xsd:element name="innersurfacesref" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> - <xsd:element name="backdomainref" type="xsd:long" maxOccurs="1" minOccurs="0"/> - <xsd:element name="frontdomainref" type="xsd:long" maxOccurs="1" minOccurs="0"/> - <xsd:element name="exteriorref" type="xsd:long" maxOccurs="1" minOccurs="0"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="EdgeType"> - <xsd:sequence> - <xsd:element name="id" type="xsd:long"/> - <xsd:element name="name" type="xsd:string"/> - <xsd:element name="vertexfromref" type="xsd:long" maxOccurs="1" minOccurs="0"/> - <xsd:element name="vertextoref" type="xsd:long" maxOccurs="1" minOccurs="0"/> - <xsd:element name="constructor" type="xsd:boolean"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="VertexType"> - <xsd:sequence> - <xsd:element name="id" type="xsd:long"/> - <xsd:element name="name" type="xsd:string"/> - <xsd:element name="x" type="xsd:double"/> - <xsd:element name="y" type="xsd:double"/> - <xsd:element name="z" type="xsd:double"/> - </xsd:sequence> - </xsd:complexType> - <!-- Element definitions --> ! <xsd:element name="constructionspace" type="ConstructionSpaceType"/> ! <xsd:element name="functionalspace" type="FunctionalSpaceType"/> ! <xsd:element name="element" type="ElementType"/> ! <xsd:element name="part" type="PartType"/> <xsd:element name="surface" type="SurfaceType"/> <xsd:element name="edge" type="EdgeType"/> --- 33,77 ---- </xsd:complexType> ! <xsd:complexType name="SurfaceType"> <xsd:complexContent> ! <xsd:extension base="EntityType"> ! <xsd:sequence> ! <xsd:element name="constructor" type="xsd:boolean" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="edgeref" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element name="hole" type="xsd:long" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element name="back" type="xsd:long" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="front" type="xsd:long" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="exterior" type="xsd:long" maxOccurs="1" minOccurs="0"/> ! </xsd:sequence> ! </xsd:extension> </xsd:complexContent> </xsd:complexType> ! <xsd:complexType name="EdgeType"> <xsd:complexContent> ! <xsd:extension base="EntityType"> ! <xsd:sequence> ! <xsd:element name="from" type="xsd:long" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="to" type="xsd:long" maxOccurs="1" minOccurs="0"/> ! <xsd:element name="constructor" type="xsd:boolean" maxOccurs="1" minOccurs="0"/> ! </xsd:sequence> ! </xsd:extension> </xsd:complexContent> </xsd:complexType> ! <xsd:complexType name="VertexType"> <xsd:complexContent> ! <xsd:extension base="EntityType"> ! <xsd:sequence> ! <xsd:element name="x" type="xsd:double"/> ! <xsd:element name="y" type="xsd:double"/> ! <xsd:element name="z" type="xsd:double"/> ! </xsd:sequence> ! </xsd:extension> </xsd:complexContent> </xsd:complexType> <!-- Element definitions --> ! <xsd:element name="space" type="SpaceType"/> <xsd:element name="surface" type="SurfaceType"/> <xsd:element name="edge" type="EdgeType"/> *************** *** 101,111 **** <!-- Main element --> ! <xsd:element name="bprocessor"> <xsd:complexType> <xsd:sequence> ! <xsd:element ref="constructionspace" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element ref="functionalspace" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element ref="element" maxOccurs="unbounded" minOccurs="0"/> ! <xsd:element ref="part" maxOccurs="unbounded" minOccurs="0"/> <xsd:element ref="surface" maxOccurs="unbounded" minOccurs="0"/> <xsd:element ref="edge" maxOccurs="unbounded" minOccurs="0"/> --- 79,87 ---- <!-- Main element --> ! <xsd:element name="bmodel"> <xsd:complexType> <xsd:sequence> ! <xsd:element name="active" type="xsd:long" maxOccurs="1" minOccurs="0"/> ! <xsd:element ref="space" maxOccurs="unbounded" minOccurs="0"/> <xsd:element ref="surface" maxOccurs="unbounded" minOccurs="0"/> <xsd:element ref="edge" maxOccurs="unbounded" minOccurs="0"/> |
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:05
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8178/src/net/sourceforge/bprocessor/model/xml Removed Files: PersistenceManager.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet --- PersistenceManager.java DELETED --- |
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:04
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8092/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileExportActionListener.java FileImportActionListener.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: FileExportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileExportActionListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileExportActionListener.java 18 Jul 2005 09:27:22 -0000 1.1 --- FileExportActionListener.java 5 Apr 2006 09:35:50 -0000 1.2 *************** *** 7,11 **** package net.sourceforge.bprocessor.gui.actions; ! import net.sourceforge.bprocessor.model.xml.PersistenceManager; import java.awt.event.ActionEvent; --- 7,11 ---- package net.sourceforge.bprocessor.gui.actions; ! import net.sourceforge.bprocessor.model.Persistence; import java.awt.event.ActionEvent; *************** *** 42,46 **** state == JFileChooser.APPROVE_OPTION) { try { ! PersistenceManager.save(file); } catch (Exception ex) { log.error("Could not export to file: " + file, ex); --- 42,46 ---- state == JFileChooser.APPROVE_OPTION) { try { ! Persistence.save(file); } catch (Exception ex) { log.error("Could not export to file: " + file, ex); Index: FileImportActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileImportActionListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileImportActionListener.java 18 Jul 2005 09:27:22 -0000 1.1 --- FileImportActionListener.java 5 Apr 2006 09:35:50 -0000 1.2 *************** *** 7,12 **** package net.sourceforge.bprocessor.gui.actions; ! import net.sourceforge.bprocessor.model.xml.PersistenceManager; ! import java.awt.event.ActionEvent; import java.awt.event.ActionListener; --- 7,11 ---- package net.sourceforge.bprocessor.gui.actions; ! import net.sourceforge.bprocessor.model.Persistence; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; *************** *** 42,46 **** state == JFileChooser.APPROVE_OPTION) { try { ! PersistenceManager.load(file); } catch (Exception ex) { log.error("Could not import file: " + file, ex); --- 41,45 ---- state == JFileChooser.APPROVE_OPTION) { try { ! Persistence.load(file); } catch (Exception ex) { log.error("Could not import file: " + file, ex); |
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:01
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8092/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java SpaceTreeView.java TreeView.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: TreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/TreeView.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TreeView.java 3 Jan 2006 10:53:50 -0000 1.2 --- TreeView.java 5 Apr 2006 09:35:50 -0000 1.3 *************** *** 31,34 **** --- 31,42 ---- this.setFont(font); } + + /** + * Info + * @param info Info + */ + public static void info(Object info) { + log.info(info); + } } Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** GenericTreeView.java 25 Mar 2006 18:09:33 -0000 1.20 --- GenericTreeView.java 5 Apr 2006 09:35:49 -0000 1.21 *************** *** 8,12 **** import java.awt.Component; - import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; --- 8,11 ---- *************** *** 15,23 **** import java.util.Collection; import java.util.Iterator; - import java.util.List; import java.util.Set; import javax.swing.ImageIcon; - import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JTree; --- 14,20 ---- *************** *** 47,50 **** --- 44,52 ---- public class GenericTreeView extends TreeView implements Observer { + /** + * + */ + private static final long serialVersionUID = 1L; + /** Show numbers of elements in display-string of container-nodes */ private static final boolean SHOW_COUNTERS = false; *************** *** 98,104 **** private boolean isChanged; - /** Current selection */ - private Object selection; - /** * Renderer --- 100,103 ---- *************** *** 106,109 **** --- 105,113 ---- public class Renderer extends DefaultTreeCellRenderer { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor */ *************** *** 226,229 **** --- 230,238 ---- public class GenericNode extends DefaultMutableTreeNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor * @param object The value *************** *** 263,266 **** --- 272,280 ---- public class ContainerNode extends GenericNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for ContainerNode * @param object User object *************** *** 303,306 **** --- 317,324 ---- public class EntityNode extends GenericNode { /** + * + */ + private static final long serialVersionUID = 1L; + /** * Constructor for EntityNode * @param object User object *************** *** 329,332 **** --- 347,355 ---- public class SpaceNode extends EntityNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for SpaceNode * @param space Space *************** *** 337,340 **** --- 360,364 ---- add(new SurfaceContainer("Surfaces", surfaces)); add(new ElementContainer("Elements", space)); + add(new GeometryContainer("Geometry", space)); if (space.getModellor() != null) { add(new ModellorNode(space.getModellor())); *************** *** 356,359 **** --- 380,388 ---- public class SurfaceNode extends EntityNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for SurfaceNode * @param surface The surface *************** *** 378,381 **** --- 407,415 ---- public class EdgeNode extends EntityNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for SurfaceNode * @param edge The edge *************** *** 401,404 **** --- 435,443 ---- public class VertexNode extends EntityNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for VertexNode * @param vertex The vertex *************** *** 423,426 **** --- 462,470 ---- public class ModellorNode extends EntityNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor * @param modellor The modellor *************** *** 436,439 **** --- 480,488 ---- public class CameraNode extends EntityNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for CameraNode * @param camera The camera *************** *** 449,452 **** --- 498,506 ---- public class SpaceContainer extends ContainerNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for SpaceContainer * @param name Display name *************** *** 477,480 **** --- 531,539 ---- public class SurfaceContainer extends ContainerNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for SurfaceContainer * @param name The name *************** *** 504,512 **** */ public class ElementContainer extends ContainerNode { ! /** Space */ ! private Space space; /** ! * Construftor * @param name The name * @param space The space --- 563,573 ---- */ public class ElementContainer extends ContainerNode { ! /** ! * ! */ ! private static final long serialVersionUID = 1L; /** ! * Constructor * @param name The name * @param space The space *************** *** 514,518 **** public ElementContainer(String name, Space space) { super(name); ! this.space = space; } --- 575,584 ---- public ElementContainer(String name, Space space) { super(name); ! Collection elements = space.getElements(); ! Iterator iter = elements.iterator(); ! while (iter.hasNext()) { ! Space current = (Space) iter.next(); ! add(new SpaceNode(current)); ! } } *************** *** 529,554 **** */ public JPopupMenu menu() { ! JPopupMenu menu = new JPopupMenu(); ! if (Project.getInstance().getActiveSpace() == space) { ! JMenuItem offsetItem = new JMenuItem("Finish Edit"); ! offsetItem.addActionListener(new MenuAction() { ! public void actionPerformed(ActionEvent event) { ! Project.getInstance().setActiveSpace(null); ! } ! } ! ); ! menu.add(offsetItem); ! } else { ! JMenuItem offsetItem = new JMenuItem("Edit"); ! offsetItem.addActionListener(new MenuAction() { ! public void actionPerformed(ActionEvent event) { ! Project.getInstance().setActiveSpace(space); ! } ! } ! ); ! menu.add(offsetItem); ! } ! ! return menu; } } --- 595,622 ---- */ public JPopupMenu menu() { ! return null; ! } ! } ! ! /** ! * Geometry Container ! */ ! public class GeometryContainer extends ContainerNode { ! ! /** ! * ! */ ! private static final long serialVersionUID = 1L; ! ! /** ! * Constructor ! * @param name The name ! * @param space The space ! */ ! public GeometryContainer(String name, Space space) { ! super(name); ! add(new SurfaceContainer("Surfaces", space.getSurfaces())); ! add(new EdgeContainer("Edges", space.getEdges())); ! add(new VertexContainer("Vertices", space.getVertices())); } } *************** *** 558,561 **** --- 626,632 ---- */ public class EdgeContainer extends ContainerNode { + /** */ + private static final long serialVersionUID = 1L; + /** * Constructor for EdgeContainer *************** *** 563,567 **** * @param edges The edges */ ! public EdgeContainer(String name, List edges) { super(name); Iterator iter = edges.iterator(); --- 634,638 ---- * @param edges The edges */ ! public EdgeContainer(String name, Collection edges) { super(name); Iterator iter = edges.iterator(); *************** *** 579,583 **** --- 650,683 ---- return edgegroupicon; } + } + + /** + * VertexContainer + */ + public class VertexContainer extends ContainerNode { + /** */ + private static final long serialVersionUID = 1L; + + /** + * Constructor for EdgeContainer + * @param name The name + * @param vertices The edges + */ + public VertexContainer(String name, Collection vertices) { + super(name); + Iterator iter = vertices.iterator(); + while (iter.hasNext()) { + Vertex current = (Vertex) iter.next(); + add(new VertexNode(current)); + } + } + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return edgegroupicon; + } } *************** *** 587,590 **** --- 687,695 ---- public class ConstraintNode extends EntityNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for ConstraintNode * @param constraint The constraint *************** *** 600,603 **** --- 705,713 ---- public class ConstraintContainer extends ContainerNode { /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for ConstraintContainer * @param name The name *************** *** 643,647 **** TreePath path = getPathForLocation(e.getX(), e.getY()); if (path != null) { ! if (e.isControlDown()) { Object object = path.getLastPathComponent(); if (object instanceof GenericNode) { --- 753,757 ---- TreePath path = getPathForLocation(e.getX(), e.getY()); if (path != null) { ! if (e.isPopupTrigger()) { Object object = path.getLastPathComponent(); if (object instanceof GenericNode) { Index: SpaceTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/SpaceTreeView.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SpaceTreeView.java 30 Jan 2006 15:08:35 -0000 1.5 --- SpaceTreeView.java 5 Apr 2006 09:35:50 -0000 1.6 *************** *** 18,21 **** --- 18,26 ---- /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Constructor for SpaceTreeView */ *************** *** 35,38 **** --- 40,44 ---- root.add(new SpaceContainer("Construction", construction)); root.add(new ConstraintContainer("Constraints", constraints)); + root.add(new GeometryContainer("Geometry", Project.getInstance().world())); model.nodeStructureChanged(root); } |
|
From: Michael L. <he...@us...> - 2006-03-30 08:03:48
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8594/src/net/sourceforge/bprocessor/model Modified Files: Geometry.java Project.java Log Message: - The intersection can now deliver a plane as its object - Removed some messages to the console Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Geometry.java 25 Mar 2006 18:08:32 -0000 1.17 --- Geometry.java 30 Mar 2006 08:03:45 -0000 1.18 *************** *** 255,259 **** private static void findSurfaces(VertexNode vertex, EdgeNode last, List edges, Surface exterior) { int count = 0; - System.out.println("find-surfaces"); List surfaces = new LinkedList(); Space mesh = ((Edge) edges.iterator().next()).getOwner(); --- 255,258 ---- Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** Project.java 26 Mar 2006 21:40:37 -0000 1.52 --- Project.java 30 Mar 2006 08:03:45 -0000 1.53 *************** *** 577,581 **** */ public void setActiveSpace(Space space) { - System.out.println("active " + space); activeSpace = space; changed(this); --- 577,580 ---- *************** *** 646,653 **** redoStack.clear(); if (currentState != null) { - log.info("pushing state on undo-stack"); undoStack.push(currentState); } - log.info("externalizing current-state"); currentState = PersistenceManager.externalize(); } --- 645,650 ---- *************** *** 675,682 **** if (canUndo()) { if (currentState != null) { - log.info("pushing state on redo-stack"); redoStack.push(currentState); } - log.info("popping state from undo-stack"); currentState = (Bprocessor) undoStack.pop(); clear(); --- 672,677 ---- *************** *** 691,698 **** if (canRedo()) { if (currentState != null) { - log.info("pushing state on undo-stack"); undoStack.push(currentState); } - log.info("popping state from redo-stack"); currentState = (Bprocessor) redoStack.pop(); clear(); --- 686,691 ---- |
|
From: Michael L. <he...@us...> - 2006-03-30 08:03:45
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8520/src/net/sourceforge/bprocessor/gl/model Modified Files: Intersection.java Log Message: - The intersection can now deliver a plane as its object - Removed some messages to the console Index: Intersection.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model/Intersection.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Intersection.java 30 Mar 2006 07:41:27 -0000 1.2 --- Intersection.java 30 Mar 2006 08:03:41 -0000 1.3 *************** *** 9,13 **** import net.sourceforge.bprocessor.model.Edge; - import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Vertex; --- 9,12 ---- *************** *** 46,50 **** /** The primary object */ ! private Geometric object; /** --- 45,49 ---- /** The primary object */ ! private Object object; /** *************** *** 54,58 **** * @param object The object */ ! public Intersection(Vertex vertex, int type, Geometric object) { super(); this.vertex = vertex; --- 53,57 ---- * @param object The object */ ! public Intersection(Vertex vertex, int type, Object object) { super(); this.vertex = vertex; *************** *** 81,85 **** * @return object */ ! public Geometric object() { return object; } --- 80,84 ---- * @return object */ ! public Object object() { return object; } |
|
From: Michael L. <he...@us...> - 2006-03-30 08:03:44
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8520/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: - The intersection can now deliver a plane as its object - Removed some messages to the console Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** View.java 29 Mar 2006 18:35:56 -0000 1.74 --- View.java 30 Mar 2006 08:03:41 -0000 1.75 *************** *** 1966,1970 **** intersection.setZ(0.0); } ! return new Intersection(intersection, Intersection.PLANE_INTERSECTION, null); } } --- 1966,1970 ---- intersection.setZ(0.0); } ! return new Intersection(intersection, Intersection.PLANE_INTERSECTION, xy); } } |
|
From: Michael L. <he...@us...> - 2006-03-30 08:03:44
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8520/src/net/sourceforge/bprocessor/gl/tool Modified Files: MoveTool.java Log Message: - The intersection can now deliver a plane as its object - Removed some messages to the console Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** MoveTool.java 29 Mar 2006 18:39:25 -0000 1.50 --- MoveTool.java 30 Mar 2006 08:03:40 -0000 1.51 *************** *** 17,21 **** import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; - import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.gl.view.Transformation; --- 17,20 ---- *************** *** 125,129 **** if (start == null) { moveEntities = new HashSet(); ! Geometric primary = current.object(); if (selection.isEmpty() && primary != null) { moveEntities.add(primary); --- 124,128 ---- if (start == null) { moveEntities = new HashSet(); ! Object primary = current.object(); if (selection.isEmpty() && primary != null) { moveEntities.add(primary); |
|
From: Michael L. <he...@us...> - 2006-03-30 07:41:30
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25032/src/net/sourceforge/bprocessor/gl/model Modified Files: Intersection.java Log Message: Improvements of AbstractPencil Index: Intersection.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model/Intersection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Intersection.java 7 Mar 2006 22:31:06 -0000 1.1 --- Intersection.java 30 Mar 2006 07:41:27 -0000 1.2 *************** *** 8,11 **** --- 8,12 ---- package net.sourceforge.bprocessor.gl.model; + import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Vertex; *************** *** 83,85 **** --- 84,143 ---- return object; } + + /** + * Return true if the object in this intersection + * is an edge (that is not a constructor) + * @return True if object is edge + */ + public boolean hasEdge() { + if (type == EDGE_MIDPOINT) { + return true; + } + if (type == EDGE) { + Edge edge = (Edge) object; + return !edge.getConstructor(); + } + return false; + } + + /** + * @return String representation + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + String name = ""; + buffer.append("["); + switch (type) { + case Intersection.VERTEX: + name = "vertex"; + break; + case Intersection.EDGE: + name = "edge"; + break; + case Intersection.SURFACE: + name = "surface"; + break; + case Intersection.EDGE_MIDPOINT: + name = "edge midpoint"; + break; + case Intersection.EDGE_INTERSECTION: + name = "edge intersection"; + break; + case Intersection.SURFACE_INTERSECTION: + name = "surface intersection"; + break; + case Intersection.PLANE_INTERSECTION: + name = "plane intersection"; + break; + } + buffer.append(name); + if (object != null) { + buffer.append(" "); + buffer.append(object); + } + buffer.append(" "); + buffer.append(vertex); + buffer.append("]"); + return buffer.toString(); + } } |
|
From: Michael L. <he...@us...> - 2006-03-30 07:41:30
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25032/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractPencil.java Log Message: Improvements of AbstractPencil Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AbstractPencil.java 30 Mar 2006 06:28:41 -0000 1.19 --- AbstractPencil.java 30 Mar 2006 07:41:27 -0000 1.20 *************** *** 60,63 **** --- 60,66 ---- protected Intersection incident; + /** Work plane */ + protected Plane plane; + /** Number */ protected String number; *************** *** 73,77 **** public AbstractPencil(GLView glv, Cursor cursor) { super(glv, cursor); ! timer = new Timer(1000, new TargetAction()); timer.setRepeats(false); } --- 76,80 ---- public AbstractPencil(GLView glv, Cursor cursor) { super(glv, cursor); ! timer = new Timer(500, new TargetAction()); timer.setRepeats(false); } *************** *** 297,301 **** if (incident != null) { constructors.addAll(xyz(incident.vertex())); ! if (incident.type() == Intersection.EDGE_MIDPOINT) { Edge edge = (Edge) incident.object(); Vertex v = edge.getDirection(); --- 300,304 ---- if (incident != null) { constructors.addAll(xyz(incident.vertex())); ! if (incident.hasEdge()) { Edge edge = (Edge) incident.object(); Vertex v = edge.getDirection(); *************** *** 413,417 **** break; case Intersection.EDGE: ! target = intersection.object(); break; case Intersection.SURFACE: --- 416,425 ---- break; case Intersection.EDGE: ! Edge edge = (Edge) intersection.object(); ! if (edge.getConstructor()) { ! target = current; ! } else { ! target = intersection.object(); ! } break; case Intersection.SURFACE: *************** *** 578,581 **** --- 586,590 ---- */ public void cleanUp() { + plane = null; start = null; current = null; |
|
From: Michael L. <he...@us...> - 2006-03-30 06:28:44
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15565/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractPencil.java Log Message: Do not show the yellow line if parrallel to an axis since it is superfluous Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AbstractPencil.java 29 Mar 2006 21:52:51 -0000 1.18 --- AbstractPencil.java 30 Mar 2006 06:28:41 -0000 1.19 *************** *** 260,263 **** --- 260,291 ---- /** + * Test if an edge is parrallel with an axiz (x, y or z) + * @param edge The edge to test + * @return True if edge is parrallel to an axis + */ + protected boolean isAxisAligned(Edge edge) { + Vertex vector = edge.getDirection(); + { + Vertex cross = vector.cross(new Vertex(1, 0 , 0)); + if (cross.isZero()) { + return true; + } + } + { + Vertex cross = vector.cross(new Vertex(0, 1 , 0)); + if (cross.isZero()) { + return true; + } + } + { + Vertex cross = vector.cross(new Vertex(0, 0 , 1)); + if (cross.isZero()) { + return true; + } + } + return false; + } + + /** * Update constructors based on start, current and incident. */ *************** *** 279,285 **** parrallel = new Edge(incident.vertex().minus(v), incident.vertex().add(v)); } ! parrallel.setConstructor(true); ! glv.getView().changeColor(parrallel, new float[] {1, 1, 0}); ! constructors.add(parrallel); } } --- 307,316 ---- parrallel = new Edge(incident.vertex().minus(v), incident.vertex().add(v)); } ! ! if (!isAxisAligned(parrallel)) { ! parrallel.setConstructor(true); ! glv.getView().changeColor(parrallel, new float[] {1, 1, 0}); ! constructors.add(parrallel); ! } } } |
|
From: Michael L. <he...@us...> - 2006-03-29 21:52:54
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29503/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractPencil.java Log Message: Parrallel edge mechanism in Pencil Timer delays constructors until hoovering over the vertex/edge Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AbstractPencil.java 29 Mar 2006 18:37:24 -0000 1.17 --- AbstractPencil.java 29 Mar 2006 21:52:51 -0000 1.18 *************** *** 8,11 **** --- 8,13 ---- import java.awt.Cursor; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; *************** *** 17,20 **** --- 19,24 ---- import java.util.Set; + import javax.swing.Timer; + import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.model.Intersection; *************** *** 59,62 **** --- 63,69 ---- protected String number; + /** Timer */ + protected Timer timer; + /** * Constructor *************** *** 66,69 **** --- 73,78 ---- public AbstractPencil(GLView glv, Cursor cursor) { super(glv, cursor); + timer = new Timer(1000, new TargetAction()); + timer.setRepeats(false); } *************** *** 260,263 **** --- 269,286 ---- if (incident != null) { constructors.addAll(xyz(incident.vertex())); + if (incident.type() == Intersection.EDGE_MIDPOINT) { + Edge edge = (Edge) incident.object(); + Vertex v = edge.getDirection(); + v.scale(50 / v.length()); + Edge parrallel = null; + if (start != null) { + parrallel = new Edge(start.vertex().minus(v), start.vertex().add(v)); + } else { + parrallel = new Edge(incident.vertex().minus(v), incident.vertex().add(v)); + } + parrallel.setConstructor(true); + glv.getView().changeColor(parrallel, new float[] {1, 1, 0}); + constructors.add(parrallel); + } } constructors(constructors); *************** *** 295,302 **** --- 318,377 ---- /** + * TargetAction + */ + protected class TargetAction implements ActionListener { + /** + * ActionPerformed + * @param event ActionEvent + */ + public void actionPerformed(ActionEvent event) { + hoover(); + } + } + + /** + * Hover is called whenever the mouse stands still for + * a specific delay. + */ + protected void hoover() { + if (current == null) { + return; + } + if (start != null) { + if (current.vertex() == start.vertex()) { + return; + } + } + + switch (current.type()) { + case Intersection.VERTEX: + incident = current; + break; + case Intersection.EDGE: + break; + case Intersection.SURFACE: + break; + case Intersection.EDGE_MIDPOINT: + incident = current; + break; + case Intersection.EDGE_INTERSECTION: + incident = current; + break; + case Intersection.SURFACE_INTERSECTION: + incident = current; + break; + case Intersection.PLANE_INTERSECTION: + break; + } + updateConstructors(); + glv.repaint(); + } + + /** * Make target * @param intersection Intersection */ protected void makeTarget(Intersection intersection) { + timer.restart(); if (intersection != null) { Object target = null; *************** *** 305,315 **** case Intersection.VERTEX: target = current; - if (start != null) { - if (intersection.vertex() != start.vertex()) { - incident = intersection; - } - } else { - incident = intersection; - } break; case Intersection.EDGE: --- 380,383 ---- *************** *** 321,331 **** case Intersection.EDGE_MIDPOINT: target = current; - if (start != null) { - if (intersection.vertex() != start.vertex()) { - incident = intersection; - } - } else { - incident = intersection; - } break; case Intersection.EDGE_INTERSECTION: --- 389,392 ---- *************** *** 493,496 **** --- 554,558 ---- number = ""; glv.repaint(); + timer.stop(); } } |
|
From: Nordholt <nor...@us...> - 2006-03-29 18:39:28
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4522 Modified Files: VectorMoveStrategy.java ControlledMoveStrategy.java MoveTool.java Log Message: restructoring and making work by Movetool extending abstractpencil, beware controlled move does not work right now Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** MoveTool.java 27 Mar 2006 14:40:04 -0000 1.49 --- MoveTool.java 29 Mar 2006 18:39:25 -0000 1.50 *************** *** 9,12 **** --- 9,13 ---- import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.model.ClippingPlane; + import net.sourceforge.bprocessor.gl.model.Intersection; import net.sourceforge.bprocessor.model.Edge; *************** *** 16,19 **** --- 17,21 ---- import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; + import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.gl.view.Transformation; *************** *** 28,31 **** --- 30,36 ---- import java.util.Set; import java.util.HashSet; + import java.util.LinkedList; + //import java.util.Timer; + import java.util.TimerTask; *************** *** 35,39 **** * The move tool */ ! public class MoveTool extends AbstractTool { /** The logger */ --- 40,44 ---- * The move tool */ ! public class MoveTool extends AbstractPencil { /** The logger */ *************** *** 60,63 **** --- 65,81 ---- /** The move strategy */ private MoveTool strategy; + + /** The move vector */ + protected Edge moveVector; + + /** The aligning edge */ + protected Edge alignEdge; + + /** Number of clicks when in 3 click mode */ + protected int numberOfClicks; + + /** The plane that the movevector ends + in if nothing else is hit */ + protected Plane currentPlane; /** *************** *** 70,78 **** strategy = null; lastMoveDirection = null; } /** * Update selection - * */ protected void update() { --- 88,99 ---- strategy = null; lastMoveDirection = null; + alignEdge = null; + numberOfClicks = 1; + currentPlane = null; + start = null; } /** * Update selection */ protected void update() { *************** *** 89,93 **** } } ! Project.getInstance().changed(vertices); } --- 110,116 ---- } } ! if (vertices != null) { ! Project.getInstance().changed(vertices); ! } } *************** *** 100,111 **** strategy.pressed(e); } else { ! moveEntities = new HashSet(); ! findTarget(e); ! if (selection.isEmpty()) { ! moveEntities.add(target); } else { ! moveEntities.addAll(selection); } ! } } --- 123,174 ---- strategy.pressed(e); } else { ! if (start == null) { ! moveEntities = new HashSet(); ! Geometric primary = current.object(); ! if (selection.isEmpty() && primary != null) { ! moveEntities.add(primary); ! } else if (!selection.isEmpty()) { ! moveEntities.addAll(selection); ! } ! excluded(getAffected(moveEntities)); ! if (!moveEntities.isEmpty()) { ! start = current; ! } } else { ! start = null; ! moveEntities = null; ! excluded(new HashSet()); } ! } ! /* ! findTarget(e); ! if (numberOfClicks == 1) { ! moveEntities = new HashSet(); ! if (target != null) { ! Vertex moveStart = findInitial(target, e); ! moveVector = new Edge(moveStart, moveStart); ! moveVector.setConstructor(true); ! glv.getView().addTempEdgeOnTop(moveVector); ! initial = moveStart.copy(); ! from = moveStart.copy(); ! numberOfClicks = 2; ! number = ""; ! } ! if (selection.isEmpty() && target != null) { ! moveEntities.add(target); ! } else if (!selection.isEmpty()) { ! moveEntities.addAll(selection); ! } ! } else if (numberOfClicks == 2) { ! glv.getView().removeEntityOnTop(moveVector); ! moveVector = null; ! if (alignEdge != null) { ! glv.getView().removeTempEdge(alignEdge); ! alignEdge = null; ! } ! update(); ! numberOfClicks = 1; ! } ! }*/ } *************** *** 141,146 **** Plane plane = ((ClippingPlane) entity).getPlane(); return plane.intersection(ray); } ! log.warn("The clicked object is not an Entity"); return null; } --- 204,214 ---- Plane plane = ((ClippingPlane) entity).getPlane(); return plane.intersection(ray); + } else if (entity instanceof Plane) { + Plane plane = (Plane)entity; + return plane.intersection(ray); + } else if (entity instanceof Intersection) { + return ((Intersection)entity).vertex(); } ! log.warn("The object is not an Entity"); return null; } *************** *** 168,174 **** strategy.moved(e); } else { ! findTarget(e); ! glv.getView().makeTarget(target); } } --- 236,305 ---- strategy.moved(e); } else { ! Intersection oldCurrent = current; ! current = findIntersection(e); ! if (current != null && ! oldCurrent != null && ! moveEntities != null) { ! move(moveEntities, current.vertex().minus(oldCurrent.vertex())); ! } ! updateConstructors(); } + /* + if (numberOfClicks == 2) { + boolean showAlign = false; + Set moveConstructors = makeXYZConerConstructors(new Vertex(0, 0, 0)); + displayConstructors(moveConstructors); + glv.getView().removeEntityOnTop(moveVector); + if (alignEdge != null) { + glv.getView().addTempEdge(alignEdge); + } + findTarget(e, (Set)moveEntities); + glv.getView().makeTarget(target); + if (target != null) { + if (target instanceof Edge) { + Edge targetEdge = (Edge)target; + if (!targetEdge.equals(alignEdge)) { + Timer alignTimer = new Timer(); + TimerTask alignTask = new AlignTask(targetEdge); + alignTimer.schedule(alignTask, 300); + } + if (alignEdge != null) { + Vertex alignDir = alignEdge.getDirection(); + Vertex targetDir = targetEdge.getDirection(); + Vertex dirCross = alignDir.cross(targetDir); + showAlign = dirCross.length() < 0.000001; + } + } + } + Intersection endPoint = + (Intersection)glv.getView().getObjectAtPoint(e.getX(), e.getY(), + (Set)moveEntities, true, + currentPlane); + Vertex to = endPoint.vertex(); + if (to != null) { + moveVector.setTo(to); + lastMoveDirection = to.minus(initial).copy(); + glv.setLength(lastMoveDirection.length()); + //Do we really want this to move also? + Vertex movement = to.minus(from); + if (vertices != null) { + move(vertices, movement); + } + from = to; + } + + if (moveVector != null) { + glv.getView().addTempEdgeOnTop(moveVector); + } + if (!showAlign) { + glv.getView().removeTempEdge(alignEdge); + } + clearConstructors(moveConstructors); + } else { + findTarget(e); + glv.getView().makeTarget(target); + } + } + */ } *************** *** 310,312 **** --- 441,529 ---- this.strategy = strategy; } + + /** + * + * Update constructors + */ + public void updateConstructors() { + if (start != null && current != null) { + super.updateConstructors(); + Edge edge = new Edge(start.vertex(), current.vertex()); + edge.setConstructor(true); + constructors.add(edge); + excluded.add(edge); + Set constcopy = new HashSet(); + constcopy.addAll(constructors); + constructors(constcopy); + Set excopy = new HashSet(); + excopy.addAll(excluded); + excluded(excopy); + glv.setLength(edge.getLength()); + } else { + constructors(new LinkedList()); + feedback(new LinkedList()); + } + makeTarget(current); + } + + /** + * Gets the set of elements that can be affected by moveing a + * set of elements. + * @param moveElements the elements to move + * @return the affected elements + */ + private Collection getAffected(Collection moveElements) { + HashSet affected = new HashSet(); + HashSet affectedEdges = new HashSet(); + HashSet affectedSurfaces = new HashSet(); + collect(moveElements, affected); + Iterator it = affected.iterator(); + while (it.hasNext()) { + affectedEdges.addAll(((Vertex)it.next()).getEdges()); + affectedSurfaces.addAll(((Vertex)it.next()).getSurfaces()); + } + affected.addAll(affectedEdges); + affected.addAll(affectedSurfaces); + return affected; + } + + + /** + * Class for handeling the task of assigning an alignedge. + */ + protected class AlignTask extends TimerTask { + /** The edge candidate to become the alignedge */ + private Edge candidateEdge; + + /** + * Constructor + * @param candidate the candidate to become alignedge + */ + public AlignTask(Edge candidate) { + super(); + candidateEdge = candidate; + } + + /** + * checks if the target is still the same edge, + * thus making it the alignedge + */ + public void run() { + + if (target instanceof Edge) { + candidateEdge.equals((Edge)target); + + Vertex direction = candidateEdge.getDirection(); + Vertex alignTo = direction.copy(); + Vertex alignFrom = direction.copy(); + alignFrom.scale(-1000); + alignTo.scale(1000); + glv.getView().removeTempEdge(alignEdge); + alignEdge = new Edge(alignFrom.add(initial), alignTo.add(initial)); + alignEdge.setConstructor(true); + glv.getView().addTempEdge(alignEdge); + glv.repaint(true); + } + } + } } Index: VectorMoveStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/VectorMoveStrategy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VectorMoveStrategy.java 27 Mar 2006 14:38:48 -0000 1.1 --- VectorMoveStrategy.java 29 Mar 2006 18:39:25 -0000 1.2 *************** *** 9,19 **** import net.sourceforge.bprocessor.gl.GLView; ! import net.sourceforge.bprocessor.model.Edge; ! import net.sourceforge.bprocessor.model.Vertex; import java.util.HashSet; - import java.util.Set; - import java.util.Timer; - import java.util.TimerTask; import java.awt.event.MouseEvent; --- 9,15 ---- import net.sourceforge.bprocessor.gl.GLView; ! import net.sourceforge.bprocessor.model.Plane; import java.util.HashSet; import java.awt.event.MouseEvent; *************** *** 29,41 **** public class VectorMoveStrategy extends MoveTool { - /** Number of clicks when in 3 click mode */ - private int numberOfClicks; - - /** The Three click constructors edge */ - private Edge threeClickConst; - - /** The aligning edge */ - private Edge alignEdge; - /** The logger */ private static Logger log = Logger.getLogger(VectorMoveStrategy.class); --- 25,28 ---- *************** *** 48,53 **** public VectorMoveStrategy(GLView glv, Cursor cursor) { super(glv, cursor); ! alignEdge = null; ! numberOfClicks = 1; } --- 35,39 ---- public VectorMoveStrategy(GLView glv, Cursor cursor) { super(glv, cursor); ! currentPlane = new Plane(0, 0, 1, 0); } *************** *** 57,82 **** */ protected void pressed(MouseEvent e) { ! if (numberOfClicks == 1) { ! super.pressed(e); vertices = new HashSet(); collect(moveEntities, vertices); - from = findInitial(target, e); - initial = from.copy(); - threeClickConst = new Edge(initial, initial); - threeClickConst.setConstructor(true); - glv.getView().addTempEdge(threeClickConst); - numberOfClicks = 2; - number = ""; - } else if (numberOfClicks == 2) { - Vertex movement = findInitial(target, e).minus(initial); - move(moveEntities, movement); - glv.getView().removeTempEdge(threeClickConst); - threeClickConst = null; - if (alignEdge != null) { - glv.getView().removeTempEdge(alignEdge); - alignEdge = null; - } - update(); - numberOfClicks = 1; } } --- 43,50 ---- */ protected void pressed(MouseEvent e) { ! super.pressed(e); ! if (numberOfClicks == 2) { vertices = new HashSet(); collect(moveEntities, vertices); } } *************** *** 87,180 **** */ protected void moved(MouseEvent e) { ! boolean showAlign = false; ! if (threeClickConst != null) { ! Set moveConstructors = makeXYZConerConstructors(new Vertex(0, 0, 0)); ! displayConstructors(moveConstructors); ! glv.getView().removeTempEdge(threeClickConst); ! if (alignEdge != null) { ! glv.getView().addTempEdge(alignEdge); ! } ! findTarget(e); ! glv.getView().makeTarget(target); ! if (target != null) { ! Vertex to = findInitial(target, e); ! if (target instanceof Edge) { ! Edge targetEdge = (Edge)target; ! if (!targetEdge.equals(alignEdge)) { ! Timer alignTimer = new Timer(); ! TimerTask alignTask = new AlignTask(targetEdge); ! alignTimer.schedule(alignTask, 300); ! } ! if (alignEdge != null) { ! Vertex alignDir = alignEdge.getDirection(); ! Vertex targetDir = targetEdge.getDirection(); ! Vertex dirCross = alignDir.cross(targetDir); ! showAlign = dirCross.length() < 0.000001; ! } ! } ! ! if (to != null) { ! threeClickConst.setTo(to); ! lastMoveDirection = to.minus(initial).copy(); ! glv.setLength(lastMoveDirection.length()); ! //Do we really want this to move also? ! //Vertex movement = to.minus(from); ! //move(moveEntities, movement); ! //from = to; ! } ! } else { ! threeClickConst.setTo(from); ! ! } ! ! if (threeClickConst != null) { ! glv.getView().addTempEdge(threeClickConst); ! } ! if (!showAlign) { ! glv.getView().removeTempEdge(alignEdge); ! } ! clearConstructors(moveConstructors); ! } else { ! findTarget(e); ! glv.getView().makeTarget(target); ! } ! } ! ! /** ! * Class for handeling the task of assigning an alignedge. ! */ ! private class AlignTask extends TimerTask { ! /** The edge candidate to become the alignedge */ ! private Edge candidateEdge; ! ! /** ! * Constructor ! * @param candidate the candidate to become alignedge ! */ ! public AlignTask(Edge candidate) { ! super(); ! candidateEdge = candidate; ! } ! ! /** ! * checks if the target is still the same edge, ! * thus making it the alignedge ! */ ! public void run() { ! if (target instanceof Edge) { ! candidateEdge.equals((Edge)target); ! ! Vertex direction = candidateEdge.getDirection(); ! Vertex alignTo = direction.copy(); ! Vertex alignFrom = direction.copy(); ! alignFrom.scale(-1000); ! alignTo.scale(1000); ! glv.getView().removeTempEdge(alignEdge); ! alignEdge = new Edge(alignFrom.add(initial), alignTo.add(initial)); ! alignEdge.setConstructor(true); ! glv.getView().addTempEdge(alignEdge); ! glv.repaint(true); ! } ! } } --- 55,59 ---- */ protected void moved(MouseEvent e) { ! super.moved(e); } Index: ControlledMoveStrategy.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ControlledMoveStrategy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ControlledMoveStrategy.java 27 Mar 2006 14:38:48 -0000 1.1 --- ControlledMoveStrategy.java 29 Mar 2006 18:39:25 -0000 1.2 *************** *** 49,55 **** private Vertex restrictionVector; - /** The initial movepoint */ - private Vertex initial; - /** * The Constructor --- 49,52 ---- *************** *** 69,78 **** protected void pressed(MouseEvent e) { super.pressed(e); ! if (target != null) { ! initial = findInitial(target, e); ! from = initial.copy(); slideMap = new HashMap(); vertices = new HashSet(); ! if (!moveEntities.isEmpty()) { Iterator it = moveEntities.iterator(); --- 66,73 ---- protected void pressed(MouseEvent e) { super.pressed(e); ! if (numberOfClicks == 2) { slideMap = new HashMap(); vertices = new HashSet(); ! if (!moveEntities.isEmpty()) { Iterator it = moveEntities.iterator(); *************** *** 81,87 **** moveEntities.clear(); moveEntities.add(controlled); ! number = ""; } - collect(moveEntities, vertices); } --- 76,97 ---- moveEntities.clear(); moveEntities.add(controlled); ! collect(moveEntities, vertices); ! } else if (numberOfClicks == 1) { ! slideMap = null; ! controlled = null; ! } ! } ! ! /** ! * Invoked when the mouse cursor has been moved ! * @param e The MouseEvent object ! */ ! protected void moved(MouseEvent e) { ! if (dragPlane == null) { ! findRestrictions(e); ! } ! if (dragPlane != null) { ! super.moved(e); } } *************** *** 91,123 **** */ protected void dragged(MouseEvent e) { ! findRestrictions(e); ! if (dragPlane != null && restrictionVector != null) { ! int x = e.getX(); ! int y = e.getY(); ! Vertex parentPos = glv.getView().toPlaneCoords(new double[] {x, y}, dragPlane); ! if (parentPos != null) { ! Vertex delta = parentPos.minus(from); ! ! //Restricting movement. ! Vertex restrictCopy = restrictionVector.copy(); ! restrictCopy.scale(1 / restrictCopy.length()); ! restrictCopy.scale(delta.dot(restrictCopy)); ! delta = restrictCopy; ! ! if (log.isDebugEnabled()) { ! log.debug("from " + from.getX() + ", " + from.getY() + ", " + from.getZ()); ! log.debug("delta " + delta.getX() + ", " + delta.getY() + ", " + delta.getZ()); ! } ! ! move(vertices, delta); ! ! from.move(delta.getX(), delta.getY(), delta.getZ()); ! glv.setLength(from.minus(initial).length()); ! lastMoveDirection = delta.copy(); ! update(); ! } else { ! log.warn("could not hit the dragplane"); ! } ! } } --- 101,105 ---- */ protected void dragged(MouseEvent e) { ! moved(e); } *************** *** 137,140 **** --- 119,123 ---- glv.getView().makeTarget(target); dragPlane = targetSurface.plane(); + currentPlane = dragPlane; Vertex controlledDir = controlledEdge.getDirection(); Vertex surfaceNormal = targetSurface.normal(); *************** *** 248,251 **** --- 231,235 ---- dragPlane = new Plane(planeNormal.getX(), planeNormal.getY(), planeNormal.getZ(), -planeNormal.dot(initial)); + currentPlane = dragPlane; } *************** *** 257,260 **** --- 241,248 ---- */ protected void move(Collection vertices, Vertex delta) { + Vertex restrictCopy = restrictionVector.copy(); + restrictCopy.scale(1 / restrictCopy.length()); + restrictCopy.scale(delta.dot(restrictCopy)); + delta = restrictCopy; Vertex deltaUnit = delta.copy(); deltaUnit.scale(1 / delta.length()); *************** *** 262,266 **** while (it.hasNext()) { Vertex vertex = (Vertex)it.next(); ! Vertex slideDir = (Vertex)slideMap.get(vertex); double slideScale; if (delta == null) { --- 250,255 ---- while (it.hasNext()) { Vertex vertex = (Vertex)it.next(); ! Vertex slideDir = ((Vertex)slideMap.get(vertex)).copy(); ! slideDir.scale(1 / slideDir.length()); double slideScale; if (delta == null) { |
|
From: Nordholt <nor...@us...> - 2006-03-29 18:37:31
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3359 Modified Files: AbstractPencil.java Log Message: added color to the xyz constructors, added a set of objects to exlude in findintersection Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AbstractPencil.java 29 Mar 2006 14:12:27 -0000 1.16 --- AbstractPencil.java 29 Mar 2006 18:37:24 -0000 1.17 *************** *** 27,30 **** --- 27,32 ---- import net.sourceforge.bprocessor.model.Vertex; + import org.apache.log4j.Logger; + /** * AbstractPencil *************** *** 32,38 **** --- 34,47 ---- */ public abstract class AbstractPencil extends AbstractTool { + + /** The logger */ + private static Logger log = Logger.getLogger(AbstractPencil.class); + /** Feedback elements */ protected Collection elements = new HashSet(); + /** Excluded elements */ + protected Collection excluded = new HashSet(); + /** Constructor elements */ protected Collection constructors = new HashSet(); *************** *** 77,82 **** */ protected Intersection findIntersection(MouseEvent e) { Intersection intersection = (Intersection) glv.getView().getObjectAtPoint(e.getX(), e.getY(), ! elements, true, new Plane(0, 0, 1, 0)); return intersection; } --- 86,94 ---- */ protected Intersection findIntersection(MouseEvent e) { + Collection unwanted = new HashSet(); + unwanted.addAll(elements); + unwanted.addAll(excluded); Intersection intersection = (Intersection) glv.getView().getObjectAtPoint(e.getX(), e.getY(), ! unwanted, true, new Plane(0, 0, 1, 0)); return intersection; } *************** *** 272,276 **** } } ! /** * Make target --- 284,297 ---- } } ! ! /** ! * Supply exluded elements ! * @param feed Collection of edges ! */ ! protected void excluded(Collection feed) { ! excluded.clear(); ! excluded.addAll(feed); ! } ! /** * Make target *************** *** 348,351 **** --- 369,375 ---- e2.setConstructor(true); e3.setConstructor(true); + glv.getView().changeColor(e1, new float[] {0, 1, 0}); + glv.getView().changeColor(e2, new float[] {1, 0, 0}); + glv.getView().changeColor(e3, new float[] {0, 0, 1}); constructors.add(e1); constructors.add(e2); |
|
From: Nordholt <nor...@us...> - 2006-03-29 18:36:04
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2369 Modified Files: View.java Log Message: objects can be given a color, tempobjects can be drawn on top of everything Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** View.java 25 Mar 2006 18:10:04 -0000 1.73 --- View.java 29 Mar 2006 18:35:56 -0000 1.74 *************** *** 22,25 **** --- 22,26 ---- import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; + import net.sourceforge.bprocessor.model.Entity; import java.util.ArrayList; *************** *** 30,33 **** --- 31,36 ---- import java.util.Collection; import java.util.Set; + import java.util.Map; + import java.util.HashMap; import java.awt.event.ActionEvent; *************** *** 278,281 **** --- 281,290 ---- private Set tempVertices; + /** Entities that should be drawn on top of everything else*/ + private Set onTopEntities; + + /** Maps entities to a color */ + private Map colorMap; + static { setTransparency(100); *************** *** 368,371 **** --- 377,382 ---- tempSurfaces = new HashSet(); tempVertices = new HashSet(); + onTopEntities = new HashSet(); + colorMap = new HashMap(); Toolbar tb = Toolbar.getInstance(); *************** *** 824,827 **** --- 835,845 ---- gl.glEnd(); gl.glPointSize(1.0f); + } + + { + Iterator it = onTopEntities.iterator(); + while (it.hasNext()) { + drawObject(it.next()); + } } } *************** *** 829,833 **** /** ! * Draw an object * @param o The Object */ --- 847,851 ---- /** ! * Draw an object with depth test disabled. * @param o The Object */ *************** *** 911,915 **** while (iter.hasNext()) { Edge current = (Edge)iter.next(); ! if (current.getConstructor()) { gl.glColor3fv(constructorColor); drawConstructor(current); --- 929,942 ---- while (iter.hasNext()) { Edge current = (Edge)iter.next(); ! float[] color = (float[])colorMap.get(current); ! if (color != null) { ! gl.glColor3fv(color); ! if (current.getConstructor()) { ! drawConstructor(current); ! } else { ! drawEdge(current); ! } ! gl.glColor3fv(lineColor); ! } else if (current.getConstructor()) { gl.glColor3fv(constructorColor); drawConstructor(current); *************** *** 2346,2349 **** --- 2373,2384 ---- } + /** + * Adds a temporary edge to be drawn on top. + * @param e the edge + */ + public void addTempEdgeOnTop(Edge e) { + onTopEntities.add(e); + } + /** * Removes a temporary edge *************** *** 2363,2366 **** --- 2398,2409 ---- /** + * Adds a temporary vertex to be drawn on top. + * @param v the vertex + */ + public void addTempVertexOnTop(Vertex v) { + onTopEntities.add(v); + } + + /** * Removes a temporary vertex * @param v the vertex to remove *************** *** 2369,2373 **** --- 2412,2440 ---- tempVertices.remove(v); } + + /** + * Removes a temporary Entity that is on top + * @param e the entity to remove + */ + public void removeEntityOnTop(Entity e) { + onTopEntities.remove(e); + } + + /** + * Puts a new color in the color map for an entity + * @param e the entity + * @param color the color + */ + public void changeColor(Entity e, float[] color) { + colorMap.put(e, color); + } + /** + * Clears the color of an entity in the color map + * @param e the entity + */ + public void clearColor(Entity e) { + colorMap.remove(e); + } /** |
|
From: Michael L. <he...@us...> - 2006-03-29 14:12:41
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29198/src/net/sourceforge/bprocessor/gl/tool Modified Files: Pencil.java AbstractPencil.java Log Message: Small things Index: Pencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Pencil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Pencil.java 27 Mar 2006 07:08:26 -0000 1.4 --- Pencil.java 29 Mar 2006 14:12:27 -0000 1.5 *************** *** 42,46 **** edges.add(edge); feedback(edges); - glv.setLength(edge.getLength()); } else { constructors(new LinkedList()); --- 42,45 ---- Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractPencil.java 29 Mar 2006 13:18:29 -0000 1.15 --- AbstractPencil.java 29 Mar 2006 14:12:27 -0000 1.16 *************** *** 251,256 **** constructors(constructors); number = ""; } ! /** * Make target --- 251,276 ---- constructors(constructors); number = ""; + updateLength(); } ! ! /** ! * Update the length field ! */ ! protected void updateLength() { ! Edge edge = null; ! if (current != null) { ! if (start != null) { ! edge = new Edge(start.vertex(), current.vertex()); ! } else if (incident != null) { ! edge = new Edge(incident.vertex(), current.vertex()); ! } ! } ! if (edge != null) { ! glv.setLength(edge.getLength()); ! } else { ! glv.setLength(0); ! } ! } ! /** * Make target |
|
From: Michael L. <he...@us...> - 2006-03-29 13:18:40
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26586/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Log Message: Improvemenents of construction line functionality in pencil Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Edge.java 25 Mar 2006 18:08:32 -0000 1.42 --- Edge.java 29 Mar 2006 13:18:35 -0000 1.43 *************** *** 271,274 **** --- 271,309 ---- /** + * Finds the intersection between a Vertex and this + * edge. The intersection is defined as the vertex + * on this edge with the smalled perpendicular distance + * to the vertex + * @param vertex The vertex + * @return The intersection + */ + public Vertex intersection(Vertex vertex) { + //FIXME the following seems too longwinded + // There has got to be a better way! + if (intersects(vertex)) { + return vertex; + } else { + Edge edge = new Edge(getFrom(), vertex); + CoordinateSystem system = CoordinateSystem.create(this, edge); + if (system != null) { + Vertex a = system.translate(getFrom()); + Vertex b = system.translate(getTo()); + Vertex p = system.translate(vertex); + + Vertex u = b.minus(a); + u.scale(1 / u.length()); + Vertex ap = p.minus(a); + double t = u.dot(ap); + u.scale(t); + Vertex q = a.add(u); + q = system.unTranslate(q); + return q; + } else { + return vertex; + } + } + } + + /** * Split this edge and update all surfaces * accordingly. |
|
From: Michael L. <he...@us...> - 2006-03-29 13:18:40
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26505/src/net/sourceforge/bprocessor/gl/tool Modified Files: Protractor.java ArcTool.java AbstractPencil.java Log Message: Improvemenents of construction line functionality in pencil Index: ArcTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ArcTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ArcTool.java 26 Mar 2006 21:40:32 -0000 1.8 --- ArcTool.java 29 Mar 2006 13:18:29 -0000 1.9 *************** *** 122,126 **** { ! int n = 6; double angle = tetra1; double step = (tetra2 - tetra1) / n; --- 122,126 ---- { ! int n = 12; double angle = tetra1; double step = (tetra2 - tetra1) / n; *************** *** 173,176 **** --- 173,177 ---- if (current != null) { updateFeedback(); + updateConstructors(); } } *************** *** 193,196 **** --- 194,198 ---- } updateFeedback(); + updateConstructors(); } } Index: Protractor.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Protractor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Protractor.java 26 Mar 2006 21:40:32 -0000 1.2 --- Protractor.java 29 Mar 2006 13:18:29 -0000 1.3 *************** *** 80,83 **** --- 80,84 ---- if (current != null) { updateFeedback(); + updateConstructors(); } } *************** *** 103,106 **** --- 104,108 ---- } updateFeedback(); + updateConstructors(); } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AbstractPencil.java 29 Mar 2006 08:23:11 -0000 1.14 --- AbstractPencil.java 29 Mar 2006 13:18:29 -0000 1.15 *************** *** 19,23 **** import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.model.Intersection; - import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometry; --- 19,22 ---- *************** *** 51,55 **** protected String number; - /** * Constructor --- 50,53 ---- *************** *** 241,285 **** /** ! * Update constructors based on origin. */ protected void updateConstructors() { ! if (start == null) { ! if (incident != null) { ! constructors(xyz(incident.vertex())); ! } else { ! constructors(new LinkedList()); ! } ! } else { ! List constructors = new LinkedList(); ! ! if (incident != null && current != null) { ! Edge e1 = new Edge(incident.vertex(), current.vertex()); ! Edge e2 = new Edge(current.vertex(), start.vertex()); ! CoordinateSystem system = CoordinateSystem.create(e1, e2); ! if (system != null) { ! ! Vertex a = system.translate(start.vertex()); ! Vertex b = system.translate(current.vertex()); ! Vertex p = system.translate(incident.vertex()); ! ! Vertex u = b.minus(a); ! u.scale(1 / u.length()); ! Vertex ap = p.minus(a); ! double t = u.dot(ap); ! u.scale(t); ! Vertex q = a.add(u); ! q = system.unTranslate(q); ! Edge edge = new Edge(incident.vertex(), q); ! edge.setConstructor(true); ! constructors.add(edge); ! constructors(constructors); ! } ! constructors.addAll(xyz(incident.vertex())); ! } ! constructors.addAll(xyz(start.vertex())); - constructors(constructors); - number = ""; } } --- 239,254 ---- /** ! * Update constructors based on start, current and incident. */ protected void updateConstructors() { ! List constructors = new LinkedList(); ! if (start != null) { constructors.addAll(xyz(start.vertex())); } + if (incident != null) { + constructors.addAll(xyz(incident.vertex())); + } + constructors(constructors); + number = ""; } |
|
From: Michael L. <he...@us...> - 2006-03-29 08:23:14
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5278/src/net/sourceforge/bprocessor/gl/tool Modified Files: RectTool.java AbstractPencil.java Log Message: Improvements in snapping of pencil and rect Index: RectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RectTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RectTool.java 26 Mar 2006 21:40:32 -0000 1.4 --- RectTool.java 29 Mar 2006 08:23:11 -0000 1.5 *************** *** 100,103 **** --- 100,104 ---- if (current != null) { updateFeedback(); + updateConstructors(); } } *************** *** 115,118 **** --- 116,120 ---- } updateFeedback(); + updateConstructors(); } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AbstractPencil.java 27 Mar 2006 15:03:25 -0000 1.13 --- AbstractPencil.java 29 Mar 2006 08:23:11 -0000 1.14 *************** *** 374,378 **** number = ""; } ! if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { cleanUp(); } else if (e.getKeyCode() == KeyEvent.VK_1) { --- 374,398 ---- number = ""; } ! if (e.getKeyCode() == KeyEvent.VK_SPACE) { ! Collection deletion = new LinkedList(); ! { ! Collection edges = Project.getInstance().getEdges(); ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! if (current.getConstructor()) { ! deletion.add(current); ! } ! } ! } ! { ! Iterator iter = deletion.iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! Project.getInstance().remove(current); ! } ! } ! glv.repaint(); ! } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { cleanUp(); } else if (e.getKeyCode() == KeyEvent.VK_1) { |
|
From: Michael L. <he...@us...> - 2006-03-29 08:14:31
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31594/src/net/sourceforge/bprocessor/gl/tool Modified Files: MultiExtrudeTool.java Log Message: Ignores the objects being extruded when finding target to align to Index: MultiExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MultiExtrudeTool.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MultiExtrudeTool.java 21 Mar 2006 12:24:49 -0000 1.11 --- MultiExtrudeTool.java 29 Mar 2006 08:14:28 -0000 1.12 *************** *** 160,164 **** // The extrusion were succesfull move it // Find the move direction ! findTarget(e); if (target != null && target instanceof Surface) { //If there are a target that is a surface drag to that surface --- 160,164 ---- // The extrusion were succesfull move it // Find the move direction ! findTarget(e, elements); if (target != null && target instanceof Surface) { //If there are a target that is a surface drag to that surface |
|
From: Michael L. <he...@us...> - 2006-03-29 08:12:10
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29280/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java Log Message: Method to find target with an ignored set of objects Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** AbstractTool.java 23 Mar 2006 11:49:50 -0000 1.65 --- AbstractTool.java 29 Mar 2006 08:11:58 -0000 1.66 *************** *** 604,607 **** --- 604,619 ---- /** + * Find target + * @param event MouseEvent + * @param ignore Elements to ignore + */ + protected void findTarget(MouseEvent event, Collection ignore) { + int x = event.getX(); + int y = event.getY(); + View view = glv.getView(); + target = view.getObjectAtPoint(x, y, ignore, false, new Plane(0, 0, 1, 0)); + } + + /** * Lets the tool clean up after itself before changing tool. */ |
|
From: Michael L. <he...@us...> - 2006-03-29 07:23:13
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28254/src/net/sourceforge/bprocessor/model Modified Files: LayerModellor.java Log Message: Space is cleared before new geometry is added Index: LayerModellor.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/LayerModellor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LayerModellor.java 25 Mar 2006 18:08:32 -0000 1.7 --- LayerModellor.java 29 Mar 2006 07:23:07 -0000 1.8 *************** *** 45,49 **** */ public void update(Object entity) { ! Surface bottom = surface.copy(space); if (surface.getBackDomain() == space) { --- 45,49 ---- */ public void update(Object entity) { ! space.clear(); Surface bottom = surface.copy(space); if (surface.getBackDomain() == space) { |