Ship root file analysis method, system and equipment

By preprocessing and logically segmenting the ship's root file, multi-format files are generated, solving the problems of low accuracy and efficiency in existing technologies. This achieves efficient and accurate file parsing and multi-format output, meeting the production needs of modern shipbuilding enterprises.

CN121144262APending Publication Date: 2025-12-16湖南天桥嘉成智能科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511142526.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-15
Publication Date
2025-12-16

AI Technical Summary

Technical Problem

Existing technologies suffer from low accuracy and efficiency in parsing ship root files, and the parsing results are limited. They cannot accurately identify semantically significant paragraphs, leading to tag mismatches and field omissions. Furthermore, they exhibit significant performance bottlenecks when processing extremely large files, making it difficult to meet the production pace demands of modern shipbuilding enterprises.

Method used

By preprocessing the ship's root file, initializing the operating environment, generating a standardized list of root file paths, and performing logical segmentation parsing based on preset structure tags, the system generates primitive files, structured data files, CNC instruction files, and statistical files, supporting the output of parsing results in multiple formats.

Benefits of technology

It improves parsing accuracy, enables the output of parsing results in multiple formats to meet the application needs of different scenarios, optimizes the processing flow, reduces resource consumption, and improves overall parsing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121144262A_ABST
    Figure CN121144262A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of file analysis, and discloses a ship root file analysis method, system and equipment, and the method comprises the steps: carrying out the preprocessing of an input ship root file, initializing an operation environment, and obtaining a normalized root file path list; according to a preset structure label in the ship root file, performing logic segmentation analysis on the content of the ship root file to obtain a contour data block; generating a primitive file, a structured data file, a numerical control instruction file and a statistical file according to the contour data block; and summarizing the visual file, the structured data file, the numerical control instruction file and the statistical file, releasing resources occupied in the running process, and outputting all the summarized files to a specified directory. According to the method, the ship root file can be completely analyzed to obtain the structured data of each part in the ship root file, so that the output of a multi-format analysis result is realized, and the analysis precision and efficiency of the ship root file are integrally improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of file parsing, more particularly, to a ship root file parsing method, system and device. BACKGROUND

[0002] In the process of digital design and manufacturing of shipbuilding industry, accurately and efficiently converting the root file generated by the upstream CAD / CAPP system into machining instructions executable by the numerical control machine tool is an important basis for realizing the integration of design and manufacturing. As an intermediate data format widely used in the industry, the ship root file (such as.gen file) carries core manufacturing data such as raw material information, part arrangement, contour path, and is widely used in automatic manufacturing links such as steel plate cutting and part machining. It is usually composed of multiple logical paragraphs, including general material information, part parameter information and different types of contour data blocks; however, due to differences in root file standards used by different shipyards, systems and software versions, including field naming, paragraph structure, file coding and contour representation, the parsing and automatic processing thereof face great technical challenges.

[0003] In the prior art, some traditional methods only support the parsing of root files into single metafile for visualization, the processing logic is simple and the function is single, there is a lack of deep understanding of the file content, and multiple structured information cannot be output, making it difficult to support subsequent numerical control programming and multi-department data flow; some enterprises use general tools for data extraction, but since such tools are not designed specifically for ship root file format, they cannot accurately identify paragraphs with strong semantics, often resulting in label mismatch, field omission and contour parsing failure, which affects data quality; at the same time, the traditional large file processing architecture has performance bottlenecks when facing ship-level super-large root files, and when processing a large number of parts and contours, it is time-consuming and prone to crash, making it difficult to meet the production rhythm needs of modern shipbuilding enterprises. These existing technologies generally have the defects of low precision and efficiency and single parsing result. SUMMARY

[0004] To overcome the defects of low precision and efficiency and single parsing result of existing root file parsing methods, the present application proposes the following technical solutions: In a first aspect, the present application proposes a ship root file parsing method, comprising: preprocessing the input ship root file, initializing the running environment, and obtaining a standardized root file path list; logically segmenting and parsing the content of the ship root file according to the preset structure tag in the ship root file, to obtain a contour data block; generating a metafile, a structured data file, a numerical control instruction file and a statistical file according to the contour data block; The visual file, the structured data file, the numerical control instruction file and the statistical file are aggregated, resources occupied in a running process are released, and all the aggregated files are output to a specified directory.

[0005] As a preferred technical solution, the input ship root file is preprocessed, the running environment is initialized, and a normalized root file path list is obtained, including: The input ship root file path and its subdirectories are traversed to identify files with a.gen suffix or containing a.gen feature keyword; If the ship root file path corresponds to a zip format compressed package, the zip format compressed package is decompressed to a temporary directory, and then the files with a.gen suffix or containing a.gen feature keyword are extracted from the decompressed content; The running environment is initialized, a log recorder, a character encoding detection module and an output path are created; The paths of the identified and extracted files with a.gen suffix or containing a.gen feature keyword are normalized, duplicate paths are removed, and a normalized path list of the files is generated.

[0006] As a preferred technical solution, the ship root file content is logically segmented and parsed according to a preset structure tag in the ship root file to obtain a contour data block, including: Different types of contour storage lists and state variables required for parsing are initialized; The ship root file is read line by line, when a contour start flag corresponding to a preset structure tag is detected, a contour parsing process is started, the content in the contour is parsed segment by segment, and the contour data of each contour including line segment type, coordinates and related parameters are extracted; The parsed contour data is classified and stored according to space, mark, cutting and bevel types to generate a contour list; The contour list is sequentially subjected to line segment number, coordinate legality and closure verification and then aggregated to obtain a contour data block.

[0007] As a preferred technical solution, the graphic element file includes a DXF file and a PNG file; According to the contour data block, the DXF file is generated, including: A DXF file instance is created; The contours in the contour data block are traversed, and the corresponding color is obtained according to the preset structure tag corresponding to the contour; The line segments of each contour are traversed, if it is a straight line, a straight line entity is created according to the coordinates of the line segment, if it is a circular arc, a circular arc entity is created according to the center, starting angle and ending angle of the line segment, the straight line entity or the circular arc entity is added to the DXF file instance and saved to a specified path; Generating a PNG file based on the outline data block includes: Create a drawing surface, obtain a canvas and set a white background, and configure anti-aliasing drawing and contour closure detection parameters; Traverse the contour line segments in the contour data block and calculate the extreme value range of the line segments' coordinates; Calculate the scaling ratio and offset based on the drawing surface dimensions and the extreme value range of the coordinates; The coordinates of the contour line segments are transformed based on the scaling ratio and offset; Traverse the contour segments after coordinate transformation. If it is a straight line, draw it according to the coordinates of the two points of the contour segment; if it is an arc, determine the arc type, calculate the corresponding parameters of the arc, and draw it according to the corresponding parameters of the arc. Convert the drawn surface into an image, encode it as a PNG file, and save it to the specified path.

