Merge pull request #2508 from afabri/Property_map-fix_Dynamic_property_map-GF

Property_map:  Fix put(Dynamic_property_map,..)
This commit is contained in:
Laurent Rineau 2017-11-15 16:48:30 +01:00
commit 31804d3c0e
7 changed files with 117 additions and 37 deletions

View File

@ -9,41 +9,46 @@ env:
- PACKAGE='Alpha_shapes_2 Alpha_shapes_3 Apollonius_graph_2 ' - PACKAGE='Alpha_shapes_2 Alpha_shapes_3 Apollonius_graph_2 '
- PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 Barycentric_coordinates_2 ' - PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 Barycentric_coordinates_2 '
- PACKAGE='BGL Boolean_set_operations_2 Bounding_volumes ' - PACKAGE='BGL Boolean_set_operations_2 Bounding_volumes '
- PACKAGE='Box_intersection_d CGAL_ImageIO CGAL_ipelets ' - PACKAGE='Box_intersection_d Cartesian_kernel CGAL_Core '
- PACKAGE='Circular_kernel_2 Circular_kernel_3 Circulator ' - PACKAGE='CGAL_ImageIO CGAL_ipelets Circular_kernel_2 '
- PACKAGE='Classification Combinatorial_map Cone_spanners_2 ' - PACKAGE='Circular_kernel_3 Circulator Classification '
- PACKAGE='Convex_decomposition_3 Convex_hull_2 Convex_hull_3 ' - PACKAGE='Combinatorial_map Cone_spanners_2 Convex_decomposition_3 '
- PACKAGE='Convex_hull_d Distance_2 Distance_3 ' - PACKAGE='Convex_hull_2 Convex_hull_3 Convex_hull_d '
- PACKAGE='Envelope_2 Envelope_3 Filtered_kernel ' - PACKAGE='Distance_2 Distance_3 Envelope_2 '
- PACKAGE='Generalized_map Generator Geomview ' - PACKAGE='Envelope_3 Filtered_kernel Generalized_map '
- PACKAGE='GraphicsView HalfedgeDS Hash_map ' - PACKAGE='Generator Geomview GraphicsView '
- PACKAGE='HalfedgeDS Hash_map Homogeneous_kernel '
- PACKAGE='Inscribed_areas Installation Interpolation ' - PACKAGE='Inscribed_areas Installation Interpolation '
- PACKAGE='Intersections_2 Intersections_3 Interval_skip_list ' - PACKAGE='Intersections_2 Intersections_3 Interval_skip_list '
- PACKAGE='Interval_support Inventor Jet_fitting_3 ' - PACKAGE='Interval_support Inventor Jet_fitting_3 '
- PACKAGE='Kernel_23 Kernel_d Kinetic_data_structures ' - PACKAGE='Kernel_23 Kernel_d Kinetic_data_structures '
- PACKAGE='Kinetic_framework Linear_cell_complex Matrix_search ' - PACKAGE='Kinetic_framework LEDA Linear_cell_complex '
- PACKAGE='Mesh_2 Mesh_3 Minkowski_sum_2 ' - PACKAGE='MacOSX Maintenance Matrix_search '
- PACKAGE='Minkowski_sum_3 Modifier Modular_arithmetic ' - PACKAGE='Mesh_2 Mesh_3 Mesher_level '
- PACKAGE='Nef_2 Nef_3 Nef_S2 ' - PACKAGE='Minkowski_sum_2 Minkowski_sum_3 Modifier '
- PACKAGE='NewKernel_d Number_types Optimal_transportation_reconstruction_2 ' - PACKAGE='Modular_arithmetic Nef_2 Nef_3 '
- PACKAGE='Partition_2 Periodic_2_triangulation_2 Periodic_3_triangulation_3 ' - PACKAGE='Nef_S2 NewKernel_d Number_types '
- PACKAGE='Point_set_2 Point_set_3 Point_set_processing_3 ' - PACKAGE='OpenNL Operations_on_polyhedra Optimal_transportation_reconstruction_2 '
- PACKAGE='Point_set_shape_detection_3 Poisson_surface_reconstruction_3 Polygon ' - PACKAGE='Optimisation_basic Partition_2 Periodic_2_triangulation_2 '
- PACKAGE='Polygon_mesh_processing Polyhedron Polyhedron_IO ' - PACKAGE='Periodic_3_triangulation_3 Point_set_2 Point_set_3 '
- PACKAGE='Polyline_simplification_2 Polynomial Polytope_distance_d ' - PACKAGE='Point_set_processing_3 Point_set_shape_detection_3 Poisson_surface_reconstruction_3 '
- PACKAGE='Principal_component_analysis Profiling_tools QP_solver ' - PACKAGE='Polygon Polygon_mesh_processing Polyhedron '
- PACKAGE='Polyhedron_IO Polyline_simplification_2 Polynomial '
- PACKAGE='Polytope_distance_d Principal_component_analysis Principal_component_analysis_LGPL '
- PACKAGE='Profiling_tools Property_map QP_solver '
- PACKAGE='Random_numbers Ridges_3 Scale_space_reconstruction_3 ' - PACKAGE='Random_numbers Ridges_3 Scale_space_reconstruction_3 '
- PACKAGE='Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 ' - PACKAGE='Scripts SearchStructures Segment_Delaunay_graph_2 '
- PACKAGE='Skin_surface_3 Snap_rounding_2 Solver_interface ' - PACKAGE='Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 Skin_surface_3 '
- PACKAGE='Spatial_searching Spatial_sorting STL_Extension ' - PACKAGE='Snap_rounding_2 Solver_interface Spatial_searching '
- PACKAGE='Straight_skeleton_2 Stream_lines_2 Stream_support ' - PACKAGE='Spatial_sorting STL_Extension Straight_skeleton_2 '
- PACKAGE='Subdivision_method_3 Surface_mesh Surface_mesh_deformation ' - PACKAGE='Stream_lines_2 Stream_support Subdivision_method_3 '
- PACKAGE='Surface_mesher Surface_mesh_parameterization Surface_mesh_segmentation ' - PACKAGE='Surface_mesh Surface_mesh_deformation Surface_mesh_parameterization '
- PACKAGE='Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization ' - PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification '
- PACKAGE='Sweep_line_2 TDS_2 TDS_3 ' - PACKAGE='Surface_mesh_skeletonization Surface_mesher Sweep_line_2 '
- PACKAGE='TDS_2 TDS_3 Testsuite '
- PACKAGE='Three Triangulation Triangulation_2 ' - PACKAGE='Three Triangulation Triangulation_2 '
- PACKAGE='Triangulation_3 Union_find Visibility_2 ' - PACKAGE='Triangulation_3 Union_find Visibility_2 '
- PACKAGE='Voronoi_diagram_2 ' - PACKAGE='Voronoi_diagram_2 wininst '
- PACKAGE='Polyhedron_demo' - PACKAGE='Polyhedron_demo'
compiler: compiler:
- clang-3.6 - clang-3.6

