CGAL :: ошибка пересечения

Я использую CGAL для расчета пересечений между 3d треугольниками. Мне нужно проверить, если пересечения возвращают точки или линии или треугольники.

typedef CGAL::Cartesian<double> tc;
typedef tc::Triangle_3       Triangle3;

CGAL::cpp11::result_of<tc::Intersect_3(Triangle3,Triangle3)>::type
resultL1 = CGAL::intersection(*t_3,*tLado1_3);

if (resultL1){                                              // LINE 110
boost::apply_visitor(Intersection_visitor(), *resultL1); // LINE 111
}

Пересечение посетителя:

template<typename R>
struct Intersection_visitor {
typedef void result_type;
void operator()(const Point3<R>& p) const{
// handle point
}
void operator()(const Segment_3<R>& s) const{
// handle segment
}
void operator()(const Triangle3<R>& t) const{
// handle triangle
}
};

Это дает мне две ошибки:

TextureManager.cpp:110: error: invalid type argument of unary '*' (have 'bool')

а также

TextureManager.cpp:111: error: could not convert 'resultL1' from 'CGAL::cpp11::result_of<CGAL::CommonKernelFunctors::Intersect_3<CGAL::Cartesian<double> >(CGAL::Triangle_3<CGAL::Cartesian<double> >, CGAL::Triangle_3<CGAL::Cartesian<double> >)>::type {aka CGAL::Object}' to 'bool'

Кто-то знает, как это исправить?

1

Решение

Согласно страница справочника вам не хватает возможного типа оператора () в посетителе. Следующий пример компилируется нормально.

#include <CGAL/Cartesian.h>

typedef CGAL::Cartesian<double> tc;
typedef tc::Triangle_3       Triangle3;

template<typename R>
struct Intersection_visitor {
typedef void result_type;
void operator()(const CGAL::Point_3<R>& /* p */) const{
// handle point
}
void operator()(const CGAL::Segment_3<R>& /* s */) const{
// handle segment
}
void operator()(const CGAL::Triangle_3<R>& /* t */) const{
// handle triangle
}
void operator()(const std::vector< CGAL::Point_3<R> >& /* t */) const{
// handle triangle
}
};

int main()
{
Triangle3 t1, t2;
CGAL::cpp11::result_of<tc::Intersect_3(Triangle3,Triangle3)>::type
resultL1 = CGAL::intersection(t1, t2);if (resultL1){                                              // LINE 110
boost::apply_visitor(Intersection_visitor<tc>(), *resultL1); // LINE 111
}

}
1

Другие решения