HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimTriFan.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: GEO_PrimTriFan.h ( GEO Library, C++)
7  *
8  * COMMENTS: Implements a normal triangle fan.
9  */
10 
11 #ifndef __GEO_PrimTriFan__
12 #define __GEO_PrimTriFan__
13 
14 #include "GEO_API.h"
15 #include "GEO_TriMesh.h"
16 #include "GEO_PrimType.h"
17 
18 class GA_Detail;
19 
20 /// Triangle fan. All triangles share the first vertex
22 {
23 protected:
24  /// NOTE: The constructor should only be called from subclass
25  /// constructors.
27  : GEO_TriMesh(d, offset)
28  {}
29 
30  /// NOTE: The destructor should only be called from subclass
31  /// destructors.
32  ~GEO_PrimTriFan() override {}
33 
34 public:
35  /// @{
36  /// Interface from GEO_TriMesh
37  bool isDegenerate() const override;
38  UT_Vector3 computeNormal() const override;
39  UT_Vector3D computeNormalD() const override;
40  void reverse() override;
41 
42  fpreal calcVolume(const UT_Vector3 &refpt) const override;
43  fpreal calcArea() const override;
44  fpreal calcPerimeter() const override;
45  /// @}
46 
47  /// Get number of triangles in the fan
48  exint getTriangleCount() const { return getVertexCount()-2; }
49 
50  /// Get the vertices for a single triangle in the fan
51  void getTriangleVertices(exint tri, int &v0, int &v1, int &v2) const
52  {
53  v0 = 0;
54  v1 = tri + 1;
55  v2 = tri + 2;
56  }
57 
58  const GA_PrimitiveJSON *getJSON() const override;
59 
60 protected:
62  { return GEO_TriMesh::buildFamilyMask(); }
63 
64  template <typename T>
65  UT_Vector3T<T> internalComputeNormal() const;
66 
67  /// All subclasses should call this method to register the curve intrinsics.
68  /// @see GA_IntrinsicManager
71  { return GEO_TriMesh::registerIntrinsics(defn); }
72 
73  // We don't need to save anything other than what's in a face
74  bool savePrivateH9(std::ostream &,
75  bool binary) const override;
76  bool loadPrivateH9(UT_IStream &) override;
77 
78 private:
79  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimTriFan &d)
80  {
81  d.saveH9(os, 0,
84  return os;
85  }
86 };
87 
88 #endif
89 
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
Definition: GEO_TriMesh.h:193
fpreal calcPerimeter() const override
bool isDegenerate() const override
Is the primitive degenerate.
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
Definition: GA_Primitive.h:232
virtual UT_Vector3D computeNormalD() const =0
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
fpreal calcVolume(const UT_Vector3 &) const override
int64 exint
Definition: SYS_Types.h:125
void reverse() override=0
Reverse the order of vertices.
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
fpreal calcArea() const override
GA_PrimitiveFamilyMask
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
virtual bool loadPrivateH9(UT_IStream &is)=0
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GA_Size GA_Offset
Definition: GA_Types.h:646
GLintptr offset
Definition: glcorearb.h:665
Triangle fan. All triangles share the first vertex.
virtual bool savePrivateH9(std::ostream &os, bool binary) const =0
bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const override
~GEO_PrimTriFan() override
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
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()
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimTriFan &d)
GLfloat v0
Definition: glcorearb.h:816
exint getTriangleCount() const
Get number of triangles in the fan.
GEO_PrimTriFan(GA_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
fpreal64 fpreal
Definition: SYS_Types.h:277
GLfloat GLfloat v1
Definition: glcorearb.h:817
Container class for all geometry.
Definition: GA_Detail.h:96
Definition of a geometric primitive.
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_TriMesh.h:188
void getTriangleVertices(exint tri, int &v0, int &v1, int &v2) const
Get the vertices for a single triangle in the fan.