AABB tree:

- rebuild now returns void.
This commit is contained in:
Pierre Alliez 2009-05-13 07:32:41 +00:00
parent ed67c4d61b
commit 75a82ec32d
3 changed files with 10 additions and 13 deletions

View File

@ -60,9 +60,9 @@ Class \ccRefName\ is a static data structure for efficient intersection and dist
\ccOperations \ccOperations
\ccMethod{template < class InputIterator> \ccMethod{template < class InputIterator>
bool rebuild(InputIterator begin, void rebuild(InputIterator begin,
InputIterator beyond);} InputIterator beyond);}
{Clears the current tree and rebuilds it from scratch. See constructor above for the parameters. Returns \ccc{true}, iff the memory allocation is successful. } {Clears the current tree and rebuilds it from scratch. See constructor above for the parameters. }
\ccMethod{void clear();} \ccMethod{void clear();}
{Clears the AABB tree. } {Clears the AABB tree. }

View File

@ -43,18 +43,18 @@ namespace CGALi {
const K&) const K&)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
FT d = 0.0; FT d = (FT)0.0;
FT distance = 0.0; FT distance = (FT)0.0;
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
if(sphere.center()[i] < bbox.min(i)) if(sphere.center()[i] < bbox.min(i))
{ {
d = bbox.min(i) - sphere.center()[i]; d = (FT)bbox.min(i) - sphere.center()[i];
distance += d*d; distance += d*d;
} }
else if(sphere.center()[i] > bbox.max(i)) else if(sphere.center()[i] > (FT)bbox.max(i))
{ {
d = sphere.center()[i] - bbox.max(i); d = sphere.center()[i] - (FT)bbox.max(i);
distance += d*d; distance += d*d;
} }
} }

View File

@ -69,7 +69,7 @@ namespace CGAL {
/// a constructor taking a ConstPrimitiveIterator as argument. /// a constructor taking a ConstPrimitiveIterator as argument.
/// Returns true if the memory allocation was successful. /// Returns true if the memory allocation was successful.
template<typename ConstPrimitiveIterator> template<typename ConstPrimitiveIterator>
bool rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond); void rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond);
/// Non virtual destructor /// Non virtual destructor
~AABB_tree() ~AABB_tree()
@ -88,7 +88,6 @@ namespace CGAL {
clear_search_tree(); clear_search_tree();
} }
// bbox and size // bbox and size
Bounding_box bbox() const { return m_p_root_node->bbox(); } Bounding_box bbox() const { return m_p_root_node->bbox(); }
size_type size() const { return m_primitives.size(); } size_type size() const { return m_primitives.size(); }
@ -435,10 +434,9 @@ namespace CGAL {
} }
// Clears tree and insert a set of primitives // Clears tree and insert a set of primitives
// Returns true upon successful memory allocation
template<typename Tr> template<typename Tr>
template<typename ConstPrimitiveIterator> template<typename ConstPrimitiveIterator>
bool AABB_tree<Tr>::rebuild(ConstPrimitiveIterator first, void AABB_tree<Tr>::rebuild(ConstPrimitiveIterator first,
ConstPrimitiveIterator beyond) ConstPrimitiveIterator beyond)
{ {
// cleanup current tree and internal KD tree // cleanup current tree and internal KD tree
@ -457,12 +455,11 @@ namespace CGAL {
{ {
std::cerr << "Unable to allocate memory for AABB tree" << std::endl; std::cerr << "Unable to allocate memory for AABB tree" << std::endl;
m_primitives.clear(); m_primitives.clear();
return false; clear();
} }
// constructs the tree // constructs the tree
m_p_root_node->expand(m_primitives.begin(), m_primitives.end(), m_primitives.size()); m_p_root_node->expand(m_primitives.begin(), m_primitives.end(), m_primitives.size());
return true;
} }