HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~SIM_SDF() override;
70 
71  /// Overrides to properly implement this class as a SIM_Data.
72  void initializeSubclass() override;
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  void saveSubclass(std::ostream &os) const override;
80  /// Loads our attributes and internal data if it was set when we saved.
81  bool loadSubclass(UT_IStream &is) override;
82 
83  int64 getMemorySizeSubclass() const override;
84  bool getIsAlternateRepresentationSubclass() const override;
86  const SIM_Data &) override;
87  SIM_Guide *createGuideObjectSubclass() const override;
89  const SIM_RootData &root,
90  const SIM_Options &options,
91  const GU_DetailHandle &gdh,
92  UT_DMatrix4 *xform,
93  const SIM_Time &t) const override;
94 
95 private:
96  /// Builds the SDF from the given geometry.
97  void buildSDF(const SIM_Geometry *geo);
98  static const SIM_DopDescription *getSDFDopDescription();
99 
100  GU_SDF *mySDF;
101  UT_VoxelMipMapF *myMipMap;
102 
103  /// Flags that we are trying to do a delayed build.
104  mutable GU_SDFDelayedBuilder *myBuilder;
105 
106  // Used to build an isosurface:
107  static float pointDensity(const UT_Vector3 &pos, void *);
108 
110 
112  SIM_Data,
113  "Volume",
114  getSDFDopDescription());
115 };
116 
117 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
virtual bool loadSubclass(UT_IStream &is)
#define SIM_NAME_TOLERANCE
Definition: SIM_Names.h:202
#define SIM_NAME_MODE
Definition: SIM_Names.h:151
#define GETSET_DATA_FUNCS_B(DataName, FuncName)
virtual bool getIsAlternateRepresentationSubclass() const
#define SIM_NAME_DIV
Definition: SIM_Names.h:109
#define SIM_NAME_LASERSCAN
Definition: SIM_Names.h:140
virtual int64 getMemorySizeSubclass() const
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
Definition: GU_SDF.h:302
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:63
#define SIM_NAME_INVERT
Definition: SIM_Names.h:139
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:208
#define GETSET_DATA_FUNCS_I(DataName, FuncName)
long long int64
Definition: SYS_Types.h:116
GLdouble t
Definition: glad.h:2397
#define SIM_NAME_FORCEBOUNDS
Definition: SIM_Names.h:121
#define SIM_NAME_FIXSIGNS
Definition: SIM_Names.h:117
#define SIM_API
Definition: SIM_API.h:12
virtual void initAlternateRepresentationSubclass(const SIM_Data &)
#define SIM_NAME_OFFSET
Definition: SIM_Names.h:157
virtual SIM_Guide * createGuideObjectSubclass() const
virtual void initializeSubclass()