I was trying to create a volume mesh using the CGAL::Polyhedron_3
data structure when, doing some tests, I noticed that the make_tetrahedron
function duplicates the vertices already present in the polyhedron.
Example: Two tetrahedra that share a common face
this is the code I tried:
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <iostream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::Vertex_iterator Vertex_iterator;
int main(void) {
// common points
Point_3 p( 1.0, 0.0, 0.0 );
Point_3 q( 0.0, 1.0, 0.0 );
Point_3 s( 0.0, 0.0, 0.0 );
// the other two
Point_3 r( 0.0, 0.0, 1.0 );
Point_3 d( 0.0, 0.0,-1.0 );
Polyhedron P;
P.make_tetrahedron( p, q, r, s );
P.make_tetrahedron( p, q, s, d );
CGAL::IO::set_ascii_mode( std::cout );
// printing out the vertices
for ( Vertex_iterator v = P.vertices_begin(); v != P.vertices_end(); v )
std::cout << v->point() << std::endl;
return 0;
}
and this is the output I expected to see:
1 0 0
0 1 0
0 0 1
0 0 0
0 0 -1
but that's what I got:
1 0 0
0 1 0
0 0 1
0 0 0
1 0 0
0 1 0
0 0 0
0 0 -1
Now, the question is:
Is it possible to store a point as a vertex only once in CGAL::Polyhedron_3
using the make_tetrahedron
function?
CodePudding user response:
You cannot store non-manifold features in a polyhedron, you need something like a linear cell complex. See here