From 6efd7f7954ddd7bd118f6abcabbf2ed7908d3723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 9 May 2012 07:14:49 +0000 Subject: [PATCH] * remove a template parameter to primitive caching * add a generic class that has two property map as template parameter to define a aabb_tree primitive --- .gitattributes | 1 + AABB_tree/include/CGAL/AABB_primitive.h | 85 +++++++++++++++++++ .../include/CGAL/AABB_segment_primitive.h | 6 +- .../include/CGAL/AABB_triangle_primitive.h | 6 +- .../internal/AABB_tree/Primitive_caching.h | 24 +++--- 5 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 AABB_tree/include/CGAL/AABB_primitive.h diff --git a/.gitattributes b/.gitattributes index f40e100b297..08a97945f15 100644 --- a/.gitattributes +++ b/.gitattributes @@ -38,6 +38,7 @@ AABB_tree/examples/AABB_tree/cleanup.bat -text AABB_tree/include/CGAL/AABB_intersections.h -text 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 diff --git a/AABB_tree/include/CGAL/AABB_primitive.h b/AABB_tree/include/CGAL/AABB_primitive.h new file mode 100644 index 00000000000..6ea0de26236 --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_primitive.h @@ -0,0 +1,85 @@ +// 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: svn+ssh://sloriot@scm.gforge.inria.fr/svn/cgal/branches/features/AABB_tree-one_primitive_per_object-sloriot/AABB_tree/include/CGAL/AABB_triangle_primitive.h $ +// $Id: AABB_triangle_primitive.h 68970 2012-05-04 14:59:14Z sloriot $ +// +// +// Author(s) : Sebastien Loriot +// +//****************************************************************************** +// File Description : +// +//****************************************************************************** + +#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_H_ +#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace CGAL { + +template < class Iterator, + class ObjectPropertyMap, + class PointPropertyMap, + bool cache_primitive=false > +class AABB_primitive : + public internal::Primitive_caching< Iterator, TrianglePropertyMap, cache_primitive > +{ + // 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 Iterator Id; // Id type + +private: + Id m_it; + PointPropertyMap m_ppmap +public: + // constructors + AABB_primitive() {} + AABB_primitive(Id it,ObjectPropertyMap t_pmap=ObjectPropertyMap(), PointPropertyMap p_pmap=PointPropertyMap()) + : m_ppmap(p_pmap), m_it(it) + { + this->set_primitive(it,t_pmap); + } +public: + Id& id() { return m_it; } + const Id& id() const { return m_it; } + + 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); + } +}; + +} // end namespace CGAL + + +#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_H_ + diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive.h b/AABB_tree/include/CGAL/AABB_segment_primitive.h index da12afd0c32..f840d663f1d 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive.h @@ -67,7 +67,7 @@ namespace internal{ struct Segment_point_accessor{ Segment_point_accessor( ::CGAL::Default ){} - typedef Primitive_caching Prim_caching; + typedef Primitive_caching Prim_caching; typedef typename boost::mpl::if_< boost::is_const, typename boost::add_const::type, @@ -94,11 +94,11 @@ template class AABB_segment_primitive : - public internal::Primitive_caching, + public internal::Primitive_caching, public internal::Segment_point_accessor { // types - typedef internal::Primitive_caching Primitive_base; + typedef internal::Primitive_caching Primitive_base; typedef internal::Segment_point_accessor Point_accessor_base; public: typedef typename GeomTraits::Point_3 Point; // point type diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive.h index 20537cc83f2..3694155ae1e 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive.h @@ -67,7 +67,7 @@ namespace internal{ struct Triangle_point_accessor{ Triangle_point_accessor( ::CGAL::Default ){} - typedef Primitive_caching Prim_caching; + typedef Primitive_caching Prim_caching; typedef typename boost::mpl::if_< boost::is_const, typename boost::add_const::type, @@ -94,11 +94,11 @@ template class AABB_triangle_primitive : - public internal::Primitive_caching, + public internal::Primitive_caching, public internal::Triangle_point_accessor { // types - typedef internal::Primitive_caching Primitive_base; + typedef internal::Primitive_caching Primitive_base; typedef internal::Triangle_point_accessor Point_accessor_base; public: typedef typename GeomTraits::Point_3 Point; // point type diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h b/AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h index fc0571018bf..5e98ff9db8a 100644 --- a/AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h +++ b/AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h @@ -1,9 +1,10 @@ -// Copyright (c) 2011 GeometryFactory (France). +// Copyright (c) 2012 INRIA Sophia-Antipolis (France). // All rights reserved. // -// This file is part of CGAL (www.cgal.org); you may redistribute it under -// the terms of the Q Public License version 1.0. -// See the file LICENSE.QPL distributed with CGAL. +// 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. @@ -22,6 +23,7 @@ // //****************************************************************************** +#include #ifndef CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H #define CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H @@ -29,12 +31,14 @@ namespace CGAL { namespace internal{ - template + template struct Primitive_caching; - template - struct Primitive_caching + template + struct Primitive_caching { + + typedef typename boost::property_traits< PropertyMap >::value_type Primitive; typedef const Primitive& result_type; Primitive datum; @@ -44,10 +48,10 @@ namespace internal{ } }; - template - struct Primitive_caching + template + struct Primitive_caching { - typedef typename PropertyMap::reference result_type; + typedef typename boost::property_traits< PropertyMap >::reference result_type; PropertyMap pmap_; void set_primitive(Id,PropertyMap pmap){pmap_=pmap;}