Working skeleton with algebraic segment traits

This commit is contained in:
Alex Tsui 2012-08-16 20:23:51 +00:00
parent 284cd602e2
commit 3ebb8ea23f
11 changed files with 377 additions and 344 deletions

View File

@ -58,6 +58,7 @@ makeTab( TraitsType tt )
Conic_arr* conic_arr;
Lin_arr* lin_arr;
Arc_arr* arc_arr;
Alg_seg_arr* alg_seg_arr;
CGAL::Object arr;
switch ( tt )
@ -93,6 +94,12 @@ makeTab( TraitsType tt )
arr = CGAL::make_object( arc_arr );
tabLabel = QString( "%1 - Circular Arc" ).arg( tabLabelCounter++ );
break;
case ALGEBRAIC_TRAITS:
alg_seg_arr = new Alg_seg_arr;
demoTab = new ArrangementDemoTab< Alg_seg_arr >( alg_seg_arr, 0 );
arr = CGAL::make_object( alg_seg_arr );
tabLabel = QString( "%1 - Algebraic" ).arg( tabLabelCounter++ );
break;
}
@ -656,7 +663,7 @@ on_actionNewTab_triggered( )
}
else if ( id == ALGEBRAIC_TRAITS )
{
std::cout << "makeTab for algebraic traits stub" << std::endl;
this->makeTab( ALGEBRAIC_TRAITS );
}
else
{

View File

@ -75,8 +75,9 @@ class ArrangementGraphicsItem : public ArrangementGraphicsItemBase
typedef typename Arrangement::Edge_iterator Edge_iterator;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Segment_2 Segment_2;
typedef typename Kernel::Point_2 Kernel_point_2;
typedef typename Traits::Point_2 Point_2;
//typedef typename Kernel::Segment_2 Segment_2;
public:
ArrangementGraphicsItem( Arrangement* t_ );
@ -89,12 +90,17 @@ public:
protected:
template < class TTraits >
void paint( QPainter* painter, TTraits traits );
template < class CircularKernel >
void paint( QPainter* painter, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits );
template < class Coefficient_ >
void paint( QPainter* painter, CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits );
//void cacheCurveBoundingRects( );
void updateBoundingBox( );
template < class TTraits >
void updateBoundingBox( TTraits traits );
template < class Coefficient_ >
void updateBoundingBox( CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits );
Arrangement* arr;
ArrangementPainterOstream< Traits > painterostream;
@ -131,23 +137,6 @@ ArrangementGraphicsItem< Arr_, ArrTraits >::paint(QPainter *painter,
QWidget * /*widget*/)
{
this->paint( painter, ArrTraits( ) );
#if 0
painter->setPen( this->verticesPen );
this->painterostream = ArrangementPainterOstream< Traits >( painter, this->boundingRect( ) );
this->painterostream.setScene( this->scene );
for ( Vertex_iterator it = this->arr->vertices_begin( ); it != this->arr->vertices_end( ); ++it )
{
Point_2 pt = it->point( );
this->painterostream << pt;
}
painter->setPen( this->edgesPen );
for ( Edge_iterator it = this->arr->edges_begin( ); it != this->arr->edges_end( ); ++it )
{
X_monotone_curve_2 curve = it->curve( );
this->painterostream << curve;
}
#endif
}
template < class Arr_, class ArrTraits >
@ -162,7 +151,8 @@ paint( QPainter* painter, TTraits traits )
for ( Vertex_iterator it = this->arr->vertices_begin( ); it != this->arr->vertices_end( ); ++it )
{
Point_2 pt = it->point( );
Point_2 p = it->point( );
Kernel_point_2 pt( p.x( ), p.y( ) );
this->painterostream << pt;
}
painter->setPen( this->edgesPen );
@ -179,7 +169,7 @@ void
ArrangementGraphicsItem< Arr_, ArrTraits >::
paint( QPainter* painter, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits )
{
typedef Point_2 Non_arc_point_2;
typedef Kernel_point_2 Non_arc_point_2;
typedef typename Traits::Point_2 Arc_point_2;
painter->setPen( this->verticesPen );
@ -200,11 +190,45 @@ paint( QPainter* painter, CGAL::Arr_circular_arc_traits_2< CircularKernel > trai
}
}
template < class Arr_, class ArrTraits >
template < class Coefficient_ >
void
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( ) );
this->painterostream.setScene( this->scene );
for ( Vertex_iterator it = this->arr->vertices_begin( ); it != this->arr->vertices_end( ); ++it )
{
Point_2 p = it->point( );
std::pair< double, double > approx = p.to_double( );
Kernel_point_2 pt( approx.first, approx.second );
this->painterostream << pt;
}
painter->setPen( this->edgesPen );
for ( Edge_iterator it = this->arr->edges_begin( ); it != this->arr->edges_end( ); ++it )
{
X_monotone_curve_2 curve = it->curve( );
this->painterostream << curve;
}
}
// We let the bounding box only grow, so that when vertices get removed
// the maximal bbox gets refreshed in the GraphicsView
template < class Arr_, class ArrTraits >
void
ArrangementGraphicsItem< Arr_, ArrTraits >::updateBoundingBox( )
{
this->updateBoundingBox( ArrTraits( ) );
}
template < class Arr_, class ArrTraits >
template < class TTraits >
void
ArrangementGraphicsItem< Arr_, ArrTraits >::updateBoundingBox( TTraits traits )
{
this->prepareGeometryChange( );
if ( this->arr->number_of_vertices( ) == 0 )
@ -231,6 +255,41 @@ ArrangementGraphicsItem< Arr_, ArrTraits >::updateBoundingBox( )
}
}
template < class Arr_, class ArrTraits >
template < class Coefficient_ >
void
ArrangementGraphicsItem< Arr_, ArrTraits >::
updateBoundingBox( CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits )
{
this->prepareGeometryChange( );
if ( this->arr->number_of_vertices( ) == 0 )
{
this->bb = Bbox_2( 0, 0, 0, 0 );
this->bb_initialized = false;
return;
}
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 );
this->bb_initialized = true;
}
typename Traits::Make_x_monotone_2 make_x_monotone_2 = traits.make_x_monotone_2_object( );
for ( Curve_iterator it = this->arr->curves_begin( );
it != this->arr->curves_end( );
++it )
{
std::vector< CGAL::Object > cvs;
make_x_monotone_2( *it, std::back_inserter( cvs ) );
for ( int i = 0 ; i < cvs.size( ); ++i )
{
X_monotone_curve_2 cv;
CGAL::assign( cv, cvs[ i ] );
this->bb = this->bb + cv.bbox( );
}
}
}
template < class Arr_, class ArrTraits >
void
ArrangementGraphicsItem< Arr_, ArrTraits >::modelChanged( )
@ -248,7 +307,6 @@ ArrangementGraphicsItem< Arr_, ArrTraits >::modelChanged( )
}
/**
* Why is this not being used?
Specialized methods:
updateBoundingBox
*/

