orbingol / NURBS-Python

Object-oriented pure Python B-Spline and NURBS library
https://onurraufbingol.com/NURBS-Python/
MIT License
625 stars 154 forks source link

Quadratic surfaces get rendered as cubics #73

Closed virtualritz closed 4 years ago

virtualritz commented 4 years ago

I'm trying to render a JSON file.

This is a unit radius NURBS sphere generated in Rhinoceros and converted from OpenNURBS to JSDON via on2json.

Importing & exporting this as a JSON again with NURBS-Python yields a perfect sphere. So the data seems to be handled correctly.

However, when visualized/rendered via geomdl.visualization it looks like a cubic surface would using these CVs, not like a sphere.

Screen Shot 2019-12-04 at 00 48 06
virtualritz commented 4 years ago

On that note: fixing this may present a good opportunity to ensure that higher order surfaces – tetrics, quintics, hexics, etc. – get visualized correctly.

orbingol commented 4 years ago

Have you tried to change surface evaluation delta (docs) to something smaller, e.g. 0.01?

virtualritz commented 4 years ago

If I set the delta to this value the script never even opens the window. It seems to be hanging. I stopped the process after 5mins.

Output:

Traceback (most recent call last):
  File "trim_GIS.py", line 68, in <module>
    sphere.render(colormap=cm.copper)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/abstract.py", line 1949, in render
    self.tessellate(force=force_tsl)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/abstract.py", line 2005, in tessellate
    trims=self.trims, **kwargs)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/tessellate.py", line 162, in tessellate
    tessellate_args=self.arguments, **kwargs)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/_tessellate.py", line 135, in make_triangle_mesh
    vlst, tlst = tsl_func(vertex1, vertex2, vertex3, vertex4, vrt_idx, tri_idx, trim_curves, tsl_args)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/_tessellate.py", line 324, in surface_trim_tessellate
    t1, t2, status = ray.intersect(edges[idx2], trim_ray)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/ray.py", line 147, in intersect
    return _intersect2d(ray1, ray2, tol)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/ray.py", line 166, in _intersect2d
    return _intersect3d(ray1_3d, ray2_3d, tol)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/ray.py", line 198, in _intersect3d
    if linalg.point_distance(ray1_pt, ray2_pt) < tol:
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/linalg.py", line 321, in point_distance
    dist_vector = vector_generate(pt1, pt2, normalize=False)
  File "/Users/moritz/Library/Python/3.7/lib/python/site-packages/geomdl/linalg.py", line 184, in vector_generate
    ret_vec.append(ep - sp)
KeyboardInterrupt
virtualritz commented 4 years ago

Ok, I let it run and after 6mins I get this image – same bug, just denser tessellation. This does still look like a quadratic being rendered as a cubic.

Screen Shot 2019-12-18 at 17 33 00
orbingol commented 4 years ago

I am sorry, I have completely missed the part that you have converted the unit sphere using rw3dm. There was another bug report on the rw3dm issue tracker and it was resolved temporarily. Please refer to the that solution for the moment: https://github.com/orbingol/rw3dm/issues/8

I am closing this issue, it is not related to geomdl but rw3dm.