Provided new API support for exude_mesh_3

This commit is contained in:
GYuvanShankar 2022-06-09 14:25:33 +05:30
parent 046f1db10a
commit e6619ab67b
12 changed files with 439 additions and 87 deletions

View File

@ -87,7 +87,7 @@ int main()
CGAL::perturb_mesh_3(c3t3, domain, time_limit = 10);
// Exudation
CGAL::exude_mesh_3(c3t3,12);
CGAL::exude_mesh_3(c3t3,CGAL::parameters::time_limit_new=12);
// Output
std::ofstream medit_file("out_cubes_intersection.mesh");

View File

@ -174,7 +174,7 @@ int main()
CGAL::perturb_mesh_3(c3t3, domain, time_limit = 10);
// Exudation
CGAL::exude_mesh_3(c3t3,12);
CGAL::exude_mesh_3(c3t3,CGAL::parameters::time_limit_new=12);
// Output
std::ofstream medit_file("out_cubes_intersection_with_features.mesh");

View File

@ -63,7 +63,7 @@ int main()
CGAL::perturb_mesh_3(c3t3, domain, time_limit = 10);
// Exudation
CGAL::exude_mesh_3(c3t3,12);
CGAL::exude_mesh_3(c3t3,CGAL::parameters::time_limit_new=12);
// Output
std::ofstream medit_file("out.mesh");

View File

@ -55,7 +55,7 @@ int main(int argc, char*argv[])
no_perturb(), no_exude());
CGAL::lloyd_optimize_mesh_3(c3t3_bis, domain, time_limit=30);
CGAL::exude_mesh_3(c3t3_bis, sliver_bound=10, time_limit=10);
CGAL::exude_mesh_3(c3t3_bis, CGAL::parameters::sliver_bound_new=10, CGAL::parameters::time_limit_new=10);
// Output
std::ofstream medit_file("out.mesh");

View File

