A STEP file exporting method based on a string buffer mechanism

CN117113457BActive Publication Date: 2026-07-14ZHEJIANG UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG UNIV
Filing Date
2023-09-06
Publication Date
2026-07-14

Smart Images

  • Figure CN117113457B_ABST
    Figure CN117113457B_ABST
Patent Text Reader

Abstract

The application discloses a STEP file export method based on a string buffer mechanism, and belongs to the field of CAD model data processing.The method first constructs head information of the exported STEP file, and writes the information into a buffer array.Secondly, data information of the STEP file to be exported is constructed, and a pointer of a face* type is obtained.Then, a pointer of a loop* type and a pointer of a surface* type are obtained from an object pointed by the face* pointer.Finally, all data of the above-mentioned pointers are written into the buffer array and exported to a file in a specified path, so that the STEP file export is completed.The application realizes the STEP file export with the advantages of simplicity, high efficiency and low storage cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of CAD model data processing, specifically involving a method for exporting STEP files based on a string caching mechanism. Background Technology

[0002] With the widespread use of modeling software, 3D modeling has become an important tool in many industries, such as gaming, film and television, architecture, design, and manufacturing. In these industries, 3D modeling can be used for virtual scene construction, product prototype demonstration, artistic creation, and educational simulation, improving production efficiency, reducing costs, and enhancing quality. The STEP standard is a set of computer-aided design (CAD) data processing standards developed by the International Organization for Standardization's Technical Committee on Industrial Automation and Integration. STEP standard documents, as neutral documents, facilitate information exchange between various modeling software programs.

[0003] Although most mainstream 3D modeling software supports importing and exporting STEP files, the export operation in known open-source 3D modeling software (such as Open CASCADE) is very complex and difficult for novice developers to understand. Summary of the Invention

[0004] In view of the above-mentioned shortcomings of the existing technology, the present invention aims to provide a STEP file export method based on a string caching mechanism. This STEP file export strategy, based on a string caching mechanism, is concise, efficient, and has low storage overhead. The export process is based on a boundary representation model, which is one of the most widely used spatial data models. It utilizes boundaries to represent entities and commonly organizes and stores model data using a hierarchical structure, defining entities using a five-layer structure: vertex, edge, loop, face, and body. The specific steps are as follows:

[0005] Step 1: Construct the header information of the exported STEP file and write the header information into the cache array.

[0006] Step 2: Construct the data information for the STEP file to be exported and write the data information to the cache array. Obtain a pointer of type body* to be exported from the CAD system, export it as an entity with the keyword "ADVANCED_BREP_SHAPE_REPRESENTATION", and simultaneously export the entity with the keyword "MANIFOLD_SOLID_BREP" referenced by the pointer.

[0007] Obtain a pointer of type shell* from the object pointed to by the pointer of type body*, and export it as an entity with the keyword "CLOSED_SHELL".

[0008] A pointer of type face* is obtained recursively from the object pointed to by the pointer of type shell*.

[0009] For each face (i.e., the object pointed to by the `face*` type pointer) in the recursive process, it is exported as an entity with the keyword "ADVANCED_FACE". A pointer of type `loop*` and a pointer of type `surface*` are obtained from the object pointed to by `face*`, and the objects pointed to by these two pointers are recursively exported. A hash table is used here to determine whether data has already been exported. The keys of the hash table are of type "void*", corresponding to various pointers, and the values ​​are of type "int", corresponding to the index row number. Before exporting the `loop*` object, it is checked against the hash table to see if it has already been exported. If it has, the key value of the hash table, i.e., the index row number, is directly obtained and written into the attribute part of the "ADVANCED_FACE" keyword. If it has not been exported, the index row number corresponding to `loop*` is the current largest index row number plus one, which is written into the attribute part of the "ADVANCED_FACE" keyword before exporting the object pointed to by `loop*`. The method for handling `surface*` objects is the same as that for `loop*` objects.

[0010] Step 3: Export all the data written to the cache array to a file at the specified path to complete the STEP file export.

