Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Restore an old status of a polyhedron

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Restore an old status of a polyhedron


Chronological Thread 
  • From: Pierre Alliez <>
  • To:
  • Subject: Re: [cgal-discuss] Restore an old status of a polyhedron
  • Date: Thu, 02 Oct 2008 17:36:05 +0200
  • Organization: INRIA

hi Abel,

you can always copy the whole mesh using the copy constructor of the polyhedron.

you can always elaborate upon a simple mesh builder that takes a triangle soup using the exemple class attached.

Make_triangle_soup<Polyhedron,Kernel,Iterator> soup_builder;
soup_builder.run(triangles.begin(),triangles.end(),*pSoup);

or write your own builder specialized to one part of the mesh.


Abel Alonso a écrit :
Hi!

I'm working with the class Polyhedron_3 to implement a Mesh Editor and when the user performs an operation which involves a hole I would like to come back to the previous state of the mesh. I have a buffer of triangles of that previous mesh state, but I cannot reconstruct the mesh by adding all of these triangles using the make_triangle method, but I cannot add a triangle which has two points inserted in the polyhedron.

So, my question is:

Does exists any method or way to construct a Polyhedron from a triangle list?

If it isn't, I would like to know if is there any way to copy a Polyhedron object to another one, without memory sharing between them.

Thanks in advance and congrats for this great library,

Abel.


#ifndef _MAKE_SOUP_
#define _MAKE_SOUP_

#include <CGAL/Modifier_base.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>

template <class HDS,class Polyhedron,class Kernel,class InputIterator>
class CModifierTriangleSoup : public CGAL::Modifier_base<HDS>
{
private:
typedef typename Kernel::Triangle_3 Triangle;
typedef typename CGAL::Polyhedron_incremental_builder_3<HDS> builder;
InputIterator m_begin, m_end;

public:

// life cycle
CModifierTriangleSoup(InputIterator begin,InputIterator end)
: m_begin(begin), m_end(end)
{
}
~CModifierTriangleSoup() {}

// make a polygon soup
void operator()( HDS& hds)
{
builder B(hds,true);
B.begin_surface(3,1,6);

int index = 0;
InputIterator it;
for(it = m_begin; it != m_end; it++)
{
const Triangle& triangle = *it;

B.add_vertex(triangle[0]);
B.add_vertex(triangle[1]);
B.add_vertex(triangle[2]);

B.begin_facet();
B.add_vertex_to_facet(index++);
B.add_vertex_to_facet(index++);
B.add_vertex_to_facet(index++);
B.end_facet();
}
B.end_surface();
}
};

template <class Polyhedron,class Kernel,class InputIterator>
class Make_triangle_soup
{
public:
typedef typename Polyhedron::HalfedgeDS HalfedgeDS;
Make_triangle_soup() {}
~Make_triangle_soup() {}

public:
void run(InputIterator begin,
InputIterator end,
Polyhedron &output)
{
CModifierTriangleSoup<HalfedgeDS,Polyhedron,Kernel,InputIterator>
soup(begin,end);
output.delegate(soup);
}
};

#endif // _MAKE_SOUP_



Archive powered by MHonArc 2.6.16.

Top of Page