2016-08-17 7 views
0

私はCGALを初めて使用しています。CGAL-4.8.1アレンジメント - ベジェ曲線はアレンジメントをファイルに保存するエラー

下図のように私はArrangement_on_surfaces_2 Bezier_curves.cppがファイルへの配置を保存する/例を修正しようとしました:

//! \file examples/Arrangement_on_surface_2/Bezier_curves.cpp 
// Constructing an arrangement of Bezier curves. 

#include <fstream> 

#include <CGAL/basic.h> 

#ifndef CGAL_USE_CORE 
#include <iostream> 
int main() 
{ 
    std::cout << "Sorry, this example needs CORE ..." << std::endl; 
    return 0; 
} 
#else 

#include <CGAL/Cartesian.h> 
#include <CGAL/CORE_algebraic_number_traits.h> 
#include <CGAL/Arr_Bezier_curve_traits_2.h> 
#include <CGAL/Arrangement_2.h> 
#include <CGAL/IO/Arr_iostream.h> 

#include "arr_inexact_construction_segments.h" 
#include "arr_print.h" 

typedef CGAL::CORE_algebraic_number_traits    Nt_traits; 
typedef Nt_traits::Rational        NT; 
typedef Nt_traits::Rational        Rational; 
typedef Nt_traits::Algebraic       Algebraic; 
typedef CGAL::Cartesian<Rational>      Rat_kernel; 
typedef CGAL::Cartesian<Algebraic>      Alg_kernel; 
typedef Rat_kernel::Point_2        Rat_point_2; 
typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits> 
                 Traits_2; 
typedef Traits_2::Curve_2        Bezier_curve_2; 
typedef CGAL::Arrangement_2<Traits_2>     Arrangement_2; 
//typedef CGAL::Arrangement_2<Traits_2>     Arrangement; 

int main (int argc, char *argv[]) 
{ 
    // Get the name of the input file from the command line, or use the default 
    // Bezier.dat file if no command-line parameters are given. 
    const char *filename = (argc > 1) ? argv[1] : "Bezier.dat"; 
    const char *outfilename = (argc > 1) ? argv[1] : "BezierOut.dat"; 

    // Open the input file. 
    std::ifstream in_file (filename); 

    if (! in_file.is_open()) { 
    std::cerr << "Failed to open " << filename << std::endl; 
    return 1; 
    } 

    // Read the curves from the input file. 
    unsigned int    n_curves; 
    std::list<Bezier_curve_2> curves; 
    Bezier_curve_2    B; 
    unsigned int    k; 

    in_file >> n_curves; 
    for (k = 0; k < n_curves; k++) { 
    // Read the current curve (specified by its control points). 
    in_file >> B; 
    curves.push_back (B); 

    std::cout << "B = {" << B << "}" << std::endl; 
    } 
    in_file.close(); 

    // Construct the arrangement. 

    Arrangement_2     arr; 
    insert (arr, curves.begin(), curves.end()); 

    // Print the arrangement size. 
    std::ofstream out_file; 
    out_file.open(outfilename); 
    out_file << "The arrangement size:" << std::endl 
      << " V = " << arr.number_of_vertices() 
      << ", E = " << arr.number_of_edges() 
      << ", F = " << arr.number_of_faces() << std::endl; 

    out_file << arr; 
    out_file.close(); 

    return 0; 
} 

#endif 

私は< <編曲OUT_FILEラインをコメントアウトした場合。うまく動作します。それ以外の場合はread_x_monotone_curveにC2678エラーが発生します。Arr_text_formtter.h

Visual Studio 15 x86を使用しています。

ありがとうございました。

答えて

0

これを解決するには、arr_print.hのprint_arrangement(arr)ルーチンをstd :: coutの代わりにstd :: ofstreamを使ってsave_arrangement(arr)に変更します。

< <演算子が動作しないようです。

他の人にもっと良い解決策がある場合は、私はそれを公開しています。

0

ベジェ曲線の配列における交点は、正確に表現できません。したがって、デフォルトのエクスポート(< <)演算子と標準形式を使用して、そのような配置を保存することはできません。

最も簡単な解決策は、曲線を保存することですが、これは、曲線を読み取るたびに配列を再計算する必要があることを意味します。おそらく他の解決策が考案されるかもしれませんが、実装されていません。

関連する問題