# Convert C1 curves and surfaces to C2 class

## Surfaces

### Overview

In engineering practice, C1-class surfaces are sometimes undesirable. For example, such surfaces may pose substantial difficulties in 3-rd party modeling systems, e.g., in Catia (where a single surface might end up broken down onto separate patches due to continuity defects). The following image illustrates a C1-class surface loaded into Analysis Situs from IGES:

Analysis Situs was designed from the day one to focus on the differential and topological props of CAD geometric models. That is why the continuity of B-spline surfaces is exposed directly in the viewer and does not require any dedicated analysis to be launched explicitly. The following color legend is used for decoding various orders of continuity at knot isolines on a B-spline surface:

C0 | C1 |

C2 | C3 |

To turn a C1-continuous B-spline surface into a C2-continuous surface, use convert-to-c2 Tcl command.

This command removes the duplicated knots, i.e., decreases their multiplicities. Knot removal would not happen if the shape modification it would induce is greater than the specified tolerance value (-tol argument). By default, this tolerance is not restricted, so local shape distortion is perfectly allowed. If the -add-knots argument is passed, extra nodes will be added to refine the resulting surface and make it fit better the input one.

The conversion operation also checks how the constructed surface deviates from the input one in the global sense (i.e., not just near knots as controlled by the -tol argument). Such a fitting test is necessary because knot removal operation is not shape-preserving. The max obtained deviation is reported as a return value of the corresponding Tcl command, so you can check it as follows:

### With or without knots

The convert-to-c2 command comes with the optional -add-knots argument that determines whether to add extra knots in the U and V directions of the surface. If this argument is not passed, then C2 continuity is achieved simply by decreasing the existing multiplicities of knots (following the rule that the order of continuity equals the degree of spline minus knot multiplicity). Here is the example (narvakd.dat ASTRA file) of a turbine blade with C1 continuity at knot isoparametric lines (C1 continuity is encoded with yellow color):

Without -add-knots option, the C2 continuity can be achieved by simply removing the repeated knot values (C2 continuity is encoded with blue color):

It is known from theory that such a naive approach might distort the original surface quite a bit. In the example above, the obtained max deviation measured between the modified and original surfaces was 0.33 mm (we did not use the -tol argument to restrict local surface deformations). If we add more knots in each span using the -add-knots option, then the deviation decreases to 0.018 mm in this particular case.

## Curves

Curve conversion is similar to surface conversion and is also based on knot removal atomic operation. The following image illustrates a C1-continuous spline curve imported from the narvakd.dat ASTRA file:

Without adding extra knots, the complexity of the curve can be decreased while improving its order of smoothness. The following image illustrates the same curve after convert-to-c2 command execution. The global deviation between the obtained and the original curve is around 0.1 mm.

As in the case with surfaces, you may want to add more knots in the curve spans (the regions between spline knots) for decreasing the global deviation. With the -add-knots flag passed, the complexity of the curve substantionally increases while the global measured deviation becomes only 0.001 mm.