HGlobals.h
Go to the documentation of this file.
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
13 #ifndef _H_GLOBALS_H
14 #define _H_GLOBALS_H
15 
16 #ifdef H_PACK_8
17 #pragma pack(push)
18 #pragma pack(8)
19 #endif
20 
25 {
26  HIO_OK = 1,
28  HIO_Fail = 3,
34 };
35 
36 #define HFileInputResult HFileIOResult
37 #define InputOK HIO_OK
38 #define InputVersionMismatch HIO_VersionMismatch
39 #define InputFail HIO_Fail
40 #define InputNotHandled HIO_NotHandled
41 #define InputBadFileName HIO_BadFileName
42 #define InputBadOptions HIO_BadOptions
43 #define InputBadLicense HIO_BadLicense
44 #define InputLibraryNotFound HIO_LibraryNotFound
45 
46 
47 #define HFileOutputResult HFileIOResult
48 #define OutputOK HIO_OK
49 #define OutputVersionMismatch HIO_VersionMismatch
50 #define OutputFail HIO_Fail
51 #define OutputNotHandled HIO_NotHandled
52 #define OutputBadFileName HIO_BadFileName
53 #define OutputBadOptions HIO_BadOptions
54 #define OutputBadLicense HIO_BadLicense
55 #define OutputLibraryNotFound HIO_LibraryNotFound
56 
60 #define LAST_HFileInputResult InputBadOptions
61 
64 #define LAST_HFileOutputResult OutputBadOptions
65 
70 enum HSignal
71 {
81 };
82 
86 #define LAST_HSignal HSignalClash
87 
88 
93 {
97 };
98 
103 {
108 };
109 
113 #define LAST_HShadowMode HShadowHard
114 
116 
121 class MVO_API HPoint
122 {
123 public:
124  float x;
125  float y;
126  float z;
127 
129  HPoint() : x(0), y(0), z(0) {};
130 
132  HPoint(float X, float Y, float Z=0.0f) : x(X), y(Y), z(Z) {};
133 
135  HPoint(HPoint const * p) : x(p->x), y(p->y), z(p->z) {};
136 
138  HPoint(HPoint const & p) : x(p.x), y(p.y), z(p.z) {};
139 
141  void Set(float X, float Y, float Z=0.0f) { x=X; y=Y; z=Z; };
142 
144  void Set(HPoint *p) { x=p->x; y=p->y; z=p->z; };
145 
147  void Set(HPoint const *p) { x=p->x; y=p->y; z=p->z; };
148 
150  void Set(HPoint &p) { x=p.x; y=p.y; z=p.z; };
151 
153  void Set(const HPoint &p) { x=p.x; y=p.y; z=p.z; };
154 
160  void Add(float X, float Y, float Z=0.0){ x+=X; y+=Y; z+=Z; };
161 
162  HPoint const operator -(const HPoint &p2) const
163  {
164  return HPoint(x-p2.x, y-p2.y, z-p2.z);
165  }
166 
167  HPoint const operator +(const HPoint &p2) const
168  {
169  return HPoint(x+p2.x, y+p2.y, z+p2.z);
170  }
171 
172  HPoint const operator *(float const rhs) const
173  {
174  return HPoint(x*rhs, y*rhs, z*rhs);
175  }
176 
177  HPoint const operator /(float const rhs) const
178  {
179  return HPoint(x/rhs, y/rhs, z/rhs);
180  }
181 
182  HPoint const & operator += (HPoint const & rhs)
183  {
184  x += rhs.x;
185  y += rhs.y;
186  z += rhs.z;
187  return *this;
188  }
189 
190  HPoint const & operator -= (HPoint const & rhs)
191  {
192  x -= rhs.x;
193  y -= rhs.y;
194  z -= rhs.z;
195  return *this;
196  }
197 
198  HPoint const & operator *= (float const rhs)
199  {
200  x *= rhs;
201  y *= rhs;
202  z *= rhs;
203  return *this;
204  }
205 
206  HPoint const & operator /= (float const rhs)
207  {
208  x /= rhs;
209  y /= rhs;
210  z /= rhs;
211  return *this;
212  }
213 
214  bool operator ==(HPoint const & rhs) const
215  {
216  return Equal(&rhs);
217  }
218 
219  bool operator !=(HPoint const & rhs) const
220  {
221  return !Equal(&rhs);
222  }
223 
224  HPoint &operator=(const HPoint &) = default;
225 
226 
228 #define HPOINT_EPSILON (1e-5f)
229 
230 
232  bool Equal(HPoint const *p, float epsi = HPOINT_EPSILON) const {
233  return (x - p->x < epsi) && (x - p->x > -epsi)
234  && (y - p->y < epsi) && (y - p->y > -epsi)
235  && (z - p->z < epsi) && (z - p->z > -epsi);
236  };
237 
239  bool Equal(HPoint const &p, float epsi = HPOINT_EPSILON) const {
240  return Equal(&p, epsi);
241  };
242 };
243 
250 class MVO_API HPointKey : public HPoint
251 {
252 public:
254  HPointKey() : HPoint(0, 0, 0) {};
255 
257  HPointKey(float X, float Y, float Z=0.0f) : HPoint(X, Y, Z) {};
258 
260  HPointKey(HPoint const * p) : HPoint(p->x, p->y, p->z) {};
261 
263  HPointKey(HPoint const & p) : HPoint(p.x, p.y, p.z) {};
264 
265  /* Define comparison operators so points can be used as keys in container classes. */
266  bool operator < (HPointKey const & rhs) const
267  {
268  if(x < rhs.x)
269  return true;
270  else if(x == rhs.x){
271  if(y < rhs.y)
272  return true;
273  else if(y == rhs.y){
274  if(z < rhs.z)
275  return true;
276  }
277  }
278  return false;
279  }
280 
281  bool operator > (HPointKey const & rhs) const
282  {
283  return !(*this < rhs);
284  }
285 
286  bool operator <= (HPointKey const & rhs) const
287  {
288  if( (*this) < rhs ){
289  return true;
290  }
291  else if( (*this) == rhs ){
292  return true;
293  }
294  return false;
295  }
296 
297  bool operator >= (HPointKey const & rhs) const
298  {
299  if( (*this) > rhs ){
300  return true;
301  }
302  else if( (*this) == rhs ){
303  return true;
304  }
305  return false;
306  }
307 };
308 
309 
312 class MVO_API HIntRectangle
313 {
314 public:
315  int left;
316  int right;
317  int bottom;
318  int top;
319 };
320 
321 
323 
328 typedef class HPoint HVector;
329 
330 
332 
335 class MVO_API HPlane
336 {
337 private:
338  float m_a;
339  float m_b;
340  float m_c;
341  float m_d;
342 
343 public:
344  HPlane(float const A = 0, float const B = 1, float const C = 0, float const D = 0) :
345  m_a(A), m_b(B), m_c(C), m_d(D){
346  };
347 
348  HPlane(HVector const & normal, float const D) :
349  m_a(normal.x), m_b(normal.y), m_c(normal.z), m_d(D){
350  };
351 
352  HPlane(HPlane const & p) :
353  m_a(p.a()), m_b(p.b()), m_c(p.c()), m_d(p.d()){
354  };
355 
357  inline void Set(float A, float B, float C, float D) { a(A); b(B); c(C); d(D); }
358 
362  inline double ClassifyPoint(HPoint const & p) const { return a() * p.x + b() * p.y + c() * p.z + d(); };
363 
367  inline void CalculateNormal(HPoint &normal) const
368  {
369  normal.Set(a(), b(), c());
370  HC_Compute_Normalized_Vector(&normal, &normal);
371  };
372 
374  bool Equal(HPlane const *p, float epsi1 = HPOINT_EPSILON, float epsi2 = HPOINT_EPSILON) const {
375  return (m_a - p->m_a < epsi1) && (m_a - p->m_a > -epsi1)
376  && (m_b - p->m_b < epsi1) && (m_b - p->m_b > -epsi1)
377  && (m_c - p->m_c < epsi1) && (m_c - p->m_c > -epsi1)
378  && (m_d - p->m_d < epsi2) && (m_d - p->m_d > -epsi2);
379  };
380 
381 
382  inline float a() const {return m_a;};
383  inline float b() const {return m_b;};
384  inline float c() const {return m_c;};
385  inline float d() const {return m_d;};
386 
387  inline void a(float A) {m_a = A;};
388  inline void b(float B) {m_b = B;};
389  inline void c(float C) {m_c = C;};
390  inline void d(float D) {m_d = D;};
391 };
392 
394 
397 class MVO_API HPlaneKey : public HPlane
398 {
399 public:
400  HPlaneKey(float const A = 0, float const B = 1, float const C = 0, float const D = 0) :
401  HPlane(A, B, C, D) {
402  };
403 
404  HPlaneKey(HVector const & normal, float const D) : HPlane(normal, D) {
405  };
406 
407  HPlaneKey(HPlane const & p) : HPlane(p) {
408  };
409 
410  bool operator < (HPlane const & rhs) const {
411  HVector n;
412 
413  CalculateNormal(n);
414  HPlane p1(n, d());
415 
416  rhs.CalculateNormal(n);
417  HPlane p2(n, rhs.d());
418 
419  if(p1.a() < p2.a())
420  return true;
421  else if(p1.a() == p2.a()){
422  if(p1.b() < p2.b())
423  return true;
424  else if(p1.b() == p2.b()){
425  if(p1.c() < p2.c())
426  return true;
427  else if(p1.c() == p2.c()){
428  if(p1.d() < p2.d())
429  return true;
430  }
431  }
432  }
433  return false;
434  };
435 
436  bool operator == (HPlane const & rhs) const {
437  HVector n;
438 
439  CalculateNormal(n);
440  HPlane p1(n, d());
441 
442  rhs.CalculateNormal(n);
443  HPlane p2(n, rhs.d());
444 
445  if( p1.a() == p2.a() &&
446  p1.b() == p2.b() &&
447  p1.c() == p2.c() &&
448  p1.d() == p2.d())
449  return true;
450 
451  return false;
452  };
453 
454  bool operator >= (HPlane const & rhs) const {
455  return !(*this < rhs);
456  };
457 
458  bool operator > (HPlane const & rhs) const {
459  return !(*this < rhs) && !(*this == rhs);
460  };
461 
462  bool operator <= (HPlane const & rhs) const {
463  return *this < rhs || *this == rhs;
464  };
465 
466  bool operator != (HPlane const & rhs) const {
467  return !(*this == rhs);
468  };
469 };
470 
471 
473 class MVO_API HPixelRGB
474 {
475 private:
476  unsigned char m_r;
477  unsigned char m_g;
478  unsigned char m_b;
479 
480 public:
481  HPixelRGB(unsigned char R = 0,unsigned char G = 0, unsigned char B = 0) : m_r(R), m_g(G), m_b(B) {
482  };
483 
484  HPixelRGB(HPixelRGB const & p) : m_r(p.r()), m_g(p.g()), m_b(p.b()) {
485  };
486 
487  inline unsigned char r() const {return m_r;};
488  inline unsigned char g() const {return m_g;};
489  inline unsigned char b() const {return m_b;};
490 
491  inline void r(unsigned char const R) {m_r = R;};
492  inline void g(unsigned char const G) {m_g = G;};
493  inline void b(unsigned char const B) {m_b = B;};
494 
496  inline void Set(unsigned char R, unsigned char G, unsigned char B){
497  r(R);
498  g(G);
499  b(B);
500  };
501 
503  inline void Setf(float R, float G, float B){
504  r((unsigned char)(R*255.99f));
505  g((unsigned char)(G*255.99f));
506  b((unsigned char)(B*255.99f));
507  };
508 };
509 
511 class MVO_API HPixelRGBA : public HPixelRGB
512 {
513 private:
514  unsigned char m_a;
515 
516 public:
517  HPixelRGBA(
518  unsigned char const R = 0,
519  unsigned char const G = 0,
520  unsigned char const B = 0,
521  unsigned char const A = 0)
522  :HPixelRGB(R, G, B), m_a(A){
523  };
524 
525  HPixelRGBA(HPixelRGBA const & p):HPixelRGB(p.r(), p.g(), p.b()),m_a(p.a()){
526  };
528  inline void Set(unsigned char R, unsigned char G, unsigned char B, unsigned char A=0){
529  HPixelRGB::Set(R, G, B);
530  a(A);
531  };
532 
534  inline void Setf(float R, float G, float B, float A=0.0f){
535  HPixelRGB::Setf(R, G, B);
536  a((unsigned char)(A*255.99f));
537  };
538 
539  inline unsigned char a() const {return m_a;};
540  inline void a(unsigned char const A) {m_a = A;};
541 };
542 
554 };
564 {
565  NoEdges = 0,
566  AllEdges,
567  PerimeterEdges
568 };
569 
570 enum HRegionFaceHighlightMode
571 {
572  FacesUnmodified = 0,
573  FacesForcedOn,
574  FacesForcedOff
575 };
580 {
584 };
585 
586 
587 
588 #ifdef H_PACK_8
589 #pragma pack(pop)
590 #endif
591 
592 #endif
593 
594 
595 
596 
597 
598 
599 
self-explantory
Definition: HGlobals.h:79
self-explanatory
Definition: HGlobals.h:33
The HPlaneKey class is the data type of a plane that can be used as a key in STL containers.
Definition: HGlobals.h:397
The HPixelRGB class is the data type of a rgb pixel.
Definition: HGlobals.h:473
bool Equal(HPoint const &p, float epsi=HPOINT_EPSILON) const
Definition: HGlobals.h:239
void Setf(float R, float G, float B, float A=0.0f)
Definition: HGlobals.h:534
color the selected item and make the rest of the model transparent.
Definition: HGlobals.h:553
HPoint(HPoint const *p)
Definition: HGlobals.h:135
self-explanatory
Definition: HGlobals.h:31
float z
The z-coordinate of a 3-dimensional point.
Definition: HGlobals.h:126
void CalculateNormal(HPoint &normal) const
Definition: HGlobals.h:367
Faces will be visible for cut geometry.
Definition: HGlobals.h:105
#define HPOINT_EPSILON
HPOINT_EPSILON.
Definition: HGlobals.h:228
void Set(HPoint *p)
Definition: HGlobals.h:144
a paint (screen update) has occurred; signal_data is pointer to HRectangle containing window size ...
Definition: HGlobals.h:77
self-explanatory
Definition: HGlobals.h:27
objects have clashed; signal_data is pointer to StencilProbe object that detected a clash; StencilPro...
Definition: HGlobals.h:78
HPointKey(HPoint const *p)
Definition: HGlobals.h:260
void Set(HPoint &p)
Definition: HGlobals.h:150
void Set(HPoint const *p)
Definition: HGlobals.h:147
HRefSelType
Definition: HGlobals.h:579
HPointKey(float X, float Y, float Z=0.0f)
Definition: HGlobals.h:257
The HPixelRGBA class is the data type of a rgba pixel.
Definition: HGlobals.h:511
No cut geometry will be visible.
Definition: HGlobals.h:104
float x
The x-coordinate of a 3-dimensional point.
Definition: HGlobals.h:124
HSelectionHighlightMode
Definition: HGlobals.h:549
Definition: HGlobals.h:312
self-explantory
Definition: HGlobals.h:74
self-explantory
Definition: HGlobals.h:75
self-explanatory
Definition: HGlobals.h:28
soft shadow
Definition: HGlobals.h:95
class HPoint HVector
The HVector class is the data type of a three-dimensional vector.
Definition: HGlobals.h:328
hard shadow
Definition: HGlobals.h:96
HPointKey(HPoint const &p)
Definition: HGlobals.h:263
HRegionEdgeHighlightMode
Definition: HGlobals.h:563
void Set(float A, float B, float C, float D)
Definition: HGlobals.h:357
use default conditional highlighting
Definition: HGlobals.h:550
bool Equal(HPoint const *p, float epsi=HPOINT_EPSILON) const
Definition: HGlobals.h:232
void Setf(float R, float G, float B)
Definition: HGlobals.h:503
do not use quick moves for reference selection
Definition: HGlobals.h:583
HCutGeometryVisibility
Definition: HGlobals.h:102
void Set(unsigned char R, unsigned char G, unsigned char B)
Definition: HGlobals.h:496
self-explantory
Definition: HGlobals.h:73
void Set(unsigned char R, unsigned char G, unsigned char B, unsigned char A=0)
Definition: HGlobals.h:528
no shadow
Definition: HGlobals.h:94
self-explanatory
Definition: HGlobals.h:29
use quick move reference highlighting
Definition: HGlobals.h:551
HPoint()
Definition: HGlobals.h:129
HPointKey()
Definition: HGlobals.h:254
float y
The y-coordinate of a 3-dimensional point.
Definition: HGlobals.h:125
self-explanatory
Definition: HGlobals.h:30
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:121
Edges will be visible for cut geometry.
Definition: HGlobals.h:106
int right
The right position.
Definition: HGlobals.h:316
HPoint(HPoint const &p)
Definition: HGlobals.h:138
self-explantory
Definition: HGlobals.h:80
double ClassifyPoint(HPoint const &p) const
Definition: HGlobals.h:362
HPoint(float X, float Y, float Z=0.0f)
Definition: HGlobals.h:132
int left
The left position.
Definition: HGlobals.h:315
do nothing to the selected item, but make the rest of the model transparent.
Definition: HGlobals.h:552
self-explantory
Definition: HGlobals.h:76
Definition: HGlobals.h:250
bool Equal(HPlane const *p, float epsi1=HPOINT_EPSILON, float epsi2=HPOINT_EPSILON) const
Definition: HGlobals.h:374
self-explanatory
Definition: HGlobals.h:32
HShadowMode
Definition: HGlobals.h:92
bool HC_Compute_Normalized_Vector(Vector const *vector, Vector *out_vector)
use whatever the current quick moves preference is
Definition: HGlobals.h:582
void Add(float X, float Y, float Z=0.0)
Definition: HGlobals.h:160
int bottom
The bottom position.
Definition: HGlobals.h:317
use spriting for reference selection
Definition: HGlobals.h:581
The HPlane class is the data type of a plane.
Definition: HGlobals.h:335
void Set(const HPoint &p)
Definition: HGlobals.h:153
self-explantory
Definition: HGlobals.h:72
void Set(float X, float Y, float Z=0.0f)
Definition: HGlobals.h:141
HSignal
Definition: HGlobals.h:70
self-explanatory
Definition: HGlobals.h:26
int top
The top position.
Definition: HGlobals.h:318
Both Faces and Edges will be visible.
Definition: HGlobals.h:107
HFileIOResult
Definition: HGlobals.h:24