00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __SIM_IndexField__
00020 #define __SIM_IndexField__
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_ScalarField;
00034 class SIM_VectorField;
00035 class SIM_MatrixField;
00036
00037
00038 class SIM_API SIM_IndexField : 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_I("initialvalue", InitialValue);
00058 GETSET_DATA_FUNCS_I("border", RawBorder);
00059 UT_VoxelBorderType getBorder() const { return (UT_VoxelBorderType) getRawBorder(); }
00060
00061
00062
00063 void getBBox(UT_BoundingBox &bbox) const;
00064
00065 UT_Vector3 getOrig() const
00066 {
00067 return getCenter() - getSize()/2;
00068 }
00069
00070
00071
00072 UT_Vector3 getDivisions() const;
00073 UT_Vector3 getSize() const;
00074 UT_Vector3 getCenter() const;
00075
00076
00077
00078 void setDivisions(const UT_Vector3 &div);
00079 void setSize(const UT_Vector3 &div);
00080 void setCenter(const UT_Vector3 &div);
00081
00082
00083
00084
00085
00086
00087 void resizeKeepData(const UT_Vector3 &size, const UT_Vector3 ¢er);
00088
00089
00090
00091
00092 void matchField(const SIM_ScalarField *field);
00093 void matchField(const SIM_VectorField *field);
00094 void matchField(const SIM_MatrixField *field);
00095 void matchField(const SIM_IndexField *field, bool matchsamples = false);
00096
00097 SIM_FieldSample getVoxelSample() const;
00098
00099 const UT_Vector3 &getVoxelSize() const;
00100 fpreal getVoxelDiameter() const;
00101
00102
00103
00104 int64 getValue(const UT_Vector3 &pos) const;
00105
00106
00107 bool indexToPos(int x, int y, int z, UT_Vector3 &pos) const;
00108
00109
00110 bool posToIndex(const UT_Vector3 &pos, int &x, int &y, int &z) const;
00111
00112
00113 SIM_RawIndexField *getField() const { return myField; };
00114
00115
00116 void setField(SIM_RawIndexField *field);
00117
00118
00119
00120 SIM_RawIndexField *stealField();
00121
00122
00123 void pubHandleModification()
00124 {
00125 handleModification();
00126 }
00127
00128 protected:
00129 explicit SIM_IndexField(const SIM_DataFactory *factory);
00130 virtual ~SIM_IndexField();
00131
00132
00133 virtual void initializeSubclass();
00134
00135 virtual void makeEqualSubclass(const SIM_Data *source);
00136
00137
00138 virtual void saveSubclass(ostream &os) const;
00139
00140 virtual bool loadSubclass(UT_IStream &is);
00141
00142 virtual int64 getMemorySizeSubclass() const;
00143
00144
00145 virtual void optionChangedSubclass(const char *name);
00146
00147 private:
00148 static const SIM_DopDescription *getIndexFieldDopDescription();
00149
00150
00151 void rebuildField();
00152
00153 SIM_RawIndexField *myField;
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 int64 myStashedInitialValue;
00164
00165 DECLARE_STANDARD_GETCASTTOTYPE();
00166
00167 DECLARE_DATAFACTORY(SIM_IndexField,
00168 SIM_Data,
00169 "IndexField",
00170 getIndexFieldDopDescription());
00171 };
00172 #endif
00173