Drawing analysis method, device, equipment and storage medium
The method addresses the issue of unsupported CAD fonts on web pages by parsing and storing character graphic information to accurately render CAD drawing files.
Patent Information
- Application Number
- CN202111616626.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2041-12-27
AI Technical Summary
CAD drawing files with shx fonts cannot be displayed normally on web pages due to unsupported font formats.
A method to parse CAD drawing files by obtaining character graphic information, establishing a mapping relationship, and storing it to enable display of unsupported fonts on web pages by using character graphic information to draw characters.
Enables the display of unsupported CAD fonts on web pages by storing character graphic information, allowing for accurate rendering of CAD drawing files regardless of font compatibility.
Smart Images

Figure CN114332881B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a drawing parsing method, device, equipment and storage medium. Background Art
[0002] CAD supports two font formats, ttf and shx. Ttf fonts are supported by Windows system, and shx fonts are fonts that come with AutoCAD software. When displaying CAD files on the web, ttf fonts can be parsed through a third-party server to generate a json file for parsing and display, while some shx fonts cannot be displayed normally. Summary of the invention
[0003] The present application provides a drawing parsing method, device, equipment and storage medium, which are used to solve the problem that the fonts in the drawing file cannot be displayed normally when the drawing file is displayed on a web page.
[0004] In a first aspect, a drawing parsing method is provided, comprising:
[0005] Get the characters to be parsed from the drawing file to be parsed;
[0006] Acquire character graphic information of the character to be parsed, wherein the character graphic information is used to indicate the shape of the character to be parsed;
[0007] Establishing a mapping relationship between the character to be parsed and the character graphic information;
[0008] According to the mapping relationship, the character graphic information is stored.
[0009] Optionally, obtaining character graphic information of the character to be parsed includes:
[0010] Decomposing the character to be parsed into N graphic elements, any of which includes a line segment or a point;
[0011] Obtaining coordinate information of each of the N graphic elements respectively;
[0012] Based on the coordinate information, character graphic information of the character to be parsed is obtained.
[0013] Optionally, obtaining character graphic information of the character to be parsed based on the coordinate information includes:
[0014] Acquire T independent points in the N graphic elements, wherein when the N graphic elements include a line segment, the line segment includes two independent points;
[0015] Numbering the T endpoints respectively to obtain T numbers;
[0016] The T numbers and the coordinate information are used as the character graphic information.
[0017] Optionally, the graphic element is the line segment;
[0018] Based on the coordinate information, character graphic information of the character to be parsed is obtained, including:
[0019] Obtain the first endpoint coordinates and the second endpoint coordinates of the line segment;
[0020] Based on the first endpoint coordinates and the second endpoint coordinates, calculating the inclination angle and the length of the line segment;
[0021] Using the tilt angle and the line segment length as character graphic information of the line segment;
[0022] Based on the character graphic information of the line segment, the character graphic information of the character to be parsed is obtained.
[0023] Optionally, storing the character graphic information according to the mapping relationship includes:
[0024] Obtain the character type of the character to be parsed;
[0025] According to the mapping relationship, the characters to be parsed are stored in a character set corresponding to the character type.
[0026] Optionally, after storing the character graphic information according to the mapping relationship, the method further includes:
[0027] Obtain a character insertion request of an insertion point, the character insertion request carrying a character height and a character identification parameter of a character to be displayed, and the insertion point indicates an insertion position of a non-drawing editing tool;
[0028] Acquire target character graphic information corresponding to the character identification parameter, wherein the target character graphic information includes coordinate information of M graphic elements;
[0029] Based on the character height and the coordinate information of the M graphic elements, the character to be displayed is drawn at the insertion point.
[0030] Optionally, the coordinate information of the M graphic elements includes coordinate information of S points, wherein the S points include endpoints of line segments and / or independent points;
[0031] Drawing the character to be displayed at the insertion point based on the character height and the coordinate information of the M graphic elements includes:
[0032] Obtaining the horizontal coordinate and the vertical coordinate of the insertion point; and obtaining the horizontal coordinate and the vertical coordinate of the target point, wherein the target point is any point among the S points;
[0033] Respectively calculating the product of the abscissa and ordinate of the target point and the character height to obtain a calculated abscissa and a calculated ordinate;
[0034] The calculated horizontal coordinate and the horizontal coordinate of the insertion point are summed to obtain a converted horizontal coordinate; the calculated vertical coordinate and the vertical coordinate of the insertion point are summed to obtain a converted vertical coordinate;
[0035] Draw the target point at a position corresponding to the converted horizontal coordinate and the converted vertical coordinate;
[0036] The characters to be displayed are obtained based on the drawn S target points.
[0037] In a second aspect, a drawing parsing device is provided, comprising:
[0038] A first acquisition unit is used to acquire the characters to be parsed from the drawing file to be parsed;
[0039] A second acquiring unit, used for acquiring character graphic information of the character to be parsed, wherein the character graphic information is used for indicating the shape of the character to be parsed;
[0040] An establishing unit, used for establishing a mapping relationship between the character to be parsed and the character graphic information;
[0041] A storage unit is used to store the character graphic information according to the mapping relationship.
[0042] In a third aspect, an electronic device is provided, comprising: a processor, a memory and a communication bus, wherein the processor and the memory communicate with each other via the communication bus;
[0043] The memory is used to store computer programs;
[0044] The processor is used to execute the program stored in the memory to implement the drawing parsing method described in the first aspect.
[0045] In a fourth aspect, a computer-readable storage medium is provided, storing a computer program, wherein the computer program, when executed by a processor, implements the drawing parsing method described in the first aspect.
[0046] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application obtains the characters to be parsed from the drawing file to be parsed; obtains the character graphic information of the characters to be parsed, and the character graphic information is used to indicate the shape of the characters to be parsed; establishes a mapping relationship between the characters to be parsed and the character graphic information; stores the character graphic information according to the mapping relationship. Since the character graphic information indicating the shape of the characters to be parsed is stored, when the drawing file needs to be displayed on the web page, the characters can be drawn based on the character graphic information of the characters to be displayed, so that when the font format of the characters is not a format supported by the Windows system, the characters can also be displayed. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0049] Figure 1 This is an architecture diagram of the network system in the embodiment of the present application;
[0050] Figure 2 A schematic diagram of a flow chart of a drawing parsing method in an embodiment of the present application;
[0051] Figure 3 This is a schematic diagram of angle numbers written in the embodiments of the present application;
[0052] Figure 4 This is a schematic diagram of the structure of a drawing parsing device in an embodiment of the present application;
[0053] Figure 5 Schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0055] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0056] First, an example is given to introduce a network system architecture to which the solution of the embodiment of the present application may be applied.
[0057] See also Figure 1 , Figure 1 An architecture diagram of a network system provided in an embodiment of the present application, such as Figure 1 As shown, the network system includes a terminal 101 , a drawing review server 102 and a database 103 .
[0058] The network system is connected via a wired or wireless network, which may be a virtual private network, a local area network, a wide area network or a metropolitan area network, etc., and the specific communication transmission protocol is not limited.
[0059] The terminal 101 may be used to submit the drawing file to be parsed to the drawing review server 102 through program code or touch signal, so as to request the drawing review server 102 to perform relevant steps of drawing parsing.
[0060] The drawing review server 102 serves as the execution entity. In some embodiments, the drawing review server 102 can be the background server of the intelligent drawing review platform. The intelligent drawing review platform automatically performs electrical drawing review by regularizing the review standards of design drawings in the construction industry. The drawing review server 102 executes program codes through the processor to perform a series of drawing analysis processes.
[0061] The database 103 can be used to store drawing files to be analyzed, character graphic information, etc. The database 103 can be a local database, such as Vanke's Van-Bu database, or a third-party database independent of the drawing review server 102, such as some design institutes' databases, or a cloud database.
[0062] It should be understood that the terminal 101 in this embodiment can be a desktop computer, a tablet computer, a supercomputer or other devices; the image review server 102 can be a local server, a cloud server, or a server cluster.
[0063] It should be understood that Figure 1 The network system architecture shown is only an example, and it may also include more components such as routers, switches, etc.
[0064] based on Figure 1 The network system architecture is shown, and the drawing parsing method proposed in the embodiment of the present application is described in detail below in conjunction with the relevant drawings.
[0065] The method can be applied to the terminal 101 or the image review server 102, such as Figure 2 As shown, the method may include the following steps:
[0066] Step 201: Obtain characters to be parsed from the drawing file to be parsed.
[0067] It should be understood that the drawing file to be parsed here may be a file in CAD format, and accordingly, the characters to be parsed are characters in shx font or TTF font in the drawing file to be parsed.
[0068] It should be understood that the TTF font here is the font supported by the Windows system, and the shx font is the font that comes with AutoCAD for editing the drawing file to be parsed.
[0069] Step 202: Obtain character graphic information of the character to be parsed, where the character graphic information is used to indicate the shape of the character to be parsed.
[0070] In this embodiment, the character graphic information of the character to be parsed is obtained specifically through a drawing editing tool capable of editing the drawing file to be parsed.
[0071] In an optional embodiment, the character to be parsed is written into the working area of the drawing editing tool; the character to be parsed is decomposed into N graphic elements in the working area, any graphic element includes a line segment or a point; the coordinate information of each of the N graphic elements is obtained respectively; based on the coordinate information, the character graphic information of the character to be parsed is obtained.
[0072] It should be understood that when the characters to be parsed are input in the drawing editing tool, since the drawing editing tool supports characters of all formats in the drawing file, the characters to be parsed can be recognized and displayed by the drawing editing tool.
[0073] In the application, the characters to be parsed can be written into the workspace of the drawing editing tool based on the font format to which the characters to be parsed belong. It should be understood that the attributes of the characters to be parsed include information such as the font format to which the characters to be parsed belong, the name of the characters to be parsed, and the like.
[0074] In an example, for TTF fonts, they are input into the AutoCAD workspace through the text command that comes with AutoCAD. For SHX fonts, for example, the common steel bar character in CAD cannot be input through the windows font, so the code string corresponding to the character (such as %%132) is input into the workspace, and AutoCAD recognizes the code string and automatically displays the shape of the steel bar symbol in the workspace.
[0075] It should be understood that for a CAD drawing file, the CAD drawing file stores information such as the attributes of the characters. For example, for the character "circuit breaker", the CAD drawing file may store information such as the name of the circuit breaker and the component category indicated by the character (here, the circuit breaker); for another example, for a steel bar character, the CAD drawing file stores the encoding string of the steel bar character.
[0076] It should be understood that for different characters to be parsed, the types and numbers of primitives that can be decomposed may be different. For example, some characters to be parsed may only have line segments as primitives, while some characters to be parsed may have both line segments and points as primitives. Of course, there may also be cases where a character to be parsed may only have points as primitives.
[0077] In this embodiment, when the primitive is a line segment, the coordinate information of the line segment can be indicated by the coordinate information of the two endpoints of the line segment. For example, there is a line segment A, and the two endpoints of the line segment A are a and b respectively, then the coordinate information of the line segment A can be the coordinate information of the endpoint a and the coordinate information of the endpoint b.
[0078] In this embodiment, in order to conveniently indicate the disassembled graphic elements, the independent points in the N graphic elements are numbered, and the numbers and coordinate information are used as character graphic information.
[0079] In an optional embodiment, T independent points in N graphic elements are obtained, wherein when the N graphic elements include a line segment, the line segment includes two independent points; the T endpoints are numbered respectively to obtain T numbers; and the T numbers and coordinate information are used as character graphic information.
[0080] It should be understood that in the character graphic information, each independent point may have attribute information, and the attribute information may indicate whether the independent point is an endpoint of a line segment, and which endpoint the independent point and the independent point belong to the same line segment.
[0081] In an example, N graphic elements include a line segment L and a point A. Correspondingly, the coordinate information of the line segment L is the coordinate information of the endpoint B and the coordinate information of the endpoint C. Then the three points A, B, and C can be numbered respectively. For example, point A is numbered 1, point B is numbered 2, and point C is numbered 3. Then when the numbers are stored as character graphic information, the storage number 1 indicates point A, and the storage number 23 indicates the line segment L.
[0082] In this embodiment, when the graphic element is a line segment, the character graphic information of the line segment may be the inclination angle and length of the line segment.
[0083] In a specific embodiment, the coordinates of the first endpoint and the second endpoint of a line segment are obtained; based on the coordinates of the first endpoint and the second endpoint, the inclination angle and the length of the line segment are calculated; the inclination angle and the length of the line segment are used as the character graphic information of the line segment; based on the character graphic information of the line segment, the character graphic information of the character to be parsed is obtained.
[0084] In the application, the first endpoint coordinates and the second endpoint coordinates are set to A(x1, y1) and B(x2, y2) respectively. Then the line segment length calculated based on the first endpoint coordinates and the second endpoint coordinates can be:
[0085]
[0086] It should be understood that |AB| here is the length of the line segment.
[0087] Accordingly, the inclination angle of the line segment calculated based on the first endpoint coordinates and the second endpoint coordinates can be:
[0088]
[0089] in, is the tilt angle.
[0090] In this embodiment, in order to facilitate the storage of character graphic information, numbers can be pre-written for different tilt angles. Figure 3 , Figure 3 The angle number diagram is written as follows: Figure 3 It can be seen that the number 0 represents a line segment of 0 degrees, 1 represents a line segment of 30 degrees, and so on. The number F represents 330 degrees.
[0091] In an example, the character graphic information is as follows:
[0092] 020,016,01A,0;
[0093] The first stroke is a horizontal line segment with a length of 2, the second stroke is a line segment with a length of 1 and a direction of 135 degrees, the third stroke is a line segment with a length of 1 and a direction of -135 degrees, and the last 0 indicates the end.
[0094] In this embodiment, according to actual needs, the character graphic information may also include information indicating whether the N disassembled primitives form a closed graphic, and whether the N disassembled primitives form a polygon, etc. This embodiment does not make specific limitations on this.
[0095] In an example, the capital letter "L" becomes a polyline segment after being written into AutoCAD and disassembled. The entity properties of this line segment are queried, and the parameter (IsClosed property) indicating the polygon (AcDbCurve) in the property is true, indicating that the polyline segment is closed.
[0096] In this embodiment, the information indicating whether the N disassembled primitives form a closed figure, the information indicating whether the N disassembled primitives form a polygon, etc. can also be indicated by numbers.
[0097] In an example, there is the following character graphic information:
[0098] *1,4,triangle,
[0099] Among them, 1 is the shape of the character after being disassembled, which is represented by four data and the shape name is "triangle".
[0100] Step 203: Establish a mapping relationship between the character to be parsed and the character graphic information.
[0101] In this embodiment, a mapping relationship between the character to be parsed and the character graphic information may be established based on the name of the character to be parsed.
[0102] It should be understood that the name of the character to be parsed here indicates the meaning of the character to be parsed.
[0103] Step 204: store the character graphic information according to the mapping relationship.
[0104] In this embodiment, in order to facilitate the subsequent search for character graphic information, a character set is set for each character type. When storing the character graphic information, the character graphic information is stored in the character set corresponding to the character type of the character to be parsed.
[0105] In a specific embodiment, the character type of the character to be parsed is obtained; and the character to be parsed is stored in a character set corresponding to the character type according to a mapping relationship.
[0106] In the application, when character graphic information is stored according to the mapping relationship, the stored information may include the name of the character to be parsed, the character type of the character to be parsed, and Json information, wherein the Json information includes two attributes: coordinate information (positions) and index (indexes). Positions is a one-dimensional array containing the coordinate information of the point; indexes is a one-dimensional array storing the numbers of the points on the multi-line segment.
[0107] It should be understood that after storing the character graphic information of the character to be parsed, the character to be parsed in the workspace of the drawing editing tool is cleared, and the next character to be parsed is read from the drawing file, and then the drawing parsing method of steps 201 to 204 is executed for the next character to be parsed.
[0108] In the application, in order to improve processing efficiency, all the characters to be parsed in the drawing file can be read in advance, and all the read characters to be parsed can be stored in a preset storage address. Therefore, after storing the character graphic information of the character to be parsed, the next character to be parsed can be read from the preset storage address, and the drawing parsing method of steps 201 to 204 above can be executed for the next character to be parsed.
[0109] The technical solution provided by the embodiment of the present application obtains the characters to be parsed from the drawing file to be parsed; obtains the character graphic information of the characters to be parsed, and the character graphic information is used to indicate the shape of the characters to be parsed; establishes a mapping relationship between the characters to be parsed and the character graphic information; and stores the character graphic information according to the mapping relationship. Since the character graphic information indicating the shape of the characters to be parsed is stored, when the drawing file needs to be displayed on the web page, the characters can be drawn based on the character graphic information of the characters to be displayed, so that when the font format of the characters is not a format supported by the Windows system, the characters can also be displayed.
[0110] In another embodiment of the present application, when the drawing file is displayed on a web page, if there are unrecognizable characters in the drawing file, the characters can be drawn based on previously stored character graphic information.
[0111] In a specific embodiment, a character insertion request for an insertion point is obtained, the character insertion request carries a character height and a character identification parameter of a character to be displayed, and the insertion point indicates an insertion position of a non-drawing editing tool; target character graphic information corresponding to the character identification parameter is obtained, the target character graphic information includes coordinate information of M graphic elements; based on the character height and the coordinate information of the M graphic elements, the character to be displayed is drawn at the insertion point.
[0112] It should be understood that the character height here is essentially the character size. For example, when the character height is 4, it means that the size of the character is 4.
[0113] In this embodiment, the character identification parameters include but are not limited to the name of the character and the character type to which the character belongs. For example, the name of the character may be "circuit breaker", and the character type to which the character belongs may be ttf.
[0114] In this embodiment, when obtaining target character graphic information corresponding to the character identification parameter, the character set corresponding to the character type in the character identification parameter can be searched first, and then the target character graphic information corresponding to the character name in the character identification parameter can be searched from the character set.
[0115] In this embodiment, since the character height of the character corresponding to the target character graphic information is inconsistent with the character height set in the web page, the character height in the character insertion request actually implements proportional scaling of the character height of the character corresponding to the target character graphic information.
[0116] In an optional embodiment, when the coordinate information of M graphic elements includes the coordinate information of S points, the horizontal coordinate and the vertical coordinate of the insertion point are obtained; and the horizontal coordinate and the vertical coordinate of the target point are obtained, and the target point is any point among the S points; the products of the horizontal coordinate and the vertical coordinate of the target point and the character height are respectively calculated to obtain the calculated horizontal coordinate and the calculated vertical coordinate; the calculated horizontal coordinate and the horizontal coordinate of the insertion point are summed to obtain the converted horizontal coordinate; the calculated vertical coordinate and the vertical coordinate of the insertion point are summed to obtain the converted vertical coordinate; the target point is drawn at the position corresponding to the converted horizontal coordinate and the converted vertical coordinate; and the characters to be displayed are obtained based on the drawn S target points.
[0117] The S points include endpoints of line segments and / or independent points;
[0118] In specific calculation, the target point coordinates are defined as (a, b), the insertion point coordinates are defined as (x0, y0), and the character height in the character insertion request is n, then the conversion coordinates may be (na+x0,nb+y0).
[0119] Based on the same concept, a drawing parsing device is provided in the embodiment of the present application. The specific implementation of the device can be found in the description of the method embodiment part, and the repeated parts will not be repeated. Figure 4 As shown, the device mainly includes:
[0120] The first acquisition unit 401 is used to acquire the characters to be parsed from the drawing file to be parsed;
[0121] A second acquiring unit 402 is used to acquire character graphic information of the character to be parsed, where the character graphic information is used to indicate the shape of the character to be parsed;
[0122] An establishing unit 403 is used to establish a mapping relationship between the character to be parsed and the character graphic information;
[0123] The storage unit 404 is used to store character graphic information according to the mapping relationship.
[0124] The second acquisition unit 402 is used for:
[0125] Write the characters to be parsed into the work area of the drawing editing tool;
[0126] Decompose the character to be parsed into N graphic elements in the work area, any graphic element includes a line segment or a point;
[0127] Get the coordinate information of each of the N graphics elements respectively;
[0128] Based on the coordinate information, character graphic information of the character to be parsed is obtained.
[0129] The second acquisition unit 402 is used for:
[0130] Obtain T independent points from N primitives, wherein when the N primitives include a line segment, the line segment includes two independent points;
[0131] Number the T endpoints respectively to obtain T numbers;
[0132] The T numbers and coordinate information are used as character graphic information.
[0133] Optionally, the primitive is a line segment;
[0134] The second acquisition unit 402 is used for:
[0135] Get the coordinates of the first endpoint and the second endpoint of the line segment;
[0136] Based on the first endpoint coordinates and the second endpoint coordinates, calculate the inclination angle and the length of the line segment;
[0137] The tilt angle and the length of the line segment are used as the character graphic information of the line segment;
[0138] Based on the character graphic information of the line segment, the character graphic information of the character to be parsed is obtained.
[0139] Optionally, the storage unit 404:
[0140] Get the character type of the character to be parsed;
[0141] According to the mapping relationship, the characters to be parsed are stored in the character set corresponding to the character type.
[0142] The device is also used to:
[0143] After storing the character graphic information according to the mapping relationship, a character insertion request of the insertion point is obtained, the character insertion request carries the character height and character identification parameters of the character to be displayed, and the insertion point indicates the insertion position of the non-drawing editing tool;
[0144] Acquire target character graphic information corresponding to the character identification parameter, the target character graphic information including coordinate information of M graphic elements;
[0145] Based on the character height and the coordinate information of the M graphics elements, the character to be displayed is drawn at the insertion point.
[0146] Optionally, the coordinate information of the M graphic elements includes coordinate information of S points, wherein the S points include endpoints of line segments and / or independent points;
[0147] The device is used to:
[0148] Obtain the horizontal coordinate and vertical coordinate of the insertion point; and obtain the horizontal coordinate and vertical coordinate of the target point, where the target point is any point among the S points;
[0149] Calculate the product of the horizontal coordinate and the vertical coordinate of the target point and the character height respectively to obtain the calculated horizontal coordinate and the calculated vertical coordinate;
[0150] The calculated abscissa and the abscissa of the insertion point are summed to obtain the converted abscissa; the calculated ordinate and the ordinate of the insertion point are summed to obtain the converted ordinate;
[0151] Draw the target point at the position corresponding to the converted horizontal coordinate and the converted vertical coordinate;
[0152] The characters to be displayed are obtained based on the drawn S target points.
[0153] Based on the same concept, an electronic device is also provided in the embodiment of the present application, such as Figure 5 As shown, the electronic device mainly includes: a processor 501, a memory 502 and a communication bus 503, wherein the processor 501 and the memory 502 communicate with each other through the communication bus 503. The memory 502 stores a program executable by the processor 501, and the processor 501 executes the program stored in the memory 502 to implement the following steps:
[0154] Obtain the characters to be parsed from the drawing file to be parsed; obtain character graphic information of the characters to be parsed, the character graphic information is used to indicate the shape of the characters to be parsed; establish a mapping relationship between the characters to be parsed and the character graphic information; store the character graphic information according to the mapping relationship.
[0155] The communication bus 503 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 503 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0156] The memory 502 may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Alternatively, the memory may also be at least one storage device located away from the processor 501 .
[0157] The above-mentioned processor 501 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., and can 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 gates or transistor logic devices, discrete hardware components.
[0158] In another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed on a computer, the computer executes the drawing parsing method described in the above embodiment.
[0159] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instruction is transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape, etc.), an optical medium (e.g., a DVD) or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0160] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0161] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A drawing analysis method, characterized in that: include: Get the characters to be parsed from the drawing file to be parsed; Acquire character graphic information of the character to be parsed, wherein the character graphic information is used to indicate the shape of the character to be parsed; Establishing a mapping relationship between the character to be parsed and the character graphic information; According to the mapping relationship, storing the character graphic information; Wherein, obtaining the character graphic information of the character to be parsed includes: Decomposing the character to be parsed into N graphic elements, any of which includes a line segment or a point; Obtaining coordinate information of each of the N graphic elements respectively; Based on the coordinate information, obtaining character graphic information of the character to be parsed; Wherein, the graphic element is the line segment; Based on the coordinate information, character graphic information of the character to be parsed is obtained, including: Obtain the first endpoint coordinates and the second endpoint coordinates of the line segment; Based on the first endpoint coordinates and the second endpoint coordinates, calculating the inclination angle and the length of the line segment; Using the tilt angle and the line segment length as character graphic information of the line segment; Based on the character graphic information of the line segment, obtaining the character graphic information of the character to be parsed; Wherein, after storing the character graphic information according to the mapping relationship, the method further includes: Obtain a character insertion request of an insertion point, the character insertion request carrying a character height and a character identification parameter of a character to be displayed, and the insertion point indicates an insertion position of a non-drawing editing tool; Acquire target character graphic information corresponding to the character identification parameter, wherein the target character graphic information includes coordinate information of M graphic elements; Based on the character height and the coordinate information of the M graphic elements, drawing the character to be displayed at the insertion point; The coordinate information of the M graphic elements includes coordinate information of S points, wherein the S points include endpoints of line segments and / or independent points; Drawing the character to be displayed at the insertion point based on the character height and the coordinate information of the M graphic elements includes: Obtaining the horizontal coordinate and the vertical coordinate of the insertion point; and obtaining the horizontal coordinate and the vertical coordinate of the target point, wherein the target point is any point among the S points; Respectively calculating the product of the abscissa and ordinate of the target point and the character height to obtain a calculated abscissa and a calculated ordinate; The calculated horizontal coordinate and the horizontal coordinate of the insertion point are summed to obtain a converted horizontal coordinate; the calculated vertical coordinate and the vertical coordinate of the insertion point are summed to obtain a converted vertical coordinate; Draw the target point at a position corresponding to the converted horizontal coordinate and the converted vertical coordinate; The character to be displayed is obtained based on the drawn S target points.
2. The method according to claim 1, characterized in that: Based on the coordinate information, character graphic information of the character to be parsed is obtained, including: Acquire T independent points in the N graphic elements, wherein when the N graphic elements include a line segment, the line segment includes two independent points; Number the T endpoints respectively to obtain T numbers; The T numbers and the coordinate information are used as the character graphic information.
3. The method according to claim 1, characterized in that According to the mapping relationship, storing the character graphic information includes: Obtain the character type of the character to be parsed; According to the mapping relationship, the characters to be parsed are stored in a character set corresponding to the character type.
4. A drawing analysis device, characterized in that: include: A first acquisition unit is used to acquire characters to be parsed from the drawing file to be parsed; A second acquiring unit, used for acquiring character graphic information of the character to be parsed, wherein the character graphic information is used for indicating the shape of the character to be parsed; An establishing unit, used for establishing a mapping relationship between the character to be parsed and the character graphic information; A storage unit, used for storing the character graphic information according to the mapping relationship; Wherein, obtaining the character graphic information of the character to be parsed includes: Decomposing the character to be parsed into N graphic elements, any of which includes a line segment or a point; Obtaining coordinate information of each of the N graphic elements respectively; Based on the coordinate information, obtaining character graphic information of the character to be parsed; Wherein, the graphic element is the line segment; Based on the coordinate information, character graphic information of the character to be parsed is obtained, including: Obtain the first endpoint coordinates and the second endpoint coordinates of the line segment; Based on the first endpoint coordinates and the second endpoint coordinates, calculating the inclination angle and the length of the line segment; Using the tilt angle and the line segment length as character graphic information of the line segment; Based on the character graphic information of the line segment, obtaining the character graphic information of the character to be parsed; Wherein, after storing the character graphic information according to the mapping relationship, the method further includes: Obtain a character insertion request of an insertion point, the character insertion request carrying a character height and a character identification parameter of a character to be displayed, and the insertion point indicates an insertion position of a non-drawing editing tool; Acquire target character graphic information corresponding to the character identification parameter, wherein the target character graphic information includes coordinate information of M graphic elements; Based on the character height and the coordinate information of the M graphic elements, drawing the character to be displayed at the insertion point; The coordinate information of the M graphic elements includes coordinate information of S points, wherein the S points include endpoints of line segments and / or independent points; Drawing the character to be displayed at the insertion point based on the character height and the coordinate information of the M graphic elements includes: Obtaining the horizontal coordinate and the vertical coordinate of the insertion point; and obtaining the horizontal coordinate and the vertical coordinate of the target point, wherein the target point is any point among the S points; Respectively calculating the product of the abscissa and ordinate of the target point and the character height to obtain a calculated abscissa and a calculated ordinate; The calculated horizontal coordinate and the horizontal coordinate of the insertion point are summed to obtain a converted horizontal coordinate; the calculated vertical coordinate and the vertical coordinate of the insertion point are summed to obtain a converted vertical coordinate; Draw the target point at a position corresponding to the converted horizontal coordinate and the converted vertical coordinate; The character to be displayed is obtained based on the drawn S target points.
5. An electronic device, characterized in that: include: A processor, a memory and a communication bus, wherein the processor and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to execute the program stored in the memory to implement the drawing parsing method described in any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the drawing parsing method according to any one of claims 1 to 3 is implemented.