@ -25,68 +25,201 @@
#include <CGAL/Mesh_3/Slivers_exuder.h>
#include <CGAL/Mesh_optimization_return_code.h>
#include <CGAL/Mesh_3/parameters_defaults.h>
#include <CGAL/boost/parameter.h>
#include <boost/parameter/preprocessor.hpp>
#include <CGAL/Named_function_parameters.h>
namespace CGAL {
/*!
@ingroup PkgMesh3Functions
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable:4003) // not enough actual parameters for macro
#endif
The function `exude_mesh_3()` performs a sliver exudation process on a Delaunay mesh.
// see <CGAL/config.h>
CGAL_PRAGMA_DIAG_PUSH
// see <CGAL/boost/parameter.h>
CGAL_IGNORE_BOOST_PARAMETER_NAME_WARNINGS
The sliver exudation process consists in optimizing the weights of vertices
of the weighted Delaunay triangulation in such a way that slivers disappear and
the quality of the mesh improves.
BOOST_PARAMETER_FUNCTION(
(Mesh_optimization_return_code),
exude_mesh_3,
parameters::tag,
(required (in_out(c3t3),*) )
(optional
(time_limit_, *, 0 )
(sliver_bound_, *, parameters::default_values_for_mesh_3::exude_sliver_bound )
)
)
@warning This optimizer modifies the weight of vertices of the triangulation and,
if called, must be the last optimizer to be called. If the mesh is refined after
this optimization has been performed, all improvements will be lost.
@pre `time_limit` \f$ \geq\f$ 0 and 0 \f$ \leq\f$ `sliver_bound` \f$ \leq\f$ 180
@tparam C3T3 is required to be a model of the concept
`MeshComplex_3InTriangulation_3`.
The argument `c3t3`, passed by
reference, provides the initial mesh
and is modified by the algorithm
to represent the final optimized mesh.
@tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
@param c3t3 the initial mesh that will be modified by the algorithm to represent the final optimized mesh.
@param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below:
\cgalNamedParamsBegin
\cgalParamNBegin{parameters::time_limit_new}
\cgalParamDescription{is used to set up, in seconds, a CPU time limit after which the optimization process
is stopped. This time is measured using the Real_timer class. The default value is
0 and means that there is no time limit.}
\cgalParamNBegin{parameters::parameters::sliver_bound_new}
\cgalParamDescription{is designed to give, in degrees, a targeted lower bound on dihedral angles of mesh cells.
The exudation process considers in turn all the mesh cells that have a smallest dihedral
angle less than sliver_bound and tries to make them disappear by weighting their vertices.
The optimization process stops when every cell in the mesh achieves this quality. The
default value is 0 and means that there is no targeted bound: the exuder then runs as long
as it can improve the smallest dihedral angles of the set of cells incident to some vertices.}
\cgalNamedParamsEnd
\return
The function `exude_mesh_3()` returns a value of type `CGAL::Mesh_optimization_return_code`
which is:
<UL>
<LI>`CGAL::BOUND_REACHED` when the targeted bound for the smallest dihedral angle in the mesh is reached.
<LI>`CGAL::TIME_LIMIT_REACHED` when the time limit is reached.
<LI>`CGAL::CANT_IMPROVE_ANYMORE` when exudation process stops because it can no longer improve
the smallest dihedral angle of the set of cells incident to some vertex in the mesh.
</UL>
\cgalHeading{Example}
\code{.cpp}
// Exude without sliver_bound, using at most 10s CPU time
exude_mesh_3(c3t3,
parameters::time_limit=10);
\endcode
\sa `CGAL::Mesh_optimization_return_code`
\sa `CGAL::make_mesh_3()`
\sa `CGAL::refine_mesh_3()`
\sa `CGAL::perturb_mesh_3()`
\sa `CGAL::lloyd_optimize_mesh_3()`
\sa `CGAL::odt_optimize_mesh_3()`
*/
template<typename C3T3, typename CGAL_NP_TEMPLATE_PARAMETERS>
Mesh_optimization_return_code exude_mesh_3(C3T3& c3t3,const CGAL_NP_CLASS& np = parameters::default_values())
{
return exude_mesh_3_impl(c3t3, time_limit_, sliver_bound_);
using parameters::choose_parameter;
using parameters::get_parameter;
int time_limit=choose_parameter(get_parameter(np,internal_np::maximum_running_time),0);
double sliver_bound= choose_parameter(get_parameter(np,internal_np::lower_sliver_bound),parameters::default_values_for_mesh_3::exude_sliver_bound);
return exude_mesh_3_impl(c3t3,time_limit,sliver_bound);
}
CGAL_PRAGMA_DIAG_POP
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#ifndef DOXYGEN_RUNNING
#ifndef CGAL_NO_DEPRECATED_CODE
template<typename C3T3, typename ... NP_PACK>
Mesh_optimization_return_code exude_mesh_3(C3T3& c3t3, const NP_PACK& ...nps)
{
return exude_mesh_3(c3t3,internal_np::combine_named_parameters(nps...));
}
#endif //CGAL_NO_DEPRECATED_CODE
template <typename C3T3>
Mesh_optimization_return_code
exude_mesh_3_impl(C3T3& c3t3,
template <typename C3T3>
Mesh_optimization_return_code
exude_mesh_3_impl(C3T3& c3t3,
const double time_limit,
const double sliver_bound)
{
typedef typename C3T3::Triangulation Tr;
typedef Mesh_3::Min_dihedral_angle_criterion<Tr> Sc;
//typedef Mesh_3::Radius_radio_criterion<Tr> Sc;
typedef typename Mesh_3::Slivers_exuder<C3T3, Sc> Exuder;
{
typedef typename C3T3::Triangulation Tr;
typedef Mesh_3::Min_dihedral_angle_criterion<Tr> Sc;
//typedef Mesh_3::Radius_radio_criterion<Tr> Sc;
typedef typename Mesh_3::Slivers_exuder<C3T3, Sc> Exuder;
// Create exuder
Sc criterion(sliver_bound, c3t3.triangulation());
Exuder exuder(c3t3, criterion);
// Create exuder
Sc criterion(sliver_bound, c3t3.triangulation());
Exuder exuder(c3t3, criterion);
// Set time_limit
exuder.set_time_limit(time_limit);
// Set time_limit
exuder.set_time_limit(time_limit);
// Launch exudation
return exuder();
}
// Launch exudation
return exuder();
}
#else
namespace CGAL {
/*!
\ingroup PkgMesh3Functions
The function `exude_mesh_3()` performs a sliver exudation process on a Delaunay mesh.
The sliver exudation process consists in optimizing the weights of vertices
of the weighted Delaunay triangulation in such a way that slivers disappear and
the quality of the mesh improves.
\warning This optimizer modifies the weight of vertices of the triangulation and,
if called, must be the last optimizer to be called. If the mesh is refined after
this optimization has been performed, all improvements will be lost.
\pre `time_limit` \f$ \geq\f$ 0 and 0 \f$ \leq\f$ `sliver_bound` \f$ \leq\f$ 180
\tparam C3T3 is required to be a model of the concept
`MeshComplex_3InTriangulation_3`.
The argument `c3t3`, passed by
reference, provides the initial mesh
and is modified by the algorithm
to represent the final optimized mesh.
The function has two optional parameters which are named parameters (we use the Boost.Parameter library).
Therefore, when calling the function, the parameters can be provided in any order
provided that the names of the parameters are used
(see example at the bottom of this page).
\cgalHeading{Named Parameters}
- <b>`parameters::time_limit`</b> is used to set up, in seconds,
a CPU time limit after which the optimization process is stopped. This time is
measured using the `Real_timer` class.
The default value is 0 and means that there is no time limit.
- <b>`parameters::sliver_bound`</b> is designed to give, in degrees, a targeted
lower bound on dihedral angles of mesh cells.
The exudation process considers in turn all the mesh cells
that have a smallest dihedral angle less than `sliver_bound`
and tries to make them disappear by weighting their vertices.
The optimization process
stops when every cell in the mesh achieves this quality.
The default value is 0 and means that there is no targeted bound:
the exuder then runs as long as
it can improve the smallest dihedral angles of the set of cells
incident to some vertices.
\return
The function `exude_mesh_3()` returns a value of type `CGAL::Mesh_optimization_return_code`
which is:
<UL>
<LI>`CGAL::BOUND_REACHED` when the targeted bound for the smallest dihedral angle in the mesh is reached.
<LI>`CGAL::TIME_LIMIT_REACHED` when the time limit is reached.
<LI>`CGAL::CANT_IMPROVE_ANYMORE` when exudation process stops because it can no longer improve
the smallest dihedral angle of the set of cells incident to some vertex in the mesh.
</UL>
\cgalHeading{Example}
\code{.cpp}
// Exude without sliver_bound, using at most 10s CPU time
exude_mesh_3(c3t3,
parameters::time_limit=10);
\endcode
\sa `CGAL::Mesh_optimization_return_code`
\sa `CGAL::make_mesh_3()`
\sa `CGAL::refine_mesh_3()`
\sa `CGAL::perturb_mesh_3()`
\sa `CGAL::lloyd_optimize_mesh_3()`
\sa `CGAL::odt_optimize_mesh_3()`
*/
template<typename C3T3>
Mesh_optimization_return_code
exude_mesh_3(C3T3& c3t3,
double parameters::time_limit=0,
double parameters::sliver_bound=0);
} /* namespace CGAL */
#endif //DOXYGEN_RUNNING
} //namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_EXUDE_MESH_3_H

View File

@ -613,8 +613,8 @@ void refine_mesh_3_impl(C3T3& c3t3,
exude_time_limit = exude.time_limit();
exude_mesh_3(c3t3,
parameters::time_limit = exude_time_limit,
parameters::sliver_bound = exude.bound());
parameters::time_limit_new = exude_time_limit,
parameters::sliver_bound_new = exude.bound());
dump_c3t3(c3t3, mesh_options.dump_after_exude_prefix);
}

