mirror of https://github.com/CGAL/cgal
Various fixes/workarounds to fix crashing in algebraic traits arrangements.
This commit is contained in:
parent
2fc1e22a23
commit
d285a87d87
|
|
@ -631,11 +631,23 @@ on_actionOpen_triggered( )
|
|||
QRectF bb = agi->boundingRect( );
|
||||
QGraphicsView* view = currentTab->getView( );
|
||||
std::cout << bb.left( ) << " " << bb.bottom( ) << ", " << bb.right( ) << " " << bb.top( ) << std::endl;
|
||||
if ( std::isinf(bb.left( )) ||
|
||||
std::isinf(bb.right( )) ||
|
||||
std::isinf(bb.top( )) ||
|
||||
std::isinf(bb.bottom( )) )
|
||||
{
|
||||
std::cout << "unbounded; using default bb" << std::endl;
|
||||
bb = QRectF( -100, -100, 200, 200 );
|
||||
view->setSceneRect( bb );
|
||||
}
|
||||
else
|
||||
{
|
||||
view->fitInView( bb, ::Qt::KeepAspectRatio );
|
||||
view->setSceneRect( bb );
|
||||
}
|
||||
#if 0
|
||||
view->centerOn( bb.center( ) );
|
||||
#endif
|
||||
view->fitInView( bb, ::Qt::KeepAspectRatio );
|
||||
view->setSceneRect( bb );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -197,7 +197,16 @@ ArrangementGraphicsItem< Arr_, ArrTraits >::
|
|||
paint( QPainter* painter, CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits )
|
||||
{
|
||||
painter->setPen( this->verticesPen );
|
||||
this->painterostream = ArrangementPainterOstream< Traits >( painter, this->boundingRect( ) );
|
||||
QRectF clipRect = this->boundingRect( );
|
||||
if ( std::isinf(clipRect.left( )) ||
|
||||
std::isinf(clipRect.right( )) ||
|
||||
std::isinf(clipRect.top( )) ||
|
||||
std::isinf(clipRect.bottom( )) )
|
||||
{
|
||||
clipRect = this->getViewportRect( );
|
||||
}
|
||||
|
||||
this->painterostream = ArrangementPainterOstream< Traits >( painter, clipRect );
|
||||
this->painterostream.setScene( this->scene );
|
||||
|
||||
for ( Vertex_iterator it = this->arr->vertices_begin( ); it != this->arr->vertices_end( ); ++it )
|
||||
|
|
@ -270,8 +279,9 @@ updateBoundingBox( CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits )
|
|||
}
|
||||
else
|
||||
{
|
||||
std::pair< double, double > approx = this->arr->vertices_begin( )->point( ).to_double( );
|
||||
this->bb = CGAL::Bbox_2( approx.first, approx.second, approx.first, approx.second );
|
||||
//std::pair< double, double > approx = this->arr->vertices_begin( )->point( ).to_double( );
|
||||
//this->bb = CGAL::Bbox_2( approx.first, approx.second, approx.first, approx.second );
|
||||
this->bb = CGAL::Bbox_2( 0, 0, 0, 0 );
|
||||
this->bb_initialized = true;
|
||||
}
|
||||
typename Traits::Make_x_monotone_2 make_x_monotone_2 = traits.make_x_monotone_2_object( );
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ public: // constructors
|
|||
public: // methods
|
||||
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve )
|
||||
{
|
||||
std::cout << "paint curve stub (alg traits)" << std::endl;
|
||||
//std::cout << "paint curve stub (alg traits)" << std::endl;
|
||||
typedef Curve_renderer_facade<CKvA_2> Facade;
|
||||
typedef std::pair< int, int > Coord_2;
|
||||
typedef std::vector< Coord_2 > Coord_vec_2;
|
||||
|
|
@ -826,6 +826,7 @@ public: // methods
|
|||
vit++;
|
||||
coord = QPoint( vit->first, vit->second );
|
||||
qpt = view->mapToScene( coord );
|
||||
//std::cout << vit->first << " " << vit->second << std::endl;
|
||||
}
|
||||
this->qp->drawPath( path );
|
||||
|
||||
|
|
@ -854,7 +855,7 @@ public: // methods
|
|||
{
|
||||
typedef Curve_renderer_facade<CKvA_2> Facade;
|
||||
std::pair< int, int > coord;
|
||||
std::cout << "draw point stub" << std::endl;
|
||||
//std::cout << "draw point stub" << std::endl;
|
||||
|
||||
this->setupFacade( );
|
||||
|
||||
|
|
@ -863,7 +864,7 @@ public: // methods
|
|||
}
|
||||
else
|
||||
{
|
||||
std::cout << coord.first << " " << coord.second << std::endl;
|
||||
//std::cout << coord.first << " " << coord.second << std::endl;
|
||||
QPoint coords( coord.first, coord.second );
|
||||
QGraphicsView* view = this->scene->views( ).first( );
|
||||
QPointF qpt = view->mapToScene( coords );
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widge
|
|||
painter->setPen( QPen( ::Qt::red, 0. ) );
|
||||
QRectF clippingRectangle = this->viewportRect( );
|
||||
this->painterOstream = ArrangementPainterOstream< Traits >( painter, clippingRectangle );
|
||||
this->painterOstream.setScene( this->getScene( ) );
|
||||
for ( int i = 0; i < this->curves.size( ); ++i )
|
||||
{
|
||||
X_monotone_curve_2 curve = this->curves[ i ];
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ protected:
|
|||
template < class CircularKernel >
|
||||
void updateEnvelope( bool lower, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits );
|
||||
|
||||
template < class Coefficient_ >
|
||||
void updateEnvelope( bool lower, CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits );
|
||||
|
||||
Construct_x_monotone_subcurve_2< Traits > construct_x_monotone_subcurve_2;
|
||||
Arrangement* arr;
|
||||
CGAL::Qt::CurveGraphicsItem< Traits >* lowerEnvelope;
|
||||
|
|
@ -272,6 +275,14 @@ updateEnvelope( bool lower, CGAL::Arr_circular_arc_traits_2< CircularKernel > tr
|
|||
envelopeToUpdate->modelChanged( );
|
||||
}
|
||||
|
||||
template < class Arr_, class Traits >
|
||||
template < class Coefficient_ >
|
||||
void
|
||||
EnvelopeCallback< Arr_, Traits >::
|
||||
updateEnvelope( bool lower, CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits )
|
||||
{
|
||||
std::cout << "alg seg envelope stub" << std::endl;
|
||||
}
|
||||
|
||||
template < class Arr_, class Traits >
|
||||
void
|
||||
|
|
|
|||
|
|
@ -440,6 +440,11 @@ public:
|
|||
return this->operator()( curve, x, this->traits, category );
|
||||
}
|
||||
|
||||
double approx( const X_monotone_curve_2& curve, const CoordinateType& x )
|
||||
{
|
||||
return CGAL::to_double( (*this)( curve, x ) );
|
||||
}
|
||||
|
||||
protected:
|
||||
template < class TTraits >
|
||||
CoordinateType operator() ( const X_monotone_curve_2& curve, const CoordinateType& x, TTraits traits_, CGAL::Arr_oblivious_side_tag )
|
||||
|
|
@ -495,6 +500,7 @@ protected:
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
Traits traits;
|
||||
Intersect_2 intersectCurves;
|
||||
|
|
@ -543,6 +549,11 @@ public:
|
|||
return res;
|
||||
}
|
||||
|
||||
double approx( const X_monotone_curve_2& curve, const FT& x )
|
||||
{
|
||||
return CGAL::to_double( (*this)( curve, x ) );
|
||||
}
|
||||
|
||||
// FIXME: inexact projection
|
||||
Root_of_2 operator() ( const X_monotone_curve_2& curve, const Root_of_2& x )
|
||||
{
|
||||
|
|
@ -550,6 +561,11 @@ public:
|
|||
return this->operator()( curve, approx );
|
||||
}
|
||||
|
||||
double approx( const X_monotone_curve_2& curve, const Root_of_2& x )
|
||||
{
|
||||
return CGAL::to_double( (*this)( curve, x ) );
|
||||
}
|
||||
|
||||
protected:
|
||||
Traits traits;
|
||||
Intersect_2 intersectCurves;
|
||||
|
|
@ -575,8 +591,39 @@ public:
|
|||
X_monotone_curve_2 c2 = this->makeVerticalLine( x );
|
||||
intersect( curve, c2, oi );
|
||||
std::pair< Point_2, Multiplicity > res;
|
||||
CGAL::assign( res, o ); // TODO: handle failure case
|
||||
return res.first.y( );
|
||||
if ( CGAL::assign( res, o ) ) // TODO: handle failure case
|
||||
{
|
||||
Point_2 p = res.first;
|
||||
std::cout << "approx y: " << p.to_double( ).second << std::endl;
|
||||
CoordinateType coord = p.y( );
|
||||
return coord;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: vertical projection failed" << std::endl;
|
||||
return CoordinateType( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
double approx( const X_monotone_curve_2& curve, const CoordinateType& x )
|
||||
{
|
||||
CGAL::Object o;
|
||||
CGAL::Oneset_iterator< CGAL::Object > oi( o );
|
||||
Intersect_2 intersect = traits.intersect_2_object( );
|
||||
X_monotone_curve_2 c2 = this->makeVerticalLine( x );
|
||||
intersect( curve, c2, oi );
|
||||
std::pair< Point_2, Multiplicity > res;
|
||||
if ( CGAL::assign( res, o ) ) // TODO: handle failure case
|
||||
{
|
||||
Point_2 p = res.first;
|
||||
std::pair< double, double > tmp = p.to_double();
|
||||
return tmp.second;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: vertical projection failed" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ highlightPointLocation( QGraphicsSceneMouseEvent* event )
|
|||
Arr_compute_y_at_x_2< Traits > compute_y_at_x_2;
|
||||
compute_y_at_x_2.setScene( this->getScene( ) );
|
||||
CoordinateType x( this->queryPt.x( ) );
|
||||
double yApprox = CGAL::to_double( compute_y_at_x_2( halfedge->curve( ), x ) );
|
||||
double yApprox = CGAL::to_double( compute_y_at_x_2.approx( halfedge->curve( ), x ) );
|
||||
FT yInt( yApprox );
|
||||
Kernel_point_2 p2( this->queryPt.x( ), yInt );
|
||||
Segment_2 seg( this->queryPt, p2 );
|
||||
|
|
|
|||
Loading…
Reference in New Issue