[0008] As a preferred technical solution, the structured data file includes JSON files and TXT files; Generating a JSON file based on the contour data block includes: Read all lines of the root file, create a dictionary to store the parsed results, as well as a key-value storage structure or a table storage structure, and initialize the row index; Based on the block markers in the root file, the data segments corresponding to GENERAL_DATA, PART_DATA, IDLE_DATA, and BURNING_DATA are parsed in blocks; The parsing results of each data segment are stored in the dictionary, the key-value storage structure, or the table storage structure, respectively. The dictionary is serialized into a JSON file, and the key-value storage structure or the table storage structure is written into a TXT file according to the specified format and output to the specified path.

[0009] As a preferred technical solution, the CNC instruction file is a .nc format G-Code file; generating the CNC instruction file based on the contour data block includes: Create a file write object, write the file start symbol, and set the units, coordinate system, and current position; Filter the empty line segment type contours from the contour data block, merge continuous empty line segments, and update the coordinates of the end point of the empty line segment. Traverse the contours in the contour data block, skip contours without segments, and perform a fast move to the corresponding contour start point for contours of the cutting, marking, or bevel categories. Traverse the contour segments processed in the above steps, and generate CNC instructions according to the contour category and segment type. For idle segments, generate G00 CNC instructions; for straight-line cutting segments, generate G01 CNC instructions; for arc-cutting segments, generate G02 or G03 CNC instructions based on the arc sweep direction. For non-idle contours, write the program end CNC instruction. Save the generated CNC instructions as a .nc file.

[0010] As a preferred technical solution, the statistical file includes an Excel file in .xlsx format; generating the statistical file based on the contour data block includes: Traverse the contour data block and root file contents, identify part information and bevel-related markers, and determine whether the part has a defined bevel. For parts with defined bevels, calculate the length of their bevel segments and summarize the total length of the bevels of the parts. Extract the first attribute information, including part number, assembly number, segment number, ship number, part length, part width, and part area; The calculation includes second attribute information such as part weight, part center of gravity, length and width of the part's minimum bounding rectangle, and total outline length of the part. Statistical data is constructed based on the bevel segment length, the total bevel length of the total parts, the first attribute information, and the second attribute information; Generate an Excel file in .xlsx format using the statistical data in a multi-worksheet structure, and save it to the specified path.

[0011] As a preferred technical solution, the metafile further includes a contour visualization file, and the method further includes: Create a drawing object and set the canvas background; Receive the list of cutting contour data and the list of bevel contour data, determine whether to merge the bevel contour into the cutting contour, if merged, copy the cutting contour, traverse the bevel contour, and replace the part of the cutting contour that overlaps with the bevel contour. Calculate the coordinate range of all contours, and determine the scaling ratio and offset based on the coordinate range and the preset image size; Process the outline data according to the scaling ratio and offset, and draw the processed outline data onto the canvas. Convert the drawing object into an image, encode it as a PNG format outline visualization file, and save it to the specified path.

[0012] Secondly, the present invention also proposes a ship root file parsing system, applied to the ship root file parsing method as described in any of the embodiments of the first aspect, comprising: The preprocessing module is used to preprocess the input ship root files, initialize the runtime environment, and obtain a normalized list of root file paths. The parsing module is used to logically segment and parse the contents of the ship root file according to the preset structure tags in the ship root file to obtain the outline data block; The generation module is used to generate primitive files, structured data files, CNC instruction files, and statistical files based on the contour data blocks; The summary module is used to summarize the visualization file, the structured data file, the CNC instruction file, and the statistical file, release the resources occupied during operation, and output all summarized files to a specified directory.

[0013] Thirdly, the present invention also proposes an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to perform the operations performed by the ship root file parsing method as described in any of the embodiments of the first aspect.

[0014] The beneficial effects of the present invention include at least the following: This invention preprocesses the input ship root file and initializes the runtime environment to obtain a standardized root file path list, reducing parsing errors caused by disordered file paths or improper environment configuration, thus laying a precise foundation for subsequent processing. Based on this, the root file content is logically segmented and parsed according to preset structure tags to accurately and completely obtain contour data blocks. Orderly segmentation avoids information confusion and omissions, further improving parsing accuracy. Based on the obtained contour data blocks, primitive files, structured data files, CNC instruction files, and statistical files are generated, enabling multi-format parsing result output to meet the application needs of different scenarios. Finally, by summarizing various files and releasing runtime resources, the processing flow is optimized, unnecessary resource consumption is reduced, and overall parsing efficiency is improved. Attached Figure Description

[0015] Figure 1 This is a flowchart illustrating the ship root file parsing method provided in an embodiment of the present invention.

[0016] Figure 2 This is a flowchart illustrating the preprocessing of an input ship root file, as provided in an embodiment of the present invention.

[0017] Figure 3 This is a flowchart illustrating the logical segmentation and parsing of the ship root file content, provided as an embodiment of the present invention.

[0018] Figure 4 This is a flowchart for generating a DXF file according to an embodiment of this application, based on the contour data block.

[0019] Figure 5This is a schematic diagram of a DXF file obtained after parsing the gen file provided in this application embodiment.

[0020] Figure 6 This is a PNG diagram obtained after parsing the gen file provided in the embodiments of this application.

[0021] Figure 7 This is a flowchart illustrating the generation of PNG files provided in an embodiment of this application.

[0022] Figure 8 This is a visualization of the G-code obtained after parsing the gen file, as provided in an embodiment of the present invention.

[0023] Figure 9 This is a flowchart for extracting the bevel length provided in an embodiment of the present invention.

[0024] Figure 10 This is a flowchart illustrating the export of statistical files provided in an embodiment of the present invention.

[0025] Figure 11 This is a visualization of the statistical file provided in an embodiment of the present invention.

[0026] Figure 12 This is a flowchart illustrating the generation of the outline visualization file provided in the embodiments of this application.

[0027] Figure 13 This is an architecture diagram of the ship root file parsing system provided in an embodiment of the present invention.

[0028] Figure 14 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0029] The embodiments of the present invention will be described below with reference to the accompanying drawings and preferred technical solutions. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred technical solutions are only for illustrating the present invention and not for limiting the scope of protection of the present invention.

