CGAL surface_mesh封面示例

时间:2018-01-24 14:18:04

标签: compiler-errors cgal aabb

在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> > > > > >')

1 个答案:

答案 0 :(得分:2)

应为tree(faces(mesh).first, faces(mesh).second, mesh)

请注意,在User Manual中,您会找到一个真实的示例 完整的语法。这个例子附带了库 目录examples/AABB_tree