Merging a Set of Bodies
The function
MbResultType UnionSolid( RPArray<MbSolid> & solids,
MbeCopyMode sameShells,
bool checkIntersect,
const MbSNameMaker & names,
bool isArray,
MbSolid *& result,
RPArray<MbSolid> * 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 MbResultType.
The function is declared in the file action_solid.h.
This function operates as the function 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 MbeCopyMode is described in the section 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:
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.
Fig. 2
The functions
MbResultType UnionSolid( const RPArray<MbSolid> & solids,
const MbSNameMaker & names,
MbSolid *& result ),
MbResultType UnionSolid( const c3d::SolidsVector & solids,
const MbSNameMaker & names,
MbSolid *& result ),
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 UnionSolid() add a builder MbUnionSolid to the history log of the constructed body, which contains all necessary data to perform the operation. The builder 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”.