HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_SDF.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: SIM_SDF.h ( SIM Library, C++)
7  *
8  * COMMENTS:
9  * This simple procedure allows for intersection with signed
10  * distance functions.
11  */
12 
13 #ifndef __SIM_SDF_H__
14 #define __SIM_SDF_H__
15 
16 #include "SIM_API.h"
17 #include <GU/GU_SDF.h>
18 
19 #include "SIM_Names.h"
20 #include "SIM_OptionsUser.h"
21 #include "SIM_DataUtils.h"
22 
23 class UT_IStream;
24 class SIM_Geometry;
25 
26 /// This class holds a signed distance function representing a GU_Detail.
27 class SIM_API SIM_SDF : public SIM_Data,
28  public SIM_OptionsUser
29 {
30 public:
31  /// Control the number of divisions.
35  GETSET_DATA_FUNCS_I("uniformdiv", UniformDivisions);
36  GETSET_DATA_FUNCS_F("divsize", DivisionSize);
43  GETSET_DATA_FUNCS_I("sweepcount", SweepCount);
44  GETSET_DATA_FUNCS_F("sweepalpha", SweepThreshold);
45 
46  /// Get the SDF.
47  const GU_SDF &getSDF() const;
48 
49  GU_SDFDelayedBuilder getDelayedSDF() const;
50 
51  /// Create a GU_Detail with the SDF present as a volume
52  /// primitive
53  GU_ConstDetailHandle createSmokeRepresentation(const SIM_RootData &root) const;
54  void addSmokeRepresentation(const SIM_RootData &root, GU_Detail *gdp) const;
55 
56  /// Forcibly changes the SDF to the given mapping.
57  void setSDF(GU_SDF *sdf);
58 
59  /// Steals the current SDF, replacing it with a blank one.
60  /// This is used to allow the IsoOffset SOP to extract an SDF
61  /// loaded into a simulation without having to copy it.
62  GU_SDF *stealSDF();
63 
64  /// Returns voxel mipmap for this sdf.
65  UT_VoxelMipMapF *getMipMap() const;
66 
67 protected:
68  explicit SIM_SDF(const SIM_DataFactory *factory);
69  virtual ~SIM_SDF();
70 
71  /// Overrides to properly implement this class as a SIM_Data.
72  virtual void initializeSubclass();
73 
74  /// Computes the right number of divisions/bounding box size
75  /// for incoming geometry
76  void computeDivisions(const GU_Detail *gdp, UT_BoundingBox &bbox, int &divx, int &divy, int &divz);
77 
78  /// Saves our attributes, and our internal data if it has been set.
79  virtual void saveSubclass(std::ostream &os) const;
80  /// Loads our attributes and internal data if it was set when we saved.
81  virtual bool loadSubclass(UT_IStream &is);
82 
83  virtual int64 getMemorySizeSubclass() const;
84  virtual bool getIsAlternateRepresentationSubclass() const;
85  virtual void initAlternateRepresentationSubclass(const SIM_Data &);
86  virtual SIM_Guide *createGuideObjectSubclass() const;
87  virtual void buildGuideGeometrySubclass(const SIM_RootData &root,
88  const SIM_Options &options,
89  const GU_DetailHandle &gdh,
90  UT_DMatrix4 *xform,
91  const SIM_Time &t) const;
92 
93 private:
94  /// Builds the SDF from the given geometry.
95  void buildSDF(const SIM_Geometry *geo);
96  static const SIM_DopDescription *getSDFDopDescription();
97 
98  GU_SDF *mySDF;
99  UT_VoxelMipMapF *myMipMap;
100 
101  /// Flags that we are trying to do a delayed build.
102  mutable GU_SDFDelayedBuilder *myBuilder;
103 
104  // Used to build an isosurface:
105  static float pointDensity(const UT_Vector3 &pos, void *);
106 
108 
110  SIM_Data,
111  "Volume",
112  getSDFDopDescription());
113 };
114 
115 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
virtual bool loadSubclass(UT_IStream &is)
#define SIM_NAME_TOLERANCE
Definition: SIM_Names.h:201
#define SIM_NAME_MODE
Definition: SIM_Names.h:150
#define GETSET_DATA_FUNCS_B(DataName, FuncName)
virtual bool getIsAlternateRepresentationSubclass() const
#define SIM_NAME_DIV
Definition: SIM_Names.h:108
#define SIM_NAME_LASERSCAN
Definition: SIM_Names.h:139
virtual int64 getMemorySizeSubclass() const
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
Definition: GU_SDF.h:289
virtual void buildGuideGeometrySubclass(const SIM_RootData &root, const SIM_Options &options, const GU_DetailHandle &gdh, UT_DMatrix4 *xform, const SIM_Time &t) const
#define GETSET_DATA_FUNCS_V3(DataName, FuncName)
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
long long int64
Definition: SYS_Types.h:100
#define SIM_NAME_INVERT
Definition: SIM_Names.h:138
This class holds a signed distance function representing a GU_Detail.
Definition: SIM_SDF.h:27
virtual void saveSubclass(std::ostream &os) const
#define SIM_NAME_UNIFORMVOXELS
Definition: SIM_Names.h:207
#define GETSET_DATA_FUNCS_I(DataName, FuncName)
#define SIM_NAME_FORCEBOUNDS
Definition: SIM_Names.h:120
#define SIM_NAME_FIXSIGNS
Definition: SIM_Names.h:116
#define SIM_API
Definition: SIM_API.h:10
virtual void initAlternateRepresentationSubclass(const SIM_Data &)
#define SIM_NAME_OFFSET
Definition: SIM_Names.h:156
virtual SIM_Guide * createGuideObjectSubclass() const
virtual void initializeSubclass()