首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CGAL::交集错误

CGAL::交集错误
EN

Stack Overflow用户
提问于 2014-08-05 01:05:52
回答 1查看 661关注 0票数 1

我正在使用CGAL来计算3d三角形之间的交点。我需要验证交叉点是否返回点、线或三角形。

代码语言:javascript
复制
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
}

交叉口访问者:

代码语言:javascript
复制
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
    }
};

这给了我两个错误:

代码语言:javascript
复制
TextureManager.cpp:110: error: invalid type argument of unary '*' (have 'bool')

代码语言:javascript
复制
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'

有人知道怎么解决这些问题吗?

EN

回答 1

Stack Overflow用户

发布于 2014-08-06 12:59:29

根据manual page,您在访问器中缺少一个可能的运算符()类型。下面的示例编译得很好。

代码语言:javascript
复制
#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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25123939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档