miho / JCSG

Java implementation of BSP based CSG (Constructive Solid Geometry)
Other
178 stars 54 forks source link

InvocationTargetException when performing boolean operations on complex shapes with JCSG #14

Closed JoachimAmoah closed 9 years ago

JoachimAmoah commented 9 years ago

When I load a .stl and convert to CSG (of the JCSG library) through this method, any boolean operation I perform fails. However simple models native to the JCSG library works fine.

So I get my CSG in a HashMap with the Node (JavaFX node of the CAD model) as a key and then perform the boolean operation union for example like this:

HashMap<Node, CSG> objCSGMap = contentModel.getObjectCSGMap(); Node obj1 = contentModel.getObjGroup().getChildren().get(0); Node obj2 = contentModel.getObjGroup().getChildren().get(1); CSG csg1 = objCSGMap.get(obj1); CSG csg2 = objCSGMap.get(obj2); CSG result = csg1.union(csg2); contentModel.set3dContent(result.toJavaFXMeshSimple().getAsMeshViews().get(0), null);

This is the error message:

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source) at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at javafx.event.Event.fireEvent(Unknown Source) at javafx.scene.Node.fireEvent(Unknown Source) at javafx.scene.control.Button.fire(Unknown Source) at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source) at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at javafx.event.Event.fireEvent(Unknown Source) at javafx.scene.Scene$MouseHandler.process(Unknown Source) at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source) at javafx.scene.Scene.impl_processMouseEvent(Unknown Source) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(Unknown Source) at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$383/1876978274.get(Unknown Source) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source) at com.sun.glass.ui.View.handleMouseEvent(Unknown Source) at com.sun.glass.ui.View.notifyMouse(Unknown Source) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source) at com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.reflect.misc.Trampoline.invoke(Unknown Source) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.reflect.misc.MethodUtil.invoke(Unknown Source) ... 55 more Caused by: java.lang.StackOverflowError at eu.mihosoft.vrl.v3d.Node.lambda$build$30(Node.java:244) at eu.mihosoft.vrl.v3d.Node$$Lambda$429/1450630044.accept(Unknown Source) at java.util.ArrayList.forEach(Unknown Source) at eu.mihosoft.vrl.v3d.Node.build(Node.java:243) at eu.mihosoft.vrl.v3d.Node.build(Node.java:258) at eu.mihosoft.vrl.v3d.Node.build(Node.java:258) at eu.mihosoft.vrl.v3d.Node.build(Node.java:258)

However, this works fine:

CSG csg1 = new Cube(10, 70, 4).toCSG(); CSG csg2 = new Cube(40).toCSG(); CSG result = csg1.union(csg2); contentModel.set3dContent(result.toJavaFXMeshSimple().getAsMeshViews().get(0), null);

So it looks like boolean operations work fine for simple CSG objects from the JCSG library itself and not imported CAD files that have been converted to CSG objects through this method.

miho commented 9 years ago

Why don't you import the CAD model directly with JCSG via STL.file()? The Caused by: java.lang.StackOverflowError error is not necessarily an error of the JCSG library. Please make sure that the stack of your JVM is big enough (e.g. -Xss515m). If this does not solve your problem you should post the model that you are trying to import.

miho commented 9 years ago

No activity.