HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~GEO_PrimSphere() override {}
43 
44 public:
46  UT_Vector3 &nml, float u,
47  float v = 0, float w = 0) const override;
48 
49  int getBBox(UT_BoundingBox *bbox) const override;
50  void addToBSphere(UT_BoundingSphere *bsphere) const override;
51 
52  bool hasGuideEdge(
53  int edgeid,
54  UT_Vector3 &a,
55  UT_Vector3 &b) const override;
56  bool hasXsectPoint(int pointid, UT_Vector3 &p) const override;
57 
58  fpreal calcVolume(const UT_Vector3 &refpt) const override;
59  fpreal calcArea() const override;
60  fpreal calcPerimeter() const override;
61 
62  const GA_PrimitiveJSON *getJSON() const override;
63 
64  /// Builds a sphere primitive of the specified type, with either the
65  /// specified point offset, or a new point if the provided offset
66  /// is invalid.
68  GA_Detail &detail, GA_Offset existing_ptoff = GA_INVALID_OFFSET)
69  {
70  return UTverify_cast<GEO_PrimSphere *>(
71  GEO_Quadric::build(detail, GA_PRIMSPHERE, existing_ptoff));
72  }
73 
75  GA_Detail &detail, GA_Size nspheres, bool append_points = true)
76  {
78  detail, GA_PRIMSPHERE, nspheres, append_points);
79  }
80 
81 protected:
83  { return GEO_Quadric::buildFamilyMask(); }
84 
85  /// All subclasses should call this method to register the sphere
86  /// intrinsics.
87  /// @see GA_AttributeIntrinsic
90  { return GEO_Quadric::registerIntrinsics(defn); }
91 
92  // Evaluate the position or the derivative at domain point (u,v), where
93  // u and v MUST be in [0,1]. "v" and "dv" will be ignored when dealing
94  // with one-dimensional types such as circles and polygons. Return 0 if
95  // OK and -1 otherwise.
97  GA_Offset result_vtx,
98  GA_AttributeRefMap &hlist,
99  fpreal u, fpreal v,
100  unsigned du, unsigned dv) const override;
101  int evaluatePointV4(
102  UT_Vector4 &pos, float u, float v = 0,
103  unsigned du=0, unsigned dv=0) const override;
104 
105 private:
106  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimSphere &d)
107  {
108  d.saveH9(os, 0,
111  return os;
112  }
113 };
114 #endif
fpreal calcPerimeter() const override
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
fpreal calcVolume(const UT_Vector3 &) const override
static GA_Offset buildBlock(GA_Detail &detail, GA_Size nspheres, bool append_points=true)
GEO_PrimSphere(GEO_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
const GLdouble * v
Definition: glew.h:1391
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:208
4D Vector class.
Definition: UT_Vector4.h:166
fpreal calcArea() const override
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:233
GA_PrimitiveFamilyMask
#define GA_INVALID_OFFSET
Definition: GA_Types.h:676
~GEO_PrimSphere() override
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
GA_Size GA_Offset
Definition: GA_Types.h:639
static GA_Offset buildBlock(GA_Detail &detail, GA_PrimitiveTypeId type, GA_Size nprims, bool append_points=true)
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
virtual const GA_PrimitiveJSON * getJSON() const =0
Provide a JSON interface to a primitive.
#define GEO_API
Definition: GEO_API.h:14
static GA_PrimitiveFamilyMask buildFamilyMask()
A handle to simplify manipulation of multiple attributes.
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
GLfloat GLfloat p
Definition: glew.h:16321
static GEO_PrimSphere * build(GA_Detail &detail, GA_Offset existing_ptoff=GA_INVALID_OFFSET)
int getBBox(UT_BoundingBox *bbox) const override=0
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const override
fpreal64 fpreal
Definition: SYS_Types.h:277
static GA_PrimitiveFamilyMask buildFamilyMask()
Return the family mask for all quadric sub-classes.
Definition: GEO_Quadric.h:219
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:95
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)
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 bool hasXsectPoint(int pointid, UT_Vector3 &p) const
GLintptr offset
Definition: glew.h:1682