2016-04-14 7 views
0

私は尋ねるには恥ずかしいですが、しばらくの間はCGALを使用していません。私はConvex_hull_2/convex_hull_yz.cppのCGALの例を、./convex_hull_yz < convex_hull_yz.cinのようなcmd経由のリダイレクトからではなく、ファイルからの入力を得るようにしようとしています。コードは次のとおりです。istream_iterator for CGAL

#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との接続に失敗します。どんなアイデアですか?

+0

私は 'のstd ::はifstream入力( "input.cin")推測します。 std :: istream_iterator < Point_2 > input_begin(入力); '動作しているはずです – sloriot

答えて

2

次を使用することができます。

std::ifstream input("input.cin"); 
std::istream_iterator<Point_2> input_begin(input); 
関連する問題