mirror of https://github.com/CGAL/cgal
add property_map as template parameter of segment and triangle primitive
and add a template parameter to enable or disable the caching of the or object inside the primitive. Pb to handle: in case the object is not cached, point() might be expansive
This commit is contained in:
parent
9823bf261b
commit
7a0b2326e1
|
|
@ -43,6 +43,7 @@ AABB_tree/include/CGAL/AABB_segment_primitive.h -text
|
|||
AABB_tree/include/CGAL/AABB_traits.h -text
|
||||
AABB_tree/include/CGAL/AABB_triangle_primitive.h -text
|
||||
AABB_tree/include/CGAL/internal/AABB_tree/AABB_search_tree.h -text
|
||||
AABB_tree/include/CGAL/internal/AABB_tree/Primitive_caching.h -text
|
||||
AABB_tree/include/CGAL/internal/AABB_tree/nearest_point_segment_3.h -text
|
||||
AABB_tree/test/AABB_tree/AABB_test_util.h -text
|
||||
AABB_tree/test/AABB_tree/aabb_correctness_triangle_test.cpp -text
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
|
||||
// Copyright (c) 2009, 2011 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Pierre Alliez, Stephane Tayeb
|
||||
// Author(s) : Pierre Alliez, Stephane Tayeb, Sebastien Loriot
|
||||
//
|
||||
//******************************************************************************
|
||||
// File Description :
|
||||
|
|
@ -25,12 +25,20 @@
|
|||
#ifndef CGAL_AABB_SEGMENT_PRIMITIVE_H_
|
||||
#define CGAL_AABB_SEGMENT_PRIMITIVE_H_
|
||||
|
||||
#include <CGAL/internal/AABB_tree/Primitive_caching.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class Iterator>
|
||||
class AABB_segment_primitive
|
||||
template <class GeomTraits,
|
||||
class Iterator,
|
||||
class PropertyMap=boost::typed_identity_property_map<typename GeomTraits::Segment_3>,
|
||||
bool cache_primitive=true>
|
||||
class AABB_segment_primitive :
|
||||
public internal::Primitive_caching<typename GeomTraits::Segment_3,Iterator,PropertyMap,cache_primitive>
|
||||
{
|
||||
// types
|
||||
typedef internal::Primitive_caching<typename GeomTraits::Segment_3,Iterator,PropertyMap,cache_primitive> Base;
|
||||
public:
|
||||
typedef typename GeomTraits::Point_3 Point; // point type
|
||||
typedef typename GeomTraits::Segment_3 Datum; // datum type
|
||||
|
|
@ -39,29 +47,23 @@ public:
|
|||
// member data
|
||||
private:
|
||||
Id m_it;
|
||||
Datum m_datum;
|
||||
|
||||
public:
|
||||
// constructors
|
||||
AABB_segment_primitive() {}
|
||||
AABB_segment_primitive(Id it)
|
||||
AABB_segment_primitive(Id it,PropertyMap pmap=PropertyMap())
|
||||
: m_it(it)
|
||||
{
|
||||
m_datum = *it; // copy segment
|
||||
}
|
||||
AABB_segment_primitive(const AABB_segment_primitive& primitive)
|
||||
{
|
||||
m_it = primitive.id();
|
||||
m_datum = primitive.datum();
|
||||
this->set_primitive(it,pmap);
|
||||
}
|
||||
public:
|
||||
Id& id() { return m_it; }
|
||||
const Id& id() const { return m_it; }
|
||||
Datum& datum() { return m_datum; }
|
||||
const Datum& datum() const { return m_datum; }
|
||||
typename Base::result_type datum() const {
|
||||
return this->get_primitive(m_it);
|
||||
}
|
||||
|
||||
/// Returns a point on the primitive
|
||||
Point reference_point() const { return m_datum.source(); }
|
||||
Point reference_point() const { return datum().source(); }
|
||||
};
|
||||
|
||||
} // end namespace CGAL
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
|
||||
// Copyright (c) 2009, 2011 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Pierre Alliez, Stephane Tayeb
|
||||
// Author(s) : Pierre Alliez, Stephane Tayeb, Sebastien Loriot
|
||||
//
|
||||
//******************************************************************************
|
||||
// File Description :
|
||||
|
|
@ -25,44 +25,46 @@
|
|||
#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_H_
|
||||
#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_
|
||||
|
||||
#include <CGAL/internal/AABB_tree/Primitive_caching.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class Iterator>
|
||||
class AABB_triangle_primitive
|
||||
{
|
||||
public:
|
||||
template <class GeomTraits,
|
||||
class Iterator,
|
||||
class PropertyMap=boost::typed_identity_property_map<typename GeomTraits::Triangle_3>,
|
||||
bool cache_primitive=true>
|
||||
class AABB_triangle_primitive :
|
||||
public internal::Primitive_caching<typename GeomTraits::Triangle_3,Iterator,PropertyMap,cache_primitive>
|
||||
{
|
||||
// types
|
||||
typedef Iterator Id; // Id type
|
||||
typedef internal::Primitive_caching<typename GeomTraits::Triangle_3,Iterator,PropertyMap,cache_primitive> Base;
|
||||
public:
|
||||
typedef typename GeomTraits::Point_3 Point; // point type
|
||||
typedef typename GeomTraits::Triangle_3 Datum; // datum type
|
||||
typedef Iterator Id; // Id type
|
||||
|
||||
private:
|
||||
// member data
|
||||
Id m_it; // iterator
|
||||
Datum m_datum; // 3D triangle
|
||||
|
||||
// constructor
|
||||
public:
|
||||
private:
|
||||
Id m_it;
|
||||
public:
|
||||
// constructors
|
||||
AABB_triangle_primitive() {}
|
||||
AABB_triangle_primitive(Id it)
|
||||
: m_it(it)
|
||||
AABB_triangle_primitive(Id it,PropertyMap pmap=PropertyMap())
|
||||
: m_it(it)
|
||||
{
|
||||
m_datum = *it; // copy triangle
|
||||
this->set_primitive(it,pmap);
|
||||
}
|
||||
AABB_triangle_primitive(const AABB_triangle_primitive& primitive)
|
||||
{
|
||||
m_datum = primitive.datum();
|
||||
m_it = primitive.id();
|
||||
}
|
||||
public:
|
||||
public:
|
||||
Id& id() { return m_it; }
|
||||
const Id& id() const { return m_it; }
|
||||
Datum& datum() { return m_datum; }
|
||||
const Datum& datum() const { return m_datum; }
|
||||
typename Base::result_type datum() const {
|
||||
return this->get_primitive(m_it);
|
||||
}
|
||||
|
||||
/// Returns a point on the primitive
|
||||
Point reference_point() const { return m_datum.vertex(0); }
|
||||
};
|
||||
Point reference_point() const { return datum().vertex(0); }
|
||||
};
|
||||
|
||||
} // end namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright (c) 2011 GeometryFactory (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.
|
||||
//
|
||||
// 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 :
|
||||
//
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
#ifndef CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H
|
||||
#define CGAL_INTERNAL_AABB_TREE_PRIMITIVE_CACHING_H
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal{
|
||||
|
||||
template <class Primitive,class Id,class PropertyMap,bool do_cache>
|
||||
struct Primitive_caching;
|
||||
|
||||
template <class Primitive,class Id,class PropertyMap>
|
||||
struct Primitive_caching<Primitive,Id,PropertyMap,true>
|
||||
{
|
||||
typedef const Primitive& result_type;
|
||||
Primitive datum;
|
||||
|
||||
void set_primitive(Id id,PropertyMap pmap){datum=get(pmap,*id);}
|
||||
result_type get_primitive(Id) const{
|
||||
return datum;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Primitive,class Id,class PropertyMap>
|
||||
struct Primitive_caching<Primitive,Id,PropertyMap,false>
|
||||
{
|
||||
typedef Primitive result_type;
|
||||
PropertyMap pmap_;
|
||||
|
||||
void set_primitive(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