HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimPlane.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: Plane primitive (infinite half-space).
9  */
10 
11 #ifndef __GEO_PrimPlane_H__
12 #define __GEO_PrimPlane_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 
21 {
22 protected:
23  /// NOTE: The constructor should only be called from subclass
24  /// constructors.
26  : GEO_Quadric(d, offset)
27  {}
28 
29  /// NOTE: The destructor should only be called from subclass
30  /// destructors.
31  ~GEO_PrimPlane() override {}
32 
33 public:
35  UT_Vector3 &nml, float u,
36  float v = 0, float w = 0) const override;
37 
38  bool getBBox(UT_BoundingBox *bbox) const override;
39  void addToBSphere(UT_BoundingSphere *bsphere) const override;
40  UT_Vector3D computeNormalD() const override;
41  UT_Vector3 computeNormal() const override;
42 
43  fpreal calcVolume(const UT_Vector3 &refpt) const override;
44  fpreal calcArea() const override;
45  fpreal calcPerimeter() const override;
46 
47  const GA_PrimitiveJSON *getJSON() const override;
48 
49  /// Builds a plane primitive with either the specified point offset, or a
50  /// new point if the provided offset is invalid.
52  GA_Detail &detail, GA_Offset existing_ptoff = GA_INVALID_OFFSET)
53  {
54  return UTverify_cast<GEO_PrimPlane *>(
55  GEO_Quadric::build(detail, GA_PRIMPLANE, existing_ptoff));
56  }
57 
59  GA_Detail &detail, GA_Size nplanes, bool append_points = true)
60  {
62  detail, GA_PRIMPLANE, nplanes, append_points);
63  }
64 
65 protected:
67  { return GEO_Quadric::buildFamilyMask(); }
68 
69  /// All subclasses should call this method to register the plane
70  /// intrinsics.
71  /// @see GA_AttributeIntrinsic
74  { return GEO_Quadric::registerIntrinsics(defn); }
75 
76  // Evaluate the position or the derivative at domain point (u,v). For
77  // planes, u and v are treated as unbounded coordinates in the local plane.
79  GA_Offset result_vtx,
80  GA_AttributeRefMap &hlist,
81  fpreal u, fpreal v,
82  unsigned du, unsigned dv) const override;
83  int evaluatePointV4(
84  UT_Vector4 &pos, float u, float v = 0,
85  unsigned du = 0, unsigned dv = 0) const override;
86 
87 private:
88  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimPlane &d)
89  {
90  d.saveH9(os, 0,
93  return os;
94  }
95 };
96 #endif
fpreal calcPerimeter() const override
const GLdouble * v
Definition: glcorearb.h:837
fpreal calcVolume(const UT_Vector3 &) const override
GEO_PrimPlane(GEO_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
Definition: GEO_PrimPlane.h:25
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
Definition: GEO_PrimPlane.h:73
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimPlane &d)
Definition: GEO_PrimPlane.h:88
UT_Vector3D computeNormalD() const override
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:242
fpreal calcArea() const override
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:243
GA_PrimitiveFamilyMask
#define GA_INVALID_OFFSET
Definition: GA_Types.h:694
GA_Size GA_Offset
Definition: GA_Types.h:653
GLintptr offset
Definition: glcorearb.h:665
static GA_Offset buildBlock(GA_Detail &detail, GA_PrimitiveTypeId type, GA_Size nprims, bool append_points=true)
virtual const GA_PrimitiveJSON * getJSON() const =0
Provide a JSON interface to a primitive.
#define GEO_API
Definition: GEO_API.h:14
A handle to simplify manipulation of multiple attributes.
~GEO_PrimPlane() override
Definition: GEO_PrimPlane.h:31
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
static GEO_PrimPlane * build(GA_Detail &detail, GA_Offset existing_ptoff=GA_INVALID_OFFSET)
Definition: GEO_PrimPlane.h:51
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:283
static GA_PrimitiveFamilyMask buildFamilyMask()
Return the family mask for all quadric sub-classes.
Definition: GEO_Quadric.h:220
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:105
static GA_Offset buildBlock(GA_Detail &detail, GA_Size nplanes, bool append_points=true)
Definition: GEO_PrimPlane.h:58
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
Definition of a geometric primitive.
bool getBBox(UT_BoundingBox *bbox) const override=0
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)
UT_Vector3 computeNormal() const override
Return a normal vector for the primitive.
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_PrimPlane.h:66