Copying a Set of Faces MbFaceShell
Each construction method that uses a set of faces in its input parameters, represented as MbFaceShell or MbSolid, modifies some vertices, edges, and faces of the source objects. To speed up constructions and keep the source face set unchanged, full or partial copying of MbFaceShell data is applied. The C3D geometric kernel uses four ways of copying a MbFaceShell face set, defined by the MbeCopyMode enumeration. As a rule, construction methods receive, together with the modified face set, a parameter of type MbeCopyMode that controls the transfer of faces, edges, and vertices from the source object to the constructed object.
Enumeration MbeCopyMode is declared in file mb_enum.h. A parameter of type MbeCopyMode can take one of four values: cm_Copy, cm_KeepSurface, cm_KeepHistory, cm_Same.
With value cm_Copy, the source face set of the modified object is fully copied, so the source object and the constructed object do not share surfaces, curves, faces, edges, vertices, or other objects. This option is used when the constructed object must not be linked to the source object.
With value cm_KeepSurface, the source object and the constructed object share the same base face surfaces. This option is used when high construction speed is required.
With value cm_KeepHistory, the source object and the constructed object share the same vertices, base face surfaces, and faces that are not modified by the performed construction or other operation. This option is used when maximum memory saving is required.
With value cm_Same, all necessary data of the source object are transferred to the constructed object, therefore after construction the source object must be deleted. This option is used when the source object is no longer needed and was created specifically for the performed construction.
Enumeration MbeCopyMode is used in the method for copying a face set MbFaceShell MbFaceShell::Copy( MbeCopyMode, MbShellHistory ). This method is used in solid construction operations whose input parameters include other solids.
With enumeration value cm_Copy, the source face set and its copy have no common data. The variant in which the source face set and its copy share common base surfaces corresponds to enumeration value cm_KeepSurface. The variant in which the source face set and its copy share common base surfaces, vertices, and faces not changed by the operation corresponds to enumeration value cm_KeepHistory. In this case, method Copy(…) uses a pointer to object MbShellHistory, which stores the correspondence between the source face set and its copy. After the operation has been performed, the copy of the face set is passed as a parameter to method MbShellHistory::SetOrigins( MbFaceShell & ) to replace unchanged faces in the copy with their originals from the source face set. The variant in which the face set is not copied in method Copy(…) corresponds to enumeration value cm_Same. It should be noted that if the operation fails, the source face set will be modified.
To copy a face set MbFaceShell, method Duplicate( MbRegDuplicate * iReg ) can be used. Object MbRegDuplicate is used to preserve in the copy the structure of mutual references that is present in the source face set. The copied face set and its copy will not be linked to each other.