CN117744187B - CAD drawing method, device, computer equipment and storage medium - Google Patents
CAD drawing method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN117744187B CN117744187B CN202410186783.0A CN202410186783A CN117744187B CN 117744187 B CN117744187 B CN 117744187B CN 202410186783 A CN202410186783 A CN 202410186783A CN 117744187 B CN117744187 B CN 117744187B
- Authority
- CN
- China
- Prior art keywords
- primitive
- drawn
- primitive data
- collected
- data set
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 62
- 238000012545 processing Methods 0.000 claims abstract description 65
- 238000004590 computer program Methods 0.000 claims abstract description 29
- 230000009191 jumping Effects 0.000 claims description 9
- 238000012216 screening Methods 0.000 claims description 4
- 230000008569 process Effects 0.000 description 17
- 238000009877 rendering Methods 0.000 description 15
- 230000005540 biological transmission Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 8
- 239000007787 solid Substances 0.000 description 8
- 238000004891 communication Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 3
- 230000008901 benefit Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000011960 computer-aided design Methods 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- IQVNEKKDSLOHHK-FNCQTZNRSA-N (E,E)-hydramethylnon Chemical compound N1CC(C)(C)CNC1=NN=C(/C=C/C=1C=CC(=CC=1)C(F)(F)F)\C=C\C1=CC=C(C(F)(F)F)C=C1 IQVNEKKDSLOHHK-FNCQTZNRSA-N 0.000 description 1
- OKTJSMMVPCPJKN-UHFFFAOYSA-N Carbon Chemical compound [C] OKTJSMMVPCPJKN-UHFFFAOYSA-N 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000008030 elimination Effects 0.000 description 1
- 238000003379 elimination reaction Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 229910021389 graphene Inorganic materials 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 238000012163 sequencing technique Methods 0.000 description 1
Landscapes
- Image Generation (AREA)
Abstract
The present application relates to a CAD drawing method, apparatus, computer device, storage medium, and computer program product. The method comprises the following steps: collecting the primitive data by adopting a central processing unit according to the drawing sequence of the primitives to be drawn of the CAD; when the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is different from the primitive type of the previous primitive to be drawn, the drawing order offset value of the previous primitive to be drawn is increased by 1 to be used as the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs; integrating the collected primitive data to obtain a primitive data set under the condition that the collected quantity meets the preset condition, and determining the drawing order reference value of the primitive data set; and drawing the drawing primitive to which the collected primitive data belongs according to the primitive data set, the drawing order reference value and the drawing order offset value of the drawing primitive to be drawn by adopting a graphic processor. The method can improve the drawing efficiency of CAD.
Description
Technical Field
The present application relates to the field of CAD technology, and in particular, to a CAD drawing method, apparatus, computer device, storage medium, and computer program product.
Background
When designing in CAD two-dimensional mode, it is often drawn according to the order of creation of primitive entities, but sometimes it is also displayed in the order specified by the user, for example, with a post-created fill displayed at the lowest level, or with a background mask (Wipeout) placed at the top, etc. After the design is finished, the computer opens the previous drawing again, and the same drawing sequence is still displayed, so the drawing sequence is very important for the user.
In the traditional technology, only the primitive entities need to be drawn one by one, so that the accuracy of the drawing sequence can be ensured. However, this drawing method is low in processing efficiency.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a CAD drawing method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the drawing efficiency of CAD.
In a first aspect, the present application provides a CAD drawing method, comprising:
Collecting the primitive data of each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitive to be drawn of CAD; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
when the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is different from the primitive type of the primitive to be drawn, to which the previously collected primitive data belongs, increasing the drawing order offset value of the primitive to be drawn, to which the previously collected primitive data belongs, by 1, and taking the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs;
integrating the collected primitive data to obtain a primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition, and determining a drawing order reference value of the primitive data set;
and drawing the primitive to be drawn, which the collected primitive data belongs to, according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn, which the collected primitive data belongs to, by adopting a graphic processor.
In one embodiment, the determining the drawing order reference value of the primitive data set includes:
Determining a drawing order reference value of a first primitive data set as 0 in the case that the primitive data set is the first primitive data set;
Determining a drawing order reference value of the primitive data set as a drawing order total value of a previous primitive data set in the case that the primitive data set is not the first primitive data set; the total drawing order value of the previous primitive data set is the sum of the drawing order reference value of the previous primitive data set and the maximum drawing order offset value of the previous primitive data set.
In one embodiment, the drawing, by using a graphics processor, the primitive to be drawn to which the collected primitive data belongs according to the primitive data set, the drawing order reference value, and the drawing order offset value of the primitive to be drawn to which the collected primitive data belongs includes:
Acquiring the primitive type of the primitive to be drawn, to which the first primitive data in the primitive data set belongs, as a target primitive type;
According to the target primitive type, screening primitive data of a target primitive to be drawn from the primitive data set; the primitive type of the target primitive to be drawn is the target primitive type;
Drawing a first primitive to be drawn and the target primitive to be drawn according to the drawing order reference value and the drawing order offset value of the primitive to be drawn to which the collected primitive data belong; the first primitive to be drawn is the primitive to be drawn to which the first primitive data belongs;
and removing the primitive data of the first primitive to be drawn and the primitive data of the target primitive to be drawn from the primitive data set to obtain a new primitive data set, and jumping to the step of obtaining the primitive type of the primitive to be drawn, which belongs to the first primitive data in the primitive data set, as the target primitive type until all the primitives to be drawn, which belong to the collected primitive data in the primitive data set, are drawn.
In one embodiment, before drawing the first primitive to be drawn and the target primitive to be drawn, the method further includes:
Acquiring a target drawing instruction corresponding to the target primitive type from a preset drawing instruction library by adopting the central processing unit;
the drawing of the first primitive to be drawn and the target primitive to be drawn comprises the following steps:
And executing one target drawing instruction by adopting the graphic processor, and drawing a first primitive to be drawn and the target primitive to be drawn.
In one embodiment, the drawing the primitive to be drawn to which the collected primitive data belongs according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn to which the collected primitive data belongs includes:
adding the drawing order offset value of the drawing primitive to which any collected primitive data belongs and the drawing order reference value to obtain the primitive drawing order value of the drawing primitive to which any collected primitive data belongs;
and drawing the primitives to be drawn, to which any one of the collected primitive data belongs, according to the primitive drawing order value.
In one embodiment, the drawing the primitive to be drawn to which the any collected primitive data belongs according to the primitive drawing order value includes:
according to the primitive drawing depth value standard information of the adopted graphic drawing application programming interface, converting the primitive drawing sequence value into a primitive drawing depth value;
and drawing the graphics to be drawn to which the any collected primitive data belongs according to the drawing depth value of the primitives by adopting the programming interface of the graphics drawing application program.
In one embodiment, the method further comprises:
Under the condition that the number of the primitives to be painted of the collected primitive data meets a preset condition, removing the primitives to be painted of the collected primitive data from the primitives to be painted of the CAD, and obtaining updated primitives to be painted;
And taking the updated drawing primitive to be drawn as the drawing primitive of the CAD, jumping to the CPU, and collecting the primitive data of each drawing primitive according to the drawing sequence of the drawing primitive of the CAD until the collection of the primitive data of the drawing primitive of the CAD is completed.
In a second aspect, the present application also provides a CAD drawing apparatus, including:
The drawing processing module is used for processing the drawing sequence of the drawing primitives to be drawn according to the drawing sequence of the CAD drawing primitives to be drawn by adopting the CPU; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
The sequence offset value determining module is used for increasing the drawing sequence offset value of the primitive to be drawn, which belongs to the previous collected primitive data, by 1 as the drawing sequence offset value of the primitive to be drawn, which belongs to the current collected primitive data, under the condition that the primitive type of the primitive to be drawn, which belongs to the current collected primitive data, is different from the primitive type of the primitive to be drawn, which belongs to the previous collected primitive data;
The sequence reference value determining module is used for integrating the collected primitive data to obtain a primitive data set and determining a drawing sequence reference value of the primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition;
and the drawing module of the drawing primitive is used for drawing the drawing primitive of the collected primitive data according to the primitive data set, the drawing order reference value and the drawing order offset value of the drawing primitive of the collected primitive data by adopting a graphic processor.
In a third aspect, the present application also provides a computer device comprising a memory and a processor, the processor comprising a central processor and a graphics processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
Collecting the primitive data of each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitive to be drawn of CAD; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
when the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is different from the primitive type of the primitive to be drawn, to which the previously collected primitive data belongs, increasing the drawing order offset value of the primitive to be drawn, to which the previously collected primitive data belongs, by 1, and taking the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs;
integrating the collected primitive data to obtain a primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition, and determining a drawing order reference value of the primitive data set;
and drawing the primitive to be drawn, which the collected primitive data belongs to, according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn, which the collected primitive data belongs to, by adopting a graphic processor.
In a fourth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Collecting the primitive data of each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitive to be drawn of CAD; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
when the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is different from the primitive type of the primitive to be drawn, to which the previously collected primitive data belongs, increasing the drawing order offset value of the primitive to be drawn, to which the previously collected primitive data belongs, by 1, and taking the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs;
integrating the collected primitive data to obtain a primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition, and determining a drawing order reference value of the primitive data set;
and drawing the primitive to be drawn, which the collected primitive data belongs to, according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn, which the collected primitive data belongs to, by adopting a graphic processor.
In a fifth aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, performs the steps of:
Collecting the primitive data of each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitive to be drawn of CAD; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
when the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is different from the primitive type of the primitive to be drawn, to which the previously collected primitive data belongs, increasing the drawing order offset value of the primitive to be drawn, to which the previously collected primitive data belongs, by 1, and taking the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs;
integrating the collected primitive data to obtain a primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition, and determining a drawing order reference value of the primitive data set;
and drawing the primitive to be drawn, which the collected primitive data belongs to, according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn, which the collected primitive data belongs to, by adopting a graphic processor.
According to the CAD drawing method, the CAD drawing device, the computer equipment, the storage medium and the computer program product, firstly, a central processing unit is adopted, according to the drawing sequence of the primitives to be drawn of CAD, the primitive data of each primitive to be drawn are collected, wherein the drawing sequence offset value corresponding to the primitive to be drawn, to which the primitive data collected first belongs, is 0, and the drawing sequence can be accurately considered by collecting the primitives according to the drawing sequence, so that the follow-up drawing scheduling processing can be ensured; then, under the condition that the primitive types of the primitives to be drawn, to which the currently collected primitive data belong, are different from those of the primitives to be drawn, the drawing order offset value of the primitives to be drawn, to which the previously collected primitive data belong, is increased by 1, and is used as the drawing order offset value of the primitives to be drawn, to which the currently collected primitive data belong, and when drawing different primitive types by subsequently calling different drawing instructions, the guarantee of accurate drawing order is provided; then, under the condition that the number of the primitives to be drawn, to which the collected primitive data belong, meets the preset condition, integrating the collected primitive data to obtain a primitive data set, integrating the primitives to be drawn into the primitive data set, providing one-time input for subsequent graphic processing, better guaranteeing the accuracy of the drawing sequence of each primitive in each primitive data set, reducing the complexity of data processing and the redundancy of data transmission, and improving the efficiency of drawing processing; determining drawing order reference values of the primitive data sets, and providing accurate reference for ensuring drawing order among different primitive data sets; finally, a graphics processor is adopted to draw the primitive to be drawn, which the collected primitive data belongs to, according to the primitive data set, the drawing order reference value and the drawing order offset value of the collected primitive data, the graphics processor is utilized to draw the primitive to be drawn, the parallel processing capacity of each pixel point of the graphics processor can be better utilized, the drawing efficiency is improved, and the drawing order offset values of the continuous primitives to be drawn with the same primitive type are the same, so that the CPU and the image processor treat the primitives to be drawn as an integrated primitive to be drawn, the drawing instruction transmitted to the image processor by the CPU is reduced, the drawing efficiency is improved, in addition, in the process of drawing the primitive by the image processor, the CPU can process the data of the next primitive data set in parallel, and the overall collaborative work of the CPU and the image processor can improve the overall drawing efficiency. According to the method, the primitive data of the primitives to be drawn are integrated into the data set, one-time input is provided for subsequent graphic processing, the transmission times of the primitive data are reduced, the transmission efficiency is improved, meanwhile, the drawing order accuracy of the graphics processor on each primitive in the same primitive data set is guaranteed by dynamically determining the drawing order offset value corresponding to the primitives to be drawn, and the drawing order accuracy of the graphics processor on the primitives is guaranteed when the drawing efficiency of CAD is improved finally by adopting the graphics processor; in addition, a graphic processor is adopted for drawing, so that the parallel computing capability of the graphic processor is fully exerted, and the drawing efficiency is improved; meanwhile, the parallel cooperative working mode of the central processing unit and the graphic processor can reduce the waiting time between the central processing unit and the graphic processor and improve the overall rendering efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
FIG. 1 is a flow diagram of a CAD drawing method in one embodiment;
FIG. 2 is a flowchart illustrating steps performed by a graphics processor to draw primitives to be drawn according to one embodiment;
FIG. 3 is a flow chart of a CAD drawing method according to another embodiment;
FIG. 4 is a schematic diagram of primitive data processed by a CPU and a graphics processor in one embodiment;
FIG. 5 is a flow diagram of a CAD drawing method in one embodiment;
FIG. 6 is a block diagram of a CAD drawing apparatus in one embodiment;
Fig. 7 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
In one embodiment, as shown in fig. 1, a CAD drawing method is provided, where this embodiment is applied to a terminal for illustration, and it is understood that the method may also be applied to a server, and may also be applied to a system including a terminal and a server, and implemented through interaction between the terminal and the server. The terminal may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, etc., and includes a central processor and a graphic processor. The server may be implemented as a stand-alone server or as a server cluster composed of a plurality of servers. In this embodiment, the method includes the steps of:
Step S101, collecting the primitive data of each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitives to be drawn of CAD; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0.
CAD is a Computer-aided design (Computer-AIDED DESIGN), which is a tool that uses Computer technology to design and draw.
The primitives to be drawn in the CAD may be primitives and any combination of primitives in the CAD. The graphic elements are graphic elements such as points, lines, polygons, circles and the like. Each drawing primitive to be drawn has corresponding associated information including color, texture, size, position, etc.
The terminal firstly adopts a central processing unit to determine the drawing sequence of each drawing primitive by traversing the primitive data of the primitives in the CAD, and then collects the primitive data of each drawing primitive one by one according to the drawing sequence to form a primitive data set of the drawing primitive. And, for each collected drawing primitive to be drawn, a drawing order offset value is set in association, so as to establish a foundation for drawing the correct order subsequently. Wherein the drawing order offset value of the first collected primitive to be drawn in the set is set to 0.
Step S102, when the primitive type of the primitive to be drawn to which the currently collected primitive data belongs is different from the primitive type of the primitive to be drawn to which the previously collected primitive data belongs, the drawing order offset value of the primitive to be drawn to which the previously collected primitive data belongs is incremented by 1 as the drawing order offset value of the primitive to be drawn to which the currently collected primitive data belongs.
In an exemplary embodiment, when collecting the primitive data of the primitive to be drawn, the cpu further identifies the primitive type of the primitive to be drawn to which the primitive data collected currently belongs, and compares the primitive type with the primitive to be drawn to which the primitive data collected previously belongs. When the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is detected to be the same as the primitive type of the primitive to be drawn, to which the previous primitive data belongs, setting the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs, to be equal to the drawing order offset value of the primitive to be drawn, to which the previous collected primitive data belongs; when detecting that the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is different from the primitive type of the primitive to be drawn, to which the previous primitive data belongs, the drawing order offset value of the primitive to be drawn, to which the previous collected primitive data belongs, is increased by 1 to be used as the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs. And ensuring the correctness of the drawing sequence of the displayed graphic elements when the graphic processor is adopted for parallel drawing in the follow-up process. The primitive type may be determined by the geometric attributes, texture attributes, or other specific identification attributes of the primitive.
Step S103, under the condition that the number of the primitives to be drawn, to which the collected primitive data belong, meets the preset condition, integrating the collected primitive data to obtain a primitive data set, and determining a drawing order reference value of the primitive data set.
The central processing unit integrates all the primitive data collected currently to obtain a primitive data set under the condition that the number of the primitives to be drawn, to which the collected primitive data belong, meets the preset condition, and provides one-time input for drawing by the graphics processor; and further determining a drawing order reference value corresponding to the whole primitive data set, and sending the drawing order reference value and the primitive data set to a graphic processor together to ensure the correctness of the drawing order among each primitive data set. And, the arrangement sequence of the primitive data in the primitive data set reserves the collection sequence during collection, namely the corresponding drawing sequence.
The preset condition may be that the number of primitives to be drawn to which the collected primitive data belongs reaches a preset number corresponding to the primitive data set, or that the primitive data of all primitives to be drawn are collected. For example, the number of primitives to be drawn is 12, and each primitive data set may integrate the primitive data of 5 primitives to be drawn, so that three primitive data sets may be obtained, each integrating the primitive data of 5, 5 and 2 primitives to be drawn.
Step S104, drawing the primitive to be painted, which the collected primitive data belongs to, by adopting a graphic processor according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be painted, which the collected primitive data belongs to.
The terminal, using a graphics processor, reads the integrated primitive dataset in preparation for starting the rendering operation. In the drawing process, the graphic processor performs drawing sequencing and organization on each graphic element in the graphic element data set according to the drawing sequence reference value and the drawing sequence offset value of each graphic element to be drawn, so as to ensure the drawing order of the graphic elements. The graphics processor can draw a plurality of primitives with the same type in parallel by adopting different drawing modes for the primitives with different types, so that the drawing efficiency is improved.
In the CAD drawing method, firstly, a central processing unit is adopted to collect the primitive data of each primitive to be drawn according to the drawing sequence of the primitive to be drawn of CAD, wherein the drawing sequence offset value corresponding to the primitive to be drawn, to which the primitive data collected by the first step belongs, is 0, and the drawing sequence can be accurately considered by collecting the primitives according to the drawing sequence, so that the subsequent drawing scheduling processing can be ensured; then, under the condition that the primitive types of the primitives to be drawn, to which the currently collected primitive data belong, are different from those of the primitives to be drawn, the drawing order offset value of the primitives to be drawn, to which the previously collected primitive data belong, is increased by 1, and is used as the drawing order offset value of the primitives to be drawn, to which the currently collected primitive data belong, and when drawing different primitive types by subsequently calling different drawing instructions, the guarantee of accurate drawing order is provided; then, under the condition that the number of the primitives to be drawn, to which the collected primitive data belong, meets the preset condition, integrating the collected primitive data to obtain a primitive data set, integrating the primitives to be drawn into the primitive data set, providing one-time input for subsequent graphic processing, better guaranteeing the accuracy of the drawing sequence of each primitive in each primitive data set, reducing the complexity of data processing and the redundancy of data transmission, and improving the efficiency of drawing processing; determining drawing order reference values of the primitive data sets, and providing accurate reference for ensuring drawing order among different primitive data sets; finally, a graphics processor is adopted to draw the primitive to be drawn, which the collected primitive data belongs to, according to the primitive data set, the drawing order reference value and the drawing order offset value of the collected primitive data, the graphics processor is utilized to draw the primitive to be drawn, the parallel processing capacity of each pixel point of the graphics processor can be better utilized, the drawing efficiency is improved, and the drawing order offset values of the continuous primitives to be drawn with the same primitive type are the same, so that the CPU and the image processor treat the primitives to be drawn as an integrated primitive to be drawn, the drawing instruction transmitted to the image processor by the CPU is reduced, the drawing efficiency is improved, in addition, in the process of drawing the primitive by the image processor, the CPU can process the data of the next primitive data set in parallel, and the overall collaborative work of the CPU and the image processor can improve the overall drawing efficiency. According to the method, the primitive data of the primitives to be drawn are integrated into the data set, one-time input is provided for subsequent graphic processing, the transmission times of the primitive data are reduced, the transmission efficiency is improved, meanwhile, the drawing order accuracy of the graphics processor on each primitive in the same primitive data set is guaranteed by dynamically determining the drawing order offset value corresponding to the primitives to be drawn, and the drawing order accuracy of the graphics processor on the primitives is guaranteed when the drawing efficiency of CAD is improved finally by adopting the graphics processor; in addition, a graphic processor is adopted for drawing, so that the parallel computing capability of the graphic processor is fully exerted, and the drawing efficiency is improved; meanwhile, the parallel cooperative working mode of the central processing unit and the graphic processor can reduce the waiting time between the central processing unit and the graphic processor and improve the overall rendering efficiency.
In an exemplary embodiment, the step S103 determines a drawing order reference value of the primitive data set, and further includes: in the case where the primitive data set is the first primitive data set, determining the drawing order reference value of the first primitive data set as 0; in the case where the primitive data set is not the first primitive data set, determining a drawing order reference value of the primitive data set as a drawing order total value of the previous primitive data set; the total drawing order value of the previous primitive data set is the sum of the drawing order reference value of the previous primitive data set and the maximum drawing order offset value in the previous primitive data set.
Illustratively, the central processor sets the drawing order reference value association of the first collected primitive dataset to 0; then, the drawing order reference value of each subsequent collected primitive data set is set as the drawing order total value of the last primitive data set, and the drawing order total value of the last primitive data set is obtained by adding the drawing order reference value of the last primitive data set to the largest drawing order offset value in the last primitive data set. It should be noted that, in each primitive data set, the primitive to be drawn to which the primitive data collected last belongs is the primitive to be drawn with the largest drawing order offset value in the primitive data set; and the largest drawing order offset value in the last primitive data set is the drawing order offset value corresponding to the primitive to be drawn, to which the primitive data finally collected in the last primitive data set belongs.
The accuracy of the drawing sequence of the primitives in parallel drawing in the same primitive data set is ensured through the setting of the drawing sequence offset value of the primitives to be drawn; by dynamically setting drawing order reference values of the primitive data sets, the correctness of drawing orders of the primitives when the adjacent primitive data sets are drawn in series is ensured, particularly, the correctness of drawing orders between the last primitive to be drawn of the previous primitive data set and the first primitive to be drawn of the next primitive data set can be ensured under the condition that the drawing order offset value and the corresponding drawing order reference value are the same for different primitive data sets by adopting serial drawing.
In the embodiment, the drawing order reference value of each primitive data set is dynamically set, so that the overall drawing order among primitive data sets can be better reflected, the sequential drawing of all primitives is ensured, and the adaptability of parallel drawing by adopting a graphic processor during CAD drawing is improved.
In an exemplary embodiment, as shown in fig. 2, the step S104 uses a graphics processor to draw the primitive to be drawn to which the collected primitive data belongs according to the primitive data set, the drawing order reference value, and the drawing order offset value of the primitive to be drawn to which the collected primitive data belongs, and may further be implemented by the following steps:
Step S201, obtaining the primitive type of the primitive to be drawn, which the first primitive data in the primitive data set belongs to, as the target primitive type;
step S202, according to the type of the target primitive, the primitive data of the target primitive to be drawn is screened out from the primitive data set;
step S203, drawing a first primitive to be drawn and a target primitive to be drawn according to the drawing order reference value and the drawing order offset value of the primitive to be drawn to which the collected primitive data belong;
step S204, the primitive data of the first primitive to be drawn and the primitive data of the target primitive to be drawn are removed from the primitive data set to obtain a new primitive data set, and the primitive type of the primitive to be drawn, which belongs to the first primitive data in the primitive data set, is skipped to be used as the step of the target primitive type until all the primitives to be drawn, which belong to the primitive data collected in the primitive data set, are drawn.
The primitive type of the target primitive to be drawn is the target primitive type.
Wherein the first primitive to be drawn is the primitive to be drawn to which the first primitive data belongs.
Illustratively, after integrating the primitive data sets, the central processor sends the primitive data sets to the graphics processor's memory. When drawing the primitive to be drawn, the graphic processor firstly obtains the primitive to be drawn, which belongs to the first primitive data based on the collection sequence (namely the drawing sequence), in the primitive data set, determines that the primitive type of the first primitive to be drawn is the target primitive type, then identifies each primitive data in the primitive data set, judges whether the primitive type of the primitive to be drawn, which belongs to the primitive data, is the same as the target primitive type, and if so, determines that the primitive to be drawn is the target primitive. Then, the graphics processor can draw the first primitive to be drawn and the target primitive to be drawn in parallel according to the drawing order reference value of the primitive data set and the drawing order offset value of each primitive to be drawn, and the drawing modes can adopt the same primitive type primitive to be drawn, so that the calculation amount of the graphics processor is reduced. At this time, the primitive processor completes drawing of all primitives to be drawn for one primitive type in the primitive data set. Then, the graphics processor eliminates the first primitive to be drawn and the target primitive to be drawn after drawing from the primitive data set to obtain a new primitive data set, and it should be noted that, the elimination of the primitive processor may record the first primitive to be drawn and the target primitive to be drawn as already drawn primitives, and the remaining primitives in the primitive data set are determined as the new primitive data set, instead of deleting the primitive data of the first primitive to be drawn and the target primitive to be drawn directly in the display memory. After obtaining the new primitive data set, the graphics processor returns to step S201 to determine the new first primitive to be drawn and the corresponding target primitive to be drawn again according to the collection sequence, so as to complete drawing of the primitive to be drawn of another primitive type. And the image processor continuously completes the drawing processing of the primitives to be drawn, which are the primitive data collected in the primitive data set, by taking the primitive type as a reference until all the primitives to be drawn, which are the primitive data collected in the primitive data set, are drawn, and all the primitives to be drawn are the set of the primitives to be drawn, which are the primitive data of each primitive in the primitive data set.
In this embodiment, by taking the primitive type as a reference, the graphics processor may draw primitives to be drawn of the same primitive type in the primitive data set in parallel, and use the same drawing manner for the same primitive type, so as to reduce the calculation amount of the graphics processor. And based on the drawing order reference value of the primitive data set and the drawing order offset value of each primitive to be drawn, the display accuracy of the drawing order of the primitives is ensured.
In an exemplary embodiment, before drawing the first primitive to be drawn and the target primitive to be drawn in step S203, the method further includes: and acquiring a target drawing instruction corresponding to the target primitive type from a preset drawing instruction library by adopting a central processing unit.
Further, in an exemplary embodiment, the drawing of the first primitive to be drawn and the target primitive to be drawn in step S203 further includes: and executing a target drawing instruction by adopting a graphic processor, and drawing a first primitive to be drawn and a target primitive to be drawn.
The terminal adopts a central processing unit to search corresponding target drawing instructions from a preset drawing instruction library according to the types of target graphic elements, and then sends the target drawing instructions to the graphic processor once; and the graphics processor executes the received target drawing instruction to draw the first primitive to be drawn and the target primitive to be drawn. It should be noted that, when the central processor sends the primitive data set to the graphics processor, all the target drawing instructions required by the primitive data set may be sent to the graphics processor together. The user may preset the target drawing instruction corresponding to each primitive type to optimize the primitive drawing process of each primitive type.
In this embodiment, by adopting different drawing instructions for the primitives to be drawn of different primitive types, custom drawing of different primitive types is achieved, so as to optimize primitive drawing processing of each primitive type and improve overall drawing efficiency.
In an exemplary embodiment, the step S104 draws the primitive to be drawn to which the collected primitive data belongs according to the primitive data set, the drawing order reference value, and the drawing order offset value of the primitive to be drawn to which the collected primitive data belongs, and further includes: adding the drawing order offset value and the drawing order reference value of the drawing primitive to which any collected primitive data belongs to the drawing primitive to which any collected primitive data belongs, so as to obtain the drawing order value of the drawing primitive to which any collected primitive data belongs; and drawing any drawing primitive to which the collected primitive data belongs according to the drawing order value of the primitive.
Illustratively, when drawing primitives, the graphics processor needs to determine the global drawing order for the primitives based on the drawing order reference value and the drawing order offset value. The graphics processor adds the drawing order offset value of each drawing order of the drawing primitive to be drawn and the drawing order reference value of the corresponding drawing primitive data set to obtain the drawing order value of the drawing primitive to be drawn; and then, the graphic processor determines the shielding relation between the primitives according to the primitive drawing order value of the primitives to be drawn and the primitive drawing order value of the drawn primitives, and draws the primitives to be drawn. So that the drawing order between the primitives can be correctly displayed. For example, for the primitives to be drawn of the same target primitive type in the primitive data set, if two primitives to be drawn are consecutive in the collection order, then the graphics processor may correctly draw the consecutive primitives to be drawn directly based on the collection order when drawing the consecutive primitives to be drawn in parallel; if the two primitives to be drawn are not continuous in the collection sequence, after the graphics processor determines the primitive drawing sequence value, the graphics processor can draw the primitives to be drawn of the same target primitive type in parallel, and can determine which pixel of the primitives to be drawn should be drawn on the pixel points where the primitives overlap; then, for the to-be-painted primitive of the subsequent target primitive type, after determining the primitive drawing order value, the graphic processor can determine whether the pixel points where the painted primitive and the to-be-painted primitive overlap should be updated as the pixel of the to-be-painted primitive or the pixel of the reserved painted primitive; the same is true between the drawn primitive data set and the primitive data set to be drawn.
In the embodiment, by calculating the drawing order value of the graphic element, finer control of the drawing order of the graphic element is realized, so that the graphic processor can more flexibly draw different graphic elements and ensure the display accuracy of the drawing order of the whole graphic element.
In an exemplary embodiment, the drawing of the primitive to be drawn to which any collected primitive data belongs according to the primitive drawing order value further includes: according to the primitive drawing depth value standard information of the adopted graphic drawing application programming interface, converting the primitive drawing sequence value into a primitive drawing depth value; and drawing any graphic primitive to be drawn, to which the collected graphic primitive data belongs, according to the graphic primitive drawing depth value by adopting a graphic drawing application programming interface.
The graphics rendering application programming interface (graphics rendering API) is a set of interfaces or kits for accessing computer graphics hardware and software functions. These interfaces allow a user to programmatically create and manipulate graphical images, implementing Graphical User Interfaces (GUIs), drawings, and other graphically-related tasks. For example DirectX, openGL, vulkan, etc.
Illustratively, the graphics processor may employ a graphics rendering application programming interface to render primitives. The graphics processor needs to convert the primitive drawing order value of the primitive to be drawn into a primitive drawing depth value which can be identified by a graphics drawing application programming interface, firstly, the graphics processor determines the adopted graphics drawing application programming interface, and then draws the depth value standard, including value range, precision and the like, of the primitive according to the graphics drawing application programming interface. Then, the graphic processor converts the drawing sequence value of the graphic element to be drawn into a graphic element drawing depth value conforming to the drawing depth value standard of the graphic element through mathematical operation; finally, the graphic processor adopts a graphic drawing application programming interface to draw the drawing element to be drawn according to the drawing depth value of the drawing element.
In this embodiment, the primitive drawing depth value standard of the adopted graphical drawing application programming interface is determined, so that the primitive drawing sequence value is converted into the corresponding primitive drawing depth value, and therefore any graphical drawing application programming interface can be flexibly selected to realize primitive drawing.
In an exemplary embodiment, the CAD drawing method further includes: under the condition that the number of the primitives to be painted of the collected primitive data meets the preset condition, removing the primitives to be painted of the collected primitive data from the primitives to be painted of the CAD, and obtaining updated primitives to be painted; and taking the updated drawing primitive to be used as the drawing primitive of the CAD, and jumping to the step of adopting the central processing unit to collect the primitive data of each drawing primitive according to the drawing sequence of the drawing primitive of the CAD until the collection of the primitive data of the drawing primitive of the CAD is completed.
For example, when the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition, that is, when the primitive data to be integrated currently are determined, the central processing unit integrates the primitive data to be integrated currently to obtain a current primitive data set, and sends the current primitive data set to the graphics processor to complete drawing processing of the primitives to be drawn, to which the primitive data collected in the current primitive data set belong; meanwhile, the CPU eliminates the graphic primitive to be painted, which the collected graphic primitive data belongs to, from the graphic primitive to be painted of the CAD, and obtains updated graphic primitive to be painted; and then taking the updated drawing primitive to be drawn as the drawing primitive of the CAD, jumping to a step of collecting the primitive data of each drawing primitive according to the drawing sequence of the drawing primitive of the CAD by adopting a central processing unit so as to determine the next primitive data set and sending the next primitive data set to a graphic processor to realize drawing processing until the collection of the primitive data of the drawing primitive of the CAD is completed, namely, the primitive data of the drawing primitive of the CAD are integrated into the corresponding primitive data set. It should be noted that, the process of eliminating by the central processor may record the primitive data in the current primitive data set as the collected primitive data, and then determine the remaining primitive to be painted in the CAD as the new primitive to be painted in the CAD, instead of directly deleting the collected primitive data in the CAD file.
In this embodiment, the primitive data sets are integrated by the central processing unit and sent to the graphics processor for rendering, and in the rendering process of the graphics processor, the central processing unit can simultaneously perform the integration of the next primitive data set, so that the advantage of parallel processing is effectively utilized, and the efficiency of the overall rendering process is improved.
In another exemplary embodiment, as shown in fig. 3, the present application also provides another CAD drawing method, which includes the steps of:
Step S301, collecting the primitive data of each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitives to be drawn of the CAD; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0.
In step S302, when the primitive type of the primitive to be drawn to which the currently collected primitive data belongs is different from the primitive type of the primitive to be drawn to which the previously collected primitive data belongs, the drawing order offset value of the primitive to be drawn to which the previously collected primitive data belongs is incremented by 1 as the drawing order offset value of the primitive to be drawn to which the currently collected primitive data belongs.
Step S303, integrating the collected primitive data to obtain a primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belongs, meets the preset condition.
In step S304, in the case where the primitive data set is the first primitive data set, the drawing order reference value of the first primitive data set is determined to be 0.
In step S305, in the case where the primitive data set is not the first primitive data set, the drawing order reference value of the primitive data set is determined as the drawing order total value of the previous primitive data set.
The total drawing order value of the previous primitive data set is the sum of the drawing order reference value of the previous primitive data set and the largest drawing order offset value in the previous primitive data set.
In step S306, a graphics processor is used to obtain the primitive type of the primitive to be drawn, which the first primitive data in the primitive data set belongs to, as the target primitive type.
Step S307, according to the target primitive type, the primitive data of the target primitive to be drawn is screened out from the primitive data set.
The primitive type of the target primitive to be drawn is the target primitive type.
Step S308, for the primitives to be drawn to which any collected primitive data belongs, adding the drawing order offset value and the drawing order reference value of the primitives to be drawn to which any collected primitive data belongs, to obtain the primitive drawing order value of the primitives to be drawn to which any collected primitive data belongs.
Step S309, according to the primitive drawing depth value standard information of the adopted graphic drawing application programming interface, converting the primitive drawing sequence value into a primitive drawing depth value.
Step S310, a central processing unit is adopted to acquire a target drawing instruction corresponding to the target primitive type from a preset drawing instruction library.
Step S311, a graphic processor is adopted to draw a first primitive to be drawn and a target primitive to be drawn according to the primitive drawing depth value and the graphic drawing application programming interface and execute a target drawing instruction.
Step S312, the primitive data of the first primitive to be drawn and the primitive data of the target primitive to be drawn are removed from the primitive data set to obtain a new primitive data set, and the process jumps to step S306 until all the primitives to be drawn, to which the primitive data collected in the primitive data set belong, are drawn.
Illustratively, in step S302, when the primitive is classified, the primitive types such as solid filled primitive, line with line width, arc line, text and the like may be specifically classified.
For example, for the solid filled primitive, the target drawing instruction for the solid filled primitive is obtained in step S310. In the target rendering instruction, the solid filled primitives may be further subdivided based on their primitive complexity: triangle rasterization processing instructions for solid filled primitives of lower complexity (i.e., rasterizing a limited number of triangles to obtain solid filled primitives based on the idea that polygons are partitioned by a limited number of triangles); and a scan line rasterization processing instruction for a solid filling primitive with higher complexity (i.e., based on the idea of line composition planes, a limited number of parallel lines are used to compose the solid filling primitive).
Aiming at line elements with line width, in a target drawing instruction, the connection part between lines can be processed in a round head expansion mode (namely, a semicircular endpoint is used as a line endpoint) or in a rectangular expansion and overlapping region removing mode based on the comparison relation between the length of the line with line width and the rendering precision, so that the overlapping area between lines is reduced, and the influence on the display effect is avoided.
Aiming at the arc line element, in a target drawing instruction, aiming at the display proportion of the arc line under the current visual window, the number of straight line segments required for drawing the arc line is adjusted in real time, and a specific number of straight line segments are drawn so as to realize the display effect of the arc line based on the limited number of straight line segments.
For character graphic elements, the central processor combines the data of each character into display data by taking pixels as units, and when in rasterization, the central processor sends a rendering instruction to the graphic processor once, the graphic processor adopts a target drawing instruction, and for any pixel position of all the character graphic elements, the storage position in the display data is determined through calculation, and the pixel parameters of the corresponding pixels are extracted, so that the drawing of the character graphic elements is realized.
The above examples only represent a few cases, which are described in more detail and are not to be construed as limiting the scope of the application.
In this embodiment, through integrating the primitives to be drawn into a data set, one-time input is provided for subsequent graphic processing, so that the number of times of transmission of primitive data is reduced, and the transmission efficiency is improved, meanwhile, through dynamically determining the drawing order offset value corresponding to the primitives to be drawn, the drawing order accuracy of the graphics processor on each primitive in the same primitive data set is ensured, and on the basis of the drawing order reference value of the primitive data set, the drawing order of the graphics processor on different primitive data sets is ensured, and finally, when the drawing efficiency of CAD is improved, the drawing order accuracy of the graphics processor on the primitives is ensured; in addition, a graphic processor is adopted for drawing, so that the parallel computing capability of the graphic processor is fully exerted, and the drawing efficiency is improved; meanwhile, the parallel cooperative working mode of the central processing unit and the graphic processor can reduce the waiting time between the central processing unit and the graphic processor and improve the overall rendering efficiency.
In an exemplary embodiment, the present application provides a CAD drawing method, as shown in fig. 4, which is a schematic diagram of primitive data processed by a cpu and a gpu in the method. When a GPU (image processor) is employed for rendering display, data needs to be sent from a CPU (central processing unit) to the GPU. Taking a segment of data as an example, a plurality of data segments are included, where each data segment stores primitive data (referred to as GPU data segments for short) corresponding to consecutive primitives of the same primitive type, while each data block stores BaseDrawOrder (i.e., drawing order reference value) of DrawOrder (drawing order), and each data segment stores OffsetDrawOrder (i.e., drawing order offset value) of DrawOrder. After the CPU collects one data block, the data block is sent to the GPU, and then the next data block is collected.
In this embodiment, the process of collecting the data blocks obtained by the cpu and sending the data blocks to the gpu for drawing, as shown in fig. 5, includes:
In step S501, the drawing order offset value is initialized to 0.
Step S502, starting the collection of the primitive data.
In step S503, the primitive data is collected, and whether it is the first primitive data. If yes, jump to step S504; if not, step S506 is skipped.
In step S504, the drawing order offset value is recorded in the vertex data of the new data segment.
In step S505, whether the data block is collected is determined. If yes, jump to step S508; if not, step S503 is skipped.
Step S506, whether the primitive type is the same as the primitive type of the previous data. If yes, jump to step S503; if not, step S507 is skipped.
In step S507, the drawing order offset value is incremented by 1, and the process goes to step S504.
In step S508, the data block is sent to the GPU.
In step S509, the GPU calculates the depth value of the primitive by using the sum of the drawing order reference value and the drawing order offset value, and completes the drawing.
For example, the primitives to be collected are respectively circle a, circle b, rectangle c, circle d according to the drawing order, and are located in the first data block BaseDrawOrder as 0. Then circle a and circle b are data segment 1 and OffsetDrawOrder is 0; rectangle c is data segment 2 and OffsetDrawOrder is 1; rectangle d is data segment 3 and OffsetDrawOrder is 2. When the GPU is used for drawing, firstly, a circle target drawing instruction is adopted, and a circle a, a circle b and a circle d are drawn in parallel; and then drawing a rectangle c by adopting a target drawing instruction of the rectangle. At the time of drawing, drawOrder of each primitive is determined based on the sum of BaseDrawOrder and OffsetDrawOrder to correctly display the contents related to the drawing order. Meanwhile, baseDrawOrder of the second data block is 0+2=2, and the first primitive in the second data block is circle e, offsetDrawOrder is 0. At this time, although both circles d and e are DrawOrder are 2, they are respectively located in different data blocks, and the CPU processes the different data blocks in series, so that the GPU processes the different data blocks in series, and the drawing of circles d and e is performed in series, thereby ensuring the accuracy of the drawing sequence.
In the case where the graphics rendering application programming interface is OpenGL, the range of depth values for OpenGl is 0 to 1 and the precision is 6 bits after the decimal point. Thus, the process of converting DrawOrder to a depth value of OpenGl is: openGl depth value = 1- (DrawOrder) 0.000001. The smaller DrawOrder is ensured, the larger DrawOrder is ensured, the smaller DrawOrder is ensured, and the correct shielding display can be realized through the depth value setting of the programming interface of the graphic drawing application program.
In this embodiment, the original primitive creation sequence or the sequence specified by the user in the CAD two-dimensional mode may be converted into the depth value corresponding to the primitive data, and then the drawing sequence is determined according to the depth value in the efficient drawing process using the GPU, so as to implement efficient and accurate CAD drawing processing.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a CAD drawing device for realizing the CAD drawing method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in one or more embodiments of the CAD drawing device provided below may be referred to above for limitation of the CAD drawing method, which is not repeated here.
In one exemplary embodiment, as shown in fig. 6, there is provided a CAD drawing apparatus comprising: a drawing primitive collection module 601, an order offset value determination module 602, an order reference value determination module 603, and a drawing primitive module 604, wherein:
The drawing primitive collection module 601 is configured to collect primitive data of each drawing primitive according to a drawing sequence of the drawing primitive of the CAD by using a central processing unit; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
The order offset value determining module 602 is configured to increment, as the drawing order offset value of the primitive to be drawn to which the currently collected primitive data belongs, the drawing order offset value of the primitive to be drawn to which the previously collected primitive data belongs by 1 when the primitive type of the primitive to be drawn to which the currently collected primitive data belongs is different from the primitive type of the primitive to be drawn to which the previously collected primitive data belongs;
An order reference value determining module 603, configured to integrate the collected primitive data to obtain a primitive data set, and determine a drawing order reference value of the primitive data set when the number of primitives to be drawn to which the collected primitive data belongs meets a preset condition;
and the drawing module 604 for drawing the primitive to be drawn, which is used for drawing the primitive to be drawn and which is used for collecting the primitive data, according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn and which is used for collecting the primitive data.
In one embodiment, the order reference value determining module 603 is further configured to determine, when the primitive data set is the first primitive data set, a drawing order reference value of the first primitive data set as 0; in the case where the primitive data set is not the first primitive data set, determining a drawing order reference value of the primitive data set as a drawing order total value of the previous primitive data set; the total drawing order value of the previous primitive data set is the sum of the drawing order reference value of the previous primitive data set and the maximum drawing order offset value in the previous primitive data set.
In one embodiment, the drawing module 604 is further configured to obtain, as the target primitive type, a primitive type of the primitive to be drawn to which the first primitive data in the primitive data set belongs; according to the target primitive type, screening out primitive data of the target primitive to be drawn from the primitive data set; the primitive type of the target primitive to be drawn is the target primitive type; drawing a first primitive to be drawn and a target primitive to be drawn according to the drawing order reference value and the drawing order offset value of the primitive to be drawn to which the collected primitive data belong; the first primitive to be drawn is the primitive to be drawn to which the first primitive data belongs; and removing the primitive data of the first primitive to be drawn and the primitive data of the target primitive to be drawn from the primitive data set to obtain a new primitive data set, and jumping to obtain the primitive type of the primitive to be drawn, which belongs to the first primitive data in the primitive data set, as the step of the target primitive type until all the primitives to be drawn, which belong to the primitive data collected in the primitive data set, are drawn.
In one embodiment, the CAD drawing apparatus further includes a drawing instruction determining module configured to acquire, by using a central processing unit, a target drawing instruction corresponding to a target primitive type from a preset drawing instruction library.
In one embodiment, the drawing module 604 is further configured to execute a target drawing instruction by using a graphics processor to draw the first primitive to be drawn and the target primitive to be drawn.
In one embodiment, the drawing module 604 is further configured to add, for the primitive to be drawn to which any collected primitive data belongs, a drawing order offset value and a drawing order reference value of the primitive to be drawn to which any collected primitive data belongs, to obtain a primitive drawing order value of the primitive to be drawn to which any collected primitive data belongs; and drawing any drawing primitive to which the collected primitive data belongs according to the drawing order value of the primitive.
In one embodiment, the primitive drawing module 604 is further configured to convert the primitive drawing order value into a primitive drawing depth value according to primitive drawing depth value standard information of the employed graphics drawing application programming interface; and drawing any graphic primitive to be drawn, to which the collected graphic primitive data belongs, according to the graphic primitive drawing depth value by adopting a graphic drawing application programming interface.
In one embodiment, the above-mentioned primitive to be drawn collecting module 601 is further configured to, in case that the number of primitives to be drawn to which the collected primitive data belongs meets a preset condition, remove the primitives to be drawn to which the collected primitive data belongs from the primitives to be drawn of the CAD, and obtain updated primitives to be drawn; and taking the updated drawing primitive to be used as the drawing primitive of the CAD, and jumping to the step of adopting the central processing unit to collect the primitive data of each drawing primitive according to the drawing sequence of the drawing primitive of the CAD until the collection of the primitive data of the drawing primitive of the CAD is completed.
The various modules in the CAD drawing apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules. The processor comprises a central processing unit and a graphic processor.
In one exemplary embodiment, a computer device is provided, which may be a terminal, and an internal structure diagram thereof may be as shown in fig. 7. The computer apparatus includes a processor (including a central processor and a graphic processor), a memory, an input/output interface, a communication interface, a display unit, and an input device. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a CAD drawing method. The display unit of the computer device is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 7 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one exemplary embodiment, a computer device is provided that includes a memory and a processor, the processor including a central processor and a graphics processor, the memory having stored therein a computer program that when executed performs the steps of:
Collecting each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitives to be drawn of the CAD; wherein, the drawing order offset value corresponding to the first collected drawing primitive to be drawn is 0;
Under the condition that the primitive type of the currently collected primitive to be drawn is different from the primitive type of the previously collected primitive to be drawn, the drawing order offset value of the previously collected primitive to be drawn is increased by 1 to be used as the drawing order offset value of the currently collected primitive to be drawn;
Integrating the collected primitives to be drawn to obtain a primitive data set under the condition that the number of the collected primitives to be drawn reaches a preset number, and determining drawing order reference values of the primitive data set;
And drawing each drawing primitive to be drawn according to the primitive data set, the drawing order reference value and the drawing order offset value of each drawing primitive to be drawn by adopting a graphic processor.
In one embodiment, there is also provided a computer device including a memory and a processor including a central processor and a graphics processor, the memory storing a computer program, the processor implementing the steps of the method embodiments described above when executing the computer program.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
Collecting each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitives to be drawn of the CAD; wherein, the drawing order offset value corresponding to the first collected drawing primitive to be drawn is 0;
Under the condition that the primitive type of the currently collected primitive to be drawn is different from the primitive type of the previously collected primitive to be drawn, the drawing order offset value of the previously collected primitive to be drawn is increased by 1 to be used as the drawing order offset value of the currently collected primitive to be drawn;
Integrating the collected primitives to be drawn to obtain a primitive data set under the condition that the number of the collected primitives to be drawn reaches a preset number, and determining drawing order reference values of the primitive data set;
And drawing each drawing primitive to be drawn according to the primitive data set, the drawing order reference value and the drawing order offset value of each drawing primitive to be drawn by adopting a graphic processor.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon which, when executed by a processor, implements the steps of the method embodiments described above, the processor comprising a central processor and a graphics processor.
In one embodiment, a computer program product is provided comprising a computer program which, when executed by a processor, performs the steps of:
Collecting each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitives to be drawn of the CAD; wherein, the drawing order offset value corresponding to the first collected drawing primitive to be drawn is 0;
Under the condition that the primitive type of the currently collected primitive to be drawn is different from the primitive type of the previously collected primitive to be drawn, the drawing order offset value of the previously collected primitive to be drawn is increased by 1 to be used as the drawing order offset value of the currently collected primitive to be drawn;
Integrating the collected primitives to be drawn to obtain a primitive data set under the condition that the number of the collected primitives to be drawn reaches a preset number, and determining drawing order reference values of the primitive data set;
And drawing each drawing primitive to be drawn according to the primitive data set, the drawing order reference value and the drawing order offset value of each drawing primitive to be drawn by adopting a graphic processor.
In one embodiment, a computer program product is provided comprising a computer program which, when executed by a processor, performs the steps of the method embodiments described above, the processor comprising a central processor and a graphics processor.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are both information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magneto-resistive random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.
Claims (11)
1. A method of CAD drawing, the method comprising:
Collecting the primitive data of each primitive to be drawn by adopting a central processing unit according to the drawing sequence of the primitive to be drawn of CAD; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
when the primitive type of the primitive to be drawn, to which the currently collected primitive data belongs, is different from the primitive type of the primitive to be drawn, to which the previously collected primitive data belongs, increasing the drawing order offset value of the primitive to be drawn, to which the previously collected primitive data belongs, by 1, and taking the drawing order offset value of the primitive to be drawn, to which the currently collected primitive data belongs;
integrating the collected primitive data to obtain a primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition, and determining a drawing order reference value of the primitive data set;
Drawing the primitive to be drawn, to which the collected primitive data belongs, according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn, to which the collected primitive data belongs, by adopting a graphic processor;
And a graphics processor, configured to draw the primitive to be drawn to which the collected primitive data belongs according to the primitive data set, the drawing order reference value, and the drawing order offset value of the primitive to be drawn to which the collected primitive data belongs, where the drawing processor includes:
Acquiring the primitive type of the primitive to be drawn, to which the first primitive data in the primitive data set belongs, as a target primitive type;
According to the target primitive type, screening primitive data of a target primitive to be drawn from the primitive data set; the primitive type of the target primitive to be drawn is the target primitive type;
Drawing a first primitive to be drawn and the target primitive to be drawn according to the drawing order reference value and the drawing order offset value of the primitive to be drawn to which the collected primitive data belong; the first primitive to be drawn is the primitive to be drawn to which the first primitive data belongs;
and removing the primitive data of the first primitive to be drawn and the primitive data of the target primitive to be drawn from the primitive data set to obtain a new primitive data set, and jumping to the step of obtaining the primitive type of the primitive to be drawn, which belongs to the first primitive data in the primitive data set, as the target primitive type until all the primitives to be drawn, which belong to the collected primitive data in the primitive data set, are drawn.
2. The method of claim 1, wherein said determining a drawing order reference value for the primitive dataset comprises:
Determining a drawing order reference value of a first primitive data set as 0 in the case that the primitive data set is the first primitive data set;
Determining a drawing order reference value of the primitive data set as a drawing order total value of a previous primitive data set in the case that the primitive data set is not the first primitive data set; the total drawing order value of the previous primitive data set is the sum of the drawing order reference value of the previous primitive data set and the maximum drawing order offset value of the previous primitive data set.
3. The method of claim 1, wherein prior to drawing the first primitive to be drawn and the target primitive to be drawn, further comprising:
Acquiring a target drawing instruction corresponding to the target primitive type from a preset drawing instruction library by adopting the central processing unit;
the drawing of the first primitive to be drawn and the target primitive to be drawn comprises the following steps:
And executing one target drawing instruction by adopting the graphic processor, and drawing a first primitive to be drawn and the target primitive to be drawn.
4. The method according to claim 1, wherein the drawing the primitive to be drawn to which the collected primitive data belongs according to the primitive data set, the drawing order reference value, and the drawing order offset value of the primitive to be drawn to which the collected primitive data belongs, includes:
adding the drawing order offset value of the drawing primitive to which any collected primitive data belongs and the drawing order reference value to obtain the primitive drawing order value of the drawing primitive to which any collected primitive data belongs;
and drawing the primitives to be drawn, to which any one of the collected primitive data belongs, according to the primitive drawing order value.
5. The method according to claim 4, wherein the drawing the primitive to be drawn to which the any one of the collected primitive data belongs according to the primitive drawing order value includes:
according to the primitive drawing depth value standard information of the adopted graphic drawing application programming interface, converting the primitive drawing sequence value into a primitive drawing depth value;
and drawing the graphics to be drawn to which the any collected primitive data belongs according to the drawing depth value of the primitives by adopting the programming interface of the graphics drawing application program.
6. The method according to any one of claims 1 to 5, further comprising:
Under the condition that the number of the primitives to be painted of the collected primitive data meets a preset condition, removing the primitives to be painted of the collected primitive data from the primitives to be painted of the CAD, and obtaining updated primitives to be painted;
And taking the updated drawing primitive to be drawn as the drawing primitive of the CAD, jumping to the CPU, and collecting the primitive data of each drawing primitive according to the drawing sequence of the drawing primitive of the CAD until the collection of the primitive data of the drawing primitive of the CAD is completed.
7. A CAD drawing apparatus, the apparatus comprising:
The drawing processing module is used for processing the drawing sequence of the drawing primitives to be drawn according to the drawing sequence of the CAD drawing primitives to be drawn by adopting the CPU; wherein, the drawing order offset value corresponding to the drawing primitive to which the first collected primitive data belongs is 0;
The sequence offset value determining module is used for increasing the drawing sequence offset value of the primitive to be drawn, which belongs to the previous collected primitive data, by 1 as the drawing sequence offset value of the primitive to be drawn, which belongs to the current collected primitive data, under the condition that the primitive type of the primitive to be drawn, which belongs to the current collected primitive data, is different from the primitive type of the primitive to be drawn, which belongs to the previous collected primitive data;
The sequence reference value determining module is used for integrating the collected primitive data to obtain a primitive data set and determining a drawing sequence reference value of the primitive data set under the condition that the number of primitives to be drawn, to which the collected primitive data belong, meets a preset condition;
the drawing module of the primitive to be drawn is used for drawing the primitive to be drawn which the collected primitive data belongs to according to the primitive data set, the drawing order reference value and the drawing order offset value of the primitive to be drawn which the collected primitive data belongs to by adopting a graphic processor;
The drawing module of the primitive to be drawn is further configured to obtain a primitive type of the primitive to be drawn, where the first primitive data in the primitive data set belongs to the primitive to be drawn, as a target primitive type; according to the target primitive type, screening primitive data of a target primitive to be drawn from the primitive data set; the primitive type of the target primitive to be drawn is the target primitive type; drawing a first primitive to be drawn and the target primitive to be drawn according to the drawing order reference value and the drawing order offset value of the primitive to be drawn to which the collected primitive data belong; the first primitive to be drawn is the primitive to be drawn to which the first primitive data belongs; and removing the primitive data of the first primitive to be drawn and the primitive data of the target primitive to be drawn from the primitive data set to obtain a new primitive data set, and jumping to the step of obtaining the primitive type of the primitive to be drawn, which belongs to the first primitive data in the primitive data set, as the target primitive type until all the primitives to be drawn, which belong to the collected primitive data in the primitive data set, are drawn.
8. The apparatus according to claim 7, wherein the order reference value determination module is further configured to determine, in the case where the primitive data set is a first primitive data set, a drawing order reference value of the first primitive data set as 0; determining a drawing order reference value of the primitive data set as a drawing order total value of a previous primitive data set in the case that the primitive data set is not the first primitive data set; the total drawing order value of the previous primitive data set is the sum of the drawing order reference value of the previous primitive data set and the maximum drawing order offset value of the previous primitive data set.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 6 when the computer program is executed; the processor includes a central processor and a graphics processor.
10. A computer readable storage medium having stored thereon a computer program, characterized in that the computer program when executed by a processor realizes the steps of the method according to any of claims 1 to 6; the processor includes a central processor and a graphics processor.
11. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the method of any one of claims 1 to 6; the processor includes a central processor and a graphics processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410186783.0A CN117744187B (en) | 2024-02-20 | 2024-02-20 | CAD drawing method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410186783.0A CN117744187B (en) | 2024-02-20 | 2024-02-20 | CAD drawing method, device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN117744187A CN117744187A (en) | 2024-03-22 |
CN117744187B true CN117744187B (en) | 2024-05-14 |
Family
ID=90251228
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410186783.0A Active CN117744187B (en) | 2024-02-20 | 2024-02-20 | CAD drawing method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117744187B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5943061A (en) * | 1994-04-08 | 1999-08-24 | Sony Corporation | Method and apparatus for generating images utilizing a string of draw commands preceded by an offset draw command |
CN111737618A (en) * | 2020-06-24 | 2020-10-02 | 广联达科技股份有限公司 | Vector diagram display method and device for Web end and computer equipment |
CN114066714A (en) * | 2021-01-14 | 2022-02-18 | 腾讯科技(深圳)有限公司 | Batch rendering method, device, equipment and storage medium |
CN116612208A (en) * | 2023-05-30 | 2023-08-18 | 中国航空无线电电子研究所 | A661Widget drawing method based on self-adaptive depth buffer |
CN117392266A (en) * | 2023-11-01 | 2024-01-12 | 西安芯云半导体技术有限公司 | Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium |
-
2024
- 2024-02-20 CN CN202410186783.0A patent/CN117744187B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5943061A (en) * | 1994-04-08 | 1999-08-24 | Sony Corporation | Method and apparatus for generating images utilizing a string of draw commands preceded by an offset draw command |
CN111737618A (en) * | 2020-06-24 | 2020-10-02 | 广联达科技股份有限公司 | Vector diagram display method and device for Web end and computer equipment |
CN114066714A (en) * | 2021-01-14 | 2022-02-18 | 腾讯科技(深圳)有限公司 | Batch rendering method, device, equipment and storage medium |
CN116612208A (en) * | 2023-05-30 | 2023-08-18 | 中国航空无线电电子研究所 | A661Widget drawing method based on self-adaptive depth buffer |
CN117392266A (en) * | 2023-11-01 | 2024-01-12 | 西安芯云半导体技术有限公司 | Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium |
Non-Patent Citations (2)
Title |
---|
A parallel data-structure for modular programming of triangulated computing media;Frédéric Gruau;《Natural Computing》;20220820;第22卷;全文 * |
基于CUDA渲染器的顺序独立透明现象的单遍高效绘制;黄梦成;刘芳;刘学慧;吴恩华;;软件学报;20110815(第08期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN117744187A (en) | 2024-03-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11270497B2 (en) | Object loading method and apparatus, storage medium, and electronic device | |
US20230053462A1 (en) | Image rendering method and apparatus, device, medium, and computer program product | |
CN110990516B (en) | Map data processing method, device and server | |
CN113012269A (en) | Three-dimensional image data rendering method and equipment based on GPU | |
CN110428504B (en) | Text image synthesis method, apparatus, computer device and storage medium | |
CN112233009A (en) | Picture rendering method, device, equipment and storage medium | |
CN115509764A (en) | Real-time rendering multi-GPU parallel scheduling method and device and memory | |
Yue et al. | A function-based linear map symbol building and rendering method using shader language | |
CN114820853A (en) | Vector graphics processing method and device, computer equipment and storage medium | |
CN106485654B (en) | Vector data processing method and device | |
US11978234B2 (en) | Method and apparatus of data compression | |
CN113538623A (en) | Method and device for determining target image, electronic equipment and storage medium | |
CN117744187B (en) | CAD drawing method, device, computer equipment and storage medium | |
KR20160068204A (en) | Data processing method for mesh geometry and computer readable storage medium of recording the same | |
CN116385253B (en) | Primitive drawing method, device, computer equipment and storage medium | |
CN116758206A (en) | Vector data fusion rendering method and device, computer equipment and storage medium | |
CN116883563A (en) | Method, device, computer equipment and storage medium for rendering annotation points | |
US11869123B2 (en) | Anti-aliasing two-dimensional vector graphics using a compressed vertex buffer | |
CN113379814B (en) | Three-dimensional space relation judging method and device | |
CN114020390A (en) | BIM model display method and device, computer equipment and storage medium | |
Masood et al. | A novel method for adaptive terrain rendering using memory-efficient tessellation codes for virtual globes | |
CN117744186B (en) | CAD rasterization method, CAD rasterization device, computer equipment and storage medium | |
CN117576645B (en) | Parking space detection method and device based on BEV visual angle and computer equipment | |
AU2023274149B2 (en) | Method for 3D visualization of sensor data | |
CN114399583B (en) | Three-dimensional model splicing method and device based on geometry |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |