SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Box3d.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
67 
68 
75 #ifndef SLIP_BOX3D_HPP
76 #define SLIP_BOX3D_HPP
77 
78 #include <iostream>
79 #include <cassert>
80 #include <string>
81 #include "Box.hpp"
82 #include "Point3d.hpp"
83 #include "DPoint3d.hpp"
84 
85 #include <boost/serialization/access.hpp>
86 #include <boost/serialization/split_member.hpp>
87 #include <boost/serialization/version.hpp>
88 
89 namespace slip
90 {
91 
92 
120 template <typename CoordType>
121 class Box3d: public slip::Box<CoordType,3>
122 {
123 public :
124  typedef Box3d<CoordType> self;
126 
135  Box3d();
141  Box3d(const Point<CoordType,3>& p1,
142  const Point<CoordType,3>& p2);
143 
154  Box3d(const CoordType& x11,
155  const CoordType& x12,
156  const CoordType& x13,
157  const CoordType& x21,
158  const CoordType& x22,
159  const CoordType& x23);
160 
168  Box3d(const CoordType& xc,
169  const CoordType& yc,
170  const CoordType& zc,
171  const CoordType& w);
172 
178  Box3d(const Point<CoordType,3>& pc,
179  const CoordType& w);
180 
188  Box3d(const Point<CoordType,3>& pc,
189  const CoordType& w1,
190  const CoordType& w2,
191  const CoordType& w3);
192 
213  const Point<CoordType,3>& front_upper_left() const;
214 
215 
230  const Point<CoordType,3>& back_bottom_right() const;
231 
242  void set_coord(const CoordType& x11,
243  const CoordType& x12,
244  const CoordType& x13,
245  const CoordType& x21,
246  const CoordType& x22,
247  const CoordType& x23);
248 
255  std::string name() const;
256 
257 
262  CoordType volume() const;
263 
268  CoordType width() const;
269 
274  CoordType height() const;
275 
280  CoordType depth() const;
281 
282 
283  private:
284  friend class boost::serialization::access;
285  template<class Archive>
286  void save(Archive & ar, const unsigned int version) const
287  {
288  ar & boost::serialization::base_object<slip::Box<CoordType,3> >(*this);
289  }
290  template<class Archive>
291  void load(Archive & ar, const unsigned int version)
292  {
293  ar & boost::serialization::base_object<slip::Box<CoordType,3> >(*this);
294  }
295  BOOST_SERIALIZATION_SPLIT_MEMBER()
296 };
297 }//slip::
298 
299 namespace slip
300 {
301 
302  template<typename CoordType>
303  inline
305  Box<CoordType,3>()
306  {}
307 
308  template<typename CoordType>
309  inline
311  const Point<CoordType,3>& p2):
312  Box<CoordType,3>(p1,p2)
313  {}
314 
315  template<typename CoordType>
316  inline
317  Box3d<CoordType>::Box3d(const CoordType& x11,
318  const CoordType& x12,
319  const CoordType& x13,
320  const CoordType& x21,
321  const CoordType& x22,
322  const CoordType& x23):
323  Box<CoordType,3>(Point3d<CoordType>(x11,x12,x13),Point3d<CoordType>(x21,x22,x23))
324  {}
325 
326  template<typename CoordType>
327  inline
328  Box3d<CoordType>::Box3d(const CoordType& xc,
329  const CoordType& yc,
330  const CoordType& zc,
331  const CoordType& w):
332  Box<CoordType,3>(Point3d<CoordType>(xc-w,yc-w,zc-w),Point3d<CoordType>(xc+w,yc+w,zc+w))
333  {}
334 
335  template<typename CoordType>
336  inline
338  const CoordType& w):
339  Box<CoordType,3>(Point3d<CoordType>(pc[0]-w,pc[1]-w,pc[2]-w),Point3d<CoordType>(pc[0]+w,pc[1]+w,pc[2]+w))
340  {}
341 
342 
343  template<typename CoordType>
344  inline
346  const CoordType& w1,
347  const CoordType& w2,
348  const CoordType& w3):
349  Box<CoordType,3>(Point3d<CoordType>(pc[0]-w1,pc[1]-w2,pc[2]-w3),Point3d<CoordType>(pc[0]+w1,pc[1]+w2,pc[2]+w3))
350  {}
351 
352 
353  template<typename CoordType>
354  inline
356 
357  template<typename CoordType>
358  inline
360 
361  template<typename CoordType>
362  inline
363  const Point<CoordType,3>& Box3d<CoordType>::front_upper_left() const {return this->p1_;}
364 
365 
366  template<typename CoordType>
367  inline
369 
370  template<typename CoordType>
371  inline
373 
374  template<typename CoordType>
375  inline
376  const Point<CoordType,3>& Box3d<CoordType>::back_bottom_right() const {return this->p2_;}
377 
378  template<typename CoordType>
379  inline
380  void Box3d<CoordType>::set_coord(const CoordType& x11,
381  const CoordType& x12,
382  const CoordType& x13,
383  const CoordType& x21,
384  const CoordType& x22,
385  const CoordType& x23)
386  {
387  this->p1_[0] = x11;
388  this->p1_[1] = x12;
389  this->p1_[2] = x13;
390  this->p2_[0] = x21;
391  this->p2_[1] = x22;
392  this->p2_[2] = x23;
393  }
394 
395 
396  template<typename T>
397  inline
398  std::string
399  Box3d<T>::name() const {return "Box3d";}
400 
401 
402  template<typename CoordType>
403  inline
404  CoordType Box3d<CoordType>::volume() const {return width() * height() * depth();}
405 
406  template<typename CoordType>
407  inline
408  CoordType Box3d<CoordType>::width() const {return (this->p2_[2] - this->p1_[2]+1);}
409 
410  template<typename CoordType>
411  inline
412  CoordType Box3d<CoordType>::height() const {return (this->p2_[1] - this->p1_[1]+1);}
413 
414  template<typename CoordType>
415  inline
416  CoordType Box3d<CoordType>::depth() const {return (this->p2_[0] - this->p1_[0]+1);}
417 
418 }//slip::
419 
420 #endif //SLIP_BOX3D_HPP
Point< CoordType, 3 > & front_upper_left()
Accessor/Mutator of the front_upper_left point (p1) of Box3d.
Definition: Box3d.hpp:359
Provides a class to modelize 3d points.
CoordType width() const
compute the width of the Box3d.
Definition: Box3d.hpp:408
void set_coord(const CoordType &x11, const CoordType &x12, const CoordType &x13, const CoordType &x21, const CoordType &x22, const CoordType &x23)
Mutator of the coordinates of the Box3d.
Definition: Box3d.hpp:380
std::string name() const
Returns the name of the class.
Definition: Box3d.hpp:399
Box< CoordType, 3 > base
Definition: Box3d.hpp:125
CoordType volume() const
compute the volume of the Box3d.
Definition: Box3d.hpp:404
Provides an abstract class to manipulate nd box.
Provides a class to modelize the difference of slip::Point3d.
Box3d()
Constructs a Box3d.
Definition: Box3d.hpp:304
Define an abstract Box structure.
Definition: Box.hpp:98
CoordType depth() const
compute the depth of the Box3d.
Definition: Box3d.hpp:416
This is a Box3d class, a specialized version of slip::Box<CoordType,DIM> with DIM = 3...
Definition: Box3d.hpp:121
Point< CoordType, 3 > & back_bottom_right()
Accessor/Mutator of the back_bottom_right point (p2) of Box3d.
Definition: Box3d.hpp:372
CoordType height() const
compute the height of the Box3d.
Definition: Box3d.hpp:412
This is a point3d class, a specialized version of Point<CoordType,DIM> with DIM = 3...