[0030] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0031] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.

[0032] Example 1 This embodiment proposes a method for parsing ship root files, such as... Figure 1 As shown, Figure 1 This is a flowchart illustrating a ship root file parsing method provided in this embodiment. The method includes the following steps: S1: Preprocess the input ship root file, initialize the runtime environment, and obtain a normalized list of root file paths; S2: Based on the preset structure tags in the ship root file, the contents of the ship root file are logically segmented and parsed to obtain the outline data block; S3: Generate a primitive file, a structured data file, a numerical control instruction file, and a statistical file based on the contour data block; S4: Summarize the visualization file, the structured data file, the CNC instruction file, and the statistical file, release the resources occupied during operation, and output all the summarized files to the specified directory.

[0033] Understandably, by preprocessing the input ship root file and initializing the runtime environment to obtain a standardized list of root file paths, parsing errors caused by disordered file paths or improper environment configuration are reduced, laying a precise foundation for subsequent processing. Based on this, the root file content is logically segmented and parsed according to preset structure tags to accurately and completely obtain contour data blocks. Orderly segmentation avoids information confusion and omissions, further improving parsing accuracy. Based on the obtained contour data blocks, primitive files, structured data files, CNC instruction files, and statistical files are generated, enabling the output of parsing results in multiple formats to meet the application needs of different scenarios. Finally, by summarizing various files and releasing runtime resources, the processing flow is optimized, unnecessary resource consumption is reduced, and overall parsing efficiency is improved.

[0034] Example 2 This embodiment is an improvement on the ship root file parsing method proposed in Embodiment 1.

[0035] like Figure 2 As shown, Figure 2 This is a flowchart illustrating the preprocessing of an input ship root file provided in an embodiment of the present invention. In this embodiment, the input ship root file is preprocessed to initialize the runtime environment and obtain a standardized root file path list, including: Traverse the input ship root file path and its subdirectories to identify files with the .gen suffix or containing the .gen keyword; If the ship root file path corresponds to a zip format compressed package, decompress the zip format compressed package to a temporary directory, and then extract files with the .gen suffix or containing the .gen keyword from the decompressed contents; Initialize the runtime environment, and create a logger, a character encoding detection module, and an output path; The paths of files with the .gen suffix or containing the .gen keyword are normalized to remove duplicate paths and generate a normalized path list for the files.

[0036] As an example, after the system starts, it first creates an empty list to store the paths of the .gen files to be parsed, and defines a recursive search function to traverse the input paths and their subdirectories. Then, the input paths are normalized to obtain their absolute paths and their validity is verified: if the input is a .gen file, its path is directly added to the results list; if it is a .zip compressed file, the built-in decompression tool is used to decompress it to a temporary directory, and then the defined recursive search function is used to filter for .gen files in the decompressed contents; if it is a directory, all subdirectories under that directory are traversed, recursively identifying .gen files and files containing the .gen keyword; if the input path is invalid, the system records an error log and interrupts the process.

[0037] In critical processing stages, the system initiates asynchronous tasks via Task.Run to perform compressed file decompression and character encoding recognition operations in parallel. The logging system, built on Serilog, records the entire process information. Simultaneously, a character encoding detection module is initialized. This module analyzes file header identifiers and character distribution to automatically identify and convert GBK and UTF-8 encodings, resolving garbled text issues caused by traditional hard-coded character sets. When creating output paths, the system automatically detects conflicts; if duplicate paths exist, a timestamp is appended to generate a new path.

[0038] Understandably, traditional methods often experience process interruptions during path resolution due to insufficient compatibility with nested file paths, missing encoding processing, and file conflicts. This stage addresses these issues by employing a recursive search mechanism to adapt to multi-level nested directories and compressed file structures, combined with automatic encoding recognition technology, significantly improving the robustness and fault tolerance of multi-source input processing. Finally, the system deduplicates the identified .gen file paths, generates a standardized list of absolute paths, records the number of files, and provides this information for use in downstream parsing stages.

[0039] like Figure 3 As shown, Figure 3This is a flowchart of logical segmentation and parsing of the ship root file content provided in an embodiment of the present invention. In this embodiment, the ship root file content is logically segmented and parsed according to preset structure tags in the ship root file to obtain contour data blocks, including: Initialize different types of contour storage lists and the state variables required for parsing; The ship root file is read line by line. When the contour start mark corresponding to the preset structure label is detected, the contour parsing process is started. The content within the contour is parsed segment by segment, and the contour data of each contour, including line segment type, coordinates and related parameters, is extracted. The parsed contour data is classified and stored according to the type of empty space, marker, cut and bevel, and a contour list is generated. After sequentially verifying the number of line segments, the validity of coordinates, and the closure of the contour list, the data is summarized to obtain the contour data block.

[0040] As an example, the system first initializes the contour storage lists for cutting, idle stroke, marking, and bevel types, as well as the state variables required for parsing. Then, it reads the ship's root file line by line. When it detects a contour start marker corresponding to a preset structural label such as BURNING_DATA (part data), IDLE_DATA (idle stroke data), MARKING_DATA (marking data), or BEVEL_DATA (bevel data), it calls ContourParserService to initiate the contour parsing process. This service parses the information within each contour segment by segment, extracting parameters such as line segment type, start and end point coordinates, arc radius, and angle for each contour. The parsed data is then categorized by idle stroke, marking, cutting, and bevel type and stored in the corresponding lists.

[0041] Simultaneously, during file traversal, the system synchronously processes part information statistics: if a line starting with PART_DATA is detected, it is marked as entering the part data block and the current part attribute dictionary is reset; if a line starting with END_OF_PART_DATA is detected, the current part information is added to the result list and the part data block is marked as leaving. Within the part data block, if the current line contains an equals sign separator, it is split into key-value pairs and stored in the current part attribute dictionary.

[0042] After contour parsing, the system sequentially checks each contour list to ensure the number of line segments conforms to the rules, the coordinates are within the valid machining range, and the contour is closed (a very small deviation between the first and last coordinates, such as 1e-5, is considered closed). The parsing process uses string matching instead of regular expressions to avoid ambiguity and ensure contour continuity and directional consistency. Finally, the system returns a categorized list of contour data and a list of part information, providing support for subsequent graphical and NC code generation functions.

