[x3d-public] Simple example of X3DConcreteNode/addChild problem

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Thu May 16 03:38:03 PDT 2019


Hi John.  Thanks for continued sleuthing.

1. Chasing addChild() is probably not a good path forward however.

The addChild() method cannot be added to X3DConcreteNode because then any X3D node would be able to add a child node.  That obviously breaks the parent-child hierarchy restrictions of XxD scene graph.

As an example: all nodes can add a single MetadataFloat child, and (as you note) IS node (for IS/connect links within a ProtoBody).  However nodes like Material cannot add any other child nodes, since those are not part of the allowed X3D scene graph.

This strictness is part of the fundamental value of X3D structural validity.  It is similarly enforced by validation techniques such as XML Schema, JSON schema, XML DTD, XML Schematron, and X3DUOM.

I suspect that the error you are seeing from

	Transform(Transform().setIS(IS())).addChild(Shape())

matching (commented) legal subgraph

   <Transform>
     <Transform>
       <IS><!-- needs a connect statement--></IS>
       <Shape/>
     </Transform>
   </Transform>

is actually quite similar in nature to the other flawed (misdirecting) pyjnius errors we've been seeing with ViewpointObject, most recently re-diagnosed as a setDEF() problem.

Any time pyjnius says that it has a problem with X3DConcreteNode there is a problem in the matching of the .py python source to underlying X3DJSAIL classes.

Give me a chance to go further on the setDEF() problem.  Once that is resolvable, it will be similarly applied to USE and IS since all three are part of X3DConcreteNode.

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/X3DConcreteNode.html
"Abstract parent class for concrete X3D nodes, containing common methods and member variables."

Am currently looking at two potential paths for solution:

a. possibly omit DEF, USE from org.web3d.x3d.sai.Navigation.Viewpoint interface (still questionable)
b. get pyjnius to return class current object when returning from methods, rather than a superclass or interface (root cause of problem)

Summary: don't worry about "addChild()" since the root problem is elsewhere.

2. @Override annotation will never "work" because it has no action.  It is a Java compiler-related note that helps warnings ensure that programmer Object-oriented design intentions are met.

3. Great to hear that you are making some strides with Jupyter.  Recommend using an even-simpler example that current works, perhaps HelloTriangle.

http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloTriangleIndex.html
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloTriangle.x3d
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloTriangle.java
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloTriangle.py

p.s. looks like some of the online .py files didn't get updated, will recheck the build process.  Example attached.

On 5/14/2019 9:33 AM, John Carlson wrote:
> Example of error generated below.  (minimal amount of code) Jupyter export attached.  I hope you can address the issue sometime with X3DJSAIL.  My best guess is that pyjnius is going through getSuperclass() and finding the abstract classes’ method setIS().  We can try deleting getSuperclass call in pyjnius if you think it’s appropriate.
> 
> My suggestion is to delete setIS from X3DConcreteNode.java or implement addChild in X3DConcreteNode.java, which may just cascade the error.  I think deleting setIS might be preferable, but test both cases.   Consider a wrapping, like:
> 
> Transform(Transform().setIS(IS())).addChild(Shape())  # hasn’t been tested, but ew.
> 
> A jnius.cast would work similarly.  We can go with a cast if you like.  Please look into a cast to see what you prefer.  Also, try converting to Java.
> 
> Now do you see where the abstract class is coming from?  Do you agree on what’s introducing the abstract class (not me)?
> 
> Good news is, I and Michael figured out how to run the code in Jupyter Lab (anaconda).  There are instructions online that work with the conda.bat command install jnius (see conda install on pyjnius website)  WooHoo! Highly recommended, but a bit stilted to start with.
> 
> Code is back to you! Looking for changes to X3DConcreteNode.java.  I can make changes to the serializer if we decide wrapping or casting is appropriate.  I just think we’ll be wrapping the wrapping the wrapping.  It seems better to me to add or delete abstract methods.
> 
> No, I don’t know why @Override didn’t work.
> 
> # This code shows the error
> 
> import jnius_config
> 
> jnius_config.set_classpath('.', 'c:/x3d-code/www.web3d.org/x3d/stylesheets/java/jars/X3DJSAIL.3.3.full.jar')
> 
> from jnius import autoclass
> 
> Shape = autoclass('org.web3d.x3d.jsail.Shape.ShapeObject')
> 
> Transform = autoclass('org.web3d.x3d.jsail.Grouping.TransformObject')
> 
> IS = autoclass('org.web3d.x3d.jsail.Core.ISObject')
> 
> Transform().setIS(IS()).addChild(Shape())
> 
> *-------------------------------------------------------------------------*
> 
> *AttributeError*                            Traceback (most recent call last)
> 
> *<ipython-input-1-62dabff95a4e>*in <module>
> 
>        8
> 
>        9
> 
> *---> 10***Transform*().*setIS*(*IS*()).*addChild*(*Shape*())*
> 
> *AttributeError*: 'org.web3d.x3d.jsail.X3DConcreteNode' object has no attribute 'addChild'


all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: HelloTriangle.future.py
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190516/ae9c1167/attachment.ksh>


More information about the x3d-public mailing list