<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:2007509928;
        mso-list-type:hybrid;
        mso-list-template-ids:-784855176 514653908 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:5;
        mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<ul style="margin-top:0in" type="disc">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l0 level1 lfo1">https://en.wikipedia.org/wiki/Small_matter_of_programming<o:p></o:p></li></ul>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">all the best, Don<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">-- <o:p>
</o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Don Brutzman  Naval Postgraduate School, Code USW/Br        brutzman@nps.edu<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA    +1.831.656.2149<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">X3D graphics, virtual worlds, navy robotics https://</span>
<span style="font-size:10.0pt;font-family:"Courier New"">faculty.nps.edu/brutzman<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> John Carlson <yottzumm@gmail.com> <br>
<b>Sent:</b> Tuesday, December 7, 2021 8:19 AM<br>
<b>To:</b> Brutzman, Donald (Don) (CIV) <brutzman@nps.edu>; X3D Graphics public mailing list <x3d-public@web3d.org><br>
<b>Subject:</b> Re: Question: Geometry class for x3d.py?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:solid #004679 1.0pt;padding:2.0pt 2.0pt 2.0pt 2.0pt">
<p class="MsoNormal" style="line-height:12.0pt;background:#004679"><span style="font-size:10.0pt;color:yellow">NPS WARNING: *external sender* verify before acting.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p>Updated x3dinput.py attached.<o:p></o:p></p>
<p>Proceeded with eval, removed JSON_Geometry class.<o:p></o:p></p>
<p>There is no need for a x3d.py Geometry class that I know of, except for below.<o:p></o:p></p>
<p>Regexp still needed for security purposes (no constructing arbitrary, possibly hidden classes, please).<o:p></o:p></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?<o:p></o:p></p>
<p>"DOM" API for creating scenegraph "elements" seems like a good solution.<o:p></o:p></p>
<p>Please provide direction for desired implementation.  If we continue with eval, perhaps we could apply it in more places?<o:p></o:p></p>
<p>Enjoy JSON parsing HelloWorld.json!<o:p></o:p></p>
<p>John<o:p></o:p></p>
<div>
<p class="MsoNormal">On 12/7/21 09:58, John Carlson wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p><span style="font-family:"Courier New";color:black;background:white">Don, you may want to create a Geometry class in x3d.py like:</span><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">class </span>
<b><span style="font-family:"Courier New"">Geometry</span></b><span style="font-family:"Courier New";color:black;background:white">(</span><span style="font-family:"Courier New";color:black;background:#FFFF54">_X3D</span><span style="font-family:"Courier New";color:black;background:white">GeometryNode):
</span><span style="font-family:"Courier New""><br>
   <span style="color:black;background:white">def </span><b>FIELD_DECLARATIONS</b><span style="color:black;background:white">(cls):
</span><br>
       <span style="color:black;background:white">return [] </span><br>
   <span style="color:black;background:white">def </span><b>JSON</b>(self): <br>
       <span style="color:black;background:white">return self.geometry.JSON(); </span>
<br>
   <span style="color:black;background:white">def </span><b>XML</b>(self): <br>
       <span style="color:black;background:white">return self.geometry.XML();</span></span><o:p></o:p></p>
<p><o:p> </o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">Also, we would have to provide parsers to fill in self.geometry.</span><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">Or test for self.geometry in the JSON and XML methods, or add a constructor.</span><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">This is mainly for loading the -geometry field.</span><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">It could be handled in the Shape class, with eval() figuring out which geometry constructor to call.  That is okay with me!</span><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">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><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">I'm going to proceed with eval in the Shape class for now.</span><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">Thanks!</span><o:p></o:p></p>
<p><span style="font-family:"Courier New";color:black;background:white">John</span><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>