Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Polyhedron_incremental_builder_3 and test_facet_indices

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Polyhedron_incremental_builder_3 and test_facet_indices


Chronological Thread 
  • From: Andreas Fabri <>
  • To:
  • Subject: Re: [cgal-discuss] Polyhedron_incremental_builder_3 and test_facet_indices
  • Date: Tue, 24 Jun 2008 20:53:56 +0200


Hi Eric,

I think you use an undocumented function in a wrong way.

You call pB.test_facet_indices(t)
and instead you should call pB.test_facet_indices(t.begin(), t.end())

If you look into the source code you will see that the two
are almost identical, but not completely.


The mistake is partially on our side, as the function is
a public member and it shouldn't.

But it is also partially on your side as you should only use
functions which are documented in the manual.

andreas



Eric Boix wrote:
Dear CGAL users,

Since I had no reply on first trial, I here dare to re-post...

I'm trying to get Polyhedron_incremental_builder_3 working for me.
I have the classical problem of having a surface given as triangles
but with uncoherent orientation. Thus before tossing out the triangles
to the incremental_builder_3, I use test_facet_indices() as an orientation
predicate and revert the triangle order when the test rejects one triangle.
[and yes they are many ways to orient the triangulation from outside
CGAL but this is not what we need ].

I must be doing things really wrong because I couldn't get it working
even for the following example for which the surface has only two
triangles [ I compile it with
g++ polySurface.cpp -lCGAL -lCGALcore++ -o polySurface -Wall] .
I would really appreciate any kind of help on this problem.

Best.
Eric Boix.

-----------------------------------------------------------------------------
#include <iostream> // for cout
#include <stdlib.h> // for exit

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Triangle_3.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/Polyhedron_3.h>

template <class HDS>
class Build_Surface : public CGAL::Modifier_base<HDS>
{
public:
Build_Surface() { }
void operator()( HDS& hds );
};

template <class HDS>
void Build_Surface< HDS >::operator()( HDS &hds )
{
/// Build a simple surface made of two triangles.
CGAL::Polyhedron_incremental_builder_3<HDS> pB(hds, true);
pB.begin_surface( 6, 2, 0);

typedef typename HDS::Vertex::Point Point;
pB.add_vertex( Point( 0.0, 0.0, 0.0));
pB.add_vertex( Point( 1.0, 0.0, 0.0));
pB.add_vertex( Point( 0.0, 1.0, 0.0));
pB.add_vertex( Point( 0.0, 0.0, 1.0));
pB.add_vertex( Point( 1.0, 1.0, 1.0));
pB.add_vertex( Point( 1.0, 0.0, 1.0));

// First triangle:
pB.begin_facet();
pB.add_vertex_to_facet(2);
pB.add_vertex_to_facet(4);
pB.add_vertex_to_facet(0);
pB.end_facet();

// Second triangle:
std::vector< std::size_t> t;
t.push_back(0); t.push_back(5); t.push_back(4);
if( pB.test_facet_indices(t) == true )
std::cout << "Test passed." << std::endl;
else
{
std::cout << "Test failed." << std::endl;
exit( 0 ) ;
}

pB.begin_facet();
pB.add_vertex_to_facet(t[0]);
pB.add_vertex_to_facet(t[1]);
pB.add_vertex_to_facet(t[2]);
pB.end_facet();

pB.end_surface();
}

int main()
{
typedef CGAL::Simple_cartesian<double> Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::HalfedgeDS HalfedgeDS;

Polyhedron P;
Build_Surface<HalfedgeDS> surface;
P.delegate(surface);
std::cout << "Done with surface building." << std::endl;
return 0;
}





Archive powered by MHonArc 2.6.16.

Top of Page