将程序转换为头文件 - 包含的文件出错

时间:2014-10-29 17:47:29

标签: c++ header-files

我想将我编写的利用CGAL库的程序转换为有用函数的文件,作为头文件包含在另一个程序中。现在,出于测试目的,我只是将“quickhull_3.cpp”文件转换为头文件,将“main”替换为带有一些描述性名称的void函数。

这个文件(“interpLatLongMap.h”,它实际上只是一个CGAL示例程序,“quickhull_3.cpp”)作为一个简单的“hello world”程序的标题:

#include <iostream>
#include "interpLatLongMap.h"

using namespace std;

int main(){
    cout << "Hello World!" << endl;
    return 0;
}

但当我将其包含在我实际上想要使用它的文件中时,我收到错误:

“CGAL-4.4 / include / CGAL / internal / Intersections_3 / Bbox_3_Segment_3_do_intersect.h:76:78:错误:宏”dmax“需要2个参数,但只有1个给定”

我显然不认为这个CGAL文件存在问题。那么我做错了什么?

所以这是“interpLatLongMap.h”,它实际上只是CGAL的“quickhull_3.cpp”,但是“main”改为“runQuickHull”:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/algorithm.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/convex_hull_3.h>
#include <vector>


typedef CGAL::Exact_predicates_inexact_constructions_kernel  K;
typedef CGAL::Polyhedron_3<K>                     Polyhedron_3;
typedef K::Segment_3                              Segment_3;

// define point creator
typedef K::Point_3                                Point_3;
typedef CGAL::Creator_uniform_3<double, Point_3>  PointCreator;

//a functor computing the plane containing a triangular facet
struct Plane_from_facet {
      Polyhedron_3::Plane_3 operator()(Polyhedron_3::Facet& f) {
      Polyhedron_3::Halfedge_handle h = f.halfedge();
      return Polyhedron_3::Plane_3( h->vertex()->point(),
                                h->next()->vertex()->point(),
                                h->opposite()->vertex()->point());
  }
};

void runQuickHull()
{
  CGAL::Random_points_in_sphere_3<Point_3, PointCreator> gen(100.0);

  // generate 250 points randomly on a sphere of radius 100.0
  // and copy them to a vector
  std::vector<Point_3> points;
  CGAL::cpp11::copy_n( gen, 250, std::back_inserter(points) );

  // define polyhedron to hold convex hull
  Polyhedron_3 poly;

  // compute convex hull of non-collinear points
  CGAL::convex_hull_3(points.begin(), points.end(), poly);

  std::cout << "The convex hull contains " << poly.size_of_vertices() << " vertices" << std::endl;

  // assign a plane equation to each polyhedron facet using functor Plane_from_facet
  std::transform( poly.facets_begin(), poly.facets_end(), poly.planes_begin(),Plane_from_facet());

}

0 个答案:

没有答案