CGAL 4.9 错误 C2039 'clear' 不是 'std::back_insert_iterator' 的成员 - 解决方法
CGAL 4.9 错误 C2039 'clear' 不是 'std::back_insert_iterator' 的成员 - 解决方法
在使用 CGAL 4.9 版本和 Visual Studio 2015 开发环境时,您可能会遇到以下错误信息:
错误 C2039 'clear': 不是 'std::back_insert_iterator<std::vector<Point_3,std::allocator<_Ty>>>' 的成员
问题原因:
这个错误是由于 std::back_insert_iterator 在 CGAL 4.9 版本中没有 clear() 成员函数导致的。
解决方法:
您可以尝试以下方法来解决此问题:
1. 升级 CGAL 版本:
建议您将 CGAL 升级到最新版本,新版本可能已经修复了此错误并提供更多功能。
2. 修改代码:
您可以修改代码,使用其他方法来清空 std::back_insert_iterator。例如,使用具有 clear() 成员函数的容器来承接迭代器的内容,并在需要时清空容器。
以下是修改示例:
**原始代码:**cppstd::vector<Point_3> containingPart;CGAL::Polygon_mesh_processing::intersection(ch_mesh, segment, std::back_inserter(containingPart));
**修改后的代码:**cppstd::vector<Point_3> tempContainer;CGAL::Polygon_mesh_processing::intersection(ch_mesh, segment, std::back_inserter(tempContainer));containingPart.clear();containingPart.insert(containingPart.end(), tempContainer.begin(), tempContainer.end());
代码解释:
- 首先,创建一个名为
tempContainer的临时容器来接收迭代器的内容。- 然后,使用clear()函数清空containingPart容器。- 最后,使用insert()函数将tempContainer中的内容复制到containingPart中。
注意:
- 以上修改示例仅供参考,具体的修改方案可能需要根据您的实际需求进行调整。- 在修改代码之前,请务必备份您的原始代码,以防意外情况发生。
如果以上方法都无法解决您的问题,建议您查阅 CGAL 的官方文档、论坛或邮件列表,以获取更具体和详细的帮助。在寻求帮助时,请提供尽可能详细的错误信息、代码段和环境配置,以便其他人能够更好地帮助您解决问题。
原文地址: https://www.cveoy.top/t/topic/lqD 著作权归作者所有。请勿转载和采集!