Analysis 分析
Analysis of shape validity 形状有效性分析
ShapeAnalysis软件包提供了用于分析拓扑形状的工具。在执行修复工具之前,没有必要通过这些工具检查形状,因为这些工具用于在修复工具内部执行修复之前的分析。但是,如果您愿意,这些工具可以独立于修复工具用于检测某些形状问题。
可以通过以下方式完成:
- 创建一个分析工具;
- 通过形状对其进行初始化,并设置公差,如果必要,将检测到问题;
- 检查您感兴趣的问题。
1 TopoDS_Face theFace = ...; 2 // create a tool for analyzing an edge 3 ShapeAnalysis_Edge aCheckEdge; 4 for (TopExp_Explorer anExp (theFace, TopAbs_EDGE); anExp.More(); anExp.Next()) 5 { 6 TopoDS_Edge anEdge = TopoDS::Edge (anExp.Current()); 7 if (!aCheckEdge.HasCurve3d (anEdge)) 8 { 9 std::cout << "Edge has no 3D curve\n"; 10 } 11 }
Analysis of orientation of wires on a face 分析face上的wires的朝向
可以借助ShapeAnalysis::IsOuterBound方法检查面是否具有外部边界
1 TopoDS_Face theFace = ...; // analyzed face 2 if (!ShapeAnalysis::IsOuterBound (theFace)) 3 { 4 std::cout << "Face has not outer boundary\n"; 5 }
Analysis of wire validity 分析wire的有效性
类ShapeAnalysis_Wire用于分析wire。它提供了探索wire特性和检查其是否符合Open CASCADE Technology要求的功能。这些功能包括:
- 检查wire上的edge的顺序,
- 检查对于small edge(长度小于给定值)的存在,
- 检查边缘曲线 edge curves的一致性,
- 检查退化边缘的存在或缺失,
- 检查是否存在自相交边和相交边(边的相交被理解为其2D曲线的相交)
- 检查缺少的边以填充曲面参数空间中的间隙,
- 分析导线方向(定义表面的外部或内部边界),
- 分析添加到现有导线的形状(边缘或导线)的方向。
请注意,除第一个检查操作外的所有检查操作都是基于对导线中的边进行排序的假设。因此,如果检测到wire未排序,则有必要在调用其他检查操作之前对其进行排序。例如,这可以在ShapeFix_Wire::FixOrder()方法的帮助下完成。
该工具应使用wire、面(或具有位置的曲面)或精度进行初始化。一旦工具初始化,就可以执行必要的检查操作。为了一次获得wire上的所有信息,提供了全局方法Perform。它调用所有其他API检查操作来检查每个单独的案例。
API方法只检查相应的案例,可以分析它们返回的值和状态,以了解是否检测到案例。
此类中的一些方法是:
- CheckOrder检查wire中的边的顺序是否正确
- CheckConnected检查边是否断开连接;
- CheckSmall检查是否存在比给定值短的边;
- CheckSelfIntersection检查是否存在自相交边或相邻相交边。如果相交是由于不相邻的边而发生的,则不会检测到。
此类维护状态管理。每个API方法都存储其最后一次执行的状态,可以通过Status...()方法查询 。此外,每个API方法都返回一个布尔值,当检测到正在分析的案例时(设置ShapeExtend_DONE状态),该值为True,否则为False。
1 TopoDS_Wire theWire = ...; 2 Standard_Real aPrecision = 1e-04; 3 ShapeAnalysis_Wire aCheckWire (theWire, theFace, aPrecision); 4 // create a tool and load objects into it 5 if (aCheckWire.CheckOrder()) 6 { 7 std::cout << "Some edges in the wire need to be reordered\n" 8 << "Please ensure that all the edges are correctly ordered before further analysis\n"; 9 return; 10 } 11 if (aCheckWire.CheckSmall (aPrecision)) 12 { 13 std::cout << "Wire contains edge(s) shorter than " << aPrecision << std::endl; 14 } 15 if (aCheckWire.CheckConnected()) 16 { 17 std::cout << "Wire is disconnected\n"; 18 } 19 if (aCheckWire.CheckSelfIntersection()) 20 { 21 std::cout << "Wire has self-intersecting or intersecting adjacent edges\n"; 22 }
Analysis of edge validity 边的有效性分析
类ShapeAnalysis_Edge用于分析边。它提供了以下功能来处理边:
- 查询几何表示(给定面或曲面上的三维曲线和曲线)
- 查询拓扑子形状(边界顶点),
- 检查重叠边,
- 分析曲线一致性:
- 3D曲线和2D曲线的相互定向(同方向或相反方向),
- 3D和2D曲线与顶点的对应关系。
此类支持上述状态管理
1 TopoDS_Face theFace = ...; 2 // create a tool for analyzing an edge 3 ShapeAnalysis_Edge aCheckEdge; 4 for (TopExp_Explorer anExp (theFace, TopAbs_EDGE); anExp.More(); anExp.Next()) 5 { 6 TopoDS_Edge anEdge = TopoDS::Edge (anExp.Current()); 7 if (!aCheckEdge.HasCurve3d (anEdge)) 8 { 9 std::cout << "Edge has no 3D curve\n"; 10 } 11 Handle(Geom2d_Curve) aPCurve; 12 Standard_Real aPFirst = 0.0, aPLast = 0.0; 13 if (aCheckEdge.PCurve (anEdge, theFace, aPCurve, aPFirst, aPLast, Standard_False)) 14 { 15 // print the pcurve and its range on the given face 16 std::cout << "Pcurve range [" << aPFirst << ", " << aPLast << "]\n"; 17 } 18 Standard_Real aMaxDev = 0.0; 19 if (aCheckEdge.CheckSameParameter (anEdge, aMaxDev)) 20 { 21 // check the consistency of all the curves in the edge 22 std::cout << "Incorrect SameParameter flag\n"; 23 } 24 std::cout << "Maximum deviation " << aMaxDev << ", tolerance" 25 << BRep_Tool::Tolerance (anEdge) << std::endl; 26 }
1 // check the overlapping of two edges 2 TopoDS_Edge theEdge1 = ...; 3 TopoDS_Edge theEdge2 = ...; 4 Standard_Real theDomainDist = 0.0; 5 6 ShapeAnalysis_Edge aCheckEdge; 7 Standard_Real aTolOverlap = 0.0; 8 if (aCheckEdge.CheckOverlapping (theEdge1, theEdge2, aTolOverlap, theDomainDist)) 9 { 10 std::cout << "Edges are overlapped with tolerance = " << aTolOverlap << std::endl; 11 std::cout << "Domain of overlapping =" << theDomainDist << std::endl; 12 }
标签:wire,检查,OCCT,ShapeAnalysis,anExp,Shape,Edge,opencascade,TopoDS From: https://www.cnblogs.com/yaoshunyu/p/18147236