SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
slice_error.hh
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 // Copyright (C) 2009 Ed Rosten (er258@cam.ac.uk)
4 //
5 // This file is part of the TooN Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
20 
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29 
30 namespace TooN {
31 
32 namespace Internal
33 {
34  template<bool StaticBad>
35  struct BadSlice;
36 
44  template<>
45  struct BadSlice<0>{
46  static void check(){}
47  };
48 
57  template<int Size, int Start, int Length>
58  struct CheckSlice
59  {
60 
63  template<int Num> struct N
64  {
65  static int n(int num)
66  {
67  return Num==Dynamic?num:Num;
68  }
69  };
70 
77  static void check()
78  {
79  //Sanity check all basic static sizes
81  BadSlice<!(Start >= 0)>::check();
84  }
85 
95  static void check(int size, int start, int length)
96  {
97  //Sanity check all basic static sizes
101 
102  //We can make sure Length <= Size, even if Start is unknown
104 
105  //We can make sure Start < Size even if Length is unknown
107 
109  #ifndef TOON_NDEBUG_MISMATCH
110  if(Start != Dynamic && Start != start)
111  {
112  std::cerr << "TooN slice: mismatch between static and dynamic start.\n";
113  std::abort();
114  }
115  if(Length != Dynamic && Length != length)
116  {
117  std::cerr << "TooN slice: mismatch between static and dynamic length.\n";
118  std::abort();
119  }
120  if(Size != Dynamic && Size != size)
121  {
122  std::cerr << "TooN slice: mismatch between static and dynamic size.\n";
123  std::abort();
124  }
125  #endif
126  if( N<Start>::n(start) + N<Length>::n(length) > N<Size>::n(size) ||
127  N<Start>::n(start) < 0 ||
128  N<Length>::n(length) < 0)
129  {
130  #ifdef TOON_TEST_INTERNALS
131  throw Internal::SliceError();
132  #elif !defined TOON_NDEBUG_SLICE
133  std::cerr << "TooN slice out of range" << std::endl;
134  std::abort();
135  #endif
136  }
137  }
138  };
139 
140  #ifdef TOON_TEST_INTERNALS
141  template<bool StaticBad>
142  struct BadSlice{
143  static void check(){
144  throw Internal::StaticSliceError();
145  }
146  };
147  #endif
148 }
149 
150 }
Everything lives inside this namespace.
Definition: allocator.hh:48
static const int Dynamic
Template size value used to indicate dynamically sized vectors and matrices.
Definition: TooN.h:272
static int n(int num)
Definition: slice_error.hh:65
static void check(int size, int start, int length)
Definition: slice_error.hh:95
static void check()
This function does nothing: it merely exists.
Definition: slice_error.hh:46