moving AABB_traits_base and Remove_optional into separate files

This commit is contained in:
Sven Oesau 2024-03-21 15:14:57 +01:00
parent c193cea746
commit 0bc40dcdc6
4 changed files with 84 additions and 27 deletions

View File

@ -21,11 +21,12 @@
#include <CGAL/Bbox_2.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/AABB_traits_base.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/AABB_tree/internal/Remove_optional.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <CGAL/AABB_traits_3.h> // for Remove_optional
#include <CGAL/Search_traits_2.h>
#include <optional>
@ -172,7 +173,7 @@ public:
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::AABB_tree::Remove_optional<Intersection_type>::type,
typename internal::Remove_optional<Intersection_type>::type,
typename Primitive::Id > Type;
};

View File

@ -21,9 +21,11 @@
#include <CGAL/Bbox_3.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/AABB_traits_base.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/AABB_tree/internal/Remove_optional.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <CGAL/Search_traits_3.h>
@ -35,30 +37,6 @@ namespace CGAL {
namespace internal{ namespace AABB_tree {
template <class T>
struct Remove_optional { typedef T type; };
template <class T>
struct Remove_optional< ::std::optional<T> > { typedef T type; };
//helper controlling whether extra data should be stored in the AABB_tree traits class
template <class Primitive, bool has_shared_data=Has_nested_type_Shared_data<Primitive>::value>
struct AABB_traits_base;
template <class Primitive>
struct AABB_traits_base<Primitive,false>{};
template <class Primitive>
struct AABB_traits_base<Primitive,true>{
typename Primitive::Shared_data m_primitive_data;
template <typename ... T>
void set_shared_data(T&& ... t){
m_primitive_data=Primitive::construct_shared_data(std::forward<T>(t)...);
}
const typename Primitive::Shared_data& shared_data() const {return m_primitive_data;}
};
// AABB_traits_intersection_base brings in the Intersection_distance predicate,
// if GeomTraits is a model RayIntersectionGeomTraits.
template <typename GeomTraits, bool ray_intersection_geom_traits=Is_ray_intersection_geomtraits<GeomTraits>::value>
@ -195,7 +173,7 @@ public:
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::AABB_tree::Remove_optional<Intersection_type>::type,
typename internal::Remove_optional<Intersection_type>::type,
typename Primitive::Id > Type;
};

View File

@ -0,0 +1,45 @@
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
//
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#ifndef CGAL_AABB_TRAITS_BASE_H
#define CGAL_AABB_TRAITS_BASE_H
namespace CGAL {
namespace internal {
namespace AABB_tree {
//helper controlling whether extra data should be stored in the AABB_tree traits class
template <class Primitive, bool has_shared_data = Has_nested_type_Shared_data<Primitive>::value>
struct AABB_traits_base;
template <class Primitive>
struct AABB_traits_base<Primitive, false> {};
template <class Primitive>
struct AABB_traits_base<Primitive, true> {
typename Primitive::Shared_data m_primitive_data;
template <typename ... T>
void set_shared_data(T&& ... t) {
m_primitive_data = Primitive::construct_shared_data(std::forward<T>(t)...);
}
const typename Primitive::Shared_data& shared_data() const { return m_primitive_data; }
};
}
}
}
#endif

View File

@ -0,0 +1,33 @@
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
//
#ifndef CGAL_REMOVE_OPTIONAL_H_
#define CGAL_REMOVE_OPTIONAL_H_
#include <optional>
#include <CGAL/license/AABB_tree.h>
namespace CGAL {
namespace internal {
template <class T>
struct Remove_optional { typedef T type; };
template <class T>
struct Remove_optional< ::std::optional<T> > { typedef T type; };
} // end namespace internal
} // end namespace CGAL
#endif