沧州网站群,wordpress关闭主循环,特价流量网站,濮阳 网站建设OCC中实现阵列操作#xff0c;本质上计算出物体的位置#xff0c;然后进行位置变换#xff0c;复制出一个新的物体的过程#xff0c;下列用直线的阵列和环形的阵列作为例子#xff1a;
直线阵列#xff1a;以一个在z轴正方向的直线向y轴方向阵列2个距离为5的对象 #inclu…OCC中实现阵列操作本质上计算出物体的位置然后进行位置变换复制出一个新的物体的过程下列用直线的阵列和环形的阵列作为例子
直线阵列以一个在z轴正方向的直线向y轴方向阵列2个距离为5的对象 #include BRepBuilderAPI_Transform.hxx
#include BRep_Builder.hxxTopoDS_Shape resShape;
for(int i 0;i3;i) {//定义一个向量gp_Vec vec(0, i*5, 0);//定义一个变换gp_Trsf tf;tf.SetTranslation(vec);//执行变换oriShape是要操作的对象true表明是进行复制BRepBuilderAPI_Transform aBRespTrsf(oriShape, tf, true);aBRespTrsf.Build();resShape aBRespTrsf.Shape();
}
环形阵列所需要的参数比较多需要有旋转所围绕的轴旋转的角度和旋转得到的数量
下图所示是将Z轴正方向的线以x轴正方向旋转30°和60°所形成的 #include gp_Ax2.hxx
#include BRepBuilderAPI_Transform.hxx
#include BRep_Builder.hxx//旋转轴的基准点
gp_Pnt pt(0, 0, 0);
//旋转轴的方向
gp_Dir vec(1, 0, 0);
//构建旋转轴
gp_Ax1 ax;
ax.SetLocation(pt);
ax.SetDirection(vec);//创建2个旋转对象
double _wireCount 2;
//旋转角度
double _degree 30;
QListdouble angleList{};
for (int i 1; i _wireCount; i) {double temp _degree * i;//计算出每个对象的旋转角度double angle temp * PI / 180.00;angleList.append(angle);
}
TopoDS_Shape resShape;
for(auto angle : angleList) {//设置变换为旋转变换gp_Trsf tf;tf.SetRotation(ax, angle);BRepBuilderAPI_Transform aBRespTrsf(oriShape, tf, true);aBRespTrsf.Build();resShape aBRespTrsf.Shape();
}