View File

@ -0,0 +1,214 @@
#! /bin/bash
#
# =============================================================================
# $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Scripts/developer_scripts/create_cgal_test $
# $Id: create_cgal_test 36975 2007-03-09 22:52:40Z spion $
#
# author(s) : Wieger Wesselink, Geert-Jan Giezeman
#
# coordinator : Utrecht University
# =============================================================================
#
# This script creates a cgal_test_with_cmake script with entries for files with a common
# C++ file extension (as mentioned in the g++ man page) in the current test directory.
VERSION=1.1
DO_RUN="y"
usage()
{
echo 'Usage : create_cgal_test [--no-run]'
echo
echo ' --help : prints this usage help'
echo ' --no-run : produces a cgal_test_with_cmake script that only does compilation, no execution'
exit
}
while [ $1 ]; do
case "$1" in
-h|-help|--h|--help)
usage;
;;
--no-run)
DO_RUN=""
shift; continue
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
header()
{
echo "#---------------------------------------------------------------------#"
echo "# $1"
echo "#---------------------------------------------------------------------#"
}
create_script()
{
echo "#! /bin/sh"
echo
echo "# This is a script for the CGAL test suite. Such a script must obey"
echo "# the following rules:"
echo "#"
echo "# - the name of the script is cgal_test_with_cmake"
echo "# - for every target two one line messages are written to the file 'error.txt'"
echo "# the first one indicates if the compilation was successful"
echo "# the second one indicates if the execution was successful"
echo "# if one of the two was not successful, the line should start with 'ERROR:'"
echo "# - running the script should not require any user interaction"
echo "# - the script should clean up object files and executables"
echo
cat << EOF
ERRORFILE=error.txt
DO_RUN=${DO_RUN}
if [ -z "\${MAKE_CMD}" ]; then
MAKE_CMD=make
fi
NEED_CLEAN=
EOF
header "configure"
cat << 'EOF'
configure()
{
echo "Configuring... "
if eval 'cmake ${INIT_FILE:+"-C${INIT_FILE}"} -DRUNNING_CGAL_AUTO_TEST=TRUE \
-DCGAL_DIR="$CGAL_DIR" \
--no-warn-unused-cli \
.' ; then
echo " successful configuration" >> $ERRORFILE
else
echo " ERROR: configuration" >> $ERRORFILE
fi
}
EOF
header "compile_and_run <target>"
cat << EOF
compile_and_run()
{
if [ -z "\${CGAL_DATA_DIR}" ]; then
if [ -d \${CGAL_DIR}/data ]; then
export CGAL_DATA_DIR=\${CGAL_DIR}/data
else
if [ -d \${CGAL_DIR}/Data/data ]; then
export CGAL_DATA_DIR=\${CGAL_DIR}/Data/data
else
echo "ERROR: Cannot run test script, please set the variable CGAL_DATA_DIR"
exit 1
fi
fi
fi
echo "Runs will be using CGAL_DATA_DIR = \${CGAL_DATA_DIR}"
echo "Compiling \$1 ... "
SUCCESS="y"
if eval '"\${MAKE_CMD}" VERBOSE=ON -fMakefile \$1' ; then
echo " successful compilation of \$1" >> \$ERRORFILE
else
echo " ERROR: compilation of \$1" >> \$ERRORFILE
SUCCESS=""
fi
if [ -n "\$DO_RUN" ] ; then
if [ -n "\${SUCCESS}" ] ; then
OUTPUTFILE=ProgramOutput.\$1.\$PLATFORM
rm -f \$OUTPUTFILE
COMMAND="./\$1"
if [ -f \$1.cmd ] ; then
COMMAND="\$COMMAND \`eval echo \$(cat \$1.cmd)\`"
fi
if [ -f \$1.cin ] ; then
COMMAND="cat \$1.cin | \$COMMAND"
fi
echo "Executing \$1 ... "
echo
ulimit -t 3600 2> /dev/null
if eval \$COMMAND > \$OUTPUTFILE 2>&1 ; then
echo " successful execution of \$1" >> \$ERRORFILE
else
echo " ERROR: execution of \$1" >> \$ERRORFILE
fi
else
echo " ERROR: not executed \$1" >> \$ERRORFILE
fi
fi
}
EOF
header "remove the previous error file"
cat << EOF
rm -f \$ERRORFILE
touch \$ERRORFILE
EOF
header "configure, compile and run the tests"
cat << EOF
configure
if [ \$# -ne 0 ] ; then
for file in \$* ; do
compile_and_run \$file
done
else
echo "Run all tests."
EOF
# workaround for Cygwin, to avoid that the 'sort' from
# C:\Windows\system32 is used instead of /usr/bin/sort
PATH=/usr/bin:$PATH
for file in `ls *.cc *.cp *.cxx *.cpp *.CPP *.c++ *.C 2> /dev/null | sort` ; do
if [ -n "`grep '\<main\>' $file`" ] ; then
BASE=`basename $file .cc`
BASE=`basename $BASE .cp`
BASE=`basename $BASE .cxx`
BASE=`basename $BASE .cpp`
BASE=`basename $BASE .CPP`
BASE=`basename $BASE .c++`
BASE=`basename $BASE .C`
cat <<EOF
if grep -qE "^${BASE}:" Makefile; then
compile_and_run $BASE
NEED_CLEAN=y
fi
EOF
fi
done
cat << EOF
fi
#
# The clean target generated by CMake under cygwin
# always fails for some reason
#
if [ -n "\${NEED_CLEAN}" ]; then
if ! ( uname | grep -q "CYGWIN" ) ; then
"\${MAKE_CMD}" -fMakefile clean
fi
fi
EOF
}
if [ -f cgal_test_with_cmake ] ; then
echo "moving cgal_test_with_cmake to cgal_test_with_cmake.bak ..."
mv -f cgal_test_with_cmake cgal_test_with_cmake.bak
fi
create_script > cgal_test_with_cmake
chmod 755 cgal_test_with_cmake
echo "created cgal_test_with_cmake, version $VERSION, in $PWD ..."

View File

@ -120,7 +120,7 @@ void test()
oss.clear();
//EXUDE (4)
CGAL::exude_mesh_3(c3t3, sliver_bound=exude_bound);
CGAL::exude_mesh_3(c3t3, CGAL::parameters::sliver_bound_new=exude_bound);
c3t3.output_to_medit(oss);
output_c3t3.push_back(oss.str());//[i*5+4]
oss.clear();

View File

@ -299,8 +299,8 @@ void refine_periodic_3_mesh_3_impl(C3T3& c3t3,
exude_time_limit = exude.time_limit();
exude_mesh_3(c3t3,
parameters::time_limit = exude_time_limit,
parameters::sliver_bound = exude.bound());
CGAL::parameters::time_limit_new = exude_time_limit,
CGAL::parameters::sliver_bound_new = exude.bound());
dump_c3t3(c3t3, mesh_options.dump_after_perturb_prefix);
}

