SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Box4d.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 
74 #ifndef SLIP_BOX4D_HPP
75 #define SLIP_BOX4D_HPP
76 
77 #include <iostream>
78 #include <cassert>
79 #include <string>
80 #include "Box.hpp"
81 #include "Point4d.hpp"
82 
83 #include <boost/serialization/access.hpp>
84 #include <boost/serialization/split_member.hpp>
85 #include <boost/serialization/version.hpp>
86 
87 namespace slip
88 {
89 
90 
106 template <typename CoordType>
107 class Box4d: public slip::Box<CoordType,4>
108 {
109 public :
110  typedef Box4d<CoordType> self;
112 
121  Box4d();
128  const slip::Point<CoordType,4>& p2);
129 
141  Box4d(const CoordType& x11,
142  const CoordType& x12,
143  const CoordType& x13,
144  const CoordType& x14,
145  const CoordType& x21,
146  const CoordType& x22,
147  const CoordType& x23,
148  const CoordType& x24);
149 
158  Box4d(const CoordType& xc,
159  const CoordType& yc,
160  const CoordType& zc,
161  const CoordType& lc,
162  const CoordType& r);
163 
170  const CoordType& r);
171 
181  const CoordType& r1,
182  const CoordType& r2,
183  const CoordType& r3,
184  const CoordType& r4);
185 
207 
208 
224 
237  void set_coord(const CoordType& x11,
238  const CoordType& x12,
239  const CoordType& x13,
240  const CoordType& x14,
241  const CoordType& x21,
242  const CoordType& x22,
243  const CoordType& x23,
244  const CoordType& x24);
245 
252  std::string name() const;
253 
254 
259  CoordType hypervolume() const;
260 
265  CoordType duration() const;
266 
271  CoordType depth() const;
272 
277  CoordType height() const;
278 
283  CoordType width() const;
284 
285  private:
286  friend class boost::serialization::access;
287  template<class Archive>
288  void save(Archive & ar, const unsigned int version) const
289  {
290  ar & boost::serialization::base_object<slip::Box<CoordType,4> >(*this);
291  }
292  template<class Archive>
293  void load(Archive & ar, const unsigned int version)
294  {
295  ar & boost::serialization::base_object<slip::Box<CoordType,4> >(*this);
296  }
297  BOOST_SERIALIZATION_SPLIT_MEMBER()
298 
299 };
300 }//slip::
301 
302 namespace slip
303 {
304 
305 template<typename CoordType>
306 inline
308 slip::Box<CoordType,4>()
309 {}
310 
311 template<typename CoordType>
312 inline
314  const slip::Point<CoordType,4>& p2):
315  slip::Box<CoordType,4>(p1,p2)
316  {}
317 
318 template<typename CoordType>
319 inline
320 Box4d<CoordType>::Box4d(const CoordType& x11,
321  const CoordType& x12,
322  const CoordType& x13,
323  const CoordType& x14,
324  const CoordType& x21,
325  const CoordType& x22,
326  const CoordType& x23,
327  const CoordType& x24):
328  slip::Box<CoordType,4>(Point4d<CoordType>(x11,x12,x13,x14),Point4d<CoordType>(x21,x22,x23,x24))
329  {}
330 
331 template<typename CoordType>
332 inline
333 Box4d<CoordType>::Box4d(const CoordType& xc,
334  const CoordType& yc,
335  const CoordType& zc,
336  const CoordType& lc,
337  const CoordType& r):
338  slip::Box<CoordType,4>(Point4d<CoordType>(xc-r,yc-r,zc-r,lc-r),Point4d<CoordType>(xc+r,yc+r,zc+r,lc+r))
339  {}
340 
341 template<typename CoordType>
342 inline
344  const CoordType& r):
345  slip::Box<CoordType,4>(Point4d<CoordType>(pc[0]-r,pc[1]-r,pc[2]-r,pc[3]-r),
346  Point4d<CoordType>(pc[0]+r,pc[1]+r,pc[2]+r,pc[3]+r))
347  {}
348 
349 
350 template<typename CoordType>
351 inline
353  const CoordType& r1,
354  const CoordType& r2,
355  const CoordType& r3,
356  const CoordType& r4):
357  slip::Box<CoordType,4>(Point4d<CoordType>(pc[0]-r1,pc[1]-r2,pc[2]-r3,pc[3]-r4),
358  Point4d<CoordType>(pc[0]+r1,pc[1]+r2,pc[2]+r3,pc[3]+r4))
359  {}
360 
361 
362 template<typename CoordType>
363 inline
365 
366 template<typename CoordType>
367 inline
369 
370 template<typename CoordType>
371 inline
373 
374 template<typename CoordType>
375 inline
377 
378 template<typename CoordType>
379 inline
381 
382 template<typename CoordType>
383 inline
385 
386 template<typename CoordType>
387 inline
388 void Box4d<CoordType>::set_coord(const CoordType& x11,
389  const CoordType& x12,
390  const CoordType& x13,
391  const CoordType& x14,
392  const CoordType& x21,
393  const CoordType& x22,
394  const CoordType& x23,
395  const CoordType& x24)
396  {
397  this->p1_[0] = x11;
398  this->p1_[1] = x12;
399  this->p1_[2] = x13;
400  this->p1_[3] = x14;
401  this->p2_[0] = x21;
402  this->p2_[1] = x22;
403  this->p2_[2] = x23;
404  this->p2_[3] = x24;
405  }
406 
407 
408 template<typename T>
409 inline
410 std::string
411 Box4d<T>::name() const {return "Box4d";}
412 
413 
414 template<typename CoordType>
415 inline
416 CoordType Box4d<CoordType>::hypervolume() const {return duration() * width() * height() * depth();}
417 
418 template<typename CoordType>
419 inline
420 CoordType Box4d<CoordType>::width() const {return (this->p2_[3] - this->p1_[3]+1);}
421 
422 template<typename CoordType>
423 inline
424 CoordType Box4d<CoordType>::height() const {return (this->p2_[2] - this->p1_[2]+1);}
425 
426 template<typename CoordType>
427 inline
428 CoordType Box4d<CoordType>::depth() const {return (this->p2_[1] - this->p1_[1]+1);}
429 
430 template<typename CoordType>
431 inline
432 CoordType Box4d<CoordType>::duration() const {return (this->p2_[0] - this->p1_[0]+1);}
433 
434 }//slip::
435 
436 #endif //SLIP_BOX4D_HPP
Box4d()
Constructs a Box4d.
Definition: Box4d.hpp:307
slip::Box< CoordType, 4 > base
Definition: Box4d.hpp:111
CoordType depth() const
compute the depth of the Box4d (second dimension size).
Definition: Box4d.hpp:428
std::string name() const
Returns the name of the class.
Definition: Box4d.hpp:411
Provides an abstract class to manipulate nd box.
Provides a class to modelize 4d points.
This is a Box4d class, a specialized version of slip::Box<CoordType,DIM> with DIM = 4...
Definition: Box4d.hpp:107
slip::Point< CoordType, 4 > & last_back_bottom_right()
Accessor/Mutator of the last_back_bottom_right point (p2) of Box4d.
Definition: Box4d.hpp:380
This is a point4d class, a specialized version of Point<CoordType,DIM> with DIM = 4...
Define an abstract Box structure.
Definition: Box.hpp:98
CoordType hypervolume() const
compute the hypervolume of the Box4d.
Definition: Box4d.hpp:416
CoordType width() const
compute the width of the Box4d (fourth dimension size).
Definition: Box4d.hpp:420
CoordType duration() const
compute the duration of the Box4d (first dimension size).
Definition: Box4d.hpp:432
slip::Point< CoordType, 4 > & first_front_upper_left()
Accessor/Mutator of the first_front_upper_left point (p1) of Box4d.
Definition: Box4d.hpp:368
CoordType height() const
compute the height of the Box4d (third dimension size).
Definition: Box4d.hpp:424
void set_coord(const CoordType &x11, const CoordType &x12, const CoordType &x13, const CoordType &x14, const CoordType &x21, const CoordType &x22, const CoordType &x23, const CoordType &x24)
Mutator of the coordinates of the Box4d.
Definition: Box4d.hpp:388