Summary of the invention
Technical matters to be solved by this invention is the determination methods of graphic element information in a kind of vector font triangular plate modeling process, in order to improve the speed of vector font triangular plate modeling.
In order to address the above problem, the invention discloses the determination methods of graphic element information in a kind of vector font triangular plate modeling process, comprising:
Input step: the input vector digital data, wherein, described vector font approaches the back vector polygon for the outline line segment, and described vector font data comprise the data of a plurality of vector points;
Y direction ordered steps: the vector font data are sorted, obtain the ranking results of coordinate Y direction;
Directions X ordered steps: the vector font data are sorted, obtain the ranking results of coordinate directions X;
Determining step: according to the vector font data, and the ranking results of coordinate Y direction and coordinate directions X, the graphic element information in the triangular plate modeling process is judged.
Preferably, described graphic element information is the crossing information of two line segments, and wherein, the end points of described line segment is the vector point;
Described determining step comprises:
Obtain the ranking results of the two-end-point of first line segment: the first starting point Y sequence number, the first terminal point Y sequence number, the first starting point X sequence number, the first terminal point X sequence number at Y direction and directions X;
Obtain the ranking results of the two-end-point of second line segment: the second starting point Y sequence number, the second terminal point Y sequence number, the second starting point X sequence number, the second terminal point X sequence number at Y direction and directions X;
According to the ranking results of first judgment rule and these two line segments, obtain the crossing information of these two line segments, wherein, described first judgment rule is:
If the minimum value in the first starting point X sequence number, the first terminal point X sequence number is greater than the maximal value in the second starting point X sequence number, the second terminal point X sequence number,
Perhaps, the maximal value in the first starting point X sequence number, the first terminal point X sequence number is less than the minimum value in the second starting point X sequence number, the second terminal point X sequence number,
Perhaps, the minimum value in the first starting point Y sequence number, the first terminal point Y sequence number is greater than the maximal value in the second starting point Y sequence number, the second terminal point Y sequence number,
Perhaps the maximal value in the first starting point Y sequence number, the first terminal point Y sequence number is less than the minimum value in the second starting point Y sequence number, the second terminal point Y sequence number,
Then described two line segments are non-intersect.
Preferably, described graphic element information is for treating judging point and leg-of-mutton position relation information, wherein, describedly treats that judging point and 3 summits of triangle are the vector point;
Described determining step comprises:
Obtain the described ranking results for the treatment of judging point at Y direction and directions X: Y sequence number and X sequence number;
According to the Y direction ranking results on 3 summits of triangle, obtain maximum Y sequence number and minimum Y sequence number;
According to the directions X ranking results on 3 summits of triangle, obtain maximum X sequence number and minimum X sequence number;
According to second judgment rule, and Y sequence number, X sequence number, maximum Y sequence number, minimum Y sequence number, maximum X sequence number and minimum X sequence number are obtained and are treated judging point and leg-of-mutton position relation information, and wherein, described second judgment rule is:
If the X sequence number is greater than maximum X sequence number,
Perhaps, the X sequence number is less than minimum X sequence number,
Perhaps, the Y sequence number is greater than maximum Y sequence number,
Perhaps, the Y sequence number is less than minimum Y sequence number,
Then this treats that judging point is not in triangle.
Preferably, described graphic element information is the salient angle vertex information;
Described determining step comprises:
According to the ranking results of coordinate Y direction, find out the vector point of Y maximum, as the salient angle summit.
Preferably, described method also comprises:
Preserve step: the data of described a plurality of vector points are remained to data array.
Preferably, described modeling process is:
Seek operation: in current vector polygon, find a salient angle summit PC, and this salient angle summit PC and preceding some PP thereof put triangle { PP, PC, the PN} that PN forms with the back;
First decision operation: at the arbitrary vector point PI except that PP, PC, PN in the current vector polygon, judge whether it satisfies the condition of cutting apart, if then carry out and cut apart the polygon operation, otherwise, carry out the operation of output triangle, wherein, the described condition of cutting apart is, PI is at triangle { PP, PC, in the PN}, and the line PIPC of PI and PC not be not the line segment intersection of end points in the vector polygon with PI or PC;
Cut apart the polygon operation: use PIPC that current vector polygon is divided into two, and return and seek operation, respectively described two vector polygons are handled;
The operation of output triangle: { PP, PC, PN} are a triangular plate, and the PC point is removed from the data array of current vector polygon in output;
Second decision operation: whether the number of judging vector point in the data array of current vector polygon less than 3, if, then carry out and remove the polygon operation, otherwise, return and seek operation;
Removal polygon operation: the data array of removing current vector polygon;
The 3rd decision operation: judge whether to exist vector polygon, if, then return and seek operation, otherwise, end operation carried out;
End operation: the triangular plate modeling finishes.
Preferably, described Y direction ordered steps comprises:
,, then sort to described vector font data sorting according to Y coordinate size according to X coordinate size if the Y coordinate is equal.
Preferably, described directions X ordered steps comprises:
,, then sort to described vector font data sorting according to X coordinate size according to Y coordinate size if the X coordinate is equal.
Compared with prior art, the present invention has the following advantages:
The present invention at first sorts to known floating point values in vector font triangular plate modeling process, like this, when the judgement that needs certain floating point values to participate in, can use the sequence number of this floating point values at ranking results; Because using the ordering sequence number of floating point values judges, in fact floating-point operation has been transformed into the integer computing, and the floating point values number of comparisons that the number of times of the floating point values comparison that ordering the time need be used carries out when being far smaller than the triangular plate modeling, thereby can improve arithmetic speed, and then improve the speed of triangular plate modeling.
Embodiment
For above-mentioned purpose of the present invention, feature and advantage can be become apparent more, the present invention is further detailed explanation below in conjunction with the drawings and specific embodiments.
Carry out at the practical application floating point values whether certain point is specifying in the triangle, whether a certain line segment during with the judgement of information such as another line segment intersection, participates in the floating point values judged, it extracts vector font information really and obtains just having determined behind a series of polygons.
One of core idea of the present invention is, behind the floating point values of determining vector font, all floating point values is sorted, and like this, when the judgement that needs certain floating point values to participate in, can use the sequence number of this floating point values at ranking results; Because using the ordering sequence number of floating point values judges, in fact floating-point operation has been transformed into the integer computing, and the floating point values number of comparisons that the number of times of the floating point values comparison that ordering the time need be used carries out when being far smaller than the triangular plate modeling, thereby can improve the speed of triangular plate modeling.
With reference to Fig. 1, show the process flow diagram of the determination methods embodiment of graphic element information in a kind of vector font triangular plate of the present invention modeling process, specifically can comprise:
Input step 11, input vector digital data, wherein, described vector font approaches the back vector polygon for the outline line segment, and described vector font data can comprise the data of a plurality of vector points;
In practice, described graphic element information can comprise the crossing information of two line segments, treat information such as judging point and leg-of-mutton position relation information, salient angle summit, wherein, describedly wait to judge that object is all relevant with described vector point, for example, the end points of described line segment is the vector point, the described judging point for the treatment of is the vector point, and 3 summits of described triangle are vector point etc.
In specific implementation, the first step of modeling should be the extraction of vector font data; With English alphabet L is example, after can approaching the outline line segment of this English alphabet L, obtains vector polygon shown in Figure 2, this vector polygon can comprise a plurality of vector points, and at this moment, the coordinate data array of described a plurality of vector points promptly can be as the input data in the modeling process: (x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5), (x6, y6).
For convenient described vector font data are managed, in a preferred embodiment of the present invention, determination methods of the present invention can also comprise:
Preserve step, the data of described a plurality of vector points are remained to data array.
Data array has been arranged, after cutting apart a triangle (be unified term, all adopt triangle to describe triangular plate in the modeling process), can should from data array, remove on leg-of-mutton salient angle summit; Like this, can change the wherein number of vector point, cut apart with convenient ensuing triangle by upgrading data array.
Y direction ordered steps 12, the vector font data are sorted, obtain the ranking results of coordinate Y direction;
The implementation procedure of this step can for: according to Y coordinate size to described vector font data sorting, if the Y coordinate equate, then sort according to X coordinate size; If the XY coordinate system according to shown in Figure 3 sorts in the Y direction from big to small to vector polygon shown in Figure 2, then the ranking results of its coordinate Y direction is: P5, P6, P4, P3, P2, P1.
Directions X ordered steps 13, the vector font data are sorted, obtain the ranking results of coordinate directions X;
In practice, the implementation of this step can for: according to X coordinate size described point data is sorted, if the X coordinate equate, then sort according to Y coordinate size; XY coordinate system according to shown in Figure 3 sorts in the Y direction from big to small to vector polygon shown in Figure 2, and then the ranking results of its coordinate Y direction is: P5, P4, P3, P2, P6, P1.
Determining step 14, according to the vector font data, and the ranking results of coordinate Y direction and coordinate directions X is judged the graphic element information in the triangular plate modeling process.
The algorithm of vector font triangular plate modeling at present is a lot, and very ripe, in a kind of preferred embodiment of the present invention, adopts fast algorithm as prototype, and at this moment, the flow process of described triangular plate modeling can comprise the steps:
Seek operation S1, in current vector polygon, find a salient angle summit PC, and this salient angle summit PC and preceding some PP thereof put triangle { PP, PC, the PN} that PN forms with the back;
This action need is used the judgement of salient angle vertex information.
A method of proof of polygon salient angle is: exist the straight line of this angular vertex of mistake to make except this summit, other point of polygon is all on same one side of this straight line; Can find out that by geometrical principle that vector point of the Y maximum in the ranking results of coordinate Y direction must satisfy top method of proof, for example, the P6 among Fig. 2 is the salient angle summit.
Because this operation only need be found a salient angle summit PN, so, when described graphic element information is the salient angle vertex information; The implementation of described determining step 14 can for: according to the ranking results of coordinate Y direction, find out the vector point of Y maximum, as the salient angle summit.
Therefore, with respect to the angle of prior art repeated calculation angle point, the present invention only need find that vector point of Y maximum, thereby can save computing velocity greatly.
The first decision operation S2, at the arbitrary vector point PI except that PP, PC, PN in the current vector polygon, judge whether it satisfies the condition of cutting apart, if then carry out and cut apart polygon operation S3, otherwise, carry out output triangle operation S4, wherein, the described condition of cutting apart is, PI is at triangle { PP, PC, in the PN}, and the line PIPC of PI and PC not be not the line segment intersection of end points in the vector polygon with PI or PC;
This action need is used the judgement for the treatment of judging point and leg-of-mutton position relation information, and wherein, described judging point and 3 summits of triangle for the treatment of are the vector point of vector polygon;
At this moment, described determining step 14 can comprise following substep:
Substep A1, obtain the described ranking results for the treatment of judging point at Y direction and directions X: Y sequence number and X sequence number;
Substep A2, according to the Y direction ranking results on 3 summits of triangle, obtain maximum Y sequence number and minimum Y sequence number;
Substep A3, according to the directions X ranking results on 3 summits of triangle, obtain maximum X sequence number and minimum X sequence number;
Substep A4, according to second judgment rule, and Y sequence number, X sequence number, maximum Y sequence number, minimum Y sequence number, maximum X sequence number and minimum X sequence number are obtained and are treated judging point and leg-of-mutton position relation information, wherein, described second judgment rule can for:
If the X sequence number is greater than maximum X sequence number,
Perhaps, the X sequence number is less than minimum X sequence number,
Perhaps, the Y sequence number is greater than maximum Y sequence number,
Perhaps, the Y sequence number is less than minimum Y sequence number,
Then this treats that judging point is not in triangle.
The structure principle of above-mentioned second judgment rule is, has not in the rectangular area that triangle covers by other point relatively, filters a large amount of irrelevant points, and therefore, the present invention has and filters irrelevant point, thereby reduces the advantage of floating point values operand; For the vector point that does not meet second judgment rule, also need to use floating point values to judge that further it is whether in the triangle of appointment.
Be appreciated that the present invention is not limited to described second judgment rule, those skilled in the art can make up other second judgment rule as required, and the present invention is not limited this.
This operation also needs to use the judgement of the crossing information of two line segments, and wherein, the end points of described line segment is the vector point;
At this moment, described determining step 14 can comprise following substep:
Substep B1, obtain the ranking results of the two-end-point of first line segment: the first starting point Y sequence number, the first terminal point Y sequence number, the first starting point X sequence number, the first terminal point X sequence number at Y direction and directions X;
Substep B2, obtain the ranking results of the two-end-point of second line segment: the second starting point Y sequence number, the second terminal point Y sequence number, the second starting point X sequence number, the second terminal point X sequence number at Y direction and directions X;
Substep B3, according to the ranking results of first judgment rule and these two line segments, obtain the crossing information of these two line segments, wherein, described first judgment rule can for:
If the minimum value in the first starting point X sequence number, the first terminal point X sequence number is greater than the maximal value in the second starting point X sequence number, the second terminal point X sequence number,
Perhaps, the maximal value in the first starting point X sequence number, the first terminal point X sequence number is less than the minimum value in the second starting point X sequence number, the second terminal point X sequence number,
Perhaps, the minimum value in the first starting point Y sequence number, the first terminal point Y sequence number is greater than the maximal value in the second starting point Y sequence number, the second terminal point Y sequence number,
Perhaps the maximal value in the first starting point Y sequence number, the first terminal point Y sequence number is less than the minimum value in the second starting point Y sequence number, the second terminal point Y sequence number,
Then described two line segments are non-intersect.
Cut apart polygon operation S3, use PIPC that current vector polygon is divided into two, and return and seek operation S1, respectively described two vector polygons are handled;
The output triangle is operated S4, { PP, PC, PN} are a triangular plate, and the PC point is removed from the data array of current vector polygon in output;
Especially, cut apart the existence that polygon operation S3 tends to cause a plurality of vector polygons; After the data that removal PC is ordered from the data array of current vector polygon, should judge also whether the PC point is present in other arbitrary vector polygon, if not, then this PC point is removed from ranking results.
The second decision operation S5, judge vector point in the data array of current vector polygon number whether less than 3, if, then carry out and remove polygon operation S6, otherwise, return and seek operation S1;
Remove the data array of polygon operation S6, the current vector polygon of removal;
Especially, for 2 points of other except that the PC point in the current vector polygon,, then it is removed from ranking results if it is not present in other arbitrary vector polygon.
The 3rd decision operation S7, judge whether to exist vector polygon, if, then return and seek operation S1, otherwise, end operation S8 carried out;
End operation S8; The triangular plate modeling finishes.
As seen, in the process of above-mentioned triangular plate modeling, operation S1 need calculate the angle of angle point; The vector point that operation S2 need judge appointment whether in the appointment triangle, and, the crossing information of two line segment intersections.
Prior art is when carrying out aforesaid operations, need to adopt floating point values to calculate, these calculate when handling the simplification polygon of these 6 points also unimportant, increase along with point, the time of its consumption becomes geometric series to rise, and general vector font all is made up of hundreds of even thousands of points; And determination methods of the present invention can find the salient angle summit easily, perhaps, filters a large amount of irrelevant points, so can improve arithmetic speed.
For making those skilled in the art understand the present invention better, below by example explanation, the implementation procedure that the graphic element information in the vector font triangular plate modeling process is judged.
Described example relates to, and English alphabet L vector polygon shown in Figure 2 is carried out the triangular plate modeling, obtains the vector type matrix of English alphabet L shown in Figure 4, and output in the direction of the clock; Wherein, the output data of 4 triangular plates among Fig. 2,3 vertex representations of available triangular plate: { P5, P6, P4}, { P6, P3, P4}, { P6, P1, P3}, { P3, P1, P2}; Original vector polygon is P1 at Y direction ranking results from small to large, P2, and P3, P4, P6, P5 is P1 at directions X ranking results from small to large, P6, P2, P3, P4, P5; The flow process of described triangular plate modeling specifically can comprise the steps:
Step T1, according to Y direction ranking results, in current vector polygon, find a salient angle summit P5, and, with reference to Fig. 5, triangle { P5, P6, P4} that this salient angle summit P5 and preceding some P4 thereof and back point P6 form;
Step T2, learn that through judgement other vector point P1, P2, the P3 of current vector polygon all do not satisfy dividing strip spare;
For example, when judging vector point P1 and leg-of-mutton position relation information, because the ranking results of P1 is respectively { X=1, Y=1}, triangle { P5, P6, { Xmin=2, Xmax=6, the Ymin=4 of P4}, Ymax=6}, and, X<Xmin, so can learn that P1 is not at triangle { P5, P6 according to second judgment principle, in the P4}, thereby P1 does not satisfy dividing strip spare.
For P2{X=3, Y=2}, P3{X=4, Y=3} is because its deterministic process and P1's is similar, so do not give unnecessary details at this.
Step T3, with reference to Fig. 6, the output triangular plate P4} removes the P5 point from current vector polygon for P5, P6, and, because P5 point does not have the vector polygon of correspondence, so, it is removed from ranking results;
Data after the renewal:
Vector polygon: { P1, P2, P3, P4, P6};
Y direction ranking results from small to large: P1, P2, P3, P4, P6;
Directions X ranking results from small to large: P1, P6, P2, P3, P4;
Triangular plate output result: { P5, P6, P4}.
The number 5>3 of vector point in the vector polygon after step T4, the renewal is so carry out the searching operation on salient angle summit;
Step T5, according to the Y direction ranking results after upgrading, in current vector polygon, find a salient angle summit P6, and, with reference to Fig. 7, triangle { P1, P6, P4} that this salient angle summit P6 and preceding some P4 thereof and back point P1 form;
Step T6, learn that the vector point P3 of current vector polygon satisfies the condition of cutting apart through judgement;
With reference to Fig. 7, { in the P4}, and line segment P3P6 does not intersect with line segment P1P2, P1P4, P2P4 P3 for P1, P6 at triangle.
Step T7, with reference to Fig. 8, use line segment P3P6, current vector polygon is divided into following two:
Vector polygon 1{P1, P2, P3, P6}
Vector polygon 2{P3, P4, P6}
Step T8, for vector polygon 2{P3, P4, P6}, the Y direction ranking results according to after upgrading finds a salient angle summit P6, and, with reference to Fig. 7, triangle { P3, P6, P4} that this salient angle summit P6 and preceding some P4 thereof and back point P3 form;
Step T9, because vector polygon 2{P3, P4, P6} outside the some P4 of back, do not have other to put except a P6 and its preceding some P3 again, obviously do not satisfy dividing strip spare;
Step T10, with reference to Fig. 8, the output triangular plate P4} removes the P6 point from vector polygon 2 for P3, P6, at this moment because the P6 point is also at vector polygon 1{P1, P2, P3 is among the P6}, so do not remove from ranking results.Data after obtaining upgrading:
Vector polygon 1:{P1, P2, P3, P6};
Y direction ranking results from small to large: P1, P2, P3, P6;
Directions X ranking results from small to large: P1, P6, P2, P3;
Triangular plate output result: { P5, P6, P4}, { P3, P6, P4}.
Step T11, owing to also have vector polygon 1{P1, P2, P3, P6} operates so carry out the searching on salient angle summit;
Step T12, according to the Y direction ranking results after upgrading, in vector polygon 1, find a salient angle summit P6, and, with reference to Fig. 9, triangle { P1, P6, P3} that this salient angle summit P6 and preceding some P3 thereof and back point P1 form;
Step T13, learn that through judgement the vector point P2 of current vector polygon does not satisfy dividing strip spare;
Step T14, with reference to Figure 10, the output triangular plate P3} removes the P6 point from vector polygon 1 for P1, P6, and, because P6 point does not have the vector polygon of correspondence, so, it is removed from ranking results;
Data after the renewal:
Vector polygon 1{P1, P2, P3};
Y direction ranking results from small to large: P1, P2, P3;
Directions X ranking results from small to large: P1, P2, P3;
Output result: { P5, P6, P4}, { P3, P6, P4}, { P1, P6, P3}.
The number of vector point is 3 in the vector polygon 1 after step T15, the renewal, so carry out the searching operation on salient angle summit;
Step T16, according to the Y direction ranking results after upgrading, in vector polygon 1, find a salient angle summit P3, and, triangle { P3, P1, P2} that this salient angle summit P3 and preceding some P2 thereof and back point P1 form;
Step T17, because vector polygon 1{P1, P2, P3} outside the some P1 of back, do not have other to put except a P3 and its preceding some P2 again, obviously do not satisfy dividing strip spare;
Step T18, with reference to Figure 11, the output triangular plate P3} removes the P3 point from vector polygon 1 for P1, P2, at this moment because there is not the vector polygon of correspondence in P3 point, so from ranking results, remove.Data after obtaining upgrading:
Vector polygon 1:{P1, P2};
Y direction ranking results from small to large: P1, P2;
Directions X ranking results from small to large: P1, P2;
Triangular plate output result: { P5, P6, P4}, { P3, P6, P4}, { P1, P6, P3}, { P1, P2, P3}.
Vector polygon 1{P1 after step T19, the renewal, the number of vector point is 2<3 among the P2}, the vector polygon 1 of dieing is not because P1, P2 be in other vector polygon, so remove from ranking results;
Step T20, currently do not have vector polygon, thus modeling finish, with reference to Figure 12, in a kind of application example of the present invention, the modeling result of output can for:
Vector polygon: sky
Y direction ranking results from small to large: sky
Directions X ranking results from small to large: sky
Triangular plate output result: { P5, P6, P4}, { P3, P6, P4}, { P1, P6, P3}, { P1, P2, P3}.
More than to the determination methods of graphic element information in a kind of vector font triangular plate modeling process provided by the present invention, be described in detail, used specific case herein principle of the present invention and embodiment are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.