[x3d-public] How should CAD -shape containerField be expressed in X3DJSAIL
Joe D Williams
joedwil at earthlink.net
Thu Feb 23 16:54:26 PST 2017
Is this a common containerfield issue when the parent node allows
special children but does not include add/removechildren?
In this, cadface will always allow a childnode with containerfield
named shape of some certain construction. In the cadface this could be
a Shape, a transform with a single child Shape, or an LOD hierarchy.
In the most simple case it is a Shape node that has a container that
also happens to be named shape, instead of its default container named
children. So it seems simple - any structure allowed in cadface must
fit in this shape container - even a single shape node.
For transcoding it should not matter except when info is missing from
the user code and sometime somebody might need to know what legal
containers are allowed in cadface and what are legal contents of
cadface shape container. But otherwise, whatever it is, its content is
defined by the containerfield named shape that is only found in
cadface.
HAnimHumanoid is like that. No children containers allowed, except
certain children having a certain container name, like skeleton and
skin, for instance.
This makes the HAnimJoint not legal outside a skeleton container,
because the only allowed HAnimJoint containerfield is skeleton which
only appears in Humanoid.
cadface includes a single containerfield named shape for a possibly
fairly complex structure that includes documentation for an active
Shape node. Shape always gotta have containerfield named children,
except when it is the only node in cadface shape container. In that
case its containerfield must be shape.
As usual, more interesting because now we have this shape container
available but it must be carefully restricted to cadface _only_ or
else we should be very concerned.
If this shape container ever escapes from cadface and gets adopted as
a root then experts have debated and giant problems have been
predicted.
All Best,
Joe
----- Original Message -----
From: <yottzumm at gmail.com>
To: "Roy Walmsley" <roy.walmsley at ntlworld.com>
Cc: "'X3D Graphics public mailing list'" <x3d-public at web3d.org>
Sent: Thursday, February 23, 2017 3:52 AM
Subject: Re: [x3d-public] How should CAD -shape containerField be
expressed in X3DJSAIL
I don’t know if the Java is correct or not. That’s why I provided the
Java (let’s try to keep on subject – Sorry the subject should say
something about CADFace, I’m trying to figure out what to put in
Java!). And it’s getting worse, because I’m groping with
containerFields with the with the new JavaSerializer as well. I may
have to revert to the old JavaSerializer to get containerFields right.
It’s a mess at this point it looks like. Too much late night coding. I
will revert to the old Serializer for now. But the Java code I’ve been
posting is from the old serializer. I was just about to post the new
serializer code results, but from some code inspection it’s not worth
it yet.
I am currently using CADFaceObject.setShape() in old serializer. It
looks like I use it with either Transform or Shape as parameters. I do
not know if this is the correct way of introducing a containerField in
the intermediate XML or not. How do I force a containerField into the
intermediate XML? I already assumed the X3dToJson.xslt was correct,
but it doesn’t hurt to run it again. The JSON file might be very old—2
days old, LOL.
I also have a XML Serializer that runs after X3DJSONLD.js. It has the
containerField in it. I do not think I would have a setShape
The setShape comes from the Object Model and is transferred to my
mapToMethod.js object. There may be a bug here as well:
"CADFace" : {
"X3DMetadataObject" : "setMetadata",
"MetadataDouble" : "setMetadata",
"MetadataInteger" : "setMetadata",
"MetadataSet" : "setMetadata",
"MetadataString" : "setMetadata",
"MetadataFloat" : "setMetadata",
"MetadataBoolean" : "setMetadata",
"Shape" : "setShape",
"LOD" : "setShape",
"Transform" : "setShape",
},
This in turn comes from my bs4 parser, parseom.py
def listChildren(self, fieldName, fieldType):
str = ""
if fieldName == "addChildren" or fieldName ==
"removeChildren":
return str
if fieldType == "SFNode":
str += '\t"' + self.node["name"] + '" : "set' +
fieldName[:1].upper() + fieldName[1:] + '",\n';
else:
str += '\t"' + self.node["name"] + '" : "add' +
fieldName[:1].upper() + fieldName[1:] + '",\n';
for child in self.children:
str += classes[child].listChildren(fieldName,
fieldType)
return str;
def print(self):
str = ""
if self.printed:
return str
for parent in self.parents:
try:
str += classes[parent].print()
except:
pass
str += '"'+self.node['name']+'" : {\n'
fields = self.node.find_all("field")
for field in fields:
if field["type"] == "MFNode" or field["type"] == "SFNode":
acnts = field["acceptableNodeTypes"].split("|")
for acnt in acnts:
str += classes[acnt].listChildren(field["name"],
field["type"])
str += '},\n'
self.printed = True
return str
Another place the containerField could come from is the JSON itself,
the JavaSerializer contains the line:
if (attr === 'containerField') {
let method =
attrs[a].nodeValue;
method =
"set"+method.charAt(0).toUpperCase() + method.slice(1);
str += "
"+grandparent.nodeName+gn+"."+method+"(";
str += element.nodeName+n;
I doubt if this is correct, but what else to do???
So naturally, I hope that the setShape method knows how to set the
containerField. I hope!
Hey if I can’t program in 5 languages every day, would it be fun?
But MY CODE ASIDE, how the heck do I force a containerField -shape
into the XML and subsequent JSON using X3DJSAIL?
John
Sent from Mail for Windows 10
From: Roy Walmsley
Sent: Thursday, February 23, 2017 5:32 AM
To: yottzumm at gmail.com
Cc: 'X3D Graphics public mailing list'; 'Don Brutzman'
Subject: RE: How should CAD -shape containerField be expressed in
X3DJSAIL
John,
Thanks for the processing summary.
The JSON file you attached to your previous message was incorrect. So,
I take it that this file corresponds to the “Incorrect JSON” listed at
the end of the third line below. In contrast, the JSON at the end of
the first line is correct. This implies that the X3dToJson stylesheet
transform works correctly.
So, the processing is going wrong somewhere on the second and third
lines you listed. What can you tell from your intermediate results?
For example, is the Java correct that you listed at the end of the
second line?
All the best,
Roy
From: yottzumm at gmail.com [mailto:yottzumm at gmail.com]
Sent: 23 February 2017 04:17
To: Roy Walmsley <roy.walmsley at ntlworld.com>; 'X3D Graphics public
mailing list' <x3d-public at web3d.org>; Don Brutzman <brutzman at nps.edu>
Subject: RE: How should CAD -shape containerField be expressed in
X3DJSAIL
Here’s the workflow:
X3D XML -> X3dToJson.xslt (perhaps via RunSaxon.java) -> Correct JSON
Correct JSON -> runjson.sh -> json2all.js -> convertJSON.js ->
X3DJSON.js (produces XML DOM) -> JavaSerializer.js -> Java
Java -> javac -> java -> X3DJSAIL (outputs XML to intermediate file
calls X3dToJson.xslt—my understanding) -> Incorrect JSON
diff Correct JSON with Incorrect JSON to see differences with
containerField.
Incorrect JSON -> Ajv + JSON Schema -> Errors.
I’ll leave it to Don to describe how X3DJSAIL is produced from XML
Schema and the Object Model.
Don has this envisioned:
X3D XML -> X3DJSAIL (Java Objects using reflection) -> Many by style
sheet.
I am producing intermediate results which may be inspected, like Java
code, for testing purposes. My primary purpose with Java is to
produced JSON code from JSON input for roundtrip testing. And possible
to get a declarative Java encoding with modern Java 8 efficiencies
(more on that later). And we are starting to be more successful with
knocking out bugs again (see CompileJava.zip please)!
Actually Java source code is probably not the way to go because it
doesn’t allow that many constants (numbers I think). There will be
some limitations we may have to program around, or ask Oracle to
extend. Really, VRML, XML and JSON are preferred in this case of
encoding over the current state of Java—but reflection may work too.
John
Sent from Mail for Windows 10
From: Roy Walmsley
Sent: Wednesday, February 22, 2017 7:08 PM
To: yottzumm at gmail.com; 'X3D Graphics public mailing list'
Subject: RE: How should CAD -shape containerField be expressed in
X3DJSAIL
Thanks John.
You are right, I don’t have a 3.1 schema for JSON.
I manually inspected the examples. They seem fine to me, and the JSON
validates against the V3.3 JSON schema. This can only mean that I don’t
understand your problem. To my eyes, all the examples and schemas are
fine. So to clarify, please give me a step-by-step account of what you
are doing. What are you starting from? What tools to you use to do
what with it? Etc..
Sorry not to be more instantly helpful,
Roy
From: yottzumm at gmail.com [mailto:yottzumm at gmail.com]
Sent: 22 February 2017 23:12
To: Roy Walmsley <roy.walmsley at ntlworld.com>; X3D Graphics public
mailing list <x3d-public at web3d.org>
Subject: FW: How should CAD -shape containerField be expressed in
X3DJSAIL
Here are the examples I am referring to. The ones with the shape
container that supposedly are supposed to validate properly. However,
there is some comments in the meta stuff that you may want to check:.
I hope I am not chasing a red herring again. I don’t see how you could
validate it against the JSON schema, unless you have a 3.1 schema.
(can I have a copy?)
www.web3d.org/x3d/content/examples/Basic/CAD/{attachments}
John
Sent from Mail for Windows 10
From: yottzumm at gmail.com
Sent: Tuesday, February 21, 2017 1:38 AM
To: Don Brutzman; Roy Walmsley; X3D Graphics public mailing list
Subject: How should CAD -shape containerField be expressed in X3DJSAIL
Attached input JSON and converted Java. The Java does not
produce -shape in the output JSON.json file [ not provided—compile and
run the Java ]. Is this OK? I am currently using setShape in the Java.
Why doesn’t the JSON.json have the containerField? Thanks!
John
--------------------------------------------------------------------------------
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
More information about the x3d-public
mailing list