S_Object.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef _S_OBJECT
4 # define _S_OBJECT
5 
6 # include <sch/Matrix/SCH_Types.h>
7 # include <sch/sch_api.h>
8 
9 namespace sch
10 {
11 
17 typedef struct _TimeStamp
18 {
19  unsigned long int value1, value2, value3, value4;
20 
21  template<class Archive>
22  void serialize(Archive & ar, const unsigned int /*version*/)
23  {
24  ar & value1 & value2 & value3 & value4;
25  }
26 
27  explicit _TimeStamp() : value1(0), value2(0), value3(0), value4(0) {}
28 
29  bool operator==(const _TimeStamp & t) const
30  {
31  return ((value1 == t.value1) && (value2 == t.value2));
32  }
33 
34  void operator++()
35  {
36  value1++;
37  if(!value1)
38  {
39  value2++;
40  if(!value2)
41  {
42  value3++;
43  if(!value3)
44  {
45  value4++;
46  }
47  }
48  }
49  }
50 
51  void operator--()
52  {
53  value1--;
54  if(value1 == (unsigned long int)(-1))
55  {
56  value2--;
57  if(value2 == (unsigned long int)(-1))
58  {
59  value3--;
60  if(value3 == (unsigned long int)(-1))
61  {
62  value4--;
63  }
64  }
65  }
66  }
68 
69 /*IMPORTANT !!!! DO NOT INHERIT FROM THIS CLASS, YOU MUST CHOOSE IF YOU NEED VECTOR NORMALIZATION OR NOT IN YOUR SUPPORT
70  * FUNCTION AND INHERIT FROM S_ObjectNormalized or S_ObjectNonNormalized*/
71 class S_Object
72 {
73 
74 public:
81  SCH_API virtual Point3 l_Support(const Vector3 & v, int & lastFeature) const = 0;
82 
86  SCH_API virtual S_Object * clone() const = 0;
87 
88 public:
89  SCH_API S_Object(void);
90  SCH_API virtual ~S_Object(void);
91 
97  SCH_API virtual Point3 support(const Vector3 & v) const = 0;
98 
105  SCH_API virtual Point3 support(const Vector3 & v, int & LastFeature) const = 0;
106 
107  /*
108  * \brief Constructs the Object from a file
109  */
110  SCH_API virtual void constructFromFile(const std::string & filename);
111 
112  /*
113  * \brief Sets the Orientation
114  */
115  SCH_API void setOrientation(const Matrix3x3 & Rotation);
116 
117  SCH_API void setOrientation(const Scalar & r00,
118  const Scalar & r01,
119  const Scalar & r02,
120  const Scalar & r10,
121  const Scalar & r11,
122  const Scalar & r12,
123  const Scalar & r20,
124  const Scalar & r21,
125  const Scalar & r22);
126 
127  SCH_API void setOrientation(const Quaternion quaternion);
128 
129  SCH_API void setOrientation(const Scalar & q0, const Scalar & q1, const Scalar & q2, const Scalar & q3);
130 
133  SCH_API void setOrientation(const Scalar & yaw, const Scalar & pitch, const Scalar & roll);
134 
135  SCH_API void setOrientation(const Scalar * const p);
136 
137  SCH_API void setOrientation(const Scalar & angle, const Vector3 & axe);
138 
142  SCH_API void setPosition(const Vector3 & v);
143 
144  SCH_API void setPosition(const Scalar & x, const Scalar & y, const Scalar & z);
145 
146  SCH_API void setPosition(const Scalar * const v);
147 
152  SCH_API void setTransformation(const Matrix4x4 & transformation);
153 
158  SCH_API void addRotation(const Matrix3x3 & Rotation);
159 
160  SCH_API void addRotation(const Scalar & r00,
161  const Scalar & r01,
162  const Scalar & r02,
163  const Scalar & r10,
164  const Scalar & r11,
165  const Scalar & r12,
166  const Scalar & r20,
167  const Scalar & r21,
168  const Scalar & r22);
169 
170  SCH_API void addRotation(const Quaternion quaternion);
171 
172  SCH_API void addRotation(const Scalar & q0, const Scalar & q1, const Scalar & q2, const Scalar & q3);
173 
174  SCH_API void addRotation(const Scalar & angle, const Vector3 & axe);
175 
178  SCH_API void addRotation(const Scalar & yaw, const Scalar & pitch, const Scalar & roll);
179 
180  SCH_API void addRotation(const Scalar * const p);
181 
187  SCH_API void addTranslation(const Vector3 & v);
188 
189  SCH_API void addTranslation(const Scalar * const v);
190 
191  SCH_API void addTranslation(const Scalar & x, const Scalar & y, const Scalar & z);
192 
199  SCH_API void addScale(const Scalar & x, const Scalar & y, const Scalar & z);
200 
205  SCH_API void addTransformation(const Matrix4x4 & transformation);
206 
211 
215  SCH_API const Vector3 & getPosition() const;
216 
220  SCH_API const Matrix3x3 & getOrientation() const;
221 
225  SCH_API void getTransformationMatrix(Scalar * S) const;
226 
227  int getSlices() const;
228  int getStacks() const;
229 
234  {
246  };
247 
251  SCH_API virtual S_ObjectType getType() const;
252 
256  const S_ObjectTimeStamp & checkStamp() const;
257 
258  template<class Archive>
259  void serialize(Archive & ar, const unsigned int /*version*/)
260  {
261  ar & stamp_;
262  ar & stacks_;
263  ar & slices_;
264  ar & mRot_;
265  ar & trans_;
266  }
267 
268 protected:
273 };
274 
275 # include <sch/S_Object/S_Object.hxx>
276 } // namespace sch
277 #endif
sch::S_Object::getType
virtual SCH_API S_ObjectType getType() const
must be overloaded to return the type
sch::S_Object::getPosition
const SCH_API Vector3 & getPosition() const
returns the position
Definition: S_Object.hxx:31
sch::S_Object::clone
virtual SCH_API S_Object * clone() const =0
Returns a copy of this S_Object.
sch
Definition: CD_Pair.h:11
sch::S_Object::support
virtual SCH_API Point3 support(const Vector3 &v) const =0
put it in objects coordinates, then calls l_support. DO NOT OVERLOAD IT UNLESS YOU KNOW WHAT YOU ARE ...
S_Object.hxx
sch::_TimeStamp::_TimeStamp
_TimeStamp()
Definition: S_Object.h:27
sch::S_Object::TSphere
@ TSphere
Definition: S_Object.h:238
sch::_TimeStamp::serialize
void serialize(Archive &ar, const unsigned int)
Definition: S_Object.h:22
sch::S_Object::S_ObjectType
S_ObjectType
type of a solid object. Don't use it to cast !
Definition: S_Object.h:233
SCH_API
#define SCH_API
Definition: sch_api.h:13
sch::S_Object::addScale
SCH_API void addScale(const Scalar &x, const Scalar &y, const Scalar &z)
composes the current transfornation with a scale
sch::S_Object::TCapsule
@ TCapsule
Definition: S_Object.h:243
sch::S_Object::trans_
Vector3 trans_
Definition: S_Object.h:272
sch::S_Object::addTransformation
SCH_API void addTransformation(const Matrix4x4 &transformation)
composes the current transfornation with transformation matrix one
sch::S_Object::~S_Object
virtual SCH_API ~S_Object(void)
SCH_Types.h
sch::S_Object::S_Object
SCH_API S_Object(void)
sch::S_Object::mRot_
Matrix3x3 mRot_
Definition: S_Object.h:271
sch::_TimeStamp::value1
unsigned long int value1
Definition: S_Object.h:19
sch::_TimeStamp::operator++
void operator++()
Definition: S_Object.h:34
sch::S_Object::TCone
@ TCone
Definition: S_Object.h:244
sch::S_Object::slices_
int slices_
Definition: S_Object.h:270
CD_Matrix::Matrix4x4T
Definition: SmallMatrix4x4T.h:15
sch::S_Object::getSlices
int getSlices() const
Definition: S_Object.hxx:36
sch::S_ObjectTimeStamp
struct sch::_TimeStamp S_ObjectTimeStamp
sch::S_Object::addRotation
SCH_API void addRotation(const Matrix3x3 &Rotation)
composes the current orientation with a Rotation
sch::S_Object::serialize
void serialize(Archive &ar, const unsigned int)
Definition: S_Object.h:259
sch::S_Object::setOrientation
SCH_API void setOrientation(const Matrix3x3 &Rotation)
sch::S_Object::resetTransformation
SCH_API void resetTransformation()
loads Identity
sch::S_Object::TSuperellipsoid
@ TSuperellipsoid
Definition: S_Object.h:240
sch::S_Object::l_Support
virtual SCH_API Point3 l_Support(const Vector3 &v, int &lastFeature) const =0
gives the support point for a given vector in local cordinates and a given last feature....
sch::S_Object::TSTP_BV
@ TSTP_BV
Definition: S_Object.h:237
sch::S_Object::TS_Object
@ TS_Object
Definition: S_Object.h:235
sch::S_Object::constructFromFile
virtual SCH_API void constructFromFile(const std::string &filename)
sch::S_Object::setPosition
SCH_API void setPosition(const Vector3 &v)
Sets the position.
sch_api.h
sch::_TimeStamp
Definition: S_Object.h:17
sch::_TimeStamp::value4
unsigned long int value4
Definition: S_Object.h:19
CD_Matrix::QuaternionT
Definition: QuaternionT.h:10
sch::S_Object::getTransformationMatrix
SCH_API void getTransformationMatrix(Scalar *S) const
puts the transfomation matrix in a sclar array
Definition: S_Object.hxx:6
sch::S_Object::checkStamp
const S_ObjectTimeStamp & checkStamp() const
returns the current time stamp
Definition: S_Object.hxx:1
sch::S_Object::TCylinder
@ TCylinder
Definition: S_Object.h:245
sch::S_Object::addTranslation
SCH_API void addTranslation(const Vector3 &v)
sch::S_Object::TBox
@ TBox
Definition: S_Object.h:239
sch::_TimeStamp::operator--
void operator--()
Definition: S_Object.h:51
sch::S_Object::getOrientation
const SCH_API Matrix3x3 & getOrientation() const
returns the orientation as a rotation matrix
Definition: S_Object.hxx:26
CD_Matrix::Vector3T< Scalar, false >
sch::S_Object::setTransformation
SCH_API void setTransformation(const Matrix4x4 &transformation)
Sets the transformation matrix.
sch::S_Object::TPolyhedron
@ TPolyhedron
Definition: S_Object.h:236
sch::_TimeStamp::value3
unsigned long int value3
Definition: S_Object.h:19
sch::S_Object::TSTP_BV_WithPolyhedron
@ TSTP_BV_WithPolyhedron
Definition: S_Object.h:241
sch::S_Object
Definition: S_Object.h:71
sch::Scalar
double Scalar
Definition: SCH_Types.h:23
CD_Matrix::Matrix3x3T< Scalar >
sch::S_Object::getStacks
int getStacks() const
Definition: S_Object.hxx:41
sch::_TimeStamp::value2
unsigned long int value2
Definition: S_Object.h:19
sch::S_Object::TPoint
@ TPoint
Definition: S_Object.h:242
sch::S_Object::stacks_
int stacks_
Definition: S_Object.h:270
sch::_TimeStamp::operator==
bool operator==(const _TimeStamp &t) const
Definition: S_Object.h:29
sch::S_Object::stamp_
S_ObjectTimeStamp stamp_
Definition: S_Object.h:269