【问题标题】:How do I use a class other than a CGAL Point_3 for point set processing?如何使用 CGAL Point_3 以外的类进行点集处理?
【发布时间】:2016-11-17 19:32:10
【问题描述】:

我有一个由外部库 Assimp 在其自己的 aiVector3D 类中加载的点数组(它没有组件访问器函数,只是对成员变量的公共访问),我想使用 CGAL 的 Point Set Processing 库来处理这些点。

由于我拥有数以千万计的这些积分(有一天可能会达到数十亿),如果我能提供帮助,我不想创建一个新的 CGAL Point_3s 数组。

documentation 说:

如果他们实现了相应的属性映射,这个包的用户可以使用其他类型来表示位置和法线。

这似乎意味着我可以通过创建一个将aiVector3D 映射到Point_3 的属性映射来实现我想要的,但是在阅读了 CGAL 和 Boost 的文档之后,我不清楚我将如何去做。

我认为这是正确的方法吗?如果是这样,我该怎么做?

【问题讨论】:

  • 我相信您高估了将点复制到 cgal 点向量的成本。您可以使用将 aiVector3D 动态转换为 cgal 点的点属性图进行管理(有关创建此类属性图的简单方法,请参见 boost::function_property_map),但我怀疑节省的费用是否值得。
  • 我想避免简单复制的两个原因,1) 输入点集一天可能有数十亿个,并且在内存中有两个副本可能会导致问题。 2)它只是不似乎优雅。 1) 可以通过内存映射文件来缓解,2) 可以放在抽屉里并忽略 :) 我会尝试boost::function_property_map,并运行一些基准测试。

标签: c++ boost cgal point-clouds assimp


【解决方案1】:

无论这或多或少是有效的(对于某种高效的含义),这就是我想出的将aiVector3D 映射到CGAL::Point_3(使用CGAL::Simple_cartesian<double> 内核)的方法,包括转换。

template <typename T>
struct AItoP {
    AItoP(const aiScene* scene, const aiNode* node) :
            _scene(scene),
            _node(node),
            _mesh(0)
    {
        _mesh = _scene->mMeshes[node->mMeshes[0]];
        _xform = _node->mTransformation * _scene->mRootNode->mTransformation;
    }

    T operator()(const size_t& x) const {
        aiVector3t<double> v(_mesh->mVertices[x].x, _mesh->mVertices[x].y, _mesh->mVertices[x].z);
        v *= _xform;

        return T(v.x, v.y, v.z);
    }
private:
    const aiScene* _scene;
    const aiNode* _node;
    const aiMesh* _mesh;
    aiMatrix4x4t<double> _xform;
};

...

#include <boost/property_map/function_property_map.hpp>

void my_processing_function() {
    std::vector<std::size_t> indices(mesh->mNumVertices);
    for(std::size_t i = 0; i < mesh->mNumVertices; ++i){
        indices[i] = i;
    }

    double cell_size = 0.05;
    std::vector<std::size_t>::iterator end;
    end = CGAL::grid_simplify_point_set(indices.begin(),
            indices.end(),
            make_function_property_map<const size_t&, Point, AItoP<Point> >(AItoP<Point>(_scene, node)),
            cell_size);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多