00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __SIM_ScalarField__
00020 #define __SIM_ScalarField__
00021
00022 #include "SIM_API.h"
00023
00024 #include <UT/UT_VoxelArray.h>
00025
00026 #include "SIM_Names.h"
00027 #include "SIM_OptionsUser.h"
00028 #include "SIM_DataUtils.h"
00029 #include "SIM_RawField.h"
00030
00031 class UT_IStream;
00032 class SIM_Geometry;
00033 class SIM_VectorField;
00034 class SIM_MatrixField;
00035 class SIM_IndexField;
00036
00037
00038 class SIM_API SIM_ScalarField : public SIM_Data,
00039 public SIM_OptionsUser
00040 {
00041 public:
00042
00043 GETSET_DATA_FUNCS_I(SIM_NAME_UNIFORMVOXELS, UniformVoxels);
00044 GETSET_DATA_FUNCS_B(SIM_NAME_TWOD, TwoDField);
00045 GETSET_DATA_FUNCS_I(SIM_NAME_VOXELPLANE, VoxelPlane);
00046 GETSET_DATA_FUNCS_V3(SIM_NAME_DIV, RawDivisions);
00047 GETSET_DATA_FUNCS_I("uniformdiv", RawUniformDivisions);
00048 GETSET_DATA_FUNCS_V3(SIM_NAME_CENTER, RawCenter);
00049 GETSET_DATA_FUNCS_V3(SIM_NAME_SIZE, RawSize);
00050
00051 GETSET_DATA_FUNCS_V3("slicediv", SliceDivisions);
00052 GETSET_DATA_FUNCS_V3("sliceoverlapneg", SliceOverlapNeg);
00053 GETSET_DATA_FUNCS_V3("sliceoverlappos", SliceOverlapPos);
00054 GETSET_DATA_FUNCS_I("slice", Slice)
00055
00056 GETSET_DATA_FUNCS_I(SIM_NAME_VOXELSAMPLE, VoxelSampleRaw);
00057 GETSET_DATA_FUNCS_F("initialvalue", InitialValue);
00058 GETSET_DATA_FUNCS_F(SIM_NAME_TOLERANCE, Tolerance);
00059 GETSET_DATA_FUNCS_I("border", RawBorder);
00060 UT_VoxelBorderType getBorder() const { return (UT_VoxelBorderType) getRawBorder(); }
00061
00062
00063
00064 void getBBox(UT_BoundingBox &bbox) const;
00065
00066 UT_Vector3 getOrig() const
00067 {
00068 return getCenter() - getSize()/2;
00069 }
00070
00071
00072
00073 UT_Vector3 getDivisions() const;
00074 UT_Vector3 getSize() const;
00075 UT_Vector3 getCenter() const;
00076
00077
00078
00079 void setDivisions(const UT_Vector3 &div);
00080 void setSize(const UT_Vector3 &size);
00081 void setCenter(const UT_Vector3 ¢er);
00082
00083
00084
00085
00086
00087
00088 void resizeKeepData(const UT_Vector3 &size, const UT_Vector3 ¢er);
00089
00090
00091
00092
00093
00094 void matchField(const SIM_ScalarField *field, bool matchsample = false);
00095 void matchField(const SIM_VectorField *field);
00096 void matchField(const SIM_MatrixField *field);
00097 void matchField(const SIM_IndexField *field);
00098
00099 SIM_FieldSample getVoxelSample() const;
00100
00101 const UT_Vector3 &getVoxelSize() const;
00102 fpreal getVoxelDiameter() const;
00103
00104
00105
00106 fpreal getValue(const UT_Vector3 &pos) const;
00107
00108
00109 UT_Vector3 getGradient(const UT_Vector3 &pos) const;
00110
00111
00112 void advect(const SIM_VectorField *vel, fpreal timestep,
00113 const SIM_RawField *collision = 0,
00114 SIM_FieldAdvection advectmethod = SIM_ADVECT_TRACE);
00115 void advect(sim_PointVelocity getVelocity, fpreal timestep,
00116 fpreal voxelsize,
00117 const SIM_RawField *collision = 0);
00118
00119
00120 void enforceBoundary(const SIM_ScalarField *collision=0,
00121 const SIM_ScalarField *colvalue=0);
00122
00123
00124 bool indexToPos(int x, int y, int z, UT_Vector3 &pos) const;
00125
00126
00127 bool posToIndex(const UT_Vector3 &pos, int &x, int &y, int &z) const;
00128
00129
00130 SIM_RawField *getField() const { return myField; };
00131
00132
00133 void setField(SIM_RawField *field);
00134
00135
00136
00137 SIM_RawField *stealField();
00138
00139
00140 void pubHandleModification()
00141 {
00142 handleModification();
00143 }
00144
00145
00146 GU_ConstDetailHandle createSmokeRepresentation(const SIM_RootData &root) const;
00147
00148
00149
00150 void addSmokeRepresentation(const SIM_RootData &root, GU_Detail *gdp) const;
00151
00152 protected:
00153 explicit SIM_ScalarField(const SIM_DataFactory *factory);
00154 virtual ~SIM_ScalarField();
00155
00156
00157 virtual void initializeSubclass();
00158
00159 virtual void makeEqualSubclass(const SIM_Data *source);
00160
00161
00162 virtual void saveSubclass(ostream &os) const;
00163
00164 virtual bool loadSubclass(UT_IStream &is);
00165
00166 virtual int64 getMemorySizeSubclass() const;
00167
00168
00169 virtual void optionChangedSubclass(const char *name);
00170
00171 private:
00172 static const SIM_DopDescription *getScalarFieldDopDescription();
00173
00174
00175 void rebuildField();
00176
00177 SIM_RawField *myField;
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 fpreal myStashedInitialValue;
00188
00189 DECLARE_STANDARD_GETCASTTOTYPE();
00190
00191 DECLARE_DATAFACTORY(SIM_ScalarField,
00192 SIM_Data,
00193 "ScalarField",
00194 getScalarFieldDopDescription());
00195 };
00196 #endif
00197