[0011] Furthermore, step 2, obtaining pointers of type loop* and surface*, is as follows: First, export the pointer of type loop* as an entity with the keyword "EDGE_LOOP". Obtain the pointer of type edge* from the object pointed to by loop*, export it as an entity with the keyword "ORIENTED_EDGE", and obtain the pointer of type curve* from the object pointed to by edge*. Curve (i.e., the object pointed to by the curve* pointer) may have multiple types, such as straight line, circle, ellipse, B-spline curve, etc. According to the curve type, obtain the attribute information of the object pointed to by the curve pointer and write it into the cache array according to the STEP rules.

[0012] Next, export the pointer of type surface*. Since surface (i.e. the object pointed to by the surface* pointer) may also have multiple types, such as plane, cylinder, sphere, cone, torus, B-spline surface, etc., it is necessary to obtain the attribute information of the object pointed to by the surface pointer according to the surface type and write it into the cache array according to the STEP rules.

[0013] For all the curve and surface types mentioned above, the data of the corresponding data structure needs to be written into the cache array according to the STEP standard. The specific processing still adopts the idea of ​​recursion. If the data to be written into the cache array is a simple type, it is written directly. If it is another entity, the referenced entity needs to be processed recursively until each case reaches the recursion exit.

[0014] The beneficial effects of this invention are as follows: Based on a string caching mechanism, this invention solves the problems that occur when writing files, can determine the index number of the entity referenced by a certain entity, and achieves simple, efficient and low storage overhead STEP file export. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the process of the present invention. Detailed Implementation

[0016] The STEP file consists of a header and a data section. The header mainly stores product information such as author, manufacturer, version, and date; simply fill it in according to the actual situation when exporting. In the data section, each line of data consists of three parts: index number, keyword, and attribute.

[0017] An index number is a "#" symbol followed by a number, which uniquely identifies a geometric element.

[0018] The keyword is a string in all uppercase. By looking up the STEP keyword in the dictionary, you can find out what specific attributes the geometric element represented by that line should have.

[0019] The attribute section describes the geometric data contained in the geometric type corresponding to the row. For the expression of topological relationships, STEP uses a referencing method, that is, referencing other entities in the attribute section. The referencing method is "#" followed by the index number of the referenced entity.

[0020] The overall topology of STEP can be viewed as a tree, where the root node is an entity with the key "ADVANCED_BREP_SHAPE_REPRESENTATION", whose attribute fields reference the entity "MANIFOLD_SOLID_BREP", which in turn references the entity "CLOSED_SHELL", and so on. Shell references face, face references loop, loop references edge, edge references vertex, and vertex is the smallest granular geometric element.

[0021] The STEP standard refers to each keyword as an "entity". In the design of the STEP export algorithm of this invention, a crucial issue is determining the index number of the entity referenced by a given entity. For example, when exporting the entity "CLOSED_SHELL", assuming its index number is "#10", and assuming its attribute part references two faces, namely the "ADVANCED_FACE" entity in STEP, it's easy to see that the index number of the first face is "#11", which is the index number of the current row plus one. However, the index number of the second face is not "#12" because face "#11" is not a leaf node in the tree and it references other entities. Therefore, during export, the first face needs to be processed recursively first. At this point, it's easy to know the largest index of the currently exported entity, let's say "#50", then the index number of the second face is "#51".

[0022] In principle, the above-mentioned export algorithm uses the idea of ​​depth-first search, that is, it first recursively processes the current node of the tree and all its child nodes, and then processes the sibling nodes of the current node. Since the algorithm has a backtracking process, it cannot be directly exported to a file, because the write operation to the file always occurs at the end of the file. For example, in the example above, when it is known that the index number of the second face is "#51", the contents of other entities have already been written to the file, so it is impossible to write the index number of the second face to the specified position.

[0023] Considering the problems that occur when writing files, this invention uses an array as a temporary storage structure. The content to be written to the file is first written to the array. After all the content to be exported is written to the cache array, the cache array is traversed and the content in it is written to the file.

