# On Modeling Antennas Using MoM-Based Algorithms: Wire-Grid versus Surface Triangulation
## 2 Materials and Methods
### Algorithm of Combining Wire- and Triangle-Grid  
Many attempts were made to build an automated mesh generator. For example, in NEC, the complex-body structure interpolation and meshing program was embedded [344]. But to the best of our knowledge, there is no such generator that can build a wire-grid using a triangular cell form. Therefore, an additional module with this feature was developed and added to the Wire-Grid code. This module can build a wire-grid model of any structure automatically based on the structure mesh generated by Triangle-Grid.  
Now, we will discuss the auxiliary module that facilitates communication between the codes described above. This module acts as an interface between the two codes and enables the transfer of the mesh data between them. The user can now easily create an antenna mesh in Triangle-Grid and import it into Wire-Grid for further processing. This integration eliminates the manual effort of entering wire segment lines, saves time, and reduces the possibility of errors in the antenna structure.  
The Triangle-Grid code stores the antenna model mesh data as two vectors: \(p\), which contains objects of the \(gp\_Pnt\) class, which defines a three-dimensional Cartesian point, and \(t\), which stores tuples of indices of three points in vector \(p\) that form a triangle. Directly transferring all triangle segments into the Wire-Grid program code could lead to duplicate segments, resulting in errors when calculating the antenna pattern. To mitigate this issue, a unique vector of index pairs that form the edges of triangles must be generated before importing the mesh from Triangle-Grid into Wire-Grid. Additionally, care must be taken to properly set the antenna excitation source in Wire-Grid, which is represented as a separate wire and must coincide with the ends of other segments in the mesh.  
The Triangle-Grid user interface has a feature called \"Export to Wire-Grid\" located in the \"Mesh settings\" section. This feature generates a special text file with the grid coordinates of the antenna model. The first two lines of the file contain the coordinates of the start and end of the antenna source segment, and the rest of the lines contain the coordinates of the wire segments. This file is then processed by the mesh import module on the Wire-Grid side. The mesh import module is a separate program written in Python, using the ktinter library to create the user interface [345].  
Figure 12 presents a block diagram of the mesh export/import function used by Triangle-Grid. This function converts the CGAL mesh into a text file without any duplicate edges. The process starts by creating a data structure, known as an associative container. This container links keys (pairs of indexes) to values (boolean flags indicating the presence of an edge in the mesh). The algorithm then goes through each triangle in the mesh, creating pairs of indexes for the edges of each triangle. If the container does not already have this edge or its inverse, it adds the edge to the container. Finally, the algorithm generates a text document with all the information stored in the container, including the coordinates of each unique grid segment. Figure 13 shows an example of employing the proposed here algorithm on the example of a four waveguide-fed horn antenna.  
Figure 12: Block diagram of the mesh import function from Triangle-Grid to Wire-Grid.  
Figure 13: Structure of a four waveguide-fed horn antenna (**a**) and its mesh using Triangle-Grid (**b**) and import function (**c**).