View File

@ -75,7 +75,7 @@ do
cd .. cd ..
for f in * for f in *
do do
if [ -d "$f/examples/$f" ] || [ -d "$f/test/$f" ] || [ -d "$f/demo/$f" ] if [ -d "$f/package_info/$f" ]
then then
PACKAGES+="$f " PACKAGES+="$f "
fi fi
@ -87,6 +87,7 @@ do
then then
echo "The matrix and the actual package list differ : ." echo "The matrix and the actual package list differ : ."
echo ${DIFFERENCE[*]} echo ${DIFFERENCE[*]}
echo "You should run generate_travis.sh."
exit 1 exit 1
fi fi
echo "Matrix is up to date." echo "Matrix is up to date."

View File

@ -19,7 +19,7 @@ INDEX=0
i=0 i=0
for f in * for f in *
do do
if [ -d "$f/examples/$f" ] || [ -d "$f/test/$f" ] || [ -d "$f/demo/$f" ] if [ -d "$f/package_info/$f" ]
then then
PACKAGES[$INDEX]+="$f " PACKAGES[$INDEX]+="$f "
i=$[i+1] i=$[i+1]

View File

@ -14,6 +14,8 @@ BGL
Boolean_set_operations_2 Boolean_set_operations_2
Bounding_volumes Bounding_volumes
Box_intersection_d Box_intersection_d
Cartesian_kernel
CGAL_Core
CGAL_ImageIO CGAL_ImageIO
CGAL_ipelets CGAL_ipelets
Circular_kernel_2 Circular_kernel_2
@ -37,6 +39,7 @@ Geomview
GraphicsView GraphicsView
HalfedgeDS HalfedgeDS
Hash_map Hash_map
Homogeneous_kernel
Inscribed_areas Inscribed_areas
Installation Installation
Interpolation Interpolation
@ -50,10 +53,14 @@ Kernel_23
Kernel_d Kernel_d
Kinetic_data_structures Kinetic_data_structures
Kinetic_framework Kinetic_framework
LEDA
Linear_cell_complex Linear_cell_complex
MacOSX
Maintenance
Matrix_search Matrix_search
Mesh_2 Mesh_2
Mesh_3 Mesh_3
Mesher_level
Minkowski_sum_2 Minkowski_sum_2
Minkowski_sum_3 Minkowski_sum_3
Modifier Modifier
@ -63,7 +70,10 @@ Nef_3
Nef_S2 Nef_S2
NewKernel_d NewKernel_d
Number_types Number_types
OpenNL
Operations_on_polyhedra
Optimal_transportation_reconstruction_2 Optimal_transportation_reconstruction_2
Optimisation_basic
Partition_2 Partition_2
Periodic_2_triangulation_2 Periodic_2_triangulation_2
Periodic_3_triangulation_3 Periodic_3_triangulation_3
@ -80,11 +90,15 @@ Polyline_simplification_2
Polynomial Polynomial
Polytope_distance_d Polytope_distance_d
Principal_component_analysis Principal_component_analysis
Principal_component_analysis_LGPL
Profiling_tools Profiling_tools
Property_map
QP_solver QP_solver
Random_numbers Random_numbers
Ridges_3 Ridges_3
Scale_space_reconstruction_3 Scale_space_reconstruction_3
Scripts
SearchStructures
Segment_Delaunay_graph_2 Segment_Delaunay_graph_2
Segment_Delaunay_graph_Linf_2 Segment_Delaunay_graph_Linf_2
Set_movable_separability_2 Set_movable_separability_2
@ -100,15 +114,16 @@ Stream_support
Subdivision_method_3 Subdivision_method_3
Surface_mesh Surface_mesh
Surface_mesh_deformation Surface_mesh_deformation
Surface_mesher
Surface_mesh_parameterization Surface_mesh_parameterization
Surface_mesh_segmentation Surface_mesh_segmentation
Surface_mesh_shortest_path Surface_mesh_shortest_path
Surface_mesh_simplification Surface_mesh_simplification
Surface_mesh_skeletonization Surface_mesh_skeletonization
Surface_mesher
Sweep_line_2 Sweep_line_2
TDS_2 TDS_2
TDS_3 TDS_3
Testsuite
Three Three
Triangulation Triangulation
Triangulation_2 Triangulation_2
@ -116,3 +131,4 @@ Triangulation_3
Union_find Union_find
Visibility_2 Visibility_2
Voronoi_diagram_2 Voronoi_diagram_2
wininst

