Constructing a Transformed Body
The function
MbResultType TransformedSolid( MbSolid & solid,
MbeCopyMode sameShell,
const TransformValues & p,
const MbSNameMaker & names,
MbSolid *& result )
performs a transformation of a source body by a given matrix calculated from the bounding cube.
The input parameters of the function are:
solid is the source body.
sameShell is a mode of copying the source body.
p is the transformation parameters.
names is a name maker of the operation.
The output parameter of the function is the modified body result.
If succeessful, the function returns rt_Success; otherwise, it returns an error code from the MbResultType enumeration (see mb_operation_result.h).
The function is declared in the action_direct.h file.
When creating the p object with the transformation parameters, one of the following constructors is used (see op_shell_parameter.h):
Default constructor:
TransformValues()
: matrix()
, fixedPoint()
, useFixed( false )
, isotropy( false )
{}
Constructor by a matrix:
TransformValues( const MbMatrix3D & m )
: matrix( m )
, fixedPoint()
, useFixed( false )
, isotropy( false )
{}
Constructor by a matrix and a fixed transformation point:
TransformValues( const MbMatrix3D & m, const MbCartPoint3D & f, bool fix = false, bool iso = false )
: matrix( m )
, fixedPoint( f )
, useFixed( fix )
, isotropy( iso )
{}
Constructor by a fixed transformation point and scale factors along axes:
TransformValues( double sX, double sY, double sZ, const MbCartPoint3D & fP );
Copy constructor:
TransformValues( const TransformValues & other )
: matrix ( other.matrix )
, fixedPoint( other.fixedPoint )
, useFixed ( other.useFixed )
, isotropy ( other.isotropy )
{}
The function scales the body by a matrix with equal or different scale factors along the axes of the global coordinate system.
The solid parameter contains the source body to be processed.
The sameShell parameter controls data copying from the source body solid to the resulting body result (see Copying_a_Set_of_Faces).
The p parameter contains a transformation matrix p.matrix and values p.fixedPoint, p.useFixed, p.isotropy, which are used for calculating the transformation matrix. The TransformValues transformation parameter is declared in the op_shell_parameter.h file.
The names parameter is used for naming body elements.
The transformation matrix is calculated from the bounding cube of the source body solid and from a displacement of one of the points of the bounding cube by the method:
bool MbCube::CalculateMatrix( size_t pIndex,
const MbCartPoint3D & point,
const MbCartPoint3D & fixedPoint,
bool useFixed,
bool isotropy,
MbMatrix3D & matrix ) const;
where
pIndex is the index of a point of the bounding cube to be displaced;
point is a space point to which the point of the bounding cube with index pIndex shall be connected;
fixedPoint is a fixed transformation point (used if useFixed = true);
useFixed is a flag for using a fixed point;
isotropy is a flag for equal transformation scale factors;
matrix is the calculated transformation matrix.
Figure 1 shows the numbering of the points of the bounding cube of the solid body. The vertices of the bounding cube have indices 0–7, the midpoints of the edges of the bounding cube have indices 8–19, and the centers of the faces of the bounding cube have indices 20–25.
Fig. 1
The transformation matrix matrix is calculated from a deformed cube obtained by moving the point of the bounding cube with index pIndex to the space point point.
If useFixed = true, the fixed transformation point is the fixedPoint point. If useFixed = false, the fixed transformation point is the point of the bounding cube opposite to the point with index pIndex. The following pairs of points of the bounding cube are considered opposite: 0–6, 1–7, 2–4, 3–5, 8–14, 9–15, 10–12, 11–13, 16–18, 17–19, 20–21, 22–23, 24–25.
If isotropy = true, the transformation scale factors along all axes are equal and proportional to the displacement vector of the point of the bounding cube with index pIndex. If isotropy = false, the transformation scale factors are proportional to the projections of the displacement vector of the point of the bounding cube with index pIndex onto the edges of the bounding cube.
The values p.fixedPoint, p.useFixed, p.isotropy and p.matrix are used as the fixedPoint, useFixed, isotropy and matrix parameters of the CalculateMatrix() method.
Figure 2 shows the source body solid, the points of the bounding cube, and the space point point to which the specified point of the bounding cube shall be moved, and Figure 3 shows the transformed body result constructed by the function under consideration with the parameters useFixed = false and isotropy = false.
Fig. 2
Fig. 3
A body can also be transformed by a given matrix by the Transform() method, which is overloaded in all geometric objects including MbSolid, but in this case the body will not contain any information about the performed operations.
The TransformedSolid() function adds the MbTransformedSolid builder to the history of the resulting body. The MbTransformedSolid builder is declared in the cr_transformed_solid.h file.
The test application test.exe constructs a transformed body by the menu command “Create → Body → By direct editing → Transformation of bounding box”.