# Approximate shell with a surface

I have a set of "nicely" connected faces in a shell. There are no holes in the shell, and the entire shell is G1 or G2 continuous. I want to approximate this shell with a single surface.

I have been trying to create an Adaptor3D_Surface subclass to these shells, but I couldn't figure it out yet. So my question is that is there something similar in OCCT or in the paid libraries? Or if someone could give some ideas to start with, that would be nice.

### Plate algorithm

Did you try Plate algorithm? The idea is to put sufficient number of "pinpoint" constraints (G0) on the host surfaces of your faces. Then you specify some average plane to be deformed so that to satisfy your constraints. This is a kind of TPS technique for approximation. The tool will build an approximation (non-polynomial) internally and then convert it to NURBS form with polynomial approximation.

### You can look also at the

You can look also at the product SSP (Surface from Scattered Points - http://www.opencascade.com/content/surfaces-scattered-points).

### I am not sure if that would

I am not sure if that would work for me, since precision in the boundaries must be very high, because the generated face has to be sewed with a given solid.

### Actually the faces that I

Actually the faces that I want to approximate come from the plating algorithm, but I can not define the constraints to generate a single surface. So I have to "reapproximate" it.

### And also I can not define the

And also I can not define the "grid" of points in the plating algorithm.

### Why cannot you? Since you

Why cannot you? Since you have full shell geometry, you may either sample its parametric domain to produce the points, or use faceter (BRepMesh) to yield curvature-driven distribution of points in 3D. You will only need to ensure that near-coincident points are filtered out.

### Ahh, so I can define an

Ahh, so I can define an ordering with the U, V parameter in the GeomPlate_PointConstraint?

Edit:
No I can't. Plating will fit an arbitrary surface to the points, and won't respect their "order", right?

### Ohh I see, but I can define

Ohh I see, but I can define tangential constraints by making point constraints with surfaces. That should work! I will give it a try.

### You mean sorting of points?

You mean sorting of points? Yes, as far as I know, the points are treated in disordered manner (that's why the FE-driven analogue mentioned by msv is called "Surface from _Scattered_ Points"). But why do you need to order your point cloud somehow? The matter is that we have experience in using Plate algorithm for exactly the same problem (build a single face basing on shell geometry), and Plate seems to work there quite reliably.

Edit: sorry, if you meant smoothness order, then yes, not only positional constraints are possible.

### Thank you ssv, I think you

Thank you ssv, I think you are right, that should work, I will give it a try.

### How dense mesh is optimal for

How dense mesh is optimal for this problem?

### Personally, I would start

Personally, I would start with uniform sampling in parametric space just to make a proof of concept. The algorithm is said to be O(N^3), so you may face performance issues on huge point clouds. As for the mesh, I think you may control chord length and angular deviations in BRepMesh. In our practice these parameters are often left to the user (or you may try to estimate then basing on surface curvatures).

BTW, since your geometry is already well-shaped, the better way to proceed, I think, would by just least squares approximation (without plating). However, I'm not aware of any ready-to-use API for that in OCCT (though, I am pretty sure it can be done with use of low-level facilities of OCCT).

### Sometimes I get unexpected

Sometimes I get unexpected (but reasonable) solutions for plating, like this one:

http://imgur.com/a/ReAUT

The constraints are the black edges.

In this case I would expect the bump to be on the other side of the curve network.
I tried to
1. add a point constraint to the other side. This just resulted another bump in the middle of this one.
2. add tangential constraints to the curves that point to the other direction. Unfortunately plating does not consider the +- direction of tangents, thus it results tangentially aligned bump but in the same direction.

Is there any way to force the direction of the filling? The GeomFill_BSplineCurves gives nice results, but there I can not control tangential constraints.

### Hi Istvan, Probably you

Hi Istvan,

Probably you should play a bit with the basic surface which is deformed. You may not rely on the initial plate constructed by the algorithm for you, but provide rather your own basic surf. If playing with basic surface will give no effect, then probably you'd better to register an issue.

P.S. There is also ConstrainedFilling algo somewhere in geometry packages. Just something to try out.