HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEO_PrimSphere.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  */
10 
11 #ifndef __GEO_PrimSphere_H__
12 #define __GEO_PrimSphere_H__
13 
14 #include "GEO_API.h"
15 #include <UT/UT_Vector3.h>
16 #include "GEO_Quadric.h"
17 #include "GEO_PrimType.h"
18 #include "GEO_Vertex.h"
19 
20 #define GEO_SPHERE_XSECT_XP 0
21 #define GEO_SPHERE_XSECT_XN 1
22 #define GEO_SPHERE_XSECT_YP 2
23 #define GEO_SPHERE_XSECT_YN 3
24 #define GEO_SPHERE_XSECT_ZP 4
25 #define GEO_SPHERE_XSECT_ZN 5
26 
27 #define GEO_SPHERE_GUIDEEDGE_X 0
28 #define GEO_SPHERE_GUIDEEDGE_Y 1
29 #define GEO_SPHERE_GUIDEEDGE_Z 2
30 
32 {
33 protected:
34  /// NOTE: The constructor should only be called from subclass
35  /// constructors.
37  : GEO_Quadric(d, offset)
38  {}
39 
40  /// NOTE: The destructor should only be called from subclass
41  /// destructors.
42  virtual ~GEO_PrimSphere() {}
43 
44 public:
45  virtual int evaluateNormalVector(UT_Vector3 &nml, float u,
46  float v = 0, float w = 0) const;
47 
48  virtual int getBBox(UT_BoundingBox *bbox) const;
49  virtual void addToBSphere(UT_BoundingSphere *bsphere) const;
50 
51  virtual bool hasGuideEdge(int edgeid, UT_Vector3 &a,
52  UT_Vector3 &b) const;
53  virtual bool hasXsectPoint(int pointid, UT_Vector3 &p) const;
54 
55  virtual fpreal calcVolume(const UT_Vector3 &refpt) const;
56  virtual fpreal calcArea() const;
57  virtual fpreal calcPerimeter() const;
58 
59  virtual const GA_PrimitiveJSON *getJSON() const;
60 
61  /// Builds a sphere primitive of the specified type, with either the
62  /// specified point offset, or a new point if the provided offset
63  /// is invalid.
65  GA_Detail &detail, GA_Offset existing_ptoff = GA_INVALID_OFFSET)
66  {
67  return UTverify_cast<GEO_PrimSphere *>(
68  GEO_Quadric::build(detail, GA_PRIMSPHERE, existing_ptoff));
69  }
70 
72  GA_Detail &detail, GA_Size nspheres, bool append_points = true)
73  {
75  detail, GA_PRIMSPHERE, nspheres, append_points);
76  }
77 
78 protected:
80  { return GEO_Quadric::buildFamilyMask(); }
81 
82  /// All subclasses should call this method to register the sphere
83  /// intrinsics.
84  /// @see GA_AttributeIntrinsic
87  { return GEO_Quadric::registerIntrinsics(defn); }
88 
89  // Evaluate the position or the derivative at domain point (u,v), where
90  // u and v MUST be in [0,1]. "v" and "dv" will be ignored when dealing
91  // with one-dimensional types such as circles and polygons. Return 0 if
92  // OK and -1 otherwise.
93  virtual bool evaluatePointRefMap( GA_Offset result_vtx,
94  GA_AttributeRefMap &hlist,
95  fpreal u, fpreal v,
96  unsigned du, unsigned dv) const;
97  virtual int evaluatePointV4( UT_Vector4 &pos, float u, float v = 0,
98  unsigned du=0, unsigned dv=0) const;
99 
100 private:
101  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimSphere &d)
102  {
103  d.saveH9(os, 0,
106  return os;
107  }
108 };
109 #endif
const GLdouble * v
Definition: glcorearb.h:836
static GA_Offset buildBlock(GA_Detail &detail, GA_Size nspheres, bool append_points=true)
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
GEO_PrimSphere(GEO_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
3D Vector class.
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GA_PrimitiveFamilyMask
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
GA_Size GA_Offset
Definition: GA_Types.h:617
static GA_Offset buildBlock(GA_Detail &detail, GA_PrimitiveTypeId type, GA_Size nprims, bool append_points=true)
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
static GA_PrimitiveFamilyMask buildFamilyMask()
A handle to simplify manipulation of multiple attributes.
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:175
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
virtual fpreal calcPerimeter() const
double fpreal
Definition: SYS_Types.h:269
static GEO_PrimSphere * build(GA_Detail &detail, GA_Offset existing_ptoff=GA_INVALID_OFFSET)
virtual ~GEO_PrimSphere()
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
static GA_PrimitiveFamilyMask buildFamilyMask()
Return the family mask for all quadric sub-classes.
Definition: GEO_Quadric.h:274
virtual fpreal calcVolume(const UT_Vector3 &) const
virtual int evaluateNormalVector(UT_Vector3 &nml, float u, float v=0, float w=0) const
virtual bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0) const =0
virtual void addToBSphere(UT_BoundingSphere *bsphere) const
Container class for all geometry.
Definition: GA_Detail.h:96
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimSphere &d)
Definition of a geometric primitive.
virtual bool hasGuideEdge(int edgeid, UT_Vector3 &a, UT_Vector3 &b) const
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
virtual bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const
static GEO_Quadric * build(GA_Detail &detail, GA_PrimitiveTypeId type, GA_Offset existing_ptoff=GA_INVALID_OFFSET)
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
virtual int getBBox(UT_BoundingBox *bbox) const =0
virtual bool hasXsectPoint(int pointid, UT_Vector3 &p) const