[0043] In this embodiment, the metafile includes DXF files and PNG files; like Figure 4 As shown, Figure 4 The flowchart for generating a DXF file provided in this application embodiment includes the following steps based on the contour data block: Create a DXF file instance; Traverse the contours in the contour data block and obtain the corresponding colors according to the preset structure labels corresponding to the contours; Traverse the line segments of each contour. If it is a straight line, create a straight line entity based on the coordinates of the line segment. If it is an arc, create an arc entity based on the center, start angle and end angle of the line segment. Add the straight line entity or arc entity to the DXF file instance and save it to the specified path. Generating a PNG file based on the outline data block includes: Create a drawing surface, obtain a canvas and set a white background, and configure anti-aliasing drawing and contour closure detection parameters; Traverse the contour line segments in the contour data block and calculate the extreme value range of the line segments' coordinates; Calculate the scaling ratio and offset based on the drawing surface dimensions and the extreme value range of the coordinates; The coordinates of the contour line segments are transformed based on the scaling ratio and offset; Traverse the contour segments after coordinate transformation. If it is a straight line, draw it according to the coordinates of the two points of the contour segment; if it is an arc, determine the arc type, calculate the corresponding parameters of the arc, and draw it according to the corresponding parameters of the arc. Convert the drawn surface into an image, encode it as a PNG file, and save it to the specified path.

[0044] As an example, such as Figure 5 , Figure 6 and Figure 7 As shown, Figure 5 This is a schematic diagram of the DXF file obtained after parsing the gen file provided in the embodiments of this application. Figure 6 The image shown is a PNG diagram obtained after parsing the gen file provided in this embodiment of the application. Figure 7The flowchart for generating a PNG file provided in this application embodiment describes the process for generating a DXF file. When generating a DXF file, a DXF document instance is created, the contours in the contour data block are traversed, and colors are obtained according to the color rules corresponding to preset structure labels (e.g., red for part contour BURNING_DATA, green for idle contour IDLE_DATA, blue for drawing contour MARKING_DATA, and orange for bevel contour BEVEL_DATA). Then, the line segments of each contour are traversed. If it is a straight line, a straight line entity is created based on the line segment coordinates; if it is an arc, an arc entity is created based on the center, start angle, and end angle of the line segment. The straight line or arc entity is added to the DXF document instance and saved to a specified path. When generating a PNG file, a drawing surface is created and a canvas is obtained, filled with a white background, and anti-aliasing drawing and contour closure detection parameters are configured. Traverse the contour line segments in the contour data block and calculate the extreme value range of the line segments' coordinates according to the following formula:

[0045]

[0046]

[0047]

[0048] Where seg is the outline line segment. X 1 is the first point of the line segment X coordinate, Y 1 is the first point of the line segment Y coordinate, X 2 is the second point of the line segment. X coordinate, Y 2 is the second point of the line segment. Y The coordinates are defined by the functions `min()` (minimum value) and `max()` (maximum value). This set of formulas iterates through all contour segments, finding the minimum, minimum, maximum, and maximum X and Y values ​​among all point coordinates. Then, based on the drawing surface dimensions and the range of coordinate extreme values... The formula for calculating the image size scaling ratio is as follows:

[0049]

[0050]

[0051] In this formula, the scaling ratios in the X-axis and Y-axis directions are calculated separately, and then the smaller of the two values ​​is taken as the final scaling ratio. This is done to ensure that the outline can be fully displayed in the image in both the X-axis and Y-axis directions, and to avoid the outline from exceeding the image range due to an excessively large ratio in one direction, thereby ensuring that the outline in the primitive file is not distorted.

[0052] The offset calculation formula is as follows:

[0053]

[0054] This formula calculates the offsets along the X and Y axes to correctly map the contour data onto the image. When calculating the offsets, 50 represents a 50-pixel margin around the image. By calculating offsetX and offsetY, the origin of the contour data's coordinates is mapped to the image's drawing area, ensuring the contour is centered within the image. For example, subtracting minX*scale from offsetX moves the point corresponding to the smallest X coordinate to a position 50 pixels from the left side of the image; similarly, adding maxY*scale to offsetY moves the point corresponding to the largest Y coordinate to a position 50 pixels from the top of the image.

[0055] The calculation is performed based on the following coordinate transformation formula:

[0056]

[0057]

[0058]

[0059] In this formula, the original contour coordinates are converted into drawing coordinates on the image, and the Y-axis is flipped to fit the image coordinate system (the positive direction of the Y-axis in the image coordinate system is downward).

[0060] Based on the calculated scaling and offset, all contour data is drawn onto the canvas. If anti-aliasing is enabled during the initialization phase, the drawn lines will have smoother edges and a better visual effect; if automatic contour closure detection is enabled, the system will check whether each contour is closed, and may automatically close any unclosed contours.

[0061] The arc type and drawing direction are determined according to the following formula:

[0062]

[0063] This formula is used to determine whether an arc is a large or small arc, and whether the arc is drawn in a clockwise or counterclockwise direction.

[0064] After calculating the parameters corresponding to the arc, the drawing is performed. Finally, the drawn surface is converted into an image, encoded as a PNG format, and saved to the specified path.

[0065] Understandably, by calculating coordinate scaling and offset, the outline is ensured to be displayed centered in the image without distortion; the added optional settings (anti-aliasing drawing and automatic outline closure detection) improve the system's flexibility, which helps to visualize the outline data of various parts in the shipbuilding industry and improves the efficiency and quality of related processing links.

[0066] In this embodiment, the structured data file includes JSON files and TXT files; Generating a JSON file based on the contour data block includes: Read all lines of the root file, create a dictionary to store the parsed results, as well as a key-value storage structure or a table storage structure, and initialize the row index; Based on the block markers in the root file, the data segments corresponding to GENERAL_DATA, PART_DATA, IDLE_DATA, and BURNING_DATA are parsed in blocks; The parsing results of each data segment are stored in the dictionary, the key-value storage structure, or the table storage structure, respectively. The dictionary is serialized into a JSON file, and the key-value storage structure or the table storage structure is written into a TXT file according to the specified format and output to the specified path.

[0067] As an example, the process begins by reading all lines of the .gen file, creating a dictionary to store the parsed results, and initializing the line indexes to construct a key-value storage structure or a table storage structure. Then, based on the block markers such as GENERAL_DATA, PART_DATA, IDLE_DATA, and BURNING_DATA in the root file, the corresponding methods are called to parse each data segment in blocks. During parsing, the contour information is nested; for example, BEVEL_DATA is nested within BURNING_DATA to facilitate finding the part contour to which the bevel contour belongs. The parsing results of each data segment are stored in the dictionary, key-value pairs, and table structures, respectively.

