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
00050 class SoSFArray : public SoSField
00051 {
00052 SO_SFIELD_REQUIRED_HEADER(SoSFArray);
00053 SO_SFIELD_CONSTRUCTOR_HEADER(SoSFArray);
00054
00055 public:
00064 enum CopyPolicy {
00068 COPY = SoMemoryObject::COPY,
00072 NO_COPY = SoMemoryObject::NO_COPY,
00077 NO_COPY_AND_DELETE = SoMemoryObject::NO_COPY_AND_DELETE,
00082 NO_COPY_AND_FREE = SoMemoryObject::NO_COPY_AND_FREE
00083 } ;
00084
00086 enum DataType
00087 {
00089 UNSIGNED_BYTE = SbDataType::UNSIGNED_BYTE,
00091 UNSIGNED_SHORT = SbDataType::UNSIGNED_SHORT,
00093 UNSIGNED_INT32 = SbDataType::UNSIGNED_INT32,
00095 SIGNED_BYTE = SbDataType::SIGNED_BYTE,
00097 SIGNED_SHORT = SbDataType::SIGNED_SHORT,
00099 SIGNED_INT32 = SbDataType::SIGNED_INT32,
00101 FLOAT = SbDataType::FLOAT
00102 } ;
00103
00109 inline void* getValue() const ;
00110
00114 DataType getDataType() const { return (DataType)m_dataType.getType(); }
00115
00119 void finishEditing();
00120
00125 virtual int operator ==(const SoSFArray &f) const;
00126
00130 virtual int operator !=(const SoSFArray &f) const
00131 { return ! ((*this) == f); }
00132
00140 void setNeverWrite(SbBool neverWrite)
00141 { m_neverWrite = neverWrite ;}
00142
00146 SbBool isNeverWrite()
00147 { return m_neverWrite ; }
00148
00152 inline const SbVec3i32& getSize() const;
00153
00164 void* startEditing(SbVec3i32 &size, SbDataType& dataType);
00165
00170 inline virtual size_t getValueSize() const ;
00171
00177 const void* getValue(SbVec3i32 &size, SbDataType &dataType) const ;
00178
00183 void setValue(const SbVec3i32 &size, const SbDataType& dataType,
00184 const void* data, CopyPolicy copy=COPY);
00185
00191 void setValue(const SbVec3i32 &size,SoMemoryObject* memObj,
00192 CopyPolicy copy);
00193
00197 SbBool isEmpty() const;
00198
00199 private:
00200 static void initClass();
00201 static void exitClass();
00202
00203 SoBufferObject *getBufferObject() const;
00204
00205 private:
00207 int m_dimension;
00208
00210 SbVec3i32 m_size;
00211
00213 virtual SbBool readValue(SoInput *in);
00214
00216 virtual void writeValue(SoOutput *out) const ;
00217
00219 SoMemoryObject* m_values ;
00220
00221 private:
00226 static const int NO_DATA_FLAG;
00227
00229 template <typename T> void allocValues(int numValues);
00230
00235 template <typename T> SbBool readAsciiValue(SoInput* in, size_t pos);
00236
00240 template <typename T> void writeAsciiValue(SoOutput* out, size_t pos) const;
00241
00243 SbDataType m_dataType ;
00244
00246 CopyPolicy m_copyPolicy;
00247
00249 SbBool m_neverWrite;
00250 };
00251
00252
00253 void*
00254 SoSFArray::getValue() const
00255 {
00256 if (isEmpty())
00257 return NULL;
00258
00259 return m_values?m_values->get():NULL;
00260 }
00261
00262
00263 const SbVec3i32&
00264 SoSFArray::getSize() const
00265 {
00266 return m_size;
00267 }
00268
00269
00270 size_t
00271 SoSFArray::getValueSize() const
00272 {
00273 return m_dataType.getSize();
00274 }
00275
00276
00277 #endif
00278
00279
00280