Disclosure of Invention
The invention aims to provide a disorder disassembly and assembly method based on a three-dimensional model, aiming at the defects existing in the prior art, and solves the problems of incapability of multiplexing and complicated codes.
The technical scheme adopted for solving the technical problems is as follows:
a disorder disassembly and assembly method based on a three-dimensional model comprises the following steps:
s1, creating a class which is enough to bear all contents of each step;
s2, creating a configuration file by using a json format, converting the json character string into a class object in an initialized mode, taking the class object as storage data, loading the class object, and setting an interdependence relation according to the class object;
s3, creating all the steps, disassembled steps and a disassembled step dictionary, and associating scene objects;
s4, judging the current step state according to the dependent items and the dependent items of the step, initializing assignment, adding the assignment to a dictionary, and recording the disassembly and assembly progress, wherein the step state comprises the dependent items, the dependent items or the dependent items and the dependent items;
s5, searching the dictionary in which the current step exists when the detachable step is detached, and then writing the logic and executing the step according to the configuration until the detachable step is empty, and finishing the installation.
Further, the step S4 further includes: according to the configured data, traversing all steps, acquiring objects related to the scene in the steps, and storing the objects in all step dictionaries.
Further, the logic for searching the dictionary dependent item and the dependent item in the step S5 is as follows:
traversing all step dictionaries in which the dependent items of a step are traversed, and if the dependent items of the step are not stored, storing; if the dependent item of the dependent item in the step is not stored, the prompt message is printed and then stored.
Further, the logic for searching the dictionary or the dependent item and/or the dependent item in the step S5 is as follows:
if there is an or relationship, it is necessary to traverse the or dependent items of this step, find incomplete, remove the step in their or dependent items;
traversing the dependent item of the current step, judging whether the dependent item of the dependent item is executed completely, and if so, adding the dependent item into a detachable step dictionary;
if there is an or relationship, the step or dependent items are judged, if there is a judgment whether they have been disassembled, if not, they are added to the disassembled step dictionary.
Further, the executing step in the step S5 specifically includes:
traversing all the step dictionaries after execution in the step S4, searching steps without dependent items, and storing the steps into a detachable step dictionary;
traversing the detachable step dictionary, starting the detachable functions of the steps, and operating the object associated with the step in the step S4;
after one of the dismounting operations is performed, the dismounting state of this step is set to be dismounted, and it is removed from the dismountable dictionary and added to the dismounted dictionary.
Compared with the prior art, the invention has the beneficial effects that: the invention has the advantages of simple technical scheme, strong reusability and clear configuration file.
Detailed Description
The present invention 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 invention 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 invention.
The embodiment of the invention provides a disorder disassembly and assembly method based on a three-dimensional model, which comprises the following steps of:
s1, creating a class which is enough to bear all contents of each step;
s2, creating a configuration file by using a json format, converting the json character string into a class object in an initialized mode, taking the class object as storage data, loading the class object, and setting an interdependence relation according to the class object;
s3, creating all the steps, disassembled steps and a disassembled step dictionary, and associating scene objects;
s4, judging the current step state according to the dependent items and the dependent items of the step, initializing assignment, adding the assignment to a dictionary, and recording the disassembly and assembly progress, wherein the step state comprises the dependent items, the dependent items or the dependent items and the dependent items;
s5, searching the dictionary in which the current step exists when the detachable step is detached, and then writing the logic and executing the step according to the configuration until the detachable step is empty, and finishing the installation.
In specific implementation, the step S4 further includes: according to the configured data, traversing all steps, acquiring objects related to the scene in the steps, and storing the objects in all step dictionaries.
In specific implementation, the logic for searching the dictionary dependent item and the dependent item in the step S5 is as follows:
traversing all step dictionaries in which the dependent items of a step are traversed, and if the dependent items of the step are not stored, storing; if the dependent item of the dependent item in the step is not stored, the prompt message is printed and then stored.
In specific implementation, the logic for searching the dictionary or the dependent item and/or the dependent item in the step S5 is as follows:
if there is an or relationship, it is necessary to traverse the or dependent items of this step, find incomplete, remove the step in their or dependent items;
traversing the dependent item of the current step, judging whether the dependent item of the dependent item is executed completely, and if so, adding the dependent item into a detachable step dictionary;
if there is an or relationship, the step or dependent items are judged, if there is a judgment whether they have been disassembled, if not, they are added to the disassembled step dictionary.
In specific implementation, the executing steps in the step S5 specifically include:
traversing all the step dictionaries after execution in the step S4, searching steps without dependent items, and storing the steps into a detachable step dictionary;
traversing the detachable step dictionary, starting the detachable functions of the steps, and operating the object associated with the step in the step S4;
after one of the dismounting operations is performed, the dismounting state of this step is set to be dismounted, and it is removed from the dismountable dictionary and added to the dismounted dictionary.
As a preferred embodiment of the present invention, as shown in fig. 1 and 2, the unordered disassembly is divided into unordered assembly and unordered disassembly, and the two are logically identical, and the unordered assembly is illustrated here as an example. The overall installation logic is divided into: data configuration and installation logic.
1. Data configuration
Creating a class (parameters such as reality, hidden objects, dependent items and dependent items, tools used, parts taken at installation, methods performed before and after steps, etc.) that is sufficient to carry all the contents of each step, and using the class as a data configuration class.
2. Installation logic
2_1, creating three dictionaries, respectively: all step dictionaries, installed step dictionaries, and installable step dictionaries;
2_2, traversing all steps according to the configured data, acquiring objects related to the scene in the steps, and storing the objects in all step dictionaries;
2_3, when judging whether one can be installed, several fields in the steps are used, i call them be: dependent items, or dependent items. The dependent items and the dependent items are generally used, and when special conditions are met, for example, the three parts A, B, C are provided, the installation occasions of A and B are parallel, C is possibly installed on A and also possibly installed on B, and two fields of the dependent items and the dependent items are used at the time;
2_4, after the operation in 2_2 is performed, traversing all step dictionaries, and then traversing the dependent item of one step therein, and storing if the dependent item of the step is not stored; if the dependent item of the dependent item in the step is not stored, the prompt message is printed and then stored. Through this traversal, the integrity of the data configuration can be verified and the interdependencies of the steps stored. By means of the dependency relationship, when a step is obtained, the step on which the step depends and the step on which the step depends can be obtained;
2_5, traversing all the step dictionaries after the execution of 2_4, searching steps without dependent items, and storing the steps into an installable step dictionary;
2_6, traversing the installable step dictionary, starting the installation function of the steps, and operating the object associated with the step 2_2;
2_7, after an installation operation is performed, setting the installation state of the step as installed, and removing it from the installable step dictionary and adding it to the installed step dictionary B;
2_8, if there is an or relationship, need to traverse the step or dependent item, find incomplete, remove them or the step in the dependent item;
2_9 traversing the dependent item of the current step, judging whether the dependent item of the dependent item is executed completely, and if so, adding the dependent item into an installable step dictionary;
2_10, if there is an or relationship, judging the step or the dependent items, if there is a judgment whether they are already installed, if not, adding them into an installable step dictionary;
2_11, then performing 2_6, and cycling until the installable step is empty, i.e. all steps are installed, and the installation is completed.
The foregoing has shown and described the basic principles, principal features and advantages of the invention. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, and that the above embodiments and descriptions are merely illustrative of the principles of the present invention, and various changes and modifications may be made without departing from the spirit and scope of the invention, which is defined in the appended claims. The scope of the invention is defined by the appended claims and equivalents thereof.