Method, device and electronic equipment for triangularizing textual information
By triangulating text information to generate triangular face data for rendering, the problem of rendering engine dependence on font files and low efficiency is solved, achieving stable text rendering effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 上海秉匠信息科技有限公司
- Filing Date
- 2022-10-28
- Publication Date
- 2026-07-14
AI Technical Summary
Existing rendering engines suffer from issues such as dependence on font files and low rendering efficiency when loading text information, especially when the system changes or the scene is scaled, which can easily lead to text style deviations and rendering stutters.
By triangulating text information into triangular face data, extracting the outline information of the text, and performing Boolean operations and triangulation, non-intersecting polygonal structures and triangulation sets are generated. This reduces the dependence on font files and lowers the CPU load during the rendering process.
It enables text rendering without relying on font files, improves rendering efficiency, reduces the impact of rendering engine scene changes on the CPU, and avoids text style deviations and stuttering.
Smart Images

Figure CN115861521B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer graphics display technology, and in particular to a method, apparatus, and electronic device for triangulating text information. Background Technology
[0002] In fields such as architecture, industry, and electromechanical engineering, CAD is frequently used to design and create 2D engineering drawings, in which text annotations are essential. In broader industry applications, CAD drawings are often parsed and loaded by various rendering engines as design references for 3D models. In this case, the text annotations and explanations on the drawings become significantly important for practical business development.
[0003] When current rendering engines load text at the pixel level, they must read the pixel information of the corresponding text from existing font files. This method usually works without problems when there is a perfect match, but as the operating system changes, font files may differ or become missing. This can lead to discrepancies between the text style and the design style, and even text loss when the corresponding text cannot be found. Therefore, most current rendering engines rely on the support of the system font library to use their specific text rendering methods.
[0004] Secondly, when the rendering engine loads text as a transparent bitmap, in addition to matching the corresponding font file, it also needs to consider whether the text bitmap resolution meets the scene's requirements when the scene is scaled. If the text bitmap resolution is fixed, the text bitmap will inevitably become distorted when the scene is enlarged; if a bitmap with a resolution suitable for the scene is generated in real time, it may not only require modifying the rendering batch, but also increase the CPU's extra burden when generating bitmaps in real time, especially when the number of characters in the scene is huge, resulting in stuttering and reduced rendering efficiency.
[0005] In summary, existing text rendering methods suffer from technical problems such as reliance on font files and low rendering efficiency. Summary of the Invention
[0006] The purpose of this invention is to provide a method, apparatus, and electronic device for text information triangulation, so as to alleviate the technical problems of existing text rendering methods that rely on font files and have low rendering efficiency.
[0007] In a first aspect, the present invention provides a method for triangulation of textual information, comprising:
[0008] Obtain the first text information of all text to be processed in a preset coordinate system, and extract the contour information corresponding to each text to be processed based on the first text information;
[0009] Based on the contour information corresponding to each of the characters to be processed, at least one non-self-intersecting polygonal contour is determined, and Boolean operations are performed on the polygonal contours to obtain at least one non-intersecting polygonal structure.
[0010] Triangulation is performed on the polygon structure corresponding to each of the texts to be processed to obtain a triangulation set corresponding to each text to be processed. The text to be processed is then rendered based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding text to be processed.
[0011] Furthermore, based on the contour information corresponding to each of the characters to be processed, at least one non-self-intersecting polygonal contour is determined, including:
[0012] Based on the attributes of each vertex in the contour information, the contour corresponding to the contour information is split into straight line segments and curve segments, and discrete points are inserted to discretize the curve segments into straight line segments;
[0013] Connect the adjacent vertices and discrete points to form a closed contour, and determine whether the closed contour has self-intersection;
[0014] If the closed contour has self-intersections, the number of discrete points in the discrete processing is increased, and the process returns to the step of connecting the vertices and discrete points to form a closed contour, until the formed closed contour is a polygonal contour without self-intersections, or the closed contour is disassembled to obtain multiple polygonal contours without self-intersections.
[0015] Furthermore, before extracting the contour information corresponding to each of the characters to be processed based on the first text information, the method further includes:
[0016] Determine whether the current text to be processed has been extracted based on the first text information of the current text to be processed;
[0017] If the outline information has been extracted, the current text to be processed is skipped, and the outline information of the subsequent text to be processed is extracted based on the first text information of the subsequent text to be processed.
[0018] Otherwise, extract the outline information of the current text to be processed based on the first text information of the current text to be processed.
[0019] Furthermore, the first text information includes: font format, font size, position, rotation angle, spacing, and font color.
[0020] Furthermore, rendering the text to be processed based on the triangulated set includes:
[0021] The triangulated set is transformed to obtain the transformed triangulated set;
[0022] The text to be processed is rendered based on the transformed triangulated set.
[0023] Furthermore, the triangulated set is transformed, including:
[0024] Obtain the second text information of all text to be processed in the coordinate system of the CAD drawing;
[0025] Calculate the text information transformation matrix corresponding to each text to be processed based on the first text information and the second text information, wherein the text information transformation matrix is the text information transformation matrix for transforming the first text information in the preset coordinate system to the second text information in the CAD drawing coordinate system;
[0026] The triangulated set is transformed using the text information transformation matrix.
[0027] Furthermore, the polygonal structure includes any one of the following: a polygonal structure with holes and a polygonal structure without holes.
[0028] Secondly, embodiments of the present invention also provide a device for text information triangulation, comprising:
[0029] The information acquisition module is used to acquire the first text information of all the text to be processed in a preset coordinate system, and extract the contour information corresponding to each text to be processed based on the first text information.
[0030] The determination and calculation module is used to determine at least one non-self-intersecting polygonal contour based on the contour information corresponding to each of the characters to be processed, and to perform Boolean operations on the polygonal contours to obtain at least one non-intersecting polygonal structure.
[0031] The triangulation module is used to triangulate the polygon structure corresponding to each of the characters to be processed, to obtain a triangulation set corresponding to each character to be processed, and to render the characters to be processed based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding characters to be processed.
[0032] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described in any of the first aspects above.
[0033] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing machine-executable instructions, which, when invoked and executed by a processor, cause the processor to perform the method described in any of the first aspects above.
[0034] In this embodiment of the invention, a method for triangulating text information is provided, comprising: acquiring first text information of all text to be processed in a preset coordinate system, and extracting contour information corresponding to each text to be processed based on the first text information; determining at least one non-self-intersecting polygonal contour based on the contour information corresponding to each text to be processed, and performing Boolean operations on the polygonal contours to obtain at least one non-intersecting polygonal structure; triangulating the polygonal structure corresponding to each text to be processed to obtain a triangulation set corresponding to each text to be processed, and rendering the text to be processed based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding text to be processed. As can be seen from the above description, the method for triangulating text information of the present invention extracts the contour information corresponding to the text to be processed based on the first text information of the text to be processed, and then determines the polygonal contour based on the contour information and processes it into at least one non-intersecting polygonal structure. Finally, triangulation is performed on the polygonal structure to obtain a triangulation set corresponding to each text to be processed. This method triangulates the text to be processed before rendering into general triangular face data and stores it, so that subsequent rendering is based on the triangular face data, without the need to match text through font files, thus eliminating the rendering engine's dependence on font files. Meanwhile, the text is loaded by the rendering engine with fixed triangular face data, which is not affected by changes in the rendering engine scene. This reduces the extra burden on the CPU during real-time rendering and effectively alleviates the technical problems of existing text rendering methods, such as dependence on font files and low rendering efficiency. Attached Figure Description
[0035] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0036] Figure 1 A flowchart illustrating a method for triangulating text information provided in an embodiment of the present invention;
[0037] Figure 2 A flowchart illustrating a method for determining a polygonal contour that does not have self-intersecting parts, provided in an embodiment of the present invention;
[0038] Figure 3 (a) and Figure 3 (b) A schematic diagram of a closed contour with self-intersection provided in an embodiment of the present invention;
[0039] Figure 4 This is a flowchart of a method for extracting contour information according to an embodiment of the present invention;
[0040] Figure 5 A flowchart illustrating a method for rendering text to be processed, provided in an embodiment of the present invention;
[0041] Figure 6 A flowchart of a triangulation set transformation method provided in an embodiment of the present invention;
[0042] Figure 7 This is a schematic diagram of a text information triangulation device provided in an embodiment of the present invention;
[0043] Figure 8 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0044] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] Currently, existing rendering engines commonly use two methods to render text: pixel-based and bitmap-based. The first method largely relies on the system font library, requiring a perfect match between the pixel information of the corresponding text and the font file. Changes to the operating system, such as different or missing font files, can lead to discrepancies between the text style and the design, or even missing text if the corresponding text cannot be found. The second method, besides matching the font file, also needs to consider whether the text bitmap resolution meets the scene's requirements when scaling. This method, in addition to relying on the system font library, also generates a scene-appropriate bitmap in real-time, placing a heavy burden on the CPU and causing performance lag.
[0046] Based on this, the text information triangulation method of the present invention processes the text before rendering into triangulated data, so that the subsequent text rendering process does not need to rely on font files and is not affected by the scene changes of the rendering engine, effectively alleviating the technical problems of relying on font files and low rendering efficiency in existing text rendering methods.
[0047] To facilitate understanding of this embodiment, a method for triangulating text information disclosed in this embodiment of the invention will first be described in detail.
[0048] Example 1:
[0049] According to an embodiment of the present invention, an embodiment of a method for text information triangulation is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0050] Figure 1 This is a flowchart of a method for text information triangulation according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0051] Step S102: Obtain the first text information of all text to be processed in the preset coordinate system, and extract the contour information corresponding to each text to be processed according to the first text information.
[0052] In industry-wide applications, 2D engineering drawings created using CAD are often parsed and loaded by various rendering engines as design references for 3D models. In this case, the text annotations and descriptions on the drawings are of significant importance for the expansion of actual business operations. Specifically, in this embodiment, the text information triangulation method pre-establishes a preset coordinate system within the CAD drawing before other rendering engines render the text. This preset coordinate system is a Cartesian coordinate system, and in practical applications, the origin of this preset coordinate system is often chosen from the origin of the CAD drawing's coordinate system.
[0053] Furthermore, based on a pre-established coordinate system, the paragraph information corresponding to each text segment within the CAD drawing is obtained. This paragraph information includes: paragraph spacing, the position of the paragraph insertion point, the font format, font size, rotation angle, and font color. Then, based on the offset of each text segment's position relative to its corresponding paragraph insertion point, the position of each text segment is obtained. Finally, combining the paragraph information and the position of each text segment, the first text information corresponding to each text segment in the pre-established coordinate system is obtained.
[0054] Finally, the text to be processed, carrying the initial text information, is input through the freeType open-source library interface, and the two-dimensional contour information of each text is extracted and stored separately. Before extracting the contour information, the freeType open-source library needs to preload the font format file corresponding to the font format of the paragraph containing the text.
[0055] Step S104: Determine at least one non-self-intersecting polygonal contour based on the contour information corresponding to each text to be processed, and perform Boolean operations on the polygonal contours to obtain at least one non-intersecting polygonal structure.
[0056] To facilitate understanding of this embodiment, the processing procedure for a single character to be processed is described below. Specifically, after freeType extracts the two-dimensional contour information of a single character to be processed, it obtains at least one closed contour and stores the contour information corresponding to each closed contour. Further, the contour information corresponding to each closed contour is processed separately, transforming each closed contour into one or more non-self-intersecting polygonal contours. Finally, all polygonal contours corresponding to the character to be processed are merged and Boolean operations are performed to obtain independent, non-intersecting polygonal structures.
[0057] Step S106: Triangulate the polygon structure corresponding to each text to be processed to obtain a triangulation set corresponding to each text to be processed, and render the text to be processed based on the triangulation set. The data in the triangulation set is the triangular face data of the corresponding text to be processed.
[0058] Specifically, based on the Deloni triangulation concept, the individual polygonal structures corresponding to the text to be processed are triangulated to obtain a triangulated set corresponding to the text. The data within this triangulated set is the triangular face data of the text to be processed. Finally, the text to be processed is rendered based on this triangulated set.
[0059] In this embodiment of the invention, a method for text information triangulation is provided, comprising: acquiring first text information of all text to be processed in a preset coordinate system, and extracting contour information corresponding to each text to be processed based on the first text information; determining at least one non-self-intersecting polygonal contour based on the contour information corresponding to each text to be processed, and performing Boolean operations on the polygonal contours to obtain at least one non-intersecting polygonal structure; triangulating the polygonal structure corresponding to each text to be processed to obtain a triangulation set corresponding to each text to be processed, and rendering the text to be processed based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding text to be processed. As can be seen from the above description, the text information triangulation method of the present invention extracts the contour information corresponding to the text to be processed based on the first text information of the text to be processed, and then determines the polygonal contour based on the contour information and processes it into at least one non-intersecting polygonal structure. Finally, triangulation is performed on the polygonal structure to obtain a triangulation set corresponding to each text to be processed. This method triangulates the text to be processed before rendering into general triangular face data and stores it, so that subsequent rendering is based on the triangular face data, without the need to match the text through font files, thus eliminating the rendering engine's dependence on font files. Meanwhile, the text is loaded by the rendering engine with fixed triangular face data, which is not affected by changes in the rendering engine scene. This reduces the extra burden on the CPU during real-time rendering and effectively alleviates the technical problems of existing text rendering methods, such as dependence on font files and low rendering efficiency.
[0060] The above provides a brief overview of the text information triangulation method of the present invention. The specific details involved are described in detail below.
[0061] In an alternative embodiment of the present invention, reference is made to... Figure 2 The process involves determining at least one non-self-intersecting polygonal contour based on the contour information corresponding to each character to be processed, including the following steps:
[0062] Step S201: Based on the attributes of each vertex in the contour information, the contour corresponding to the contour information is split into straight line segments and curve segments, and discrete points are inserted to discretize the curve segments into straight line segments.
[0063] To facilitate understanding of this embodiment, the processing procedure for a single character to be processed is described below. First, all contour information corresponding to each character to be processed stored in freeType is processed sequentially. The contour information corresponding to a single closed contour includes: a set of two-dimensional coordinate points (i.e., vertices) that make up the closed contour, and the attribute value of each coordinate point (i.e., vertex). Specifically, based on the attribute value of each coordinate point contained in the contour information corresponding to each closed contour, the closed contour is split into straight line segments and curved line segments. Straight line segments do not require additional processing, but curved line segments need to be processed into straight line segments.
[0064] Since all the curve segments are quadratic or cubic Bézier curves, multiple discrete points can be inserted on the curve segments according to the Bézier curve formula, thereby discretizing each curve segment and then connecting them sequentially into multiple straight line segments.
[0065] Step S202: Connect adjacent vertices and discrete points to form a closed contour, and determine whether the closed contour has self-intersection;
[0066] Specifically, adjacent vertices and discrete points are connected end-to-end, thereby sequentially connecting the unprocessed straight line segments and the multiple straight line segments obtained after processing the curve segments to form a closed contour. Further, it is determined whether the closed contour exhibits self-intersection.
[0067] Step S203: If the closed contour has self-intersections, increase the number of discrete points in the discrete processing, and return to the step of connecting the first and last vertices and discrete points to form a closed contour, until the formed closed contour is a polygonal contour without self-intersections, or, disassemble the closed contour to obtain multiple polygonal contours without self-intersections.
[0068] Specifically, if the closed contour has self-intersections, the number of discrete points inserted into the processed curve segment is increased, thereby improving the accuracy of the multiple line segments obtained from the discretization process. Then, the process returns to step S202 to connect the first and last vertices and discrete points to form a closed contour, and it is determined whether the closed contour has self-intersections. The above process is repeated until it is determined that the formed closed contour is a polygonal contour without self-intersections.
[0069] Alternatively, after determining that the closed contours are self-intersecting, the closed contours can be directly decomposed to obtain multiple non-self-intersecting polygonal contours. (Refer to...) Figure 3 (a) and Figure 3 (b) The specific decomposition process is as follows: starting from the starting point of the closed contour, connect adjacent vertices sequentially, and use the line segment formed by two adjacent preset vertices to calculate the intersection point with the line segment formed by two other adjacent vertices in all vertices except the preset vertices. Figure 3(a) Find the intersection points of the inner line segment (1,2) with line segments (3,4), (4,5), (5,6), (6,7) and (7,8) in turn; or, find the intersection points of the line segment (2,3) with line segments (4,5), (5,6), (6,7) and (7,8) in turn, and so on.
[0070] If a line segment formed by adjacent preset vertices intersects with a line segment formed by two other adjacent vertices (excluding the preset vertices), an intersection point is inserted at the intersection. All vertices between the two intersecting line segments are then removed from all vertices. The deleted vertices are recorded sequentially, and a new subset contour is formed using the deleted vertices and the inserted intersection points. That is, as follows... Figure 3 As shown in (b), when line segment (2, 3) intersects with line segment (7, 8), an intersection point A is inserted at the intersection position and vertices 3-7 are deleted. Then, a new subset contour (A, 3, 4, 5, 6, 7) is formed using the deleted vertices and the inserted intersection point. At this time, the undeleted vertices and the inserted intersection point (1, 2, A, 8) form a closed contour.
[0071] Furthermore, the closed contour (1, 2, A, 8) and the subset contour (A, 3, 4, 5, 6, 7) are further decomposed using the above steps until a set of ordered vertices is obtained where no line segment between any two adjacent vertices intersects with any other line segment between adjacent vertices. Finally, the recorded subset contours are recursively processed according to the above process. Figure 3 (a) The closed contour shown is recursively processed according to the above decomposition process. The recorded subset contours are (1, 2, A, 8), (A, 3, 4, B) and (B, 5, 6, 7).
[0072] Once all contours and subset contours are no longer self-intersecting, store these non-intersecting polygonal contours.
[0073] In an alternative embodiment of the present invention, reference is made to... Figure 4 Before extracting the contour information corresponding to each character to be processed based on the first text information, the method further includes the following steps:
[0074] Step S301: Determine whether the current text to be processed has undergone contour information extraction based on the first text information of the current text to be processed.
[0075] Specifically, when dealing with a large number of characters, this embodiment generates a shared, fixed-size triangular mesh cache for the same characters in the same font format but different font sizes during text triangulation. In this case, when processing identical characters appearing sequentially, all can reference the same set of triangles; that is, the same character (i.e., identical characters appearing sequentially) only undergoes text triangulation once. Therefore, before extracting the contour information corresponding to a single character based on the first text information, it is necessary to determine whether the current character has already undergone contour information extraction.
[0076] Step S302: If the outline information has been extracted, skip the current text to be processed and extract the outline information of the subsequent text to be processed based on the first text information of the subsequent text to be processed.
[0077] Specifically, if the current text to be processed has already undergone contour information extraction once, then the current text to be processed is skipped, and the contour information of the subsequent text to be processed is extracted based on the first text information of the subsequent text to be processed. As described in the above steps, the current text to be processed can directly reference the triangular face data within the triangulated set obtained after the contour information extraction of the text to be processed with the same characters.
[0078] Using the above method, since text with identical characters only needs to retain its initial text information such as position, rotation angle, and character size, there is no need to cache the same triangular face data obtained after triangulation multiple times, effectively reducing the amount of data stored after processing. In the subsequent text rendering process, this not only improves the execution efficiency of converting the text into a triangular mesh, but also improves the loading and rendering efficiency in the subsequent rendering process.
[0079] Step S303: Otherwise, extract the outline information of the current text to be processed based on the first text information of the current text to be processed.
[0080] Specifically, if the current text to be processed has not yet had its outline information extracted, then the outline information of the current text to be processed is extracted based on the first text information of the current text to be processed.
[0081] In an optional embodiment of the present invention, the first text information includes: font format, font size, position, rotation angle, spacing, and font color.
[0082] In an alternative embodiment of the present invention, reference is made to... Figure 5 Rendering of the text to be processed based on triangulated sets includes:
[0083] Step S401: Transform the triangulated set to obtain the transformed triangulated set;
[0084] Specifically, when performing subsequent text rendering based on the triangulated set obtained by triangulating the text information to be processed, the triangulated set needs to be transformed beforehand. This is because the process of obtaining the triangulated set is completed within a pre-established coordinate system, while CAD drawings have their own inherent coordinate system, and the subsequent text rendering is based on the CAD drawing coordinate system. Therefore, this embodiment also needs to transform the triangulated set in the pre-established coordinate system to obtain a transformed triangulated set in the CAD drawing coordinate system.
[0085] Step S402: Render the text to be processed based on the transformed triangulated set.
[0086] Specifically, the transformed triangulated set in the coordinate system of the CAD drawing is used for subsequent rendering of the text to be processed.
[0087] Since the text to be processed is loaded by the rendering engine as a fixed set of triangle face data, when the rendering engine scene changes, the rendering engine only needs to translate and scale the triangle face vertices of the text to be processed, which greatly simplifies the rendering process, reduces the extra burden on the CPU during real-time rendering, and solves the problems of low efficiency in rendering two-dimensional and three-dimensional text, vector scaling distortion, and strict requirements on fonts in existing rendering engines.
[0088] In an optional embodiment of the present invention, reference is made to Figure 6 Transformations of triangulated sets include:
[0089] Step S501: Obtain the second text information of all text to be processed in the coordinate system of the CAD drawing;
[0090] Specifically, based on the inherent coordinate system of the CAD drawing, the paragraph information of each text segment in the drawing coordinate system is obtained. This paragraph information includes: paragraph spacing, paragraph insertion point position, font format, font size, rotation angle, and font color. Then, based on the offset of each text segment's position relative to its corresponding paragraph insertion point, the position of each text segment is obtained. Finally, combining the paragraph information and the position of each text segment, the second text information of each text segment in the drawing coordinate system is obtained.
[0091] Step S502: Calculate the text information transformation matrix corresponding to each text to be processed based on the first text information and the second text information. The text information transformation matrix is the text information transformation matrix that transforms the first text information in the preset coordinate system to the second text information in the CAD drawing coordinate system.
[0092] Specifically, based on the first and second text information, a text information transformation matrix is calculated for each text to be processed, transforming it from the preset coordinate system to the CAD drawing coordinate system. This transformation matrix mainly includes: position transformation, font size transformation, and rotation angle transformation, i.e., the offset, scaling, and rotation of the text to be processed in the two coordinate systems. In practice, position transformation is the offset of the corresponding position coordinates in the two coordinate systems; font size transformation is the ratio between the scaling ratios of the corresponding CAD design drawings in the two coordinate systems. In practical applications, the scaling ratio of the preset coordinate system is generally 100%, while the scaling ratio of the CAD drawing coordinate system is the corresponding ratio set on the CAD design page; and rotation angle transformation is the angle between the positive X-axis directions of the two coordinate systems.
[0093] Step S503: Transform the triangulated set using the text information transformation matrix.
[0094] Specifically, the triangulated set in the preset coordinate system is transformed by the text information transformation matrix to obtain the triangulated set in the CAD drawing coordinate system.
[0095] In an optional embodiment of the present invention, the polygonal structure includes any one of the following: a polygonal structure with holes and a polygonal structure without holes.
[0096] Example 2:
[0097] This invention also provides a device for text information triangulation. This device is mainly used to perform the text information triangulation method provided in Embodiment 1 of this invention. The following is a detailed description of the text information triangulation device provided in this invention.
[0098] Figure 7 This is a schematic diagram of a text information triangulation device according to an embodiment of the present invention, such as... Figure 7 As shown, the device mainly includes: an information acquisition module 10, a determination and calculation module 20, and a triangulation module 30, wherein:
[0099] The information acquisition module 10 is used to acquire the first text information of all the text to be processed in the preset coordinate system, and extract the contour information corresponding to each text to be processed according to the first text information.
[0100] The determination and operation module 20 is used to determine at least one non-self-intersecting polygonal contour based on the contour information corresponding to each text to be processed, and to perform Boolean operations on the polygonal contours to obtain at least one non-intersecting polygonal structure.
[0101] The triangulation module 30 is used to triangulate the polygon structure corresponding to each text to be processed to obtain a triangulation set corresponding to each text to be processed, so as to render the text to be processed based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding text to be processed.
[0102] In this embodiment of the invention, a device for text information triangulation is provided, comprising: acquiring first text information of all text to be processed in a preset coordinate system, and extracting contour information corresponding to each text to be processed based on the first text information; determining at least one non-self-intersecting polygonal contour based on the contour information corresponding to each text to be processed, and performing Boolean operations on the polygonal contours to obtain at least one non-intersecting polygonal structure; triangulating the polygonal structure corresponding to each text to be processed to obtain a triangulation set corresponding to each text to be processed, and rendering the text to be processed based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding text to be processed. As can be seen from the above description, the device for text information triangulation of the present invention extracts the contour information corresponding to the text to be processed based on the first text information of the text to be processed, and then determines the polygonal contour based on the contour information and processes it into at least one non-intersecting polygonal structure. Finally, triangulation is performed on the polygonal structure to obtain a triangulation set corresponding to each text to be processed. This device triangulates the text to be processed before rendering into general triangular face data and stores it, so that subsequent rendering is based on the triangular face data, without the need to match the text through font files, thus eliminating the rendering engine's dependence on font files. Meanwhile, the text is loaded by the rendering engine with fixed triangular face data, which is not affected by changes in the rendering engine scene. This reduces the extra burden on the CPU during real-time rendering and effectively alleviates the technical problems of existing text rendering devices, such as dependence on font files and low rendering efficiency.
[0103] Optionally, the determination and calculation module 20 is further configured to: divide the contour corresponding to the contour information into straight line segments and curve segments according to the attributes of each vertex in the contour information, and insert discrete points to discretize the curve segments into straight line segments;
[0104] Connect adjacent vertices and discrete points to form a closed contour, and determine whether the closed contour has self-intersection;
[0105] If the closed contour has self-intersections, increase the number of discrete points in the discrete processing and return to the step of connecting the first and last vertices and discrete points to form the closed contour, until the formed closed contour is a polygonal contour without self-intersections, or disassemble the closed contour to obtain multiple polygonal contours without self-intersections.
[0106] Optionally, before extracting the contour information corresponding to each character to be processed based on the first text information, the text information triangulation device is further used to: determine whether the current character to be processed has undergone contour information extraction based on the first text information of the current character to be processed.
[0107] If the outline information has been extracted, the current text to be processed is skipped, and the outline information of the subsequent text to be processed is extracted based on the first text information of the subsequent text to be processed.
[0108] Otherwise, extract the outline information of the current text to be processed based on the first text information of the current text to be processed.
[0109] Optionally, the first text information includes: font format, size, position, rotation angle, spacing, and color.
[0110] Optionally, the triangulation module 30 is also used to: transform the triangulated set to obtain the transformed triangulated set;
[0111] The text to be processed is rendered based on the transformed triangulated set.
[0112] Optionally, the triangulation module 30 is also used to: obtain the second text information of all text to be processed in the coordinate system of the CAD drawing;
[0113] Calculate the text information transformation matrix corresponding to each text to be processed based on the first text information and the second text information. The text information transformation matrix is the text information transformation matrix that transforms the first text information in the preset coordinate system to the second text information in the CAD drawing coordinate system.
[0114] The triangulated set is transformed using a text information transformation matrix.
[0115] Optionally, the polygonal structure includes either a polygonal structure with holes or a polygonal structure without holes.
[0116] The device provided in this embodiment of the invention has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.
[0117] like Figure 8 As shown in the embodiment of this application, an electronic device 800 includes a processor 801, a memory 802, and a bus. The memory 802 stores machine-readable instructions that can be executed by the processor 801. When the electronic device is running, the processor 801 communicates with the memory 802 via the bus, and the processor 801 executes the machine-readable instructions to perform the steps of the text information triangulation method described above.
[0118] Specifically, the memory 802 and processor 801 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 801 runs the computer program stored in the memory 802, it can execute the above-mentioned text information triangulation method.
[0119] The processor 801 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 801 or by instructions in software form. The processor 801 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 802, and processor 801 reads the information in memory 802 and, in conjunction with its hardware, completes the steps of the above method.
[0120] Corresponding to the above-described text information triangulation method, this application embodiment also provides a computer-readable storage medium storing machine-executable instructions. When the machine-executable instructions are invoked and executed by a processor, the machine-executable instructions cause the processor to perform the steps of the above-described text information triangulation method.
[0121] The text information triangulation device provided in this application embodiment can be specific hardware on a device or software or firmware installed on the device. The implementation principle and technical effects of the device provided in this application embodiment are the same as those in the foregoing method embodiments. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the foregoing method embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can all be referred to the corresponding processes in the above method embodiments, and will not be repeated here.
[0122] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0123] For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0124] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0125] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0126] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0127] It should be noted that similar reference numerals and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, the terms "first," "second," "third," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. Finally, it should be stated that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit it. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the scope of the technology disclosed in this application, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application. All should be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for triangulating textual information, characterized in that, include: Obtain the first text information of all text to be processed in a preset coordinate system, and extract the contour information corresponding to each text to be processed based on the first text information; Based on the contour information corresponding to each of the characters to be processed, at least one non-self-intersecting polygonal contour is determined, and Boolean operations are performed on the polygonal contours to obtain at least one non-intersecting polygonal structure. Triangulation is performed on the polygon structure corresponding to each text to be processed to obtain a triangulation set corresponding to each text to be processed, and the text to be processed is rendered based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding text to be processed. Determine at least one non-self-intersecting polygonal contour based on the contour information corresponding to each of the characters to be processed, including: Based on the attributes of each vertex in the contour information, the contour corresponding to the contour information is split into straight line segments and curve segments, and discrete points are inserted to discretize the curve segments into straight line segments; Connect the adjacent vertices and discrete points to form a closed contour, and determine whether the closed contour has self-intersection; If the closed contour has self-intersections, the number of discrete points in the discrete processing is increased, and the process returns to the step of connecting the vertices and discrete points to form a closed contour, until the formed closed contour is a polygonal contour without self-intersections, or the closed contour is disassembled to obtain multiple polygonal contours without self-intersections.
2. The method according to claim 1, characterized in that, Before extracting the contour information corresponding to each of the characters to be processed based on the first text information, the method further includes: Determine whether the current text to be processed has been extracted based on the first text information of the current text to be processed; If the outline information has been extracted, the current text to be processed is skipped, and the outline information of the subsequent text to be processed is extracted based on the first text information of the subsequent text to be processed. Otherwise, extract the outline information of the current text to be processed based on the first text information of the current text to be processed.
3. The method according to claim 1, characterized in that, The first text information includes: font format, font size, position, rotation angle, spacing, and font color.
4. The method according to claim 1, characterized in that, Rendering the text to be processed based on the triangulated set includes: The triangulated set is transformed to obtain the transformed triangulated set; The text to be processed is rendered based on the transformed triangulated set.
5. The method according to claim 4, characterized in that, Transformation of the triangulated set includes: Obtain the second text information of all text to be processed in the coordinate system of the CAD drawing; Calculate the text information transformation matrix corresponding to each text to be processed based on the first text information and the second text information, wherein the text information transformation matrix is the text information transformation matrix for transforming the first text information in the preset coordinate system to the second text information in the CAD drawing coordinate system; The triangulated set is transformed using the text information transformation matrix.
6. The method according to claim 1, characterized in that, The polygonal structure includes any one of the following: a polygonal structure with holes and a polygonal structure without holes.
7. A device for triangulating textual information, characterized in that, include: The information acquisition module is used to acquire the first text information of all the text to be processed in a preset coordinate system, and extract the contour information corresponding to each text to be processed based on the first text information. The determination and calculation module is used to determine at least one non-self-intersecting polygonal contour based on the contour information corresponding to each of the characters to be processed, and to perform Boolean operations on the polygonal contours to obtain at least one non-intersecting polygonal structure. The triangulation module is used to triangulate the polygon structure corresponding to each of the texts to be processed to obtain a triangulation set corresponding to each text to be processed, so as to render the text to be processed based on the triangulation set, wherein the data in the triangulation set is the triangular face data of the corresponding text to be processed. The determination and calculation module, in the process of determining at least one non-self-intersecting polygonal contour based on the contour information corresponding to each of the characters to be processed, is further configured to: split the contour corresponding to the contour information into straight line segments and curve segments according to the attributes of each vertex in the contour information, and insert discrete points to discretize the curve segments into straight line segments; connect the adjacent vertices and discrete points to form a closed contour, and determine whether the closed contour has self-intersection; if the closed contour has self-intersection, increase the number of discrete points for discretization, and return to the step of connecting the vertices and discrete points to form a closed contour, until the formed closed contour is a non-self-intersecting polygonal contour, or, disassemble the closed contour to obtain multiple non-self-intersecting polygonal contours.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores machine-executable instructions that, when invoked and executed by a processor, cause the processor to perform the method according to any one of claims 1 to 6.