Document object Boolean operation method
By generating a lookup table in the document object boolean operation and judging the intersection of rectangles, and selecting a suitable path boolean operation method, the problem of excessive memory usage and time-consuming in the prior art is solved, and a more efficient document object boolean operation is achieved.
Patent Information
- Application Number
- CN202411941446.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-06-03
AI Technical Summary
The prior art causes excessive memory usage and time-consuming problems when document objects are operated by Boolean.
By generating an N*M*Z lookup table, record the minimum boundary rectangle of rectangle A and rectangle B, judge their intersection situation, and select a normal or optimized path Boolean operation method based on the intersection situation.
Effectively reduces the memory usage and time-consuming of path boolean operations, and improves the efficiency of document object boolean operations.
Smart Images

Figure CN120085830A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vector graphics Boolean operations, and particularly to a method for Boolean operations on document objects. Background Art
[0002] Boolean graphic operations refer to graphics processed by using logical operations - Boolean operations. Boolean operation is a logical deduction method of digital symbolization, including union, intersection, and subtraction. This logical operation method is introduced in graphic processing operations to enable simple basic graphics to be combined to generate new shapes, and can be developed from two-dimensional Boolean operations such as Figure 1 to three-dimensional graphic Boolean operations.
[0003] When there is a series of objects in a document that need to perform Boolean operations, the objects need to be converted into paths one by one, and then Boolean operations are performed on the paths one by one.
[0004] At this time, a large number of time-consuming path Boolean operations will occur, resulting in excessive memory occupation and time consumption. Summary of the Invention
[0005] The main object of the present invention is to provide a method for Boolean operations on document objects to solve the problems of excessive memory occupation and time consumption caused by performing Boolean operations in the prior art.
[0006] To achieve the above object, according to the present invention, a method for Boolean operations on document objects is provided. A method for Boolean operations on document objects is characterized in that an N*M*Z lookup table is generated for the document interface. The lookup table can record at least two rectangles, rectangle A and rectangle B. The rectangle A and rectangle B respectively correspond to different paths, and the paths are composed of minimum bounding rectangles. When adding the path of rectangle A to the lookup table, it is judged which regions in the lookup table the minimum bounding rectangle of the path of rectangle A intersects. If there is an intersection, the rectangle of the path of rectangle A is recorded in these intersecting regions; it is judged whether rectangle B intersects with the recorded rectangle, and the minimum bounding rectangle of the path of rectangle B is used to search in the lookup table to confirm whether the minimum bounding rectangle of rectangle A recorded in the lookup table intersects with the minimum bounding rectangle of the current path of rectangle B.
[0007] When the minimum bounding rectangle of rectangle A intersects with the minimum bounding rectangle of the current path of rectangle B, normal path Boolean operations are performed.
[0008] When the minimum bounding rectangle of rectangle A does not intersect with the minimum bounding rectangle of the current path of rectangle B, optimized Boolean operations are performed.
[0009] When rectangle A and rectangle B do not intersect, when path A and path B are added, it is represented as the addition of two strings in the program; if path A and path B are cross Boolean operations, an empty value is returned; if path A and path B are subtraction Boolean operations, then path A is returned; if path A and path B are exclusion Boolean operations, then simply add path A and path B directly.
[0010] When rectangle A and rectangle B intersect, when path A and path B are mixed Boolean operations, the added area of path A and path B is returned; if path A and path B are cross Boolean operations, the intersecting area of path A and path B is returned; if path A and path B are subtraction Boolean operations, the area obtained by subtracting the intersecting area of path A and path B from path A is returned; if path A and path B are exclusion Boolean operations, the area obtained by adding the areas of path A and path B and then subtracting the intersecting area of path A and path B is returned.
[0011] When the document interface is a 2D plane and there is an N*M*Z lookup table, one of the values of N*M*Z is 0.
[0012] Read in the data of rectangle A and rectangle B in sequence. Corresponding to the regions in the lookup table for the minimum bounding rectangle data of all vertices, edges, and faces of rectangle A, record them in the A2_Point_list table; corresponding to the regions in the lookup table for the minimum bounding rectangle data of all vertices, edges, and faces of rectangle B, record them in the B2_Point_list table; determine whether there are the same values in the A2_Point_list table and the B2_Point_list table. If there are, it is determined to be intersecting; if not, it is determined to be non-intersecting.
[0013] When the interface is a 3D interface and there is an N*M*Z lookup table, all values of N*M*Z are not 0. Read in the data of rectangle A and rectangle B in sequence. Corresponding to the regions in the lookup table for the minimum bounding rectangle data of all vertices, edges, loops, and faces of rectangle A, record them in the A3_Point_list table; corresponding to the regions in the lookup table for the minimum bounding rectangle data of all vertices, edges, loops, and faces of rectangle B, record the regions in the B3_Point_list table. Determine whether there are the same values in the A3_Point_list table and the B3_Point_list table. If there are, it is determined to be intersecting; if not, it is determined to be non-intersecting.
[0014] When the document interface is a 2D plane, the minimum bounding rectangle is a 1 unit * 1 unit square. At this time, for the 2D interface lookup table, a 10-unit can be used as a separator. The length of one side of the interface is 10*N, and the length of the other side is 10*M; or a 100-unit can be used as a separator. The length of one side of the interface is 100*N, and the length of the other side is 100*M.
[0015] When the document interface is a three-dimensional plane, the root minimum bounding rectangle is a cube with a size of 1 unit * 1 unit * 1 unit. At this time, for the three-dimensional interface lookup table, a separator line can be set every 10 units. One side length of the interface is 10 * N, another side length is 10 * M, and the third side is 10 * Z; or a separator line can be set every 100 units, with one side length of the interface being 100 * N, another side length being 100 * M, and the third side being 100 * Z.
[0016] Rectangle A may be recorded in multiple lookup tables simultaneously. The paths of rectangle B and rectangle A may intersect in some lookup tables but not in others, or may not intersect in all lookup tables. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings forming a part of this specification are used to provide a further understanding of the present invention. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention.
[0018] Figure 1 Examples of the Boolean operations of the invention are shown, including hybrid Boolean operations, cross Boolean operations, reduction Boolean operations, and exclusion Boolean operations.
[0019] Figure 2 Specific Embodiment 1 of the present invention is shown.
[0020] Figure 3 Specific Embodiment 2 of the present invention is shown. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0021] It should be noted that, without conflict, the embodiments in the present invention and the features in the embodiments can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0022] It should be pointed out that unless otherwise specified, all technical and scientific terms used in the present invention have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs.
[0023] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0024] Embodiment 1
[0025] When the document interface is a two-dimensional plane, one of the values in the N*M*Z lookup table is 0. When a two-dimensional pattern needs to perform a Boolean operation.
[0026] 1. Generate a two-dimensional lookup table as Figure 2 , assuming the size is 1000*1000, divided into 10*10 regions, and the size of each small square is 100*100.
[0027] 2. The lookup table can record a batch of rectangles, and each rectangle corresponds to a path. The minimum bounding rectangle of all current objects to be operated on.
[0028] 3. Now as Figure 2 shown, the position of Shape1 is (228, 169), the size is (132, 99), and it intersects with the grids of (2, 1), (3, 1), (2, 2), (3, 2), (2, 1), (2, 1). Then record the grids where Shape1 intersects in the A2_Point_list.
[0029] 4. Next, look at Shape2. It intersects with the grids of (4, 4), (5, 4), (6, 4), (4, 5), (5, 5), (6, 5). Then record the grids where Shape2 intersects and record the area in the B22_Point_list table. At this time, judge that there are no identical values in the A2_Point_list table and the B22_Point_list table. So Shape2 does not intersect with the Shape1 object.
[0030] 5. Shape2 does not intersect with the Shape1 object. When the Boolean operation is addition, it is manifested as the addition of two strings in the program; if Shape1 and Shape2 are cross Boolean operations, return empty; if Shape1 and Shape2 are subtraction Boolean operations: return Shape1; if Shape1 and Shape2 are exclusion Boolean operations, it is manifested as the addition of two strings in the program.
[0031] 6. Then look at Shape3. It intersects with the grids of ((1, 2), (2, 2), (1, 3), (2, 3), (1, 4), (2, 4). Then record the grids where Shape3 intersects and record the area in the B21_Point_list table. At this time, judge that there is an identical value (2, 2) in the A2_Point_list table and the B21_Point_list table. Then judge that Shape3 intersects with Shape1.
[0032] 7. When Shape3 and Shape1 intersect, if Shape3 and Shape1 are in a mixed Boolean operation, the added area of Shape3 and Shape1 is returned; if Shape1 and Shape3 are in an intersection Boolean operation, the intersecting area of Shape1 and Shape3 is returned; if Shape1 and Shape3 are in a subtraction Boolean operation, the area obtained by subtracting the intersecting area of Shape1 and Shape3 from the Shape1 area is returned; if Shape1 and Shape3 are in an exclusion Boolean operation, the area obtained by adding the Shape1 and Shape3 areas and then subtracting the intersecting area of Shape1 and Shape3 is returned.
[0033] Embodiment 2
[0034] When the document interface is a 3D plane and for an N*M*Z lookup table, all three of the N, M, and Z values are non-zero. When there is a 3D pattern that requires a Boolean operation.
[0035] 1. Generate a 3D lookup table as Figure 3 , assuming a size of 1000*1000*1000, divided into 10*10*10 regions, and the size of each small grid is 100*100*100.
[0036] 2. The lookup table can record a batch of rectangles, with each rectangle corresponding to a path. Rectangularize the minimum bounding rectangles of all current objects to be operated on.
[0037] 3. As shown in Figure 3 , the position of rectangle 1 is (159, 0, 2) with a size of (152, 189, 135), and it intersects 12 grids such as (1, 0, 0), (2, 0, 0), (3, 0, 0), (1, 0, 1), (2, 0, 1), (3, 0, 1), (1, 1, 1), (2, 1, 1), (3, 1, 1), (1, 1, 0), (2, 1, 0), (3, 1, 0). Then record the grids intersected by rectangle 1 in the A3_Point_list.
[0038] 4. Next, look at rectangle 2. It intersects 8 grids such as (1, 0, 0), (2, 0, 0), (1, 0, 1), (2, 0, 1), (1, 1, 1), (2, 1, 1), (1, 1, 0), (2, 1, 0). Then record the grids intersected by rectangle 2 and record the area in the B31_Point_list table. At this time, judge whether there are 8 identical values (1, 0, 0), (2, 0, 0), (1, 0, 1), (2, 0, 1), (1, 1, 1), (2, 1, 1), (1, 1, 0), (2, 1, 0) in the A3_Point_list table and the B31_Point_list table. If so, it is judged as an intersection.
[0039] 5. When the rectangle 2 and rectangle 1 intersect, if the rectangle 2 and rectangle 1 are in a mixed Boolean operation, return the added area of rectangle 2 and rectangle 1; if rectangle 1 and rectangle 2 are in an intersection Boolean operation, return the intersecting area of rectangle 1 and rectangle 2; if rectangle 1 and rectangle 2 are in a subtraction Boolean operation, return the area of rectangle 1 minus the intersecting area of rectangle 1 and rectangle 2; if rectangle 1 and rectangle 2 are in an exclusion Boolean operation: return the added area of rectangle 1 and rectangle 2, and then the intersecting area of rectangle 1 and rectangle 2.
[0040] 6. Now look at rectangle 3. It intersects with 2 grids such as (4, 0, 0) and (4, 1, 0). Then record the grids that rectangle 3 intersects with and record the area in the B32_Point_list table. At this time, judge whether there is any one in the A3_Point_list table and the B32_Point_list table, and judge that they do not intersect.
[0041] 7. Rectangle 3 does not intersect with the rectangle 1 object. When the Boolean operation is addition, it is manifested as the addition of two strings in the program; if rectangle 1 and rectangle 3 are in an intersection Boolean operation, return an empty set; if rectangle 1 and rectangle 3 are in a subtraction Boolean operation: return rectangle 1; if rectangle 1 and rectangle 3 are in an exclusion Boolean operation, it is manifested as the addition of two strings in the program.
[0042] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments of the present invention. For example, in Embodiment 1, rectangle A can be Shape1, and rectangle B can be Shape2 or Shape3. In Embodiment 2, rectangle A can be rectangle 1, and rectangle B can be rectangle 2 or rectangle 3.
[0043] Unless the context clearly indicates otherwise, the singular forms are also intended to include the plural forms. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they specify the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0044] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for Boolean operation of a document object, characterized in that: Generate an N*M*Z lookup table on the document interface, the lookup table can record at least two rectangles, rectangle A and rectangle B, the rectangle A and rectangle B correspond to different paths respectively, the path is composed of minimum bounding moments, when the path of rectangle A is to be added to the lookup table, determine which areas in the lookup table the minimum bounding rectangle of the path of rectangle A intersects with, if so, record the rectangles of the path of rectangle A into these intersecting areas; determine whether rectangle B intersects with the recorded rectangle, use the minimum bounding rectangle of the path of rectangle B to search in the lookup table, and confirm whether the minimum bounding rectangle of rectangle A recorded in the lookup table intersects with the minimum bounding rectangle of the current path of rectangle B.
2. According to the method of Boolean operation of document objects described in claim 1, when the minimum bounding rectangle of rectangle A intersects with the minimum bounding rectangle of the current path of rectangle B, a normal path Boolean operation is performed.
3. According to the method of Boolean operation of document objects described in claim 1, when the minimum bounding rectangle of rectangle A does not intersect with the minimum bounding rectangle of the current path of rectangle B, an optimized Boolean operation is performed.
4. According to the method-based Boolean operation of a document object Boolean operation as claimed in claim 3, the optimized Boolean operation is: If path A and path B are mixed Boolean operations, then path A and path B are directly added together, which is represented as the addition of two strings in the program; If path A and path B are cross Boolean operations, return empty; If path A and path B are reduction Boolean operations: then return path A; If path A and path B are exclusive Boolean operations, then just add path A and path B together, which is represented as the addition of two strings in the program.
5. According to the method for Boolean operation of a document object as claimed in claim 2, the normal Boolean operation is: If path A and path B are mixed Boolean operations, the added area of path A and path B is returned; If path A and path B are cross Boolean operations, the intersection area of path A and path B is returned; If Path A and Path B are reduction Boolean operations, then the area of Path A minus the area where Path A and Path B intersect is returned; If Path A and Path B are exclusive Boolean operations: the area of Path A plus the area of Path B is returned, and then the area of the intersection of Path A and Path B is subtracted.
6. A method for Boolean operation of document objects according to claim 1, wherein the document interface is a 2-dimensional plane, an N*M*Z lookup table, and one of the values of N*M*Z is 0. Read the data of rectangle A and rectangle B in sequence, and record the minimum boundary moment data of all vertices, edges, and faces of rectangle A corresponding to the area where the lookup table is located in the A2_Point_list table; The minimum boundary moment data of all vertices, edges and faces of the rectangle B are recorded in the B2_Point_list table; It is determined whether the A2_Point_list table and the B2_Point_list table have the same value. If so, it is determined that they intersect; otherwise, it is determined that they do not intersect.
7. A method for Boolean operation of document objects according to claim 1, wherein the document interface is a 3D interface, an N*M*Z lookup table, all values of N*M*Z are not 0, Read the data of rectangle A and rectangle B in sequence, correspond the minimum bounding moment data of all vertices, edges, rings and faces of rectangle A to the area where the lookup table is located, and record it in the A3_Point_list table; correspond the minimum bounding moment data of all vertices, edges, rings and faces of rectangle B to the area where the lookup table is located, and record the area in the B3_Point_list table, and determine whether the A3_Point_list table and the B3_Point_list table have the same value. If so, it is determined that they intersect, otherwise it is determined that they do not intersect.
8. According to the method of Boolean operation of document objects in claim 6, when the minimum bounding rectangle is a 1 unit * 1 unit square, the two-dimensional interface lookup table can use 10 units as a dividing line, and the length of one side of the interface is 10 * N, and the length of the other side is 10 * M; Or you can use 100 units as a dividing line, with the length of one side of the interface being 100*N and the length of the other side being 100*M.
9. According to the method of Boolean operation of a document object in claim 7, when the minimum bounding rectangle is a cube of 1 unit * 1 unit * 1 unit, the three-dimensional interface lookup table can use 10 units as a dividing line, the length of one side of the interface is 10 * N, the length of another side is 10 * M, and the third side is 10 * Z; Or you can use 100 units as a dividing line, with the length of one side of the interface being 100*N, the length of another side being 100*M, and the third side being 100*Z.
10. According to the method for Boolean operation of a document object as claimed in any one of claims 8 or 9, the rectangle A is recorded in multiple lookup tables at the same time. The paths of the rectangle B and the rectangle A may intersect in some lookup tables but not in other lookup tables, or may not intersect in all lookup tables.