1. The question was raised
In some database management systems or office automation and statistical software, generally have the ability to draw three-dimensional view. When used, it is usually required to input drawing data, angle of view, scale and other parameters in the given table. This only applies to the small batch of statistical data to draw statistical three-dimensional view. In many fields, such as geology, geomorphology, meteorology, hydrology, transportation, forestry and so on, a certain quantity that needs to be described usually has the spatial distribution characteristic, this kind of spatial distribution data quantity is generally very huge, when uses the three-dimensional view software drawing often can encounter the problem which the number of tables cannot hold And it's also easy to make mistakes and consume a lot of human resources by typing data back into a table.
The drawing of three-dimensional view and the organization of the corresponding drawing data is not a very difficult thing, and it can be achieved with a small amount of program code. This paper will introduce a simple method of using C + + language to draw three-dimensional view of mass data. The key technology of this method is as follows: (1) The FoxPro database management system is used to organize the drawing data and make the. h files that can be included and invoked for C + + language, (2) in the drawing of three-dimensional view, the "Polygon method" is used to hide the segment.
2. Preparation of drawing data
The original data for the drawing comes from the FoxPro (or Foxbase) database management system. You can place the data of a picture in a one-dimensional array and include it in an. h file. This allows the data to be invoked anywhere in the program, as long as the header file is included in the first three-dimensional view of the C + + program. For example, there is a data string: 3,8,10,11,27,6, ..., set to hold an array of a, the data file name is Data.h, in Data.h, the data string is stored in the form of:
a={3,8,10,11, 27, 6,::};
The data can be copied from the FoxPro. dbf file. Of course, before the copy will need to undergo a simple processing. In a. dbf file, the field to which the drawing data is located is DT1, where you can add a DH (comma) of the field and replace the contents of the fields with "," and then copy the following command to the Data.h file: Copy to Data.h field DT1,DH dele with Blank then opens the Data.h file, adding "a={" at the beginning of the data, plus "};" At the end of the data.
3. Drawing three-dimensional view programming basic idea
The key technique of drawing three-dimensional view is "blanking", i.e. eliminating the invisible line in three-dimensional observation. In the book on "Computer Graphics," The Hidden method is more "computational method", that is, from the current data point row in the drawn lines which should be hidden, and then clear the lines. The author has designed a simple and novel method of blanking (this is called "polygon Method"), not only the program code is simple, but also the principle of the blanking method is very concise and clear. The basic idea and operation steps are introduced as follows:
3.1 The first row of data painting x direction network cable. Connecting the first row data points with the line function;
3.2 Draw Y-direction network cable. The 2nd row and 1th row in the y direction corresponding to the data point line;
3.3 "Polygon Method" to do blanking. According to the 2nd row of data in the background color brush a polygon, so that the 2nd row of data points may be obscured by lines (that is, should be hidden lines) that is erased;
3.4 2nd row data draw x direction network cable. Connecting the 2nd row of data points with the line function;
3.5 Repeat steps 3.2~3.4 until the complete diagram is drawn.