Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] About Bezier curves in Arrangement

Subject: CGAL users discussion list

List archive

[cgal-discuss] About Bezier curves in Arrangement


Chronological Thread 
  • From: stzpz <>
  • To:
  • Subject: [cgal-discuss] About Bezier curves in Arrangement
  • Date: Wed, 26 Jan 2011 08:26:47 -0800 (PST)


Hello,

I am willing to get the point location of a Bezier curves Arrangement, so I
use Arr_Bezier_curve_traits_2 along with Arr_curve_data_traits_2 to
construct the arrangement with auxiliary data (curve number) attached with
each Bezier curve. And then I perform the point location function to get the
outer connected boundaries of the point. Everything is fine except that the
auxiliary data in the returning boundaries are incorrect.

I use outer_ccb() to get the outer boundaries of the face, then use
curve().supporting_curve() to get the original bezier curves with auxiliary
data. The data in Bezier curves are correct. However, the auxiliary data
corresponding with them are in correct. Here is the code:

// =================== CODE BEGIN =====================
#include <CGAL/basic.h>
#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/Arr_curve_data_traits_2.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/to_rational.h>
#include <list>
using namespace std;

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_org_2;
typedef Traits_org_2::Curve_2 Bezier_curve_2;

typedef unsigned int CurveNumber;
typedef CGAL::Arr_curve_data_traits_2<Traits_org_2, CurveNumber> Traits_2;

typedef Traits_2::Curve_2 Bezier_curve_num_2;
typedef Traits_2::Point_2
Point_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
typedef CGAL::Arr_walk_along_line_point_location<Arrangement_2> Naive_pl;

#define TORAT(x) (CGAL::to_rational<Rational>((x)))

void point_loc(Arrangement_2 *arr) {
Naive_pl pl(*arr);

// this point is inside the face
Point_2 p(TORAT(50), TORAT(40));

CGAL::Object obj = pl.locate(p);
Arrangement_2::Face_const_handle f;

if (CGAL::assign(f, obj)) {
if(!f->is_unbounded()) {
Arrangement_2::Ccb_halfedge_const_circulator bound_circ =
f->outer_ccb();

// first sub curve
Bezier_curve_num_2 curr_curve_num =
bound_circ->curve().supporting_curve();
Bezier_curve_2 curr_curve = curr_curve_num;

// ================ the result is INCORRECT of the next line
===================
CurveNumber curve_num = curr_curve_num.data();
cout<<"current curve num: "<<curve_num<<endl;
//
==================================================================
}
}
}

int main (int argc, char *argv[]) {
const char *filename = (argc > 1) ? argv[1] : "test5.dat";
std::ifstream in_file (filename);

int n_curves;
std::list<Bezier_curve_num_2> curves;
Bezier_curve_2 B;
int k;

in_file >> n_curves;
for (k = 0; k < n_curves; k++) {
in_file >> B;
Bezier_curve_num_2 bb(B, k);
curves.push_back (bb);
}

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

Arrangement_2::Edge_iterator eit;
for(eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) {
// ============= this result is CORRECT ==============
int num = eit->curve().data();
std::cout<<"Current curve number:"<<num<<std::endl;
// =============================================
}

point_loc(&arr);

return 0;
}
// =================== CODE END =====================
The data file test5.dat is in below
=================== DATA BEGIN =====================
3
2 0 0 100 100
2 20 80 100 0
2 -10 14 120 40
=================== DATA END ======================

Could anybody help me to find out how to get the correct auxiliary data in
the returning boundaries constructed by point location algorithm?


Besides, it seems that Arr_Bezier_curves_traits_2 cannot handle some special
case of curves like horizontal line segments. For example, using the code
above and another data file below,
=================== DATA BEGIN =====================
3
2 0 0 100 0
2 30 -20 30 80
2 100 -15 -20 75
=================== DATA END ======================
the program will terminate with assertion fails in line 770 of
Bezier_curve_2.h when inserting bezier curves into arrangement. Is it a bug
and how to fix it?


Does anyone know how to solve them? Thanks very much!

Sincerely yours,

Stzpz

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/About-Bezier-curves-in-Arrangement-tp3238384p3238384.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page