## 2 Generalized Contour-Sum Method  
The contour-sum method was firstly proposed by [PERSON] and [PERSON] in 1992 [12] to prove that there is a branch cut (phase singularity) in the phase function of a light field with strong intensity variation. Since then, it has been adopted to detect OV beams using the phase slopes measured by an SH-WFS [20]. The essence of this method is that the circulation value of the phase gradient along a closed path enclosing the singularity point has a relationship with the TC value \(n\), which is an integer and can be expressed as [20]:  
\[n=\frac{1}{2n}\oint_{C}\
abla\phi\cdot d\overrightarrow{r}, \tag{1}\]where \(C\) is a closed path, \(\
abla\phi\) is the phase gradient, and \(\vec{d\,r}\) is an infinitesimal displacement along the closed path \(C\).  
In practice, in order to determine the TC, we must discretize the line integral according to the geometrical configuration of sampling points, and accordingly rewrite Equation (1) as:  
\[\mathit{Cir}=\frac{A}{2\pi}\sum_{k=1}^{K}\vec{S}_{k}\cdot\vec{l}_{k}, \tag{2}\]  
where \(K\) is the number of sampling points along the closed path, and \(S_{k}\) and \(l_{k}\) are the phase slope and discretized contour path of the \(k\)-th sampling point, respectively. In Equation (2), a constant \(A\) is introduced to compensate for the error caused by the discretization [24], and \(\mathit{Cir}\) is the TC value to be measured.  
Specially, with the use of an SH-WFS, the discretization is realized by the lenslet array, and the phase slopes are simply obtained by the displacements of the focusing spots produced by the corresponding lenslets. Thus, the discretized contour paths connect the centers of the lenslet areas, forming the closed path. Figure 1 illustrates the generalized contour-sum method. In Figure 1, the square indicates the lenslet area, and the area marked with downward diagonal lines is the element forming the closed path. The discretized-contour path \(l_{k}\) is represented by the red vector that connects the centers of the two adjacent elements in the closed path, and the blue vector \(S_{k}\) is the phase slope, which is the average of the phase slopes at the two adjacent elements.  
The raw data from the SH-WFS measurement consist of a Hartmann of multiple focused spots. The five main steps of the GCSM are (1) preprocessing the Hartmanngram, including thresholding and segmentation; (2) calculating the phase slope of the individual lenslet area locations according to the SH-WFS working principle; (3) summing the intensity values of all pixels in each lenslet area to obtain the intensity sum value; (4) extracting a closed path from the intensity sum map; and (5) calculating the circulation, which is TC value of the OV beam.  
In this algorithm, the closed path should be extracted from the intensity sum map, instead of from the Hartmanngram itself. This is because the intensity distribution behind the individual lenslet areas reflects the average distortion, but not the intensity distribution of the sub-wavefront incident into the lenslets. Since closed path determination is a crucial step, we focus on exploring the most proper closed path determination method in the rest of this paper.