簡體   English   中英

適用於CGAL的istream_iterator

[英]istream_iterator for CGAL

我很尷尬地問,但是我已經有一段時間沒有使用CGAL了。 我試圖使CGAL的Convex_hull_2 / convex_hull_yz.cpp示例從文件獲取輸入,而不是通過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;
}

這是裁判 所以顯然我的嘗試是行不通的:

/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" );

相關問題: 是否有C ++迭代器可以逐行遍歷文件? ,據我所知,但無法與CGAL連接。 有什么想法嗎?

您可以使用以下內容:

std::ifstream input("input.cin");
std::istream_iterator< Point_2 > input_begin( input );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM