Multiplication of Body

The function

MbResultType DuplicationSolid( const MbSolid &                    solid,
                               const MbDuplicationSolidParams &   params,
                                     c3d::SolidSPtr &             result );

creates copies of an original body, transforms them according to the specified law, and combines them into a single body.

The function input parameters are:

  • solid - the original body;

  • params - construction parameters.

In the MbDuplicationSolidParams class, the following constructors are used to initialize the params object with construction parameters (see op_shell_parameter.h):

MbDuplicationSolidParams( const DPtr<DuplicationValues> &  values,
                                IProgressIndicator *       prog = nullptr )

_duplicationValues ( values )
, _selIndices        (        )
, _adaptMode         ( false  )
, _names             (        )
, _progress          ( prog   )
{
   if ( _duplicationValues == nullptr )
   {
      C3D_ASSERT( _duplicationValues != nullptr );
      _duplicationValues = new DuplicationMatrixValues();
   }
}
MbDuplicationSolidParams( const DPtr<DuplicationValues> &  values,
                          const MbSNameMaker &             names,
                                IProgressIndicator *       prog = nullptr )

_duplicationValues ( values )
, _selIndices        (        )
, _adaptMode         ( false  )
, _names             (        )
, _progress          ( prog   )
{
   if ( _duplicationValues == nullptr )
   {
      C3D_ASSERT( _duplicationValues != nullptr );
      _duplicationValues = new DuplicationMatrixValues();
   }
}

Constructor based on the DuplicationMeshValues class for copying along a grid:

MbDuplicationSolidParams(       bool                  isPolar,
                          const MbVector3D &          dir1,
                          const double                step1,
                          const uint                  num1,
                          const MbVector3D &          dir2,
                          const double                step2,
                          const uint                  num2,
                          const MbCartPoint3D *       center,
                                bool                  isAlongAxis,
                                IProgressIndicator *  prog = nullptr )

_duplicationValues( new DuplicationMeshValues( isPolar, dir1, step1, num1, dir2, step2, num2, center, isAlongAxis ) )
, _selIndices()
, _adaptMode( false )
, _names()
, _progress( prog )
{}

Constructors based on the DuplicationMatrixValues class for copying along matrices:

MbDuplicationSolidParams( const MbMatrix3D &           matr,
                                IProgressIndicator *   prog = nullptr )

_duplicationValues( new DuplicationMatrixValues( matr ) )
, _selIndices()
, _adaptMode( false )
, _names()
, _progress( prog )
{}
MbDuplicationSolidParams( const SArray<MbMatrix3D> &   matr,
                                IProgressIndicator *   prog = nullptr )

_duplicationValues( new DuplicationMatrixValues( matr ) )
, _selIndices()
, _adaptMode( false )
, _names()
, _progress( prog )
{}
MbDuplicationSolidParams( const std::vector<MbMatrix3D> &  matr,
                                IProgressIndicator *       prog = nullptr )

: _duplicationValues( new DuplicationMatrixValues( matr ) )
, _selIndices()
, _adaptMode( false )
, _names()
, _progress( prog )
{}

where

  • _duplicationValues - duplication parameter object;

  • _selIndices - indices of selected shell faces;

  • _adaptMode - adaptation mode for open shells;

  • _names - name maker for bodies and faces created by the operation;

  • IProgressIndicator * _progress - operation progress indicator.

The output parameter of the function is the constructed body result.

The function returns an operation result code from the MbResultType enumeration.

The function is declared in the file action_solid.h.

The _names parameter provides naming for the faces, edges and vertices of the constructed body.

The values parameter specifies the construction parameters. Figure 1 shows the data used in the construction and the inheritance scheme of construction parameters from the abstract class DuplicationValues:

../../../../_images/M.2.25.1.png

Fig. 1

To duplicate a body whose copies are arranged along a two-dimensional grid, use the DuplicationMeshValues parameters.

Two types of duplication are supported: along two directions and along a polar grid.

The values.isPolar parameter determines the grid type.

axis1 and axis2 are vectors in the global coordinate system that define the directions of the grid (either linear or polar).

If values.isPolar = false, the original body and constructed copies are arranged at the nodes of a two-dimensional grid with the axes values.axis1 and values.axis2. The original body serves as the reference point. Along the values.axis1 axis, values.num1 copies of the body are arranged with step values.step1; along the values.axis2 axis, values.num2 copies of the body are arranged with step values.step2, including the original body.

If values.isPolar = true, the constructed copies are arranged at the nodes of a polar grid. The original body serves as the origin. The radial direction of the grid is determined by the values.axis1 vector, and the rotation axis is determined by the cross product of values.axis1 and values.axis2. Along the radial directions, values.num1 copies of the body are arranged with step values.step1; on each circle, values.num2 copies of the body are arranged with angular step values.step2.

If values.isAlongAxis = true, the bodies are arranged along the radial axis. If values.isAlongAxis = false, the bodies are arranged parallel to the original body.

The values.center parameter determines the center of the local coordinate system (as well as the application point of the rotation axis in the case of a polar system).

To duplicate a body whose copies are transformed according to a set of matrices, use the DuplicationMatrixValues parameters. The set of transformation matrices is defined by the values.matrices parameter.

If, after construction, the copies and the original body intersect with each other, a Boolean union operation is performed on the intersecting bodies. Figure 2 shows the result of constructing a body duplicated along a polar grid:

../../../../_images/M.2.25.2.png

Fig. 2

The DuplicationSolid() function adds the builder MbDuplicationSolid to the construction log of the body, which contains all the necessary data for executing the operation. The MbDuplicationSolid builder is declared in the file cr_duplication_solid.h.

In the test application test.exe, duplication of the body is performed using the menu commands “Create→Solid→Based on a solid→Duplication by grid” and “Create→Solid→Based on a solid→Duplication by matrices”.