IGES format: convert a plane to a green surface

Source: Internet
Author: User

Recently, I learned how to work in a company for two weeks and earn 1000 yuan of living expenses. The company is not big. It is an outsourcing company. Now I am working on a software similar to AutoCAD. I am responsible for the development of one of the functions, which are three-dimensional graphics (such as the three-dimensional model map of bridges) export the file to the IGES format. I just finished this task yesterday and left a footprint in my blog.

Let's talk about the IGES format first. This format is far more complex than PNG and MP3 formats. He is an industrial standard. IGES (the initial Graphics Exchange Specification) format is defined based on computer-aided design (CAD) & Computer-Aided Manufacturing (CAM) systems (Computer-Aided Design & Computer-Aided Manufacturing System) common ANSI information exchange standards between different computer systems. It can be simply understood that IGES is a public bridge used for communication between different drawing software. For example.


Although this function has been completed, I personally feel that it is not perfect. The IGES format contains many graph systems. Common surface and line use the most commonly used surface and line. I personally think these two surfaces are very complex and have many parameters. This parameter curve makes some vertices generate lines very clear. According to the set parameters, the shape can conform to the fluid dynamics. For example, if the vehicle body is designed with this design software, it will be more in line with aerodynamic. This curve (surface) is composed of a control point, a control point's weight, a node vector S, a T, and a spline function. Simply put, P = f (I). Given an independent variable I, a vertex P is generated based on function rule F. This curve is composed of these Ppoints. (Understanding is very simple .... Do not spray)

In IGES, 128 is used for the surface of the production environment, and 126 is used for the surface of the production environment.

126:

126, K, M, pr1.. 4, S, P (Control Point), Smin, Smax, normal

128, K1, K2, pr1.. 5, S, T, P, Smin, Smax, tmin, Tmax

As a person who has never been familiar with computer graphics, he doesn't understand these things at all. In order to earn money, I read this related book "computer graphics" Sun jiaguang and Tsinghua for a few days.

Although this is complicated, the company I outsource will export a body composed of a plane and a straight line. Therefore, you only need to understand how to convert the plane to the form of the OpenGL parameter.

After using inventor to generate some straight lines, we can see that except the control points, other values (K, M, S, etc.) are fixed. the control points are composed of two points, it is P1 and P2, And if P1 points to P2, then in 126, It is P1 written before P2.

Using inventor to export some planes for analysis, I export the three sides, four sides, five sides, and six sides on the Zoy plane. After the analysis, you are very happy. The data is as follows:


All planes, no matter how many edges, are composed of four control points with a weight of 1,

S value: 0.0, 0.0, Ymax-ymin T value: 0.0, 0.0, zmax-zmin

Control points are also regular,


I was excited and found that something was wrong. These images were all a certain plane, which was so special that I used inventor to generate an oblique triangle. After reading the data, I cried:

Data:

Because it is a three-dimensional image, we did not immediately discover the rule of control points. After a long period of observation, we used software to draw points and control points on the plane and analyze the side length, finally, we found the final rule: The image is still the image above:


Conclusion:

For any plane X, the control point (the concept of a box) is a rectangle that shares a plane x and is surrounded by plane x. S is the length of one side, and T is the length of the other side.

In this way, the format of 128 is displayed. Assume that the four control points are P1, P2, P3, P4, and the two sides are a and B, the final 128 format is:


As for code writing, we use

406,504,502,128,126,508,510,514,186 these elements (an individual contains a 504, A 502, A 514, and a 186. One individual contains multiple sides, one bread contains one 128, one 508, one 510, and multiple 126 .), Because 504 (edge table) requires all P values of 126. Therefore, when exporting the IGES format, first write the information of segment S and segment G to the file 2, and then divide it into two steps, the first step is to cycle all faces to process all edges as 126 (only P values are allocated and no specific data is processed. Open an array, record the P value of each 126, and pay attention to the judgment of the duplicate edge. I use a temporary table), and then integrate the P value into the array of 504. After processing, all the faces are recycled, and the value of the P segment of the Information 504,128,126 is written into the 1 file, and the value of the D segment is written into the 2 file. After all the bodies are processed, write the T-segment value to file 1, and finally Write File 1 to file 2. 2. The files are the files in the IG format to be exported.

The write part of the code is not very detailed, because this time I am mainly responsible for figuring out the 128 format and then writing the code that outputs the P and D segments, the specific format information is handled by a colleague.

Looking forward to opening bricks ~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.