View File

@ -762,6 +762,12 @@ public:
typedef typename Traits::Point_2 Point_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
public: // constructors
ArrangementPainterOstream( QPainter* p, QRectF clippingRectangle = QRectF( ) ):
Superclass( p, clippingRectangle )
{ }
public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve )
{
std::cout << "paint curve stub (alg traits)" << std::endl;

View File

@ -32,7 +32,8 @@ public:
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
//typedef typename Traits::Construct_x_monotone_curve_2 Construct_x_monotone_curve_2;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Point_2 Kernel_point_2;
typedef typename Traits::Point_2 Point_2;
typedef typename Kernel::Segment_2 Segment_2;
typedef typename Kernel::Ray_2 Ray_2;
typedef typename Kernel::Line_2 Line_2;
@ -141,7 +142,6 @@ updateEnvelope( bool lower, TTraits traits )
CGAL::upper_envelope_x_monotone_2( curves.begin( ), curves.end( ), diagram );
}
return;
typename Diagram_1::Edge_const_handle e = diagram.leftmost( );
typename Diagram_1::Vertex_const_handle v;
QRectF clipRect = this->viewportRect( );
@ -196,7 +196,7 @@ void
EnvelopeCallback< Arr_, Traits >::
updateEnvelope( bool lower, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits )
{
typedef Point_2 Non_arc_point_2;
typedef Kernel_point_2 Non_arc_point_2;
typedef typename Traits::Point_2 Arc_point_2;
CGAL::Qt::CurveGraphicsItem< Traits >* envelopeToUpdate;
if ( lower )

View File

@ -736,6 +736,11 @@ class GraphicsViewCurveInput< CGAL::Arr_algebraic_segment_traits_2< Coefficient_
public GraphicsViewCurveInputBase
{
public:
GraphicsViewCurveInput( QObject* parent ):
GraphicsViewCurveInputBase( parent )
{ }
};
} // namespace Qt

View File

