How to generate a mesh with CGAL for a surface defined in a closed parametric form? - mesh

I would like to generate a mesh/triangulation for a parametric surfaces with CGAL. This surface is defined by a closed parametric form as can be seen on this website. Note that x, y, and z are defined in terms of two parameters u and v. For such a surface, which is given by a closed parametric form, it should be possible to generate a pretty good mesh/triangulation. I have found several ways to implement it with CGAL (3D Surface Mesh Generation, Surface Reconstruction from Point Sets, ...). My question is which one is appropriate for my special case?

Related

Parameterization of Triangulated Surface Meshes

I’d like to perform a surface parametrization of a triangle mesh (for the purpose of texture mapping).
I tried using some of CGAL’s algorithms, e.g. ARAP, Discrete Conformal Map etc.
The problem is that the surface parameterization methods proposed by CGAL only deal with meshes which are homeomorphic (topologically equivalent) to discs.
Meshes with arbitrary topology can be parameterized, provided that the user specifies a cut graph (a set of edges), which defines the border of a topological disc.
So the problem now becomes – how to cut the graph properly (using CGAL’s interface).
I found a similar question from 3 years ago that went unanswered.
P.S.
If someone can point me to a different library that can do the job, that’ll be just as great.
Thanks.

3d surface triangulation of an open surface with CGAL

I'm a newbie to CGAL library. However, I think it's a very suitable package for what I want to do.
I have a set of points representing a 3D surface (as shown in figure 1).
I want to fit a 3d triangulation on this surface. The surface is not closed and therefore does not occupy a volume. The code provided in poisson_reconstruction_example.cpp seems appropriate for this job. But the problem is that as a part of poisson_reconstruction algorithm it closes the ends and underneath of the surface to make it a volume (see figure2).
I was wondering:
1- Is there a way to do the triangulation on the surface just defined by the points, without getting a closed surface which encloses a finite volume?
This means that the final triangulation has boundary edges.
I'm happy with any Upsampling or smoothing which may be needed.
2- If the answer to the first question is no, then, is there any way to guarantee that the input points are the vertices of the generated triangles?
The poisson surface reconstruction generates a close surface that interpolates the point cloud given as input. It requires as input a point set with normals.
If you need a algorithm that only uses input points in the output, you can try the Advancing Front Surface Reconstruction algorithm.

CGAL 3D surface mesh generation for unbounded implicit surfaces

This is again a question about the CGAL 3D surface mesher.
http://doc.cgal.org/latest/Surface_mesher/index.html#Chapter_3D_Surface_Mesh_Generation
With the definition
Surface_3 surface(sphere_function, // pointer to function
Sphere_3(CGAL::ORIGIN, 64.0)); // bounding sphere
(as given too in the example code) I define an implicit surface given by 'sphere function' and a Sphere_3 of radius 8.
The difference is now, that the zeros of 'sphere function' are (contrary to its now misleading name) no longer bounded and inside Sphere_3. Instead 'sphere_function' represents an unbounded surface (think of x^2 + y^2 - z^2 - 1 = 0) and my intention is to triangularize its part that is in the Sphere_3.
In my examples up to now this worked quite well, if only for some annoying problem, I do not know how to overcome: The boundaries, where the implicit surface meets the Sphere, are very "rough" or "jagged" in a more than acceptable amount.
I already tried the 'Manifold_with_boundary_tag()', but it gave no improvements.
One road to improve the output that I am contemplating, is converting the triangulated mesh (a C2t3) into a Polyhedron_3 and this in a Nef_polyhedron and intersect that with a Nef_polyhedron well approximating a slightly smaller Sphere. But this seems a bit like shooting with cannons for sparrows, nevertheless I have currently no better idea and googling gave me also no hint. So my question: What to do about this problem? Can it be done with CGAL (and moderate programming effort) or is it necessary or better to use another system?
(Just for explanation for what I need this: I try to develop a program that constructs 3D-printable models of algebraic surfaces and having a smooth and also in the boundaries smooth triangulation is my last step that is missing before I can hand the surface over to OpenSCAD to generate a solid body of constant thickness).
The only solution I see is to use the 3D Mesh Generation with sharp feature preservation and no criteria on the cells. You will have to provide the intersection of the bounding sphere with the surface yourself.
There is one example with two intersecting spheres in the user manual.

Library for fitting parametric curves

Does anyone know of a library (any language, though preferably python/R/matlab) for parametric curve fitting, i.e. if you have a set of points in the plane {(x_i,y_i)} you can find parameter estimates for two (polynomial) functions y=f_y(t) and x=f_x(t) for some (arc-length?) parametrization t? This is especially useful if you have some multi-valued function (e.g. a circle) for which regression wouldn't work.
There are a number of papers detailing algorithms (e.g. 'Parametric Curve Fitting', Grossman 1971) but I can't find any corresponding software that would save a lot of time coding up.
For future reference, I ended up using the princurve library in R based on principal curves by Trevor Hastie.

Objective C / Solving math systems

I've been trying to develop a simple app that calculates the equation of a curve using information given by the user.
For example, let's suppose the user has the equation of a circle and the equation of an ellipse, and he wants to know the intersection points.
Mathematically speaking, this is a quite simple problem, but i can't figure out how to tell Xcode to solve that system.
I've looked into the Accelerate framework, and i found the "dgesv" function of Lapack. This would be a perfect solution for a system of lines, but what about more complex systems like the one i've stated before?
I was even wondering how to calculate the tangent line of a curve, and other similar geometry problems.
For example, let's suppose the user has the equation of a circle and the equation of an ellipse, and he wants to know the intersection points. Mathematically speaking, this is a quite simple problem, but i can't figure out how to tell Xcode to solve that system.
The problem of intersecting a circle and an ellipse in general involves solving a fourth degree polynomial equation. You can break it down to third degree, but square roots alone won't suffice. So I'd say that's not really a “quiet simple problem”. That being said, some numeric libraries do support algorithms for finding the real or complex roots of a univariate polynomial. So you'd eliminate one of your variables (e.g. using resultants or Gröbner bases) and then feed the resulting polynomial to that. Not sure what libraries would be most suitable in the Objective C world. But a question asking to suggest a specific library would be deemed off-topic anyway, so use the keywords I mentioned to find something that suites your needs.
I was even wondering how to calculate the tangent line of a curve, and other similar geometry problems.
The tangent direction is simply orthogonal to the gradient of the implicit form. In other words, describe your curve not parametrically as x=f(t) and y=g(t) but instead implicitely as f(x,y)=0. In case of a circle that would look like x2+y2+ax+by+c=0. Then compute the partial derivatives with respect to x and y. That's 2x+a and 2y+b. So (2x+a, 2y+b) is perpendicular to the circle, and (2y+b, -2x-a) is tangential. Not sure what you'd consider similar to this.