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, be specifically related to a kind of quadrilateral subdivision curved surface access method based on vertex encoding.
Background technology
The fields such as quadrilateral subdivision curved surface is widely used in solid modelling, video display are played up, game movie making.It is by segmenting quadrilateral, makes original grid more smooth-going.But quadrilateral subdivision curved surface stores, usually need to keep apex coordinate and topological structure, along with the increase of segmentation level, the unit number of subdivision curved surface increases by geometric progression, and EMS memory occupation amount sharply rises, and internal memory finally can be caused to overflow.
At present, usually adopt the method for self-adapting subdividing to reduce quadrilateral subdivision curved surface EMS memory occupation amount, namely utilize the mechanism of perspective projection, the quadrilateral units that can be presented in form is segmented, and the part that can not show does not process.Because this method does not affect visual effect, play up and game movie making so be widely used in video display, but this method is inapplicable solid modelling, because solid modelling needs to segment all unit usually.
For this reason, the present invention proposes a kind of quadrilateral subdivision curved surface access method based on vertex encoding, by a kind of coding method, different summit is uniquely corresponding with the memory location at its place, improve memory access efficiency, utilize the combination of coding simultaneously, any summit in subdivision curved surface and unit can be determined, avoid the memory cost brought owing to preserving subdivision curved surface topological structure, this method is widely used in solid modelling, video display are played up and game movie, can improve memory usage more than 55%.
Summary of the invention
For the above-mentioned technological deficiency existing for prior art, the invention provides a kind of quadrilateral subdivision curved surface access method based on vertex encoding, utilize a kind of vertex encoding method that summit is uniquely corresponding with its memory location, place, improve memory usage.
Based on a quadrilateral subdivision curved surface access method for vertex encoding, comprise the steps:
Step (1) treats segmentation quadrilateral to what input, according to given maximum segmentation level, for waiting four vertex encodings segmenting quadrilateral;
Step (2) is segmented quadrilateral to treating in step (1) and is carried out recursion, until reach given maximum segmentation level, and in each segmentation process, encodes to newly-generated summit;
Step (3) calculates the position of each vertex encoding in vertical array, then by the coordinate on each summit stored in position corresponding to this vertex encoding in vertical array.
Step (4) is according to the coding of most top layer subdivision curved surface four angle points, calculate the coding at center, limit and center, face, and then the vertex encoding of quadrilateral units in all subdivision curved surfaces is obtained by recursive fashion, calculate the position of this summit in vertical array according to vertex encoding, then extract apex coordinate according to the position calculated.
Treating segmentation network of quadrilaterals lattice model to what input in described step (1), according to given maximum segmentation level, for waiting four vertex encodings segmenting quadrilateral, comprising the steps:
1-1., according to given maximum segmentation level m, calculates and often goes and the number of vertices n often arranged after m segmentation,
1-2., according to clock-wise order, adopts decimal integer to treat four vertex encodings of segmentation quadrilateral, the front two of this decimal integer to should the row number of summit column, rear two to should the summit line number of being expert at, concrete:
1-2-1. chooses arbitrarily and waits to segment a summit in quadrilateral as initial vertex, and line number row number are 1,
1-2-2. chooses next summit along clockwise direction, and row number are 1, and line number is n;
1-2-3. chooses next summit along clockwise direction, and line number row number are n;
1-2-4. chooses next summit along clockwise direction, and row number are n, and line number is 1;
In described step (2), quadrilateral is segmented to treating in step (1) and carries out recursion, until reach given maximum segmentation level, and in each segmentation process, encoded in newly-generated summit, specifically comprise the steps:
2-1. is according to subdivision rules, and upgrade original apex coordinate, and generate new limit central point and face central point, limit central point is encoded to two vertex encoding averages on this limit, place, and face central point is encoded to vertex encoding average on the face diagonal of place;
2-2. repeats step 2-1, until reach maximum segmentation level.
Calculate the position of each vertex encoding in vertical array in described step (3), adopt following formula:
(number/MAX-1)×n+number%MAX-1;
Wherein number is vertex encoding, MAX choose just greater than n 10 integral number power;
Calculate the position of this summit in vertical array according to vertex encoding in described step (4), then extract apex coordinate according to the position calculated, the calculating of the position of its summit in vertical array adopts following formula:
(number/MAX-1)×n+number%MAX-1
Wherein number is vertex encoding, MAX choose just greater than n 10 integral multiple.
In described step (2), Catmull-Clark method is adopted to segment quadrilateral.
Beneficial effect of the present invention is as follows:
The present invention is uniquely corresponding with the memory location at its place by different summit by a kind of coding method, utilize the superposition of coding and coding simultaneously, any summit in subdivision curved surface and unit can be determined, avoid the memory cost brought owing to preserving subdivision curved surface topological structure, this method is widely used in solid modelling, video display are played up and game movie, can improve memory usage more than 55%.
Summary of the invention
Accompanying drawing explanation
Fig. 1 is the steps flow chart schematic diagram of quadrilateral subdivision curved surface access method of the present invention;
Fig. 2 (a) is the original quadrilateral coding to input;
Fig. 2 (b) is for segmenting result for the first time;
Fig. 2 (c) is for segmenting result for the second time;
Embodiment
In order to more specifically describe the present invention, below in conjunction with the drawings and the specific embodiments, quadrilateral subdivision curved surface access method of the present invention is described in detail.
As shown in Figure 1, a kind of based on vertex encoding quadrilateral subdivision curved surface access method, comprise the steps:
Step (1) to the original quadrilateral of input, according to given maximum segmentation level, for waiting to segment four vertex encodings of quadrilateral, as shown in Fig. 2 (a);
To the original network of quadrilaterals lattice model of input, according to given maximum segmentation level, be quadrilateral four vertex encodings to be segmented, comprise the steps:
1-1., according to given maximum segmentation level m, calculates and often goes and the number of vertices n often arranged after m segmentation,
1-2. according to clock-wise order, by a decimal integer to quadrilateral four vertex encodings, the front two of this integer to should the row number of summit column, rear two to should the summit line number of being expert at,
1-2-1. chooses arbitrarily a summit in quadrilateral as initial vertex, and line number row number are 1,
1-2-2. chooses next summit along clockwise direction, and row number are 1, and line number is n;
1-2-3. chooses next summit along clockwise direction, and line number row number are n;
1-2-4. chooses next summit along clockwise direction, and row number are n, and line number is 1;
Step (2) carries out recursion to the quadrilateral in step (1), until reach given maximum segmentation level, in each segmentation process, encodes, as shown in Fig. 2 (b) to newly-generated summit;
Recursion is carried out to the quadrilateral in step (1), until reach given maximum segmentation level, in each segmentation process, newly-generated node is encoded, comprises the steps:
2-1. is according to subdivision rules, and upgrade original apex coordinate, and generate new limit central point and face central point, limit central point is encoded to two vertex encoding averages of corresponding sides, and face central point is encoded to vertex encoding average on the face diagonal of place,
2-2. repeats step 2-1, until reach maximum segmentation level.
Catmull-Clark method is adopted to segment quadrilateral.
Step (3) is all summits of subdivision curved surface generated, and calculates the position of vertex encoding in vertical array, as shown in Fig. 2 (c);
Use formula (number/MAX-1) * n+number%MAX-1 to calculate the position of vertex encoding number in vertical array, wherein, MAX choose just greater than n 10 integral multiple;
Step (4), according to the coding of most top layer subdivision curved surface four angle points, is calculated the coding at center, limit and center, face, and then is obtained the coding on all subdivision curved surface summits by recursive fashion, calculates the position of this summit in vertical array according to coding.
Paracentral coding equals the coding mean value on corresponding sides summit, face centre code equals the mean value that corresponding surface diagonal line is encoded, and uses formula (number/MAX-1) * n+number%MAX-1 to calculate the position of vertex encoding number in vertical array.