SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Box1d.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_BOX1D_HPP
76 #define SLIP_BOX1D_HPP
77 
78 #include <iostream>
79 #include <cassert>
80 #include <string>
81 #include "Box.hpp"
82 #include "Point.hpp"
83 #include "Point1d.hpp"
84 #include "DPoint1d.hpp"
85 
86 #include <boost/serialization/access.hpp>
87 #include <boost/serialization/split_member.hpp>
88 #include <boost/serialization/version.hpp>
89 
90 namespace slip
91 {
92 
93 
109 template <typename CoordType>
110 class Box1d: public slip::Box<CoordType,1>
111 {
112 public :
113  typedef Box1d<CoordType> self;
115 
124  Box1d();
130  Box1d(const Point<CoordType,1>& p1,
131  const Point<CoordType,1>& p2);
132 
138  Box1d(const CoordType& x1,
139  const CoordType& x2);
140 
141 
142 
148  Box1d(const Point<CoordType,1>& pc,
149  const CoordType& w);
150 
161  void upper_left(const Point<CoordType,1>& p1);
171  const Point<CoordType,1>& upper_left() const;
172 
173 
178  void bottom_right(const Point<CoordType,1>& p2);
188  const Point<CoordType,1>& bottom_right() const;
189 
196  void set_coord(const CoordType& x1,
197  const CoordType& x2);
205  std::string name() const;
206 
211  CoordType length() const;
212 
217  CoordType width() const;
218 
219 private:
221  template<class Archive>
222  void save(Archive & ar, const unsigned int version) const
223  {
224  ar & boost::serialization::base_object<slip::Box<CoordType,1> >(*this);
225  }
226  template<class Archive>
227  void load(Archive & ar, const unsigned int version)
228  {
229  ar & boost::serialization::base_object<slip::Box<CoordType,1> >(*this);
230  }
231  BOOST_SERIALIZATION_SPLIT_MEMBER()
232 
233 };
234 }//slip::
235 
236 namespace slip
237 {
238  template<typename CoordType>
239  inline
241  Box<CoordType,1>()
242  {}
243 
244  template<typename CoordType>
245  inline
247  const Point<CoordType,1>& p2):
248  Box<CoordType,1>(p1,p2)
249  {}
250 
251  template<typename CoordType>
252  inline
253  Box1d<CoordType>::Box1d(const CoordType& x1,
254  const CoordType& x2):
255  Box<CoordType,1>(Point1d<CoordType>(x1),Point1d<CoordType>(x2))
256  {}
257 
258  template<typename CoordType>
259  inline
261  const CoordType& w):
262  Box<CoordType,1>(Point1d<CoordType>(pc[0]-w),Point1d<CoordType>(pc[0]+w))
263  {}
264 
265 
266 
267 
268  template<typename CoordType>
269  inline
270  void Box1d<CoordType>::upper_left(const Point<CoordType,1>& p1) {this->p1_=p1;}
271 
272  template<typename CoordType>
273  inline
275 
276  template<typename CoordType>
277  inline
278  const Point<CoordType,1>& Box1d<CoordType>::upper_left() const {return this->p1_;}
279 
280 
281  template<typename CoordType>
282  inline
283  void Box1d<CoordType>::bottom_right(const Point<CoordType,1>& p2) {this->p2_=p2;}
284 
285  template<typename CoordType>
286  inline
288 
289  template<typename CoordType>
290  inline
291  const Point<CoordType,1>& Box1d<CoordType>::bottom_right() const {return this->p2_;}
292 
293 
294  template<typename CoordType>
295  inline
296  void Box1d<CoordType>::set_coord(const CoordType& x1,
297  const CoordType& x2)
298  {
299  this->p1_[0] = x1;
300  this->p2_[0] = x2;
301  }
302 
303  template<typename T>
304  inline
305  std::string
306  Box1d<T>::name() const {return "Box1d";}
307 
308 
309  template<typename CoordType>
310  inline
311  CoordType Box1d<CoordType>::length() const {return this->width();}
312 
313  template<typename CoordType>
314  inline
315  CoordType Box1d<CoordType>::width() const {return (this->p2_[0] - this->p1_[0]+1);}
316 
317 }//slip::
318 
319 #endif //SLIP_BOX1D_HPP
Point< CoordType, 1 > & upper_left()
Accessor/Mutator of the upper_left point (p1) of Box1d.
Definition: Box1d.hpp:274
CoordType width() const
compute the width of the Box1d.
Definition: Box1d.hpp:315
void set_coord(const CoordType &x1, const CoordType &x2)
Mutator of the coordinates of the Box1d.
Definition: Box1d.hpp:296
Provides an abstract class to manipulate nd box.
Provides an abstract class to modelize nd points.
Provides a class to modelize 1d points.
std::string name() const
Returns the name of the class.
Definition: Box1d.hpp:306
Point< CoordType, 1 > & bottom_right()
Accessor/Mutator of the bottom_right point (p2) of Box1d.
Definition: Box1d.hpp:287
This is a point1d class, a specialized version of Point<CoordType,DIM> with DIM = 1...
Definition: Point1d.hpp:101
This is a Box1d class, a specialized version of slip::Box<CoordType,DIM> with DIM = 1...
Definition: Box1d.hpp:110
CoordType length() const
compute the length of the Box1d.
Definition: Box1d.hpp:311
Provides a class to modelize the difference of slip::Point1d.
Define an abstract Box structure.
Definition: Box.hpp:98
Box1d()
Constructs a Box3d.
Definition: Box1d.hpp:240
Box< CoordType, 1 > base
Definition: Box1d.hpp:114
friend class boost::serialization::access
Definition: Box1d.hpp:220