~ubuntu-branches/debian/sid/coin2/sid

« back to all changes in this revision

Viewing changes to src/fields/SoMFVec4b.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-06-28 02:38:17 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080628023817-lgrh0u677j1gcqgf
Tags: 2.5.0-2
* debian/control: Change suggests from libopenal0 to libopenal0a.
  Closes: #488001.  Change ${Source-Version} to ${binary:Version}.
  Update to standards version 3.8.0.

* debian/rules: Do not ignore errors in clean rule.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************\
 
2
 *
 
3
 *  This file is part of the Coin 3D visualization library.
 
4
 *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
 
5
 *
 
6
 *  This library is free software; you can redistribute it and/or
 
7
 *  modify it under the terms of the GNU General Public License
 
8
 *  ("GPL") version 2 as published by the Free Software Foundation.
 
9
 *  See the file LICENSE.GPL at the root directory of this source
 
10
 *  distribution for additional information about the GNU GPL.
 
11
 *
 
12
 *  For using Coin with software that can not be combined with the GNU
 
13
 *  GPL, and for taking advantage of the additional benefits of our
 
14
 *  support services, please contact Systems in Motion about acquiring
 
15
 *  a Coin Professional Edition License.
 
16
 *
 
17
 *  See http://www.coin3d.org/ for more information.
 
18
 *
 
19
 *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
 
20
 *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
 
21
 *
 
22
\**************************************************************************/
 
23
 
 
24
/*!
 
25
  \class SoMFVec4b SoMFVec4b.h Inventor/fields/SoMFVec4b.h
 
26
  \brief The SoMFVec4b class is a container for SbVec4b vectors.
 
27
  \ingroup fields
 
28
 
 
29
  This field is used where nodes, engines or other field containers
 
30
  needs to store an array of vectors with four elements.
 
31
 
 
32
  This field supports application data sharing through a
 
33
  setValuesPointer() method. See SoMField documentation for
 
34
  information on how to use this function.
 
35
 
 
36
  \sa SbVec4b, SoSFVec4b
 
37
  \since Coin 2.5
 
38
*/
 
39
 
 
40
// *************************************************************************
 
41
 
 
42
#include <Inventor/fields/SoMFVec4b.h>
 
43
 
 
44
#include <assert.h>
 
45
#include <Inventor/fields/SoSubFieldP.h>
 
46
#include <Inventor/SoInput.h>
 
47
#include <Inventor/errors/SoDebugError.h>
 
48
 
 
49
#include "shared.h"
 
50
 
 
51
// *************************************************************************
 
52
 
 
53
SO_MFIELD_SOURCE(SoMFVec4b, SbVec4b, SbVec4b);
 
54
 
 
55
SO_MFIELD_SETVALUESPOINTER_SOURCE(SoMFVec4b, SbVec4b, SbVec4b);
 
56
SO_MFIELD_SETVALUESPOINTER_SOURCE(SoMFVec4b, SbVec4b, int8_t);
 
57
 
 
58
// *************************************************************************
 
59
 
 
60
// Override from parent class.
 
61
void
 
62
SoMFVec4b::initClass(void)
 
63
{
 
64
  SO_MFIELD_INTERNAL_INIT_CLASS(SoMFVec4b);
 
65
}
 
66
 
 
67
// *************************************************************************
 
68
 
 
69
// No need to document readValue() and writeValue() here, as the
 
70
// necessary information is provided by the documentation of the
 
71
// parent classes.
 
72
#ifndef DOXYGEN_SKIP_THIS
 
73
 
 
74
SbBool
 
75
SoMFVec4b::read1Value(SoInput * in, int idx)
 
76
{
 
77
  assert(idx < this->maxNum);
 
78
  return 
 
79
    in->readByte(this->values[idx][0]) &&
 
80
    in->readByte(this->values[idx][1]) &&
 
81
    in->readByte(this->values[idx][2]) &&
 
82
    in->readByte(this->values[idx][3]);
 
83
}
 
84
 
 
85
void
 
86
SoMFVec4b::write1Value(SoOutput * out, int idx) const
 
87
{
 
88
  sosfvec4b_write_value(out, (*this)[idx]);
 
89
}
 
90
 
 
91
#endif // DOXYGEN_SKIP_THIS
 
92
 
 
93
// *************************************************************************
 
94
 
 
95
/*!
 
96
  Set \a num vector array elements from \a xyzw, starting at index
 
97
  \a start.
 
98
*/
 
99
void
 
100
SoMFVec4b::setValues(int start, int numarg, const int8_t xyzw[][4])
 
101
{
 
102
  if(start+numarg > this->maxNum) this->allocValues(start+numarg);
 
103
  else if(start+numarg > this->num) this->num = start+numarg;
 
104
 
 
105
  for(int i=0; i < numarg; i++) this->values[i+start].setValue(xyzw[i]);
 
106
  this->valueChanged();
 
107
}
 
108
 
 
109
/*!
 
110
  Set the vector at \a idx.
 
111
*/
 
112
void
 
113
SoMFVec4b::set1Value(int idx, int8_t x, int8_t y, int8_t z, int8_t w)
 
114
{
 
115
  this->set1Value(idx, SbVec4b(x, y, z, w));
 
116
}
 
117
 
 
118
/*!
 
119
  Set the vector at \a idx.
 
120
*/
 
121
void
 
122
SoMFVec4b::set1Value(int idx, const int8_t xyzw[4])
 
123
{
 
124
  this->set1Value(idx, SbVec4b(xyzw));
 
125
}
 
126
 
 
127
/*!
 
128
  Set this field to contain a single vector with the given
 
129
  element values.
 
130
*/
 
131
void
 
132
SoMFVec4b::setValue(int8_t x, int8_t y, int8_t z, int8_t w)
 
133
{
 
134
  this->setValue(SbVec4b(x,y,z,w));
 
135
}
 
136
 
 
137
/*!
 
138
  Set this field to contain a single vector with the given
 
139
  element values.
 
140
*/
 
141
void
 
142
SoMFVec4b::setValue(const int8_t xyzw[4])
 
143
{
 
144
  if (xyzw == NULL) this->setNum(0);
 
145
  else this->setValue(SbVec4b(xyzw));
 
146
}
 
147
 
 
148
// *************************************************************************