@ -28,7 +28,7 @@ public:
typedef typename Arrangement::Induced_edge_iterator Induced_edge_iterator;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Kernel::Point_2 Point;
typedef typename Kernel::Point_2 Kernel_point_2;
typedef typename Kernel::Segment_2 Segment;
MergeEdgeCallback( Arrangement* arr_, QObject* parent_ );
@ -163,7 +163,7 @@ getNearestMergeableCurve( QGraphicsSceneMouseEvent* event )
{
// find the nearest curve to the cursor that is adjacent to a curve that
// can be merged with it
Point p = this->convert( event->scenePos( ) );
Kernel_point_2 p = this->convert( event->scenePos( ) );
double minDist = 0.0;
bool noneFound = true;
Halfedge_iterator nearestHei;
@ -209,7 +209,7 @@ getNearestMergeableCurve( Halfedge_handle h, QGraphicsSceneMouseEvent* event )
{
// find the nearest curve to the cursor that is adjacent to a curve that
// can be merged with it
Point p = this->convert( event->scenePos( ) );
Kernel_point_2 p = this->convert( event->scenePos( ) );
Halfedge_handle h1 = h->prev( );
Halfedge_handle h2 = h->next( );
Vertex_iterator source = h->source( );

View File

@ -41,7 +41,8 @@ public:
typedef typename Arrangement::Hole_const_iterator Hole_const_iterator;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Point_2 Kernel_point_2;
typedef typename Traits::Point_2 Point_2;
typedef typename Kernel::Segment_2 Segment_2;
typedef typename CGAL::Arr_trapezoid_ric_point_location< Arrangement > TrapezoidPointLocationStrategy;
typedef typename CGAL::Arr_simple_point_location< Arrangement > SimplePointLocationStrategy;
@ -59,15 +60,16 @@ protected:
void highlightPointLocation( QGraphicsSceneMouseEvent *event, CGAL::Arr_oblivious_side_tag );
void highlightPointLocation( QGraphicsSceneMouseEvent *event, CGAL::Arr_open_side_tag );
Face_const_handle getFace( const CGAL::Object& o );
CGAL::Object locate( const Point_2& point );
CGAL::Object locate( const Point_2& point, CGAL::Tag_false /*supportsLandmarks*/ );
CGAL::Object locate( const Point_2& point, CGAL::Tag_true /*doesNotSupportLandmarks*/ );
CGAL::Object locate( const Kernel_point_2& point );
CGAL::Object locate( const Kernel_point_2& point, CGAL::Tag_false /*supportsLandmarks*/ );
CGAL::Object locate( const Kernel_point_2& point, CGAL::Tag_true /*doesNotSupportLandmarks*/ );
using Callback::scene;
CGAL::Qt::Converter< Kernel > convert;
CGAL::Object pointLocationStrategy;
Arrangement* arr;
CGAL::Qt::CurveGraphicsItem< Traits >* highlightedCurves;
Arr_construct_point_2< Traits > toArrPoint;
}; // class PointLocationCallback
@ -126,87 +128,6 @@ highlightPointLocation( QGraphicsSceneMouseEvent* event )
{
typename Traits::Left_side_category category;
this->highlightPointLocation( event, category );
#if 0
Point_2 point = this->convert( event->scenePos( ) );
CGAL::Object pointLocationResult = this->locate( point );
Face_const_handle face = this->getFace( pointLocationResult );
this->highlightedCurves->clear( );
if ( ! face->is_unbounded( ) )
{ // it is an interior face; highlight its border
Ccb_halfedge_const_circulator cc = face->outer_ccb( );
do
{
X_monotone_curve_2 curve = cc->curve( );
this->highlightedCurves->insert( curve );
} while ( ++cc != face->outer_ccb( ) );
}
Hole_const_iterator hit;
Hole_const_iterator eit = face->holes_end( );
for ( hit = face->holes_begin( ); hit != eit; ++hit )
{ // highlight any holes inside this face
Ccb_halfedge_const_circulator cc = *hit;
do
{
X_monotone_curve_2 curve = cc->curve( );
this->highlightedCurves->insert( curve );
cc++;
}
while ( cc != *hit );
}
#endif
// TODO: highlight isolated vertices
#if 0
if (mode == MODE_POINT_LOCATION)
{
static_cast<CGAL::Qt_widget&>(*this) << CGAL::LineWidth(3);
Point_2 temp_p (pl_point.x(), pl_point.y());
CGAL::Object obj = locate(temp_p);
Face_const_handle f = get_face(obj);
/* more prudent color selection that selects the drawing color
according to my_prefrance. replaced setColor(Qt::yellow)*/
QColor my_preferance[4]= {Qt::yellow,Qt::green,Qt::red,Qt::blue};
setCorrectColor(f->color(),my_preferance, 4);
if (!f->is_unbounded()) // its an inside face
{
Ccb_halfedge_const_circulator cc = f->outer_ccb();
do
{
m_tab_traits.draw_xcurve(this , cc->curve() );
}
while (++cc != f->outer_ccb());
}
//color the holes of the located face
Holes_const_iterator hit, eit = f->holes_end();
for (hit = f->holes_begin(); hit != eit; ++hit)
{
Ccb_halfedge_const_circulator cc = *hit;
do
{
m_tab_traits.draw_xcurve(this , cc->curve() );
cc++;
}
while (cc != *hit);
}
//color isolated vertices
Isolated_vertex_const_iterator ivit = f->isolated_vertices_begin();
for (; ivit != f->isolated_vertices_end(); ++ivit)
{
static_cast<CGAL::Qt_widget&>(*this) << ivit->point();
}
static_cast<CGAL::Qt_widget&>(*this) << CGAL::LineWidth(m_line_width);
}
#endif
emit modelChanged( );
}
@ -216,7 +137,8 @@ void
PointLocationCallback< Arr_ >::
highlightPointLocation( QGraphicsSceneMouseEvent *event, CGAL::Arr_oblivious_side_tag )
{
Point_2 point = this->convert( event->scenePos( ) );
Kernel_point_2 point = this->convert( event->scenePos( ) );
CGAL::Object pointLocationResult = this->locate( point );
Face_const_handle face = this->getFace( pointLocationResult );
this->highlightedCurves->clear( );
@ -249,7 +171,7 @@ void
PointLocationCallback< Arr_ >::
highlightPointLocation( QGraphicsSceneMouseEvent *event, CGAL::Arr_open_side_tag )
{
Point_2 point = this->convert( event->scenePos( ) );
Kernel_point_2 point = this->convert( event->scenePos( ) );
CGAL::Object pointLocationResult = this->locate( point );
Face_const_handle face = this->getFace( pointLocationResult );
this->highlightedCurves->clear( );
@ -302,7 +224,7 @@ getFace( const CGAL::Object& obj )
template < class Arr_ >
CGAL::Object
PointLocationCallback< Arr_ >::
locate( const Point_2& point )
locate( const Kernel_point_2& point )
{
typename Supports_landmarks< Arrangement >::Tag supportsLandmarks;
return this->locate( point, supportsLandmarks );
@ -311,13 +233,16 @@ locate( const Point_2& point )
template < class Arr_ >
CGAL::Object
PointLocationCallback< Arr_ >::
locate( const Point_2& point, CGAL::Tag_true )
locate( const Kernel_point_2& pt, CGAL::Tag_true )
{
CGAL::Object pointLocationResult;
WalkAlongLinePointLocationStrategy* walkStrategy;
TrapezoidPointLocationStrategy* trapezoidStrategy;
SimplePointLocationStrategy* simpleStrategy;
LandmarksPointLocationStrategy* landmarksStrategy;
Point_2 point = this->toArrPoint( pt );
if ( CGAL::assign( walkStrategy, this->pointLocationStrategy ) )
{
pointLocationResult = walkStrategy->locate( point );
@ -340,12 +265,15 @@ locate( const Point_2& point, CGAL::Tag_true )
template < class Arr_ >
CGAL::Object
PointLocationCallback< Arr_ >::
locate( const Point_2& point, CGAL::Tag_false )
locate( const Kernel_point_2& pt, CGAL::Tag_false )
{
CGAL::Object pointLocationResult;
WalkAlongLinePointLocationStrategy* walkStrategy;
TrapezoidPointLocationStrategy* trapezoidStrategy;
SimplePointLocationStrategy* simpleStrategy;
Point_2 point = this->toArrPoint( pt );
if ( CGAL::assign( walkStrategy, this->pointLocationStrategy ) )
{
pointLocationResult = walkStrategy->locate( point );

View File

@ -46,6 +46,7 @@ public:
typedef typename Traits::Equal_2 Equal_2;
typedef typename Traits::Multiplicity Multiplicity;
typedef typename ArrTraitsAdaptor< Traits >::Point_2 Point_2;
typedef typename ArrTraitsAdaptor< Traits >::CoordinateType CoordinateType;
typedef typename Kernel::Segment_2 Segment_2;
typedef typename Kernel::FT FT;
@ -58,13 +59,19 @@ public:
protected:
void mousePressEvent( QGraphicsSceneMouseEvent *event );
void mouseMoveEvent( QGraphicsSceneMouseEvent *event );
virtual Point_2 snapPoint( QGraphicsSceneMouseEvent *event );
template < class TTraits >
Point_2 snapPoint( QGraphicsSceneMouseEvent *event, TTraits traits );
template < class CircularKernel >
Point_2 snapPoint( QGraphicsSceneMouseEvent* event, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits );
template < class TTraits >
void splitEdges( const Point_2& pt, TTraits traits );
template < class CircularKernel >
void splitEdges( const Point_2& pt, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits );
template < class Coefficient_ >
void splitEdges( const Point_2& pt, CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits );
template < class TTraits >
void updateGuide( const Point_2& pt, TTraits traits );
@ -197,6 +204,15 @@ splitEdges( const Point_2& clickedPoint, CGAL::Arr_circular_arc_traits_2< Circul
std::cout << "Circular arc split edges stub" << std::endl;
}
template < class Arr_ >
template < class Coefficient_ >
void
SplitEdgeCallback< Arr_ >::
splitEdges( const Point_2& clickedPoint, CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > traits )
{
std::cout << "Algebraic segment split edges stub" << std::endl;
}
template < class Arr_ >
void
SplitEdgeCallback< Arr_ >::
@ -204,16 +220,6 @@ mouseMoveEvent( QGraphicsSceneMouseEvent* event )
{
Point_2 clickedPoint = this->snapPoint( event );
this->updateGuide( clickedPoint, this->traits );
#if 0
if ( this->hasFirstPoint )
{ // provide visual feedback for where the split line is
Point_2 currentPoint = clickedPoint;
Segment_2 currentSegment( this->p1, currentPoint );
QLineF qSegment = this->convert( currentSegment );
this->segmentGuide.setLine( qSegment );
emit modelChanged( );
}
#endif
}
template < class Arr_ >
@ -225,7 +231,9 @@ updateGuide( const Point_2& clickedPoint, TTraits traits )
if ( this->hasFirstPoint )
{ // provide visual feedback for where the split line is
Point_2 currentPoint = clickedPoint;
Segment_2 currentSegment( this->p1, currentPoint );
typename Kernel::Point_2 pt1( CGAL::to_double( this->p1.x( ) ), CGAL::to_double( this->p1.y( ) ) );
typename Kernel::Point_2 pt2( CGAL::to_double( currentPoint.x( ) ), CGAL::to_double( currentPoint.y( ) ) );
Segment_2 currentSegment( pt1, pt2 );
QLineF qSegment = this->convert( currentSegment );
this->segmentGuide.setLine( qSegment );
emit modelChanged( );
@ -254,6 +262,15 @@ template < class Arr_ >
typename SplitEdgeCallback< Arr_ >::Point_2
SplitEdgeCallback< Arr_ >::
snapPoint( QGraphicsSceneMouseEvent* event )
{
return this->snapPoint( event, Traits( ) );
}
template < class Arr_ >
template < class TTraits >
typename SplitEdgeCallback< Arr_ >::Point_2
SplitEdgeCallback< Arr_ >::
snapPoint( QGraphicsSceneMouseEvent *event, TTraits traits )
{
if ( this->snapToGridEnabled )
{
@ -264,8 +281,32 @@ snapPoint( QGraphicsSceneMouseEvent* event )
return this->snapToVertexStrategy.snapPoint( event );
}
else
{ // fallback "analog" selection
typename Kernel::Point_2 pt = this->convert( event->scenePos( ) );
CoordinateType x( pt.x( ) );
CoordinateType y( pt.y( ) );
return Point_2( x, y );
}
}
template < class Arr_ >
template < class CircularKernel >
typename SplitEdgeCallback< Arr_ >::Point_2
SplitEdgeCallback< Arr_ >::
snapPoint( QGraphicsSceneMouseEvent* event, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits )
{
if ( this->snapToGridEnabled )
{
return this->convert( event->scenePos( ) );
return this->snapToGridStrategy.snapPoint( event );
}
if ( this->snappingEnabled )
{
return this->snapToVertexStrategy.snapPoint( event );
}
else
{ // fallback "analog" selection
typename Kernel::Point_2 pt = this->convert( event->scenePos( ) );
return Point_2( pt );
}
}

View File

@ -77,9 +77,11 @@ struct Supports_landmarks< Arr_, true >
/**
Support for new ArrTraits should specify types:
* Kernel
* Kernel - a not-necessarily-exact kernel to represent the arrangement
graphically. We'll use the Point_2 type provided by this kernel for computing
distances
* Point_2 - the point type used in the particular arrangement
* Coordinate_1 - the coordinate type used by the point type
* CoordinateType - the coordinate type used by the point type
*/
template < class ArrTraits >
class ArrTraitsAdaptor
@ -92,6 +94,7 @@ public:
typedef Kernel_ Kernel;
typedef CGAL::Arr_segment_traits_2< Kernel > ArrTraits;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::FT CoordinateType;
};
template < class Kernel_ >
@ -101,6 +104,7 @@ public:
typedef Kernel_ Kernel;
typedef CGAL::Arr_linear_traits_2< Kernel > ArrTraits;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::FT CoordinateType;
};
template < class SegmentTraits >
@ -110,6 +114,7 @@ public:
typedef CGAL::Arr_polyline_traits_2< SegmentTraits > ArrTraits;
typedef typename SegmentTraits::Kernel Kernel;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::FT CoordinateType;
};
template < class CircularKernel >
@ -119,6 +124,7 @@ public:
typedef CGAL::Arr_circular_arc_traits_2< CircularKernel > ArrTraits;
typedef CircularKernel Kernel;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::Root_of_2 CoordinateType;
};
template < class RatKernel, class AlgKernel, class NtTraits >
@ -128,6 +134,7 @@ public:
typedef CGAL::Arr_conic_traits_2< RatKernel, AlgKernel, NtTraits > ArrTraits;
typedef AlgKernel Kernel;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::FT CoordinateType;
};
template < class Coefficient_ >
@ -137,6 +144,8 @@ public:
typedef Coefficient_ Coefficient;
typedef typename CGAL::Arr_algebraic_segment_traits_2< Coefficient > ArrTraits;
typedef typename ArrTraits::Point_2 Point_2; // CKvA_2
typedef typename ArrTraits::Algebraic_real_1 CoordinateType;
typedef CGAL::Cartesian< typename ArrTraits::Bound > Kernel;
//typedef typename ArrTraits::CKvA_2 Kernel;
};
@ -144,7 +153,7 @@ template < class ArrTraits >
class Compute_squared_distance_2_base : public QGraphicsSceneMixin
{
public:
typedef CGAL::Cartesian< double > CoordKernel;
typedef CGAL::Cartesian< double > InexactKernel;
public: // ctors
Compute_squared_distance_2_base( )
@ -160,7 +169,7 @@ public: // methods
protected: // fields
typename Kernel::Compute_squared_distance_2 squared_distance;
CoordKernel::Compute_squared_distance_2 squaredDistance;
InexactKernel::Compute_squared_distance_2 squaredDistance;
};
template < class ArrTraits >
@ -386,13 +395,34 @@ public: // methods
}
};
template < class Coefficient_ >
class Compute_squared_distance_2< CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > > :
public Compute_squared_distance_2_base< CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > >
{
public:
typedef Coefficient_ Coefficient;
typedef CGAL::Arr_algebraic_segment_traits_2< Coefficient > Traits;
typedef typename Traits::Bound FT; // unused
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Kernel::Point_2 Point_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
public:
double operator() ( const Point_2& p, const X_monotone_curve_2& c ) const
{
double res = 0.0;
return res;
}
};
template < class ArrTraits >
class Arr_compute_y_at_x_2 : public QGraphicsSceneMixin
{
public:
typedef ArrTraits Traits;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Kernel::FT FT;
typedef typename ArrTraitsAdaptor< Traits >::CoordinateType CoordinateType;
//typedef typename Kernel::FT FT;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Line_2 Line_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
@ -404,7 +434,7 @@ public:
intersectCurves( this->traits.intersect_2_object( ) )
{ }
FT operator() ( const X_monotone_curve_2& curve, const FT& x )
CoordinateType operator() ( const X_monotone_curve_2& curve, const CoordinateType& x )
{
typename Traits::Left_side_category category;
return this->operator()( curve, x, this->traits, category );
@ -412,14 +442,14 @@ public:
protected:
template < class TTraits >
FT operator() ( const X_monotone_curve_2& curve, const FT& x, TTraits traits_, CGAL::Arr_oblivious_side_tag )
CoordinateType operator() ( const X_monotone_curve_2& curve, const CoordinateType& x, TTraits traits_, CGAL::Arr_oblivious_side_tag )
{
typename TTraits::Construct_x_monotone_curve_2 construct_x_monotone_curve_2 =
traits_.construct_x_monotone_curve_2_object( );
FT res( 0 );
CoordinateType res( 0 );
CGAL::Bbox_2 clipRect = curve.bbox( );
Point_2 p1c1( x, FT( clipRect.ymin( ) - 1 ) ); // clicked point
Point_2 p2c1( x, FT( clipRect.ymax( ) + 1 ) ); // upper bounding box
Point_2 p1c1( x, CoordinateType( clipRect.ymin( ) - 1 ) ); // clicked point
Point_2 p2c1( x, CoordinateType( clipRect.ymax( ) + 1 ) ); // upper bounding box
const X_monotone_curve_2 verticalLine =
construct_x_monotone_curve_2( p1c1, p2c1 );
@ -438,16 +468,16 @@ protected:
}
template < class TTraits >
FT operator() ( const X_monotone_curve_2& curve, const FT& x, TTraits traits_, CGAL::Arr_open_side_tag )
CoordinateType operator() ( const X_monotone_curve_2& curve, const CoordinateType& x, TTraits traits_, CGAL::Arr_open_side_tag )
{
typename TTraits::Construct_x_monotone_curve_2 construct_x_monotone_curve_2 =
traits_.construct_x_monotone_curve_2_object( );
FT res( 0 );
CoordinateType res( 0 );
QRectF clipRect = this->viewportRect( );
Line_2 line = curve.supporting_line( );
// FIXME: get a better bounding box for an unbounded segment
Point_2 p1c1( x, FT( -10000000 ) ); // clicked point
Point_2 p2c1( x, FT( 10000000 ) ); // upper bounding box
Point_2 p1c1( x, CoordinateType( -10000000 ) ); // clicked point
Point_2 p2c1( x, CoordinateType( 10000000 ) ); // upper bounding box
const X_monotone_curve_2 verticalLine =
construct_x_monotone_curve_2( p1c1, p2c1 );
@ -513,19 +543,59 @@ public:
return res;
}
#if 0
// FIXME: inexact projection
Root_of_2 operator() ( const X_monotone_curve_2& curve, const Root_of_2& x )
{
FT approx( CGAL::to_double( x ) );
return this->operator()( curve, approx );
}
#endif
protected:
Traits traits;
Intersect_2 intersectCurves;
};
template < class Coefficient_ >
class Arr_compute_y_at_x_2< CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > > : public QGraphicsSceneMixin
{
public:
typedef Coefficient_ Coefficient;
typedef CGAL::Arr_algebraic_segment_traits_2< Coefficient > Traits;
typedef typename Traits::Algebraic_real_1 CoordinateType;
typedef typename Traits::Point_2 Point_2;
typedef typename Traits::Intersect_2 Intersect_2;
typedef typename Traits::Multiplicity Multiplicity;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
CoordinateType operator() ( 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;
CGAL::assign( res, o ); // TODO: handle failure case
return res.first.y( );
}
protected:
X_monotone_curve_2 makeVerticalLine( const CoordinateType& x )
{
typename Traits::Construct_point_2 constructPoint =
traits.construct_point_2_object( );
typename Traits::Construct_x_monotone_segment_2 constructSegment =
traits.construct_x_monotone_segment_2_object( );
std::vector< X_monotone_curve_2 > curves;
Point_2 p1 = constructPoint( x, CoordinateType( -1000000 ) );
Point_2 p2 = constructPoint( x, CoordinateType( +1000000 ) );
constructSegment( p1, p2, std::back_inserter( curves ) );
return curves[ 0 ]; // by construction, there is one curve in curves
}
Traits traits;
};
#undef SUBCURVE_1
// TODO: Make Construct_x_monotone_subcurve_2 more generic
@ -538,14 +608,13 @@ public:
typedef typename ArrTraits::Split_2 Split_2;
typedef typename ArrTraits::Intersect_2 Intersect_2;
typedef typename ArrTraits::Multiplicity Multiplicity;
#ifdef SUBCURVE_1
typedef typename ArrTraits::Construct_x_monotone_curve_2 Construct_x_monotone_curve_2;
#endif
typedef typename ArrTraits::Construct_min_vertex_2 Construct_min_vertex_2;
typedef typename ArrTraits::Construct_max_vertex_2 Construct_max_vertex_2;
typedef typename ArrTraits::Compare_x_2 Compare_x_2;
typedef typename Kernel::FT FT;
typedef typename Kernel::Point_2 Point_2;
typedef typename ArrTraitsAdaptor< ArrTraits >::CoordinateType CoordinateType;
typedef typename ArrTraits::Point_2 Point_2;
typedef typename Kernel::Point_2 Kernel_point_2;
//typedef typename Kernel::Line_2 Line_2;
//typedef typename Kernel::Compute_y_at_x_2 Compute_y_at_x_2;
@ -553,9 +622,6 @@ public:
intersect_2( this->traits.intersect_2_object( ) ),
split_2( this->traits.split_2_object( ) ),
compare_x_2( this->traits.compare_x_2_object( ) ),
#ifdef SUBCURVE_1
construct_x_monotone_curve_2( this->traits.construct_x_monotone_curve_2_object( ) ),
#endif
construct_min_vertex_2( this->traits.construct_min_vertex_2_object( ) ),
construct_max_vertex_2( this->traits.construct_max_vertex_2_object( ) )
{ }
@ -575,32 +641,9 @@ public:
X_monotone_curve_2 finalSubcurve;
if ( this->compare_x_2( pLeft, pMin ) == CGAL::LARGER )
{
#ifndef SUBCURVE_1
Arr_compute_y_at_x_2< ArrTraits > compute_y_at_x;
FT y1 = compute_y_at_x( curve, pLeft.x( ) );
CoordinateType y1 = this->compute_y_at_x( curve, pLeft.x( ) );
Point_2 splitPoint( pLeft.x( ), y1 );
this->split_2( curve, splitPoint, unusedTrimmings, subcurve );
#endif
// FIXME: handle vertical lines properly
#ifdef SUBCURVE_1
CGAL::Bbox_2 c_bbox = curve.bbox( );
FT splitLineYMin( c_bbox.ymin( ) - 1.0 );
FT splitLineYMax( c_bbox.ymax( ) + 1.0 );
Point_2 splitLinePBottom( pLeft.x( ), splitLineYMin );
Point_2 splitLinePTop( pLeft.x( ), splitLineYMax );
X_monotone_curve_2 splitLine =
this->construct_x_monotone_curve_2( splitLinePBottom, splitLinePTop );
CGAL::Object res;
CGAL::Oneset_iterator< CGAL::Object > oi( res );
this->intersect_2( splitLine, curve, oi );
std::pair< Point_2, Multiplicity > pair;
if ( CGAL::assign( pair, res ) )
{
Point_2 splitPoint = pair.first;
this->split_2( curve, splitPoint, unusedTrimmings, subcurve );
}
#endif
}
else
{
@ -609,30 +652,9 @@ public:
if ( this->compare_x_2( pRight, pMax ) == CGAL::SMALLER )
{
#ifndef SUBCURVE_1
Arr_compute_y_at_x_2< ArrTraits > compute_y_at_x;
FT y2 = compute_y_at_x( subcurve, pRight.x( ) );
CoordinateType y2 = this->compute_y_at_x( subcurve, pRight.x( ) );
Point_2 splitPoint( pRight.x( ), y2 );
this->split_2( subcurve, splitPoint, finalSubcurve, unusedTrimmings );
#else
CGAL::Bbox_2 c_bbox = subcurve.bbox( );
FT splitLineYMin( c_bbox.ymin( ) - 1.0 );
FT splitLineYMax( c_bbox.ymax( ) + 1.0 );
Point_2 splitLinePBottom( pRight.x( ), splitLineYMin );
Point_2 splitLinePTop( pRight.x( ), splitLineYMax );
X_monotone_curve_2 splitLine =
this->construct_x_monotone_curve_2( splitLinePBottom, splitLinePTop );
CGAL::Object res;
CGAL::Oneset_iterator< CGAL::Object > oi( res );
this->intersect_2( splitLine, subcurve, oi );
std::pair< Point_2, Multiplicity > pair;
if ( CGAL::assign( pair, res ) )
{
Point_2 splitPoint = pair.first;
//return X_monotone_curve_2( splitLinePBottom, splitPoint );
this->split_2( subcurve, splitPoint, finalSubcurve, unusedTrimmings );
}
#endif
}
else
{
@ -647,9 +669,7 @@ protected:
Intersect_2 intersect_2;
Split_2 split_2;
Compare_x_2 compare_x_2;
#ifdef SUBCURVE_1
Construct_x_monotone_curve_2 construct_x_monotone_curve_2;
#endif
Arr_compute_y_at_x_2< ArrTraits > compute_y_at_x;
Construct_min_vertex_2 construct_min_vertex_2;
Construct_max_vertex_2 construct_max_vertex_2;
}; // class Construct_x_monotone_subcurve_2
@ -795,6 +815,28 @@ protected:
Construct_x_monotone_subcurve_2< CGAL::Arr_segment_traits_2< Kernel_ > > constructSubsegment;
};
template < class Coefficient_ >
class Construct_x_monotone_subcurve_2< CGAL::Arr_algebraic_segment_traits_2< Coefficient_ > >
{
public: // typedefs
typedef Coefficient_ Coefficient;
typedef CGAL::Arr_algebraic_segment_traits_2< Coefficient > ArrTraits;
typedef typename ArrTraits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename ArrTraitsAdaptor< ArrTraits >::Kernel Kernel;
typedef typename ArrTraits::Point_2 Point_2;
//typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Segment_2 Segment_2;
public: // methods
// curve can be unbounded. if curve is unbounded to the left, pLeft is a point on the left edge of viewport.
X_monotone_curve_2 operator() ( const X_monotone_curve_2& curve, const Point_2& pLeft, const Point_2& pRight )
{
// TODO: trim the algebraic curve
return curve;
}
protected:
};
// FIXME: return Traits::Point_2 instead of Kernel::Point_2
template < class ArrTraits >
@ -847,7 +889,7 @@ public:
QPointF clickedPoint = event->scenePos( );
QRectF viewportRect = this->viewportRect( );
if ( viewportRect == QRectF( ) )
{
{ // fallback case; we usually shouldn't end up here
Kernel_point_2 res = this->convert( event->scenePos( ) );
return Point_2( CGAL::to_double(res.x( )), CGAL::to_double(res.y()) );
}
@ -963,13 +1005,14 @@ public:
template < class TTraits >
Point_2 snapPoint( const Kernel_point_2& clickedPoint, TTraits traits )
{
Point_2 initialPoint( CGAL::to_double(clickedPoint.x()), CGAL::to_double(clickedPoint.y()) );
Point_2 closestPoint( CGAL::to_double(clickedPoint.x()), CGAL::to_double(clickedPoint.y()) );
bool first = true;
FT minDist( 0 );
QRectF viewportRect = this->viewportRect( );
if ( viewportRect == QRectF( ) )
{
return clickedPoint;
return initialPoint;
}
FT maxDist( ( viewportRect.right( ) - viewportRect.left( ) ) / 4.0 );
@ -992,7 +1035,7 @@ public:
}
else
{
return clickedPoint;
return initialPoint;
}
}
@ -1048,6 +1091,53 @@ protected:
CGAL::Qt::Converter< Kernel > convert;
}; // class SnapToArrangementVertexStrategy
/**
Converts between Kernel points and Arrangement points.
The conversion is not necessarily exact.
*/
template < class ArrTraits >
class Arr_construct_point_2
{
typedef typename ArrTraits::Point_2 Point_2;
typedef typename ArrTraitsAdaptor< ArrTraits >::CoordinateType CoordinateType;
typedef typename ArrTraitsAdaptor< ArrTraits >::Kernel Kernel;
typedef typename Kernel::Point_2 Kernel_point_2;
public:
Point_2 operator()( const Kernel_point_2& pt )
{
return (*this)( pt.x(), pt.y() );
}
template < class T >
Point_2 operator()( const T& x, const T& y )
{
return (*this)( x, y, ArrTraits( ) );
}
protected:
template < class T, class TTraits >
Point_2 operator()( const T& x, const T& y, TTraits traits )
{
CoordinateType xx( x );
CoordinateType yy( y );
Point_2 res( xx, yy );
return res;
}
template < class T, class CircularKernel >
Point_2 operator()( const T& x, const T& y, CGAL::Arr_circular_arc_traits_2< CircularKernel > traits )
{
typedef typename CircularKernel::Root_for_circles_2_2 Root_for_circles_2_2;
CoordinateType xx( x );
CoordinateType yy( y );
Root_for_circles_2_2 p( xx, yy );
Point_2 res( p );
return res;
}
};
class Find_nearest_edge_base : public QGraphicsSceneMixin
{ };
@ -1080,12 +1170,13 @@ public: // constructors
public: // member methods
Halfedge_const_handle operator()( const Point_2& queryPt )
{
CGAL::Object pointLocationResult = this->pointLocationStrategy.locate( queryPt );
typename ArrTraits::Point_2 pt = this->toArrPoint( queryPt );
CGAL::Object pointLocationResult = this->pointLocationStrategy.locate( pt );
Face_const_handle face = this->getFace( pointLocationResult );
bool first = 1;
X_monotone_curve_2 closestCurve;
Halfedge_const_handle closestEdge;
FT minDist( 0 );
double minDist( 0 );
if ( ! face->is_unbounded( ) )
{ // it is an interior face so it has a ccb
@ -1093,7 +1184,7 @@ public: // member methods
do
{
X_monotone_curve_2 curve = cc->curve( );
FT dist = this->pointCurveDistance( queryPt, curve );
double dist = this->pointCurveDistance( queryPt, curve );
if ( first || dist < minDist )
{
first = 0;
@ -1115,7 +1206,7 @@ public: // member methods
}
X_monotone_curve_2 curve = cc->curve( );
FT dist = this->pointCurveDistance( queryPt, curve );
double dist = this->pointCurveDistance( queryPt, curve );
if ( first || dist < minDist )
{
first = 0;
@ -1135,7 +1226,7 @@ public: // member methods
do
{
X_monotone_curve_2 curve = cc->curve( );
FT dist = this->pointCurveDistance( queryPt, curve );
double dist = this->pointCurveDistance( queryPt, curve );
if ( first || dist < minDist )
{
first = 0;
@ -1180,6 +1271,7 @@ protected: // member fields
Arrangement* arr;
Point_curve_distance pointCurveDistance;
Point_location_strategy pointLocationStrategy;
Arr_construct_point_2< ArrTraits > toArrPoint;
}; // class Find_nearest_edge
@ -1229,7 +1321,7 @@ public: // member methods
bool first = 1;
X_monotone_curve_2 closestCurve;
Halfedge_const_handle closestEdge;
FT minDist( 0 );
double minDist( 0 );
if ( ! face->is_unbounded( ) )
{ // it is an interior face so it has a ccb
@ -1237,7 +1329,7 @@ public: // member methods
do
{
X_monotone_curve_2 curve = cc->curve( );
FT dist = this->pointCurveDistance( queryPt, curve );
double dist = this->pointCurveDistance( queryPt, curve );
if ( first || dist < minDist )
{
first = 0;
@ -1258,7 +1350,7 @@ public: // member methods
}
X_monotone_curve_2 curve = cc->curve( );
FT dist = this->pointCurveDistance( queryPt, curve );
double dist = this->pointCurveDistance( queryPt, curve );
if ( first || dist < minDist )
{
first = 0;
@ -1276,7 +1368,7 @@ public: // member methods
do
{
X_monotone_curve_2 curve = cc->curve( );
FT dist = this->pointCurveDistance( queryPt, curve );
double dist = this->pointCurveDistance( queryPt, curve );
if ( first || dist < minDist )
{
first = 0;
@ -1318,4 +1410,6 @@ protected: // member fields
}; // class Find_nearest_edge
#endif // CGAL_ARRANGEMENTS_DEMO_UTILS_H

View File

@ -57,7 +57,9 @@ public:
typedef typename Traits::Intersect_2 Intersect_2;
typedef typename Traits::Multiplicity Multiplicity;
typedef typename ArrTraitsAdaptor< Traits >::Kernel Kernel;
typedef typename Kernel::Point_2 Point_2;
typedef typename ArrTraitsAdaptor< Traits >::CoordinateType CoordinateType;
typedef typename Kernel::Point_2 Kernel_point_2;
typedef typename Traits::Point_2 Point_2;
typedef std::pair< typename Traits::Point_2, Multiplicity > IntersectionResult;
typedef typename Kernel::Segment_2 Segment_2;
typedef typename Kernel::FT FT;
@ -77,8 +79,8 @@ protected:
void mouseMoveEvent( QGraphicsSceneMouseEvent *event );
void highlightPointLocation( QGraphicsSceneMouseEvent *event );
Face_const_handle getFace( const CGAL::Object& o );
CGAL::Object rayShootUp( const Point_2& point );
CGAL::Object rayShootDown( const Point_2& point );
CGAL::Object rayShootUp( const Kernel_point_2& point );
CGAL::Object rayShootDown( const Kernel_point_2& point );
using Superclass::scene;
using Superclass::shootingUp;
@ -90,7 +92,8 @@ protected:
CGAL::Object pointLocationStrategy;
CGAL::Qt::CurveGraphicsItem< Traits >* highlightedCurves;
QGraphicsLineItem* activeRay;
Point_2 queryPt;
Kernel_point_2 queryPt;
Arr_construct_point_2< Traits > toArrPoint;
}; // class VerticalRayShootCallback
template < class Arr_ >
@ -193,7 +196,7 @@ highlightPointLocation( QGraphicsSceneMouseEvent* event )
Vertex_const_handle vertex;
if ( CGAL::assign( unboundedFace, pointLocationResult ) )
{
Point_2 p2( FT( this->queryPt.x( ) ), y2 );
Kernel_point_2 p2( FT( this->queryPt.x( ) ), y2 );
Segment_2 lineSegment( this->queryPt, p2 );
QLineF qLineSegment = this->convert( lineSegment );
this->activeRay->setLine( qLineSegment );
@ -205,48 +208,13 @@ highlightPointLocation( QGraphicsSceneMouseEvent* event )
// draw a ray from the clicked point to the hit curve
Arr_compute_y_at_x_2< Traits > compute_y_at_x_2;
compute_y_at_x_2.setScene( this->getScene( ) );
double yApprox = CGAL::to_double( compute_y_at_x_2( halfedge->curve( ), this->queryPt.x( ) ) );
CoordinateType x( this->queryPt.x( ) );
double yApprox = CGAL::to_double( compute_y_at_x_2( halfedge->curve( ), x ) );
FT yInt( yApprox );
Point_2 p2( this->queryPt.x( ), yInt );
Kernel_point_2 p2( this->queryPt.x( ), yInt );
Segment_2 seg( this->queryPt, p2 );
QLineF qseg = this->convert( seg );
this->activeRay->setLine( qseg );
#if 0
Point_2 p1c1( p1.x( ), p1.y( ) );
Point_2 p2c1( p1.x( ), y2 );
//std::cout << "p1.x( ): " << p1.x( ) << std::endl;
//std::cout << "y2: " << y2 << std::endl;
const X_monotone_curve_2 c1 =
this->construct_x_monotone_curve_2( p1c1, p2c1 );
const X_monotone_curve_2 c2 = halfedge->curve( );
CGAL::Object res;
CGAL::Oneset_iterator< CGAL::Object > oi( res );
//std::vector< CGAL::Object > ress;
this->intersectCurves( c1, c2, oi );
//this->intersectCurves( c1, c2, std::back_inserter( ress ) );
//std::cout << "num intersections: " << ress.size( ) << std::endl;
//typedef typename
//std::pair< Point_2, Multiplicity > pair;
IntersectionResult pair;
if ( CGAL::assign( pair, res ) )
{
//std::cout << "bound to IntersectionResult" << std::endl;
Point_2 p2 = pair.first;
Segment_2 lineSegment( p1, p2 );
QLineF qLineSegment = this->convert( lineSegment );
this->activeRay->setLine( qLineSegment );
}
else
{
Point_2 p2 = pair.first;
Segment_2 lineSegment( p1, p2c1 );
QLineF qLineSegment = this->convert( lineSegment );
this->activeRay->setLine( qLineSegment );
}
#endif
}
else if ( CGAL::assign( vertex, pointLocationResult ) )
{
@ -254,86 +222,6 @@ highlightPointLocation( QGraphicsSceneMouseEvent* event )
}
emit modelChanged( );
#if 0
{
Face_const_handle ubf;
if (CGAL::assign(ubf, obj))
{
CGAL_assertion(ubf->is_unbounded());
//relevant_face_color = unbounded_face_color() as initialized
up = Coord_point(pl_draw.x() , y_max());
static_cast<CGAL::Qt_widget&>(*this) << Coord_segment(pl_draw, up);
}
// we shoot something
else
{
Halfedge_const_handle he;
if (CGAL::assign(he, obj))
{
Point_2 p1c1(pl_point.x() , y_max() * m_tab_traits.COORD_SCALE);
Point_2 p2c1(pl_point.x() , pl_point.y());
const X_monotone_curve_2 c1 =
m_tab_traits.curve_make_x_monotone(p1c1 , p2c1);
const X_monotone_curve_2 c2 = he->curve();
CGAL::Object res;
CGAL::Oneset_iterator<CGAL::Object> oi(res);
m_traits.intersect_2_object()(c1, c2, oi);
std::pair<Point_2,Multiplicity> p1;
if (CGAL::assign(p1, res))
{
Coord_type y1 =
CGAL::to_double(p1.first.y())/ m_tab_traits.COORD_SCALE;
up = Coord_point(pl_draw.x(), y1);
}
else
{
up = pl_draw;
}
relevant_face_color = he->face()->color();
/*choose color to mark the edge that differs from the current
edge_color, the background, and the relevant face color*/
setCorrectColor(relevant_face_color);
m_tab_traits.draw_xcurve(this , he->curve() );
}
else
{
Vertex_const_handle v;
CGAL_assertion(CGAL::assign(v, obj));
CGAL::assign(v, obj);
up = Coord_point(CGAL::to_double(v->point().x()) /
m_tab_traits.COORD_SCALE,
CGAL::to_double(v->point().y()) /
m_tab_traits.COORD_SCALE);
//locate face that arrow will be drawn in, and retrieve its color
CGAL::Object obj1 = locate(temp_p);
Face_const_handle f1 = get_face(obj1);
relevant_face_color=f1->color();
/*choose color to mark the vertice so that it differs from the
edge_color, the background, and the relevant_face_color*/
setCorrectColor(relevant_face_color);
static_cast<CGAL::Qt_widget&>(*this) << up;
}
}
//select arrow color that differs from the color of the face it is in
setCorrectColor(relevant_face_color);
static_cast<CGAL::Qt_widget&>(*this) << CGAL::LineWidth(2);
static_cast<CGAL::Qt_widget&>(*this) << Coord_segment(pl_draw,up);
// draw an arrow that points to 'up' point
int x = this->x_pixel(CGAL::to_double(up.x()));
int y = this->y_pixel(CGAL::to_double(up.y()));
this->get_painter().drawLine(x-7 , y+7 , x , y);
this->get_painter().drawLine(x+7 , y+7 , x , y);
static_cast<CGAL::Qt_widget&>(*this) << CGAL::LineWidth(m_line_width);
}
#endif
}
template < class Arr_ >
@ -361,13 +249,16 @@ getFace( const CGAL::Object& obj )
template < class Arr_ >
CGAL::Object
VerticalRayShootCallback< Arr_ >::
rayShootUp( const Point_2& point )
rayShootUp( const Kernel_point_2& pt )
{
CGAL::Object pointLocationResult;
WalkAlongLinePointLocationStrategy* walkStrategy;
TrapezoidPointLocationStrategy* trapezoidStrategy;
SimplePointLocationStrategy* simpleStrategy;
LandmarksPointLocationStrategy* landmarksStrategy;
Point_2 point = this->toArrPoint( pt );
if ( CGAL::assign( walkStrategy, this->pointLocationStrategy ) )
{
pointLocationResult = walkStrategy->ray_shoot_up( point );
@ -392,13 +283,16 @@ rayShootUp( const Point_2& point )
template < class Arr_ >
CGAL::Object
VerticalRayShootCallback< Arr_ >::
rayShootDown( const Point_2& point )
rayShootDown( const Kernel_point_2& pt )
{
CGAL::Object pointLocationResult;
WalkAlongLinePointLocationStrategy* walkStrategy;
TrapezoidPointLocationStrategy* trapezoidStrategy;
SimplePointLocationStrategy* simpleStrategy;
LandmarksPointLocationStrategy* landmarksStrategy;
Point_2 point = this->toArrPoint( pt );
if ( CGAL::assign( walkStrategy, this->pointLocationStrategy ) )
{
pointLocationResult = walkStrategy->ray_shoot_down( point );
@ -420,5 +314,4 @@ rayShootDown( const Point_2& point )
return pointLocationResult;
}
#endif // VERTICAL_RAY_SHOOT_CALLBACK_H

View File

@ -41,7 +41,7 @@ X_monotone_curve_2 makeVerticalLine( Bound x )
traits.construct_x_monotone_segment_2_object( );
std::vector< X_monotone_curve_2 > curves;
Point_2 p1 = constructPoint( x, Bound( -10000 ) );
Point_2 p1 = constructPoint( Algebraic_real_1(x), Algebraic_real_1(Bound( -10000 )) );
Point_2 p2 = constructPoint( x, Bound( +10000 ) );
constructSegment( p1, p2, std::back_inserter( curves ) );
return curves[ 0 ];
@ -52,6 +52,7 @@ typedef Kernel::Point_2 Kernel_point_2;
int main( )
{
Algebraic_real_1 real( 1 );
//CGAL::Qt::Converter< Algebraic_kernel_d_2 > testConverter;
//CGAL::Qt::Converter< CKvA_2 > testConverter;