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:
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  {
245  TCylinder
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
Definition: QuaternionT.h:11
Definition: S_Object.h:72
SCH_API void addScale(const Scalar &x, const Scalar &y, const Scalar &z)
composes the current transfornation with a scale
virtual SCH_API S_Object * clone() const =0
Returns a copy of this S_Object.
SCH_API void setOrientation(const Matrix3x3 &Rotation)
SCH_API void setOrientation(const Scalar &q0, const Scalar &q1, const Scalar &q2, const Scalar &q3)
SCH_API void setTransformation(const Matrix4x4 &transformation)
Sets the transformation matrix.
SCH_API void addRotation(const Scalar &yaw, const Scalar &pitch, const Scalar &roll)
virtual SCH_API Point3 support(const Vector3 &v, int &LastFeature) const =0
version of support with last feature optimization
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 ...
Vector3 trans_
Definition: S_Object.h:272
SCH_API void addRotation(const Matrix3x3 &Rotation)
composes the current orientation with a Rotation
int getSlices() const
Definition: S_Object.hxx:36
SCH_API void addTranslation(const Scalar &x, const Scalar &y, const Scalar &z)
SCH_API void getTransformationMatrix(Scalar *S) const
puts the transfomation matrix in a sclar array
Definition: S_Object.hxx:6
Matrix3x3 mRot_
Definition: S_Object.h:271
virtual SCH_API void constructFromFile(const std::string &filename)
SCH_API void addRotation(const Quaternion quaternion)
SCH_API void setPosition(const Vector3 &v)
Sets the position.
SCH_API void setPosition(const Scalar *const v)
SCH_API void setOrientation(const Scalar *const p)
SCH_API void addTransformation(const Matrix4x4 &transformation)
composes the current transfornation with transformation matrix one
SCH_API void setPosition(const Scalar &x, const Scalar &y, const Scalar &z)
SCH_API const Vector3 & getPosition() const
returns the position
Definition: S_Object.hxx:31
int slices_
Definition: S_Object.h:270
S_ObjectTimeStamp stamp_
Definition: S_Object.h:269
SCH_API const Matrix3x3 & getOrientation() const
returns the orientation as a rotation matrix
Definition: S_Object.hxx:26
SCH_API void addRotation(const Scalar &r00, const Scalar &r01, const Scalar &r02, const Scalar &r10, const Scalar &r11, const Scalar &r12, const Scalar &r20, const Scalar &r21, const Scalar &r22)
int stacks_
Definition: S_Object.h:270
SCH_API S_Object(void)
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_API void setOrientation(const Scalar &yaw, const Scalar &pitch, const Scalar &roll)
int getStacks() const
Definition: S_Object.hxx:41
virtual SCH_API ~S_Object(void)
SCH_API void addRotation(const Scalar *const p)
SCH_API void setOrientation(const Scalar &r00, const Scalar &r01, const Scalar &r02, const Scalar &r10, const Scalar &r11, const Scalar &r12, const Scalar &r20, const Scalar &r21, const Scalar &r22)
SCH_API void addTranslation(const Scalar *const v)
SCH_API void addTranslation(const Vector3 &v)
S_ObjectType
type of a solid object. Don't use it to cast !
Definition: S_Object.h:234
@ TSuperellipsoid
Definition: S_Object.h:240
@ TBox
Definition: S_Object.h:239
@ TCapsule
Definition: S_Object.h:243
@ TPolyhedron
Definition: S_Object.h:236
@ TPoint
Definition: S_Object.h:242
@ TS_Object
Definition: S_Object.h:235
@ TSTP_BV
Definition: S_Object.h:237
@ TCylinder
Definition: S_Object.h:245
@ TCone
Definition: S_Object.h:244
@ TSphere
Definition: S_Object.h:238
@ TSTP_BV_WithPolyhedron
Definition: S_Object.h:241
const S_ObjectTimeStamp & checkStamp() const
returns the current time stamp
Definition: S_Object.hxx:1
SCH_API void setOrientation(const Scalar &angle, const Vector3 &axe)
SCH_API void addRotation(const Scalar &angle, const Vector3 &axe)
SCH_API void addRotation(const Scalar &q0, const Scalar &q1, const Scalar &q2, const Scalar &q3)
SCH_API void setOrientation(const Quaternion quaternion)
void serialize(Archive &ar, const unsigned int)
Definition: S_Object.h:259
virtual SCH_API S_ObjectType getType() const
must be overloaded to return the type
SCH_API void resetTransformation()
loads Identity
Definition: CD_Pair.h:12
double Scalar
Definition: SCH_Types.h:23
struct sch::_TimeStamp S_ObjectTimeStamp
#define SCH_API
Definition: sch_api.h:13
Definition: SmallMatrix4x4T.h:16
Definition: S_Object.h:18
unsigned long int value3
Definition: S_Object.h:19
unsigned long int value4
Definition: S_Object.h:19
void operator--()
Definition: S_Object.h:51
void operator++()
Definition: S_Object.h:34
bool operator==(const _TimeStamp &t) const
Definition: S_Object.h:29
_TimeStamp()
Definition: S_Object.h:27
unsigned long int value2
Definition: S_Object.h:19
void serialize(Archive &ar, const unsigned int)
Definition: S_Object.h:22
unsigned long int value1
Definition: S_Object.h:19