Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoSFArray.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : R. ALBOU (Jan 2005)
22**=======================================================================*/
23
24#ifndef SO_SF_ARRAY_H
25#define SO_SF_ARRAY_H
26
27#include <Inventor/fields/SoSubField.h>
28#include <Inventor/fields/SoSFImage.h>
29
30class SoMemoryObject;
31class SoBufferObject;
32
49class SoSFArray : public SoSField
50{
51 SO_SFIELD_REQUIRED_HEADER(SoSFArray);
52 SO_SFIELD_CONSTRUCTOR_HEADER(SoSFArray);
53
54public:
83
102
108 inline void* getValue() const ;
109
113 DataType getDataType() const { return (DataType)m_dataType.getType(); }
114
119
124 virtual int operator ==(const SoSFArray &f) const;
125
129 virtual int operator !=(const SoSFArray &f) const
130 { return ! ((*this) == f); }
131
139 void setNeverWrite(SbBool neverWrite)
140 { m_neverWrite = neverWrite ;}
141
146 { return m_neverWrite ; }
147
151 inline const SbVec3i32& getSize() const;
152
163 void* startEditing(SbVec3i32 &size, SbDataType& dataType);
164
169 inline virtual size_t getValueSize() const ;
170
176 const void* getValue(SbVec3i32 &size, SbDataType &dataType) const ;
177
182 void setValue(const SbVec3i32 &size, const SbDataType& dataType,
183 const void* data, CopyPolicy copy=COPY);
184
190 void setValue(const SbVec3i32 &size,SoMemoryObject* memObj,
191 CopyPolicy copy);
192
197
198private:
199 static void initClass();
200 static void exitClass();
201
202 SoBufferObject *getBufferObject() const;
203
204private:
206 int m_dimension;
207
209 SbVec3i32 m_size;
210
212 virtual SbBool readValue(SoInput *in);
213
215 virtual void writeValue(SoOutput *out) const ;
216
218 SoMemoryObject* m_values ;
219
220private:
225 static const int NO_DATA_FLAG;
226
228 template <typename T> void allocValues(int numValues);
229
234 template <typename T> SbBool readAsciiValue(SoInput* in, size_t pos);
235
239 template <typename T> void writeAsciiValue(SoOutput* out, size_t pos) const;
240
242 SbDataType m_dataType ;
243
245 CopyPolicy m_copyPolicy;
246
248 SbBool m_neverWrite;
249};
250
251/*----------------------------------------------------------------------------*/
252void*
254{
255 if (isEmpty())
256 return NULL;
257
258 return m_values?m_values->get():NULL;
259}
260
261/*----------------------------------------------------------------------------*/
262const SbVec3i32&
264{
265 return m_size;
266}
267
268/*----------------------------------------------------------------------------*/
269size_t
271{
272 return m_dataType.getSize();
273}/*----------------------------------------------------------------------------*/
274
275
276#endif /* _SO_SF_ARRAY_H */
277
278
Class encoding a data type.
Definition SbDataType.h:58
DataType getType() const
Returns the type as an enum.
Definition SbDataType.h:239
@ FLOAT
float
Definition SbDataType.h:78
@ SIGNED_BYTE
signed byte
Definition SbDataType.h:72
@ UNSIGNED_INT32
unsigned int (32bits)
Definition SbDataType.h:70
@ UNSIGNED_BYTE
unsigned byte
Definition SbDataType.h:66
@ SIGNED_SHORT
signed short
Definition SbDataType.h:74
@ UNSIGNED_SHORT
unsigned short
Definition SbDataType.h:68
@ SIGNED_INT32
signed int (32bits)
Definition SbDataType.h:76
unsigned int getSize() const
Returns size in bytes of the type.
Definition SbDataType.h:260
3D vector class.
Definition SbVec.h:1517
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Used to read Open Inventor data files.
Definition SoInput.h:363
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Handle memory bu...
@ NO_COPY_AND_FREE
Passed buffer used, SoMemoryObject will free.
@ NO_COPY
Passed buffer used, user will delete.
@ NO_COPY_AND_DELETE
Passed buffer used, SoMemoryObject will delete.
@ COPY
Open Inventor will make a copy of the data.
void * get() const
Returns a pointer to the encapsulated buffer.
Used to write Open Inventor data files.
Definition SoOutput.h:186
Abstract Field containing an array of values.
Definition SoSFArray.h:50
void finishEditing()
Indicates that batch edits have finished.
SbBool isNeverWrite()
Returns the "neverWrite" flag.
Definition SoSFArray.h:145
virtual int operator!=(const SoSFArray &f) const
Returns TRUE if all of the values of this field do not equal those of the given field f.
Definition SoSFArray.h:129
void * getValue() const
Returns a read-only pointer to the array's values.
Definition SoSFArray.h:253
virtual int operator==(const SoSFArray &f) const
Returns TRUE if all of the values of this field equal those of the given field f.
const SbVec3i32 & getSize() const
Returns the dimensions of the array.
Definition SoSFArray.h:263
CopyPolicy
SoSFArray may be manipulating some large amounts of memory.
Definition SoSFArray.h:63
@ NO_COPY_AND_DELETE
Passed buffer used, SoSFImage will delete.
Definition SoSFArray.h:76
@ COPY
Open Inventor will make a copy of the data (default)
Definition SoSFArray.h:67
@ NO_COPY
Passed buffer used , user will delete.
Definition SoSFArray.h:71
@ NO_COPY_AND_FREE
Passed buffer used, SoSFImage will free.
Definition SoSFArray.h:81
DataType
Supported data type enumeration values.
Definition SoSFArray.h:86
@ FLOAT
FLOAT.
Definition SoSFArray.h:100
@ UNSIGNED_SHORT
UNSIGNED_SHORT.
Definition SoSFArray.h:90
@ UNSIGNED_INT32
UNSIGNED_INT32.
Definition SoSFArray.h:92
@ SIGNED_INT32
SIGNED_INT32.
Definition SoSFArray.h:98
@ UNSIGNED_BYTE
UNSIGNED_BYTE.
Definition SoSFArray.h:88
@ SIGNED_SHORT
SIGNED_SHORT.
Definition SoSFArray.h:96
@ SIGNED_BYTE
SIGNED_BYTE.
Definition SoSFArray.h:94
void setNeverWrite(SbBool neverWrite)
Sets the "neverWrite" flag.
Definition SoSFArray.h:139
virtual size_t getValueSize() const
Returns the size in bytes of one data value, e.g.
Definition SoSFArray.h:270
DataType getDataType() const
Returns the data type of the array.
Definition SoSFArray.h:113
void setValue(const SbVec3i32 &size, SoMemoryObject *memObj, CopyPolicy copy)
Fill the array with the specified dimensions and data from an SoMemoryObject using the specified copy...
void setValue(const SbVec3i32 &size, const SbDataType &dataType, const void *data, CopyPolicy copy=COPY)
Fill the array with data of the specified dimensions and type using the specified copy policy.
SbBool isEmpty() const
Returns TRUE if the current array is empty.
void * startEditing(SbVec3i32 &size, SbDataType &dataType)
Returns a pointer to the internally maintained array that can be modified.
const void * getValue(SbVec3i32 &size, SbDataType &dataType) const
Returns a read-only pointer to the array's values and its dimensions and data type.
Abstract base class for all single-value fields.
Definition SoSField.h:93
int SbBool
Boolean type.
Definition SbBase.h:87