View File

@ -50,22 +50,20 @@ struct Dynamic_property_map {
} }
} }
friend reference get(const Dynamic_property_map& m, const key_type& k) friend reference get(const Dynamic_property_map& m, const key_type& k)
{ {
typename Map::const_iterator it = m.map_->find(k); typename Map::const_iterator it = m.map_->find(k);
if(it == m.map_->end()){ if(it == m.map_->end()){
(*(const_cast<Dynamic_property_map&>(m).map_))[k] = m.default_value();
return m.default_value(); return m.default_value();
} }
return it->second; return it->second;
} }
friend void put(Dynamic_property_map& m, const key_type& k, const value_type& v) friend void put(const Dynamic_property_map& m, const key_type& k, const value_type& v)
{ {
if(v != m.default_value()){ (*(m.map_))[k] = v;
(*(m.map_))[k] = v;
}
} }
@ -192,7 +190,7 @@ add_property(face_property_t<T> prop, const G&)
return internal::Dynamic_property_map<face_descriptor,T>(prop.t); return internal::Dynamic_property_map<face_descriptor,T>(prop.t);
} }
template<class G, class T, typename Descriptor> template<typename G, typename Descriptor, typename T>
void remove_property( void remove_property(
internal::Dynamic_property_map<Descriptor, T> pm, internal::Dynamic_property_map<Descriptor, T> pm,
const G&) const G&)

View File

@ -0,0 +1,47 @@
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.
project( Property_map_Tests )
cmake_minimum_required(VERSION 2.8.11)
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# include helper file
include( ${CGAL_USE_FILE} )
# Boost and its components
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
# include for local directory
# include for local package
include_directories( BEFORE ../../include )
# Creating entries for all C++ files with "main" routine
# ##########################################################
include( CGAL_CreateSingleSourceCGALProgram )
create_single_source_cgal_program( "dynamic_property_map.cpp" )

View File

@ -0,0 +1,13 @@
#include <CGAL/Dynamic_property_map.h>
int main()
{
CGAL::internal::Dynamic_property_map<int,int> dpm(2);
assert(dpm.default_value() == 2);
assert(get(dpm, 0) == 2);
put(dpm, 0, 1);
assert(get(dpm, 0) == 1);
return 0;
}