KernelCollectionConvexHull.cpp
Go to the documentation of this file.
1 // (C) Copyright Renaud Detry 2007-2015.
2 // Distributed under the GNU General Public License and under the
3 // BSD 3-Clause License (See accompanying file LICENSE.txt).
4 
5 /** @file */
6 
8 
10 
11 namespace nuklei {
12 
14  {
15  NUKLEI_TRACE_BEGIN();
16 #ifdef NUKLEI_USE_CGAL_DEPRECATED
17  using namespace cgal_convex_hull_types;
18 
19  if (n > size()) n = size();
20 
21  // create instance of the class with dimension == 3
22  boost::shared_ptr<Convex_hull_3> CH_p(new Convex_hull_3(3));
23 
24  for (const_sample_iterator i = as_const(*this).sampleBegin(n); i != i.end(); ++i)
25  {
26  Vector3 loc = i->getLoc();
27  CH_p->insert(Point_3(loc.X(), loc.Y(), loc.Z()));
28  }
29 
30  if (!CH_p->is_valid())
31  NUKLEI_LOG("As it often happens, CGAL says the hull is invalid.");
32 
33  if (deco_.has_key(HULL_KEY)) deco_.erase(HULL_KEY);
34  deco_.insert(HULL_KEY, CH_p);
35 #else
36  NUKLEI_THROW("This function requires CGAL. See http://renaud-detry.net/nuklei/group__install.html");
37 #endif
38  NUKLEI_TRACE_END();
39  }
40 
41 
43  {
44  NUKLEI_TRACE_BEGIN();
45 #ifdef NUKLEI_USE_CGAL_DEPRECATED
46  using namespace cgal_convex_hull_types;
47  Vector3 loc = k.getLoc();
48  if (!deco_.has_key(HULL_KEY))
49  NUKLEI_THROW("Undefined convex hull. Call buildConvexHull() first.");
50  return deco_.get< boost::shared_ptr<Convex_hull_3> >(HULL_KEY)->bounded_side
51  (Point_3(loc.X(), loc.Y(), loc.Z())) != CGAL::ON_UNBOUNDED_SIDE;
52 #else
53  NUKLEI_THROW("This function requires CGAL. See http://renaud-detry.net/nuklei/group__install.html");
54 #endif
55  NUKLEI_TRACE_END();
56  }
57 
58 
59 }
60 
nuklei_trsl::ppfilter_iterator< is_picked, const_iterator > const_sample_iterator
Sample Iterator type.
Public namespace.
Definition: Color.cpp:9
virtual Vector3 getLoc() const =0
Get the location component of the kernel.
void buildConvexHull(unsigned n)
Builds the convex hull of kernel positions and stores the hull internally. See Intermediary Results.
bool isWithinConvexHull(const kernel::base &k) const
Check if k is within the convex hull of contained kernel positions.
Polymorphic kernel class.
Definition: Kernel.h:45
Container::size_type size() const
Returns the number of kernels.
T const & as_const(T const &t)
Provides a const reference to an object.
Definition: Common.h:197
#define NUKLEI_THROW(x)
Throws an Error.
Definition: Common.h:94
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file LICENSE.txt or copy at http://www.gnu.org/copyleft/gpl.html.)
Revised Sun Sep 13 2020 19:10:06.