View File

@ -335,13 +335,15 @@ struct Boost_parameter_compatibility_wrapper
};
// TODO: need to make sure this works when using several compilation units
const Boost_parameter_compatibility_wrapper<internal_np::number_of_iterations_t> max_iteration_number;
const Boost_parameter_compatibility_wrapper<internal_np::convergence_ratio_t> convergence;
const Boost_parameter_compatibility_wrapper<internal_np::vertex_freeze_bound_t> freeze_bound;
const Boost_parameter_compatibility_wrapper<internal_np::maximum_running_time_t> time_limit;
const Boost_parameter_compatibility_wrapper<internal_np::i_seed_begin_iterator_t> seeds_begin;
const Boost_parameter_compatibility_wrapper<internal_np::i_seed_end_iterator_t> seeds_end;
const Boost_parameter_compatibility_wrapper<internal_np::seeds_are_in_domain_t> mark_;
const Boost_parameter_compatibility_wrapper<internal_np::number_of_iterations_t> max_iteration_number_new;
const Boost_parameter_compatibility_wrapper<internal_np::convergence_ratio_t> convergence_new;
const Boost_parameter_compatibility_wrapper<internal_np::vertex_freeze_bound_t> freeze_bound_new;
const Boost_parameter_compatibility_wrapper<internal_np::maximum_running_time_t> time_limit_new;
const Boost_parameter_compatibility_wrapper<internal_np::i_seed_begin_iterator_t> seeds_begin_new;
const Boost_parameter_compatibility_wrapper<internal_np::i_seed_end_iterator_t> seeds_end_new;
const Boost_parameter_compatibility_wrapper<internal_np::seeds_are_in_domain_t> mark_new;
//Compatibility wrappers for exude_mesh_3.h
const Boost_parameter_compatibility_wrapper<internal_np::lower_sliver_bound_t> sliver_bound_new;
#endif
// function to extract a parameter

