[x3d-public] Question: Geometry class for x3d.py?

John Carlson yottzumm at gmail.com
Wed Dec 8 18:45:55 PST 2021


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.

John

If it’s okay with you, I will use eval on prototype, and we can do
something else for code generation/stylesheets.

Suggest a way to map class names to classes, possibly provided by x3d.py,
and we can proceed to eliminate eval.

Thanks!

John

On Wed, Dec 8, 2021 at 9:54 AM Brutzman, Donald (Don) (CIV) <
brutzman at nps.edu> wrote:

> 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.
>
>
>
> Hopefully you have a standalone example import, with inputs and outputs
> included, so that I might confirm consistent operation when first testing.
>
>
>
> 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.
>
>
>
> Patience pays.  Anything we want to do only requires a few SMOPs to sort
> out and get correct, hopefully for a long long time.
>
>
>
>    - https://en.wikipedia.org/wiki/Small_matter_of_programming
>
>
>
> 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 https://
> faculty.nps.edu/brutzman
>
>
>
> *From:* John Carlson <yottzumm at gmail.com>
> *Sent:* Tuesday, December 7, 2021 8:19 AM
> *To:* Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>; X3D Graphics
> public mailing list <x3d-public at web3d.org>
> *Subject:* Re: Question: Geometry class for x3d.py?
>
>
>
> NPS WARNING: *external sender* verify before acting.
>
>
>
> Updated x3dinput.py attached.
>
> Proceeded with eval, removed JSON_Geometry class.
>
> There is no need for a x3d.py Geometry class that I know of, except for
> below.
>
> Regexp still needed for security purposes (no constructing arbitrary,
> possibly hidden classes, please).
>
> 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?
>
> "DOM" API for creating scenegraph "elements" seems like a good solution.
>
> Please provide direction for desired implementation.  If we continue with
> eval, perhaps we could apply it in more places?
>
> Enjoy JSON parsing HelloWorld.json!
>
> John
>
> On 12/7/21 09:58, John Carlson wrote:
>
> Don, you may want to create a Geometry class in x3d.py like:
>
> class *Geometry*(_X3DGeometryNode):
>    def *FIELD_DECLARATIONS*(cls):
>        return []
>    def *JSON*(self):
>        return self.geometry.JSON();
>    def *XML*(self):
>        return self.geometry.XML();
>
>
>
> Also, we would have to provide parsers to fill in self.geometry.
>
> Or test for self.geometry in the JSON and XML methods, or add a
> constructor.
>
> This is mainly for loading the -geometry field.
>
> It could be handled in the Shape class, with eval() figuring out which
> geometry constructor to call.  That is okay with me!
>
> 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.
>
> I'm going to proceed with eval in the Shape class for now.
>
> Thanks!
>
> John
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211208/f9ba5807/attachment.html>


More information about the x3d-public mailing list