00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SO_SF_ARRAY_H
00025 #define SO_SF_ARRAY_H
00026
00027 #include <Inventor/fields/SoSubField.h>
00028 #include <Inventor/fields/SoSFImage.h>
00029
00030 class SoMemoryObject;
00031 class SoBufferObject;
00032
00049 class SoSFArray : public SoSField
00050 {
00051 SO_SFIELD_REQUIRED_HEADER(SoSFArray);
00052 SO_SFIELD_CONSTRUCTOR_HEADER(SoSFArray);
00053
00054 public:
00063 enum CopyPolicy {
00067 COPY = SoMemoryObject::COPY,
00071 NO_COPY = SoMemoryObject::NO_COPY,
00076 NO_COPY_AND_DELETE = SoMemoryObject::NO_COPY_AND_DELETE,
00081 NO_COPY_AND_FREE = SoMemoryObject::NO_COPY_AND_FREE
00082 } ;
00083
00085 enum DataType
00086 {
00088 UNSIGNED_BYTE = SbDataType::UNSIGNED_BYTE,
00090 UNSIGNED_SHORT = SbDataType::UNSIGNED_SHORT,
00092 UNSIGNED_INT32 = SbDataType::UNSIGNED_INT32,
00094 SIGNED_BYTE = SbDataType::SIGNED_BYTE,
00096 SIGNED_SHORT = SbDataType::SIGNED_SHORT,
00098 SIGNED_INT32 = SbDataType::SIGNED_INT32,
00100 FLOAT = SbDataType::FLOAT
00101 } ;
00102
00108 inline void* getValue() const ;
00109
00113 DataType getDataType() const { return (DataType)m_dataType.getType(); }
00114
00118 void finishEditing();
00119
00124 virtual int operator ==(const SoSFArray &f) const;
00125
00129 virtual int operator !=(const SoSFArray &f) const
00130 { return ! ((*this) == f); }
00131
00139 void setNeverWrite(SbBool neverWrite)
00140 { m_neverWrite = neverWrite ;}
00141
00145 SbBool isNeverWrite()
00146 { return m_neverWrite ; }
00147
00151 inline const SbVec3i32& getSize() const;
00152
00163 void* startEditing(SbVec3i32 &size, SbDataType& dataType);
00164
00169 inline virtual size_t getValueSize() const ;
00170
00176 const void* getValue(SbVec3i32 &size, SbDataType &dataType) const ;
00177
00182 void setValue(const SbVec3i32 &size, const SbDataType& dataType,
00183 const void* data, CopyPolicy copy=COPY);
00184
00190 void setValue(const SbVec3i32 &size,SoMemoryObject* memObj,
00191 CopyPolicy copy);
00192
00196 SbBool isEmpty() const;
00197
00198 private:
00199 static void initClass();
00200 static void exitClass();
00201
00202 SoBufferObject *getBufferObject() const;
00203
00204 private:
00206 int m_dimension;
00207
00209 SbVec3i32 m_size;
00210
00212 virtual SbBool readValue(SoInput *in);
00213
00215 virtual void writeValue(SoOutput *out) const ;
00216
00218 SoMemoryObject* m_values ;
00219
00220 private:
00225 static const int NO_DATA_FLAG;
00226
00228 template <typename T> void allocValues(int numValues);
00229
00234 template <typename T> SbBool readAsciiValue(SoInput* in, size_t pos);
00235
00239 template <typename T> void writeAsciiValue(SoOutput* out, size_t pos) const;
00240
00242 SbDataType m_dataType ;
00243
00245 CopyPolicy m_copyPolicy;
00246
00248 SbBool m_neverWrite;
00249 };
00250
00251
00252 void*
00253 SoSFArray::getValue() const
00254 {
00255 if (isEmpty())
00256 return NULL;
00257
00258 return m_values?m_values->get():NULL;
00259 }
00260
00261
00262 const SbVec3i32&
00263 SoSFArray::getSize() const
00264 {
00265 return m_size;
00266 }
00267
00268
00269 size_t
00270 SoSFArray::getValueSize() const
00271 {
00272 return m_dataType.getSize();
00273 }
00274
00275
00276 #endif
00277
00278
00279