[0068] Next, the dictionary is serialized into a JSON file, following the standard JSON Schema format and using UTF-8 encoding to support multilingual character processing. Simultaneously, the key-value or table storage structure is written into a TXT file for easy manual review and traceability. From file reading and block parsing to data export, a modular design enables efficient processing. The exported structured data can serve as an intermediate format for system integration, improving the efficiency and accuracy of data processing in the shipbuilding industry.

[0069] Understandably, existing technologies rely on Excel macros, Python scripts, or general text extraction tools to process .gen files. Because these are not designed for the shipbuilding industry's format, they cannot accurately identify semantic paragraphs such as END_OF_PART_INFORMATION, often resulting in label mismatches, field omissions, and contour parsing failures, leading to a decline in data quality. This invention, based on a label-driven and state-controlled parsing model, precisely parses specific data blocks in the shipbuilding root file (such as GENERAL_DATA~END_OF_GENERAL_DATA, PART_DATA~END_OF_PART_DATA, IDLE_DATA~END_OF_IDLE_DATA, etc.), extracting metafiles, detailed part information, and data required for nesting calculations, ensuring the accuracy and professionalism of data parsing in the shipbuilding industry.

[0070] Understandably, existing technologies mostly employ linear export methods for parsing .gen files, supporting only the parsing of .gen files into DXF metafiles for design visualization, or only the generation of Gcode CNC code from DXF files. These methods have simple processing logic, limited functionality, and lack a deep understanding of the file content, failing to meet the data flow needs of enterprise-level multi-system systems. This invention, by accurately parsing the detailed contour information of ship parts, constructs refined structured object objects for these parts, realizing a single-source input, multi-source output visualization and collaboration framework. It supports exporting multiple file formats such as DXF (metafile design), PNG (visual display), NC (CNC machining), and JSON / TXT (structured data interaction), covering the entire data flow scenario from design and manufacturing to statistics, meeting the collaborative needs of multiple departments.

[0071] In this embodiment, the CNC instruction file is a .nc format G-Code file; generating the CNC instruction file based on the contour data block includes: Create a file write object, write the file start symbol, and set the units, coordinate system, and current position; Filter the empty line segment type contours from the contour data block, merge continuous empty line segments, and update the coordinates of the end point of the empty line segment. Traverse the contours in the contour data block, skip contours without segments, and perform a fast move to the corresponding contour start point for contours of the cutting, marking, or bevel categories. Traverse the contour segments processed in the above steps, and generate CNC instructions according to the contour category and segment type. For idle segments, generate G00 CNC instructions; for straight-line cutting segments, generate G01 CNC instructions; for arc-cutting segments, generate G02 or G03 CNC instructions based on the arc sweep direction. For non-idle contours, write the program end CNC instruction. Save the generated CNC instructions as a .nc file.

[0072] As an example, such as Figure 8 As shown, Figure 8 The image shows the visualization of the G-code obtained after parsing the gen file in this embodiment of the invention. First, a StreamWriter object is created, and G-code is written to the specified path. The starting symbol is set to %, the unit is set to millimeters, and an absolute coordinate system is used, with the current position set as the origin. Then, the outline list is traversed, and the basic information of each outline and its line segments is output for debugging and inspection. Next, outlines of the IDLE category are filtered out, consecutive IDLE line segments are merged, the coordinates of the line segment endpoints are updated, and then the merged IDLE outlines are added to the non-IDLE outline list.

[0073] Then, all contours are traversed, skipping contours with no segments. For contours classified as cut, marked, or chamfered, a fast move to the starting point and device activation operation is performed. Next, the line segments of each contour are traversed, generating different G-codes based on the contour category and line segment type: G00 CNC instructions are generated for idle line segments, G01 CNC instructions are generated for straight-line cut line segments, and G02 or G03 CNC instructions are generated based on the arc sweep direction for circular cut line segments. For non-IDLE type contours, a program termination CNC instruction, such as M10, is written.

[0074] During the process, the GCodeExporterService module is used to parse the contour segment type and generate corresponding instructions, supporting special processing of bevel segments, such as adding processing instructions like M09 / M10, and constructing complete start, end, and cutting logic. At the same time, different line segments of the same contour are merged to optimize paths, maintaining the path order while performing local optimization, automatically generating instruction comments and debugging information, supporting path repositioning processing and safety height control extensions, improving processing efficiency and automation level.

[0075] Understandably, existing technologies do not optimize idle paths (IDLE segments) when exporting CNC code, leading to G-code redundancy and low machining efficiency. This invention implements idle path merging and bevel contour fusion strategies in GCodeExporterService, extracting and merging continuous IDLE segments to reduce idle movement pauses; it also merges bevel contours and cutting contours to reduce G-code complexity. After optimization, the average number of instructions is reduced by approximately 11%, and the machining path switching speed is improved by 6%, significantly enhancing the machining efficiency and instruction execution performance of CNC equipment.

[0076] In this embodiment, the statistical file includes an Excel file in .xlsx format; generating the statistical file based on the contour data block includes: Traverse the contour data block and root file contents, identify part information and bevel-related markers, and determine whether the part has a defined bevel. For parts with defined bevels, calculate the length of their bevel segments and summarize the total length of the bevels of the parts. Extract the first attribute information, including part number, assembly number, segment number, ship number, part length, part width, and part area; The calculation includes second attribute information such as part weight, part center of gravity, length and width of the part's minimum bounding rectangle, and total outline length of the part. Statistical data is constructed based on the bevel segment length, the total bevel length of the total parts, the first attribute information, and the second attribute information; Generate an Excel file in .xlsx format using the statistical data in a multi-worksheet structure, and save it to the specified path.

[0077] As an example, such as Figure 9 , Figure 10 and Figure 11 As shown, Figure 9 This is a flowchart for extracting the bevel length provided in an embodiment of the present invention. Figure 10 This is a flowchart illustrating the export of statistical files provided in an embodiment of the present invention. Figure 11 The visualization of the statistical file provided in this embodiment of the invention is shown below. The program first initializes the logger, receives a list of strings containing the file content, iterates through the list to identify key data blocks such as PART_INFORMATION and BURNING_DATA, extracts the part name, and determines whether the part has a defined bevel based on markers such as BEVEL_DEFINED. For parts with defined bevels, the length of the bevel segment is calculated. If the coordinate error between the start and end points of the segment is within 1e-5, the segment is skipped; otherwise, the segment length is calculated using a coordinate formula. The total bevel length of the parts is then obtained and stored in a dictionary with the part name as the key and the bevel length as the value. After the calculation is complete, the log is recorded and statistical information is output. The specific calculation formula is shown below:

