HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimTriStrip.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_PrimTriStrip.h ( GEO Library, C++)
7  *
8  * COMMENTS: Implements a normal triangle strip.
9  */
10 
11 #ifndef __GEO_PrimTriStrip__
12 #define __GEO_PrimTriStrip__
13 
14 #include "GEO_API.h"
15 #include "GEO_TriMesh.h"
16 #include "GEO_PrimType.h"
17 
18 class GA_Detail;
19 
20 /// A strip of triangles. The Nth triangle shares an edge with the previous.
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  virtual ~GEO_PrimTriStrip() {}
33 
34 public:
35  /// @{
36  /// Interface from GEO_TriMesh
37  virtual bool isDegenerate() const;
38  virtual UT_Vector3 computeNormal() const;
39  virtual void reverse();
40  virtual void reverseNormal();
41 
42  virtual fpreal calcVolume(const UT_Vector3 &refpt) const;
43  virtual fpreal calcArea() const;
44  virtual fpreal calcPerimeter() const;
45  /// @}
46 
47  /// Get number of triangles in the strip
48  int getTriangleCount() const { return getVertexCount()-2; }
49 
50  /// Get the vertices for a single triangle in the strip
51  void getTriangleVertices(int idx, int &v0, int &v1, int &v2) const
52  {
53  v0 = idx;
54  if (idx & 1)
55  {
56  v1 = idx+1;
57  v2 = idx+2;
58  }
59  else
60  {
61  v1 = idx+2;
62  v2 = idx+1;
63  }
64  }
65 
66  virtual const GA_PrimitiveJSON *getJSON() const;
67 
68 protected:
70  { return GEO_TriMesh::buildFamilyMask(); }
71 
72  /// All subclasses should call this method to register the curve intrinsics.
73  /// @see GA_IntrinsicManager
76  { return GEO_TriMesh::registerIntrinsics(defn); }
77 
78  // We don't need to save anything other than what's in a face
79  virtual bool savePrivateH9(std::ostream &, bool binary) const;
80  virtual bool loadPrivateH9(UT_IStream &);
81 
82 private:
83  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimTriStrip &d)
84  {
85  d.saveH9(os, 0,
88  return os;
89  }
90 };
91 
92 #endif
93 
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
Definition: GEO_TriMesh.h:258
virtual bool isDegenerate() const
Is the primitive degenerate.
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
static GA_PrimitiveFamilyMask buildFamilyMask()
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
3D Vector class.
virtual ~GEO_PrimTriStrip()
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:654
GA_Size GA_Offset
Definition: GA_Types.h:617
virtual fpreal calcArea() const
virtual bool savePrivateH9(std::ostream &os, bool binary) const =0
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
virtual void reverse()=0
Reverse the order of vertices.
virtual fpreal calcPerimeter() const
virtual bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const
GLfloat v0
Definition: glcorearb.h:815
double fpreal
Definition: SYS_Types.h:270
GEO_PrimTriStrip(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().
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimTriStrip &d)
A strip of triangles. The Nth triangle shares an edge with the previous.
GLfloat GLfloat v1
Definition: glcorearb.h:816
virtual GA_Size getVertexCount() const final
Definition: GEO_TriMesh.h:142
virtual fpreal calcVolume(const UT_Vector3 &) const
Container class for all geometry.
Definition: GA_Detail.h:95
int getTriangleCount() const
Get number of triangles in the strip.
Definition of a geometric primitive.
void getTriangleVertices(int idx, int &v0, int &v1, int &v2) const
Get the vertices for a single triangle in the strip.
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_TriMesh.h:252
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)