Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Optimize snap rounding operation
- Date: Mon, 17 Oct 2011 23:55:58 -0700
I am not sure what you use as kernel but simply this should be
the most efficient:
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Snap_rounding_traits_2<Kernel> Traits;
Sebastien.
On 10/17/2011 01:14 AM, Graviton wrote:
I would need to snap round a list of polygons I have, here's my code:
#include<CGAL/basic.h>
#include<CGAL/Cartesian.h>
#include<CGAL/Quotient.h>
#include<CGAL/MP_Float.h>
#include<CGAL/Snap_rounding_traits_2.h>
#include<CGAL/Snap_rounding_2.h>
struct Kernel : public CGAL::Exact_predicates_exact_constructions_kernel
{};
typedef Kernel::FT Number_type;
//typedef CGAL::Quotient<CGAL::Gmpq> Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Snap_rounding_traits_2<Kernel> Traits;
typedef Kernel::Segment_2 Segment_2;
typedef Kernel::Point_2 Point_2;
typedef std::list<Segment_2> Segment_list_2;
typedef std::list<Point_2> Polyline_2;
typedef std::list<Polyline_2> Polyline_list_2;
void ComputeSegment(Segment_list_2 seg_list)
{
Polyline_list_2 output_list;
CGAL::snap_rounding_2<Traits,Segment_list_2::const_iterator,Polyline_list_2>
(seg_list.begin(), seg_list.end(), output_list, 10, false, false, 1);
int counter = 0;
Polyline_list_2::const_iterator iter1;
for (iter1 = output_list.begin(); iter1 != output_list.end(); ++iter1) {
std::cout<< "Polyline number "<< ++counter<< ":\n";
Polyline_2::const_iterator iter2;
for (iter2 = iter1->begin(); iter2 != iter1->end(); ++iter2)
std::cout<< " ("<< iter2->x()<< ":"<< iter2->y()<< ")\n";
}
}
My dataset contains about 3000 segments, however, when I run the above code
it took about 1 second.
I just wonder is there anyway I can further make this code run faster, but
not at the expense of the accuracy and system stability?
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Optimize-snap-rounding-operation-tp3911353p3911353.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Optimize snap rounding operation, Graviton, 10/17/2011
- Re: [cgal-discuss] Optimize snap rounding operation, Sebastien Loriot (GeometryFactory), 10/18/2011
Archive powered by MHonArc 2.6.16.