Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Problem with building polyhedron

Subject: CGAL users discussion list

List archive

[cgal-discuss] Problem with building polyhedron


Chronological Thread 
  • From: Omer Ozturk <>
  • To:
  • Subject: [cgal-discuss] Problem with building polyhedron
  • Date: Wed, 19 Nov 2014 07:42:30 -0800 (PST)

Hello everyone,
I'm having problem with building a polyhedron from points. What i'm doing is
like the following;

1. Create a sphere from implicit function:

Tr tr; // 3D-Delaunay triangulation
C2t3 c2t3 (tr); // 2D-complex in 3D-Delaunay triangulation
// defining the surface
Surface_3 surface(sphere_function, // pointer to function
Sphere_3(CGAL::ORIGIN, 2.)); // bounding sphere
// Note that "2." above is the *squared* radius of the bounding sphere!
// defining meshing criteria
CGAL::Surface_mesh_default_criteria_3
criteria(30., // angular bound
0.1, // radius bound
0.1); // distance bound
// meshing surface
CGAL::make_surface_mesh(c2t3, surface, criteria,
CGAL::Non_manifold_tag());

2. Insert the mesh points into a list:

Tr::Point_iterator iterator;

for(iterator = tr.points_begin(); iterator != tr.points_end();
iterator++){

Point p(iterator->x(), iterator->y(), iterator->z());
points.append(p);

}
3. Build the polyhedron from these points:

template <class HDS>
class Build_triangle : public CGAL::Modifier_base<HDS> {

public:
QList<Point> pts;

void setPoints(QList<Point> prmt){
pts = prmt;
}

Build_triangle() {}
void operator()( HDS& hds) {
// Postcondition: hds is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B( hds, true);
B.begin_surface(pts.length(), pts.length()/3, 0);
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
for(int i=0;i<pts.length(); i++){
B.add_vertex( Point( pts[i].x, pts[i].y, pts[i].z));
}
B.begin_facet();
for(int i=0;i&lt;pts.length(); i++){
B.add_vertex_to_facet( i);
}
B.end_facet();
B.end_surface();
}
};

//Some code here...

Polyhedron P;
Build_triangle&lt;HalfedgeDS> triangle;
triangle.setPoints(points);
P.delegate( triangle);

But when i do that, i get a line instead of a sphere. What am i doing wrong?

Thanks.



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Problem-with-building-polyhedron-tp4660130.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page