HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Iso.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 Utility Library (C++)
7  *
8  * COMMENTS: Calculate an isosurface from a field. The evaluation
9  * routine should return a positive value outside the surface
10  * and a negative value inside for the computed normals to
11  * point outward.
12  */
13 
14 #ifndef __GU_Iso__
15 #define __GU_Iso__
16 
17 #include "GU_API.h"
18 #include <GA/GA_Types.h>
19 #include <UT/UT_Vector3.h>
20 #include <UT/UT_BoundingBox.h>
21 #include <UT/UT_Assert.h>
22 
23 class GU_Detail;
24 class GEO_Primitive;
25 
26 /// Function to determine inside/outside tests.
27 typedef float (*GU_IsoCallback)(const UT_Vector3 &pos, void *data);
28 
30 {
31 public:
32  GU_IsoSurface(bool isthreadsafe = false);
33  virtual ~GU_IsoSurface();
34 
35  void setCallback(GU_IsoCallback eval, void *eval_data)
36  { myEval = eval; myEvalData = eval_data; }
37 
38  void polygonize(GU_Detail *gdp, const UT_BoundingBox &box,
39  int xdivs, int ydivs, int zdivs,
40  bool makepolysoup = false);
41 
42  /// Evaluate the field at a position
43  virtual float evalEdge(const UT_Vector3 &pos)
44  { return myEval(pos, myEvalData); }
45 
46  /// Check whether gradients are available for surfacing
47  virtual bool hasGradient() const { return false; }
48 
49  /// Evaluate gradients if available
50  virtual UT_Vector3 evalGrad(const UT_Vector3 &pos)
51  { return UT_Vector3(0, 0, 0); }
52 
53  /// This function can be used to fill attribute information. The
54  /// position of the point will be set to its final position when this
55  /// function is called. The eval() method will have just been used so
56  /// that you can use any information that would have been set up for
57  /// this.
58  virtual void fillPointVertexAttributes(GU_Detail &detail,
59  GA_Offset vtxoff) {}
60 
61  /// This function can be used to fill out primitive attribute information.
62  virtual void fillPrimitiveAttributes(GEO_Primitive *primitive) {}
63 
64  /// This indicates whether evalEdge and evalGrad
65  /// can be called in multiple threads at the same time.
66  bool isThreadSafe() const {return myIsThreadSafe;}
67 
68 private:
69  GU_IsoCallback myEval;
70  void * myEvalData;
71  bool myIsThreadSafe;
72 };
73 
74 #endif // __GU_Iso__
bool isThreadSafe() const
Definition: GU_Iso.h:66
virtual UT_Vector3 evalGrad(const UT_Vector3 &pos)
Evaluate gradients if available.
Definition: GU_Iso.h:50
GLboolean * data
Definition: glcorearb.h:131
virtual float evalEdge(const UT_Vector3 &pos)
Evaluate the field at a position.
Definition: GU_Iso.h:43
UT_Vector3T< float > UT_Vector3
void setCallback(GU_IsoCallback eval, void *eval_data)
Definition: GU_Iso.h:35
virtual void fillPrimitiveAttributes(GEO_Primitive *primitive)
This function can be used to fill out primitive attribute information.
Definition: GU_Iso.h:62
virtual void fillPointVertexAttributes(GU_Detail &detail, GA_Offset vtxoff)
Definition: GU_Iso.h:58
GA_Size GA_Offset
Definition: GA_Types.h:641
virtual bool hasGradient() const
Check whether gradients are available for surfacing.
Definition: GU_Iso.h:47
HUSD_API bool eval(VtValue &val, T &ret_val)
#define GU_API
Definition: GU_API.h:14
float(* GU_IsoCallback)(const UT_Vector3 &pos, void *data)
Function to determine inside/outside tests.
Definition: GU_Iso.h:27