# Sketch-Guided Topology Optimization with Enhanced Diversity for Innovative Structural Design
## 3 Method
### Sketch-Based Constraints  
Free-hand sketches are intuitive for designers to express ideas. Some aspects of sketch images such as line thickness or shading variations are irrelevant to the desired structural topology, and the sketch can be simply decomposed into open-stroke elements and closed-shape elements. Corresponding constraint terms tailored to the unique characteristics of strokes and closed shapes are introduced. Strokes reflect the designer's intended structural boundaries without imposing constraints on material distribution in adjacent regions. During the early design ideation, designers typically conceptualize characteristic lines that capture key stylistic or visual features rather than defining precise shapes. To accommodate this, a stroke-based constraint is introduced, ensuring that the structural boundaries of the generated design align with the sketched strokes while maintaining a degree of freedom in neighboring regions to facilitate further exploration of the design space. The proposed constraint is an undirected structural boundary constraint, where the loss is computed based on the similarity between current structural boundaries and the sketched strokes, as described in Equation (8). \[L_{edge}=\sum_{i,j}\bigl{(}\mathbf{R}I_{i,j}-\overline{E}_{i,j}\bigr{)}^{2}\cdot \mathbb{I}_{[\mathbf{R}I_{i,j}>0.5]} \tag{8}\]  
where \(\mathbf{R}I\) represents the sketch image normalized to [0,1], \(\overline{E}\) represents the current structural boundaries within the design domain, and \(\mathbb{I}_{[:]}\) is the indicator function. The structural boundaries are extracted by a differentiable convolution operator on the density distribution map, where the convolution kernel is the edge-detecting Sobel operator, as shown in Equations (9)-(11). The density distribution map is obtained by forward computation of the density function at uniformly sampled grid points. In experiments, the sample grid resolution is taken as the image resolution of the sketch for convenience. \[\mathbf{E}=\sqrt{\bigl{(}\mathbf{I}*\mathbf{K}_{x}\bigr{)}^{2}+\bigl{(}\mathbf{I}*\mathbf{K}_{y} \bigr{)}^{2}+\epsilon} \tag{9}\]  
\[\mathbf{E}^{*}=\frac{\mathbf{E}-\min(\mathbf{E})}{\max(\mathbf{E})-\min(\mathbf{E})} \tag{10}\]  
\[\overline{\mathbf{E}}=\mathbf{E}^{*}\cdot\mathbb{I}_{[(i,j)\in\mathbf{P}]} \tag{11}\]  
where \(\mathbf{I}\) is the density distribution map, \(*\) is the convolution operator, \(\mathbf{K}_{x}\) and \(\mathbf{K}_{y}\) are the Sobel kernels along the x- and y-directions, respectively, \(\epsilon\) is a small constant to avoid division by zero (in experiments, \(\epsilon=1\times 10^{-6}\)), and \(\mathbf{P}\) is the non-design field within the density distribution map. The sketch-based constraint is transformed into a penalty loss term for the neural density function. Since the steps of structural boundary extraction and constraint loss computation are differentiable, sensitivity analysis for this constraint term can be automated through the back-propagation of the neural network. In experiments, morphological dilation is applied to preprocess the sketch image to improve the saliency of strokes, and the weight coefficient of this constraint is gradually increased as similar to the volume constraint. The closed-shape elements not only contain contour lines, which reflect the intended structural boundaries, but also signify the visual integrity of the drawn shape by the closure of the contours. Based on this, a direct way to apply a constraint is to make the closed shape directly represent a cavity or a solid. This study presents a more flexible constraint that drives the material distribution within the closed-shape region to be nearly uniform while allowing some variation. It is transformed to a penalty loss term, thereby enforcing a soft constraint to achieve visual integrity. The calculation of this loss term is shown in Equation (12).