mirror of https://github.com/CGAL/cgal
update AABB_primitive to take into account the fact that the property maps
can be stored outside of the primitive
This commit is contained in:
parent
21cf39655e
commit
dfc678846f
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ template < class FaceGraph,
|
|||
class AABB_FaceGraph_triangle_primitive : public AABB_primitive< Id_,
|
||||
Triangle_from_facet_handle_property_map<FaceGraph>,
|
||||
One_point_from_facet_handle_property_map<FaceGraph>,
|
||||
cache_datum >
|
||||
Tag_false,
|
||||
cache_datum >
|
||||
{
|
||||
typedef Triangle_from_facet_handle_property_map<FaceGraph> Triangle_property_map;
|
||||
typedef One_point_from_facet_handle_property_map<FaceGraph> 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:
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ template < class HalfedgeGraph,
|
|||
class AABB_HalfedgeGraph_segment_primitive : public AABB_primitive< Id_,
|
||||
Segment_from_edge_descriptor_property_map<HalfedgeGraph>,
|
||||
Source_point_from_edge_descriptor<HalfedgeGraph>,
|
||||
Tag_false,
|
||||
cache_datum >
|
||||
{
|
||||
typedef Segment_from_edge_descriptor_property_map<HalfedgeGraph> 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:
|
||||
|
|
|
|||
|
|
@ -26,48 +26,128 @@
|
|||
#ifndef CGAL_AABB_PRIMITIVE_H
|
||||
#define CGAL_AABB_PRIMITIVE_H
|
||||
|
||||
#include <CGAL/internal/AABB_tree/Primitive_caching.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/tags.h>
|
||||
|
||||
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<Id_, ObjectPropertyMap, cache_datum> 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<Id, ObjectPropertyMap, PointPropertyMap,Tag_false,Tag_false>
|
||||
: public AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap>
|
||||
{
|
||||
typedef AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap> 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<Id, ObjectPropertyMap, PointPropertyMap,Tag_true,Tag_false>
|
||||
: public AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap>
|
||||
{
|
||||
typedef AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap> 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<Id, ObjectPropertyMap, PointPropertyMap,Tag_false,Tag_true>
|
||||
: public AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap>
|
||||
{
|
||||
typedef AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap> Base;
|
||||
public:
|
||||
typedef std::pair<ObjectPropertyMap,PointPropertyMap> 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<Id, ObjectPropertyMap, PointPropertyMap,Tag_true,Tag_true>
|
||||
: public AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap>
|
||||
{
|
||||
typedef AABB_primitive_base<Id,ObjectPropertyMap,PointPropertyMap> 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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,11 +59,13 @@ template < class Iterator,
|
|||
class AABB_segment_primitive : public AABB_primitive< Iterator,
|
||||
Input_iterator_property_map<Iterator>,
|
||||
internal::Source_of_segment_3_iterator_property_map<Iterator>,
|
||||
Tag_false,
|
||||
cache_datum >
|
||||
{
|
||||
typedef AABB_primitive< Iterator,
|
||||
Input_iterator_property_map<Iterator>,
|
||||
internal::Source_of_segment_3_iterator_property_map<Iterator>,
|
||||
Tag_false,
|
||||
cache_datum > Base;
|
||||
public:
|
||||
// constructors
|
||||
|
|
|
|||
|
|
@ -58,11 +58,13 @@ template < class Iterator,
|
|||
class AABB_triangle_primitive : public AABB_primitive< Iterator,
|
||||
Input_iterator_property_map<Iterator>,
|
||||
internal::Point_from_triangle_3_iterator_property_map<Iterator>,
|
||||
Tag_false,
|
||||
cache_datum >
|
||||
{
|
||||
typedef AABB_primitive< Iterator,
|
||||
Input_iterator_property_map<Iterator>,
|
||||
internal::Point_from_triangle_3_iterator_property_map<Iterator>,
|
||||
Tag_false,
|
||||
cache_datum > Base;
|
||||
public:
|
||||
// constructors
|
||||
|
|
|
|||
|
|
@ -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 <CGAL/property_map.h>
|
||||
#include <CGAL/tags.h>
|
||||
|
||||
#ifndef CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H
|
||||
#define CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal{
|
||||
|
||||
template <class Id,class PropertyMap,class do_cache>
|
||||
struct Primitive_caching;
|
||||
|
||||
template <class Id,class PropertyMap>
|
||||
struct Primitive_caching<Id,PropertyMap,Tag_true>
|
||||
{
|
||||
|
||||
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 <class Id,class PropertyMap>
|
||||
struct Primitive_caching<Id,PropertyMap,Tag_false>
|
||||
{
|
||||
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
|
||||
Loading…
Reference in New Issue