Re: Delaunay and Java3D




>     BranchGroup branch = renderer.getBranch();
>     // now the Shape3D you want is the child or
>     // grandchild or greatgrandchild of branch
>     // (I'm not sure which offhand)
>     //
>     // you can't re-use that Shape3D unless you
>     // invoke branch.detach() to take it out of
>     // the live Java3D scenegraph


Hi, thanks for your help, I found a Shap3D there, but I have problems
detaching it:

public void displayChanged(DisplayEvent e) {
        if (e.getId() == DisplayEvent.TRANSFORM_DONE) {
            System.out.println("displaychanged");
            BranchGroup branchGroup = renderer.getBranch();
            branchGroup.detach();
            Enumeration enum = branchGroup.getAllChildren();
            System.out.println(branchGroup);
            while(enum.hasMoreElements()) {
                Object o;
                o = enum.nextElement();
                if (o instanceof BranchGroup) {
                    System.out.println((BranchGroup) o);
                }
                if (o instanceof Shape3D) {
                    System.out.println((Shape3D) o);
                    Shape3D shape3d = (Shape3D) o;

                    // GIS3DView machen und fuellen
                    GIS3DView gis3dView = new GIS3DView(true);
                    Layer3D layer3d = new Layer3D();
                    layer3d.addShape(shape3d);
                    gis3dView.addLayer(layer3d);

                    GisTermService s = GisTerm.lookupService("GisTerm");
                    JTabbedPane p = gisTerm.getTabbedPane();
                    p.add("VisAD",gis3dView);
                    p.setSelectedComponent(gis3dView);
                    
                }
            }
        }

I get the following exception:

displaychanged
javax.media.j3d.BranchGroup@5f4bfc
javax.media.j3d.Shape3D@75b4d1
javax.media.j3d.MultipleParentException: Group.addChild: child already has
a par
ent
        at
javax.media.j3d.GroupRetained.checkValidChild(GroupRetained.java:374)

        at javax.media.j3d.GroupRetained.addChild(GroupRetained.java:383)
        at javax.media.j3d.Group.addChild(Group.java:261)
        at gis.services.gis3D.Layer3D.addShape(Layer3D.java:140)
        at
app.gwvis.TerrainListener.displayChanged(TerrainListener.java:51)
        at visad.DisplayImpl.notifyListeners(DisplayImpl.java:430)
        at visad.DisplayImpl.notifyListeners(DisplayImpl.java:413)
        at visad.DisplayImpl.doAction(DisplayImpl.java:1025)
        at visad.ActionImpl.run(ActionImpl.java:198)
        at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:86)
...

Thanks for your help again

Desiree