[0078]

[0079] The process then proceeds to the Excel export stage, preparing a dictionary to store worksheet data, receiving data from multiple worksheets, the save path, and bevel length information. It iterates through the data in each worksheet, extracting the steel plate thickness, processing the metadata for each part, and checking the existence of the contour data. A row data dictionary is created, populated with information such as the .gen root file name, ship number, segment number, and part code. The bevel length is obtained from the dictionary, and then statistical information such as part weight, centroid coordinates, minimum bounding rectangle size, and total contour length are calculated. The lengths of straight line segments and arcs are calculated using corresponding formulas. The centroid is the average of all point coordinates. The approximate area is obtained using a contour algorithm, and the part weight is derived from the area, thickness, and density. The specific formulas are shown below:

[0080]

[0081] Each row of data is added to the export list and stored in the worksheet data dictionary. Ensure the save directory exists and delete any existing files. Save the data as a multi-worksheet Excel file using MiniExcel.SaveAs, supporting dynamic field mapping (configurable via Excel items in appsettings.json). Output feedback upon successful export. The entire process achieves efficient statistical analysis and structured export of part information and bevel data, facilitating nesting quantity calculations and improving data processing and analysis efficiency.

[0082] In this embodiment, the metafile further includes a contour visualization file, and the method further includes: Create a drawing object and set the canvas background; Receive the list of cutting contour data and the list of bevel contour data, determine whether to merge the bevel contour into the cutting contour, if merged, copy the cutting contour, traverse the bevel contour, and replace the part of the cutting contour that overlaps with the bevel contour. Calculate the coordinate range of all contours, and determine the scaling ratio and offset based on the coordinate range and the preset image size; Process the outline data according to the scaling ratio and offset, and draw the processed outline data onto the canvas. Convert the drawing object into an image, encode it as a PNG format outline visualization file, and save it to the specified path.

[0083] As an example, such as Figure 12 As shown, Figure 12This flowchart illustrates the process of generating a contour visualization file as provided in this application embodiment. An SKSurface drawing object is created and a canvas is obtained, filled with a white background. A list of cutting contour data and a list of bevel contour data are received, and it is determined whether to merge the bevel contour into the cutting contour. If merging is selected, a deep copy operation is performed on the cutting contour, followed by traversing the bevel contour, checking and replacing the overlapping parts of the cutting contour and the bevel contour, facilitating the viewing of the bevel processing location in subsequent processes. When a cutting segment (cutSegment) and a bevel segment (bevelSegment) overlap at the same coordinate position, the cutting segment is removed, and the bevel segment is retained. The coordinate range of all contour data is calculated, and based on this range and the preset image size, the scaling ratio and offset are determined. The contour data is processed according to this scaling ratio and offset, while optimization strategies such as sorting, line segment connection, and color marking are implemented on the contours to improve graphic recognizability and engineering guidance, avoiding redundant redrawing in DXF / PNG files. The processed contour data is drawn onto the canvas, and finally, the SKSurface is converted to an SKImage, encoded as a PNG format contour visualization file, and saved to a specified path.

[0084] Understandably, existing technologies cannot distinguish between collinear contours of industrial parts, leading to repeated cutting by cutting equipment; and the output images have obvious jagged edges, making them unsuitable for industrial visualization scenarios. This invention automatically checks the overlap of the beginning and end of the contour, automatically closing contours with a deviation of less than 1e-4 between the beginning and end nodes; it supports deduplication of collinear segments and optimization of arc segments to avoid repeated cutting. Image rendering: Utilizing the SkiaSharp rendering engine and OpenCVSharp4 image interface, an anti-aliasing rendering strategy is enabled, reducing the jagged edges of the image by approximately 27%, improving the smoothness of the output image, and adapting it to industrial visualization, visual inspection, and graphics-assisted operation scenarios.

[0085] Example 3 This embodiment uses part D303C_AH36250_02 from a major shipyard as a test sample to implement and verify the method provided in the above embodiment.

[0086] In this embodiment, the .gen file corresponding to the part contains 3993 lines of contour data and 17 part attribute fields.

[0087] Taking part D303C_AH36250_02 as an example, the system processing flow is as follows: InputHandler first reads the .gen file, supporting the processing of single files, directories, or ZIP archives; then GenParserService parses the file content, extracting structured data such as GENERAL_DATA, PART_DATA, and IDLE_DATA; next, ContourParserService parses the contour data, distinguishing different types of contours such as idle strokes, markings, cuts, and chamfers; finally, ExportService coordinates the invocation of various export service classes to export the data in formats such as JSON, TXT, DXF, GCode, PNG, and Excel.

[0088] On a standard development machine (e.g., 4-core CPU, 16GB RAM), parsing and exporting the part data takes approximately 0.02 seconds with a 100% success rate. The graphic output error is within ±0.1mm. The specific time is affected by the file size and complexity; for example, processing time will increase for complex files containing a large amount of contour data. After successful processing, the system will generate one JSON file for inter-program data exchange, one plain text TXT file for easy viewing and debugging, one CAD graphic format DXF file for subsequent design modifications, one CNC equipment general instruction set GCode file for controlling the machining equipment, one PNG image visually displaying the part contour, and one Excel statistical file containing part metadata, weight, and other statistical information (for easy calculation of nesting quantities).

[0089] Under normal circumstances, with correct file format and compatible dependencies, the processing success rate can reach 100%. In special cases, if the parsed .gen file does not conform to the parsing rules of mainstream shipyards (such as missing tabs or the use of other tags), parsing may be completed, but issues such as missing part outlines and GCode errors may occur. The system has a robust built-in exception handling mechanism: InputHandler captures read exceptions such as file non-existence and insufficient permissions, logs them, and provides user-friendly prompts; GenParserService and ContourParserService capture parsing exceptions such as format errors and missing data, and record the error context for troubleshooting; each export service class captures export exceptions such as file creation failure and unsupported format, rolls back generated files, and ensures data consistency.

[0090] To improve performance, the system employs parallel programming to handle independent parsing and exporting tasks (such as parsing different part contour data simultaneously). It caches common configurations and frequently used dictionaries to reduce redundant calculations and uses asynchronous I / O operations to avoid blocking the main thread, thus improving system response speed. The testing phase covers empty file testing (verifying the handling of empty .gen files and throwing explicit error messages), extremely large file testing (using files >50MB to verify performance stability and avoid memory overflow or processing timeouts), and boundary data testing (testing boundary data such as coordinate values ​​and line segment lengths to ensure accurate calculation results). Regarding version compatibility, the file format supports mainstream shipyard .gen files; older versions are converted using a compatibility layer, and newer versions have reserved extension interfaces. The project is developed based on .NET 8.0 and is compatible with .NET Core / .NET 5+ runtime environments. Dependencies use the latest stable versions to ensure normal functionality.

