# A New Approach to Detect Hand-Drawn Dashed Lines in Engineering Sketches
## 4 Non-Solid Line Clustering
### Obtaining Candidate Dashes  
To enhance the efficiency of the search process, the algorithm first discards those strokes that are _implausible_ dashes, following these steps:  
1. Exclusion of Long Strokes:  
Excessively long strokes are excluded as candidate dashes, as SBM dashed lines typically represent hidden edges, which can only be hidden by faces delimited by edges that are necessarily larger than the dashes. The algorithm determines the length of the longest segment in the sketch, denoted as **<MaxLength>**. Subsequently, a threshold value **<TrimLength>** is calculated as a percentage of **<MaxLength>**:  
\[\mathit{TrimLength}=\mathit{MaxLength}\cdot\mathit{DashSizeMax} \tag{1}\]  
where \(\mathit{DashSizeMax}\) has a default percentage of 50%. Segments exceeding the length of **<TrimLength>** are discarded and labeled as non-visitable. 2. Discarding non-isolated strokes:  
Candidate stroke tips must maintain a significant distance from neighboring tips. The valence of each tip is then calculated to identify potential shared vertices, avoiding collinearity. Closeness is determined by a threshold relative to stroke size, calculated as  
\[\mathit{Threshold}=|\mathit{Segment}\mathit{length}|\cdot\mathit{ IsolatedTipThreshold} \tag{2}\]  
Figure 5: Fitting one stroke to its regression line. The default value of _IsolatedTipThreshold_ is 25% of the dash length. The algorithm then identifies endpoints near stroke tips, excluding collinear strokes. If both tips have a valence > 0, the stroke is discarded as dashed and marked as non-visitable. 3. Assessment of stroke similarity:  
The algorithm temporarily excludes strokes that significantly deviate from the average stroke length. At the start of each search iteration, the average length of the remaining candidate strokes <avgLength> is recalculated. Based on the principle of similarity, the algorithm assumes that only similar dashes belong to a single dashed stroke. It uses the average length of remaining candidate strokes, <avgLength>, to establish the length range for currently visible dashes:  
\[DashLengthMin=\frac{avgLength}{DashSizeShortRange}\]  
\[DashLengthMax=avgLength\cdot DashSizeLongRange \tag{3}\]  
where _DashSizeShortRange_ is the number of times that a stroke should be shorter than the average dash to be excluded (default is 5 times shorter). _DashSizeLongRange_ is the number of times that a stroke should be longer than the average dash to be excluded (default is 2.5 times longer). Candidate strokes that fall outside the range [DashLengthMin, DashLengthMax] are temporarily discarded and labeled as currently non-visitable. These strokes may become visible later as the algorithm progresses and adjusts the average length based on remaining non-visited dashes. Hence, these parameters must be recalculated each time a candidate dashed line is created and the search for remaining dashed strokes is relaunched. Since shorter strokes are prioritized for visitation, these parameters tend to increase as the search progresses and the short strokes are gradually grouped together. 4. Evaluation of gap consistency:  
Following again the perceptual principle of similarity, the algorithm assumes that only dashes that are separated by similar gaps may belong to a single dashed stroke. Therefore, <avgLength> is used to calculate the gap range for currently visible dashes, which is computed as follows:  
\[DashGapMin=\frac{avgLength}{DashGapShortRange}\]  
\[DashGapMax=avgLength\cdot DashGapLongRange \tag{4}\]  
where _DashGapShortRange_ specifies how much shorter the fictitious segment connecting two consecutive tips must be than the average dash to be excluded (default: 10 times shorter). _DashGapLongRange_ indicates how much longer this segment must be than the average dash to be excluded (default: 2 times longer). Subsequently, candidate dashes with gaps outside the range [DashGapMin, DashGgapMax] are temporarily discarded and labeled as currently non-visitable. 5. Straightness check:  
Straightness of dashes is evaluated after the chain is complete.