HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PrimMesh.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: GU_PrimMesh.h (C++)
7  *
8  * COMMENTS:
9  * Header file for GU_PrimMesh.h class...
10  *
11  */
12 
13 #ifndef __GU_PrimMesh_h__
14 #define __GU_PrimMesh_h__
15 
16 #include "GU_API.h"
17 #include <GEO/GEO_PrimMesh.h>
18 
19 class GA_Detail;
20 class GA_EdgeGroup;
21 class GEO_ConvertParms;
22 class GEO_Detail;
23 class GEO_PrimPoly;
24 class GEO_PolyCounts;
25 class UT_MemoryCounter;
26 
27 /////////////////////////////////////////////////////////////
28 // //
29 // Class: GU_PrimMesh //
30 // Descr: This class is responsible for operations //
31 // done on mesh primitives. As we need to access //
32 // the GEO_Detail, the pointer is passed in the //
33 // constructor. The second constructor creates a //
34 // mesh with the given parameters. //
35 // //
36 /////////////////////////////////////////////////////////////
37 
39 {
40  /// NOTE: Primitives should not be deleted directly. They are managed
41  /// by the GA_PrimitiveList and the stash.
42  ~GU_PrimMesh() override {}
43 
44 public:
45  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
47  : GEO_PrimMesh(gdp, offset)
48  {}
49 
50  /// Report approximate memory usage.
51  int64 getMemoryUsage() const override;
52 
53  /// Count memory usage using a UT_MemoryCounter in order to count
54  /// shared memory correctly.
55  /// NOTE: This should always include sizeof(*this).
56  void countMemory(UT_MemoryCounter &counter) const override;
57 
58  const GA_PrimitiveDefinition &getTypeDef() const override
59  {
60  UT_ASSERT(theDefinition);
61  return *theDefinition;
62  }
63 
64  // Conversion Method
65 
67  GA_PointGroup *usedpts = 0) override;
68  GEO_Primitive *convertNew(GEO_ConvertParms &parms) override;
69 
70  // Cut a wedge of the primitive given a domain range
71  // ind1 and ind2 are indices to the refined values
72  // They are updated if negative on input, else used as is.
73  // If keep is zero the curve is only refined and the indices
74  // updated.
75 
76  GU_PrimMesh *cutU(float u1, float u2,
77  int &ind1, int &ind2, int keep);
78  GU_PrimMesh *cutV(float v1, float v2,
79  int &ind1, int &ind2, int keep);
80 
81  // Open the primitive at the given domain value
82  void openAtU(float u);
83  void openAtV(float v);
84 
85  // remove a single curve in the domain of the hull
86  GEO_PrimPoly *extractU(float unitu)
87  { return extractU(unitu, getParent()); }
88  GEO_PrimPoly *extractU(float unitu, GEO_Detail *parent) const;
89  GEO_PrimPoly *extractV(float unitv)
90  { return extractV(unitv, getParent()); }
91  GEO_PrimPoly *extractV(float unitv, GEO_Detail *parent) const;
92 
93  // This is more powerful than convertNew. It always returns a NEW
94  // object, so free it when you're done with it. It may return a mesh,
95  // a NURB surface or a Bezier surface depending on the type.
96  GEO_Hull *reconfigure(unsigned type, int orderu, int orderv,
97  bool openu, bool openv) const;
98 
99  int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
100  float tmax = 1E17F, float tol = 1E-12F,
101  float *distance = 0, UT_Vector3 *pos = 0,
102  UT_Vector3 *nml = 0, int accurate = 0,
103  float *u = 0, float *v = 0,
104  int ignoretrim = 1) const override;
105 
106 
107  // NOTE: For static member functions please call in the following
108  // manner. <ptrvalue> = GU_PrimMesh::<functname>
109  // i.e. meshptr = GU_PrimMesh::build(params...);
110 
111  // Optional Build Method
112 
113  static GU_PrimMesh *build(GEO_Detail *gudp,
114  int rows, int cols,
116  int wrapu = 0, int wrapv = 0,
117  int appendPoints=1);
118 
119  // Remove as many of the given edges of possible from this poly.
120  // If edge #a is removed, bit a in the bit array is set to a & 1.
121  // returns 0 if successful, -1 if the poly becomes degenerate, and
122  // -2 if the poly should be removed.
123  int removeEdges(const GA_EdgeGroup &edges,
124  UT_BitArray *remove_edges=0);
125 
126  /// For each vertex of polygons representing the mesh with the
127  /// specified properties, this function fills in what the
128  /// vertex number in the corresponding mesh would be.
129  /// This is useful for avoiding creating an intermediate GU_PrimMesh
130  /// that would just be converted to polygons or a polygon soup.
131  static void fillMeshVertArray(GEO_SurfaceType surface, GA_Size nrows,
132  GA_Size ncols, bool wrappedu, bool wrappedv,
133  UT_IntArray &relvertnums,
134  GEO_PolyCounts &polysizes,
135  bool parallel = true);
136 
137 protected:
138  GEO_Hull *getSubHull(int top, int left, int bottom, int right,
139  GEO_SubHullFlags break_flags) override;
140 
141 private:
142  // Recursively break the mesh using the edge-deletion matricies.
143  // used by removeEdges
144 
145  int create(int rows, int cols,
147  int wrapu = 0, int wrapv = 0,
148  int appendPoints = 1);
149 
150  void computeVertices(GEO_Hull &hull, int, int) const;
151 
152  GEO_Primitive *doConversion(GEO_ConvertParms &parms, int reusePoints);
153 
154  static GA_PrimitiveDefinition *theDefinition;
155  friend class GU_PrimitiveFactory;
157 };
159 
160 #endif
GLint left
Definition: glcorearb.h:2005
const GLdouble * v
Definition: glcorearb.h:837
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
GLdouble right
Definition: glad.h:2817
SYS_FORCE_INLINE GEO_Detail * getParent() const
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
GLdouble u1
Definition: glad.h:2676
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GA_Size GA_Offset
Definition: GA_Types.h:646
GLintptr offset
Definition: glcorearb.h:665
virtual void countMemory(UT_MemoryCounter &counter) const
GU_PrimMesh(GA_Detail *gdp, GA_Offset offset=GA_INVALID_OFFSET)
NOTE: This constructor should only be called via GU_PrimitiveFactory.
Definition: GU_PrimMesh.h:46
long long int64
Definition: SYS_Types.h:116
#define GU_API
Definition: GU_API.h:14
GLdouble GLdouble u2
Definition: glad.h:2676
GLint GLint bottom
Definition: glcorearb.h:2005
const GA_PrimitiveDefinition & getTypeDef() const override
Definition: GU_PrimMesh.h:58
virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1) const
GLfloat GLfloat v1
Definition: glcorearb.h:817
GEO_PrimPoly * extractV(float unitv)
Definition: GU_PrimMesh.h:89
virtual GEO_Hull * getSubHull(int top, int left, int bottom, int right, GEO_SubHullFlags break_flags)=0
GLdouble GLdouble GLdouble top
Definition: glad.h:2817
GEO_SurfaceType
Container class for all geometry.
Definition: GA_Detail.h:96
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
GEO_PrimPoly * extractU(float unitu)
Definition: GU_PrimMesh.h:86
Definition of a geometric primitive.
SIM_API const UT_StringHolder distance
type
Definition: core.h:1059
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0