Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ CGAL&x2B;多边形集合连接失败_C++_Cgal - Fatal编程技术网

C++ CGAL&x2B;多边形集合连接失败

C++ CGAL&x2B;多边形集合连接失败,c++,cgal,C++,Cgal,我试图从《CGAL安排及其应用:Efi Fogel、Dan Halperin、Ron Wein的分步指南》一书中编译一个例子。可以在以下链接中看到示例: 由于某种原因,我得到了一个非常模糊的严重编译错误。以下是我到目前为止所写的内容: 这里是实际投射阴影的主要函数。我已经对导致编译错误的行进行了注释,并在下面发布了错误本身 #include <boost/lexical_cast.hpp> #include <iostream> #include <string&

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

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

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

#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;
}

这就是它变得非常糟糕的地方。编译错误有一英里长,非常模糊。我有点不明白。我超出了这篇文章的字符数,因此我将其发布在我的Onedrive中,您可以在这里看到:

我不知道为什么,但我通过更改内核成功地将其编译。我将文件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
\ifndef BOP\u线性
#定义BOP_线性_H
#包括
#包括
//#包括
#包括
typedef双实数;
简单笛卡尔核;
//typedef CGAL::精确谓词\u精确构造\u内核;
typedef内核::Point_2 Point;
typedef CGAL::Polygon_2 Polygon;
typedef CGAL::带孔的多边形\u 2带孔的多边形\u;
typedef std::列出带孔容器的Pgn_;
#恩迪夫

您是否尝试编译原始示例?它们都可以从……哦,谢谢。我不知道。我会试着回去报到
#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
#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
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
#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