[0024] Furthermore, for certain geometric data, reuse should be considered, and duplicate export should be avoided. For example, when two faces reference the same surface, only one copy of the surface data should be exported. To address this, this invention uses `std::unordered_map`, which maps "void*" type to "int" type.<void*,int> "The data structure can map pointers of any type to index row numbers in STEP. When exporting a surface or some other entities, the pointer of the current object is first converted to the "void*" type, and then it is determined whether the corresponding index number exists in the hash table. If it exists, it is used directly; otherwise, the data of the entity is written to the cache array, and then the corresponding "void*" type pointer and the index number newly written to the cache array are inserted into the hash table."

[0025] like Figure 1As shown, this invention proposes a STEP file export method based on a string caching mechanism. The detailed process of this method is as follows:

[0026] Step 1: First, construct the header information of the STEP file to be exported. Generate information such as the author, manufacturer, version, and date of the current product according to the actual situation, and write this information into the cache array.

[0027] Step 2: Next, construct the data information of the STEP file to be exported. Obtain the pointer of type body* to be exported from the CAD system, export it as an entity with the keyword "ADVANCED_BREP_SHAPE_REPRESENTATION", and at the same time export the entity with the keyword "MANIFOLD_SOLID_BREP" referenced by the pointer.

[0028] Obtain a pointer of type shell* from the object pointed to by the pointer of type body*, and export it as an entity with the keyword "CLOSED_SHELL".

[0029] This retrieves a pointer to a face from the object pointed to by a pointer of type shell*. Taking a line of content from a STEP file as an example: "#16=CLOSED_SHELL('',(#17,#105,#109));", since this shell contains 3 faces, and the index of the second face can only be known after the first face has been processed, the push_back member function needs to be used to add the following content to the cache array: "#16=CLOSED_SHELL('',(#17,). Then, the face with index 17 is processed recursively. In the example above, after processing the face with index 17..." The current maximum index number is 104, so the index number of the second face is 105. This is written into the corresponding shell line in the cache array. At this point, the data in the shell line of the cache array becomes "#16=CLOSED_SHELL('',(#17,#105,"). We continue to recursively process the face with index number 105. After that, we know that the index number of the third face is 109. At this point, the complete data of the shell line is known: "#16=CLOSED_SHELL('',(#17,#105,#109));". After recursively processing the face with index number 109, the algorithm reaches the recursion exit point.

[0030] The above text has detailed how to write data into the cache array step by step. The example above only applies to CLOSED_SHELL, but it is not limited to this. For any entity, if it references other entities and needs to recursively process the referenced entities in order to know the index number of the next referenced entity, then the same rule needs to be used to gradually write the information to be exported into the cache array.

[0031] For each face in the above recursive process, derive an entity with the keyword "ADVANCED_FACE", and obtain a pointer of type loop* and a pointer of type surface* from the object pointed to by the pointer of type face*.

[0032] First, export a pointer of type `loop*` as an entity with the keyword `EDGE_LOOP`. Then, obtain a pointer of type `edge*` from the object pointed to by the `loop*` pointer, exporting it as an entity with the keyword `ORIENTED_EDGE`. Finally, obtain a pointer of type `curve*` from the object pointed to by `edge*`. Curves can have various types, such as lines, circles, ellipses, and B-spline curves. Depending on the curve type, obtain the attribute information of the object pointed to by the curve pointer and write it to the cache array according to the STEP rules. For example, a line is represented by a point and a direction; therefore, obtain the point and direction information from the object pointed to by the curve pointer and export it. The processing rules for other curves are the same.

[0033] Next, export a pointer of type `surface*`. Since a surface can have multiple types, such as a plane, cylinder, sphere, cone, torus, B-spline surface, etc., the attribute information of the object pointed to by the curve pointer needs to be obtained according to the curve type and written to the cache array according to the STEP rules. Taking a straight line as an example, a straight line is represented by a point and a direction, so the point and direction information needs to be obtained from the object pointed to by the curve pointer and exported. The processing rules for other curves are the same.

[0034] For all the curve and surface types mentioned above, the data of the corresponding data structure needs to be written into the cache array according to the STEP standard. The specific processing still adopts the idea of ​​recursion. If the data to be written into the cache array is a simple type, it is written directly. If it is another entity, the referenced entity needs to be processed recursively until each case reaches the recursion exit.

