vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
555 stars 92 forks source link

NURBS surface not displayed #315

Closed CsatiZoltan closed 2 years ago

CsatiZoltan commented 2 years ago

I want to plot a (non-rational) B-spline surface. Following the advice on the forum, I used NURBSsurface as a starting point. However, I get an empty output when I run the code. The same issue with the code in this post: the control net is shown but the surface is not.

The same issue happens on the web application as locally, on my system:

$ asy --version
Asymptote version 2.70 [(C) 2004 Andy Hammerlindl, John C. Bowman, Tom Prince]

ENABLED OPTIONS:
WebGL    3D HTML rendering
OpenGL   3D OpenGL rendering
XDR      external data representation (portable binary file format)
GC       Boehm garbage collector

DISABLED OPTIONS:
GSL      GNU Scientific Library (special functions)
FFTW3    Fast Fourier transforms
CURL     URL support
Readline interactive history and editing
Editline interactive editing (if Readline is unavailable)
Sigsegv  distinguish stack overflows from segmentation faults
johncbowman commented 2 years ago

Asymptote doesn't currently support NURBS in OpenGL or v3d (although a summer intern is looking into approximating them with Bezier curves and surfaces). They are supported in PRC (this requires the options -f pdf -prc and Adobe Reader).

CsatiZoltan commented 2 years ago

I see. Some further questions I have in mind:

  1. What about B-spline surfaces (i.e. equal weights) -- are they supported by OpenGL or v3d?
  2. Concerning NURBS,
    • is there another option than Adobe Reader (I work under Ubuntu, where Adobe Reader is not supported for many years)?
    • is there any other output format (possibly using a third-party converter), which would allow me to embed the graphics in a web page (like reveal.js for presentations) ?
    • I can export a B-spline surface from FreeCAD into an HTML file (OpenGL), see the attached example. Would it be possible to process it somehow with Asymptote so that I can add other graphical elements (LaTeX text/formula, axes, etc.)? That would be a great intermediate solution in my opinion.
  3. How should I modify the example to make it work with Bézier surfaces, without representing the Bézier surface as a specific NURBS surface (as in the example), which is not rendered in OpenGL or v3d? I tried draw(P), but that signature is apparently not supported.

geom.zip

johncbowman commented 2 years ago
  1. Only Bezier surfaces and curves are currently supported (we used to use the GLU library to render NURBS but it is now deprecated and we now need to do our own rendering; work is underway to support NURBS).

  2. Here are instructions for installing Adobe Reader under Fedora which you can adapt for Ubuntu: wget http://ardownload.adobe.com/pub/adobe/reader/unix/9.x/9.5.5/enu/AdbeRdr9.5.5-1_i486linux_enu.rpm

dnf install AdbeRdr9.5.5-1_i486linux_enu.rpm

Install other needed packages on Fedora

dnf install libcanberra-gtk2.i686 adwaita-gtk2-theme.i686 PackageKit-gtk3-module.i686 mesa-dri-drivers.i686 gdk-pixbuf2-xlib.i686

  1. You'll have to wait until we support NURBS again, unless you want to use PRC and Adobe Reader.
johncbowman commented 2 years ago

If you zoom in on geom.html you will see that it is not correctly rendered; vector graphics is supposed to be scalable. It uses three.js which does not output vector graphics, unfortunately.

This is just a tesselation and yes, Asymptote supports tesselations too. If you are happy with a fixed-mesh approximation like this, one option would be to write a converter to v3d, which Asymptote can read directly.

CsatiZoltan commented 2 years ago

Thank you for the quick reply and the clear explanations. Once NURBS are implemented, will you support arbitrary number of control points, or will it be restricted to degree 3?

johncbowman commented 2 years ago

We will support a NURBS of arbitrary degree, just like in the PRC version.