From dfc678846fcb18ed5b8d49ef0f9cda53489f6ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 14 May 2012 16:10:00 +0000 Subject: [PATCH] update AABB_primitive to take into account the fact that the property maps can be stored outside of the primitive --- .gitattributes | 1 - .../CGAL/AABB_FaceGraph_triangle_primitive.h | 4 +- .../AABB_HalfedgeGraph_segment_primitive.h | 2 + AABB_tree/include/CGAL/AABB_primitive.h | 132 ++++++++++++++---- .../include/CGAL/AABB_segment_primitive.h | 2 + .../include/CGAL/AABB_triangle_primitive.h | 2 + .../internal/AABB_tree/Primitive_caching.h | 67 --------- 7 files changed, 115 insertions(+), 95 deletions(-) delete mode 100644 AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h diff --git a/.gitattributes b/.gitattributes index 5160d71a436..82cf57c06a2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -48,7 +48,6 @@ AABB_tree/include/CGAL/AABB_polyhedron_segment_primitive.h -text AABB_tree/include/CGAL/AABB_polyhedron_triangle_primitive.h -text AABB_tree/include/CGAL/AABB_primitive.h -text AABB_tree/include/CGAL/AABB_traits.h -text -AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h -text AABB_tree/test/AABB_tree/AABB_test_util.h -text AABB_tree/test/AABB_tree/aabb_correctness_triangle_test.cpp -text AABB_tree/test/AABB_tree/aabb_distance_edge_test.cpp -text diff --git a/AABB_tree/include/CGAL/AABB_FaceGraph_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_FaceGraph_triangle_primitive.h index 72d581ce3a0..9eaf0b4cc5f 100644 --- a/AABB_tree/include/CGAL/AABB_FaceGraph_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_FaceGraph_triangle_primitive.h @@ -41,7 +41,8 @@ template < class FaceGraph, class AABB_FaceGraph_triangle_primitive : public AABB_primitive< Id_, Triangle_from_facet_handle_property_map, One_point_from_facet_handle_property_map, - cache_datum > + Tag_false, + cache_datum > { typedef Triangle_from_facet_handle_property_map Triangle_property_map; typedef One_point_from_facet_handle_property_map Point_property_map; @@ -49,6 +50,7 @@ class AABB_FaceGraph_triangle_primitive : public AABB_primitive< Id_, typedef AABB_primitive< Id_, Triangle_property_map, Point_property_map, + Tag_false, cache_datum > Base; public: diff --git a/AABB_tree/include/CGAL/AABB_HalfedgeGraph_segment_primitive.h b/AABB_tree/include/CGAL/AABB_HalfedgeGraph_segment_primitive.h index ffaf8c34e2e..9dedb10a18d 100644 --- a/AABB_tree/include/CGAL/AABB_HalfedgeGraph_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_HalfedgeGraph_segment_primitive.h @@ -58,6 +58,7 @@ template < class HalfedgeGraph, class AABB_HalfedgeGraph_segment_primitive : public AABB_primitive< Id_, Segment_from_edge_descriptor_property_map, Source_point_from_edge_descriptor, + Tag_false, cache_datum > { typedef Segment_from_edge_descriptor_property_map Triangle_property_map; @@ -66,6 +67,7 @@ class AABB_HalfedgeGraph_segment_primitive : public AABB_primitive< Id_, typedef AABB_primitive< Id_, Triangle_property_map, Point_property_map, + Tag_false, cache_datum > Base; public: diff --git a/AABB_tree/include/CGAL/AABB_primitive.h b/AABB_tree/include/CGAL/AABB_primitive.h index d88e496c3ba..76d8f769661 100644 --- a/AABB_tree/include/CGAL/AABB_primitive.h +++ b/AABB_tree/include/CGAL/AABB_primitive.h @@ -26,48 +26,128 @@ #ifndef CGAL_AABB_PRIMITIVE_H #define CGAL_AABB_PRIMITIVE_H -#include +#include +#include namespace CGAL { +//class for the typedefs template < class Id_, class ObjectPropertyMap, - class PointPropertyMap, - class cache_datum=Tag_false > -class AABB_primitive : - public internal::Primitive_caching< Id_, ObjectPropertyMap, cache_datum > + class PointPropertyMap > +struct AABB_primitive_base { - // types - typedef internal::Primitive_caching Primitive_base; -public: - typedef typename boost::property_traits< ObjectPropertyMap >::value_type Datum; //datum type typedef typename boost::property_traits< PointPropertyMap >::value_type Point; //point type + typedef typename boost::property_traits< ObjectPropertyMap >::reference Datum_ref; //reference datum type + typedef typename boost::property_traits< PointPropertyMap >::reference Point_ref; //reference point type typedef Id_ Id; // Id type -private: - PointPropertyMap m_ppmap; - Id m_it; +protected: + Id m_id; public: // constructors - AABB_primitive(Id it,ObjectPropertyMap t_pmap=ObjectPropertyMap(), PointPropertyMap p_pmap=PointPropertyMap()) - : Primitive_base(it,t_pmap),m_ppmap(p_pmap), m_it(it) - {} -public: - Id id() const { return m_it; } + AABB_primitive_base(Id id) : m_id(id) {} - typename Primitive_base::result_type datum() const { - return this->get_primitive(m_it); - } - - /// Returns a point on the primitive - typename boost::property_traits< PointPropertyMap >::reference - reference_point() const { - return get(m_ppmap, m_it); - } + Id id() const {return m_id;} }; + +template < class Id, + class ObjectPropertyMap, + class PointPropertyMap, + class ExternalPropertyMaps, + class cache_datum> +struct AABB_primitive; + + +//no caching, property maps internally stored +template < class Id, + class ObjectPropertyMap, + class PointPropertyMap > +class AABB_primitive + : public AABB_primitive_base +{ + typedef AABB_primitive_base Base; + ObjectPropertyMap m_obj_pmap; + PointPropertyMap m_pt_pmap; +public: + AABB_primitive(Id id, ObjectPropertyMap obj_pmap=ObjectPropertyMap(), PointPropertyMap pt_pmap=PointPropertyMap()) + : Base(id), m_obj_pmap(obj_pmap), m_pt_pmap(pt_pmap) {} + + typename Base::Datum_ref + datum() const { return get(m_obj_pmap,this->m_id); } + + typename Base::Point_ref + reference_point() const { return get(m_pt_pmap,this->m_id); } +}; + +//caching, property maps internally stored +template < class Id, + class ObjectPropertyMap, + class PointPropertyMap > +class AABB_primitive + : public AABB_primitive_base +{ + typedef AABB_primitive_base Base; + typename boost::property_traits< ObjectPropertyMap >::value_type m_datum; + PointPropertyMap m_pt_pmap; +public: + AABB_primitive(Id id, ObjectPropertyMap obj_pmap=ObjectPropertyMap(), PointPropertyMap pt_pmap=PointPropertyMap()) + : Base(id), m_datum( get(obj_pmap,id) ), m_pt_pmap(pt_pmap){} + + const typename Base::Datum& + datum() const { return m_datum; } + + typename Base::Point_ref + reference_point() const { return get(m_pt_pmap,this->m_id); } +}; + +//no caching, property maps are stored outside the class +template < class Id, + class ObjectPropertyMap, + class PointPropertyMap > +class AABB_primitive + : public AABB_primitive_base +{ + typedef AABB_primitive_base Base; +public: + typedef std::pair Extra_data; + + AABB_primitive(Id id, ObjectPropertyMap=ObjectPropertyMap(), PointPropertyMap=PointPropertyMap()) + : Base(id) {} + + typename Base::Datum_ref + datum(const Extra_data& data) const { return get(data.first,this->m_id); } + + typename Base::Point_ref + reference_point(const Extra_data& data) const { return get(data.second,this->m_id); } +}; + + +//caching, property map is stored outside the class +template < class Id, + class ObjectPropertyMap, + class PointPropertyMap > +class AABB_primitive + : public AABB_primitive_base +{ + typedef AABB_primitive_base Base; + typename boost::property_traits< ObjectPropertyMap >::value_type m_datum; +public: + typedef PointPropertyMap Extra_data; + + AABB_primitive(Id id, ObjectPropertyMap obj_pmap=ObjectPropertyMap(), PointPropertyMap=PointPropertyMap()) + : Base(id), m_datum( get(obj_pmap,id) ) {} + + const typename Base::Datum& + datum(Extra_data) const { return m_datum; } + + typename Base::Point_ref + reference_point(Extra_data data) const { return get(data,this->m_id); } +}; + } // end namespace CGAL diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive.h b/AABB_tree/include/CGAL/AABB_segment_primitive.h index 967d1abfbc3..01c3999c3a3 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive.h @@ -59,11 +59,13 @@ template < class Iterator, class AABB_segment_primitive : public AABB_primitive< Iterator, Input_iterator_property_map, internal::Source_of_segment_3_iterator_property_map, + Tag_false, cache_datum > { typedef AABB_primitive< Iterator, Input_iterator_property_map, internal::Source_of_segment_3_iterator_property_map, + Tag_false, cache_datum > Base; public: // constructors diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive.h index 499c45cad18..076e7954a0d 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive.h @@ -58,11 +58,13 @@ template < class Iterator, class AABB_triangle_primitive : public AABB_primitive< Iterator, Input_iterator_property_map, internal::Point_from_triangle_3_iterator_property_map, + Tag_false, cache_datum > { typedef AABB_primitive< Iterator, Input_iterator_property_map, internal::Point_from_triangle_3_iterator_property_map, + Tag_false, cache_datum > Base; public: // constructors diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h b/AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h deleted file mode 100644 index f4a5a39116d..00000000000 --- a/AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2012 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Sebastien Loriot -// -//****************************************************************************** -// File Description : -// -//****************************************************************************** - -#include -#include - -#ifndef CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H -#define CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H - -namespace CGAL { -namespace internal{ - - template - struct Primitive_caching; - - template - struct Primitive_caching - { - - typedef typename boost::property_traits< PropertyMap >::value_type Primitive; - typedef const Primitive& result_type; - Primitive datum; - - Primitive_caching(Id id,PropertyMap pmap) {datum=get(pmap,id);} - result_type get_primitive(Id) const{ - return datum; - } - }; - - template - struct Primitive_caching - { - typedef typename boost::property_traits< PropertyMap >::reference result_type; - PropertyMap pmap_; - - Primitive_caching(Id,PropertyMap pmap){pmap_=pmap;} - result_type get_primitive(Id id) const{ - return get(pmap_,id); - } - }; - - -} } //namespace CGAL::internal - -#endif