Subject: CGAL users discussion list
List archive
- From: "Jeb Gaither" <>
- To: <>
- Subject: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement
- Date: Wed, 1 Jul 2020 17:41:09 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=None ; spf=None
- Ironport-phdr: 9a23:1uIirBFHcHj6nfaDodAl7p1GYnF86YWxBRYc798ds5kLTJ7zoMmwAkXT6L1XgUPTWs2DsrQY0rSQ6/qrADJcqdbZ6TZeKcEKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMYbjZZjJ6or1hfFvHREd/lXyG5nOFmfmwrw6tqq8JNs7ihdu+gt+9JcXan/Yq81UaFWADM6Pm4v+cblrwPDTQyB5nsdVmUZjB9FCBXb4R/5Q5n8rDL0uvJy1yeGM8L2S6s0WSm54KdwVBDokiYHOCUn/2zRl8d9kbhUoBOlpxx43o7UfISYP+dwc6/BYd8XQ3dKU8BMXCJDH4y8dZMCAesBM+hGsofzqVgAohSiCgerGOPh0iRFiWXq0aAgy+ktDx3K0BImEtkTsHrUttL1NKIKXOy7yKfH0y7MZO5X1zjn6YjIbhAhru+WXb5+bMHczksvGB3egViLtYHlJS+V2/kNsmWH7ORsT/6gi2kiqwxopDWk28gjhJXTiI0P1lDE6Tt2wJwzJdCgVkN1bsKpHpVfui+UOYZ7Q8cvT3xstSokyLAKpJ62cDUExZkpxhPSZfyKfoaK7xzsVeudPTV1iXN4dLywhhu+7U6twfDyWMmz1VZFtCtFkt/Uu38R2Bzc8MyHRuF6/ke71jaC0R3Y5OJcIU0si6bXN5oszqQtmpcRq0jPAzL6lUXsgKOLaEko5O6l4Pn9bLr8vJ+TLYp0hxn+Mqswnsy/Bvw1PRISX2if9um80b3j/UriT7lUjvA6iLPZv47VJcQava65HxFa0pw95BmiFDem0cgYkmcdIF1ZfxKHipDlO1DIIP/mEfeym0qgnCtvyvzcI7HsAI/BImXenLrhZ7px9lBQxBQrwdBa/Z1UC7UBIPzpWk/2sdzVFh05PBKvzOv8Etp9zJ8eVnmPA6CDMaPeq0OH5uUqI+WUfo8apC79K+Q55/7plXI2hVAdcrOt3ZcOdX+4H+9mLFmEYXr3mdcMCnwKvwo7TOzyklKOSz9TZ3CoX6I9/D43EoymDZ2QDryq1eiK0y6/W5FXfWtbEUukEHHydozCVe1aOwyIJco02B4JX/COQo491Ry0/keuybdtBsPO5gcJnLOl399wsb6A3Sou/CB5WpzOm1qGSHt5yztRFm0GmZtnqEk48W+tlK1xgvhWD9tWvqgbWx0mP4/VzqpxDNWgAlucLOfMc06vR5CdOR90Tt81xIRXMU9hH4mnjhfJhXfsGbIalqeXCYY5/rndw3W3LMF4mS6fiPsRymI+S84KDlWIw7Zl/lGIVafTj2+IvofsfqMZjnbA
Hello,
Problem Description
I have successfully used the C:\del64\CGAL-5.0.1\examples\Arrangement_on_surface_2\build\Debug\Bezier_curves.exe for several years using different versions of CGAL as they have become available. My only modifications to the example code are to load the curves from a file and save the results to a file.
Recently I have been encountering a number of precondition violations. I have observed that sometimes if I repeatedly run the program with the same set of curves, once in a while it will produce a violation free result.
In reviewing other situations where individuals have encountered precondition violations, the solution is to change to an exact solution.
I cannot figure out how to do this for Bezier Curves.
I have include my source code and a failure example below.
Thank you!
Jeb Gaither
Source Code
//! \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;
//----------------------------------------------------------------------------- // Save all vertices (points) and edges (curves) along a connected component // boundary. // template<class Arrangement> void save_ccb(typename Arrangement::Ccb_halfedge_const_circulator circ,std::ofstream &aOutputFile) { typename Arrangement::Ccb_halfedge_const_circulator curr = circ; typename Arrangement::Halfedge_const_handle he;
aOutputFile << "(" << curr->source()->point() << ")"; aOutputFile << std::endl; do { he = curr; aOutputFile << " [" << he->curve() << "] " << "(" << he->target()->point() << ")"; aOutputFile << std::endl; ++curr; } while (curr != circ); aOutputFile << std::endl;
return; }
//----------------------------------------------------------------------------- // Save the boundary description of an arrangement face. // template<class Arrangement> void save_face(typename typename Arrangement::Face_const_handle f, std::ofstream &aOutputFile) { // Print the outer boundary. if (f->is_unbounded()) { aOutputFile << "Unbounded face. " << std::endl; } else { aOutputFile << "Outer boundary: "; print_ccb<Arrangement>(f->outer_ccb(), aOutputFile); aOutputFile << std::endl; }
// Print the boundary of each of the holes. typename Arrangement::Hole_const_iterator hole; int index = 1;
for (hole = f->holes_begin(); hole != f->holes_end(); ++hole, ++index) { aOutputFile << " Hole #" << index << ": "; print_ccb<Arrangement>(*hole, aOutputFile); aOutputFile << std::endl; }
// Print the isolated vertices. typename Arrangement::Isolated_vertex_const_iterator iv;
for (iv = f->isolated_vertices_begin(), index = 1; iv != f->isolated_vertices_end(); ++iv, ++index) { aOutputFile << " Isolated vertex #" << index << ": " << "(" << iv->point() << ")" << std::endl; }
return; }
//----------------------------------------------------------------------------- // Save the given arrangement to file. // template<class Arrangement> void save_arrangement(const Arrangement& arr, std::ofstream &aOutputFile) { CGAL_precondition(arr.is_valid());
// Print the arrangement vertices. typename Arrangement::Vertex_const_iterator vit;
aOutputFile << arr.number_of_vertices() << " vertices:" << std::endl; for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) { aOutputFile << "(" << vit->point() << ")"; if (vit->is_isolated()) aOutputFile << " - Isolated." << std::endl; else aOutputFile << " - degree " << vit->degree() << std::endl; }
// Print the arrangement edges. typename Arrangement::Edge_const_iterator eit;
aOutputFile << arr.number_of_edges() << " edges:" << std::endl; for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) { aOutputFile << "[" << eit->curve() << "]" << std::endl; } // Print the arrangement faces. typename Arrangement::Face_const_iterator fit;
aOutputFile << arr.number_of_faces() << " faces:" << std::endl; for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) { // save_face(fit->face(), aOutputFile); // Print the outer boundary. if (fit->is_unbounded()) { aOutputFile << "Unbounded face. " << std::endl; } else { aOutputFile << "Outer boundary: "; save_ccb<Arrangement>(fit->outer_ccb(), aOutputFile); }
// Print the boundary of each of the holes. typename Arrangement::Hole_const_iterator hole; int index = 1;
for (hole = fit->holes_begin(); hole != fit->holes_end(); ++hole, ++index) { aOutputFile << " Hole #" << index << ": "; save_ccb<Arrangement>(*hole, aOutputFile); }
// Print the isolated vertices. typename Arrangement::Isolated_vertex_const_iterator iv;
for (iv = fit->isolated_vertices_begin(), index = 1; iv != fit->isolated_vertices_end(); ++iv, ++index) { aOutputFile << " Isolated vertex #" << index << ": " << "(" << iv->point() << ")" << std::endl; }
}
return; }
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(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; save_arrangement(arr,out_file); out_file.close();
return 0; }
#endif
Failure Example
B = {4 3711507924 2865278219 3387450460 2979371134 3732852274 765306650 4082921600 751693496} B = {4 4082921600 751693496 138023630 738080342 492760467 2924918518 150946400 2833985697} B = {4 150946400 2833985697 4104099630 2743052877 3065734660 374349059 3364942830 563526687} B = {4 3364942830 563526687 3664151001 752704315 1005965016 3499763387 780346946 3228647410} B = {4 780346946 3228647410 554728876 2957531432 2761678721 3963207703 2889287872 4291330058} B = {4 2889287872 4291330058 3016897023 324485117 1065165481 4270020853 1050800113 3916166178} B = {4 1050800113 3916166178 1036434745 3562311503 2959435552 3204033711 2856266200 3548982900} B = {4 2856266200 3548982900 2753096848 3893932088 623757336 647140960 837105897 345708045} B = {4 837105897 345708045 1050454457 44275131 3606491089 2688200429 3301513570 2915003916} B = {4 3301513570 2915003916 2996536052 3141807404 4125511678 951489078 198993326 823727760} B = {4 198993326 823727760 567442270 695966440 175364532 2630762126 4073586476 2644375203} B = {4 4073586476 2644375203 3676841125 2657988281 3275428162 750418751 3661633657 855020001} B = {4 3661633657 855020001 4047839152 959621250 926695811 3076393280 589726066 2861216888} B = {4 589726066 2861216888 252756322 2646040497 2699960175 98915684 2953013560 405815950} B = {4 2953013560 405815950 3206066946 712716216 1264969863 3873641561 1122937075 3503452199} B = {4 1122937075 3503452199 980904286 3133262837 2637935791 3526926066 2652301229 3925012512} B = {4 2652301229 3925012512 2666666667 28131662 1038366037 430641326 1155958989 43625208} B = {4 1155958989 43625208 1273551940 3951576384 3137038473 2775034485 2896254476 3112251688} B = {4 2896254476 3112251688 2655470480 3449468891 310415954 1005477905 653155187 752675593} B = {4 653155187 752675593 995894419 499873282 4026427409 2438259646 3613587087 2579689395} B = {4 3613587087 2579689395 3200746765 2721119143 3639500427 1065592276 4082921600 1051979157} B = {4 4082921600 1051979157 231375477 1038366037 679464162 2666666667 248867213 2548397013} B = {4 248867213 2548397013 4113237559 2430127360 2803954977 565287424 3693372790 319518432} CGAL error: precondition violation! _expression_ : comp_f(object, nodeP->object) != LARGER File : C:\del64\CGAL 5.01\include\CGAL/Multiset.h Line : 2131 Explanation: Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html
C:\del64\CGAL-5.0.1\examples\Arrangement_on_surface_2\build\Debug\Bezier_curves.exe (process 5928) exited with code -1. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . . |
- [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Jeb Gaither, 07/01/2020
- Re: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Efi Fogel, 07/02/2020
- RE: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Jeb Gaither, 07/03/2020
- Re: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Efi Fogel, 07/05/2020
- Re: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Carlos Rabelo, 07/05/2020
- Re: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Efi Fogel, 07/05/2020
- RE: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Jeb Gaither, 07/03/2020
- Re: [cgal-discuss] Precondition Violations Using CGAL Bezier Curves Arrangement, Efi Fogel, 07/02/2020
Archive powered by MHonArc 2.6.19+.