Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] A problem of incremental builder with extended HDS

Subject: CGAL users discussion list

List archive

[cgal-discuss] A problem of incremental builder with extended HDS


Chronological Thread 
  • From: johnzjq <>
  • To:
  • Subject: [cgal-discuss] A problem of incremental builder with extended HDS
  • Date: Thu, 14 Oct 2010 07:22:37 -0700 (PDT)


Dear All,

I am using Polyhedron_incremental_builder_3 to build a HDS extended by face
color.

Everything goes well from begin_surface to end_surface (I had verified the
color information of the facets during this process). However, when the step
jumps out of the delegate() function, I found the face color in the
polyhedron became invalid!

How to solve it? Please help.

John

Attached code:

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

template <class Refs>
struct My_face : public CGAL::HalfedgeDS_face_base<Refs>{
CGAL::Color color;
My_face(){}
My_face(CGAL::Color c) : color(c){}
};
struct My_items : public CGAL::Polyhedron_items_3{
template<class Refs,class Traits>
struct Face_wrapper{
typedef My_face<Refs> Face;
};
};

template <class HDS>
class Build_triangle : public CGAL::Modifier_base<HDS> {
public:
typedef typename HDS::Vertex::Point Point;
typedef typename HDS::Face_handle Face_handle;
Build_triangle() {}
void operator()( HDS& hds) {
// Postcondition: ‘hds’ is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B( hds, true);
B.begin_surface( 3, 1, 6);
B.add_vertex( Point( 0, 0, 0));
B.add_vertex( Point( 1, 0, 0));
B.add_vertex( Point( 0, 1, 0));
Face_handle f = B.begin_facet();
f->color = CGAL::RED;
B.add_vertex_to_facet( 0);
B.add_vertex_to_facet( 1);
B.add_vertex_to_facet( 2);
B.end_facet();
B.end_surface();
}
};
typedef CGAL::Simple_cartesian<double> Kernel;
typedef CGAL::Polyhedron_3<Kernel,My_items> Polyhedron;
typedef Polyhedron::HalfedgeDS HalfedgeDS;

int main()
{
Polyhedron P;
Build_triangle<HalfedgeDS> triangle;
P.delegate( triangle);
//here the color is gone!
CGAL_assertion( P.is_triangle( P.halfedges_begin()));
return 0;
}
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/A-problem-of-incremental-builder-with-extended-HDS-tp2995396p2995396.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page