## 3 Proposed Method
### Watershed-Based Feature Recognition
#### 3.1.1 Two-Dimensional Curvature Map Construction  
Curvatures are the fundamental attribute that expose the convexity and concavity of freeform surface, which describe the inherent properties of freeform surface and can be used to guide the distribution of surface feature. Typically, the principal curvatures at surface points denoted \(k_{min}\) and \(k_{max}\) are the minimum curvature and maximum curvature, and the Gaussian curvature \(k_{gaussian}\) and mean curvature \(k_{mem}\) can be deduced by \(k_{min}\) and \(k_{max}\), and vice versa. In the study, root-mean-square curvature \(k_{rmc}\) is adopted for feature recognition that has been demonstrated in previous research work. The curvatures can be calculated by means of first and second fundamental forms of the T-spline surface.  
For T-spline surface in Equation (1), the first fundamental form (\(I\)) is given by  
\[I=Eds^{2}+2 Fdsdt+Gdt^{2} \tag{4}\]  
where  
\[E=S_{s}^{2},F=S_{s}S_{t},G=S_{t}^{2} \tag{5}\]  
The second fundamental form (\(II\)) is given by  
\[II=Lds^{2}+2 Mdsdt+Ndt^{2} \tag{6}\]  
where  
\[L=\mathbf{n}S_{ss},F=\mathbf{n}S_{st},G=\mathbf{n}S_{tt} \tag{7}\]  
Figure 2: Flow chart of watershed-based toolpath generation for the T-spline surface: (**a**) the input T-spline surface that has one convex feature, (**b**) two-dimensional curvature map shaded by root-mean-square curvature, (**c**) watershed results and PolyBoundingBox construction for the convex feature, (**d**) MSRs generation using T-spline local refinement, and sub-regions are shaded using different color, (**e**) optimized multi-rectangle toolpath generation for the surface.  
and \(n\) is the surface unit normal given by  
\[n=\frac{S_{s}\times S_{t}}{\|S_{s}\times S_{t}\|} \tag{8}\]  
Hence, the gaussian curvature (\(k_{gaussian}\)), mean curvature (\(k_{man}\)), and two principal curvatures (\(k_{max}\), \(k_{min}\)) are calculated as follows respectively:  
\[\left\{\begin{array}{l}k_{gaussian}=\frac{LN-NQ^{2}}{EG-F^{2}}\\ k_{man}=\frac{1}{2}\big{(}\frac{LN-2 EM+GL}{EG-F^{2}}\big{)}\\ k_{max}=k_{man}+\sqrt{k_{man}^{2}-k_{gaussian}}\\ k_{min}=k_{mean}-\sqrt{k_{man}^{2}-k_{gaussian}}\\ \end{array}\right. \tag{9}\]  
And the root-mean-square curvature (\(k_{rmc}\)) is defined as below:  
\[k_{rmc}=\sqrt{k_{min}^{2}+k_{max}^{2}} \tag{10}\]  
Curvatures are calculated for each point generated on T-spline surface using uniform sampling. Hence, a two-dimensional curvature map (\(2 DCM\)) is defined in T-spline parametric space, where T-spline parameters (\(s\),\(t\)) are employed as the (\(x\),\(y\)) coordinates of the \(2 DCM\), and the curvature information is employed as the \(z\) value of the \(2 DCM\). The resolution of the \(2 DCM\) is decided by the points sampling frequency. High sampling frequency can generate a dense map that will improve the feature recognition accuracy with high computation cost and vice versa.  
An example of T-spline surface \(2 DCM\) is given as shown in Figure 3: (a) presents the input T-spline surface, (b) gives the \(u\) and \(v\) iso-parametric lines of T-spline surface, (c) shows the sampling points colored by root mean square curvature, (d) projects the uniform sampling points on parametric space and colored in interpolation mode. It is evident that the concave and convex regions can be successfully delineated from the \(2 DCM\) intuitionally, and the feature recognition procedure will be presented in the next section.