Merge pull request #2978 from MaelRL/PMap-Fix_Default_pmap-GF

Property map: fix get() not returning the default value
This commit is contained in:
Sebastien Loriot 2018-05-15 22:09:59 +02:00 committed by GitHub
commit 1b84d7402d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 17 deletions

View File

@ -496,7 +496,7 @@ private:
launch_feature_computation (new Feature_adder_verticality<VectorMap> (this, normal_map, 0)); launch_feature_computation (new Feature_adder_verticality<VectorMap> (this, normal_map, 0));
} }
void generate_normal_based_features(const CGAL::Default_property_map<Iterator, typename GeomTraits::Vector_3>&) void generate_normal_based_features(const CGAL::Constant_property_map<Iterator, typename GeomTraits::Vector_3>&)
{ {
generate_multiscale_feature_variant_0<Verticality> (); generate_multiscale_feature_variant_0<Verticality> ();
} }
@ -544,7 +544,7 @@ private:
2, 25.f * float(i), 12.5f)); 2, 25.f * float(i), 12.5f));
} }
void generate_color_based_features(const CGAL::Default_property_map<Iterator, RGB_Color>&) void generate_color_based_features(const CGAL::Constant_property_map<Iterator, RGB_Color>&)
{ {
} }
@ -581,7 +581,7 @@ private:
launch_feature_computation (new Feature_adder_echo<EchoMap> (this, echo_map, i)); launch_feature_computation (new Feature_adder_echo<EchoMap> (this, echo_map, i));
} }
void generate_echo_based_features(const CGAL::Default_property_map<Iterator, std::size_t>&) void generate_echo_based_features(const CGAL::Constant_property_map<Iterator, std::size_t>&)
{ {
} }
@ -615,10 +615,10 @@ private:
} }
template <typename T> template <typename T>
Default_property_map<Iterator, T> Constant_property_map<Iterator, T>
get_parameter (const Default&) get_parameter (const Default&)
{ {
return Default_property_map<Iterator, T>(); return Constant_property_map<Iterator, T>();
} }
template<typename VectorMap, typename ColorMap, typename EchoMap> template<typename VectorMap, typename ColorMap, typename EchoMap>

View File

@ -440,20 +440,29 @@ make_property_map(const std::vector<T>& v)
} }
/// \ingroup PkgProperty_map /// \ingroup PkgProperty_map
/// Property map that only returns the default value type /// Property map that returns a fixed value.
/// \cgalModels `ReadablePropertyMap` /// Note that this value is chosen when the map is constructed and cannot
template<class InputIterator, class ValueType> /// be changed afterwards. Specifically, the free function `put()` does nothing.
struct Default_property_map{ ///
/// \cgalModels `ReadWritePropertyMap`
template<class KeyType, class ValueType>
struct Constant_property_map
{
const ValueType default_value; const ValueType default_value;
typedef typename InputIterator::value_type key_type; typedef KeyType key_type;
typedef boost::readable_property_map_tag category; typedef ValueType value_type;
typedef boost::read_write_property_map_tag category;
Default_property_map(const ValueType& default_value = ValueType()) : default_value (default_value) { } Constant_property_map(const value_type& default_value = value_type()) : default_value (default_value) { }
/// Free function to use a get the value from an iterator using Input_iterator_property_map. /// Free function that returns `pm.default_value`.
inline friend ValueType inline friend value_type
get (const Default_property_map&, const key_type&){ return ValueType(); } get (const Constant_property_map& pm, const key_type&){ return pm.default_value; }
/// Free function that does nothing.
inline friend void
put (const Constant_property_map&, const key_type&, const value_type&) { }
}; };
/// \ingroup PkgProperty_map /// \ingroup PkgProperty_map