首页 > 其他分享 >opencascade官网文档学习之OCCT-Shape healing (3)分析 TopoDS_Shape

opencascade官网文档学习之OCCT-Shape healing (3)分析 TopoDS_Shape

时间:2024-04-20 13:44:05浏览次数:26  
标签:wire 检查 OCCT ShapeAnalysis anExp Shape Edge opencascade TopoDS

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

相关文章

  • 鸿蒙HarmonyOS实战-ArkUI组件(Shape)
    ......
  • Tensorflow 中conv2d_transpose函数output_shape参数的由来和范围
    目录1.卷积和转置卷积(1)卷积(2)转置卷积2.tf.nn.conv2d函数和tf.nn.conv2d_transpose函数(1)tf.nn.conv2d函数(2)tf.nn.conv2d_transpose函数3.转置卷积output_shape参数的探讨(1)卷积过程中,存在尺度丢失现象。(2)转置卷积是恢复卷积之前原始信息的过程1.卷积和转置卷积(1)卷积......
  • R语言k-Shape时间序列聚类方法对股票价格时间序列聚类|附代码数据
    原文链接:http://tecdat.cn/?p=3726最近我们被客户要求撰写关于时间序列聚类的研究报告,包括一些图形和统计输出。本文我们将使用k-Shape时间序列聚类方法检查与我们有业务关系的公司的股票收益率的时间序列企业对企业交易和股票价格在本研究中,我们将研究具有交易关系的公司的......
  • 【Linux】linuxCNC+Qt+Opencascade+kdl+hal 实时6轴机器人控制器
    CNC机器人程序框架机器人模型笔记:debian重启后无法打开共享目录最新版搜狗输入法安装后不支持中文,需要安装旧版本的sogoupinyin_4.0.1.2800_x86_64.deb可用数控机器人在哪些领域应用有优势数控机器人在多个领域都展现出了显著的优势,特别是在需要高精度和......
  • 模版匹配——inspect_shape_model
    inspect_shape_modelcreatesarepresentationofashapemodel.TheoperatorisparticularlyusefulinordertodeterminetheparametersNumLevelsandContrast,whichareusedincreate_shape_model,create_scaled_shape_model,orcreate_aniso_shape_model,q......
  • 模板匹配——determine_shape_model_params
    determine_shape_model_params—Determinetheparametersofashapemodel.模版匹配参数确定 determine_shape_model_paramsdeterminescertainparametersofashapemodelautomaticallyfromthemodelimageTemplate.Theparameterstobedeterminedcanbesp......
  • 模板匹配——create_shape_model
    Theoperatorcreate_shape_modelpreparesatemplate,whichispassedintheimageTemplate,asashapemodelusedformatching.TheROIofthemodelispassedasthedomainofTemplate.运算符create_shape_model准备一个模板,该模板在图像模板中传递,作为用于匹配的......
  • OpenCASCADE开发指南<二>:OCC 体系结构和基本概念
        OCC是用面向对象方法设计的一个CAD基础平台(软件)。为了能从整体上把握OCC的组织情况,也为了方便后续章节的讨论,下面将介绍OCC体系结构和几个基本概念。1、OCC体系结构1.1面向对象方法和面向对象的软件工程  在介绍OCC体系结构之前,先介绍面向对象方......
  • 模板匹配——set_shape_model_clutter
    通过设置杂波,来准确定位要检测对象;如下图中未设置杂波情况下,匹配结果如(3);如图(4)设置杂波后,匹配结果如图(5)**Createashapemodel.*创建一个模型read_image(ImageModel,'/bga_gap/bga_gap_01.png')gen_circle(ROI,753.869,551.624,28.4027)reduce_domain(Image......
  • 模版匹配——set_shape_model_param
    1.'min_contrast'最小对比度SetstheminimumcontrastoftheobjectinthesearchimagesfortheshapemodelModelID.Thereby,thevalueof'min_contrast'thatwasoriginallyset,e.g.withcreate_shape_model,isoverwrittenfortheshape......