[x3d-public] Feedbacks related to x3d.py

Thomas Paviot tpaviot at gmail.com
Fri Jun 12 03:24:15 PDT 2020


Hello,

I've currently been porting the pythonocc x3d exporter code to the x3d.py
official package (latest release 0.0.31). Here are the feedbacks from my
first experiments. I will reply to this message to report other issues as
long as they come.

1. I'm confused with the way lists and tuples are used to pass sequences to
class methods:

For example, the Coordinate node accepts both lists and tuples as a point
vector:
>>> import x3d
x3d.py package loaded, have fun with X3D Graphics!
>>> x3d.Coordinate(point=[[1,0,0], [0,1,0]])
<x3d.Coordinate object at 0x000001EA57A437F0>
>>> x3d.Coordinate(point=[(1,0,0), (0,1,0)])
<x3d.Coordinate object at 0x000001EA57A43710>

But the Normal node only takes list of tuples:
>>> x3d.Normal(vector=[(1,0,0), (0,1,0)])
<x3d.Normal object at 0x000001EA582FA160>
>>> x3d.Normal(vector=[[1,0,0], [0,1,0]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"D:\Devel\pythonocc-core\src\Extend\DataExchange\x3d_standard\x3d.py", line
35739, in __init__
    self.vector = vector
  File
"D:\Devel\pythonocc-core\src\Extend\DataExchange\x3d_standard\x3d.py", line
35749, in vector
    assertGreaterThanEquals('vector', vector, -1)
  File
"D:\Devel\pythonocc-core\src\Extend\DataExchange\x3d_standard\x3d.py", line
1652, in assertGreaterThanEquals
    assert isGreaterThanEquals(value, minimum), fieldName + '=' +
str(value) + ' fails assertGreaterThanEquals minimum=' + str(minimum)
  File
"D:\Devel\pythonocc-core\src\Extend\DataExchange\x3d_standard\x3d.py", line
1641, in isGreaterThanEquals
    if each < minimum:
TypeError: '<' not supported between instances of 'list' and 'int'

IMO all sequence parameters should accept both lists and tuples and all
possible combinations (list of lists, list of tuples, tuple of lists, tuple
of tuples).

2. I noticed the IndexedTriangleSet does not have any creaseAngle field,
whereas x3dom supports it.

>>> x3d.IndexedFaceSet(creaseAngle=0.2)
<x3d.IndexedFaceSet object at 0x000001EA5ED7A7B8>
>>> x3d.IndexedTriangleSet(creaseAngle=0.2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'creaseAngle'

It actually follows the standard specification (
https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/rendering.html#IndexedTriangleSet),
my question is then related to the standard itself: why do the
IndexedTriangleSet (and some other geometries) does not define the
creaseAngle field ?

Best Regards,

Thomas Paviot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200612/63bb0c5c/attachment.html>


More information about the x3d-public mailing list