Subject: CGAL users discussion list
List archive
- From: "Max" <>
- To: "" <>
- Subject: [cgal-discuss][Polyhedron] Integrate several Off models into one single model
- Date: Sat, 9 Feb 2008 00:06:04 +0800
- Disposition-notification-to: "Max" <>
- Organization: LoadCom
Hi all,
I want to integrate several Off models(manifold) into a single model.
I found the incremental builder example for polyhedron in the documentation.
I adapted the code for my purpose. Everything seems to be smooth. The program
ends successfully, and the visulization of the result is just want I expected.
However, having a closer look at the resulting file, I find a strange
phenomenom - the resulting number of vertices and facets is much greater
than what they 'should me'.
For example, I was combining 6 similar but disconnected models, each has 578
vertices and 1152 facets. To my surprise, the resulting model has 12138
vertices
and 24192 facets, far more than 6*578 and 6*1152, respectively.
All of the working code is as follows:
// A modifier creating a polyhedron with the incremental builder
template <class Polyhedron_3>
class Build_polyhedron : public CGAL::Modifier_base<typename
Polyhedron_3::HDS>
{
typedef typename Polyhedron_3::HDS HDS;
typedef typename Polyhedron_3::Point_const_iterator Point_iterator;
typedef typename Polyhedron_3::Facet_const_iterator Facet_iterator;
typedef typename Polyhedron_3::Halfedge_around_facet_const_circulator
Halfedge_facet_circulator;
const Polyhedron_3 &p_;
Build_polyhedron() {} // not open to user
public:
explicit Build_polyhedron(const Polyhedron_3 &p) : p_(p) {}
void operator() (HDS& hds)
{
typedef CGAL::Polyhedron_incremental_builder_3<HDS> Builder;
// Postcondition: `hds' is a valid polyhedral surface.
Builder B(hds, true);
// building a surface
B.begin_surface(p_.size_of_vertices(), 1);
// building vertices
for(Point_iterator p = p_.points_begin(); p !=
p_.points_end(); ++p)
B.add_vertex(*p);
// building facets
for(Facet_iterator f = p_.facets_begin(); f !=
p_.facets_end(); ++f)
{
B.begin_facet();
Halfedge_facet_circulator c = f->facet_begin();
// Facets in polyhedral surfaces are at least
triangles.
CGAL_assertion(CGAL::circulator_size(c) >= 3);
do {
B.add_vertex_to_facet(std::distance(p_.vertices_begin(), c->vertex()));
} while ( ++c != f->facet_begin());
B.end_facet();
}
B.end_surface();
}
};
// Integrate source into target
template<class Polyhedron_3>
void IntegratePolyhedron(Polyhedron_3 &target, const Polyhedron_3 &source)
{
Build_polyhedron<Polyhedron_3> polyhedron(source);
target.delegate(polyhedron);
}
Thanks in advance for any help.
B/Rgds
Max
- Re: [cgal-discuss] Kinetic_data_structures... some questions, Mahmood Naderan, 02/08/2008
- Re: [cgal-discuss] Kinetic_data_structures... some questions, Daniel Russel, 02/08/2008
- <Possible follow-up(s)>
- Re: [cgal-discuss] Kinetic_data_structures... some questions, Mahmood Naderan, 02/08/2008
- [cgal-discuss][Polyhedron] Integrate several Off models into one single model, Max, 02/08/2008
- Re: [cgal-discuss] Kinetic_data_structures... some questions, Daniel Russel, 02/08/2008
- Re: [cgal-discuss] Kinetic_data_structures... some questions, Mahmood Naderan, 02/09/2008
- Re: [cgal-discuss] Kinetic_data_structures... some questions, Mahmood Naderan, 02/09/2008
Archive powered by MHonArc 2.6.16.