# Merging polysurface into a single NURBS surface

Scenario:
Calculating the gauge dimensions of curved surfaces/polysurfaces.

What I did:

• using Rhino.Geometry.Surface.GetSurfaceSize I am able to find gauge dimensions for surfaces

• for polysurfaces I cannot unroll/squish, the result is incorrect. So I need to merge them into a single surface.

• I realize I’ll have to convert my polysurface into mesh then convert that mesh into nurbs surface. Using any of the methods below does the trick to convert to mesh. Although still unclear how to increase the accuracy.
CreateFromBrep(Brep)
CreateFromBrep(Brep, MeshingParameters)
BrepFace.GetMesh()

What I need:

• Guidance / approach / algorithm / code snippet - how to convert this mesh back into a single nurbs surface.
• Publication / Scientific article explaining a method to do that

https://developer.rhino3d.com/api/RhinoScriptSyntax/#collapse-UnrollSurface

Flattens a developable surface or polysurface

##### Parameters:

surface_id (guid): the surface’s identifier
explode (bool, optional): If True, the resulting surfaces ar not joined
following_geometry ({guid, …]): List of curves, dots, and points which should be unrolled with the surface

just set the second argument to false and go from there.

Doesn’t work every time, sometimes the resulting flattened polysurface is connected through a point and there’s a gap. This is wrong.

Probably because the surfaces are not exactly developable. UnrollSrf is intended for unrolling developable surfaces. If a surface is not exactly developable it is not mathematically possible to flatten the surface without distortion.

Have you tried using Patch to convert the mesh into a surface. You may need to experiment with the number of U and V spans to obtain the desired accuracy.

True but you’re trying to do the mathematically impossible, so you’re down to using “bad” tools if you insist on trying.

All I need is to have the gauge dimensions and area within accepted tolerance.

That is not mathematically impossible

Interesting. I use Patch frequently to obtain surfaces from a relatively dense set of points / mesh and obtain good results. . The density of input points / mesh may need adjusting. The maximum edge length option is one method to increase the density of a mesh. As I mentioned above some experimentation with the number of U and V spans used in Patch may be needed to achieve the desired accuracy without a sufficiently smooth surface. Patch produces a single degree 3 surface without creases. If the input represents a surface with creases etc. then a single application of Patch will probably not produce the desired result.

If the input does not have creases then Patch should be able to produce a single surface which will Smash or Squish with sufficient accuracy. Of course if the surface is non-developable the flattened surface will not be unique. Different assumptions/settings for flattening process will result in different results.

Can you provide a sample polysurface?