I am trying to compile an example from the book CGAL Arrangements and Their Applications: A Step-by-Step Guide By Efi Fogel, Dan Halperin, Ron Wein. The example can be seen at this link:
For some reason I get a fierce compilation error that is very vague. Here is what I have written so far:
Here is the main function that actually casts the shadow. I have commented the line causing the compile error and posted the error itself below.
#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;
}
Here is the Normal_Equation struct in Normal_equation.h
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());
}
};
The following two files are used as type setters: 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
I am no expert with this stuff so I included my Makefile so you can see what I have linked
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
Here is where it gets really nasty. The compile error is a mile long and is really vague. It is a little beyond me. I excedded the character count for this post so I have posted it in my Onedrive and you can see it here: http://1drv.ms/1eHZkuq