[0035] Step 3: Export all the data written to the cache array by the above pointers to a file at the specified path to complete the STEP file export.

[0036] Thus, the detailed flow of the STEP export algorithm of this invention has been presented. This invention implements export functions for various data types, including points, lines, circles, ellipses, B-spline curves, planes, cylinders, spheres, cones, tori, and B-spline surfaces. The entire algorithm flow has been implemented in actual engineering projects. Furthermore, each curve and surface supported by the algorithm has undergone thorough testing. Files exported from each curve and surface supported by this invention have been correctly displayed in mainstream 3D modeling software, demonstrating the correctness of the export algorithm. Additionally, this invention ensures that the exported information is free of redundancy. For repeatedly referenced data, a hash table is used to determine if it already exists, significantly reducing the size of the final exported file.

Claims

1. A method for exporting STEP files based on a string caching mechanism, characterized in that, Includes the following steps: Step 1: Construct the header information of the exported STEP file and write the header information into the cache array; Step 2: Construct the data information of the exported STEP file and write the data information into the cache array; Step 3: Export all data written to the cache array to a file at the specified path to complete the STEP file export; Step 2 is as follows: Step 2.1: Obtain the pointer of type body* from the computer-aided design system, export the entity of the keyword "ADVANCED_BREP_SHAPE_REPRESENTATION", and at the same time export the entity of the keyword "MANIFOLD_SOLID_BREP" referenced by the pointer; Step 2.2: Obtain a pointer of type shell* from the object pointed to by the pointer of type body*, and export it as an entity with the keyword "CLOSED_SHELL"; Step 2.3: Recursively obtain a pointer of type face* from the object pointed to by the pointer of type shell*; Step 2.4: For each object 'face' pointed to by a 'face*' type pointer in the recursive process, export it as an entity with the keyword "ADVANCED_FACE". Obtain a 'loop*' type pointer and a 'surface*' type pointer from the object pointed to by 'face*'. Recursively export the objects pointed to by the 'loop*' type pointer and the 'surface*' type pointer. Step 2.4 also includes using a hash table to determine whether the data has been exported, where the key of the hash table is of type "void*", corresponding to various pointers, and the value is of type "int", corresponding to the index row number; Before exporting loop* objects, check the hash table to see if they have already been exported. If they have, retrieve the key value (index row number) of the hash table and write it into the attribute part of the "ADVANCED_FACE" keyword. If they have not been exported, the index row number corresponding to loop* is the current largest index row number plus one, and write it into the attribute part of the "ADVANCED_FACE" keyword before exporting the object pointed to by loop*. The same method is used to process surface* objects as loop* objects.

2. The STEP file export method based on string caching mechanism according to claim 1, characterized in that, The header information mentioned in step 1 includes: the author, manufacturer, version, and date information of the current product.

3. The STEP file export method based on a string caching mechanism according to claim 1, characterized in that, In step 2.4, the specific process of obtaining pointers of type loop* and type surface* is as follows: First, export the pointer of type loop* as an entity of the keyword "EDGE_LOOP". Obtain the pointer of type edge* from the object pointed to by loop*, export it as an entity of the keyword "ORIENTED_EDGE", and obtain the pointer of type curve* from the object pointed to by edge*. Then, export the pointer of type surface*.

4. The STEP file export method based on a string caching mechanism according to claim 3, characterized in that, The object pointed to by the curve* type pointer has multiple curve types. Based on the curve type, the attribute information of the object pointed to by the curve pointer is obtained and written to the cache array according to the STEP rules. The surface* pointer points to an object whose surface type has multiple surface types. Based on the surface type, the attribute information of the object pointed to by the surface pointer is obtained and written to the cache array according to the STEP rules.

5. The STEP file export method based on a string caching mechanism according to claim 4, characterized in that, For various curve and surface types, data is written to a cache array according to the STEP standard. The specific processing adopts a recursive approach. If the data to be written to the cache array is a simple type, it is written directly. If it is another entity, the referenced entity is processed recursively until each case reaches the recursion exit point.