Subject: CGAL users discussion list
List archive
- From: "jasmeet.singh" <>
- To:
- Subject: Re: [cgal-discuss] Viewer for Arrangement 2D
- Date: Fri, 9 Aug 2019 02:41:05 -0500 (CDT)
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=Pass
- Ironport-phdr: 9a23:fgdfVReoKa4EyOlRiu6ROB2LlGMj4u6mDksu8pMizoh2WeGdxcS6YR7h7PlgxGXEQZ/co6odzbaP6ea5ADJLuM/Q+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe7x/IAiooQnLq8UanIpvJqksxhfUpnZDZvhby35vKV+PhRj3+92+/IRk8yReuvIh89BPXKDndKkmTrJWESorPXkt6MLkqRfMQw2P5mABUmoNiRpHHxLF7BDhUZjvtCbxq/dw1zObPc3ySrA0RCii4qJ2QxLmlCsLKzg0+3zRh8dtjqxUvQihqgRxzYDUfo+bN/hxfq3Ac9wVWWVPUd1cVzBDD4+gc4cDE/YNMfheooLgp1UOtxy+BQy0Ce/hyD9HnGT23agk3Os/DQHKxhcgH9MIsHTbrNX5OroZXOe3zKbS1jXDau1Z1inh6ITSaRAhoPeMXb1wccbLzEkgCR/KgkiNpYH+PjOV1/gNvHOb7+p9T+6gkXIopxtwojip38ohjJTCiIwSylDB7yp5wYA1KMW+SEFhetGrC59QuD+AO4RqRcMiRmdlszs5xL0eoZO3YSwHxZA9yxPRaPGLaYuF7xP5WOuQIDp1gm9udqiliBao60egz/XxVsmq31ZOqSpIit/Mu38X2xzV8MeIUeBy/kO/1jqVyw/T7eRELVg1lardNZEh3qY9mocXvEnHBCP7lkb7gLWVe0gl4OSl6uXqbq3jppCGNo90jg/+Mr4pmsy6Gek4MBIBX3Oe+euiyrLj4Vf1QK5Ljv0wnanZsIrWJcEFqaGlHgNZz50u6xe+Dze6y9sYnWQHIEhfdx2blYTpOlfOLOjiDfijm1SsjCtrx/feM7L9DZXCNHzDnK78crZ88E5T1BczzctE559PEbEAIPfzWlfru9DCDx85NRa0w+f9B9ln2IMeQzHHPqjMO6zbtRqE5/kkPvKXTI4Tojf0bfY/tND0inps010UZqyk0IdRc3G+EfQsaxGbaGHpj9odV3wLuAU+CunngwTbeT9Se3yyQuQ17Xc6DtT1Xs/4WomxjenZj2+AFZpMazUeUw3eITLTb4yBHsw0RmeSL8tmy2FWU+TnTYYr3xWj8gT9zug+d7aGymgjrZvmkeNNyajLjxhrqW51DtiX03zLRmoyn2VaH2ZnjpA6mlR0zxK46YY9hvVZEdJJ4PYQDlU7NILWz/E8Atu0WwSTJdo=
Thanks, everyone for the answers. I really appreciate it.
I do not think that I truly understand what exactly has to be done to solve
the root of the issue here. Getting the Kernel from the point type is not
the right way as pointed out earlier
(CGAL::Kernel_traits<Arr_circle_segment_traits_2<K>::Point_2>::Kernel).
However, the Basic viewer currently imports everything into the buffer by
first converting the points into the Kernel -
CGAL::Exact_predicates_exact_constructions_kernel.
//
-------------------------------------------------------------------------------------
// Structs to transform any CGAL point/vector into a
Local_point/Local_vector
template<typename K>
struct Geom_utils
{
static Local_point get_local_point(const typename K::Point_2& p)
{
CGAL::Cartesian_converter<K, Local_kernel> converter;
return Local_point(converter(p.x()), 0, converter(p.y()));
}
static Local_point get_local_point(const typename K::Weighted_point_2&
p)
{
typename K::Point_2 lp(p);
return Geom_utils<K>::get_local_point(lp);
}
static Local_point get_local_point(const typename K::Point_3& p)
{
CGAL::Cartesian_converter<K, Local_kernel> converter;
return converter(p);
}
static Local_point get_local_point(const typename K::Weighted_point_3&
p)
{
typename K::Point_3 lp(p);
return Geom_utils<K>::get_local_point(lp);
}
static Local_vector get_local_vector(const typename K::Vector_2& v)
{
CGAL::Cartesian_converter<K, Local_kernel> converter;
return Local_vector(converter(v.x()), 0, converter(v.y()));
}
static Local_vector get_local_vector(const typename K::Vector_3& v)
{
CGAL::Cartesian_converter<K, Local_kernel> converter;
return converter(v);
}
static Local_ray get_local_ray(const typename K::Ray_2& r)
{
CGAL::Cartesian_converter<K, Local_kernel> converter;
return converter(r);
}
};
// Specialization for Local_kernel, because there is no need of conversion
here.
template<>
struct Geom_utils<Local_kernel>
{
static Local_point get_local_point(const Local_kernel::Point_2& p)
{ return Local_point(p.x(), 0, p.y()); }
static Local_point get_local_point(const Local_kernel::Weighted_point_2&
p)
{ return Local_point(p.point().x(), 0, p.point().y());}
static const Local_point & get_local_point(const Local_kernel::Point_3&
p)
{ return p; }
static Local_point get_local_point(const Local_kernel::Weighted_point_3&
p)
{ return Local_point(p);}
static Local_vector get_local_vector(const Local_kernel::Vector_2& v)
{ return Local_vector(v.x(), 0, v.y()); }
static const Local_vector& get_local_vector(const
Local_kernel::Vector_3& v)
{ return v; }
};
////////////////////////////////////////////////////////////////
// Global function to simplify function calls.
template<typename KPoint>
Local_point get_local_point(const KPoint& p)
{
return Geom_utils<typename CGAL::Kernel_traits<KPoint>::Kernel>::
get_local_point(p);
}
template<typename KVector>
Local_vector get_local_vector(const KVector& v)
{
return Geom_utils<typename CGAL::Kernel_traits<KVector>::Kernel>::
get_local_vector(v);
}
//
-------------------------------------------------------------------------------------
After trying several methods, I found a method to bypass the conversion of
the point type. I make a call to the add_point() method in circular segment
viewer after converting the point to the kernel used in the buffer of the
basic viewer.
//
-------------------------------------------------------------------------------------
typedef CGAL::Exact_predicates_exact_constructions_kernel Viewer_kernel;
Viewer_kernel::Point_3 p(to_double(vit->point().x()), 0,
to_double(vit->point().y()));
this->add_point(p);
//
-------------------------------------------------------------------------------------
This way the code compiles just fine and the points can be viewed in the
viewer window. I know this is probably not the best method to deal with the
problem at hand but it works for the viewer's purposes. Kindly let me know
if you can suggest doing something better.
Also, can you comment on the second part of my doubt:
2. To draw the various curves, the demo uses Qt5's various function defined
in qpainter.h, eg. drawArc, drawEllipse. However, the basic viewer doesn't
have support for drawing such curves. How can I draw the curves in the
arrangement without much duplication in the code? Should I write the draw
functionalities for circular arcs, bezier curves, etc. from scratch or can I
use it from somewhere?
--
Sent from: http://cgal-discuss.949826.n4.nabble.com/
- Re: [cgal-discuss] Viewer for Arrangement 2D, Guillaume Damiand, 08/03/2019
- Re: [cgal-discuss] Viewer for Arrangement 2D, Efi Fogel, 08/03/2019
- Re: [cgal-discuss] Viewer for Arrangement 2D, jasmeet.singh, 08/09/2019
- Re: [cgal-discuss] Viewer for Arrangement 2D, Efi Fogel, 08/03/2019
Archive powered by MHonArc 2.6.18.