CGAL + Polygon_set连接失败



我正试图从Efi Fogel, Dan Halperin, Ron Wein的《CGAL安排及其应用:一步一步指南》一书中编译一个例子。这个例子可以在这个链接中看到:

https://books.google.ca/books?id=u0CONtnwi9YC& pg = PA203&液化石油气= PA203& dq = CGAL + shadow&源= bl& ots = 16 olfsupyy&团体= YM3Da9lqB5-LNjGcpip_v_fBWOw& hl = en& sa = X& ei = ajCUVf_XKobloATxi6noDA& ved = 0 ccyq6aewaq # v = onepage& q& f = false

由于某些原因,我得到了一个非常模糊的严重编译错误。以下是我到目前为止写的内容:

这里是实际投射阴影的主要函数。我已经注释了导致编译错误的行,并将错误本身贴在下面。

#include <boost/lexical_cast.hpp>
#include <iostream>
#include <string>
#include <CGAL/Cartesian.h>
#include <CGAL/Filtered_kernel.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Direction_3.h>
#include <fstream>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Polyhedron_traits_with_normals_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/IO/Gps_iostream.h>
#include "Normal_equation.h"
#include "bops_set_linear.h"
typedef double Real;
//typedef CGAL::Cartesian<Real> Kernel0;
// Use a filtered kernel so that all predicates are exact.
//typedef CGAL::Filtered_kernel<Kernel0> Kernel;
typedef CGAL::Polyhedron_traits_with_normals_3<Kernel> Polyhedron_traits;
typedef CGAL:: Polyhedron_3<Polyhedron_traits> Polyhedron;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Plane_3 Plane_3;
typedef Kernel::Direction_3 Direction_3;
int main(int argc, char* argv[]){
    CGAL_assertion(argc > 3);
    Kernel::FT x = boost::lexical_cast<double>(argv[1]); //Take in x coordinate for shadow plane
    Kernel::FT y = boost::lexical_cast<double>(argv[2]); //Take in y coordinate for shadow plane
    Kernel::FT z = boost::lexical_cast<double>(argv[3]); //Take in z coordinate for shadow plane
    Direction_3 direction(x, y, z);
    const char* filename = (argc > 4) ? argv[4] : "hand.off";
    std::ifstream inFile(filename);
    if (!inFile.is_open()){
        std::cerr << "Failed to open file " << filename << "n";
        exit(1);
    }
    Polyhedron polyhedron;
    inFile >> polyhedron;
    std::transform(polyhedron.facets_begin(), polyhedron.facets_end(), polyhedron.planes_begin(), Normal_equation());
    std::list<Polygon> polygons;
    Kernel kernel;
    Kernel::Compare_z_3 cmp_z = kernel.compare_z_3_object();
    Kernel::Construct_projected_xy_point_2 proj = kernel.construct_projected_xy_point_2_object();
    Kernel::Construct_translated_point_3 translate = kernel.construct_translated_point_3_object();
    Point_3 origin = kernel.construct_point_3_object()(CGAL::ORIGIN);
    Plane_3 plane = kernel.construct_plane_3_object()(origin, direction);
    Point_3 r = translate(origin, direction.vector());
    for (Polyhedron::Facet_const_iterator fit = polyhedron.facets_begin(); fit != polyhedron.facets_end(); ++fit){
        if (CGAL::angle(translate(origin, fit->plane()), origin, r) == CGAL::OBTUSE) continue;
    //Go over the facet vertices and project them
    Polygon polygon;
    Polyhedron::Halfedge_around_facet_const_circulator hit = fit->facet_begin();
    do{
        const Point_3& point = hit->vertex()->point();
        polygon.push_back(proj(plane, point));
    } while (++hit != fit->facet_begin());
    polygons.push_back(polygon);
}
polyhedron.clear();
Polygon_set S;
S.join(polygons.begin(), polygons.end()); //THIS IS THE LINE CAUSING THE COMPILE ERROR
std::cout << S;
return 0;
}

下面是Normal_Equation .h

中的Normal_Equation结构
struct Normal_equation{
    template <typename Facet> typename Facet::Plane_3 operator()(Facet & f){
        typename Facet::Halfedge_handle h = f.halfedge();
        return CGAL::cross_product(h->next()->vertex()->point() - h->vertex()->point(), h->next()->next()->vertex()->point() - h->next()->vertex()->point());
    }
};

以下两个文件用作类型设置器:bops_linear.h

#ifndef BOPS_LINEAR_H
#define BOPS_LINEAR_H
#include <list>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2                            Point;
typedef CGAL::Polygon_2<Kernel>                    Polygon;
typedef CGAL::Polygon_with_holes_2<Kernel>         Polygon_with_holes;
typedef std::list<Polygon_with_holes>              Pgn_with_holes_container;
#endif

bops_set_linear.h

#ifndef BOPS_SET_LINEAR_H
#define BOPS_SET_LINEAR_H
#include "bops_linear.h"
#include <CGAL/Polygon_set_2.h>
typedef CGAL::Polygon_set_2<Kernel>             Polygon_set;
#endif

我不是这方面的专家,所以我把我的Makefile包括在内,这样你就可以看到我链接的

CXX = g++
CXXFLAGS = -g -O -frounding-math
Link = -lCGAL -lmpfr -lgmp -DBOOST_LOG_DYN_LINK -lboost_thread
all: main
main: main.cpp Normal_equation.h 
    $(CXX) $(CXXFLAGS) -o $@ main.cpp $(Link)
clean:
    rm -f main.o main

这才是真正令人讨厌的地方。这个编译错误很长,而且很模糊。这对我来说有点难懂。我超过了这篇文章的字符数,所以我把它发布在我的Onedrive上,你可以在这里看到:http://1drv.ms/1eHZkuq

我不知道为什么,但我设法通过改变内核来编译它。我将文件bops_liner.h更改为

#ifndef BOPS_LINEAR_H
#define BOPS_LINEAR_H
#include <list>
#include <CGAL/Simple_cartesian.h>
//#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>

typedef double Real;
typedef CGAL::Simple_cartesian<Real> Kernel;
//typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2                            Point;
typedef CGAL::Polygon_2<Kernel>                    Polygon;
typedef CGAL::Polygon_with_holes_2<Kernel>         Polygon_with_holes;
typedef std::list<Polygon_with_holes>              Pgn_with_holes_container;
#endif

相关内容

  • 没有找到相关文章

最新更新