HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GQ_Point.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Quad Edge Library (C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef _GQ_Point_h_
12 #define _GQ_Point_h_
13 
14 #include "GQ_API.h"
15 #include <GEO/GEO_Detail.h>
16 #include <GA/GA_Types.h>
17 #include <SYS/SYS_Math.h>
18 #include <UT/UT_NonCopyable.h>
19 #include <UT/UT_Vector3.h>
20 #include <UT/UT_SmallObject.h>
21 #include <SYS/SYS_Types.h>
22 
23 class GQ_Edge;
24 
25 class GQ_API GQ_Point : public UT_SmallObject<UT_NonCopyable>
26 {
27 public:
28  explicit GQ_Point(GEO_Detail *gdp, GA_Offset ptoff)
29  : myGdp(gdp)
30  , myPtOff(ptoff)
31  , mySpare(0)
32  , myEdge(0)
33  , myFlags(0)
34  {
35  }
36 
37  bool isValid() const { return GAisValid(myPtOff); }
38 
39  GEO_Detail *geoDetail() const { return myGdp; }
40 
41  GA_Offset ptOff() const { return myPtOff; }
42  GA_Index ptNum() const { return myGdp->pointIndex(myPtOff);}
43 
44  UT_Vector3 getPos3() const { return myGdp->getPos3(myPtOff); }
45  UT_Vector4 getPos4() const { return myGdp->getPos4(myPtOff); }
46 
47  void setPos3(const UT_Vector3 &pos)
48  {
49  myGdp->setPos3(myPtOff, pos);
50  }
51 
52  int aboveOrBelow(UT_Vector3 &normal, float distance) const
53  {
54  float dist = dot(getPos3(), normal) + distance;
55  if (SYSequalZero(dist)) return 0;
56  else return (dist > 0.0F) ? 1 : -1;
57  }
58  float distToPlane(UT_Vector3 &normal, float distance) const
59  {
60  return dot(getPos3(), normal) + distance;
61  }
62 
63  void setEdge(GQ_Edge *e) { myEdge = e; }
64  GQ_Edge *getEdge() const { return myEdge; }
65 
66  void setFlags(unsigned mask) { myFlags = mask; }
67  unsigned getFlags(unsigned mask=~0) const
68  { return myFlags & mask; }
69  void addFlags(unsigned mask) { myFlags |= mask; }
70  void clearFlags(unsigned mask=~0) { myFlags &= ~mask; }
71 
72 private:
73  GEO_Detail *myGdp;
74  GA_Offset myPtOff;
75 
76 public:
77  void *mySpare; // public for legacy reasons
78 
79 private:
80  GQ_Edge *myEdge; // an edge that share this point at org()
81  unsigned myFlags;
82 };
83 #endif
GA_API const UT_StringHolder dist
void setFlags(unsigned mask)
Definition: GQ_Point.h:66
#define GQ_API
Definition: GQ_API.h:10
void * mySpare
Definition: GQ_Point.h:77
GEO_Detail * geoDetail() const
Definition: GQ_Point.h:39
float distToPlane(UT_Vector3 &normal, float distance) const
Definition: GQ_Point.h:58
bool GAisValid(GA_Size v)
Definition: GA_Types.h:625
void addFlags(unsigned mask)
Definition: GQ_Point.h:69
void setEdge(GQ_Edge *e)
Definition: GQ_Point.h:63
GLint GLuint mask
Definition: glcorearb.h:123
void clearFlags(unsigned mask=~0)
Definition: GQ_Point.h:70
unsigned getFlags(unsigned mask=~0) const
Definition: GQ_Point.h:67
GA_Size GA_Offset
Definition: GA_Types.h:617
GQ_Edge * getEdge() const
Definition: GQ_Point.h:64
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:698
GQ_Point(GEO_Detail *gdp, GA_Offset ptoff)
Definition: GQ_Point.h:28
UT_Vector3 getPos3() const
Definition: GQ_Point.h:44
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
Definition: CE_Vector.h:218
void setPos3(const UT_Vector3 &pos)
Definition: GQ_Point.h:47
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
GA_Index ptNum() const
Definition: GQ_Point.h:42
GA_Offset ptOff() const
Definition: GQ_Point.h:41
bool isValid() const
Definition: GQ_Point.h:37
int aboveOrBelow(UT_Vector3 &normal, float distance) const
Definition: GQ_Point.h:52
UT_Vector4 getPos4() const
Definition: GQ_Point.h:45