Multi-level revocation recovery method and device of CAD system and storage medium
By building a directed dependency graph in the CAD system and adjusting the operation sequence, the problem that the undo recovery function in the prior art cannot effectively handle complex operation dependencies is solved, and efficient and consistent undo and recovery operations are achieved, which significantly improves system performance and reliability.
Patent Information
- Application Number
- CN202510183506.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-06-13
AI Technical Summary
The undo recovery function in the existing CAD system cannot effectively handle dependencies in complex operations, resulting in inconsistent or unpredictable results during the undo recovery process.
The transaction management module receives user operation instructions, generates an operation set, analyzes the involved geometric objects and their association relationships, and builds a directed dependency graph. Adjust and fill the sequence of operations according to topology to ensure that operations are performed in the correct order.
The efficiency and consistency of undo and recovery operations are achieved, and the inconsistency problem caused by wrong operation sequence in traditional methods is avoided, which significantly improves the performance and reliability of the system.
Smart Images

Figure CN120144237A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer-aided design, and particularly to a multi-level undo and redo method, device, and storage medium for a CAD system. Background Art
[0002] In existing CAD systems, the undo and redo functions are usually implemented through a stack or a linear history. However, as the functions of CAD systems become increasingly complex, the geometric objects, parameters, constraint conditions, etc. involved in the operation history are also more complex. The traditional command-mode Undo-Redo operations often cannot effectively handle these dependencies, resulting in inconsistent or unpredictable results during the undo and redo processes, including operation omissions, cross-module inconsistencies, and lack of dependency management, etc. Summary of the Invention
[0003] This application provides a multi-level undo and redo method, device, and storage medium for a CAD system, which can ensure the efficiency and consistency of undo and redo operations, and significantly improve the performance and reliability of the system.
[0004] On the one hand, this application provides a multi-level undo and redo method for a CAD system, and the method includes:
[0005] Receiving a user operation instruction through a transaction management module and generating a corresponding operation set, the operation set containing multiple atomic operation units;
[0006] Analyzing the geometric objects involved in the operation set and their association relationships, and constructing a directed dependency graph with geometric objects as nodes and object inter-dependency relationships as edges;
[0007] According to the topological structure of the directed dependency graph, adjusting the order of the atomic operation units in the operation set and filling in operations to generate an operation sequence that conforms to the dependency constraints;
[0008] When performing an undo or redo operation, executing the atomic operation units in the operation sequence in reverse topological order or forward topological order.
[0009] On the other hand, this application provides a multi-level undo and redo device for a CAD system, and the device includes:
[0010] A transaction management module, configured to receive a user operation instruction and generate a corresponding operation set, the operation set containing multiple atomic operation units;
[0011] A construction module, configured to analyze the geometric objects involved in the operation set and their association relationships, and construct a directed dependency graph with geometric objects as nodes and object inter-dependency relationships as edges;
[0012] A generation module, configured to sequentially adjust and operation-fill atomic operation units in the operation set according to the topological structure of the directed dependency graph, and generate an operation sequence that conforms to dependency constraints;
[0013] An execution module, configured to execute atomic operation units in the operation sequence in a reverse topological order or a forward topological order when performing an undo or redo operation.
[0014] In a third aspect, the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the technical solution of the multi-level undo / redo method of the CAD system as described above are implemented.
[0015] In a fourth aspect, the present application provides a storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the technical solution of the multi-level undo / redo method of the CAD system as described above are implemented.
[0016] As can be seen from the technical solutions provided by the present application above, on the one hand, by parsing geometric objects involved in the operation set and their association relationships, and constructing a directed dependency graph with geometric objects as nodes and object dependency relationships as edges, the dependency relationships between operations can be precisely managed and controlled, ensuring the efficiency and consistency of undo and redo operations; on the other hand, according to the topological structure of the directed dependency graph, the atomic operation units in the operation set are sequentially adjusted and operation-filled to generate an operation sequence that conforms to dependency constraints. When performing an undo or redo operation, the atomic operation units in the operation sequence are executed in a reverse topological order or a forward topological order, which can ensure that operations are executed in the correct order and avoid the inconsistency problems caused by incorrect operation orders in traditional methods. In other words, the technical solution of the present application solves the problems of inaccurate and inefficient undo / redo functions in existing CAD systems, especially when dealing with multi-level operations, and can significantly improve the performance and reliability of the system. Description of the Drawings
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0018] Figure 1 It is a flowchart of the multi-level undo / redo method of the CAD system provided by the embodiment of the present application;
[0019] Figure 2It is a schematic structural diagram of a multi-level undo / redo device of a CAD system provided by an embodiment of the present application;
[0020] Figure 3 It is a schematic structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0021] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0022] In this specification, adjectives such as first and second can only be used to distinguish one element or action from another element or action, and do not necessarily require or imply any actual such relationship or order. Where circumstances permit, reference elements or components or steps (etc.) should not be construed as limited to only one of the elements, components, or steps, but can be one or more of the elements, components, or steps, etc.
[0023] In this specification, for the convenience of description, the dimensions of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0024] In existing CAD systems, the undo and redo functions are usually implemented by means of a stack or a linear history. However, as the functions of CAD systems become increasingly complex, the geometric objects, parameters, constraint conditions, etc. involved in the operation history are also becoming more and more complex. The Undo-Redo operations based on the traditional command mode often cannot effectively handle these dependencies, resulting in inconsistent or unpredictable results during the undo / redo process, including operation omissions, cross-module inconsistencies, and lack of dependency management, etc. Among them, operation omission is manifested as when deleting a geometric body with associated constraints, the system only executes the main deletion command, resulting in residual invalid constraints; cross-module inconsistency is manifested as when the modification of an assembly involves the cooperation of multiple modules, it is impossible to ensure the atomic submission of operations; and lack of dependency management is manifested as not considering the topological dependency relationship between geometric objects, resulting in an incorrect undo order.
[0025] In view of the above problems in the prior art, the present application proposes a multi-level undo / redo method for a CAD system, and its flowchart is as shown in the appendix Figure 1 shown, mainly including steps S101 to S104, which are described in detail as follows:
[0026] Step S101: Receive a user operation instruction through a transaction management module and generate a corresponding operation set, where the operation set contains multiple atomic operation units.
[0027] Here, several concepts such as operation (operation, op), operation set (operationSet, ops), object (object, obj) and operation set list (opsList) are first explained. In the embodiment of the present application, operation refers to an atomic operation at the engine level in the CAD system, such as creating a circle, deleting a circle or creating a block, etc.; operations can be divided into three categories, namely, creation operation (CreateOp), modification operation (ModifyOp) and deletion operation (DelOp), etc. The operation set is a container for managing operations, which is composed of multiple operations in sequence, namely ops = {op1, op2, op3, ...}. A user-level operation may trigger multiple software-level operations, which together constitute an operation set. Object refers to the object being operated. Each operation holds an object, indicating an operation on the object. The operation set list is a list container for managing operation sets, namely opsList = {ops1, ops2, ops3, ...}, which records the user's operations for subsequent undo (Undo) and redo (Redo).
[0028] When a user performs an operation in the CAD system, the transaction management module first receives the user's operation instructions. Assume that the user performs a series of modification operations on geometric objects (such as rectangles, circles, etc.), such as scaling, translation, and rotation. The transaction management module will decompose these operations into multiple atomic operation units, each of which represents a specific operation type, including creation operations, modification operations, or deletion operations. The creation operation contains the initialization parameters and parent object references of the geometric object, the modification operation records the differential data before and after the parameter modification, and the deletion operation carries the object dependency release instruction. For example, "translate rectangle (a, b)" or "rotate circle (45 degrees)" is a modification operation.
[0029] It should be noted that the atomic operation units in the above embodiments are atomic operation units because these operation units are the smallest indivisible basic operation units, so as to ensure the traceability and consistency of each operation. For example, when a user performs the operation of "moving a rectangle", the transaction management module will decompose the operation into multiple atomic operation units, such as "saving the current state of the rectangle", "calculating the new position of the rectangle", "updating the position information of the rectangle", and so on. Each atomic operation unit may include a creation operation, a modification operation and / or a deletion operation, wherein the creation operation contains the initialization parameters and parent object references of the geometric object, the modification operation records the differential data before and after the parameter modification, and the deletion operation carries the object dependency release instruction. Each type of operation contained in the atomic operation unit implements a reversible execution interface and supports the symmetric conversion of forward execution and reverse compensation. The implementation of these reversible execution interfaces can be to configure the corresponding deletion inverse operation for the creation operation and carry the original creation parameters, generate parameter substitution operations for the modification operation and save the state comparison table before and after the modification, and retain the object serialization data for the deletion operation and record the dependency release path, and so on. Specifically, for creation operations, forward execution is to generate a new geometric object based on the parameter set and create a corresponding node in the dependency graph, while reverse compensation is to delete the geometric object and remove the relevant nodes and associated edges from the dependency graph, while retaining the original parameters for recovery. For modification operations, forward execution is to update the target parameter from the old value to the new value, record the comparison table of the new and old values, while reverse compensation is to restore the parameter from the new value to the old value, and the comparison table entries are used as the basis for rollback. For deletion operations, forward execution is to remove the geometric object and release its dependencies, serialize and store the complete data of the object, while reverse compensation is to rebuild the object from the serialized data and restore the original dependency network.
[0030] Specifically, receiving the user operation instruction through the transaction management module and generating the corresponding operation set can be implemented through steps S1011 to S1013, as described below:
[0031] Step S1011: Identify geometric objects involved in user operations.
[0032] The transaction management module first identifies the geometric object involved in the user operation. For example, if the user instruction is "move rectangle", the geometric object of the operation is "rectangle".
[0033] Step S1012: Disassemble the operation type in the user operation corresponding to the geometric object.
[0034] Decompose complex operations into several basic operations. For example, "moving a rectangle" may include multiple operation units such as "saving the original position of the rectangle", "calculating the new position of the rectangle", and "updating the coordinates of the rectangle".
[0035] Step S1013: Construct an operation set according to the operation type.
[0036] After analyzing all the basic operations, an operation set is generated, which contains multiple atomic operation units.
[0037] Step S102: Parse the geometric objects involved in the operation set and their association relationships, and construct a directed dependency graph with geometric objects as nodes and the dependency relationships between objects as edges.
[0038] The system parses all the geometric objects in the operation set and their association relationships. The parsing process first identifies all the geometric objects involved (such as points, lines, planes, etc.) and the constraint relationships between them. For example, the operations of some geometric objects may affect other objects (such as size changes or position changes), and this kind of influence relationship is the dependency relationship. Based on these dependency relationships, the system constructs a directed graph, where each geometric object is a node in the graph, and the dependency relationships between operations are represented as edges in the graph. The structure of this dependency graph network provides a basis for subsequent operation order adjustment and undo / redo. For example, if the position of a rectangle depends on the position of another circle, then in the dependency graph, there will be a directed edge between the rectangle and the circle, indicating that the position change of the rectangle depends on the change of the circle. This kind of dependency relationship will help the system determine which operations can be undone or redone in subsequent steps.
[0039] Specifically, as an embodiment of the present application, parsing the geometric objects involved in the operation set and their association relationships, and constructing a directed dependency graph with geometric objects as nodes and the dependency relationships between objects as edges can be implemented through steps S1021 to S1023, and the details are as follows:
[0040] Step S1021: Identify the explicit constraint relationships, implicit association relationships, and spatial adjacency constraint relationships between geometric objects.
[0041] In the CAD field, the explicit constraint relationships between geometric objects are relationships explicitly set by users or the system, including feature parent-child relationships, etc. For example, the angle, distance, parallel or perpendicular relationships between certain two geometric objects. These explicit constraint relationships are usually set through user input or system settings. The implicit association relationships between geometric objects are automatically deduced from the spatial relationships between geometric objects, including parameter inheritance relationships automatically generated by the system, etc. For example, adjacent geometric objects may implicitly form a certain constraint due to their spatial position relationships. The spatial adjacency constraint relationships between geometric objects refer to the relative position relationships between adjacent geometric objects in geometric space, including topological connection relationships, face contact relationships, etc. For example, when the positions of two rectangular objects are close or their edges are in contact, the system can define this adjacency relationship as a spatial adjacency constraint. It should be noted that spatial adjacency constraints can sometimes be regarded as a special type of implicit association relationship, especially when they are automatically deduced from the geometric positions or spatial contact relationships of objects. For example, when two geometric objects are close or intersect, the system can automatically establish an adjacency constraint. Such constraints are usually not explicitly defined by users but are deduced based on spatial relationships. However, in some cases, spatial adjacency constraints can also be defined as explicit constraint relationships, especially when explicitly required by users or the system to consider spatial adjacency. For example, a user may explicitly require that two geometric objects be "adjacent", even if they do not completely contact, and the system may define it as an explicit constraint relationship.
[0042] Step S1022: Construct a directed dependency graph by mapping the explicit constraint relationship, implicit association relationship, and spatial adjacency constraint relationship to a parent-child dependency edge, a virtual dependency edge, and a sibling dependency edge, respectively.
[0043] As mentioned above, the explicit constraint relationship between geometric objects can be a constraint relationship actively created by the user through a graphical interface. For example, when adding a radius numerical constraint to a ring, the system establishes an explicit parent-child dependency relationship between the ring object and the radius constraint object, and thus maps this explicit parent-child dependency relationship to a parent-child dependency edge. The implicit association relationship between geometric objects can be an association relationship automatically generated by the system according to the modeling logic. For example, the position association relationship between the center of the bottom surface and the axis of the cylinder automatically generated when creating a cylinder, and maps this implicit association relationship to a virtual dependency edge. The spatial adjacency constraint relationship between geometric objects can be a topological connection relationship between geometric objects. For example, when two cubes are in coplanar contact, the system maps this spatial adjacency constraint relationship between their corresponding face objects to a sibling dependency edge.
[0044] Step S1023: Record the impact of the deletion operation on the association relationships between geometric objects and dynamically update the directed dependency graph.
[0045] In the embodiments of the present application, the deletion operation may be: traversing all child nodes that depend on the currently deleted object along the edge direction of the directed dependency graph; generating corresponding deletion precursor constraint operation units for each child node that depends on the currently deleted object; and inserting the deletion precursor constraint operation units into the main deletion operation in topological sort order.
[0046] In the embodiments of the present application, when a user deletes a geometric object, the system marks the relationship between the object and other dependent objects in the directed dependency graph and automatically updates the dependency edges in the directed dependency graph. While recording the deleted object, the system recalculates the affected nodes in the directed dependency graph; the deletion operation directly affects other operations that depend on the deleted object. To achieve dynamic maintenance, the system needs to ensure that the deletion operation can automatically update the directed dependency graph to prevent the operations on the already deleted object from continuing to execute. After deleting the object, the system uses a dynamic update algorithm, such as an event-driven update mechanism, to repair the dependency relationship, ensuring that the execution order of all related operations is adjusted to avoid operation failures. Specifically, recording the impact of the deletion operation on the association relationship between geometric objects, the dynamic update of the directed dependency graph may be: the directed dependency graph engine traverses all the out-direction dependency edges of the object on which the deletion operation is performed, that is, the deleted object, to identify the affected child nodes and sibling nodes; for the child nodes that have an explicit constraint relationship (such as radius constraint) with the deleted object, generating corresponding constraint release operation units, and for the sibling nodes that have a spatial adjacency constraint relationship (such as tangent circles) with the deleted object, updating their adjacency status to "isolated"; recording the type, start node, and end node information of the deleted edges in the dependency relationship change log. Taking the radius constraint CON1 (R1→CON1) manually added by the user, the concentric relationship (O1→R1) between the center O1 automatically generated by the system and the circle R1, and the tangent relationship between the circle R1 and the circle R2 as an example, when deleting the circle R1, the directed dependency graph engine traverses all the child nodes (CON1) and sibling nodes (R2) along the dependency edges of R1, and then performs a constraint release operation on CON1 to release the dependency edge of R1→CON1, updates the spatial adjacency status of R2 to release the dependency edge, and at the same time, records the information of the dependency edge in the dependency relationship change log.
[0047] Step S103: According to the topological structure of the directed dependency graph, adjust the order of the atomic operation units in the operation set and fill in the operations to generate an operation sequence that conforms to the dependency constraints.
[0048] In a directed dependency graph, nodes represent atomic operation units and edges represent dependency relationships. Order adjustment is based on the topological sorting of the directed dependency graph to determine the execution order of operations. Topological sorting automatically ensures that the prerequisite conditions on which the operation units depend are executed first. For example, if operation A depends on the result of operation B, the system will ensure that operation B is executed before operation A. After order adjustment, there may be some dependency relationships between operation units that are not fully defined. At this time, "operation filling" is required. The goal of operation filling is to fill all possible gaps to ensure that all dependencies before each operation unit are satisfied. Taking the example of deleting a bolt part in an assembly, the operation filling is to perform the following operations: identify the mating constraint relationship between the bolt and the nut, and generate an atomic operation unit of "release mating constraint"; detect the attachment relationship of the bolt hole, and generate an atomic operation unit of "update hole feature parameters"; the finally generated operation sequence is in order: [release mating constraint] → [update hole feature] → [delete bolt].
[0049] As an embodiment of the present application, according to the topological structure of the directed dependency graph, the order adjustment and operation filling of the atomic operation units in the operation set are performed, and the operation sequence that meets the dependency constraints can be realized through steps S1031 to S1033, which are described in detail as follows:
[0050] Step S1031: According to the topological structure of the directed dependency graph, perform forward topological sorting on the creation-type operation set in the operation set, so that the parent object operation precedes the child object operation, and perform reverse topological sorting on the deletion-type operation set in the operation set, so that the child object operation precedes the parent object operation.
[0051] Step S1032: According to the predecessor nodes of the core atomic operation unit in the directed dependency graph, insert the constraint operation units before the core atomic operation unit in topological order.
[0052] In an embodiment of the present application, the core atomic operation unit is a subset of the atomic operation unit, specifically referring to the core operations in the current operation set that are directly initiated by the user and need to be executed with priority. For example, when modifying the height of a cylinder, the "modify height parameter operation" directly executed by the user is the core atomic operation unit. The constraint operation unit includes the establishment, update or release of constraint relationships, and so on. The topological order can be the forward topological sorting or reverse topological sorting of the aforementioned embodiment. Taking the example of a user creating a circle with a radius constraint in the sketch module, the following geometric objects are involved: the center of the parent object (O1), the ring of the child object (R1), and the radius constraint of the grandchild object (CON1). The dependencies of these geometric objects are as follows: O1→R1 (the ring depends on the center position), R1→CON1 (the constraint depends on the ring radius). When the user triggers the creation operation of "Create a circle with constraints", the system automatically generates three atomic operation units: [CreateOp(O1), CreateOp(R1), CreateOp(CON1)]. At this time, they are sorted in the dependency direction: parent node (O1) → child node (R1) → grandchild node (CON1), and the generated operation sequence is: [CreateOp(O1)] → [CreateOp(R1)] → [CreateOp(CON1)].
[0053] Let's take the case where the user deletes the circle created in the above example. In this case, the dependency O1←R1←CON1 needs to be released. When the user triggers the "delete circle" operation, the system generates the initial operation unit: [DelOp(O1)]. Sort in reverse order of dependency: grandchild node (CON1) → child node (R1) → parent node (O1). The associated deletion operation is automatically inserted, and the operation sequence is finally formed: [DelOp(CON1)] → [DelOp(R1)] → [DelOp(O1)].
[0054] Step S1033: for the modification operation set in the operation set, the sequence adjustment and operation filling are performed synchronously, so that all constraint update operations that depend on the current parameter modification are executed before the core parameter modification operation.
[0055] In the above embodiments, the sequence adjustment includes a forward operation sequence and a reverse operation sequence. Among them, the forward operation sequence is arranged in the forward order of the topological sorting result to ensure that the creation of the parent object precedes the creation of the child object (for example, creating a cylinder first and then generating surface texture), while the reverse operation sequence is arranged in the reverse order of the topological sorting result to ensure that the deletion of the child object precedes the deletion of the parent object (for example, removing the surface texture first and then deleting the cylinder). In the embodiments of the present application, the core parameter modification operation is a specific type of the core atomic operation unit, specifically referring to the operation that directly affects the core parameters of the geometric object in the modification operation set, such as modifying the height, radius, etc. of the cylinder. Different from the creation operation set or the deletion operation set, which generate an operation sequence that conforms to the dependency constraint only after performing sequence adjustment and then operation filling, for the modification operation set in the operation set, it is necessary to synchronously execute the sequence adjustment and the operation filling to avoid the problem of inconsistent intermediate states caused by "modifying parameters first and then supplementing constraints" in the traditional method. For example, when modifying the height of the cylinder, it is necessary to adjust the operation sequence (for example, updating the constraint first) and perform the operation filling (for example, updating the end face constraint) at the same time. If the parameter is directly modified while ignoring the constraint update, it will result in inconsistent constraint relationships and parameter values. For example, after modifying the height of the cylinder, if the end face constraint is not updated first, it may cause geometric contradictions.
[0056] Step S104: When performing the undo or redo operation, execute the atomic operation units in the operation sequence in the reverse topological order or the forward topological order.
[0057] In the embodiments of the present application, the purpose of the Undo operation is to undo the previously executed operations, that is, to gradually return from the current state to the initial state without destroying the state of the system or the dependency relationships of other operations. Therefore, the Undo operation needs to be executed in reverse topological order, that is, starting from the last executed operation and gradually backtracking to the earliest executed operation. If an operation that does not depend on other operations is undone first, the order of undoing will break the preconditions of other operations. Suppose there is a dependency relationship among three operations as follows: operation C depends on operation B, operation B depends on operation A, and the operation order is operation A → operation B → operation C. When performing the Undo operation, it must be ensured that the undo order conforms to the dependency relationship among the operations, that is, first undo operation C because operation C depends on operation B (if B is undone first and then C, the dependency of operation C may be destroyed when B is undone); after undoing operation C, then undo operation B because operation B depends on operation A; finally, undo operation A. This order is the reverse topological sorting, ensuring that the undone operations do not break the dependency relationships of the already undone operations. The purpose of the Redo operation is to restore the previously undone operations. The Redo operation will re-execute those undone operations to restore the system to the state before the undo. When performing the Redo operation, the operations need to be re-executed in the original order, so forward topological sorting is required. The Redo operation must be re-executed in the original order to ensure that when each operation is restored, the operations it depends on have been executed. For example, if operation C depends on operation B and operation B depends on operation A, then the Redo order of operations A, B, and C should be the same as the original execution order. If the operations are restored in reverse order, it may result in the dependency relationships of the operations not being satisfied, and thus the correct state cannot be restored. Suppose operations A → operation B → operation C were previously undone, and now the Redo operation is to be performed. Then first restore operation A, as operation A is the precondition for operations B and C; then restore operation B, as operation B is the precondition for operation C; finally, restore operation C. This order is the forward topological sorting, ensuring that the prerequisite operations for each Redo operation have been restored.
[0058] The transaction management module mentioned in the foregoing embodiments also performs the following operations: maintaining an operation stack to record the operation sequence; setting a transaction isolation level to control the scope of influence of concurrent operations; when performing operation rollback, adopting a compensation operation mechanism to restore the system state, where the compensation operation mechanism includes a dual recovery strategy of object state snapshots and incremental logs. The specific implementation of the compensation operation mechanism in the above embodiments may be: before the execution of an atomic operation unit, creating a serialized snapshot of the affected geometric object; recording the incremental modification logs generated during the operation execution; when rolling back, preferentially executing the incremental logs in reverse, and switching to the snapshot recovery mode when detecting a broken dependency relationship. The compensation operation mechanism in the above embodiments enables the automatic generation of corrective operations and compensation when the operation execution fails. For example, if the undo operation cannot fully restore to the previous state, by automatically compensating for some operations, the atomicity and consistency of the operation are ensured.
[0059] It should be noted that the above embodiments may also include the processing of composite operations, that is, the above embodiments further include steps S1051 to S1053, which are described in detail as follows:
[0060] Step S1051: When detecting a composite operation involving multiple functional modules, decompose the composite operation into multiple sub-operation sets.
[0061] A composite operation refers to several operations of multiple functional modules on the same object. For example, multiple functional modules simultaneously modify the geometric constraints and assembly constraints of the same part. In the embodiments claimed, by parsing the feature codes of the operation instructions, the types of functional modules involved can be identified (such as part modeling module, assembly constraint module), and according to the predefined module association rules, the set of modules that need to coordinate operations can be determined, so as to detect composite operations involving multiple functional modules. When detecting an operation involving multiple functional modules, the system will decompose it into multiple sub-operation sets. For example, in a CAD system, a composite operation may be associated with multiple modules, such as geometric operations, view operations, graphic rendering, etc. The system decomposes these operations into different sub-operation sets and assigns independent execution threads to each sub-operation set.
[0062] Step S1052: Establish an inter-module message channel for each sub-operation set.
[0063] Each sub-operation set communicates through the inter-module message channel. The message channel ensures that information can be transmitted between modules, coordinates the execution of operations, and prevents operation conflicts.
[0064] Step S1053: Ensure the atomic commit of cross-module operations of multiple functional modules through a transaction coordinator.
[0065] Specifically, the transaction coordinator ensures the atomic commit of cross-module operations of multiple functional modules through a two-phase commit protocol. The two-phase commit protocol includes a pre-commit phase and a formal commit phase. In the pre-commit phase, the feasibility of operations is verified for each of the multiple functional modules, and the module preparation status is collected; when all functional modules return ready, the formal commit phase is entered to initiate a formal commit instruction; when any of the multiple functional modules returns an exception, a global rollback process is triggered.
[0066] It should be noted that the rollback process of the above-mentioned embodiment includes the reverse release operation of cross-module dependency. In order to ensure that each atomic operation unit can be executed correctly, the system will verify before each operation is executed to ensure that the execution of the atomic operation unit will not violate the constraint relationship in the directed dependency graph. If the system encounters an exception (such as dependency conflict, data consistency problem, etc.) when executing the operation, the rollback mechanism will be triggered to cancel all executed operations and restore to the state before the operation starts. For example, if a conflict occurs between the dependency of a certain atomic operation unit and another atomic operation unit during the cancellation operation, the system will immediately roll back the operation and restore to the stable state before the cancellation. The system uses incremental logs to record the execution status of each atomic operation unit so that it can be quickly restored when problems arise.
[0067] From the above attached Figure 1 It can be seen from the multi-level undo and restore method of the CAD system of the example that, on the one hand, by parsing the geometric objects involved in the operation set and their associations, a directed dependency graph with geometric objects as nodes and dependencies between objects as edges is constructed, which can accurately manage and control the dependencies between operations, and ensure the efficiency and consistency of undo and restore operations; on the other hand, according to the topological structure of the directed dependency graph, the atomic operation units in the operation set are adjusted in sequence and filled in with operations to generate an operation sequence that meets the dependency constraints. When performing undo or restore operations, the atomic operation units in the operation sequence are executed in the reverse topological order or the forward topological order, which can ensure that the operations are performed in the correct order, and avoid the inconsistency problem caused by the wrong operation order in the traditional method. In other words, the technical solution of the present application solves the problem of inaccurate and inefficient undo and restore functions in existing CAD systems, especially when dealing with multi-level operations, and can significantly improve the performance and reliability of the system.
[0068] Please refer to the attached Figure 2 , is a multi-level undo and restore device for a CAD system provided in an embodiment of the present application, the device may include a transaction management module 201, a construction module 202, a generation module 203 and an execution module 204, which are described in detail as follows:
[0069] The transaction management module 201 is used to receive user operation instructions and generate corresponding operation sets, wherein the operation set includes multiple atomic operation units;
[0070] A construction module 202 is used to parse the geometric objects and their associations involved in the operation set, and construct a directed dependency graph with the geometric objects as nodes and the dependencies between the objects as edges;
[0071] A generation module 203 is used to adjust the order and fill the operation of the atomic operation units in the operation set according to the topological structure of the directed dependency graph, and generate an operation sequence that meets the dependency constraints;
[0072] The execution module 204 is used to execute the atomic operation units in the operation sequence according to the reverse topological order or the forward topological order when performing the undo or restore operation.
[0073] From the above attached Figure 2 It can be seen from the multi-level undo and restore device of the example CAD system that, on the one hand, by parsing the geometric objects involved in the operation set and their associations, a directed dependency graph with geometric objects as nodes and dependencies between objects as edges is constructed, which can accurately manage and control the dependencies between operations and ensure the efficiency and consistency of undo and restore operations; on the other hand, according to the topological structure of the directed dependency graph, the atomic operation units in the operation set are adjusted in sequence and filled in with operations to generate an operation sequence that meets the dependency constraints. When performing undo or restore operations, the atomic operation units in the operation sequence are executed in the reverse topological order or the forward topological order, which can ensure that the operations are performed in the correct order and avoid the inconsistency problem caused by the wrong operation order in the traditional method. In other words, the technical solution of the present application solves the problem of inaccurate and inefficient undo and restore functions in existing CAD systems, especially when dealing with multi-level operations, which can significantly improve the performance and reliability of the system.
[0074] Optionally, the multi-level undo and restore device of the CAD system in the above example may further include a decomposition module, a channel establishment module and a submission module, wherein:
[0075] A decomposition module, used for decomposing the composite operation into multiple sub-operation sets when a composite operation involving multiple functional modules is detected;
[0076] A channel establishment module is used to establish an inter-module message channel for each sub-operation set;
[0077] The commit module is used to ensure the atomic commit of cross-module operations of multiple functional modules through the transaction coordinator.
[0078] Figure 3 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 3As shown, the electronic device 3 of this embodiment mainly includes: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30, such as a program for the multi-level undo and redo method of a CAD system. When the processor 30 executes the computer program 32, the steps in the above-described embodiment of the multi-level undo and redo method of the CAD system are implemented, such as Figure 1 the steps S101 to S104 shown. Alternatively, when the processor 30 executes the computer program 32, the functions of each module / unit in the above-described device embodiments are implemented, such as Figure 2 the functions of the transaction management module 201, the construction module 202, the generation module 203, and the execution module 204 shown.
[0079] Exemplarily, the computer program 32 of the multi-level undo and redo method of the CAD system mainly includes: receiving a user operation instruction through the transaction management module and generating a corresponding operation set, where the operation set contains multiple atomic operation units; parsing the geometric objects involved in the operation set and their association relationships, and constructing a directed dependency graph with geometric objects as nodes and object-dependent relationships as edges; according to the topological structure of the directed dependency graph, adjusting the order of the atomic operation units in the operation set and filling in operations to generate an operation sequence that conforms to the dependency constraints; when performing an undo or redo operation, executing the atomic operation units in the operation sequence in reverse topological order or forward topological order. The computer program 32 can be divided into one or more modules / units. One or more modules / units are stored in the memory 31 and executed by the processor 30 to complete this application. One or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program 32 in the electronic device 3. For example, the computer program 32 can be divided into the functions of the transaction management module 201, the construction module 202, the generation module 203, and the execution module 204 (modules in the virtual device). The specific functions of each module are as follows: The transaction management module 201 is used to receive a user operation instruction and generate a corresponding operation set, where the operation set contains multiple atomic operation units; the construction module 202 is used to parse the geometric objects involved in the operation set and their association relationships, and construct a directed dependency graph with geometric objects as nodes and object-dependent relationships as edges; the generation module 203 is used to adjust the order of the atomic operation units in the operation set and fill in operations according to the topological structure of the directed dependency graph to generate an operation sequence that conforms to the dependency constraints; the execution module 204 is used to execute the atomic operation units in the operation sequence in reverse topological order or forward topological order when performing an undo or redo operation.
[0080] The electronic device 3 may include but is not limited to the processor 30 and the memory 31. Those skilled in the art can understand that Figure 3This is only an example of the electronic device 3, which does not constitute a limitation on the electronic device 3. It may include more or fewer components than those shown in the figure, or combine some components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0081] The so-called processor 30 may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor, etc.
[0082] The memory 31 may be an internal storage unit of the electronic device 3, such as the hard disk or memory of the electronic device 3. The memory 31 may also be an external storage device of the electronic device 3, such as a plug-in hard disk equipped on the electronic device 3, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 31 may also include both an internal storage unit and an external storage device of the electronic device 3. The memory 31 is used to store computer programs and other programs and data required by the electronic device. The memory 31 may also be used to temporarily store data that has been output or is to be output.
[0083] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present application. The specific working processes of the units and modules in the above device can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0084] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0085] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0086] In the embodiments provided in this application, it should be understood that the disclosed device / equipment and method can be implemented in other ways. For example, the device / equipment embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the device or unit can be in electrical, mechanical or other forms.
[0087] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0088] In addition, the functional units in the various embodiments of this application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0089] When an integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of this application, it can also be completed by instructing relevant hardware through a computer program. The computer program of the multi-level undo / redo method for a CAD system can be stored in a storage medium. When the computer program is executed by a processor, it can implement the steps of each of the above method embodiments, that is, receive a user operation instruction through a transaction management module and generate a corresponding operation set, where the operation set includes multiple atomic operation units; analyze the geometric objects involved in the operation set and their association relationships, and construct a directed dependency graph with geometric objects as nodes and the object dependency relationships as edges; according to the topological structure of the directed dependency graph, adjust the order of the atomic operation units in the operation set and perform operation filling to generate an operation sequence that conforms to the dependency constraints; when performing an undo or redo operation, execute the atomic operation units in the operation sequence in reverse topological order or forward topological order. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The storage medium can include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice within the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the storage medium does not include electrical carrier signals and telecommunication signals.
[0090] The above embodiments are only used to illustrate the technical solutions of this application, rather than to limit it; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of each embodiment of this application, and should all be included within the protection scope of this application. The specific implementation manners described above have further elaborated on the purpose, technical solutions, and beneficial effects of this application. It should be understood that the above is only the specific implementation manners of this application, and is not used to limit the protection scope of this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this application should all be included within the protection scope of this invention.
Claims
1. A multi-level undo and restore method for a CAD system, characterized in that: The method comprises: Receive user operation instructions through the transaction management module and generate a corresponding operation set, wherein the operation set includes multiple atomic operation units; Parsing the geometric objects and their association relationships involved in the operation set, and constructing a directed dependency graph with the geometric objects as nodes and the dependencies between the objects as edges; According to the topological structure of the directed dependency graph, the atomic operation units in the operation set are sequentially adjusted and filled with operations to generate an operation sequence that meets the dependency constraints; When performing an undo or redo operation, the atomic operation units in the operation sequence are executed in a reverse topological order or a forward topological order.
2. The multi-level undo and restore method of the CAD system as claimed in claim 1, characterized in that: The step of parsing the geometric objects and their associations involved in the operation set and constructing a directed dependency graph with the geometric objects as nodes and the dependencies between the objects as edges specifically includes: Identifying explicit constraint relationships, implicit association relationships, and spatial adjacency constraint relationships between the geometric objects; The directed dependency graph is constructed by mapping the explicit constraint relationship, the implicit association relationship and the spatial adjacency constraint relationship into parent-child dependency edges, virtual dependency edges and sibling dependency edges respectively; The influence of the deletion operation on the association relationship between the geometric objects is recorded, and the directed dependency graph is dynamically updated.
3. The multi-level undo and restore method of the CAD system as claimed in claim 2, characterized in that: The step of adjusting the order and filling the operations of the atomic operation units in the operation set according to the topological structure of the directed dependency graph to generate an operation sequence that meets the dependency constraints includes: According to the topological structure of the directed dependency graph, a forward topological sort is performed on the creation operation set in the operation set so that the parent object operation precedes the child object operation, and a reverse topological sort is performed on the deletion operation set in the operation set so that the child object operation precedes the parent object operation; According to the predecessor node of the core atomic operation unit in the directed dependency graph, the constraint operation unit is inserted before the core atomic operation unit in topological order; For the modification operation set in the operation set, the sequence adjustment and the operation filling are performed synchronously, so that all constraint update operations that depend on the current parameter modification are performed before the core parameter modification operation.
4. The multi-level undo and restore method of the CAD system as claimed in claim 3, characterized in that: The deletion operation includes: Traversing all child nodes that depend on the currently deleted object along the edge direction of the directed dependency graph; Generating a corresponding predecessor constraint deletion operation unit for each of the child nodes; The deletion predecessor constraint operation unit is inserted before the main deletion operation in topological order.
5. The multi-level undo and restore method of the CAD system as claimed in claim 1, characterized in that: The transaction management module also performs the following operations: Maintaining an operation stack to record the operation sequence; Set the transaction isolation level to control the impact of concurrent operations; When performing an operation rollback, a compensation operation mechanism is used to restore the system state, and the compensation operation mechanism includes a dual recovery strategy of object state snapshot and incremental log.
6. The multi-level undo and restore method of the CAD system according to claim 1, characterized in that: The method further comprises: When a composite operation involving multiple functional modules is detected, the composite operation is decomposed into multiple sub-operation sets; Establishing an inter-module message channel for each of the sub-operation sets; The atomic commit of cross-module operations of the multiple functional modules is ensured by a transaction coordinator.
7. The multi-level undo and restore method of a CAD system according to claim 6, characterized in that: The transaction coordinator adopts a two-phase commit protocol, which includes a pre-commit phase and a formal commit phase; In the pre-submission stage, performing operation feasibility verification on each of the multiple functional modules and collecting module preparation status; When all functional modules return ready, the formal submission phase is entered to initiate a formal submission instruction; When any functional module of the multiple functional modules returns an exception, a global rollback process is triggered.
8. A multi-level undo and restore device for a CAD system, characterized in that: The device comprises: A transaction management module, configured to receive user operation instructions and generate a corresponding operation set, wherein the operation set includes a plurality of atomic operation units; A construction module, used for parsing the geometric objects and their associations involved in the operation set, and constructing a directed dependency graph with the geometric objects as nodes and the dependencies between the objects as edges; A generation module, used to adjust the order and fill the operation of the atomic operation units in the operation set according to the topological structure of the directed dependency graph, and generate an operation sequence that meets the dependency constraints; The execution module is used to execute the atomic operation units in the operation sequence according to the reverse topological order or the forward topological order when performing the undo or restore operation.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Object operation processing method, device and equipment
CN122132608A