mirror of https://github.com/CGAL/cgal
rendering spatial curves & bugfixes
This commit is contained in:
parent
acf4ea73d5
commit
2ad61a38f7
|
|
@ -28,11 +28,12 @@
|
|||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Arr_tags.h>
|
||||
#include <CGAL/Fourtuple.h>
|
||||
|
||||
#include <CGAL/Curved_kernel_via_analysis_2.h>
|
||||
#include <CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_functors.h>
|
||||
|
||||
#ifdef CGAL_CKvA_COMPILE_RENDERER
|
||||
#ifdef CGAL_CKVA_COMPILE_RENDERER
|
||||
#include <CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -864,17 +865,20 @@ public:
|
|||
//! itself
|
||||
typedef Dupin_cyclide_point_2 Self;
|
||||
|
||||
//! point approximation
|
||||
typedef typename CGAL::Cartesian< double >::Point_3 Approximation_3;
|
||||
//! our lovely cyclide
|
||||
typedef typename ASiDC_traits_2::Dupin_cyclide_3 Dupin_cyclide_3;
|
||||
|
||||
//! types needed to replicate constructors
|
||||
//! types needed to replicate constructors
|
||||
typedef typename Base::Curve_analysis_2 Curve_analysis_2;
|
||||
typedef typename Base::X_coordinate_1 X_coordinate_1;
|
||||
typedef typename Base::Rep Rep;
|
||||
|
||||
//! for visualization
|
||||
//! for parameterization
|
||||
typedef CGAL::Polynomial< double > Poly_double_1;
|
||||
typedef CGAL::Polynomial< Poly_double_1 > Poly_double_2;
|
||||
|
||||
typedef CGAL::Fourtuple< double > Point_double_4;
|
||||
|
||||
|
||||
//!\name replicates all constructors of the base (stupid solution)
|
||||
//! see base type constructors for detailed description
|
||||
|
|
@ -917,70 +921,97 @@ public:
|
|||
//!\name visualization & approximation
|
||||
//!@{
|
||||
|
||||
#ifdef CGAL_CKvA_COMPILE_RENDERER
|
||||
#ifdef CGAL_CKVA_COMPILE_RENDERER
|
||||
//! sets up rendering window \c bbox and resolution
|
||||
static void setup_renderer(CGAL::Bbox_2 bbox, int res_w, int res_h) {
|
||||
Curve_renderer_facade< ASiDC_traits_2 >::setup(bbox, res_w, res_h);
|
||||
}
|
||||
|
||||
//! sets up cyclide parameterization equations
|
||||
static void setup_parameterization(
|
||||
const typename ASiDC_traits_2::Dupin_cyclide_3& base_surf) {
|
||||
static void setup_parameterization(const Dupin_cyclide_3& base_surf) {
|
||||
|
||||
parametrize_poly(0, CGAL::to_double(base_surf.x_param()));
|
||||
parametrize_poly(1, CGAL::to_double(base_surf.y_param()));
|
||||
parametrize_poly(2, CGAL::to_double(base_surf.z_param()));
|
||||
parametrize_poly(3, CGAL::to_double(base_surf.w_param()));
|
||||
param_surface(&base_surf);
|
||||
param_tube_circle(&base_surf);
|
||||
param_outer_circle(&base_surf);
|
||||
param_pole(&base_surf);
|
||||
}
|
||||
|
||||
//! get / set parameterization polynomial with index \c idx (0..3)
|
||||
static const Poly_double_2& parametrize_poly(unsigned idx,
|
||||
const boost::optional< Poly_double_2 >& ref = boost::none) {
|
||||
static const Poly_double_2 *param_surface(
|
||||
const Dupin_cyclide_3* base_surf = NULL) {
|
||||
|
||||
static Poly_double_2 _param[4]; // x, y, z, w respectively
|
||||
|
||||
CGAL_precondition(idx < 4);
|
||||
if(ref)
|
||||
_param[idx] = *ref;
|
||||
return _param[idx];
|
||||
if(base_surf != NULL)
|
||||
_param[0] = CGAL::to_double(base_surf->x_param()),
|
||||
_param[1] = CGAL::to_double(base_surf->y_param()),
|
||||
_param[2] = CGAL::to_double(base_surf->z_param()),
|
||||
_param[3] = CGAL::to_double(base_surf->w_param());
|
||||
|
||||
return _param;
|
||||
}
|
||||
|
||||
static const Poly_double_1 *param_tube_circle(
|
||||
const Dupin_cyclide_3* base_surf = NULL) {
|
||||
|
||||
static Poly_double_1 _param[4]; // see above
|
||||
if(base_surf != NULL)
|
||||
// make_transform_iterator ?
|
||||
_param[0] = CGAL::to_double(base_surf->tube_circle()[0]),
|
||||
_param[1] = CGAL::to_double(base_surf->tube_circle()[1]),
|
||||
_param[2] = CGAL::to_double(base_surf->tube_circle()[2]),
|
||||
_param[3] = CGAL::to_double(base_surf->tube_circle()[3]);
|
||||
return _param;
|
||||
}
|
||||
|
||||
static const Poly_double_1 *param_outer_circle(
|
||||
const Dupin_cyclide_3* base_surf = NULL) {
|
||||
|
||||
static Poly_double_1 _param[4]; // see above
|
||||
if(base_surf != NULL)
|
||||
_param[0] = CGAL::to_double(base_surf->outer_circle()[0]),
|
||||
_param[1] = CGAL::to_double(base_surf->outer_circle()[1]),
|
||||
_param[2] = CGAL::to_double(base_surf->outer_circle()[2]),
|
||||
_param[3] = CGAL::to_double(base_surf->outer_circle()[3]);
|
||||
return _param;
|
||||
}
|
||||
|
||||
static const Point_double_4& param_pole(
|
||||
const Dupin_cyclide_3* base_surf = NULL) {
|
||||
|
||||
static Point_double_4 _pole;
|
||||
if(base_surf != NULL)
|
||||
_pole.e0 = CGAL::to_double(base_surf->pole().e0),
|
||||
_pole.e1 = CGAL::to_double(base_surf->pole().e1),
|
||||
_pole.e2 = CGAL::to_double(base_surf->pole().e2),
|
||||
_pole.e3 = CGAL::to_double(base_surf->pole().e3);
|
||||
return _pole;
|
||||
}
|
||||
|
||||
/*!\brief
|
||||
* computes approximation of a point
|
||||
*
|
||||
* returns \c false if the point does not fall within the drawing window
|
||||
* \c Coord_3 must be constructible from a triple of doubles
|
||||
*/
|
||||
bool compute_approximation(Approximation_3& result) const {
|
||||
template < class Coord_3 >
|
||||
bool compute_approximation(Coord_3& result) const {
|
||||
|
||||
typedef Curve_renderer_facade< ASiDC_traits_2 > Facade;
|
||||
typename Facade::Coord_2 cc;
|
||||
|
||||
|
||||
CGAL::Twotuple< double > cc;
|
||||
if(!Facade::instance().draw(*this, cc))
|
||||
return false; // bad luck
|
||||
|
||||
Poly_double_2 px = parametrize_poly(0), py = parametrize_poly(1),
|
||||
pz = parametrize_poly(2), pw = parametrize_poly(3);
|
||||
|
||||
CGAL::Bbox_2 bbox;
|
||||
int res_w, res_h;
|
||||
Facade::instance().get_resolution(res_w, res_h);
|
||||
Facade::instance().get_window(bbox);
|
||||
// gotcha !!
|
||||
double lx = bbox.xmax() - bbox.xmin(), ly = bbox.ymax() - bbox.ymin();
|
||||
double s = bbox.xmin() + (double)cc.x * lx / res_w,
|
||||
t = bbox.ymin() + (double)cc.y * ly / res_h;
|
||||
|
||||
double x0, y0, z0, w0 = NiX::substitute_xy(pw, s, t);
|
||||
if(std::abs(w0) < 1e-17)
|
||||
return false;
|
||||
|
||||
x0 = NiX::substitute_xy(px, s, t) / w0;
|
||||
y0 = NiX::substitute_xy(py, s, t) / w0;
|
||||
z0 = NiX::substitute_xy(pz, s, t) / w0;
|
||||
|
||||
result = Approximation_3(x0, y0, z0);
|
||||
const Poly_double_2* params = param_surface();
|
||||
double x0 = NiX::substitute_xy(params[0], cc.e0, cc.e1),
|
||||
y0 = NiX::substitute_xy(params[1], cc.e0, cc.e1),
|
||||
z0 = NiX::substitute_xy(params[2], cc.e0, cc.e1),
|
||||
invw0 = 1.0 / NiX::substitute_xy(params[3], cc.e0, cc.e1);
|
||||
|
||||
result = Coord_3(x0*invw0, y0*invw0, z0*invw0);
|
||||
return true;
|
||||
}
|
||||
#endif // CGAL_CKvA_COMPILE_RENDERER
|
||||
#endif // CGAL_CKVA_COMPILE_RENDERER
|
||||
//!@}
|
||||
|
||||
friend class CGALi::Arc_2<ASiDC_traits_2>;
|
||||
|
|
@ -1005,7 +1036,7 @@ public:
|
|||
typedef typename ASiDC_traits_2::Point_2 Point_2;
|
||||
|
||||
//! point approximation
|
||||
typedef typename CGAL::Cartesian< double >::Point_3 Approximation_3;
|
||||
//typedef typename CGAL::Cartesian< double >::Point_3 Approximation_3;
|
||||
|
||||
//! types needed to replicate constructors
|
||||
typedef typename Base::Curve_analysis_2 Curve_analysis_2;
|
||||
|
|
@ -1093,70 +1124,9 @@ public:
|
|||
//!\name visualization & approximation
|
||||
//!@{
|
||||
|
||||
#ifdef CGAL_CKvA_COMPILE_RENDERER
|
||||
#ifdef CGAL_CKVA_COMPILE_RENDERER
|
||||
|
||||
/*!\brief
|
||||
* computes arc's approximation using preset window and resolution
|
||||
*
|
||||
* @note: call Dupin_cyclide_point_2::setup_renderer() and
|
||||
* setup_parameterization() before computing approximation
|
||||
*/
|
||||
template <class OutputIterator>
|
||||
OutputIterator compute_approximation(OutputIterator oi) const {
|
||||
|
||||
typedef Curve_renderer_facade< ASiDC_traits_2 > Facade;
|
||||
typedef typename Facade::Coord_vec_2 Coord_vec_2;
|
||||
typedef typename Facade::Coord_2 Coord_2;
|
||||
|
||||
std::list<Coord_vec_2> points;
|
||||
std::pair<Coord_2, Coord_2> end_points;
|
||||
|
||||
Facade::instance().draw(*this, points, end_points);
|
||||
if(points.empty())
|
||||
return oi;
|
||||
|
||||
CGAL::Bbox_2 bbox;
|
||||
int res_w, res_h;
|
||||
Facade::instance().get_resolution(res_w, res_h);
|
||||
Facade::instance().get_window(bbox);
|
||||
|
||||
Poly_double_2 px = Point_2::parametrize_poly(0),
|
||||
py = Point_2::parametrize_poly(1),
|
||||
pz = Point_2::parametrize_poly(2),
|
||||
pw = Point_2::parametrize_poly(3);
|
||||
|
||||
double pixw = (bbox.xmax() - bbox.xmin()) / res_w,
|
||||
pixh = (bbox.ymax() - bbox.ymin()) / res_h;
|
||||
typename std::list<Coord_vec_2>::const_iterator lit = points.begin();
|
||||
while(lit != points.end()) {
|
||||
|
||||
const Coord_vec_2& tmp = *lit++;
|
||||
typename Coord_vec_2::const_iterator cit;
|
||||
int xprev = -1, yprev = -1;
|
||||
for(cit = tmp.begin(); cit != tmp.end(); cit++) {
|
||||
|
||||
if(xprev == cit->x && yprev == cit->y)
|
||||
continue; // don't push duplicate points
|
||||
xprev = cit->x, yprev = cit->y;
|
||||
double s = bbox.xmin() + (double)xprev * pixw,
|
||||
t = bbox.ymin() + (double)yprev * pixh;
|
||||
|
||||
// std::cerr << "x = " << cit->x << "; y = " << cit->y <<
|
||||
// "; x0 = " << x0 << "; y0 = " << y0 << std::endl;
|
||||
double x0, y0, z0, w0 = NiX::substitute_xy(pw, s, t);
|
||||
if(std::abs(w0) < 1e-17)
|
||||
continue;
|
||||
|
||||
x0 = NiX::substitute_xy(px, s, t) / w0;
|
||||
y0 = NiX::substitute_xy(py, s, t) / w0;
|
||||
z0 = NiX::substitute_xy(pz, s, t) / w0;
|
||||
*oi++ = Approximation_3(x0, y0, z0);
|
||||
}
|
||||
}
|
||||
return oi;
|
||||
}
|
||||
|
||||
#endif // CGAL_CKvA_COMPILE_RENDERER
|
||||
#endif
|
||||
//!@}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Bbox_2.h>
|
||||
#include <CGAL/Twotuple.h>
|
||||
#include <CGAL/Arithmetic_kernel.h>
|
||||
|
||||
#include <CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h>
|
||||
|
|
@ -69,23 +70,20 @@ class Curve_renderer_interface;
|
|||
* represents a single curve renderer instance with usual parameter set to
|
||||
* speed up rendering of several objects supported by the same curve
|
||||
*
|
||||
* @warning not recommended to use for multi-threaded applications
|
||||
* @warning not recommended to use in multi-threaded applications
|
||||
*/
|
||||
template <class CurvedKernelViaAnalysis_2>
|
||||
class Curve_renderer_facade
|
||||
{
|
||||
Curve_renderer_facade() { // private constructor
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
typedef CGAL::Interval_nt<true> Interval_double;
|
||||
|
||||
typedef Curve_renderer_interface<CurvedKernelViaAnalysis_2,
|
||||
Interval_double> Curve_renderer;
|
||||
|
||||
typedef typename Curve_renderer::Coord_vec_2 Coord_vec_2;
|
||||
|
||||
typedef typename Curve_renderer::Coord_2 Coord_2;
|
||||
Interval_double > Curve_renderer;
|
||||
|
||||
static Curve_renderer& instance() {
|
||||
static Curve_renderer _this;
|
||||
|
|
@ -95,9 +93,9 @@ public:
|
|||
static void setup(const CGAL::Bbox_2& bbox, int res_w, int res_h) {
|
||||
int _w, _h;
|
||||
CGAL::Bbox_2 tmp;
|
||||
instance().get_resolution(_w, _h);
|
||||
instance().get_window(tmp);
|
||||
|
||||
CORE::CORE_init(2);
|
||||
CORE::setDefaultPrecision(70, CORE::extLong::getPosInfty());
|
||||
instance().get_setup_parameters(&tmp, _w, _h);
|
||||
if(bbox != tmp || res_w != _w || res_h != _h) {
|
||||
instance().setup(bbox, res_w, res_h);
|
||||
}
|
||||
|
|
@ -130,12 +128,6 @@ public:
|
|||
typedef typename Curved_kernel_via_analysis_2::Curve_kernel_2
|
||||
Curve_kernel_2;
|
||||
|
||||
//! approximation coordinates
|
||||
typedef CGALi::Coord_2 Coord_2;
|
||||
|
||||
//! vector of coordinates
|
||||
typedef CGALi::Coord_vec_2 Coord_vec_2;
|
||||
|
||||
//! exact rational number type
|
||||
typedef typename ::CGAL::Get_arithmetic_kernel<
|
||||
typename Curve_kernel_2::Coefficient>::Arithmetic_kernel
|
||||
|
|
@ -216,12 +208,11 @@ public:
|
|||
//! \name Public methods and properties
|
||||
//!@{
|
||||
|
||||
inline void get_window(CGAL::Bbox_2& bbox) {
|
||||
return renderer().get_window(bbox);
|
||||
}
|
||||
|
||||
inline void get_resolution(int& res_w, int& res_h) {
|
||||
return renderer().get_resolution(res_w, res_h);
|
||||
//!@note pass null-pointer for \c pbox parameter if you don't need
|
||||
//! the drawing window
|
||||
inline void get_setup_parameters(CGAL::Bbox_2 *pbox, int& res_w,
|
||||
int& res_h) {
|
||||
return renderer().get_setup_parameters(pbox, res_w, res_h);
|
||||
}
|
||||
|
||||
/*!\brief
|
||||
|
|
@ -241,51 +232,55 @@ public:
|
|||
/*!\brief
|
||||
* rasterizes an x-monotone curve \c arc
|
||||
*
|
||||
* returns a list of sequences of pixel coordinates in \c points and
|
||||
* end-point coordinats in \c end_points
|
||||
* outputs the list of sequences of pixel coordinates as objects of type
|
||||
* \c Coord_2 to the output iterator \c pts , end-point coordinates are
|
||||
* returned as a two-tuple \c end_pts
|
||||
*
|
||||
* \c Container must support \c push_back and \c clear operations
|
||||
*
|
||||
* \c Coord_2 must be constructible from a pair of integers / doubles
|
||||
* depending on the renderer type
|
||||
*/
|
||||
inline void draw(const Arc_2& arc, std::list<Coord_vec_2>& points,
|
||||
std::pair<Coord_2, Coord_2>& end_points)
|
||||
{
|
||||
template < class Coord_2, template < class > class Container >
|
||||
inline void draw(const Arc_2& arc, Container< std::vector<Coord_2> >& pts,
|
||||
CGAL::Twotuple< Coord_2 >& end_pts) {
|
||||
|
||||
#ifndef CGAL_CKVA_DUMMY_RENDERER
|
||||
Bbox_2 bbox;
|
||||
int res_w, res_h;
|
||||
try {
|
||||
renderer().draw(arc, points, end_points);
|
||||
renderer().draw(arc, pts, end_pts);
|
||||
}
|
||||
catch(CGALi::Insufficient_rasterize_precision_exception) {
|
||||
std::cerr << "Switching to multi-precision arithmetic" <<
|
||||
std::endl;
|
||||
#ifdef CGAL_CKVA_USE_MULTIPREC_ARITHMETIC
|
||||
Bbox_2 bbox;
|
||||
int res_w, res_h;
|
||||
if(::boost::is_same<typename NiX::NT_traits<Float>::Is_exact,
|
||||
CGAL::Tag_true>::value)
|
||||
if(::boost::is_same<typename Algebraic_structure_traits< Float >::
|
||||
Is_exact, CGAL::Tag_true>::value)
|
||||
goto Lexit;
|
||||
|
||||
get_window(bbox);
|
||||
get_resolution(res_w, res_h);
|
||||
|
||||
get_setup_parameters(&bbox, res_w, res_h);
|
||||
bigfloat_renderer().setup(bbox, res_w, res_h);
|
||||
try {
|
||||
points.clear();
|
||||
bigfloat_renderer().draw(arc, points, end_points);
|
||||
pts.clear();
|
||||
bigfloat_renderer().draw(arc, pts, end_pts);
|
||||
return;
|
||||
}
|
||||
catch(CGALi::Insufficient_rasterize_precision_exception) {
|
||||
|
||||
std::cerr << "Switching to exact arithmetic" << std::endl;
|
||||
#ifdef CGAL_CKVA_USE_RATIONAL_ARITHMETIC
|
||||
Bbox_2 bbox;
|
||||
int res_w, res_h;
|
||||
if(::boost::is_same<typename NiX::NT_traits<Float>::Is_exact,
|
||||
CGAL::Tag_true>::value)
|
||||
|
||||
if(::boost::is_same<
|
||||
typename Algebraic_structure_traits< Float >::Is_exact,
|
||||
CGAL::Tag_true>::value)
|
||||
goto Lexit;
|
||||
|
||||
get_window(bbox);
|
||||
get_resolution(res_w, res_h);
|
||||
get_setup_parameters(&bbox, res_w, res_h);
|
||||
exact_renderer().setup(bbox, res_w, res_h);
|
||||
|
||||
try {
|
||||
points.clear();
|
||||
exact_renderer().draw(arc, points, end_points);
|
||||
pts.clear();
|
||||
exact_renderer().draw(arc, pts, end_pts);
|
||||
return;
|
||||
}
|
||||
catch(CGALi::Insufficient_rasterize_precision_exception) {
|
||||
|
|
@ -299,8 +294,9 @@ Lexit: std::cerr << "Sorry, this does not work even with exact "
|
|||
std::cerr << "polynomial: " << renderer().curve().polynomial_2() <<
|
||||
std::endl;
|
||||
|
||||
renderer().get_window(bbox);
|
||||
std::cerr << "window: " << bbox << std::endl;
|
||||
renderer().get_setup_parameters(&bbox, res_w, res_h);
|
||||
std::cerr << "window: " << bbox << "; resolution: " <<
|
||||
res_w << " x " << res_h << std::endl;
|
||||
|
||||
#endif // CGAL_CKVA_USE_MULTIPREC_ARITHMETIC
|
||||
}
|
||||
|
|
@ -308,9 +304,14 @@ Lexit: std::cerr << "Sorry, this does not work even with exact "
|
|||
}
|
||||
|
||||
/*!\brief
|
||||
* rasterizes a point on curve
|
||||
* rasterizes a point on curve, returns point coordinates as objects of
|
||||
* type \c Coord_2 which are constructible from a pair of ints / doubles
|
||||
*
|
||||
* retunrs \c false if point lies outside the window or cannot be
|
||||
* rasterized due to precision problems
|
||||
*/
|
||||
bool draw(const Point_2& point, CGALi::Coord_2& coord) {
|
||||
template < class Coord_2 >
|
||||
bool draw(const Point_2& point, Coord_2& coord) {
|
||||
#ifndef CGAL_CKVA_DUMMY_RENDERER
|
||||
try {
|
||||
return renderer().draw(point, coord);
|
||||
|
|
@ -327,8 +328,6 @@ Lexit: std::cerr << "Sorry, this does not work even with exact "
|
|||
//!@}
|
||||
}; // Curve_renderer_interface
|
||||
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_CKVA_CURVE_RENDERER_FACADE_H
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -82,45 +82,61 @@ static const int DIR_TAKEN_MAP[] =
|
|||
{1, 1, -1, 0, 0, 0, -1, 1};
|
||||
|
||||
template <class Integer>
|
||||
struct Pixel_2_templ
|
||||
struct Pixel_2_
|
||||
{
|
||||
int x, y; // pixel coordinates relative to the drawing area
|
||||
unsigned level; // subdivision level: 0 - for pixels,
|
||||
// 1 - for 1/2 pixels, and so on)
|
||||
#ifdef CGAL_CKVA_RENDER_WITH_REFINEMENT
|
||||
double xv, yv; // double approximation of curve-pixel intersection point
|
||||
#endif
|
||||
|
||||
Integer sub_x, sub_y; // subpixel coordinates relative to pixel's boundary
|
||||
// (always 0 for pixels)
|
||||
bool operator ==(const Pixel_2_templ<Integer>& pix) const
|
||||
{
|
||||
|
||||
Pixel_2_& operator =(const Pixel_2_& pix) {
|
||||
#ifdef CGAL_CKVA_RENDER_WITH_REFINEMENT
|
||||
memcpy(this, &pix, sizeof(int)*3 + sizeof(double)*2);
|
||||
#else
|
||||
memcpy(this, &pix, sizeof(int)*3);
|
||||
#endif
|
||||
sub_x = pix.sub_x;
|
||||
sub_y = pix.sub_y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator ==(const Pixel_2_& pix) const {
|
||||
if(memcmp(this, &pix, sizeof(int)*3))
|
||||
return false;
|
||||
return (sub_x==pix.sub_x&&sub_y==pix.sub_y);
|
||||
return (sub_x == pix.sub_x && sub_y == pix.sub_y);
|
||||
}
|
||||
};
|
||||
|
||||
// structure describing the seed point and backward direction, support for
|
||||
// multiple seed points
|
||||
template <class Integer>
|
||||
struct Seed_point_templ
|
||||
struct Seed_point_
|
||||
{
|
||||
Seed_point_templ()
|
||||
Seed_point_()
|
||||
{ }
|
||||
Seed_point_templ(const Pixel_2_templ<Integer>& start_, int dir_,
|
||||
int orient_, int taken_, bool coincide_) : start(start_),
|
||||
back_dir(dir_), orient(orient_), direction_taken(taken_),
|
||||
|
||||
Seed_point_(const Pixel_2_<Integer>& start_, int dir_,
|
||||
int taken_, bool coincide_) : start(start_),
|
||||
back_dir(dir_), direction_taken(taken_),
|
||||
branches_coincide(coincide_)
|
||||
{ }
|
||||
Pixel_2_templ<Integer> start; // starting pixel
|
||||
|
||||
Pixel_2_<Integer> start; // starting pixel
|
||||
int back_dir; // backward direction
|
||||
int orient; // 0 - push_back, 1 - push_front
|
||||
int direction_taken;
|
||||
bool branches_coincide;
|
||||
};
|
||||
|
||||
template <class Rational, class AlgebraicReal>
|
||||
struct Clip_point_templ // describes a bottom/top clip point
|
||||
struct Clip_point_ // describes a bottom/top clip point
|
||||
{
|
||||
Clip_point_templ() { }
|
||||
Clip_point_templ(Rational left_, Rational right_, int arcno_=-1) :
|
||||
Clip_point_() { }
|
||||
Clip_point_(Rational left_, Rational right_, int arcno_=-1) :
|
||||
left(left_), right(right_), arcno(arcno_) { }
|
||||
Rational left, right; // isolating interval boundaries
|
||||
int arcno; // arcno of a segment this point belongs to
|
||||
|
|
@ -128,7 +144,7 @@ struct Clip_point_templ // describes a bottom/top clip point
|
|||
};
|
||||
|
||||
template <class Integer>
|
||||
std::ostream& operator <<(std::ostream& os, const Pixel_2_templ<Integer>& pix)
|
||||
std::ostream& operator <<(std::ostream& os, const Pixel_2_<Integer>& pix)
|
||||
{
|
||||
os << " (" << pix.x << "/" << pix.sub_x << "; " << pix.y << "/" <<
|
||||
pix.sub_y << ") level = " << pix.level;
|
||||
|
|
@ -140,17 +156,6 @@ std::ostream& operator <<(std::ostream& os, const Pixel_2_templ<Integer>& pix)
|
|||
class Insufficient_rasterize_precision_exception
|
||||
{ };
|
||||
|
||||
struct Coord_2 {
|
||||
|
||||
Coord_2() {
|
||||
}
|
||||
Coord_2(int x_, int y_) : x(x_), y(y_) {
|
||||
}
|
||||
int x, y;
|
||||
};
|
||||
|
||||
typedef std::vector<Coord_2> Coord_vec_2;
|
||||
|
||||
/*! \brief defines class \c Curve_renderer_internals
|
||||
*
|
||||
* provides an interface to low-level range analysis and polynomials evaluation
|
||||
|
|
@ -502,9 +507,9 @@ bool Curve_renderer_internals<CurveKernel_2, Coeff_>::setup(
|
|||
res_w = res_w_;
|
||||
res_h = res_h_;
|
||||
|
||||
if(x_min >= x_max||y_min >= y_max||res_w < 5||res_h < 5||res_w > 1024||
|
||||
res_h > 1024) {
|
||||
Gfx_OUT("Incorrect setup parameters" << std::endl);
|
||||
if(x_min >= x_max||y_min >= y_max||res_w < 4||res_h < 4||res_w > 2048||
|
||||
res_h > 2048) {
|
||||
std::cerr << "Incorrect setup parameters" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -515,8 +520,6 @@ bool Curve_renderer_internals<CurveKernel_2, Coeff_>::setup(
|
|||
|
||||
pixel_w_r = (x_max_r - x_min_r) / res_w;
|
||||
pixel_h_r = (y_max_r - y_min_r) / res_h;
|
||||
// NiX::simplify(pixel_w_r);
|
||||
// NiX::simplify(pixel_h_r);
|
||||
|
||||
pixel_w = rat2float(pixel_w_r);
|
||||
pixel_h = rat2float(pixel_h_r);
|
||||
|
|
@ -863,10 +866,6 @@ int Curve_renderer_internals<CurveKernel_2, Coeff_>::evaluate_generic(
|
|||
} else
|
||||
c1 = y_min + c*pixel_h;
|
||||
|
||||
if(show_dump) {
|
||||
//Gfx_OUT("evaluate " << poly << " at: " << c1 << "\n");
|
||||
}
|
||||
|
||||
if(!not_cached) {
|
||||
hash_key.first = x_min + x*pixel_w;
|
||||
hash_key.second = y_min + y*pixel_h;
|
||||
|
|
|
|||
|
|
@ -29,15 +29,16 @@ CGAL_BEGIN_NAMESPACE
|
|||
* outputs a curve arc to \c Qt_widget
|
||||
*/
|
||||
template <class CKvA_2>
|
||||
Qt_widget& operator << (Qt_widget& ws, const typename CKvA_2::Arc_2& arc) {
|
||||
Qt_widget& operator << (Qt_widget& ws, const CGALi::Arc_2< CKvA_2 >& arc) {
|
||||
|
||||
typedef Curve_renderer_facade<CKvA_2> Facade;
|
||||
typedef typename Facade::Coord_vec_2 Coord_vec_2;
|
||||
typedef typename Facade::Coord_2 Coord_2;
|
||||
|
||||
typedef CGAL::Twotuple< int > Coord_2;
|
||||
typedef std::vector< Coord_2 > Coord_vec_2;
|
||||
|
||||
CGAL::Twotuple< Coord_2 > end_points;
|
||||
std::list<Coord_vec_2> points;
|
||||
std::pair<Coord_2, Coord_2> end_points;
|
||||
|
||||
|
||||
Facade::setup(CGAL::Bbox_2(ws.x_min(), ws.y_min(), ws.x_max(), ws.y_max()),
|
||||
ws.width(), ws.height());
|
||||
|
||||
|
|
@ -48,6 +49,8 @@ Qt_widget& operator << (Qt_widget& ws, const typename CKvA_2::Arc_2& arc) {
|
|||
QPainter *ppnt = &ws.get_painter();
|
||||
int height = ws.height();
|
||||
|
||||
// std::cerr << ws.width() << " and " << ws.height() << "\n";
|
||||
|
||||
typename std::list<Coord_vec_2>::const_iterator lit = points.begin();
|
||||
while(lit != points.end()) {
|
||||
|
||||
|
|
@ -55,15 +58,18 @@ Qt_widget& operator << (Qt_widget& ws, const typename CKvA_2::Arc_2& arc) {
|
|||
typename Coord_vec_2::const_iterator vit = vec.begin();
|
||||
|
||||
if(vec.size() == 2) {
|
||||
ppnt->moveTo(vit->x, height - vit->y);
|
||||
ppnt->moveTo(vit->e0, height - vit->e1);
|
||||
vit++;
|
||||
ppnt->lineTo(vit->x, height - vit->y);
|
||||
ppnt->lineTo(vit->e0, height - vit->e1);
|
||||
|
||||
} else {
|
||||
ppnt->moveTo(vit->x, height - vit->y);
|
||||
ppnt->moveTo(vit->e0, height - vit->e1);
|
||||
//std::cerr << "(" << vit->e0 << "; " << vit->e1 << "\n";
|
||||
while(vit != vec.end()) {
|
||||
ppnt->lineTo(vit->x, height - vit->y);
|
||||
ppnt->lineTo(vit->e0, height - vit->e1);
|
||||
vit++;
|
||||
//if(vit != vec.end())
|
||||
//std::cerr << "(" << vit->e0 << "; " << vit->e1 << "\n";
|
||||
}
|
||||
}
|
||||
lit++;
|
||||
|
|
@ -72,9 +78,8 @@ Qt_widget& operator << (Qt_widget& ws, const typename CKvA_2::Arc_2& arc) {
|
|||
QPen old_pen = ppnt->pen();
|
||||
ppnt->setPen(QPen(Qt::NoPen)); // avoid drawing outlines
|
||||
// draw with the current brush attributes
|
||||
ppnt->drawEllipse(end_points.first.x-3,height-end_points.first.y-3, 6, 6);
|
||||
ppnt->drawEllipse(end_points.second.x-3,height-end_points.second.y-3,
|
||||
6, 6);
|
||||
ppnt->drawEllipse(end_points.e0.e0-3,height-end_points.e0.e1-3, 6, 6);
|
||||
ppnt->drawEllipse(end_points.e1.e0-3,height-end_points.e1.e1-3, 6, 6);
|
||||
ppnt->setPen(old_pen);
|
||||
|
||||
return ws;
|
||||
|
|
@ -84,11 +89,11 @@ Qt_widget& operator << (Qt_widget& ws, const typename CKvA_2::Arc_2& arc) {
|
|||
* outputs a curve point to \c Qt_widget
|
||||
*/
|
||||
template <class CKvA_2>
|
||||
Qt_widget& operator << (Qt_widget& ws, const typename CKvA_2::Point_2& pt) {
|
||||
Qt_widget& operator << (Qt_widget& ws, const CGALi::Point_2< CKvA_2 >& pt) {
|
||||
|
||||
typedef Curve_renderer_facade<CKvA_2> Facade;
|
||||
|
||||
typename Facade::Coord_2 coord;
|
||||
CGAL::Twotuple< int > coord;
|
||||
Facade::setup(CGAL::Bbox_2(ws.x_min(), ws.y_min(), ws.x_max(), ws.y_max()),
|
||||
ws.width(), ws.height());
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include <CGAL/Curved_kernel_via_analysis_2l/Surface_arc_2l.h>
|
||||
#include <CGAL/Curved_kernel_via_analysis_2l/Curved_kernel_via_analysis_2l_functors.h>
|
||||
|
||||
#ifdef CGAL_CKvA_COMPILE_RENDERER
|
||||
#ifdef CGAL_CKVA_COMPILE_RENDERER
|
||||
#include <CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ public:
|
|||
//!\name approximation & visualization
|
||||
//!@{
|
||||
|
||||
#ifdef CGAL_CKvA_COMPILE_RENDERER
|
||||
#ifdef CGAL_CKVA_COMPILE_RENDERER
|
||||
|
||||
//! sets up rendering window \c bbox and resolution \c res_w by \c res_h
|
||||
static void setup_renderer(CGAL::Bbox_2 bbox, int res_w, int res_h) {
|
||||
|
|
@ -261,7 +261,7 @@ public:
|
|||
result = Approximation_3(x0, y0, compute_z(ppt, this->sheet()));
|
||||
return true;
|
||||
}
|
||||
#endif // CGAL_CKvA_COMPILE_RENDERER
|
||||
#endif // CGAL_CKVA_COMPILE_RENDERER
|
||||
//!@}
|
||||
|
||||
//! for constructint points
|
||||
|
|
@ -585,7 +585,7 @@ public:
|
|||
//!\name visualization
|
||||
//!@{
|
||||
|
||||
#ifdef CGAL_CKvA_COMPILE_RENDERER
|
||||
#ifdef CGAL_CKVA_COMPILE_RENDERER
|
||||
|
||||
|
||||
|
||||
|
|
@ -645,7 +645,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
#endif // CGAL_CKvA_COMPILE_RENDERER
|
||||
#endif // CGAL_CKVA_COMPILE_RENDERER
|
||||
//!@}
|
||||
|
||||
// friends
|
||||
|
|
|
|||
Loading…
Reference in New Issue