mirror of https://github.com/CGAL/cgal
added parameter to Orthtree_traits_point to use square/cubic space
This commit is contained in:
parent
6d84c07621
commit
d95d650dbf
|
|
@ -27,13 +27,15 @@ namespace CGAL {
|
||||||
\tparam GeomTraits a model of `Kernel`
|
\tparam GeomTraits a model of `Kernel`
|
||||||
\tparam PointRange a model of `Range` whose value type is the key type of `PointMap`
|
\tparam PointRange a model of `Range` whose value type is the key type of `PointMap`
|
||||||
\tparam PointMap a model of `ReadablePropertyMap` whose value type is `GeomTraits::Point_3`
|
\tparam PointMap a model of `ReadablePropertyMap` whose value type is `GeomTraits::Point_3`
|
||||||
|
\tparam cubic boolean to enforce a cubic octree
|
||||||
*/
|
*/
|
||||||
template <
|
template <
|
||||||
typename GeomTraits,
|
typename GeomTraits,
|
||||||
typename PointRange,
|
typename PointRange,
|
||||||
typename PointMap = Identity_property_map<typename std::iterator_traits<typename PointRange::iterator>::value_type>
|
typename PointMap = Identity_property_map<typename std::iterator_traits<typename PointRange::iterator>::value_type>,
|
||||||
|
bool cubic = false
|
||||||
>
|
>
|
||||||
using Octree = Orthtree<Orthtree_traits_point<GeomTraits, PointRange, PointMap, 3>>;
|
using Octree = Orthtree<Orthtree_traits_point<GeomTraits, PointRange, PointMap, cubic, 3>>;
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ template <
|
||||||
typename GeomTraits,
|
typename GeomTraits,
|
||||||
typename PointRange,
|
typename PointRange,
|
||||||
typename PointMap = Identity_property_map<typename std::iterator_traits<typename PointRange::iterator>::value_type>,
|
typename PointMap = Identity_property_map<typename std::iterator_traits<typename PointRange::iterator>::value_type>,
|
||||||
|
bool cubic = false,
|
||||||
int dimension = Ambient_dimension<
|
int dimension = Ambient_dimension<
|
||||||
typename std::iterator_traits<typename PointRange::iterator>::value_type,
|
typename std::iterator_traits<typename PointRange::iterator>::value_type,
|
||||||
GeomTraits
|
GeomTraits
|
||||||
|
|
@ -91,7 +92,7 @@ public:
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
using Base = Orthtree_traits_base<GeomTraits, dimension>;
|
using Base = Orthtree_traits_base<GeomTraits, dimension>;
|
||||||
using Self = Orthtree_traits_point<GeomTraits, PointRange, PointMap, dimension>;
|
using Self = Orthtree_traits_point<GeomTraits, PointRange, PointMap, cubic, dimension>;
|
||||||
using Tree = Orthtree<Self>;
|
using Tree = Orthtree<Self>;
|
||||||
|
|
||||||
using Node_index = typename Base::Node_index;
|
using Node_index = typename Base::Node_index;
|
||||||
|
|
@ -129,6 +130,21 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if constexpr (cubic) {
|
||||||
|
std::array<typename Self::FT, Self::dimension> center;
|
||||||
|
FT max_side = 0;
|
||||||
|
for (int i = 0; i < Self::dimension; i++) {
|
||||||
|
FT side = bbox_max[i] - bbox_min[i];
|
||||||
|
max_side = (std::max<FT>)(max_side, side);
|
||||||
|
center[i] = (bbox_min[i] + bbox_max[i]) * 0.5f;
|
||||||
|
}
|
||||||
|
max_side *= 0.5f;
|
||||||
|
for (int i = 0; i < Self::dimension; i++) {
|
||||||
|
bbox_min[i] = center[i] - max_side;
|
||||||
|
bbox_max[i] = center[i] + max_side;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {std::apply(Self::construct_point_d_object(), bbox_min),
|
return {std::apply(Self::construct_point_d_object(), bbox_min),
|
||||||
std::apply(Self::construct_point_d_object(), bbox_max)};
|
std::apply(Self::construct_point_d_object(), bbox_max)};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,15 @@ namespace CGAL {
|
||||||
\tparam GeomTraits must be a model of `Kernel`
|
\tparam GeomTraits must be a model of `Kernel`
|
||||||
\tparam PointRange must be a model of `Range` whose value type is the key type of `PointMap`
|
\tparam PointRange must be a model of `Range` whose value type is the key type of `PointMap`
|
||||||
\tparam PointMap must be a model of `ReadablePropertyMap` whose value type is `GeomTraits::Point_2`
|
\tparam PointMap must be a model of `ReadablePropertyMap` whose value type is `GeomTraits::Point_2`
|
||||||
|
\tparam square boolean to enforce a square quadtree
|
||||||
*/
|
*/
|
||||||
template <typename GeomTraits, typename PointRange,
|
template <typename GeomTraits, typename PointRange,
|
||||||
typename PointMap = Identity_property_map
|
typename PointMap = Identity_property_map
|
||||||
<typename std::iterator_traits<typename PointRange::iterator>::value_type> >
|
<typename std::iterator_traits<typename PointRange::iterator>::value_type>,
|
||||||
|
bool squared = false
|
||||||
|
>
|
||||||
|
|
||||||
using Quadtree = Orthtree<Orthtree_traits_point<GeomTraits, PointRange, PointMap, 2>>;
|
using Quadtree = Orthtree<Orthtree_traits_point<GeomTraits, PointRange, PointMap, squared, 2>>;
|
||||||
|
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue