diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_sizing_field.h index 3fc92e1b97b..f50ef858cab 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_sizing_field.h @@ -26,6 +26,8 @@ #ifndef CGAL_MESH_3_MESH_SIZING_FIELD_H #define CGAL_MESH_3_MESH_SIZING_FIELD_H +#include + namespace CGAL { namespace Mesh_3 @@ -44,6 +46,8 @@ class Mesh_sizing_field typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; + + typedef typename CGAL::Mesh_3::Vertex_handle_comparator Vcomp; public: // update vertices of mesh triangulation ? @@ -171,12 +175,18 @@ operator()(const Point_3&, const std::pair& c) const { // Assumes that p is the centroid of c const Cell_handle& cell = c.first; - + std::vector v; + v.push_back(cell->vertex(0)); + v.push_back(cell->vertex(1)); + v.push_back(cell->vertex(2)); + v.push_back(cell->vertex(3)); + std::sort(v.begin(), v.end(), Vcomp()); + // Interpolate value using tet vertices values - const FT& va = cell->vertex(0)->meshing_info(); - const FT& vb = cell->vertex(1)->meshing_info(); - const FT& vc = cell->vertex(2)->meshing_info(); - const FT& vd = cell->vertex(3)->meshing_info(); + const FT& va = v[0]->meshing_info(); + const FT& vb = v[1]->meshing_info(); + const FT& vc = v[2]->meshing_info(); + const FT& vd = v[3]->meshing_info(); return ( (va+vb+vc+vd)/4 ); } @@ -190,16 +200,23 @@ interpolate_on_cell_vertices(const Point_3& p, const Cell_handle& cell) const typename Gt::Compute_volume_3 volume = Gt().compute_volume_3_object(); + std::vector v; + v.push_back(cell->vertex(0)); + v.push_back(cell->vertex(1)); + v.push_back(cell->vertex(2)); + v.push_back(cell->vertex(3)); + std::sort(v.begin(), v.end(), Vcomp()); + // Interpolate value using tet vertices values - const FT& va = cell->vertex(0)->meshing_info(); - const FT& vb = cell->vertex(1)->meshing_info(); - const FT& vc = cell->vertex(2)->meshing_info(); - const FT& vd = cell->vertex(3)->meshing_info(); + const FT& va = v[0]->meshing_info(); + const FT& vb = v[1]->meshing_info(); + const FT& vc = v[2]->meshing_info(); + const FT& vd = v[3]->meshing_info(); - const Point_3& a = cell->vertex(0)->point(); - const Point_3& b = cell->vertex(1)->point(); - const Point_3& c = cell->vertex(2)->point(); - const Point_3& d = cell->vertex(3)->point(); + const Point_3& a = v[0]->point(); + const Point_3& b = v[1]->point(); + const Point_3& c = v[2]->point(); + const Point_3& d = v[3]->point(); const FT abcp = CGAL::abs(volume(a,b,c,p)); const FT abdp = CGAL::abs(volume(a,d,b,p));