ALBA
albaOBB.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaOBB
5 Authors: Marco Petrone
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaOBB_h
17#define __albaOBB_h
18#include "albaBase.h"
19#include "albaTimeStamped.h"
20
21#include "albaDefines.h"
22#include "albaMTime.h"
23#include "albaMatrix.h"
24
25//----------------------------------------------------------------------------
26// forward declarations
27//----------------------------------------------------------------------------
28
29
36class ALBA_EXPORT albaOBB : public albaBase, public albaTimeStamped
37{
38public:
40 albaOBB(double source[6]);
42
43 static albaOBB *New() {return new albaOBB;}
44
48 bool Equals(float bounds[6]) const;
49 bool Equals(double bounds[6]) const;
50 bool Equals(albaOBB &bounds) const;
51 bool Equals(albaOBB *bounds) {return Equals(*bounds);}
52
53
56 bool IsValid() const {return (m_Bounds[0]<=m_Bounds[1] && \
57 m_Bounds[2]<=m_Bounds[3] && \
58 m_Bounds[4]<=m_Bounds[5]); \
59 }
60
63 void Reset();
64
67 void DeepCopy(double bounds[6]);
68 void DeepCopy(float bounds[6]);
70 void DeepCopy(albaOBB &source) {DeepCopy(&source);}
71 void CopyTo(double target[6]) const;
72 void CopyTo(float target[6]) const;
73
77 void ApplyTransform() {ApplyTransform(m_Matrix,*this);}
78
83 void ApplyTransform(albaOBB &newbounds) {ApplyTransform(m_Matrix,newbounds);}
84
88 static void ApplyTransform(const albaMatrix &mat, albaOBB &newbounds);
89 void ApplyTransform(const albaMatrix &mat) {ApplyTransform(mat,*this);}
90
94 void MergeBounds(albaOBB &bounds);
95
98 bool IsInside(double point[3]) const;
99 bool IsInside(float point[3]) const;
100 bool IsInside(double x,double y,double z) const;
101
105 static void MergeBounds(double b1[6], double b2[6]);
106
108 void GetDimensions(float dims[3]) const;
110 void GetDimensions(double dims[3]) const;
111
113 void GetCenter(float center[3]) const;
115 void GetCenter(double center[3]) const;
116
118 void SetCenter(double center[3]);
119
121 void SetCenter(float center[3]);
122
124 void SetDimensions(double dims[3]);
125
127 void SetDimensions(float dims[3]);
128
130 double GetWidth() const;
131
133 double GetHeight() const;
134
136 double GetDepth() const;
137
139 void SetOrientation(double rx, double ry, double rz);
140
142 void GetOrientation(double rxyz[3]);
143
145 virtual void Print(std::ostream& os, const int tabs=0) const;
146
147 // member variables are left public to simplify access
148
150 double m_Bounds[6];
151};
152
153//-------------------------------------------------------------------------
154inline bool albaOBB::IsInside(double point[3]) const
155//-------------------------------------------------------------------------
156{
157 return IsInside(point[0],point[1],point[2]);
158}
159
160//-------------------------------------------------------------------------
161inline bool albaOBB::IsInside(float point[3]) const
162//-------------------------------------------------------------------------
163{
164 return IsInside(point[0],point[1],point[2]);
165}
166
167//-------------------------------------------------------------------------
168inline bool albaOBB::IsInside(double x,double y,double z) const
169//-------------------------------------------------------------------------
170{
171 return ((x>=m_Bounds[0])&&(x<=m_Bounds[1])&& \
172 (y>=m_Bounds[2])&&(y<=m_Bounds[3])&& \
173 (z>=m_Bounds[4])&&(z<=m_Bounds[5]));
174}
175
176#endif
177
albaBase - the pourpose of this class is just to groups utilities classes
Definition: albaBase.h:27
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:44
This class simply stores a Box boundary (i.e.
Definition: albaOBB.h:37
double GetDepth() const
return the Z dimension
double GetWidth() const
return the X dimension
void SetOrientation(double rx, double ry, double rz)
set orientation of the internal matrix
void DeepCopy(albaOBB *)
void GetOrientation(double rxyz[3])
extract orientation from internal matrix
void GetDimensions(double dims[3]) const
return dimensions of this box
void GetCenter(double center[3]) const
return center of the box
void Reset()
Reset this object bounds to an invalid value [0,-1,0,-1,0,-1].
static albaOBB * New()
Definition: albaOBB.h:43
void DeepCopy(double bounds[6])
Copy another bounds from another object.
void GetCenter(float center[3]) const
return center of the box
void ApplyTransform(const albaMatrix &mat)
Definition: albaOBB.h:89
static void MergeBounds(double b1[6], double b2[6])
This is a static function to merge two different space bounds.
void DeepCopy(albaOBB &source)
Definition: albaOBB.h:70
bool Equals(albaOBB &bounds) const
void SetDimensions(double dims[3])
set dimensions of the box preserving its center
bool Equals(double bounds[6]) const
static void ApplyTransform(const albaMatrix &mat, albaOBB &newbounds)
Apply the given transform to the internal bounds (do not concatenate to the internal Matrix).
virtual void Print(std::ostream &os, const int tabs=0) const
dump the bounding box
void GetDimensions(float dims[3]) const
return dimensions of this box
void DeepCopy(float bounds[6])
void ApplyTransform(albaOBB &newbounds)
Apply the internally stored transform to the bounding box, recompute the bounding box and stores new ...
Definition: albaOBB.h:83
albaOBB(double source[6])
bool IsValid() const
Return true if the BBox is valid.
Definition: albaOBB.h:56
void CopyTo(double target[6]) const
void MergeBounds(albaOBB &bounds)
Merge this objects's bounds with the given one.
void SetDimensions(float dims[3])
set dimensions of the box preserving its center
void SetCenter(float center[3])
translate the box to the new center
void ApplyTransform()
Apply the internally stored transform to the bounding box, recompute the internally stored bounding b...
Definition: albaOBB.h:77
albaMatrix m_Matrix
the pose matrix of the OBB
Definition: albaOBB.h:149
double GetHeight() const
return the Y dimension
bool Equals(float bounds[6]) const
Return 1 if the two bounds are equivalent.
void CopyTo(float target[6]) const
bool Equals(albaOBB *bounds)
Definition: albaOBB.h:51
void SetCenter(double center[3])
translate the box to the new center
bool IsInside(double point[3]) const
Return true if the point is inside the bounds.
Definition: albaOBB.h:154
class acting as an interface for timestamped objects This object simply defines few methods for manag...