## 3 Program Development and Implementation
### Data Integration and Conversion  
After filtering the data, we obtained two CSV files containing information about the positions of pipeline network elements and controls. We then performed the following conversion steps on these two files. First, the labels obtained from object detection were not numbered, so we needed to number the targets. The numbering method was as follows: based on the co-ordinates of the center points, we numbered them first by the \(X\)-axis co-ordinates in ascending order. If the \(X\)-axis co-ordinates were the same, they were numbered by the \(Y\)-axis co-ordinates in ascending order. For the WPF control components, only the center point co-ordinates were retained, and other unnecessary co-ordinates were removed. For the pipeline segments, in order to combine them into a complete pipeline network, we not only needed the co-ordinates for the top-left, top-right, bottom-left, bottom-right, and center points but also calculated and added the midpoints of the two shortest edges. These co-ordinates were saved in the last two columns of the file, named \"nearest_midpoint\" and \"second_nearest_midpoint\", respectively. The \"nearest_midpoint\" column holds the point with the smaller \(X\)-axis value and, if the \(X\)-axis values were the same, the smaller \(Y\)-axis point was used. After calculating the required co-ordinates, we combined all the recognized elements into a ship's pipeline network and imported them into a C# program for computation. The first column of the network file is named \"PipeID\", which contains the names of the pipeline segments, and only the segment numbers recognized from the SVG file need to be extracted, as the pipeline segments are the most important part of the network. The second column of the network file is named \"Name\", which contains the names of the control elements on the pipeline segments. When the program determines that a pipeline segment overlaps with a WPF control (by calculating the distance between the centerline formed by the midpoints of the two shortest edges of the pipeline segment and the center point of the control and, if it is less than 50, it is considered overlapping), the program fills the corresponding cell with the name of the control. The third column of the network file is named \"PipeDirection\", which contains the flow direction of the pipeline segment. The program determines this based on the type of overlapping arrow. If it is a Right Arrow or Down Arrow, the cell will contain \"AB\". If it is a Left Arrow or Up Arrow, the cell will contain \"BA\". If there is no arrow, \"CC\" is entered, indicating that the fluid can flow in both directions. The fourth and fifth columns of the network file are named \"PipeConnectA\" and \"PipeConnectB\", respectively, and they record the co-ordinates that overlap with the \"nearest_midpoint\" and \"second_nearest_midpoint\" columns (top-left and bottom-right co-ordinates) from the SVG result file. When the program determines that the \"nearest_midpoint\" of Pipe1 overlaps with the \"second_nearest_midpoint\" of Pipe2, it fills \"2B\" in Pipe1's \"PipeConnectA\" column and \"1A\" in Pipe2's \"PipeConnectB\" column. If multiple pipelines overlap, they are separated by commas. If the result in the third column is \"AB\" and there is no result in the fifth column (i.e., there is no pipeline segment connected in the \"PipeConnectorB\" column), the corresponding cell in the seventh column is filled with \"TURE\", indicating that the segment is a terminal segment. Similarly, if the result in the third column is \"BA\" and there is no result in the fourth column (i.e., there is no pipeline segment connected in the \"PipeConnectorA\" column), the corresponding cell in the seventh column is filled with \"TURE\", indicating that the segment is a terminal segment.