# 一、立方体

## 1.构造

• 通过两个位置确定立方体，一个为(0,0,0)，另一个为(dx dy dz)
``````BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const Standard_Real dx,
const Standard_Real dy,
const Standard_Real dz
)
``````
• 通过位置P 和大小 dx, dy, dz 确定立方体
``````BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const gp_Pnt& P,
const Standard_Real dx,
const Standard_Real dy,
const Standard_Real dz
)
``````
• 通过P1和P2的位置
``````BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const gp_Pnt& P1,
const gp_Pnt& P2
)
``````
• 通过坐标轴Ax2构造一个框，使其边平行于Ax2
``````BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const gp_Ax2& Axes,
const Standard_Real dx,
const Standard_Real dy,
const Standard_Real dz
)
``````

## 2.实例

``````//! 生成立方体
void make_cube(Standard_Real _dx = 1.0, Standard_Real _dy = 1.0, Standard_Real _dz = 1.0);
``````

``````void C3DWidget::make_cube(Standard_Real _dx, Standard_Real _dy, Standard_Real _dz)
{
TopoDS_Shape t_topo_box = BRepPrimAPI_MakeBox(_dx, _dy, _dz).Shape();
Handle(AIS_Shape) t_ais_box = new AIS_Shape(t_topo_box);
m_context->Display(t_ais_box, Standard_True);
m_view->FitAll();
}
``````

# 二、圆柱

## 1.构造

BRepPrimAPI_MakeCylinder 提供圆柱模型的构造：

• 通过半径R和高度H构造圆柱
``````BRepPrimAPI_MakeCylinder::BRepPrimAPI_MakeCylinder(const Standard_Real 	R,
const Standard_Real 	H
)
``````

## 2.实例

``````    //! 生成圆柱
void make_cylinder(Standard_Real _R = 0.5,  Standard_Real _H = 2.0);
``````

``````void C3DWidget::make_cylinder(Standard_Real _R, Standard_Real _H)
{
TopoDS_Shape t_topo_cylinder = BRepPrimAPI_MakeCylinder(_R , _H).Shape();
Handle(AIS_Shape) t_ais_cylinder = new AIS_Shape(t_topo_cylinder);
m_context->Display(t_ais_cylinder, Standard_True);
m_view->FitAll();
}
``````

# 三、球

## 1.构造

BRepPrim_Sphere 提供球体模型的构造：

``````BRepPrim_Sphere::BRepPrim_Sphere(const Standard_Real Radius)
``````
``````BRepPrim_Sphere::BRepPrim_Sphere(const gp_Pnt& Center,
)
``````

## 2.实例

``````    //! 球体
void make_sphere(Standard_Real _R = 1.0);
``````

``````void C3DWidget::make_sphere(Standard_Real _R)
{
TopoDS_Shape t_topo_sphere = BRepPrimAPI_MakeSphere(_R).Shape();
Handle(AIS_Shape) t_ais_sphere = new AIS_Shape(t_topo_sphere);
m_context->Display(t_ais_sphere, Standard_True);
m_view->FitAll();
}
``````

# 四、圆锥

## 1.构造

BRepPrimAPI_MakeCone 提供圆锥模型的构造：

• 构造一个圆锥，高度为H，在Z=0的平面上半径为R1，在Z=H平面上，半径为R2，且R1和R2可以为零
``````BRepPrimAPI_MakeCone::BRepPrimAPI_MakeCone(const Standard_Real R1,
const Standard_Real R2,
const Standard_Real H
)
``````

## 2.实例

``````    //! 生成圆锥
void make_cone(Standard_Real _R1 = 1.0, Standard_Real _R2 = 0.0, Standard_Real _H = 2.0);
``````

``````void C3DWidget::make_cone(Standard_Real _R1, Standard_Real _R2, Standard_Real _H)
{
TopoDS_Shape t_topo_cone = BRepPrimAPI_MakeCone(_R1,_R2,_H).Shape();
Handle(AIS_Shape) t_ais_cone = new AIS_Shape(t_topo_cone);
m_context->Display(t_ais_cone, Standard_True);
m_view->FitAll();
}
``````

# 五、圆环

## 1.构造

BRepPrimAPI_MakeTorus 提供圆环模型的构造：

• 通过半径R1和R2构造圆环
``````BRepPrimAPI_MakeTorus::BRepPrimAPI_MakeTorus(const Standard_Real R1,
const Standard_Real R2
)
``````

## 2.实例

``````    //! 生成圆环体
void make_torus(Standard_Real _R1 =2.0, Standard_Real _R2 = 0.5);
``````

``````void C3DWidget::make_torus(Standard_Real _R1, Standard_Real _R2)
{
TopoDS_Shape t_topo_torus = BRepPrimAPI_MakeTorus(_R1 ,_R2).Shape();
Handle(AIS_Shape) t_ais_torus = new AIS_Shape(t_topo_torus);
m_context->Display(t_ais_torus, Standard_True);
m_view->FitAll();
}
``````