From a77b066f6b5de69df1e2b67491d4c11a9e0b7ef0 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 15 Oct 2015 13:11:48 +0200 Subject: [PATCH] add a precondition to global optimizers this precondition checks that global optimizers are not run on a triangulation with weights. Protecting balls are an exception and don't prevent global optimizers from running --- .../CGAL/internal/Mesh_3/check_weights.h | 65 +++++++++++++++++++ Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h | 4 ++ Mesh_3/include/CGAL/odt_optimize_mesh_3.h | 4 ++ Mesh_3/include/CGAL/perturb_mesh_3.h | 4 ++ 4 files changed, 77 insertions(+) create mode 100644 Mesh_3/include/CGAL/internal/Mesh_3/check_weights.h diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/check_weights.h b/Mesh_3/include/CGAL/internal/Mesh_3/check_weights.h new file mode 100644 index 00000000000..1fff0a98a77 --- /dev/null +++ b/Mesh_3/include/CGAL/internal/Mesh_3/check_weights.h @@ -0,0 +1,65 @@ +// Copyright (c) 2015 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL: https://scm.gforge.inria.fr/svn/cgal/branches/features/Mesh_3-experimental-GF/Mesh_3/include/CGAL/internal/Mesh_3/get_index.h $ +// $Id: get_index.h 67573 2012-02-02 14:54:51Z lrineau $ +// +// +// Author(s) : Jane Tournois +// +//****************************************************************************** +// File Description : +// +// +//****************************************************************************** + +#ifndef CGAL_INTERNAL_MESH_3_CHECK_WEIGHTS_H +#define CGAL_INTERNAL_MESH_3_CHECK_WEIGHTS_H + +#include +#include + +namespace CGAL { +namespace internal { +namespace Mesh_3 { + + +template +bool has_non_protecting_weights(const Triangulation& tr, + const MeshDomain&) +{ + bool with_features = + boost::is_same::value; + + for (typename Triangulation::Finite_vertices_iterator + vv = tr.finite_vertices_begin(); + vv != tr.finite_vertices_end(); + ++vv) + { + if (vv->point().weight() != 0.) + { + if (with_features && vv->in_dimension() > 1) + return true; + } + } + return false; +} + + +}//end namespace Mesh_3 +}//end namespace internal +}//end namespace CGAL + +#endif //CGAL_INTERNAL_MESH_3_CHECK_WEIGHTS_H + diff --git a/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h b/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h index 8fda47e58a4..03e7885e9cf 100644 --- a/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h +++ b/Mesh_3/include/CGAL/lloyd_optimize_mesh_3.h @@ -31,6 +31,7 @@ #include #include #include +#include namespace CGAL { @@ -65,6 +66,9 @@ lloyd_optimize_mesh_3_impl(C3T3& c3t3, const double freeze_bound , const bool do_freeze) { + CGAL_precondition( + !internal::Mesh_3::has_non_protecting_weights(c3t3.triangulation(), domain)); + typedef typename C3T3::Triangulation Tr; typedef Mesh_3::Mesh_sizing_field Sizing; diff --git a/Mesh_3/include/CGAL/odt_optimize_mesh_3.h b/Mesh_3/include/CGAL/odt_optimize_mesh_3.h index c098dd29a13..02df9698ddb 100644 --- a/Mesh_3/include/CGAL/odt_optimize_mesh_3.h +++ b/Mesh_3/include/CGAL/odt_optimize_mesh_3.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace CGAL { @@ -66,6 +67,9 @@ odt_optimize_mesh_3_impl(C3T3& c3t3, const double freeze_ratio, const bool do_freeze ) { + CGAL_precondition( + !internal::Mesh_3::has_non_protecting_weights(c3t3.triangulation(), domain)); + typedef typename C3T3::Triangulation Tr; typedef Mesh_3::Mesh_sizing_field Sizing; diff --git a/Mesh_3/include/CGAL/perturb_mesh_3.h b/Mesh_3/include/CGAL/perturb_mesh_3.h index 120fce89c0b..f497ee1a069 100644 --- a/Mesh_3/include/CGAL/perturb_mesh_3.h +++ b/Mesh_3/include/CGAL/perturb_mesh_3.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -96,6 +97,9 @@ perturb_mesh_3_impl(C3T3& c3t3, const SliverCriterion& sliver_criterion, const PPerturbationVector& perturbation_vector) { + CGAL_precondition( + !internal::Mesh_3::has_non_protecting_weights(c3t3.triangulation(), domain)); + typedef MeshDomain Md; typedef SliverCriterion Sc;