.. role:: blue :class: blue Merging a Set of Bodies ======================= .. _Merging_a_Set_of_Bodies_: .. версия ядра: 118058 The function .. code-block:: cpp MbResultType UnionSolid( RPArray & solids, MbeCopyMode sameShells, bool checkIntersect, const MbSNameMaker & names, bool isArray, MbSolid *& result, RPArray * notGluedSolids = NULL ); unites bodies from a given set into a single body. The input parameters of the function are: - **solids** — a set of bodies; - **sameShells** — the copy mode for bodies in the set; - **checkIntersect** — the flag that enables intersection checking for bodies in the set (*false* means no check); - **names** — the name maker for the operation; - **isArray** — the flag indicating whether the set of bodies is regular. The output parameters of the function are the constructed body **result** and the set of bodies **notGluedSolids**, which were not used in the operation (may be null). The function returns a result code from the enumeration :blue:`MbResultType`. The function is declared in the file *action_solid.h*. This function operates as the function :blue:`UnionResult`\() with parameter values **solid** = 0, **sameShell** = *cm_Same*, **oType** = *bo_Union*, **mergeFlags**.\ *mergeFaces* = *true*. The function performs union of the set of bodies **solids** into a single body **result** even if the bodies do not intersect one another. The parameter **sameShells** controls the transfer of faces, edges and vertices from bodies **solids** to the constructed body **result** and can take one of four values: - *cm_Same* = 0 (the shell is not copied); - *cm_KeepHistory* (the source shell and its copy share common base surfaces, vertices, and faces unchanged by the operation); - *cm_KeepSurface* (the source shell and its copy share common base surfaces); - *cm_Copy* (the source shell and its copy have no shared data). The enumeration :blue:`MbeCopyMode` is described in the section :ref:`Copying a Set of Faces MbFaceShell `. The parameter **checkIntersect** issues a command to check for intersection of bodies in the set **solids** with one another. If the parameter **checkIntersect** == *true*, then during result construction, a Boolean union operation is performed on all intersecting bodies in the set **solids**. Otherwise, the union of bodies from the given set is performed by simply transferring faces from all bodies into the constructed body. Regardless of the value of the parameter **checkIntersect**, all non-intersecting bodies in the set **solids** transfer their faces to a common intermediate body. The parameter **isArray** works only when **checkIntersect** == *true* and indicates the regularity of the set of bodies **solids**. If **isArray** == *true*, then the bodies in the set are positioned at nodes of a rectangular or circular grid, and the body positions are specified in the face names. The parameter **names** provides naming for the faces, edges and vertices of the constructed body. The parameter **notGluedSolids** contains bodies that were not used in the operation due to the impossibility of merging them. Figure 1 shows the source bodies **solids**: .. figure:: /MODELER/OPERATIONS_ON_BODIES/pictures/M.2.18.1.png :width: 12cm :align: center Fig. 1 Figure 2 shows the result **result** of the union of bodies **solids**. In this case, the parameter **checkIntersect** must be set equal to *true*, since the bodies in **solids** intersect with one another. .. figure:: /MODELER/OPERATIONS_ON_BODIES/pictures/M.2.18.2.png :width: 12cm :align: center Fig. 2 The functions .. code-block:: cpp MbResultType UnionSolid( const RPArray & solids, const MbSNameMaker & names, MbSolid *& result ), .. code-block:: cpp MbResultType UnionSolid( const c3d::SolidsVector & solids, const MbSNameMaker & names, MbSolid *& result ), .. code-block:: cpp MbResultType UnionSolid( const c3d::SolidsSPtrVector & solids, const MbSNameMaker & names, MbSolid *& result ) are simplified variants of the previously discussed function of the same name, which unite bodies from a given set by simply transferring faces from all bodies into one new body. Thus, the constructed body and the source bodies share the same faces. The functions :blue:`UnionSolid`\() add a builder :blue:`MbUnionSolid` to the history log of the constructed body, which contains all necessary data to perform the operation. The builder :blue:`MbUnionSolid` is declared in the file *cr_union_solid.h*. In the test application *test.exe*, the Boolean operation of a body with a set of bodies is performed by the menu command "Create → Solid → Based on a solid → Set of solids".