mirror of https://github.com/CGAL/cgal
Merge branch 'fix-deprecations-in-demo' into Aos_2-polyline_upgrade-fub
This commit is contained in:
commit
02c9bf8333
|
|
@ -313,9 +313,30 @@ protected:
|
|||
{
|
||||
if (!f->is_unbounded()) // f is not the unbounded face
|
||||
{
|
||||
typedef typename CGAL::Arr_polyline_traits_2<Kernel_> Arr_poly_traits;
|
||||
typedef typename Arr_poly_traits::Compare_endpoints_xy_2 Comp_end_pts_2;
|
||||
typedef typename Arr_poly_traits::Construct_min_vertex_2 Poly_const_min_v;
|
||||
typedef typename Arr_poly_traits::Construct_max_vertex_2 Poly_const_max_v;
|
||||
|
||||
// Obtain a polyline traits class and construct the needed functors
|
||||
Arr_poly_traits poly_tr;
|
||||
Comp_end_pts_2 comp_end_pts = poly_tr.compare_endpoints_xy_2_object();
|
||||
Poly_const_min_v poly_const_min_v=poly_tr.construct_min_vertex_2_object();
|
||||
Poly_const_max_v poly_const_max_v=poly_tr.construct_max_vertex_2_object();
|
||||
|
||||
// Construct needed functors from the segment traits
|
||||
typedef typename Arr_poly_traits::Segment_traits_2 Segment_traits;
|
||||
typedef typename Segment_traits::Construct_min_vertex_2 Seg_const_min_v;
|
||||
typedef typename Segment_traits::Construct_max_vertex_2 Seg_const_max_v;
|
||||
Seg_const_min_v construct_min_v = poly_tr.segment_traits_2()->
|
||||
construct_min_vertex_2_object();
|
||||
Seg_const_max_v construct_max_v = poly_tr.segment_traits_2()->
|
||||
construct_max_vertex_2_object();
|
||||
|
||||
// Iterator of the segments of an x-monotone polyline
|
||||
typename X_monotone_curve_2::Segment_const_iterator seg_it;
|
||||
|
||||
QVector< QPointF > pts; // holds the points of the polygon
|
||||
typename X_monotone_curve_2::const_iterator pt_itr;
|
||||
typename X_monotone_curve_2::const_reverse_iterator pt_rev_itr;
|
||||
X_monotone_curve_2 cv;
|
||||
|
||||
/* running with around the outer of the face and generate from it
|
||||
|
|
@ -324,29 +345,49 @@ protected:
|
|||
Ccb_halfedge_circulator cc = f->outer_ccb();
|
||||
do {
|
||||
cv = cc->curve();
|
||||
bool curve_has_same_direction =
|
||||
( *(cc->curve().begin()) == cc->source()->point() );
|
||||
if ( curve_has_same_direction )
|
||||
{
|
||||
for( pt_itr = cv.begin() , ++pt_itr ; pt_itr != cv.end(); ++pt_itr)
|
||||
|
||||
// Determine the direction of cv (left-to-right or right-to-left)
|
||||
Comparison_result dir = comp_end_pts(cv);
|
||||
|
||||
for (seg_it = cv.begin_segments();
|
||||
seg_it != cv.end_segments() ; ++seg_it)
|
||||
{
|
||||
double x = CGAL::to_double((*pt_itr).x());
|
||||
double y = CGAL::to_double((*pt_itr).y());
|
||||
if (dir == SMALLER)
|
||||
{
|
||||
// cv is directed from left-to-right
|
||||
// Adding the left-min vertex of the current segment
|
||||
double x = CGAL::to_double((construct_min_v(*seg_it)).x());
|
||||
double y = CGAL::to_double((construct_min_v(*seg_it)).y());
|
||||
QPointF coord_source(x , y);
|
||||
pts.push_back(coord_source );
|
||||
}
|
||||
else
|
||||
{
|
||||
// cv is directed from right-to-left
|
||||
// Adding the right-max vertex of the current segment
|
||||
double x = CGAL::to_double((construct_max_v(*seg_it)).x());
|
||||
double y = CGAL::to_double((construct_max_v(*seg_it)).y());
|
||||
QPointF coord_source(x , y);
|
||||
pts.push_back(coord_source );
|
||||
}
|
||||
}
|
||||
|
||||
if (dir == SMALLER)
|
||||
{
|
||||
// Add the right-most point of cv
|
||||
double x = CGAL::to_double((poly_const_max_v(cv)).x());
|
||||
double y = CGAL::to_double((poly_const_max_v(cv)).y());
|
||||
QPointF coord_source(x , y);
|
||||
pts.push_back(coord_source );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (pt_rev_itr = cv.rbegin() , ++pt_rev_itr; pt_rev_itr != cv.rend();
|
||||
++pt_rev_itr)
|
||||
{
|
||||
double x = CGAL::to_double((*pt_rev_itr).x());
|
||||
double y = CGAL::to_double((*pt_rev_itr).y());
|
||||
// Add the left-most point of cv
|
||||
double x = CGAL::to_double((poly_const_min_v(cv)).x());
|
||||
double y = CGAL::to_double((poly_const_min_v(cv)).y());
|
||||
QPointF coord_source(x , y);
|
||||
pts.push_back(coord_source );
|
||||
}
|
||||
}
|
||||
//created from the outer boundary of the face
|
||||
} while (++cc != f->outer_ccb());
|
||||
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ class GraphicsViewCurveInput< CGAL::Arr_polyline_traits_2< SegmentTraits > >:
|
|||
{
|
||||
public:
|
||||
typedef CGAL::Arr_polyline_traits_2< SegmentTraits > Traits;
|
||||
typedef typename Traits::Construct_curve_2 Construct_polyline;
|
||||
typedef typename Traits::Curve_2 Curve_2;
|
||||
typedef typename SegmentTraits::Kernel Kernel;
|
||||
typedef typename Kernel::Point_2 Point_2;
|
||||
|
|
@ -199,6 +200,10 @@ protected:
|
|||
|
||||
void mousePressEvent( QGraphicsSceneMouseEvent* event )
|
||||
{
|
||||
// Obtain a functor for the construction of polylines
|
||||
Traits poly_tr;
|
||||
Construct_polyline construct_poly = poly_tr.construct_curve_2_object();
|
||||
|
||||
Point_2 clickedPoint = this->snapPoint( event );
|
||||
if ( this->points.empty( ) )
|
||||
{ // first
|
||||
|
|
@ -234,7 +239,8 @@ protected:
|
|||
delete this->polylineGuide[ i ];
|
||||
}
|
||||
this->polylineGuide.clear( );
|
||||
Curve_2 res( this->points.begin( ), this->points.end( ) );
|
||||
Curve_2 res =
|
||||
construct_poly( this->points.begin( ), this->points.end( ) );
|
||||
this->points.clear( );
|
||||
|
||||
emit generate( CGAL::make_object( res ) );
|
||||
|
|
@ -423,10 +429,10 @@ protected:
|
|||
}
|
||||
this->polylineGuide.clear( );
|
||||
|
||||
double x1 = CGAL::to_double( this->points[ 0 ].x( ) );
|
||||
double y1 = CGAL::to_double( this->points[ 0 ].y( ) );
|
||||
double x2 = CGAL::to_double( this->points[ 1 ].x( ) );
|
||||
double y2 = CGAL::to_double( this->points[ 1 ].y( ) );
|
||||
double x1 = CGAL::to_double( this->points[ 0 ].x( ) );
|
||||
double y1 = CGAL::to_double( this->points[ 0 ].y( ) );
|
||||
double x2 = CGAL::to_double( this->points[ 1 ].x( ) );
|
||||
double y2 = CGAL::to_double( this->points[ 1 ].y( ) );
|
||||
Curve_2 res = Curve_2( Rat_segment_2( Rat_point_2( x1, y1 ),
|
||||
Rat_point_2( x2, y2 ) ) );
|
||||
// std::cout << "res is " << ( (res.is_valid( ))? "" : "not ")
|
||||
|
|
@ -445,10 +451,10 @@ protected:
|
|||
this->circleItem = NULL;
|
||||
|
||||
// std::cout << "TODO: Add the circle" << std::endl;
|
||||
double x1 = CGAL::to_double( this->points[ 0 ].x( ) );
|
||||
double y1 = CGAL::to_double( this->points[ 0 ].y( ) );
|
||||
double x2 = CGAL::to_double( this->points[ 1 ].x( ) );
|
||||
double y2 = CGAL::to_double( this->points[ 1 ].y( ) );
|
||||
double x1 = CGAL::to_double( this->points[ 0 ].x( ) );
|
||||
double y1 = CGAL::to_double( this->points[ 0 ].y( ) );
|
||||
double x2 = CGAL::to_double( this->points[ 1 ].x( ) );
|
||||
double y2 = CGAL::to_double( this->points[ 1 ].y( ) );
|
||||
double sq_rad = CGAL::square(x2 - x1) + CGAL::square(y2 - y1);
|
||||
Curve_2 res = Curve_2( Rat_circle_2( Rat_point_2( x1, y1 ), sq_rad ) );
|
||||
|
||||
|
|
@ -547,7 +553,7 @@ protected:
|
|||
this->points.clear( );
|
||||
this->pointsGraphicsItem.clear( );
|
||||
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "Points don't specify a valid conic. Try again!"
|
||||
|
|
@ -577,7 +583,7 @@ protected:
|
|||
ConicType conicType;
|
||||
};
|
||||
|
||||
// class GraphicsViewCurveInput< CGAL::Arr_conic_traits_2<
|
||||
// class GraphicsViewCurveInput< CGAL::Arr_conic_traits_2<
|
||||
// RatKernel, AlgKernel, NtTraits > >
|
||||
|
||||
/**
|
||||
|
|
@ -897,7 +903,7 @@ public:
|
|||
Point_2 res = this->toArrPoint( pt );
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
Traits traits;
|
||||
Converter< Kernel > convert;
|
||||
|
|
|
|||
|
|
@ -339,28 +339,27 @@ public:
|
|||
typedef typename Traits::Curve_2 Curve_2;
|
||||
typedef typename Curve_2::const_iterator Curve_const_iterator;
|
||||
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
|
||||
typedef typename Curve_2::Segment_const_iterator Seg_const_it;
|
||||
|
||||
double operator() ( const Point_2& p, const X_monotone_curve_2& c ) const
|
||||
{
|
||||
Curve_const_iterator ps = c.begin();
|
||||
Curve_const_iterator pt = ps; pt++;
|
||||
Seg_const_it seg_it_s = c.begin_segments();
|
||||
|
||||
bool first = true;
|
||||
FT min_dist = 0;
|
||||
|
||||
while ( pt != c.end() )
|
||||
{
|
||||
const Point_2& source = *ps;
|
||||
const Point_2& target = *pt;
|
||||
Segment_2 seg( source, target );
|
||||
FT dist = this->squared_distance( p, seg );
|
||||
|
||||
if ( first || dist < min_dist )
|
||||
while (seg_it_s != c.end_segments())
|
||||
{
|
||||
first = false;
|
||||
min_dist = dist;
|
||||
Segment_2 seg = *seg_it_s;
|
||||
FT dist = this->squared_distance( p, seg );
|
||||
|
||||
if ( first || dist < min_dist )
|
||||
{
|
||||
first = false;
|
||||
min_dist = dist;
|
||||
}
|
||||
seg_it_s++;
|
||||
}
|
||||
ps++; pt++;
|
||||
}
|
||||
|
||||
return CGAL::to_double( min_dist );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue