Entering circular polygons being added

This commit is contained in:
Fernando Cacciola 2010-01-27 17:09:17 +00:00
parent 15382fb248
commit b58ebd3f74
4 changed files with 144 additions and 94 deletions

View File

@ -84,7 +84,7 @@ void trace( std::string s )
#include <CGAL/Qt/BezierCurves.h> #include <CGAL/Qt/BezierCurves.h>
#include <CGAL/Qt/CircularPolygons.h> #include <CGAL/Qt/CircularPolygons.h>
#include <CGAL/Qt/GraphicsViewBezierPolygonInput.h> #include <CGAL/Qt/GraphicsViewBezierPolygonInput.h>
#include <CGAL/Qt/GraphicsViewGpsCircleSegmentInput.h> #include <CGAL/Qt/GraphicsViewCircularPolygonInput.h>
//#include <CGAL/Qt/GraphicsViewGpsCircleInput.h> //#include <CGAL/Qt/GraphicsViewGpsCircleInput.h>
#include <CGAL/Qt/Converter.h> #include <CGAL/Qt/Converter.h>
#include <CGAL/Qt/DemosMainWindow.h> #include <CGAL/Qt/DemosMainWindow.h>
@ -451,7 +451,8 @@ private:
Bezier_region_source_container mBlue_bezier_sources ; Bezier_region_source_container mBlue_bezier_sources ;
Bezier_region_source_container mRed_bezier_sources ; Bezier_region_source_container mRed_bezier_sources ;
CGAL::Qt::GraphicsViewBezierPolygonInput<Bezier_traits>* mBezierInput ; CGAL::Qt::GraphicsViewBezierPolygonInput<Bezier_traits>* mBezierInput ;
CGAL::Qt::GraphicsViewGpsCircleSegmentInput<Circular_curve>* mCircularInput ; CGAL::Qt::GraphicsViewCircularPolygonInput<Gps_circular_kernel>* mCircularInput ;
//CGAL::Qt::GraphicsViewGpsCircleSegmentInput<Circular_curve>* mCircularInput ;
//CGAL::Qt::GraphicsViewGpsCircleInput<Circular_traits>* mCircleInput ; //CGAL::Qt::GraphicsViewGpsCircleInput<Circular_traits>* mCircleInput ;
public: public:
@ -625,7 +626,7 @@ MainWindow::MainWindow()
this->addRecentFiles(this->menuFile, this->actionQuit); this->addRecentFiles(this->menuFile, this->actionQuit);
mBezierInput = new CGAL::Qt::GraphicsViewBezierPolygonInput <Bezier_traits> (this, &mScene); mBezierInput = new CGAL::Qt::GraphicsViewBezierPolygonInput <Bezier_traits> (this, &mScene);
mCircularInput = new CGAL::Qt::GraphicsViewGpsCircleSegmentInput <Circular_curve>(this, &mScene); mCircularInput = new CGAL::Qt::GraphicsViewCircularPolygonInput<Gps_circular_kernel>(this, &mScene);
//mCircleInput = new CGAL::Qt::GraphicsViewCircleInput <Circular_traits>(this, &mScene); //mCircleInput = new CGAL::Qt::GraphicsViewCircleInput <Circular_traits>(this, &mScene);
QObject::connect(mBezierInput , SIGNAL(generate(CGAL::Object)), this, SLOT(processInput(CGAL::Object))); QObject::connect(mBezierInput , SIGNAL(generate(CGAL::Object)), this, SLOT(processInput(CGAL::Object)));
@ -682,7 +683,7 @@ void MainWindow::dropEvent(QDropEvent *event)
Circular_polygon linear_2_circ( Linear_polygon const& pgn ) Circular_polygon linear_2_circ( Linear_polygon const& pgn )
{ {
CGAL::Cartesian_converter<Linear_kernel,Circular_kernel> convert ; CGAL::Cartesian_converter<Linear_kernel,Gps_circular_kernel> convert ;
Circular_polygon rCP; Circular_polygon rCP;
@ -753,7 +754,7 @@ bool read_dxf ( QString aFileName, Circular_polygon_set& rSet, Circular_region_s
if ( in_file ) if ( in_file )
{ {
CGAL::Dxf_bsop_reader<Circular_kernel> reader; CGAL::Dxf_bsop_reader<Gps_circular_kernel> reader;
std::vector<Circular_polygon> circ_polygons; std::vector<Circular_polygon> circ_polygons;
std::vector<Circular_polygon_with_holes> circ_polygons_with_holes; std::vector<Circular_polygon_with_holes> circ_polygons_with_holes;

View File

@ -25,7 +25,7 @@
#include <CGAL/Qt/BoundaryPiecesGraphicsItem.h> #include <CGAL/Qt/BoundaryPiecesGraphicsItem.h>
#include <CGAL/Qt/Converter.h> #include <CGAL/Qt/Converter.h>
#define USE_CLIPPING //#define USE_CLIPPING
namespace CGAL { namespace CGAL {

View File

@ -35,7 +35,6 @@ struct Circular_X_monotone_bbox
} }
} ; } ;
#if 0
struct Circular_bbox struct Circular_bbox
{ {
template<class Circle_segment_2> template<class Circle_segment_2>
@ -67,9 +66,6 @@ struct Circular_bbox
} }
} ; } ;
#endif
struct Draw_circular_X_monotone_curve struct Draw_circular_X_monotone_curve
{ {
template<class X_monotone_circle_segment_2, class Path> template<class X_monotone_circle_segment_2, class Path>
@ -157,7 +153,6 @@ struct Draw_circular_X_monotone_curve
} }
} ; } ;
#if 0
struct Draw_circular_curve struct Draw_circular_curve
{ {
@ -174,28 +169,10 @@ struct Draw_circular_curve
if ( curve.is_circular() ) if ( curve.is_circular() )
{ {
typename X_monotone_circle_segment_2::Circle_2 const& circ = curve.supporting_circle(); typename Circle_segment_2::Circle_2 const& circ = curve.supporting_circle();
typename X_monotone_circle_segment_2::Kernel::Point_2 const& center = circ.center(); typename Circle_segment_2::Kernel::Point_2 const& center = circ.center();
typename Circle_segment_2::Point_2 const& source = curve.source();
if ( curve.is_full() ) typename Circle_segment_2::Point_2 const& target = curve.target();
{
double cx = to_double(center.x());
double cy = to_double(center.y());
double rad = std::sqrt( to_double(circ.squared_radius() ) ;
if ( aIdx == 0 )
aPath.moveTo(cx+rad,cy) ;
else aPath.lineTo(cx+rad,cy) ;
QRectF bbox = convert(circ.bbox()) ;
aPath.arcTo(bbox , 0, 360 );
}
else
{
typename X_monotone_circle_segment_2::Point_2 const& source = curve.source();
typename X_monotone_circle_segment_2::Point_2 const& target = curve.target();
double sx = to_double(source.x()); double sx = to_double(source.x());
double sy = to_double(source.y()); double sy = to_double(source.y());
@ -244,7 +221,6 @@ struct Draw_circular_curve
aPath.arcTo(bbox , dasource, daspan ); aPath.arcTo(bbox , dasource, daspan );
} }
} }
}
else else
{ {
Linear_point lS( CGAL::to_double(curve.source().x()), CGAL::to_double(curve.source().y()) ) ; Linear_point lS( CGAL::to_double(curve.source().x()), CGAL::to_double(curve.source().y()) ) ;
@ -256,12 +232,85 @@ struct Draw_circular_curve
aPath.lineTo( convert( lT ) ) ; aPath.lineTo( convert( lT ) ) ;
} }
} }
} ; } ;
#endif /*
struct Draw_circular_curve
{
template<class Circle_segment_2, class Path>
void operator()( Circle_segment_2 const& curve, Path& aPath, int aIdx ) const
{
if ( !cs_.is_full() )
{
double sx = to_double(cs_.source().x());
double sy = to_double(cs_.source().y());
double tx = to_double(cs_.target().x());
double ty = to_double(cs_.target().y());
if( cs_.orientation() == COLLINEAR)
{
painter->drawLine(sx,sy,tx,ty);
}
else
{
double cx = to_double(cs_.supporting_circle().center().x());
double cy = to_double(cs_.supporting_circle().center().y());
double x0, y0, x1, y1 ;
if(cs_.orientation() == CLOCKWISE)
{
x0 = sx ;
y0 = sy ;
x1 = tx ;
y1 = ty ;
}
else
{
x0 = tx ;
y0 = ty ;
x1 = sx ;
y1 = sy ;
}
double rad = std::sqrt(CGAL::to_double(cs_.supporting_circle().squared_radius()));
double a = std::atan2( y0 - cy, x0 - cx ) ;
double a2p = std::atan2( y1 - cy, x1 - cx );
if (a2p <= a)
a2p += 2 * CGAL_PI;
double alen2 = a2p - a;
double to_deg = 180 / CGAL_PI ;
painter->drawArc(cx - rad, cy - rad, 2 * rad, 2 * rad, - a * to_deg * 16, - alen2 * to_deg * 16 );
}
}
else
{
if( cs_.orientation() != COLLINEAR)
{
double cx = to_double(cs_.supporting_circle().center().x());
double cy = to_double(cs_.supporting_circle().center().y());
double rad = std::sqrt(CGAL::to_double(cs_.supporting_circle().squared_radius()));
painter->drawArc(cx -rad, cy - rad, 2 * rad, 2 * rad, 0, 360*16);
}
}
}
} ;
*/
template<class Circular_boundary_pieces>
class Circular_boundary_pieces_graphics_item : public Boundary_pieces_graphics_item<Circular_boundary_pieces,Draw_circular_curve,Circular_bbox>
{
typedef Boundary_pieces_graphics_item<Circular_boundary_pieces,Draw_circular_curve,Circular_bbox> Base ;
public :
Circular_boundary_pieces_graphics_item( Circular_boundary_pieces* aPieces ) : Base(aPieces) {}
} ;
template<class Circular_boundary> template<class Circular_boundary>
class Circular_boundary_graphics_item : public Piecewise_boundary_graphics_item<Circular_boundary,Draw_circular_X_monotone_curve,Circular_X_monotone_bbox> class Circular_boundary_graphics_item : public Piecewise_boundary_graphics_item<Circular_boundary,Draw_circular_X_monotone_curve,Circular_X_monotone_bbox>

View File

@ -46,9 +46,9 @@ typedef Linear_kernel::Point_2 Linear_point ;
typedef CGAL::Lazy_exact_nt<Base_nt> Coord_type; typedef CGAL::Lazy_exact_nt<Base_nt> Coord_type;
struct Circular_kernel : public CGAL::Cartesian<Coord_type> {}; struct Gps_circular_kernel : public CGAL::Cartesian<Coord_type> {};
typedef CGAL::Gps_circle_segment_traits_2<Circular_kernel> Circular_traits; typedef CGAL::Gps_circle_segment_traits_2<Gps_circular_kernel> Circular_traits;
typedef Circular_traits::Curve_2 Circular_curve; typedef Circular_traits::Curve_2 Circular_curve;
typedef Circular_traits::X_monotone_curve_2 Circular_X_monotone_curve; typedef Circular_traits::X_monotone_curve_2 Circular_X_monotone_curve;
typedef Circular_traits::Point_2 Circular_point ; typedef Circular_traits::Point_2 Circular_point ;