<div><div dir="auto">Good exports require good inputs and good loading.  I have been exporting in XML as I mentioned I would do.   Those results look good.  If JSON imports = JSON exports, I thing we will be good, so I have not been trying to provide outputs.   JSON imports have been provided in zips.   I will try to provide web accessible code soon.</div><div dir="auto"><br></div><div dir="auto">John</div><div dir="auto"><br></div><div dir="auto">If it’s okay with you, I will use eval on prototype, and we can do something else for code generation/stylesheets.</div><div dir="auto"><br></div><div dir="auto">Suggest a way to map class names to classes, possibly provided by x3d.py, and we can proceed to eliminate eval.</div><div dir="auto"><br></div><div dir="auto">Thanks!</div></div><div><div dir="auto"><br></div><div dir="auto">John</div><div dir="auto"><br></div><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 8, 2021 at 9:54 AM Brutzman, Donald (Don) (CIV) <<a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">





<div lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div>
<p class="MsoNormal">Thanks for this John, will be able to look at it next week.  As discussed Monday, it is important to get export correct first before integrating import – that way round-trip testing is possible.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hopefully you have a standalone example import, with inputs and outputs included, so that I might confirm consistent operation when first testing.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Am not employing or permitting use of eval() in x3d.py due to security considerations.  Just confirmed by inspecting source that it is not present.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Patience pays.  Anything we want to do only requires a few SMOPs to sort out and get correct, hopefully for a long long time.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<ul style="margin-top:0in" type="disc">
<li style="margin-left:0in"><a href="https://en.wikipedia.org/wiki/Small_matter_of_programming" target="_blank">https://en.wikipedia.org/wiki/Small_matter_of_programming</a><u></u><u></u></li></ul>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New""><u style="font-family:"Courier New""></u> <u style="font-family:"Courier New""></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">all the best, Don<u style="font-family:"Courier New""></u><u style="font-family:"Courier New""></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">-- <u style="font-family:"Courier New""></u>
<u style="font-family:"Courier New""></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">Don Brutzman  Naval Postgraduate School, Code USW/Br        <a href="mailto:brutzman@nps.edu" style="font-family:"Courier New"" target="_blank">brutzman@nps.edu</a><u style="font-family:"Courier New""></u><u style="font-family:"Courier New""></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA    +1.831.656.2149<u style="font-family:"Courier New""></u><u style="font-family:"Courier New""></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">X3D graphics, virtual worlds, navy robotics https://</span>
<span style="font-size:10pt;font-family:"Courier New""><a href="http://faculty.nps.edu/brutzman" style="font-family:"Courier New"" target="_blank">faculty.nps.edu/brutzman</a><u style="font-family:"Courier New""></u><u style="font-family:"Courier New""></u></span></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border-style:solid none none;border-top-width:1pt;padding:3pt 0in 0in;border-top-color:rgb(225,225,225)">
<p class="MsoNormal"><b>From:</b> John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> <br>
<b>Sent:</b> Tuesday, December 7, 2021 8:19 AM<br>
<b>To:</b> Brutzman, Donald (Don) (CIV) <<a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a>>; X3D Graphics public mailing list <<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a>><br>
<b>Subject:</b> Re: Question: Geometry class for x3d.py?<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border:1pt solid rgb(0,70,121);padding:2pt">
<p class="MsoNormal" style="line-height:12pt;background-color:rgb(0,70,121)"><span style="font-size:10pt;color:yellow">NPS WARNING: *external sender* verify before acting.<u></u><u></u></span></p>
</div></div></div><div lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word"><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p>Updated x3dinput.py attached.<u></u><u></u></p>
<p>Proceeded with eval, removed JSON_Geometry class.<u></u><u></u></p>
<p>There is no need for a x3d.py Geometry class that I know of, except for below.<u></u><u></u></p>
<p>Regexp still needed for security purposes (no constructing arbitrary, possibly hidden classes, please).<u></u><u></u></p>
<p>Looks good, not sure of performance at this time, we could provide factory, dispatch table, switch, or if/elif/else for constructing geometry.   Eval seems the least secure.  Perhaps we could run some benchmarks?<u></u><u></u></p>
<p>"DOM" API for creating scenegraph "elements" seems like a good solution.<u></u><u></u></p>
<p>Please provide direction for desired implementation.  If we continue with eval, perhaps we could apply it in more places?<u></u><u></u></p>
<p>Enjoy JSON parsing HelloWorld.json!<u></u><u></u></p>
<p>John<u></u><u></u></p>
<div>
<p class="MsoNormal">On 12/7/21 09:58, John Carlson wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<p><span style="font-family:"Courier New";background-color:white;color:black">Don, you may want to create a Geometry class in x3d.py like:</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">class </span>
<b><span style="font-family:"Courier New"">Geometry</span></b><span style="font-family:"Courier New";background-color:white;color:black">(</span><span style="font-family:"Courier New";background-color:rgb(255,255,84);color:black">_X3D</span><span style="font-family:"Courier New";background-color:white;color:black">GeometryNode):
</span><span style="font-family:"Courier New""><br>
   <span style="font-family:"Courier New";background-color:white;color:black">def </span><b style="font-family:"Courier New"">FIELD_DECLARATIONS</b><span style="font-family:"Courier New";background-color:white;color:black">(cls):
</span><br>
       <span style="font-family:"Courier New";background-color:white;color:black">return [] </span><br>
   <span style="font-family:"Courier New";background-color:white;color:black">def </span><b style="font-family:"Courier New"">JSON</b>(self): <br>
       <span style="font-family:"Courier New";background-color:white;color:black">return self.geometry.JSON(); </span>
<br>
   <span style="font-family:"Courier New";background-color:white;color:black">def </span><b style="font-family:"Courier New"">XML</b>(self): <br>
       <span style="font-family:"Courier New";background-color:white;color:black">return self.geometry.XML();</span></span><u></u><u></u></p>
<p><u></u> <u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">Also, we would have to provide parsers to fill in self.geometry.</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">Or test for self.geometry in the JSON and XML methods, or add a constructor.</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">This is mainly for loading the -geometry field.</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">It could be handled in the Shape class, with eval() figuring out which geometry constructor to call.  That is okay with me!</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">Obviously, eval is a tiny bit dangerous, even if only resolving a class.  I recommend creating a regexp that matches all node and statement names.</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">I'm going to proceed with eval in the Shape class for now.</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">Thanks!</span><u></u><u></u></p>
<p><span style="font-family:"Courier New";background-color:white;color:black">John</span><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>

</blockquote></div></div>
</div>