Subject: CGAL users discussion list
List archive
- From: Icek <>
- To:
- Subject: [cgal-discuss] Construct Polyhedron from points
- Date: Sun, 26 Jul 2009 23:29:26 -0700 (PDT)
Hello, Im trying to construct Polyhedron from my mesh structure. And then
NefPolyhedron from polyhedron. I found that I have to use Incremental
builder, but resulting polyhedron is_closed() is always false, even when my
mesh is simple cube. And NefPolyheron requires closed polyhedron, so is this
piece of code right? Or how do I create polyhedron from points?
template <class HDS> class PolyhedronFromMesh : public
CGAL::Modifier_base<HDS>
{
public:
PolyhedronFromMesh(const Mesh & mesh) : _mesh(mesh)
{
}
void operator()( HDS& hds)
{
// Postcondition: `hds' is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B( hds, false);
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
unsigned int nPoints = _mesh.Points.size();
unsigned int nFacets = _mesh.Indices.size() ? _mesh.Indices.size()
/ 3 : nPoints / 3;
B.begin_surface(nPoints,nFacets);
for(unsigned int i = 0; i < nPoints; i++)
{
Vec3 p = _mesh.Points[i];
B.add_vertex(Point(p.x,p.y, p.z));
}
if(_mesh.Indices.size())
for(unsigned int i=0; i < _mesh.Indices.size(); i+=3)
{
B.begin_facet();
B.add_vertex_to_facet((long unsigned int)_mesh.Indices[i]);
B.add_vertex_to_facet((long unsigned int)_mesh.Indices[i+1]);
B.add_vertex_to_facet((long unsigned int)_mesh.Indices[i+2]);
B.end_facet();
}
else
for(unsigned int i=0; i < _mesh.Indices.size(); i+=3)
{
B.begin_facet();
B.add_vertex_to_facet( i);
B.add_vertex_to_facet( i+1);
B.add_vertex_to_facet( i+2);
B.end_facet();
}
B.end_surface();
}
const Mesh & _mesh;
};
--
View this message in context:
http://www.nabble.com/Construct-Polyhedron-from-points-tp24674159p24674159.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Construct Polyhedron from points, Icek, 07/27/2009
- Re: [cgal-discuss] Construct Polyhedron from points, Matthias Teich, 07/27/2009
- Re: [cgal-discuss] Construct Polyhedron from points, Icek, 07/27/2009
- Re: [cgal-discuss] Construct Polyhedron from points, Matthias Teich, 07/27/2009
Archive powered by MHonArc 2.6.16.