Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Extra Points are generated when using snap rounding

Subject: CGAL users discussion list

List archive

[cgal-discuss] Extra Points are generated when using snap rounding


Chronological Thread 
  • From: Graviton <>
  • To:
  • Subject: [cgal-discuss] Extra Points are generated when using snap rounding
  • Date: Tue, 3 Jan 2012 22:43:27 -0800 (PST)

This is 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>

typedef CGAL::Quotient<CGAL::MP_Float> 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;

int main()
{
Segment_list_2 seg_list;
Polyline_list_2 output_list;

double mag = 50;
// seg_list.push_back(Segment_2(Point_2(0.25*mag, 0.25*mag),
Point_2(0.75*mag, 0.75*mag)));
seg_list.push_back(Segment_2(Point_2(354250, -6750), Point_2(365750,
-10750)));
seg_list.push_back(Segment_2(Point_2(350250, -53750), Point_2(365750,
-10749.99609375)));
/* seg_list.push_back(Segment_2(Point_2(7, 0), Point_2(7, 10)));*/

// 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<Traits,Segment_list_2::const_iterator,Polyline_list_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);
}



and the output is
Polyline number 1:
{700501/2, -13499.5/2}
{731500/2, -21499.5/2}
{731501/2, -21499.5/2}

Polyline number 2:
{700501/2, -107500/2}
{731500/2, -21499.5/2}
{731501/2, -21499.5/2}

But I feel that there should only be 2 points in both Polyline number 1 and
Polyline number 2, as the Point 2 of segment 1 and segment 2 are very near
to each other and should be rounded as such.

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Extra-Points-are-generated-when-using-snap-rounding-tp4260237p4260237.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page