Division of a Body into Disconnected Parts

The functions

DetachParts(       MbSolid &          solid,
                   RPArray<MbSolid> & parts,
                   bool               sort,
             const MbSNameMaker &     names )
DetachParts(       MbSolid &           solid,
                   c3d::SolidsVector & parts,
                   bool                sort,
             const MbSNameMaker &      names )
DetachParts(       MbSolid &               solid,
                   c3d::SolidsSPtrVector & parts,
                   bool                    sort,
             const MbSNameMaker &          names )

detach disconnected parts from a body. If the source body breaks into multiple parts, the largest part remains in the source body, while the remaining parts are placed into the supplied container of solids.

The input parameters of the function are:

  • solid – the source body;

  • sort – the flag for sorting detached parts in descending order of their bounding box;

  • names – the name maker.

The output parameters of the function are the source body solid and the set of detached parts parts.

The functions is declared in the file action_solid.h.

After subtracting body solid2 from body solid1, as shown in Fig. 1, the result of the Boolean operation solid will consist of several topologically disconnected parts, but will behave as a single object (Fig. 2).

../../../../_images/M.2.19.1.png

Fig. 1

../../../../_images/M.2.19.2.png

Fig. 2

If the sorting flag sort == true, the source body solid will contain the part with the largest overall size, and the detached parts will be sorted in descending order of their bounding boxes (Fig. 3). Otherwise, the source body will contain the part topologically connected to the first face, and the detached parts will be sorted by the index of their initial face in the source body.

../../../../_images/M.2.19.3.png

Fig. 3

The parameter names provides naming of the constructed body and versioning of the operation.

Functions

CreateParts( const MbSolid &          solid,
                   RPArray<MbSolid> & parts,
             const MbSNameMaker &     names );
CreateParts( const MbSolid &           solid,
                   c3d::SolidsVector & parts,
             const MbSNameMaker &      names );
CreateParts( const MbSolid &               solid,
                   c3d::SolidsSPtrVector & parts,
             const MbSNameMaker &          names );
CreateParts( const MbSolid &          solid,
                   RPArray<MbSolid> & parts,
                   bool               sort,
             const MbSNameMaker &     names );
CreateParts( const MbSolid &           solid,
                   c3d::SolidsVector & parts,
                   bool                sort,
             const MbSNameMaker &      names );

perform the same operations as the function described above, with the difference that they do not modify the source body solid. Instead, all topologically disconnected parts of the source body are added to parts (Fig. 4).

../../../../_images/M.2.19.4.png

Fig. 4

The parts bodies will be constructed on the same faces as the original solid body. The overloads without the sort parameter arrange the parts in the same order as DetachParts() does when sort = false (by face numbers).

If the original body consists of a single component, no new bodies are created, and the function returns 0.

The functions DetachParts() and CreateParts() add builders MbDetachSolid to the history log of the constructed body. These builders contain all the necessary data to perform the operation. The builder MbDetachSolid is declared in the file cr_detach_solid.h.

In the test application test.exe, splitting disconnected parts is performed using the menu command “Modify ⟶ Solid or shell ⟶ Split parts”.