Open CASCADE基础介绍(4)
gp_Trsf类
定义一个矩阵变换的类
--可以定义平移、旋转、缩放的矩阵;
--可以对称于一个点,一条线,一个平面;
示例一:
对称于一个点:
gp_Trsf theTransformation;
gp_Pnt PntCenterOfTheTransformation(110,60,60);
theTransformation.SetMirror(PntCenterOfTheTransformation);
示例二:
绕一个轴旋转:
gp_Trsf theTransformation;
gp_Ax1 axe = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.));
theTransformation.SetRotation(axe,30*PI/180);
示例三:
缩放:
gp_Trsf theTransformation;
gp_Pnt theCenterOfScale(200,60,60);
theTransformation.SetScale(theCenterOfScale,0.5);
示例四:
平移:
gp_Trsf theTransformation;
gp_Vec theVectorOfTranslation(-6,-6,6);
theTransformation.SetTranslation(theVectorOfTranslation);
示例五:
Displacement:
TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
gp_Trsf theTransformation;
gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1));
gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1));
theTransformation.SetDisplacement(ax3_1,ax3_2);
BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
TopoDS_Shape TransformedShape = myBRepTransformation.Shape();
示例六:
变形
gp_GTrsf theTransformation;
gp_Mat rot(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5);
theTransformation.SetVectorialPart(rot);
theTransformation.SetTranslationPart(gp_XYZ(5,5,5));
BRepBuilderAPI_GTransform myBRepTransformation(S,theTransformation);
TopoDS_Shape S2 = myBRepTransformation.Shape();