diff --git a/Mesh_2/include/CGAL/Constrained_voronoi_diagram_2.h b/Mesh_2/include/CGAL/Constrained_voronoi_diagram_2.h index 16ffb523203..c3dfdecab30 100644 --- a/Mesh_2/include/CGAL/Constrained_voronoi_diagram_2.h +++ b/Mesh_2/include/CGAL/Constrained_voronoi_diagram_2.h @@ -273,7 +273,7 @@ private: if(!m_cdt.is_infinite(seed) && !seed->is_blind() - && m_cdt.triangle(seed).area() != 0) + && !m_cdt.triangle(seed).is_degenerate() ) //to avoid flat triangles outside the domain { std::stack faces; diff --git a/Mesh_2/include/CGAL/Mesh_2/Lloyd_move_2.h b/Mesh_2/include/CGAL/Mesh_2/Lloyd_move_2.h index 6199445c91c..dadc06875c8 100644 --- a/Mesh_2/include/CGAL/Mesh_2/Lloyd_move_2.h +++ b/Mesh_2/include/CGAL/Mesh_2/Lloyd_move_2.h @@ -74,7 +74,7 @@ namespace Mesh_2 // Compute mass FT density = density_2d(tri_centroid, sizing_field); - FT abs_area = CGAL::abs(tri.area()); + FT abs_area = CGAL::abs(cdt.geom_traits().compute_area_2_object()(tri[0], tri[1], tri[2])); FT mass = abs_area * density; move = move + mass * Vector_2(p, tri_centroid); diff --git a/Mesh_2/test/Mesh_2/test_mesh_opti_projection_traits.cpp b/Mesh_2/test/Mesh_2/test_mesh_opti_projection_traits.cpp new file mode 100644 index 00000000000..5c8b75ed100 --- /dev/null +++ b/Mesh_2/test/Mesh_2/test_mesh_opti_projection_traits.cpp @@ -0,0 +1,61 @@ +#define CGAL_MESH_2_OPTIMIZER_VERBOSE +//#define CGAL_MESH_2_OPTIMIZERS_DEBUG +//#define CGAL_MESH_2_SIZING_FIELD_USE_BARYCENTRIC_COORDINATES + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Ks; +typedef CGAL::Projection_traits_xy_3 K; +typedef CGAL::Delaunay_mesh_vertex_base_2 Vb; +typedef CGAL::Delaunay_mesh_face_base_2 Fb; +typedef CGAL::Triangulation_data_structure_2 Tds; +typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; +typedef CGAL::Delaunay_mesh_size_criteria_2 Criteria; +typedef CGAL::Delaunay_mesher_2 Mesher; + +typedef CDT::Vertex_handle Vertex_handle; +typedef CDT::Point Point; + + +int main() +{ + CDT cdt; + + Vertex_handle va = cdt.insert(Point(-2,0,1)); + Vertex_handle vb = cdt.insert(Point(0,-2,1)); + Vertex_handle vc = cdt.insert(Point(2,0,1)); + Vertex_handle vd = cdt.insert(Point(0,1,1)); + cdt.insert(Point(2, 0.6,1)); + + cdt.insert_constraint(va, vb); + cdt.insert_constraint(vb, vc); + cdt.insert_constraint(vc, vd); + cdt.insert_constraint(vd, va); + + std::cout << "Number of vertices: " << cdt.number_of_vertices() << std::endl; + + std::cout << "Meshing..." << std::endl; + + Mesher mesher(cdt); + mesher.set_criteria(Criteria(0.125, 0.05)); + mesher.refine_mesh(); + + std::cout << "Number of vertices: " << cdt.number_of_vertices() << std::endl; + + std::cout << "Run Lloyd optimization..."; + CGAL::lloyd_optimize_mesh_2(cdt, + CGAL::parameters::max_iteration_number = 10); + std::cout << " done." << std::endl; + + std::cout << "Number of vertices: " << cdt.number_of_vertices() << std::endl; +}