QT——opencsacade+qt 之绘制球

绘制球的基本过程

gp_Ax2类:实例化一个坐标;
gp_Ax2::SetLocation(gp_Pnt); 设置原点位置
BRepPrimAPI_MakeSphere(gp_Ax2,int)::shape(); 传入坐标和半径并创建球形
AIS_Shape (const TopoDS_Shape &shap); 初始化形状
AIS_Shape::SetColor();创建面(如果它们不存在)并为其设置颜色
myOccView::getContext()::Display(); // 在occt显示
Quantity_NOC_BLUE1

void MainWindow::makeSphere(QString str, int x, int y,  int z,  int R) {
    gp_Ax2 anAxis;
    // SetLocation改变原点的位置,gp_Pnt():用3个笛卡尔坐标创建一个点
    anAxis.SetLocation(gp_Pnt(x, y, z));
    TopoDS_Shape aTopoSphere = BRepPrimAPI_MakeSphere(anAxis, R).Shape();
    Handle(AIS_Shape) anAisSphere = new AIS_Shape(aTopoSphere);
    anAisSphere->SetColor(Quantity_NOC_BLUE1);
    myOccView->getContext()->Display(anAisSphere, Standard_True);
}
posted @ 2023-03-18 21:45  摩天仑  阅读(90)  评论(0编辑  收藏  举报