7

Suppose we have some mesh (see the illustrating picture from CorelDraw, which uses the same technique in "Mesh fill" instrument).

alt text
(source: sonic.net)

Obviously this kind of mesh is represented by a set of points and lines between them are actually determined using that set of points (probably somehow interpolated). This instrument also has buttons to increase mesh resolution.

My question is the following - how are such sort of things computed? Suppose I have some set of points that actually represent a mesh (for easy case let's even assume, that points on the "border" are static and can't move). And I want to increase the mesh resolution, for example, in 4 times (so that number of mesh points actually becomes 4 * initial_points_count).

How should I compute the locations of new points if the only data that I have is that initial point matrix?

The fastest (even approximated) method would suit me, but I don't know where to search or how to develop such kind of algorithm.

Thank you.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Yippie-Ki-Yay
  • 22,026
  • 26
  • 90
  • 148
  • Does this "mesh fill" work on any shape or does it create only meshes for circles? To me it is not clear how it works. Also, what is the significance of the colors. – Unreason Jul 07 '10 at 10:32
  • @Unreason Any shape. In my current case, I am actually looking for a way to increase the resolution for a mesh on a rectangle. *Probably, this circle wasn't the best sample...* Actually, I could have set the question without that picture. – Yippie-Ki-Yay Jul 07 '10 at 10:36
  • Ok, I took a look at http://www.corel.com/servlet/Satellite?pagename=Corel3/Section/Display&sid=1047024315119&gid=1047024331836&cid=1047022730336 and it works for any shape. If you want to implement/understand I don't think you can look at points only, you will have to consider the curves and their internal representation. – Unreason Jul 07 '10 at 10:37
  • @HardCoder1986: However, if you are looking for a solution on the rectangle then the problem degenerates to a trivial solution - 'divide each side to required resolution. make a m x n grid. done.' – Unreason Jul 07 '10 at 10:39
  • @Unreason Maybe there is a way to implement this **mesh resolution increase** (can this be achieved by *smoothing*?) when I have only point coordinates or would I have to build some sort of these curves, etc, etc, and use them to interpolate new points' coordinates? – Yippie-Ki-Yay Jul 07 '10 at 10:42
  • @Unreason About the rectangular case - think of the situation when points aren't positioned in a rectilinear way (basically, the points inside the rectangle can take any position and, hence, build complex curves). If I have some matrix with these points, what should I do to make my mesh resolution larger (in terms of points per square inch, for example)? – Yippie-Ki-Yay Jul 07 '10 at 10:44
  • @Unreason Also to mention, as I understand now, mesh smoothing is not something I'm looking for. I don't want to make my mesh "look better", I simply want to achieve larger point density (for another algorithm, actually). – Yippie-Ki-Yay Jul 07 '10 at 10:47
  • @HardCoder1986 Please summarize the question in the title! – reinierpost Jul 07 '10 at 12:43

5 Answers5

4

Comments on existing answers:

It seems to me that Mau's and martient's answer describe a solution to problem of approximating a known form with polygon mesh (and you don't have a known form).

Algorithm that Dave mentions would smooth any form, but not necessarily in the intended way.

If you look at You's answer you will see that the new points come from linear interpolation between the points, and if that is good enough for you all solutions are comparable (except Dave's).

Such increase in the mesh density will not make the resulting mesh look any 'nicer' - more similar to original form. If that's not good enough then you first have to decide what is the actual form/shape that you are trying to represent with the mesh (if you could expand on your example it might be a bit more obvious; is this tool creating only circle meshes or it can take any shape and 'mesh fill' it?).

Also, you should notice that you don't work with a polygon mesh, but with mesh of curves (probably bezier), which is another reasons why some of the answers would not directly apply to your problem.

EDIT: After looking more closely on how corel does this and assuming that you actually know the curves not only the points(!):

  • You begin with set of curves, and it seems to me that you have horizontal and vertical curves to begin with
  • If you want to increase the resolution (for example horizontal resolution), you could take two consecutive vertical curves and divide every segment of the horizontal curves they pass through at mid point thus creating a set of points that define the new curve; you could also interpolate the angle at which the curve passes through the point

alt text http://img706.imageshack.us/img706/5693/path5818.png

The above (manually drawn) picture shows tries to illustrate a) adding of the new curve (red) that you would generate in this way. b) adding the linearly interpolated polyline (blue), that goes more towards polygon mesh approach (so you can judge if that is acceptable for you)

Note: Depending on the algorithm for which you are preparing the mesh you might or might not have any benefits in considering the mesh lines to be curves (difference between red and blue solutions might be negligible for certain algorithm and important for other). If the algorithm simply expect points then you should also look at how to approximate bezier curves with points (reading through this might help; though you don't need pixel precision).

For highest precision/best results you should first increase the density of curves and the approximate them with lines.

Unreason
  • 12,556
  • 2
  • 34
  • 50
2

Have you looked at subdivision? Should work for refining meshes like that.

martiert
  • 1,636
  • 2
  • 18
  • 23
2

What You're looking for is a mesh smooth algorithm. Unfortunately I don't have any resources at hand, so I can only suggest to google for "mesh smoothing". That's a huge field.

EDIT

Here's a nice, short, roundup of a couple of methods/algorithms to achieve mesh smoothing: http://www.mpi-inf.mpg.de/~ag4-gm/handouts/06gm_surf3.pdf

Dave O.
  • 2,231
  • 3
  • 21
  • 25
  • @HardCoder1986: I don't think this will get you where you want - take a look at http://en.wikipedia.org/wiki/Laplacian_smoothing and see if you can implement it. – Unreason Jul 07 '10 at 10:30
  • But Laplacian Smoothing is only one of many implementations of mesh smoothing. I admit, that my hint isn't that valuable for Beginners. Feel free to post good resources on the topic. – Dave O. Jul 07 '10 at 10:36
  • @Dave: it was only an example to show that smoothing algorithms will degenerate contour/outline. – Unreason Jul 07 '10 at 10:51
  • @Unreason not every algorithm is going to do that. There are methods, that treat the vertices of the input mesh as features and preserve them. – Dave O. Jul 07 '10 at 14:43
  • @Dave, it will still linearly (or in some other way) degenerate the countour/outline. I wanted to point out to OP that he is starting with perfect info on the shape/contour (bezier curve segments) and that smoothing methods will degrade it. On the other hand OP did specify that available input is only 'matrix of mesh points' so your answer is respecting that, it was just that I did not think that OP actually wanted that - so I was subjective, but OP agreed (for now). – Unreason Jul 07 '10 at 15:43
  • @Unreason yep you're right. even feature preserving methods will degenerate to a smoothed convex hull, but one would need really many iterations for that. – Dave O. Jul 07 '10 at 19:24
2

I would start by adding halfway points on all lines by interpolating (the curves in the illustration are most likely Bézier curves of some sort, so I would interpolate them as such, or use biliniear interpolation as Mau suggested) and placing new points halfway between the old ones, giving me 3 times the resolution. I would then interpolate between these new points (both ways if precision is key) and place a new point at the intersection (or halfway). See "illustration" below.

Initial state  =>  Interpolate  =>  Place points  =>  Interpolate => Final state
  x       x         x-------x        x   x   x         x   x   x      x   x   x
                    |       |                              |    
                    |       |        x       x         x---+---x      x   x   x
                    |       |                              |
  x       x         x-------x        x   x   x         x   x   x      x   x   x
You
  • 22,800
  • 3
  • 51
  • 64
1

Sounds like a job for Bilinear Interpolation (where the coordinate system is on the sphere surface).

Mau
  • 14,234
  • 2
  • 31
  • 52