RVM file reading method
Through the methods of data flow reading and tree structure establishment, the problem of three-dimensional model analysis and reconstruction in RVM files is solved, and efficient and accurate three-dimensional model reconstruction and display are achieved.
Patent Information
- Application Number
- CN202411743858.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-30
- Publication Date
- 2025-03-28
AI Technical Summary
The existing technology is difficult to effectively parse and reconstruct three-dimensional models in RVM files, resulting in cross-platform use difficulties and incomplete acquisition of model information.
Read RVM files through data streams, judge the file format and establish a data tree, read the file recursively, and establish a model tree structure based on the strings CNTB and CNTE, classify data types and reconstruct different geometric model types.
Automatic identification and data analysis of different types of RVM files is realized, the speed and accuracy of file reading is improved, and the three-dimensional model can be correctly parsed and reconstructed, achieving an accuracy rate of more than 98%.
Smart Images

Figure CN119720378A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of three-dimensional ship design, and in particular to a method for reading an RVM file. Background Art
[0002] RVM is a ship 3D model file format. The file format includes text and binary formats. The file stores the geometric information of the 3D model. If the 3D model wants to be used across platforms, the 3D model file needs to be parsed and reconstructed. Due to the technical barriers of large-scale 3D software, it is basically impossible to obtain complete model information. Therefore, we must analyze the file format and find a way to read the model file. Summary of the invention
[0003] The purpose of the present invention is to provide a method for reading an RVM file that can correctly parse and reconstruct a three-dimensional model.
[0004] The technical solution adopted by the present invention to achieve the above-mentioned purpose is: a method for reading an RVM file, comprising the following steps: a. Use data stream to read files. By reading the first 4 bits of the file, determine the file format. If it is a character type, process it as text. If not, process it as a binary file. b. Create a data tree by recursively reading the file. When a string CNTB is encountered, it indicates the beginning of the level, and when a string CNTE is encountered, it indicates the end of the level. According to this rule, a model tree structure is established; c. Classify the data types. Through the above steps, when PRIM is read, it indicates that it is geometric model data. The file type is defined after prim, and then the geometric file type is judged. The file types range from 1 to 8 and 11. 1 is a pyramid type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The remaining 7 groups of data represent the length and width of the bottom edge, the length and width of the top edge, the center offset and the height respectively; 2 is a rectangular type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The 6 groups of data on the edge represent the outer contour bounding box of the geometric model, which are represented by two-point coordinates, and the last 3 groups of data represent the length, width and height of the cuboid; 3 is the square ring type, and the 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The last 4 groups of data represent the inner diameter of the square ring, the outer diameter of the square ring, the height of the square ring and the rotation chord length of the square ring; 4 is the circular ring type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which are represented by two-point coordinates. The last 3 groups of data represent the inner diameter of the circular ring, the outer diameter of the circular ring and the chord length of the circular ring; 5 is the ellipsoid type, which is The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 2 sets of data represent the radius and height of the ellipsoid; 6 is the sphere type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 2 sets of data represent the radius and height of the sphere; 7 is the frustum type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 2 sets of data represent the radius and height of the sphere. The first group of data represents the outer contour bounding box of the geometric model, which is represented by two-point coordinates and is finally divided into 9 groups of data, which respectively represent the lower surface radius of the cone, the upper surface radius, the height of the cone, the center offset X value of the cone, the center offset Y value of the cone, the inclination angle of the upper surface relative to the current X axis, the inclination angle of the upper surface relative to the current Y axis, the inclination angle of the lower surface relative to the current X axis, and the inclination angle of the lower surface relative to the current Y axis; 8 is the cylinder type, and the 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates and is finally divided into 2 groups of data, which respectively represent the radius and height of the cylinder;11 is the plane type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two point coordinates. The next number represents the number of faces that make up the plane, followed by the number of points that make up the plane. These points are used to construct a surface, and then the surfaces form a plane. d. Reconstruct data based on the results of data type classification; e. Display the reconstructed data.
[0005] The step d reconstructs the pyramid type data, constructs a multi-line segment through the points of the top and bottom quadrilaterals, finds the coordinates of 8 points through offset, and then constructs the pyramid type through scanning.
[0006] The step d is to reconstruct the 2 cuboid type data and construct the cuboid shape through the three values of length, width and height.
[0007] The step d is to reconstruct the 3D ring type data, construct a face through the inner diameter, outer diameter and height, and construct a square ring geometry by rotating the face by chord length.
[0008] The step d is to reconstruct the 4-ring type data and construct a ring through the three values of inner diameter, outer diameter and chord length.
[0009] In the step d, the 5 ellipsoid type data is reconstructed, an ellipse is constructed by radius and height, and the ellipse is rotated 180 degrees to construct an ellipsoid.
[0010] In the step d, the 6-sphere type data is reconstructed to construct a sphere by the center and radius.
[0011] In the step d, the 7-cone type data is reconstructed, the upper surface is constructed by the center and radius of the upper surface, the lower surface is constructed by the center and radius of the lower surface, and the upper surface and the lower surface are swept to construct the cone.
[0012] In the step d, the 8 cylinder type data are reconstructed, the upper and lower surfaces are constructed by the center and radius, the outer surface of the cylinder is constructed by the height, and the upper surface, the lower surface and the height are combined to construct a cylinder.
[0013] In the step d, the 11 plane type data are reconstructed and all the planes are connected to construct a plane body.
[0014] The reconstructed 1 pyramid type data, 2 rectangular block type data, 3 square ring type data, 4 circular ring type data, 5 ellipsoid type data, 6 sphere type data, 7 truncated cone type data, 8 cylinder type data and 11 plane type data are displayed, and the pyramid, rectangular block, square ring, circular ring, ellipsoid, sphere, truncated cone, cylinder and plane are displayed through coordinate transformation.
[0015] The present invention discloses a method for reading an RVM file, which can automatically identify different types of files, perform data analysis according to the file type, improve the speed and accuracy of file reading, and can analyze different geometric types and reconstruct them. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a system framework diagram of a method for reading an RVM file of the present invention.
[0017] Figure 2 The present invention is a flowchart of a method for reading an RVM file. DETAILED DESCRIPTION
[0018] like Figure 1 and Figure 2As shown, the method for reading RVM files includes the following steps: a. Using data stream to read files, by reading the first 4 bits of the file, determine the file format, if it is a character type, process it as a text, if not, process it as a binary file; b. Create a data tree, by recursively reading the file, encountering the string CNTB indicates the beginning of the level, encountering CNTE indicates the end of the level, and establishing a model tree structure according to this rule; c. Classify the data type, through the above steps, when PRIM is read, it indicates that it is geometric model data, prim defines the type of the file, and then determines the geometric file type, The file types range from 1 to 8 and 11. 1 is a pyramid type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The remaining 7 groups of data represent the length and width of the bottom edge, the length and width of the top edge, the center offset and the height; 2 is a rectangular type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two points. The last 3 groups of data represent the length, width and height of the cuboid; 3 is the square ring type, the 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model, these data constitute the rotation matrix and the position coordinates of the model, and the last 4 groups of data represent the inner diameter of the square ring, the outer diameter of the square ring, the height of the square ring and the rotation chord length of the square ring; 4 is the circular ring type, the 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model, these data constitute the rotation matrix and the position coordinates of the model, and the following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 3 groups of data represent the inner diameter of the circular ring, the outer diameter of the circular ring, and the height of the circular ring. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 2 sets of data represent the radius and height of the ellipsoid. The 6 is the sphere type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 2 sets of data represent the radius and height of the sphere.7 is a cone type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. Finally, it is divided into 9 groups of data, which respectively represent the lower surface radius of the cone, the upper surface radius, the height of the cone, the center offset X value of the cone, the center offset Y value of the cone, the inclination angle of the upper surface relative to the current X axis, the inclination angle of the upper surface relative to the current Y axis, the inclination angle of the lower surface relative to the current X axis, and the inclination angle of the lower surface relative to the current Y axis; 8 is a cylinder type. The 12 groups of data after the type represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The first group of data constitutes the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. Finally, it is divided into 2 groups of data, representing the radius and height of the cylinder respectively; 11 is the plane type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The next number represents the number of faces that make up the plane, followed by the number of points that make up the plane. These points are constructed into Surfaces, and then the surfaces form a plane; d. Reconstruct the data type classification results, reconstruct the 1 pyramid type data, construct a multi-line segment through the points of the top and bottom quadrilaterals, find the coordinates of 8 points through offset, and then construct the pyramid type through scanning; reconstruct the 2 rectangular block type data, and construct the rectangular block shape through the three values of length, width and height; reconstruct the 3 square ring type data, construct the surface through the three values of inner diameter, outer diameter and height, and construct the square ring geometry by rotating the surface by chord length; reconstruct the 4 circular ring type data, and construct the circular ring through the three values of inner diameter, outer diameter and chord length; reconstruct the 5 ellipsoid type data Reconstruction is performed to construct an ellipse through radius and height, and the ellipse is rotated 180 degrees to construct an ellipsoid; 6 sphere type data is reconstructed to construct a sphere through the center and radius; 7 truncated cone type data is reconstructed to construct the upper surface through the center and radius of the upper surface, and the lower surface through the center and radius of the lower surface, and the upper and lower surfaces are swept to construct a truncated cone; 8 cylinder type data is reconstructed to construct the upper and lower surfaces through the center and radius, and the outer surface of the cylinder is constructed through the height, and the upper surface, lower surface and height are combined to construct a cylinder; 11 plane type data is reconstructed to connect all planes to construct a plane body;e. Display the reconstructed data. The reconstructed 1 pyramid type data is displayed as a pyramid through coordinate transformation. The reconstructed 2 cuboid type data is displayed as a cuboid through coordinate transformation. The reconstructed 3 square ring type data is displayed as a square ring through coordinate transformation. The reconstructed 4 circular ring type data is displayed as a circular ring through coordinate transformation. The reconstructed 5 ellipsoid type data is displayed as an ellipsoid through coordinate transformation. The reconstructed 6 sphere type data is displayed as a sphere through coordinate transformation. The reconstructed 7 truncated cone type data is displayed as a truncated cone through coordinate transformation. The reconstructed 8 cylinder type data is displayed as a cylinder through coordinate transformation. The reconstructed 11 plane type data is displayed as a plane through coordinate transformation. The experimental results show that the accuracy of the RVM file reading method of the present invention reaches more than 98%, and the three-dimensional model can be correctly analyzed and reconstructed. ;
Claims
1. A method for reading an RVM file, characterized in that: The following steps are involved: a. Use data stream to read the file, and judge the file format by reading the first 4 bits of the file. If If it is a character type, it is processed as text; if not, it is processed as a binary file; b. Create a data tree by recursively reading the file. When you encounter the string CNTB, it indicates the beginning of the level. When you encounter CNTE Indicates the end of the hierarchy, and establishes a model tree structure based on this rule; c. Classify the data types. Through the above steps, when PRIM is read, it indicates that it is geometric model data. After prim, the file type is defined, and then the geometry file type is determined. The file types range from 1 to 8 and 11. 1 is the pyramid type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometry model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometry model, which is represented by two-point coordinates. The remaining 7 sets of data represent the length and width of the bottom edge, the length and width of the top edge, the center offset and the height. 2 is the cuboid type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 3 sets of data represent the length, width and height of the cuboid. 3 is the square ring type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The last 4 groups of data represent the inner diameter, outer diameter, height and rotation chord length of the square ring. 4 is the circular ring type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 3 groups of data represent the inner diameter, outer diameter and chord length of the circular ring. 5 is the ellipsoid type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. The last 2 groups of data represent the radius and height of the ellipsoid. 6 is the sphere type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two point coordinates. The last 2 sets of data represent the radius and height of the sphere. 7 is the cone type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. Finally, it is divided into 9 groups of data, which respectively represent the lower surface radius of the cone, the upper surface radius, the height of the cone, the center offset X value of the cone, the center offset Y value of the cone, the inclination angle of the upper surface relative to the current X axis, the inclination angle of the upper surface relative to the current Y axis, the inclination angle of the lower surface relative to the current X axis, and the inclination angle of the lower surface relative to the current Y axis. 8 is the cylinder type. The 12 groups of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 groups of data represent the outer contour bounding box of the geometric model, which is represented by two-point coordinates. Finally, it is divided into 2 groups of data, representing the radius and height of the cylinder respectively. 11 is the plane type. The 12 sets of data after the type constitute the coordinates and rotation coordinates of the geometric model. These data constitute the rotation matrix and the position coordinates of the model. The following 6 sets of data represent the outer contour bounding box of the geometric model, which is represented by two point coordinates. The next number represents the number of faces that make up the plane, followed by the number of points that make up the plane. These points are used to construct a surface, and then the surfaces form a plane. d. Reconstruct data based on the results of data type classification; e. Display the reconstructed data.
2. The method for reading an RVM file according to claim 1, wherein: The step d reconstructs the pyramid type data, constructs a multi-line segment through the points of the top and bottom quadrilaterals, finds the coordinates of 8 points through offset, and then constructs the pyramid type through scanning.
3. The method for reading an RVM file according to claim 1, characterized in that: The step d is to reconstruct the 2 cuboid type data and construct the cuboid shape through the three values of length, width and height.
4. The method for reading an RVM file according to claim 1, characterized in that: The step d is to reconstruct the 3D ring type data, construct a face through the inner diameter, outer diameter and height, and construct a square ring geometry by rotating the face by chord length.
5. The method for reading an RVM file according to claim 1, characterized in that: In the step d, the 4-ring type data is reconstructed to construct a ring through the three values of inner diameter, outer diameter and chord length.
6. The method for reading an RVM file according to claim 1, characterized in that: In the step d, the 5 ellipsoid type data is reconstructed, an ellipse is constructed by radius and height, and the ellipse is rotated 180 degrees to construct an ellipsoid.
7. The method for reading an RVM file according to claim 1, characterized in that: In the step d, the 6-sphere type data is reconstructed to construct a sphere by the center and radius.
8. The method for reading an RVM file according to claim 1, characterized in that: In the step d, the 7-cone type data is reconstructed, the upper surface is constructed by the center and radius of the upper surface, the lower surface is constructed by the center and radius of the lower surface, and the upper surface and the lower surface are swept to construct the cone.
9. The method for reading an RVM file according to claim 1, characterized in that: In the step d, the 8 cylinder type data are reconstructed, the upper and lower surfaces are constructed by the center and radius, the outer surface of the cylinder is constructed by the height, and the upper surface, the lower surface and the height are combined to construct a cylinder.
10. The method for reading an RVM file according to claim 1, characterized in that: In the step d, the plane type data 11 is reconstructed, and all the planes are connected to construct a plane body.
11. A method for reading an RVM file according to claims 2 to 10, characterized in that: The reconstructed 1 pyramid type data, 2 rectangular block type data, 3 square ring type data, 4 circular ring type data, 5 ellipsoid type data, 6 sphere type data, 7 truncated cone type data, 8 cylinder type data and 11 plane type data are displayed, and the pyramid, rectangular block, square ring, circular ring, ellipsoid, sphere, truncated cone, cylinder and plane are displayed through coordinate transformation.