OCC 拟合的平面转换为有界平面

问题:针对导入的部分面无法获取大小,同时也无法判断点是否在面上。但是OBB可以获取大小

解决方法:通过面拟合转换gp_Pln,然后获取面的内外边,重新修剪生成新的TopoDS_Face

疑问:本人对OCC中各种面的特性不是很了解有知道的老大可以帮忙普及一下:

TopoDS_Face

BRepAdaptor_Surface

GeomAbs_Plane

Geom_Plane

GeomPlate_Surface

gp_Pln

以下是实现的参数部分代码,通过UV提取点,判断点是否在面上。

//如果获取的包容盒小于步距,获取一下OBB包容盒判断是否大于2,大于2开始面转换

if (aUmax - aUmin < uStep || aVmax - aVmin < vStep)

{

Bnd_OBB obb;

BRepBndLib::AddOBB(aFace, obb, Standard_True, Standard_False);

if (2 * obb.XHSize() > 2 || 2 * obb.YHSize() > 2 || 2 * obb.ZHSize() > 2)

{

//判断面的类型 转换面类型 获取面的边界 修建获取新的有界面 针对平面

if (aSurface.GetType() == GeomAbs_SurfaceOfRevolution || aSurface.GetType() == GeomAbs_BSplineSurface)//回旋曲面//样条曲面

{

TopLoc_Location theTopLoc_Location = aFace.Location();

Handle(Geom_Surface) geomSurface = aSurface.Surface().Surface();

Handle(Geom_BSplineSurface) bsplineSurface = GeomConvert::SurfaceToBSplineSurface(geomSurface);

GeomConvert_SurfToAnaSurf converter(bsplineSurface);

converter.SetConvType(GeomConvert_Simplest);

converter.SetTarget(GeomAbs_Plane);

geomSurface = converter.ConvertToAnalytical(1);

gp_Pln thegp_Pln;

if (converter.IsCanonical(geomSurface))

{

Standard_CString aRotatedEntityTypeName = geomSurface->DynamicType()->Name();

if (geomSurface->IsKind(STANDARD_TYPE(Geom_Plane)))

{

Handle(Geom_Plane) theGeom_Plane = Handle(Geom_Plane)::DownCast(geomSurface);

theGeom_Plane->Transform(theTopLoc_Location);

if (theGeom_Plane.IsNull())

{

return 0;

}

thegp_Pln = theGeom_Plane->Pln();

TopoDS_Wire outerWire = ShapeAnalysis::OuterWire(aFace);

std::vector<TopoDS_Wire> innerHoles;

// 遍历面上的每个边界线 (TopoDS_Wire)

for (TopExp_Explorer wireExp(aFace, TopAbs_WIRE); wireExp.More(); wireExp.Next()) {

TopoDS_Wire wire = TopoDS::Wire(wireExp.Current());

if (!wire.IsSame(outerWire))

{

innerHoles.push_back(wire); // 内孔

}

}

BRepBuilderAPI_MakeFace faceBuilder(thegp_Pln, outerWire);

// 添加内孔

for (const auto& holeWire : innerHoles) {

faceBuilder.Add(holeWire);

}

// 生成新的有限平面

aFace = faceBuilder.Face();

aSurface = BRepAdaptor_Surface(aFace);

aUmin = aSurface.FirstUParameter();

aUmax = aSurface.LastUParameter();

aVmin = aSurface.FirstVParameter();

aVmax = aSurface.LastVParameter();

}

}

}

}

}

相关推荐
走好每一步4 小时前
12、VTK用X、Z平面去切割一个圆锥
平面·vtk·三维图像
走好每一步8 小时前
11、VTK重要数学知识:平面和法向量
平面·vtk·三维图像
爱讲故事的2 天前
计算机网络第四章复习:网络层 Data Plane 数据平面
网络·计算机网络·平面
爱讲故事的3 天前
计算机网络第 5 章复习:Network Layer Control Plane(网络层控制平面)
网络·计算机网络·平面
Σίσυφος19005 天前
激光三角 光平面标定-多高度误差分析
人工智能·计算机视觉·平面
Σίσυφος19005 天前
激光三角 光平面标定-多高度
平面
Σίσυφος19005 天前
激光三角 光平面标定
平面
胡摩西10 天前
立体电子围栏如何实现?毫米级室内定位让安全生产从“平面”走向“空间”
人工智能·安全·平面·室内定位
weixin_3975740911 天前
Agent OS治理平台:资源平面、执行平面与控制平面的架构
人工智能·平面·架构
kaikaile199512 天前
平面桁架 Matlab 刚度矩阵计算程序
matlab·平面·矩阵