A kind of quadrilateral subdivision curved surface access method based on vertex encoding
Technical field
The invention belongs to computer control and detection technique field, and in particular to a kind of quadrilateral subdivision based on vertex encoding
Curved surface access method.
Background technology
The fields such as quadrilateral subdivision curved surface is widely used in solid modelling, video display render, game movie makes.It
By being finely divided to quadrangle, original grid is set more to smooth out.But quadrilateral subdivision curved surface stores, it usually needs
Apex coordinate and topological structure are kept, with the increase of subdivision level, the unit number of subdivision curved surface increases by geometric progression, interior
Deposit occupancy to steeply rise, eventually result in internal memory spilling.
At present, the method for generally use self-adapting subdividing reduces quadrilateral subdivision curved surface EMS memory occupation amount, i.e., sharp
With the mechanism of perspective projection, it is finely divided for the quadrilateral units that can be shown in form, and the part that can not be shown is not
Process.Because this method does not influence on visual effect, made so being widely used in video display and rendering with game movie,
But this method does not apply to solid modelling but, because solid modelling usually requires to be finely divided all units.
Therefore, the present invention proposes a kind of quadrilateral subdivision curved surface access method based on vertex encoding, pass through one kind
Coding method is uniquely corresponding with the storage location where it by different summits, improves memory access efficiency, while utilize the group of coding
Close, it may be determined that any summit and unit in subdivision curved surface, avoid due to preserving subdivision curved surface topological structure and bring
Memory cost, this method is widely used in solid modelling, video display render and game movie, can improve memory usage 55% with
On.
The content of the invention
For the above-mentioned technological deficiency present in prior art, the invention provides a kind of quadrangle based on vertex encoding
Grid subdivision curved surface access method, it is using a kind of vertex encoding method that summit and storage location where it is uniquely corresponding, improve
Memory usage.
A kind of quadrilateral subdivision curved surface access method based on vertex encoding, comprises the following steps:
Step (1) segments level, for the four of quadrangle to be segmented to the quadrangle to be segmented of input according to given maximum
Individual vertex encoding;
Step (2) carries out recursion to the quadrangle to be segmented in step (1), until reaching given maximum subdivision of reservoir
It is secondary, and newly-generated summit is encoded in segmentation process every time;
Step (3) calculates position of each vertex encoding in vertical array, and the coordinate on each summit then is stored in into top
Position corresponding to the vertex encoding in point array.
Coding of the step (4) according to top four angle points of subdivision curved surface, calculates the coding at side center and face center, enters
And the vertex encoding of quadrilateral units in all subdivision curved surfaces is obtained by recursive fashion, calculate the summit according to vertex encoding
Position in vertical array, then according to the position extraction apex coordinate calculated.
To the network of quadrilaterals lattice model to be segmented of input in described step (1), according to given maximum subdivision level, it is
Four vertex encodings of quadrangle to be segmented, comprise the following steps:
The maximum subdivision level m that 1-1. foundations give, calculates the number of vertices n often to be gone after m subdivision with each column,
1-2. treats four vertex encodings of subdivision quadrangle using decimal integer according to clock-wise order, and this ten enters
The front two of integer processed to should summit column row number, latter two to should the line number be expert at of summit, specifically:
It is 1 that 1-2-1., which arbitrarily chooses a summit in quadrangle to be segmented as initial vertex, line number row number,
1-2-2. chooses next summit, row number 1, line number n along clockwise direction;
1-2-3. chooses next summit along clockwise direction, and line number row number is n;
1-2-4. chooses next summit, row number n, line number 1 along clockwise direction;
In described step (2), recursion is carried out to the quadrangle to be segmented in step (1), until reaching given
Maximum subdivision level, and newly-generated summit is encoded, specifically comprised the following steps in segmentation process every time:
2-1. updates original apex coordinate, and generate new side central point and face central point, side center according to subdivision rules
Point is encoded to two vertex encoding averages on the place side, and vertex encoding is averaged on face diagonal where face central point is encoded to
Number;
2-2. repeat step 2-1, until reaching maximum subdivision level.
Position of each vertex encoding in vertical array is calculated in described step (3), using equation below:
(number/MAX-1) × n+number%MAX-1;
Wherein number is vertex encoding, and MAX chooses 10 integral number power just greater than n;
Position of the summit in vertical array is calculated according to vertex encoding in described step (4), then according to meter
The position extraction apex coordinate calculated, the calculating of position of its summit in vertical array use equation below:
(number/MAX-1) × n+number%MAX-1
Wherein number is vertex encoding, and MAX chooses 10 integral multiple just greater than n.
In described step (2), quadrangle is finely divided using Catmull-Clark methods.
The present invention has the beneficial effect that:
The present invention is uniquely corresponding with the storage location where it by different summits by a kind of coding method, while utilizes volume
The superposition of code and coding, it may be determined that any summit and unit in subdivision curved surface, avoid due to preserving subdivision curved surface topology
Structure and the memory cost brought, this method is widely used in solid modelling, video display render and game movie, can improve internal memory
Utilization rate more than 55%.
The content of the invention
Brief description of the drawings
Fig. 1 is the step schematic flow sheet of quadrilateral subdivision curved surface access method of the present invention;
Fig. 2 (a) is that the original quadrangle of input is encoded;
Fig. 2 (b) is subdivision result for the first time;
Fig. 2 (c) is second of subdivision result;
Embodiment
In order to more specifically describe the present invention, below in conjunction with the accompanying drawings and embodiment is to network of quadrilaterals of the invention
Lattice subdivision curved surface access method is described in detail.
As shown in figure 1, a kind of be based on vertex encoding quadrilateral subdivision curved surface access method, comprise the following steps:
Step (1) segments level, for four of quadrangle to be segmented to the original quadrangle of input according to given maximum
Vertex encoding, as shown in Fig. 2 (a);
To the original network of quadrilaterals lattice model of input, according to given maximum subdivision level, for quadrangle four to be segmented
Individual vertex encoding, comprises the following steps:
The maximum subdivision level m that 1-1. foundations give, calculates the number of vertices n often to be gone after m subdivision with each column,
1-2. is according to clock-wise order, with a decimal integer to four vertex encodings of quadrangle, preceding the two of the integer
Position to should summit column row number, latter two to should the line number be expert at of summit,
It is 1 that 1-2-1., which arbitrarily chooses a summit in quadrangle as initial vertex, line number row number,
1-2-2. chooses next summit, row number 1, line number n along clockwise direction;
1-2-3. chooses next summit along clockwise direction, and line number row number is n;
1-2-4. chooses next summit, row number n, line number 1 along clockwise direction;
Step (2) carries out recursion to the quadrangle in step (1), until reaching given maximum subdivision level, often
In secondary segmentation process, newly-generated summit is encoded, as shown in Fig. 2 (b);
Recursion is carried out to the quadrangle in step (1), until reach given maximum subdivision level, it is subdivided every time
Cheng Zhong, newly-generated node is encoded, comprised the following steps:
2-1. updates original apex coordinate, and generate new side central point and face central point, side center according to subdivision rules
Point is encoded to two vertex encoding averages of corresponding sides, and vertex encoding is averaged on face diagonal where face central point is encoded to
Number,
2-2. repeat step 2-1, until reaching maximum subdivision level.
Quadrangle is finely divided using Catmull-Clark methods.
Step (3) is all summits of subdivision curved surface of generation, calculates position of the vertex encoding in vertical array, such as Fig. 2
(c) shown in;
Vertex encoding number is calculated in vertical array using formula (number/MAX-1) * n+number%MAX-1
Position, wherein, MAX choose just greater than n 10 integral multiple;
Coding of the step (4) according to top four angle points of subdivision curved surface, calculates the coding at side center and face center, enters
And the coding on all subdivision curved surface summits is obtained by recursive fashion, calculate position of the summit in vertical array according to coding
Put.
Equal to the coding average value on corresponding sides summit, face centre code is equal on corresponding face diagonal to be compiled paracentral coding
The average value of code, vertex encoding number is calculated in vertical array using formula (number/MAX-1) * n+number%MAX-1
In position.