HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimTube.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: Geometry Library (C++)
7  *
8  * COMMENTS:
9  * This is a cylinder. There are two ways of storing a cylinder/tube:
10  * a) By setting two point references for the base and top
11  * of the cylinder. In this method, the height of the
12  * cylinder is locked. As well, the axes are fixed.
13  * This is the least preferred method since the X and Y
14  * axes are undefined (too many degrees of freedom).
15  * b) The preferred way is to specify a single point. The tube
16  * will extend in the Z axis according to the height
17  * specified. The tube may then be rotated or whatever
18  * and the X and Y axes will always be well defined.
19  *
20  */
21 
22 #ifndef __GEO_PrimTube_H__
23 #define __GEO_PrimTube_H__
24 
25 #include "GEO_API.h"
26 #include "GEO_Quadric.h"
27 #include "GEO_PrimType.h"
28 #include "GEO_Vertex.h"
29 
30 #define GEO_TUBE_XSECT_BOT_XP 0
31 #define GEO_TUBE_XSECT_BOT_XN 1
32 #define GEO_TUBE_XSECT_BOT_ZP 2
33 #define GEO_TUBE_XSECT_BOT_ZN 3
34 #define GEO_TUBE_XSECT_MID_XP 4
35 #define GEO_TUBE_XSECT_MID_XN 5
36 #define GEO_TUBE_XSECT_MID_ZP 6
37 #define GEO_TUBE_XSECT_MID_ZN 7
38 #define GEO_TUBE_XSECT_TOP_XP 8
39 #define GEO_TUBE_XSECT_TOP_XN 9
40 #define GEO_TUBE_XSECT_TOP_ZP 10
41 #define GEO_TUBE_XSECT_TOP_ZN 11
42 #define GEO_TUBE_XSECT_BOT_XN2 12
43 #define GEO_TUBE_XSECT_TOP_XN2 13
44 #define GEO_TUBE_XSECT_BOT_XP2 14
45 #define GEO_TUBE_XSECT_TOP_XP2 15
46 #define GEO_TUBE_XSECT_BOT_ZN2 16
47 #define GEO_TUBE_XSECT_TOP_ZN2 17
48 #define GEO_TUBE_XSECT_BOT_ZP2 18
49 #define GEO_TUBE_XSECT_TOP_ZP2 19
50 #define GEO_TUBE_XSECT_BOT_CTR 20
51 #define GEO_TUBE_XSECT_TOP_CTR 21
52 
53 #define GEO_TUBE_GUIDEEDGE_BX 0
54 #define GEO_TUBE_GUIDEEDGE_BZ 1
55 #define GEO_TUBE_GUIDEEDGE_MX 2
56 #define GEO_TUBE_GUIDEEDGE_MZ 3
57 #define GEO_TUBE_GUIDEEDGE_TX 4
58 #define GEO_TUBE_GUIDEEDGE_TZ 5
59 #define GEO_TUBE_GUIDEEDGE_XN 6
60 #define GEO_TUBE_GUIDEEDGE_XP 7
61 #define GEO_TUBE_GUIDEEDGE_ZN 8
62 #define GEO_TUBE_GUIDEEDGE_ZP 9
63 #define GEO_TUBE_GUIDEEDGE_Z 10
64 
66 {
67 public:
69  {
70  endcaps = 0;
71  }
73  : endcaps(s.endcaps)
74  {
75  }
76  unsigned endcaps:1; // Tube has end caps
77 };
78 
80 {
81 protected:
82  /// NOTE: The constructor should only be called from subclass
83  /// constructors.
85 
86  /// NOTE: The destructor should only be called from subclass
87  /// destructors.
88  virtual ~GEO_PrimTube() {}
89 
90 public:
91  virtual int evaluateNormalVector(UT_Vector3 &nml, float u,
92  float v = 0, float w = 0) const;
93  virtual int getBBox(UT_BoundingBox *bbox) const;
94  virtual void addToBSphere(UT_BoundingSphere *bsphere) const;
95  // virtual UT_Vector3 baryCenter() const;
96  virtual GEO_Primitive *copy(int preserve_shared_pts = 0) const;
97  virtual void copyPrimitive(const GEO_Primitive *src);
98 
99  virtual void copyUnwiredForMerge(const GA_Primitive *src,
100  const GA_MergeMap &map);
101 
102  virtual bool hasGuideEdge(int edgeid, UT_Vector3 &a,
103  UT_Vector3 &b) const;
104  virtual bool hasXsectPoint(int pointid, UT_Vector3 &p) const;
105 
106 //
107 // End cap handling for tube primitive
108  unsigned endcaps(void) const { return flags.endcaps; }
109  void setEndCaps(int onOff) { flags.endcaps = onOff; }
110  float getTaper(void) const { return myTaper; }
111  void setTaper(float t) { myTaper = t; }
112 
113 //
114 // Tube Capture Region handling
115 //
116 
117 // computes weight of point in this capture region tube. If the point
118 // is outside the region, the weight is zero. Otherwise the weight is
119 // .0 at the edge of the region, 1.0 along the center bone line of the
120 // region.
121 // pos must be in tube's SOP space, i.e. you've multiplied by the
122 // inverse of getTransform4()
123  float getCaptureRegionWeight( const UT_Vector3 &pos,
124  const GA_ROAttributeRef &tubeCaptAtrOffset) const;
125  static float computeCaptureRegionWeight( const UT_Vector3 &pos,
126  float bcap, float tcap, float taperx,
127  float taperz, float min_weight,
128  float max_weight );
129 
130  virtual fpreal calcVolume(const UT_Vector3 &refpt) const;
131  virtual fpreal calcArea() const;
132  virtual fpreal calcPerimeter() const;
133 
134  virtual const GA_PrimitiveJSON *getJSON() const;
135 
136 protected:
138  { return GEO_Quadric::buildFamilyMask(); }
139 
141 
142  // Save and load the privates of this class.
143  virtual bool savePrivateH9(std::ostream &os, bool binary) const;
144  virtual bool loadPrivateH9(UT_IStream &is);
145 
146  // Evaluate the position or the derivative at domain point (u,v), where
147  // u and v MUST be in [0,1]. "v" and "dv" will be ignored when dealing
148  // with one-dimensional types such as circles and polygons. Return 0 if
149  // OK and -1 otherwise.
150  virtual bool evaluatePointRefMap( GA_Offset result_vtx,
151  GA_AttributeRefMap &hlist,
152  fpreal u, fpreal v, uint du, uint dv) const;
153  virtual int evaluatePointV4( UT_Vector4 &pos, float u, float v = 0,
154  unsigned du=0, unsigned dv=0) const;
155 
156 private:
158  // The taper is the radius of the bottom half of the default tube.
159  // The top half's radius is one. These radii are then modified by
160  // myXform.
161  float myTaper;
162 
163  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimTube &d)
164  {
165  d.saveH9(os, 0,
168  return os;
169  }
170 };
171 #endif
GEO_PrimTubeFlags(const GEO_PrimTubeFlags &s)
Definition: GEO_PrimTube.h:72
unsigned endcaps(void) const
Definition: GEO_PrimTube.h:108
const GLdouble * v
Definition: glcorearb.h:836
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
GLbitfield flags
Definition: glcorearb.h:1595
#define GA_NO_OVERRIDE
Definition: GA_Primitive.h:76
3D Vector class.
GA_PrimitiveFamilyMask
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
GA_Size GA_Offset
Definition: GA_Types.h:617
void setEndCaps(int onOff)
Definition: GEO_PrimTube.h:109
This class provides a way to manage a reference to an attribute permitting Read-Only access...
virtual fpreal calcArea() const
virtual const GA_PrimitiveJSON * getJSON() const =0
GLintptr offset
Definition: glcorearb.h:664
Provide a JSON interface to a primitive.
#define GEO_API
Definition: GEO_API.h:10
A handle to simplify manipulation of multiple attributes.
float getTaper(void) const
Definition: GEO_PrimTube.h:110
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
virtual fpreal calcPerimeter() const
unsigned int uint
Definition: SYS_Types.h:40
void setTaper(float t)
Definition: GEO_PrimTube.h:111
double fpreal
Definition: SYS_Types.h:270
virtual ~GEO_PrimTube()
Definition: GEO_PrimTube.h:88
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_PrimTube.h:137
virtual void copyUnwiredForMerge(const GA_Primitive *src, const GA_MergeMap &map)
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
virtual void copyPrimitive(const GEO_Primitive *src)
static GA_PrimitiveFamilyMask buildFamilyMask()
Return the family mask for all quadric sub-classes.
Definition: GEO_Quadric.h:276
virtual fpreal calcVolume(const UT_Vector3 &) const
virtual int evaluateNormalVector(UT_Vector3 &nml, float u, float v=0, float w=0) const
virtual void addToBSphere(UT_BoundingSphere *bsphere) const
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
#define const
Definition: zconf.h:214
virtual bool hasGuideEdge(int edgeid, UT_Vector3 &a, UT_Vector3 &b) const
GA_DECLARE_INTRINSICS(GA_NO_OVERRIDE)
virtual int getBBox(UT_BoundingBox *bbox) const =0
virtual bool hasXsectPoint(int pointid, UT_Vector3 &p) const
GLenum src
Definition: glcorearb.h:1792