0

在 CGAL 网页上,您会看到这个简短的示例:

 CGAL::AABB_tree tree(faces(surface_mesh));

在所有 surface_mesh 和 AABBTree 文档示例中,未使用此行,所以我想知道如何配置 AABB 特征以使该示例成为可能。我自己的方法无法编译:

    #include <CGAL/AABB_face_graph_triangle_primitive.h>
    #include <CGAL/AABB_traits.h>
    #include <CGAL/AABB_tree.h>
    #include <CGAL/AABB_triangle_primitive.h>
    #include <CGAL/Simple_cartesian.h>
    #include <CGAL/Surface_mesh.h>
    #include <fstream>
    #include <iostream>
    #include <list>

    typedef CGAL::Simple_cartesian<double> Kernel;
    typedef Kernel::FT FT;
    typedef Kernel::Ray_3 Ray;
    typedef Kernel::Line_3 Line;
    typedef Kernel::Point_3 Point;

    typedef CGAL::Surface_mesh<Point> SMesh;
    typedef CGAL::AABB_face_graph_triangle_primitive<SMesh> Primitive;
    typedef CGAL::AABB_traits<Kernel, Primitive> AABB_Mesh_Traits;
    typedef CGAL::AABB_tree<AABB_Mesh_Traits> AABBTree;

    int main( const int argc, const char* argv[] )
    {
        const char* filename = ( argc > 1 ) ? argv[1] : "model.obj";
        std::ifstream input( filename );
        SMesh mesh;
        input >> mesh;
        AABBTree tree( faces( mesh ) );

        Point a( 1.0, 0.0, 0.0 );
        Point b( 0.0, 1.0, 0.0 );
        Ray ray_query( a, b );
        std::cout << tree.number_of_intersected_primitives( ray_query )
           << " intersections(s) with ray query" << std::endl;

        return EXIT_SUCCESS;
    }

编译器错误是:

 no matching constructor for initialization of 'AABBTree' 
 (aka 'AABB_tree<AABB_traits<Simple_cartesian<double>, 
   AABB_face_graph_triangle_primitive<
    Surface_mesh<Point_3<CGAL::Simple_cartesian<double> > > > > >')
4

1 回答 1

2

应该是tree(faces(mesh).first, faces(mesh).second, mesh)

请注意,在用户手册中,您可以找到一个使用完整语法的真实示例。这个例子自带的库在目录下examples/AABB_tree

于 2018-01-24T19:40:08.963 回答