#include <iostream>
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Segment_2 Segment_2;
//#pragma comment(lib, "gmp.dll")
#include <iostream>
#include "gmp.h"
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/intersections.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::Point_2 Point_21;
typedef K::Line_2 Line_2;
typedef K::Intersect_2 Intersect_2;
using namespace std;
int main()
{
std::cout << "Hello World!\n";
//std::cout << __cplusplus << _MSVC_LANG << BOOST_MSVC << std::endl;
Point_2 p(1, 1), q(10, 10);
std::cout << "p = " << p << std::endl;
std::cout << "q = " << q.x() << " " << q.y() << std::endl;
std::cout << "sqdist(p,q) = "
<< CGAL::squared_distance(p, q) << std::endl;
Segment_2 s(p, q);
Point_2 m(5, 9);
std::cout << "m = " << m << std::endl;
std::cout << "sqdist(Segment_2(p,q), m) = "
<< CGAL::squared_distance(s, m) << std::endl << __cplusplus << std::endl;
std::cout << "p, q, and m ";
switch (CGAL::orientation(p, q, m)) {
case CGAL::COLLINEAR:
std::cout << "are collinear\n";
break;
case CGAL::LEFT_TURN:
std::cout << "make a left turn\n";
break;
case CGAL::RIGHT_TURN:
std::cout << "make a right turn\n";
break;
}
Line_2 lina(1, 1, 2);
Line_2 linb(1, -1, 1);
CGAL::cpp11::result_of<Intersect_2(Line_2, Line_2)>::type
result = intersection(lina, linb);
if (result)
{
const Point_21* p = boost::get<Point_21 >(&*result);
std::cout << "ok\n";
//std::cout << "q = " << p->x() << " " << p->y() << std::endl;
//std::cout << *p << std::endl;
std::cout << p->x() << ", " << p->y() << std::endl;
}
system("pause");
return 0;
}
出现的问题
if (result)
{
const Point_21* p = boost::get<Point_21 >(&*result);
std::cout << "ok\n";
//std::cout << "q = " << p->x() << " " << p->y() << std::endl;
//std::cout << *p << std::endl;
std::cout << p->x() << ", " << p->y() << std::endl;
acutPrintf(_T("\n%f %f"), p->x(),p->y() );
}
这里输出的是-1.5,-0.5
但是到arx里面输出的都是0.又遇到奇葩恶心人的问题了。这样也用不了啊,
acutPrintf(_T(“\n%f %f”), p->x(),p->y() );这句输出全是0
typedef CGAL::Exact_predicates_exact_constructions_kernel K;这里不用精确的模型。用一般进度的结果到时对的,但是怕精度不够