View File

@ -248,3 +248,6 @@ CGAL_add_named_parameter(convergence_ratio_t, convergence_ratio, convergence_rat
CGAL_add_named_parameter(vertex_freeze_bound_t, vertex_freeze_bound, vertex_freeze_bound)
CGAL_add_named_parameter(i_seed_begin_iterator_t, i_seed_begin_iterator, i_seed_begin_iterator)
CGAL_add_named_parameter(i_seed_end_iterator_t, i_seed_end_iterator, i_seed_end_iterator)
//List of named parameters used in exude_mesh_3.h
CGAL_add_named_parameter(lower_sliver_bound_t,lower_sliver_bound,lower_sliver_bound)

View File

@ -2,33 +2,33 @@
# This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.23)
project(Triangulation_2_Tests)
project( Triangulation_2 )
find_package(CGAL REQUIRED)
find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core )
include_directories(BEFORE "include")
include_directories (BEFORE "include")
# create a target per cppfile
file(
GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}")
endforeach()
create_single_source_cgal_program( "issue_3447.cpp" )
create_single_source_cgal_program( "issue_4025.cpp" )
create_single_source_cgal_program( "issue_4405.cpp" )
create_single_source_cgal_program( "issue_5055.cpp" )
create_single_source_cgal_program( "issue_5080.cpp" )
create_single_source_cgal_program( "test_cdt_2_projection_traits_special_case.cpp" )
create_single_source_cgal_program( "test_cdt_degenerate_case.cpp" )
create_single_source_cgal_program( "test_CDT_plus_2_with_Projection_traits_xy_3.cpp" )
create_single_source_cgal_program( "test_const_del_triangulation_2.cpp" )
create_single_source_cgal_program( "test_constrained_triangulation_2.cpp" )
create_single_source_cgal_program( "test_constrained_triangulation_with_info_2.cpp" )
create_single_source_cgal_program( "test_const_triang_plus_2.cpp" )
create_single_source_cgal_program( "test_delaunay_hierarchy_2.cpp" )
create_single_source_cgal_program( "test_delaunay_triangulation_2.cpp" )
create_single_source_cgal_program( "test_delaunay_triangulation_proj.cpp" )
create_single_source_cgal_program( "test_deprecated_projection_traits.cpp" )
create_single_source_cgal_program( "test_regular_hierarchy_2.cpp" )
create_single_source_cgal_program( "test_regular_triangulation_2.cpp" )
create_single_source_cgal_program( "test_structural_filtering_traits.cpp" )
create_single_source_cgal_program( "test_triangulation_2_bis.cpp" )
create_single_source_cgal_program( "test_triangulation_2.cpp" )
create_single_source_cgal_program( "test_triangulation_geom_traits.cpp" )
create_single_source_cgal_program( "test_triangulation_with_zip_iterator_2.cpp" )
if(BUILD_TESTING)
set_tests_properties(
execution___of__test_constrained_triangulation_2
execution___of__test_delaunay_triangulation_2
execution___of__test_triangulation_geom_traits
execution___of__test_triangulation_2
execution___of__test_triangulation_2_bis
execution___of__test_delaunay_hierarchy_2
execution___of__test_const_triang_plus_2
execution___of__test_regular_triangulation_2
execution___of__test_const_del_triangulation_2
execution___of__test_regular_hierarchy_2
execution___of__test_deprecated_projection_traits
PROPERTIES RESOURCE_LOCK Triangulation_2_Tests_IO)
endif()