Open CASCADE学习|拓扑变换

目录

平移变换

旋转变换

组合变换

通用变换


平移变换

TopoDS_Shape out;gp_Trsf theTransformation;gp_Vec theVectorOfTranslation(0., 0.125 / 2, 0.);theTransformation.SetTranslation(theVectorOfTranslation);BRepBuilderAPI_Transform myBRepTransformation(out, theTransformation);TopoDS_Shape TransformedShape = myBRepTransformation.Shape();

旋转变换

TopoDS_Shape out;gp_Trsf theTransformation;gp_Ax1 axez = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0., 0., 1.));theTransformation.SetRotation(axez, -90 * M_PI / 180);BRepBuilderAPI_Transform myBRepTransformation(out, theTransformation);TopoDS_Shape TransformedShape = myBRepTransformation.Shape();

组合变换

TopoDS_Shape out;
//平移:
gp_Trsf theTransformation1;
gp_Vec theVectorOfTranslation(0., 0.125 / 2, 0.);
theTransformation1.SetTranslation(theVectorOfTranslation);
//绕一个轴旋转:
gp_Trsf theTransformation2;
gp_Ax1 axez = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0., 0., 1.));
theTransformation2.SetRotation(axez, -90 * M_PI / 180);
​
gp_Trsf theTransformation3;
gp_Ax1 axex = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(1., 0., 0.));
theTransformation3.SetRotation(axex, -50 * M_PI / 180);
​
BRepBuilderAPI_Transform myBRepTransformation(out, theTransformation3*theTransformation2* theTransformation1);
TopoDS_Shape TransformedShape = myBRepTransformation.Shape();

通用变换

Open CASCADE学习|拓扑变换_第1张图片

TopoDS_Shape S;
Handle(gp_GTrsf) theTransformation = new gp_GTrsf();
Handle(gp_Mat) rot = new gp_Mat(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5);  //描述一个三行三列的矩阵,用以替换转换的矢量部分
theTransformation->SetVectorialPart(*rot);
theTransformation->SetTranslationPart(gp_XYZ(5, 5, 5)); //使用一个给定的坐标系作为转换,即替换原图形的局部坐标系
Handle(BRepBuilderAPI_GTransform) myBRepTransformation = new BRepBuilderAPI_GTransform(S, theTransformation, false);
TopoDS_Shape S2 = myBRepTransformation->Shape(); //改变形状以及位置后的拓扑

Open CASCADE学习|拓扑变换_第2张图片

你可能感兴趣的:(Open,CASCADE,学习,Open,CASCADE,c++)