通过面投影在轴线上计算得出。
//计算TopoDS_Face投影在轴线上的最大高度(针对面有Location情况)
Standard_Real dmuCADPicker::GetMaxLengthInDirection(const TopoDS_Face& face, const gp_Vec& direction)
{
// 初始化最小和最大投影距离
Standard_Real minProj = Precision::Infinite();
Standard_Real maxProj = -Precision::Infinite();
// 遍历面上的边
TopExp_Explorer exp(face, TopAbs_EDGE);
for (; exp.More(); exp.Next()) {
TopoDS_Edge edge = TopoDS::Edge(exp.Current());
// 获取边的离散点
TopoDS_Vertex v1, v2;
TopExp::Vertices(edge, v1, v2);
gp_Pnt p1 = BRep_Tool::Pnt(v1);
gp_Pnt p2 = BRep_Tool::Pnt(v2);
// 将点投影到指定方向
Standard_Real proj1 = p1.XYZ().Dot(direction.XYZ());
Standard_Real proj2 = p2.XYZ().Dot(direction.XYZ());
// 更新最小和最大投影距离
if (proj1 < minProj) minProj &#