vgl_bounding_box.hxx
Go to the documentation of this file.
1 #include "vgl_bounding_box.h"
2 #include "vgl_sphere_3d.h"
3 #include "vgl_pointset_3d.h"
4 #include "vgl_cubic_spline_3d.h"
5 #include "vgl_box_3d.h"
6 
7 template <class T>
9  T r = sph.radius();
10  vgl_point_3d<T> c = sph.centre();
11  T cx = c.x(), cy = c.y(), cz = c.z();
12  vgl_point_3d<T> p0(cx-r, cy-r, cz-r);
13  vgl_point_3d<T> p1(cx+r, cy+r, cz+r);
14  vgl_box_3d<T> bb;
15  bb.add(p0); bb.add(p1);
16  return bb;
17 }
18 
19 template <class T>
21  unsigned n = ptset.npts();
22  vgl_box_3d<T> bb;
23  for(unsigned i=0; i<n; i++)
24  bb.add(ptset.p(i));
25  return bb;
26 }
27 
28 template <class T>
30  vgl_box_3d<T> ret;
31  std::vector<vgl_point_3d<T> > knots = spline.knots();
32  for(typename std::vector<vgl_point_3d<T> >::const_iterator kit = knots.begin();
33  kit != knots.end(); ++kit)
34  ret.add(*kit);
35  return ret;
36 }
37 
38 #define VGL_BOUNDING_BOX_INSTANTIATE(T) \
39 template vgl_box_3d<T> vgl_bounding_box(vgl_sphere_3d<T> const&); \
40 template vgl_box_3d<T> vgl_bounding_box(vgl_pointset_3d<T> const&); \
41 template vgl_box_3d<T> vgl_bounding_box(vgl_cubic_spline_3d<T> const&)
A 3-d cubic spline curve defined by a set of knots (3-d points)
vgl_point_3d< Type > p(unsigned i) const
Contains class to represent a cartesian 3D bounding box.
Set of bounding box functions.
Type & z()
Definition: vgl_point_3d.h:73
Type radius() const
Definition: vgl_sphere_3d.h:46
void add(vgl_point_3d< Type > const &p)
Add a point to this box.
Definition: vgl_box_3d.hxx:373
vgl_box_3d< T > vgl_bounding_box(vgl_sphere_3d< T > const &sph)
Bounding box for a sphere.
A 3-d pointset.
a sphere in 3D nonhomogeneous space
std::vector< vgl_point_3d< Type > > knots() const
Type & x()
Definition: vgl_point_3d.h:71
const vgl_point_3d< Type > & centre() const
Definition: vgl_sphere_3d.h:45
Represents a cartesian 3D box.
Definition: vgl_box_3d.h:65
size_t npts() const
Type & y()
Definition: vgl_point_3d.h:72