【发布时间】:2016-04-14 07:57:47
【问题描述】:
不好意思问了,不过好久没用CGAL了。我试图让Convex_hull_2/convex_hull_yz.cpp CGAL 示例从文件中获取输入,而不是通过 cmd 从重定向中获取输入,例如./convex_hull_yz < convex_hull_yz.cin。代码如下:
#include <iostream>
#include <iterator>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Projection_traits_yz_3.h>
#include <CGAL/convex_hull_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K3;
typedef CGAL::Projection_traits_yz_3<K3> K;
typedef K::Point_2 Point_2;
int main()
{
std::istream_iterator< Point_2 > input_begin( std::cin );
std::istream_iterator< Point_2 > input_end;
std::ostream_iterator< Point_2 > output( std::cout, "\n" );
CGAL::convex_hull_2( input_begin, input_end, output, K() );
return 0;
}
这里是ref。所以很明显我的尝试是行不通的:
/home/gsamaras/CGAL-4.7/examples/Convex_hull_2/convex_hull_yz.cpp:13:83: error: no matching function for call to ‘std::istream_iterator<CGAL::Point_3<CGAL::Epick> >::istream_iterator(const char [19])’
std::istream_iterator< Point_2 > input_begin( "convex_hull_yz.cin" );
相关问题:Is there a C++ iterator that can iterate over a file line by line?,我了解,但我无法连接到 CGAL。请问有什么想法吗?
【问题讨论】:
-
我猜
std::ifstream input("input.cin"); std::istream_iterator< Point_2 > input_begin( input );应该可以工作
标签: c++ io cgal istream istream-iterator