[0091] Understandably, existing technologies lack a high-performance parsing framework for ultra-large .gen files (containing thousands of parts and tens of thousands of contour segments) at the shipbuilding level. Traditional methods are time-consuming and prone to crashing, failing to meet the production rhythm requirements of modern shipbuilding enterprises for second-level feedback, concurrent processing, and batch export. This invention is based on .NET 8.0's TaskParallelLibrary (TPL), with a first level of file-level task unit concurrency (processing multiple .gen files in parallel through Task.Run), and a second level of intra-segment data parallel processing (parsing data segments such as PART_DATA and BURNING_DATA within a single file in parallel through Parallel.ForEach); it also employs ConcurrentDictionary.<string,object> Thread-safe containers share intermediate data, avoiding data races and thread conflicts, and enabling efficient and stable parsing of large files.

[0092] Example 4 like Figure 13 As shown, this embodiment proposes a ship root file parsing system, which is applied to the ship root file parsing method described in the above embodiment, including: a preprocessing module 100, a parsing module 200, a generation module 300, and a summarizing module 400.

[0093] The preprocessing module 100 preprocesses the input ship root file, initializes the running environment, and obtains a standardized list of root file paths. The parsing module 200 performs logical segmentation parsing of the ship root file content based on preset structure tags in the ship root file to obtain contour data blocks. The generation module 300 generates primitive files, structured data files, CNC instruction files, and statistical files based on the contour data blocks. The summarization module 400 summarizes the visualization files, structured data files, CNC instruction files, and statistical files, releases resources occupied during operation, and outputs all summarized files to a specified directory.

[0094] Understandably, existing technologies suffer from high module coupling, lack scalability, and difficulty adapting to the structural differences in .gen files across different shipyards, with limited deployment options. This invention employs a modular design and standard interface encapsulation, decoupling input processing, structure parsing, contour classification, format export, and statistical analysis into independent modules. Through dependency injection, it supports flexible expansion, hot replacement, and multi-version compatibility. Customized parsing plugins can be deployed as needed to address the differences in .gen files across different shipyards, without modifying the main logic. It supports integration via API, CLI, NuGet, and other methods, and can be deployed to automated production lines, MES, and CAPP systems, demonstrating strong adaptability and continuous evolution capabilities.

[0095] Understandably, compared to current mainstream gen file processing methods, this invention has significant advantages in several key dimensions. Traditional methods often employ a single-source input, single-format output strategy, supporting only export to DXF or GCode files. In contrast, this invention, based on unified data structure modeling and modular export interface design, can export six formats—DXF, PNG, GCode, JSON, TXT, and Excel—in one stop, with each exporter independently driven to customize and convert output. Existing technologies suffer from significant performance bottlenecks in serial parsing when processing large projects, often crashing due to thread blocking or memory overflow. This invention, however, adopts a .NET 8.0 TPL two-layer concurrency model, using Task.Run to achieve concurrent distribution of file tasks, internally using Parallel.ForEach for segmented parallel processing, and leveraging ConcurrentDictionary to manage intermediate data, improving parsing efficiency by 45-60%. Most tools do not process contour data, resulting in jagged edges and broken lines in the output image. This invention introduces contour closure correction, near collinear merging (error tolerance ≤1mm, included angle ≤3°) and anti-aliasing rendering (SkiaSharp+OpenCvSharp4), which reduces the image jaggedness rate by 27% and significantly improves clarity and smoothness.

[0096] Commercial tools often handle structured segments like BEVEL_DATA poorly, failing to accurately identify bevel information. This invention employs semantic tag-driven and structure state control, utilizing the tag recognition and structure transformation strategies of PartMetadataExtractorService to parse irregular tags, enabling bevel segment extraction, length statistics, and image fusion. Existing technologies often generate GCode containing numerous redundant IDLE segments. This invention sets up path classification and merging functions in GCodeExporterService to extract and compress idle segments and merge the main path, reducing the average number of instructions by approximately 11% and improving path switching speed by 6%. While most commercial tools are monolithic and closed systems, this invention independently encapsulates each functional service, manages its lifecycle through dependency injection, supports multiple embedding methods such as API calls and CLI deployment, and can be extended as needed, offering enhanced adaptability and maintainability.

[0097] It should be noted that the foregoing explanation of the embodiment of the ship root file parsing method also applies to the ship root file parsing system of this embodiment, and will not be repeated here.

[0098] Example 5 Figure 14 This is a schematic diagram of the structure of the electronic device 500 provided in this embodiment. The electronic device 500 includes: a memory 501, a processor 502, and a computer program stored in the memory 501 and executable on the processor 502.

[0099] When processor 502 executes the program, it implements the ship root file parsing method provided in the above embodiments.

[0100] Furthermore, the electronic device 500 also includes a communication interface 503 for communication between the memory 501 and the processor 502.

[0101] The memory 501 may include high-speed RAM (Random Access Memory) and may also include non-volatile memory, such as at least one disk storage device.

[0102] If the memory 501, processor 502, and communication interface 503 are implemented independently, then the communication interface 503, memory 501, and processor 502 can be interconnected via a bus to complete communication between them. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0103] Optionally, in a specific implementation, if the memory 501, processor 502, and communication interface 503 are integrated on a single chip, then the memory 501, processor 502, and communication interface 503 can communicate with each other through an internal interface.

[0104] Processor 502 may be a CPU (Central Processing Unit), an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of the present invention.

[0105] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described ship root file parsing method.

[0106] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0107] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0108] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of the invention pertain.

[0109] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any of the following techniques known in the art, or a combination thereof: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (FPGAs), field-programmable gate arrays (FPGAs), etc.

[0110] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.

[0111] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for parsing ship root files, characterized in that, include: The input ship root file is preprocessed to initialize the runtime environment and obtain a normalized list of root file paths; Based on the preset structure tags in the ship root file, the contents of the ship root file are logically segmented and parsed to obtain the outline data block; Based on the contour data blocks, generate primitive files, structured data files, CNC instruction files, and statistical files; The system aggregates the visualization file, the structured data file, the CNC instruction file, and the statistical file, releases the resources used during operation, and outputs all aggregated files to a specified directory.

