[Bug]使用ST_Intersection函数报:ORA-06530: Reference to uninitialized composite

导语

今天测试一个ST_Geometry的试验,使用了ST_Intersection函数,获得两个图层的相交部分,在执行过程中报:ORA-06530: Reference to uninitialized composite

分析

查找了Esri的官方技术文章,竟然是一个bug。

 

Bug NIM-101461

<think>我们正在处理一个关于CGAL库中`surface_intersection`函数使用问题,特别是针对`Surface_mesh<Kernel::Point_3>`类型的网格。根据用户的问题,我们需要提供关于`CGAL::Polygon_mesh_processing::surface_intersection`的使用方法。首先,回顾一下CGAL文档中关于这个函数的描述:该函数用于计算两个三角形网格表面的交集,并输出交线的集合(即多段线)。由于用户使用的是`CGAL::Surface_mesh<Kernel::Point_3>`,我们需要确保我们的代码示例使用这种类型的网格。注意:`surface_intersection`函数要求网格是三角形网格,并且必须是可交换的(两个网格需要处于同一个坐标系中)。此外,该函数可能有多个重载,但在这里我们关注两个网格的交集。根据CGAL文档,函数签名大致如下:```cpptemplate<classTriangleMesh,classPolylineContainer,classNamedParameters1,classNamedParameters2>boolsurface_intersection(constTriangleMesh&tm1,constTriangleMesh&tm2,PolylineContainer&polylines,constNamedParameters1&np1,constNamedParameters2&np2)```但是,由于我们使用的是`Surface_mesh`,而且没有命名参数,我们可以使用简化版本。我们还需要包含必要的头文件:-对于`Surface_mesh`:`#include<CGAL/Surface_mesh.h>`-对于多边形网格处理:`#include<CGAL/Polygon_mesh_processing/surface_intersection.h>`-可能还需要核心(Kernel)相关的头文件注意:CGAL使用精确的谓词和构造非常重要,以避免数值错误。因此,我们通常会使用一个具有鲁棒性的内核。我们假设用户已经定义了一个内核(Kernel),例如`Exact_predicates_inexact_constructions_kernel`或`Exact_predicates_exact_constructions_kernel`。步骤:1.定义内核和网格类型。2.创建两个输入网格(用户需要提供,这里我们创建两个示例网格,但实际中用户会使用自己的数据)。3.调用`surface_intersection`函数,并获取结果(多段线集合)。示例代码结构如下:```cpp#include<CGAL/Exact_predicates_inexact_constructions_kernel.h>#include<CGAL/Surface_mesh.h>#include<CGAL/Polygon_mesh_processing/surface_intersection.h>namespacePMP=CGAL::Polygon_mesh_processing;usingKernel=CGAL::Exact_predicates_inexact_constructions_kernel;usingPoint_3=Kernel::Point_3;usingSurface_mesh=CGAL::Surface_mesh<Point_3;intmain(){//创建两个Surface_mesh对象:mesh1和mesh2Surface_meshmesh1,mesh2;//这里应该填充网格数据(读取文件或手动创建),但示例中省略//例如:从OFF文件读取//std::ifstreaminput1("mesh1.off");//input1>>mesh1;//存储交线的容器:每条交线由一系列点构成(多段线)std::vector<std::vector<Point_3>>polylines;//调用表面求交函数boolintersecting=PMP::surface_intersection(mesh1,mesh2,polylines);//输出交线信息if(intersecting){std::cout<< "两网格相交,交线数量:"<< polylines.size()<< std::endl;for(constauto&polyline:polylines){std::cout<< "交线包含点:"<< polyline.size()<< std::endl;//如果需要,可以进一步输出每个点的坐标}}else{std::cout<< "两网格不相交"<< std::endl;}return0;}```注意:-函数返回一个布尔值,表示两个网格是否相交(如果找到至少一个交线则返回true)。-结果存储在`polylines`中,它是一个多段线的容器,每条多段线由点组成(顺序表示交线的连接)。-这个函数要求网格必须是三角形网格。如果不是,需要先进行三角化。-如果网格有自交或非流形,可能会影响结果或导致错误。在实际应用中,建议先进行网格修复。用户需要确保两个网格在同一个坐标系中,并且网格是流形的(至少是局部可交的)。另外,根据CGAL版本(5.0及以上),可能需要包含不同的头文件路径,但上述代码应该适用于较新版本。最后,编译时需要链接CGAL及其依赖项(如gmp、mpfr)。相关问题:1.如何判断两个网格是否相交?还有其他方法吗?2.`surface_intersection`函数在遇到非流形网格时会如何处理?3.除了多段线,能否获取交点的其他信息?</think> 针对您查询的 `CGAL::Polygon_mesh_processing::surface_intersection` 在 `Surface_mesh<Kernel::Point_3>` 上的使用方法,以下是完整的技术指南: ### 核心代码实现 ```cpp #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Surface_mesh.h> #include <CGAL/Polygon_mesh_processing/surface_intersection.h> namespace PMP = CGAL::Polygon_mesh_processing; using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; using Point_3 = Kernel::Point_3; using Surface_mesh = CGAL::Surface_mesh<Point_3>; int main() { // 创建两个测试网格 Surface_mesh mesh1, mesh2; // 示例:添加三角形到mesh1 (需替换为实际数据) auto v1 = mesh1.add_vertex(Point_3(0,0,0)); auto v2 = mesh1.add_vertex(Point_3(1,0,0)); auto v3 = mesh1.add_vertex(Point_3(0,1,0)); mesh1.add_face(v1, v2, v3); // 示例:添加三角形到mesh2 (需替换为实际数据) auto w1 = mesh2.add_vertex(Point_3(0,0,1)); auto w2 = mesh2.add_vertex(Point_3(1,0,1)); auto w3 = mesh2.add_vertex(Point_3(0,1,1)); mesh2.add_face(w1, w2, w3); // 输出容器:存储交线(多段线) std::vector<std::vector<Point_3>> polylines; // 执行表面求交计算 bool has_intersection = PMP::surface_intersection(mesh1, mesh2, std::back_inserter(polylines)); if (has_intersection) { std::cout << "检测到相交,交线数量: " << polylines.size() << std::endl; for (auto& poly : polylines) { std::cout << "多段线点数: " << poly.size() << std::endl; } } return 0; } ``` ### 关键参数说明 1. **输入要求**: - 必须为三角形网格(非三角网格需先三角化) - 两个网格需在相同坐标系 - 支持任意封闭/开放曲面 2. **输出容器**: - `polylines`:每个元素是交点的有序序列,描述一条连续交线 - 交点顺序:按实际几何连接顺序排列 3. **返回值**: - `bool` 类型:检测到有效交线时返回 `true` ### 编译配置要求 CMakeLists.txt 配置示例: ```cmake cmake_minimum_required(VERSION 3.10) project(SurfaceIntersectionDemo) find_package(CGAL REQUIRED COMPONENTS Core) add_executable(${PROJECT_NAME} main.cpp) target_link_libraries(${PROJECT_NAME} CGAL::Core) ``` ### 典型应用场景 1. 机械工程:零件干涉检查(如图示装配体干涉区域) $$\int_{\Omega} \|\nabla \phi \| \, dA$$ 2. 医学成像:组织分割表面交叉分析 3. 地理信息:地表模型叠加分析[^1] ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值