Boolean Operation with Kinematic Body
The function
MbResultType EvolutionResult( const c3d::SolidSPtr & srcSolid,
const MbeCopyMode copyMode,
OperationType oType,
const MbEvolutionShellParams & evShellParams,
c3d::SolidSPtr & result );
performs the construction of a kinematic body and then a Boolean operation between the specified body and the constructed body.
The input parameters of the function are:
srcSolid – a given body for the Boolean operation;
copyMode – a copy mode of the specified body;
oType – a type of Boolean operation:
bo_Union – union of bodies,
bo_Intersect – intersection of bodies,
bo_Difference – subtraction of bodies;
evShellParams – an object, that contains source data for constructing the kinematic body.
The output parameter of the function is the result object containing the constructed body.
The function returns an operation result code from the enumeration MbResultType (see mb_operation_result.h).
The function is declared in the action_solid.h file.
When creating the evShellParams object with source data for the construction, one of the following constructors is used (see op_shell_parameter.h):
MbEvolutionShellParams( const MbSweptData & sweptData,
const MbCurve3D & spineCurve,
const EvolutionValues & evolParams,
const MbSNameMaker & operName,
const RPArray<MbSNameMaker> & contoursNames,
const MbSNameMaker & spineName,
IProgressIndicator * prog = nullptr );
MbEvolutionShellParams( const MbSweptData & sweptData,
const MbWireFrame & spineFrame,
const EvolutionValues & evolParams,
const MbSNameMaker & operName,
const RPArray<MbSNameMaker> & contoursNames,
const MbSNameMaker & spineName,
IProgressIndicator * prog = nullptr );
MbEvolutionShellParams( const MbSweptData & sweptData,
const MbSpine & spine,
const EvolutionValues & evolParams,
const MbSNameMaker & operName,
const RPArray<MbSNameMaker> & contoursNames,
const MbSNameMaker & spineName,
IProgressIndicator * prog = nullptr );
MbEvolutionShellParams( const MbSweptData & sweptData,
const MbSpine & spine,
const EvolutionValues & evolParams,
const MbSNameMaker & operName,
const RPArray<MbSNameMaker> & contoursNames,
const MbSNameMaker & spineName,
const VariableSectionValues & varSectVals,
IProgressIndicator * prog = nullptr );
where
sweptData – data about the generatrix curve;
spineCurve – a guide curve;
spineFrame – a guide curve as a wire frame;
spine – a guide curve with additional information;
evolParams – an object containing operation parameters;
operName – a name maker object for the operation;
contoursNames – a name maker object for generatrix contours;
spineName – a name maker object for the guide curve;
varSectVals – data required for constructing a body along a path with changing section;
prog – progress indicator for operation execution.
The function represents a sequential combination of two functions: the function EvolutionShell(), which performs body construction by moving generatrix curves sweptData along the guide curve spine (spineCurve, spineFrame), and the function BooleanResult(), which performs the Boolean operation oType of the body srcSolid with the kinematic body constructed in the previous step. The function EvolutionShell() is described in the section Constructing a Kinematic Body, the function BooleanResult() is described in the section Boolean Operations on Bodies.
The parameter copyMode controls the transfer of faces, edges and vertices from the source body srcSolid 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).
A detailed description of the enumeration MbeCopyMode is provided in the section Copying a Set of Faces MbFaceShell.
The parameter oType determines the type of Boolean operation and can take three values: bo_Union, bo_Intersect, bo_Difference.
When oType = bo_Union, the function performs a union of the body srcSolid and the kinematic body.
When oType = bo_Intersect, the function performs an intersection of the body srcSolid and the kinematic body.
When oType = bo_Difference, the function subtracts the kinematic body from the body srcSolid.
The parameters operName and contoursNames provide naming for the faces, edges and vertices of the constructed body.
When constructing a body by moving curves, the EvolutionResult() function has the same capabilities as the EvolutionShell() function: guide curves can lie on a plane, on a curved surface or in space; the body can completely fill closed curves or have a thin wall. The following are some capabilities of the function related to Boolean operations.
Fig. 1 shows the body srcSolid, the generatrix curve sweptData and the guide curve spine:
Fig. 1
Fig. 2 shows the result of the union Boolean operation of the body srcSolid and the body obtained by moving the generatrix curve sweptData along the guide curve spine shown in Fig. 1:
Fig. 2
Fig. 3 shows the result of the difference Boolean operation (subtracting the body obtained by moving the generatrix curve sweptData along the guide curve spine from the body srcSolid shown in Fig. 1):
Fig. 3
Fig. 4 shows the result of the intersection Boolean operation of the body srcSolid and the body obtained by moving the generatrix curve sweptData along the guide curve spine shown in Fig. 1:
Fig. 4
The EvolutionResult() function adds the creator MbCurveEvolutionSolid to the construction log of the body, which contains all necessary data for performing the operation. The creator MbCurveEvolutionSolid is declared in the file cr_evolution_solid.h.
In the test application test.exe the Boolean operation with the constructed kinematic body is performed by menu commands:
“Create→Solid→As union with a solid→Curve sweeping”,
“Create→Solid→As subtraction with a solid→Curve sweeping”,
“Create→Solid→As intersection with a solid→Curve sweeping”.