Structs.h
Go to the documentation of this file.
1 // ****************************************************************************
2 // This file is part of the Integrating Vision Toolkit (IVT).
3 //
4 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
5 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
6 //
7 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 //
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
19 //
20 // 3. Neither the name of the KIT nor the names of its contributors may be
21 // used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
25 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
28 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // ****************************************************************************
35 // ****************************************************************************
36 // Filename: Structs.h
37 // Author: Pedram Azad
38 // Date: 2004
39 // ****************************************************************************
40 
41 
42 #ifndef __STRUCTS_H__
43 #define __STRUCTS_H__
44 
45 
46 // ****************************************************************************
47 // Necessary includes
48 // ****************************************************************************
49 
50 // IVT
51 #include "Math/Math2d.h"
52 #include "Math/Math3d.h"
54 
55 // system
56 #include <string.h>
57 #include <math.h>
58 #include <vector>
59 
60 
61 
62 // ****************************************************************************
63 // Structs
64 // ****************************************************************************
65 
66 struct ROI
67 {
69 };
70 
72 {
75 };
76 
78 {
81 };
82 
90 {
95 
99  float width;
100 
104  float height;
105 
109  float angle;
110 };
111 
118 struct Circle2d
119 {
124 
128  float radius;
129 };
130 
137 struct Ellipse2d
138 {
143 
147  float radius_x;
148 
152  float radius_y;
153 
161  float angle;
162 };
163 
180 {
182  {
184  Math2d::SetVec(directionVector, Math2d::zero_vec);
185  Math2d::SetVec(normalVector, Math2d::zero_vec);
186  c = 0.0f;
187  }
188 
189  StraightLine2d(const Vec2d &point1, const Vec2d &point2)
190  {
191  // choose first point as reference point
192  Math2d::SetVec(point, point1);
193 
194  // compute direction vector
195  Math2d::SubtractVecVec(point2, point1, directionVector);
196 
197  // normalize direction vector
198  Math2d::NormalizeVec(directionVector);
199 
200  // compute normal vector (will be normalized, since u is normalized)
201  Math2d::SetVec(normalVector, -directionVector.y, directionVector.x);
202 
203  // compute - n * a
204  c = -Math2d::ScalarProduct(normalVector, point);
205  }
206 
207  StraightLine2d(float angle, float c)
208  {
209  // set c
210  this->c = c;
211 
212  // compute normal vector (will be normalized, since sin^2 + cos^2 = 1
213  Math2d::SetVec(normalVector, cosf(angle), sinf(angle));
214 
215  // compute direction vector (will be normalized, since n is normalized)
216  Math2d::SetVec(directionVector, -normalVector.y, normalVector.x);
217 
218  // compute an arbitrary point belonging to the straight line
219  if (fabsf(normalVector.x) > fabsf(normalVector.y))
220  {
221  Math2d::SetVec(point, -c / normalVector.x, 0.0f);
222  }
223  else
224  {
225  Math2d::SetVec(point, 0.0f, -c / normalVector.y);
226  }
227  }
228 
229  StraightLine2d(const PointPair2d &pointPair)
230  {
231  StraightLine2d(pointPair.p1, pointPair.p2);
232  }
233 
238 
243 
248 
252  float c;
253 };
254 
255 struct MyRegion
256 {
257  // constructor
259  {
260  pPixels = 0;
261  }
262 
263  // copy constructor
264  MyRegion(const MyRegion &region)
265  {
266  nPixels = region.nPixels;
267 
268  if (region.pPixels)
269  {
270  pPixels = new int[nPixels];
271  memcpy(pPixels, region.pPixels, nPixels * sizeof(int));
272  }
273  else
274  pPixels = 0;
275 
276  nSeedOffset = region.nSeedOffset;
277 
278  Math2d::SetVec(centroid, region.centroid);
279 
280  min_x = region.min_x;
281  min_y = region.min_y;
282  max_x = region.max_x;
283  max_y = region.max_y;
284 
285  ratio = region.ratio;
286  }
287 
288  // destructor
290  {
291  if (pPixels)
292  delete [] pPixels;
293  }
294 
295  // assign operator
296  MyRegion& operator= (const MyRegion &region)
297  {
298  nPixels = region.nPixels;
299 
300  if (pPixels)
301  delete [] pPixels;
302 
303  if (region.pPixels)
304  {
305  pPixels = new int[nPixels];
306  memcpy(pPixels, region.pPixels, nPixels * sizeof(int));
307  }
308  else
309  pPixels = 0;
310 
311  nSeedOffset = region.nSeedOffset;
312 
313  Math2d::SetVec(centroid, region.centroid);
314 
315  min_x = region.min_x;
316  min_y = region.min_y;
317  max_x = region.max_x;
318  max_y = region.max_y;
319 
320  ratio = region.ratio;
321 
322  return *this;
323  }
324 
325  // attributes
326  int *pPixels;
327  int nPixels;
328 
330 
332 
333  int min_x;
334  int min_y;
335  int max_x;
336  int max_y;
337 
338  float ratio;
339 };
340 
341 
342 // ****************************************************************************
343 // Typedefs
344 // ****************************************************************************
345 
346 typedef std::vector<MyRegion> RegionList;
352 
353 
354 
355 #endif /* __STRUCTS_H__ */
CDynamicArrayTemplate< Ellipse2d > CEllipse2dArray
Definition: Structs.h:349
float height
The height of the rectangle.
Definition: Structs.h:104
Vec2d centroid
Definition: Structs.h:331
float width
The width of the rectangle.
Definition: Structs.h:99
int min_x
Definition: Structs.h:333
Data structure for the representation of a 2D circle.
Definition: Structs.h:118
Vec2d center
The center of the ellipse.
Definition: Structs.h:142
~MyRegion()
Definition: Structs.h:289
CDynamicArrayTemplate< StraightLine2d > CStraightLine2dArray
Definition: Structs.h:350
StraightLine2d(float angle, float c)
Definition: Structs.h:207
CDynamicArrayTemplate< int > CIntArray
Definition: Structs.h:351
Data structure for the representation of a 3D vector.
Definition: Math3d.h:73
Data structure for the representation of a 2D rectangle.
Definition: Structs.h:89
StraightLine2d(const Vec2d &point1, const Vec2d &point2)
Definition: Structs.h:189
float ScalarProduct(const Vec2d &vector1, const Vec2d &vector2)
Definition: Math2d.cpp:155
float angle
The rotiation angle of the ellipse, given in radians.
Definition: Structs.h:161
float radius
The radius of the circle.
Definition: Structs.h:128
Vec2d normalVector
The normalized normal vector of the straight line.
Definition: Structs.h:247
StraightLine2d(const PointPair2d &pointPair)
Definition: Structs.h:229
float radius_y
The radius in vertical direction of the ellipse (vertical refers to when angle = 0).
Definition: Structs.h:152
std::vector< MyRegion > RegionList
Definition: Structs.h:346
const GLubyte * c
Definition: glext.h:5181
Vec2d center
The center of the rectangle.
Definition: Structs.h:94
CDynamicArrayTemplate< Circle2d > CCircle2dArray
Definition: Structs.h:348
int min_x
Definition: Structs.h:68
int min_y
Definition: Structs.h:68
Vec3d p2
Definition: Structs.h:80
CDynamicArrayTemplate< MyRegion > CRegionArray
Definition: Structs.h:347
int * pPixels
Definition: Structs.h:326
Vec2d p1
Definition: Structs.h:73
int min_y
Definition: Structs.h:334
Definition: Structs.h:66
void NormalizeVec(Vec2d &vec)
Definition: Math2d.cpp:160
float angle
The angle of the rectangle.
Definition: Structs.h:109
void SubtractVecVec(const Vec2d &vector1, const Vec2d &vector2, Vec2d &result)
Definition: Math2d.cpp:148
MyRegion()
Definition: Structs.h:258
const Vec2d zero_vec
Definition: Math2d.cpp:61
int nPixels
Definition: Structs.h:327
Data structure for the representation of a 2D ellipse.
Definition: Structs.h:137
int max_x
Definition: Structs.h:335
MyRegion(const MyRegion &region)
Definition: Structs.h:264
Data structure for the representation of a 2D straight line.
Definition: Structs.h:179
float radius_x
The radius in horizontal direction of the ellipse (horizontal refers to when angle = 0)...
Definition: Structs.h:147
Vec2d p2
Definition: Structs.h:74
Vec2d center
The center of the circle.
Definition: Structs.h:123
int nSeedOffset
Definition: Structs.h:329
float c
The negative scalar product of normalVector and point.
Definition: Structs.h:252
float ratio
Definition: Structs.h:338
Data structure for the representation of a 2D vector.
Definition: Math2d.h:82
void SetVec(Vec2d &vec, float x, float y)
Definition: Math2d.cpp:68
int max_x
Definition: Structs.h:68
Vec3d p1
Definition: Structs.h:79
int max_y
Definition: Structs.h:336
Vec2d directionVector
The normalized direction vector of the straight line.
Definition: Structs.h:242
int max_y
Definition: Structs.h:68
Vec2d point
An aribtrary point belonging to the straight line.
Definition: Structs.h:237


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Mon Dec 2 2019 03:47:28