2. The ship root file parsing method according to claim 1, characterized in that, The input ship root file is preprocessed to initialize the runtime environment and obtain a normalized list of root file paths, including: Traverse the input ship root file path and its subdirectories to identify files with the .gen suffix or containing the .gen keyword; If the ship root file path corresponds to a zip format compressed package, decompress the zip format compressed package to a temporary directory, and then extract files with the .gen suffix or containing the .gen keyword from the decompressed contents; Initialize the runtime environment, and create a logger, a character encoding detection module, and an output path; The paths of files with the .gen suffix or containing the .gen keyword are normalized to remove duplicate paths and generate a normalized path list for the files.

3. The ship root file parsing method according to claim 1, characterized in that, Based on the preset structure tags in the ship root file, the content of the ship root file is logically segmented and parsed to obtain contour data blocks, including: Initialize different types of contour storage lists and the state variables required for parsing; The ship root file is read line by line. When the contour start mark corresponding to the preset structure label is detected, the contour parsing process is started. The content within the contour is parsed segment by segment, and the contour data of each contour, including line segment type, coordinates and related parameters, is extracted. The parsed contour data is classified and stored according to the type of empty space, marker, cut and bevel, and a contour list is generated. After sequentially verifying the number of line segments, the validity of coordinates, and the closure of the contour list, the data is summarized to obtain the contour data block.

4. The ship root file parsing method according to claim 1, characterized in that, The metafiles include DXF files and PNG files; Generating a DXF file based on the contour data block includes: Create a DXF file instance; Traverse the contours in the contour data block and obtain the corresponding colors according to the preset structure labels corresponding to the contours; Traverse the line segments of each contour. If it is a straight line, create a straight line entity based on the coordinates of the line segment. If it is an arc, create an arc entity based on the center, start angle and end angle of the line segment. Add the straight line entity or arc entity to the DXF file instance and save it to the specified path. Generating a PNG file based on the outline data block includes: Create a drawing surface, obtain a canvas and set a white background, and configure anti-aliasing drawing and contour closure detection parameters; Traverse the contour line segments in the contour data block and calculate the extreme value range of the line segments' coordinates; Calculate the scaling ratio and offset based on the drawing surface dimensions and the extreme value range of the coordinates; The coordinates of the contour line segments are transformed based on the scaling ratio and offset; Traverse the contour segments after coordinate transformation. If it is a straight line, draw it according to the coordinates of the two points of the contour segment; if it is an arc, determine the arc type, calculate the corresponding parameters of the arc, and draw it according to the corresponding parameters of the arc. Convert the drawn surface into an image, encode it as a PNG file, and save it to the specified path.

5. The ship root file parsing method according to claim 1, characterized in that, The structured data files include JSON files and TXT files; Generating a JSON file based on the contour data block includes: Read all lines of the root file, create a dictionary to store the parsed results, as well as a key-value storage structure or a table storage structure, and initialize the row index; Based on the block markers in the root file, the data segments corresponding to GENERAL_DATA, PART_DATA, IDLE_DATA, and BURNING_DATA are parsed in blocks; The parsing results of each data segment are stored in the dictionary, the key-value storage structure, or the table storage structure, respectively. The dictionary is serialized into a JSON file, and the key-value storage structure or the table storage structure is written into a TXT file according to the specified format and output to the specified path.

6. The ship root file parsing method according to claim 1, characterized in that, The numerical control instruction file is a G-Code file in .nc format; Based on the contour data block, a numerical control instruction file is generated, including: Create a file write object, write the file start symbol, and set the units, coordinate system, and current position; Filter the empty line segment type contours from the contour data block, merge continuous empty line segments, and update the coordinates of the end point of the empty line segment. Traverse the contours in the contour data block, skip contours without segments, and perform a fast move to the corresponding contour start point for contours of the cutting, marking, or bevel categories. Traverse the contour segments processed in the above steps, and generate CNC instructions according to the contour category and segment type. For idle segments, generate G00 CNC instructions; for straight-line cutting segments, generate G01 CNC instructions; for arc-cutting segments, generate G02 or G03 CNC instructions based on the arc sweep direction. For non-idle contours, write the program end CNC instruction. Save the generated CNC instructions as a .nc file.

7. The ship root file parsing method according to claim 1, characterized in that, The statistical files include Excel files in .xlsx format; Based on the contour data blocks, a statistical file is generated, including: Traverse the contour data block and root file contents, identify part information and bevel-related markers, and determine whether the part has a defined bevel. For parts with defined bevels, calculate the length of their bevel segments and summarize the total length of the bevels of the parts. Extract the first attribute information, including part number, assembly number, segment number, ship number, part length, part width, and part area; The calculation includes second attribute information such as part weight, part center of gravity, length and width of the part's minimum bounding rectangle, and total outline length of the part. Statistical data is constructed based on the bevel segment length, the total bevel length of the total parts, the first attribute information, and the second attribute information; Generate an Excel file in .xlsx format using the statistical data in a multi-worksheet structure, and save it to the specified path.

8. The ship root file parsing method according to claim 7, characterized in that, The metafile also includes a contour visualization file, and the method further includes: Create a drawing object and set the canvas background; Receive the list of cutting contour data and the list of bevel contour data, determine whether to merge the bevel contour into the cutting contour, if merged, copy the cutting contour, traverse the bevel contour, and replace the part of the cutting contour that overlaps with the bevel contour. Calculate the coordinate range of all contours, and determine the scaling ratio and offset based on the coordinate range and the preset image size; Process the outline data according to the scaling ratio and offset, and draw the processed outline data onto the canvas. Convert the drawing object into an image, encode it as a PNG format outline visualization file, and save it to the specified path.

9. A ship root file parsing system, characterized in that, include: The preprocessing module is used to preprocess the input ship root files, initialize the runtime environment, and obtain a normalized list of root file paths. The parsing module is used to logically segment and parse the contents of the ship root file according to the preset structure tags in the ship root file to obtain the outline data block; The generation module is used to generate primitive files, structured data files, CNC instruction files, and statistical files based on the contour data blocks; The summary module is used to summarize the visualization file, the structured data file, the CNC instruction file, and the statistical file, release the resources occupied during operation, and output all summarized files to a specified directory.

10. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to perform the operations performed by the ship root file parsing method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Cutter radius compensation method based on DXF file

    CN111221296A

  • Data structure of metadata, and reproduction apparatus and method of the metadata

    US20060053153A1