Skip to Content.
Sympa Menu

cgal-discuss - A problem about convex_hull_3

Subject: CGAL users discussion list

List archive

A problem about convex_hull_3


Chronological Thread 
  • From: "dmyan" <>
  • To: <>
  • Subject: A problem about convex_hull_3
  • Date: Mon, 18 Jun 2007 00:56:05 +0800

Dear All,
I meet a problem about convex_hull_3 to compute the convex hull of a set of points. Some points in the set are same. I find the result of convex_hull_3 is different if the sequence of points are different. Does anyone know the reason? Thanks very much!

Following is the definition of primitives :

......
#ifdef CGAL_USE_GMP
#include <CGAL/Gmpq.h>
typedef CGAL::Gmpq RT;
#else
#include <CGAL/double.h>
typedef double RT;
#endif

typedef CGAL::Cartesian<RT> Kernel_3;
typedef CGAL::Convex_hull_traits_3<Kernel_3> Ch_Traits_3;
typedef CGAL::Point_3<Kernel_3> Point_3;
typedef CGAL::Vector_3<Kernel_3> Vector_3;
typedef CGAL::Sphere_3<Kernel_3> Sphere_3;
typedef Kernel_3::Segment_3 Segment_3;
typedef Ch_Traits_3::Polyhedron_3 Polyhedron_3;


Following is my testing code:

1st case: the output is : "convex hull is a segment "
double data[18][3] = { {0, -1.91232, 0},
{0, -1.91232, 0},
{0, -1.91232, 0},
{0, 0, 1.91232},
{0, -1.91232, 0},
{0, 0, 0},
{1.91232, 0, 0},
{0, -1.91232, 0},
{0, 0, 0},
{0, 0, 0},
{1.91232, 0, 0},
{1.91232, 0, 0},
{1.91232, 0, 0},
{0, 0, 1.91232},
{1.91232, 0, 0},
{1.91232, 0, 0},
{0, 0, 1.91232},
{0, -1.91232, 0}};
std::vector<Point_3> pts;
for(int i=0; i<18; ++i)
{
Point_3 p(data[i][0], data[i][1], data[i][2]);
pts.push_back(p);
}

// define object to hold convex hull
CGAL::Object ch_object;
// compute convex hull
CGAL::convex_hull_3(pts.begin(), pts.end(), ch_object);
// determine what kind of object it is
Segment_3 segment;
Polyhedron_3 polyhedron;
if ( CGAL::assign(segment, ch_object) )
std::cout << "convex hull is a segment " << std::endl;
else if ( CGAL::assign (polyhedron, ch_object) )
std::cout << "convex hull is a polyhedron " << std::endl;
else
std::cout << "convex hull error!" << std::endl;

2nd case: the output is : "convex hull is a polyhedron "

double data[18][3] = { {0, 0, 1.91232},
{0, 0, 1.91232},
{0, 0, 1.91232},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{1.91232, 0, 0},
{1.91232, 0, 0},
{1.91232, 0, 0},
{1.91232, 0, 0},
{1.91232, 0, 0},
{1.91232, 0, 0},
{0, -1.91232, 0},
{0, -1.91232, 0},
{0, -1.91232, 0},
{0, -1.91232, 0},
{0, -1.91232, 0},
{0, -1.91232, 0}};
std::vector<Point_3> pts;
for(int i=0; i<18; ++i)
{
Point_3 p(data[i][0], data[i][1], data[i][2]);
pts.push_back(p);
}

// define object to hold convex hull
CGAL::Object ch_object;
// compute convex hull
CGAL::convex_hull_3(pts.begin(), pts.end(), ch_object);
// determine what kind of object it is
Segment_3 segment;
Polyhedron_3 polyhedron;
if ( CGAL::assign(segment, ch_object) )
std::cout << "convex hull is a segment " << std::endl;
else if ( CGAL::assign (polyhedron, ch_object) )
std::cout << "convex hull is a polyhedron " << std::endl;
else
std::cout << "convex hull error!" << std::endl;



Thanks !

dmyan




Archive powered by MHonArc 2.6.16.

Top of Page