Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Snap Rounding Only Works when Pixel Size>1?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Snap Rounding Only Works when Pixel Size>1?


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Snap Rounding Only Works when Pixel Size>1?
  • Date: Wed, 16 Mar 2011 15:52:30 +0100

These is indeed a problem.

with 0.01 I got one point and with 0.011 I got a segment.

I'll have a closer look at what is going on.

If Gmp is available on your machine, use CGAL::Gmpq (which is a better choice anyway) as Number_type and the problem should no longer appear.

S.

nsoonhui wrote:
I found that if pixel size is less than 1( but bigger than 0), then the pixel
size is taken as 1, regardless of what you specify.

Here's the code sample that demonstrates my point:


#include #include #include #include #include #include
typedef CGAL::Quotient Number_type;
typedef CGAL::Cartesian Kernel;
typedef CGAL::Snap_rounding_traits_2 Traits;
typedef Kernel::Segment_2 Segment_2;
typedef Kernel::Point_2 Point_2;
typedef std::list Segment_list_2;
typedef std::list Polyline_2;
typedef std::list Polyline_list_2;

int main()
{
Segment_list_2 seg_list;
Polyline_list_2 output_list;

double mag = 1;
seg_list.push_back(Segment_2(Point_2(0.25*mag, 0.25*mag),
Point_2(0.75*mag, 0.75*mag)));

// Generate an iterated snap-rounding representation, where the centers of
// the hot pixels bear their original coordinates, using 5 kd trees:
CGAL::snap_rounding_2
(seg_list.begin(), seg_list.end(), output_list, 0.01*mag, 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";
}

return(0);
}


The output is that there is only 1 segment with 1 point (0.51/2, 0.51/2).

However if I set mag=100, then there is 1 segment with2 points( 51/2,
0.51/2) and (151/2, 151/2).

I cna't help but feel that for mag=1, there really should be 1 segment with
2 points, like the case with mag=100. Am I right?

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Snap-Rounding-Only-Works-when-Pixel-Size-1-tp3340736p3340736.html
Sent from the cgal-discuss mailing list archive at Nabble.com.





Archive powered by MHonArc 2.6.16.

Top of Page