23 #include <dtkCoreSupport/dtkGlobal.h>
25 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
27 class axlFieldDiscretePrivate
31 QVector<int> arrayInt;
32 QVector<float> arrayFloat;
33 QVector<double> arrayDouble;
59 this->setObjectName(name);
87 qDebug() <<
"Setting scalar value on non scalar field.";
92 if(d->arrayInt.size() >= index+1 ){
93 d->arrayInt.replace(index, v1);
94 }
else if(d->arrayInt.size() == index){
95 d->arrayInt.push_back(v1);
97 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
100 if(d->arrayFloat.size() >= index+1 ){
101 d->arrayFloat.replace(index, v1);
102 }
else if(d->arrayFloat.size() == index){
103 d->arrayFloat.push_back(v1);
105 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
108 if(d->arrayDouble.size() >= index+1 ){
109 d->arrayDouble.replace(index, v1);
110 }
else if(d->arrayDouble.size() == index){
111 d->arrayDouble.push_back(v1);
113 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
116 qDebug() << Q_FUNC_INFO <<
"This type doesn't exists";
127 qDebug() <<
"Setting vector value on non vector field.";
137 if(d->arrayInt.size() >= 3*(index+1)){
138 d->arrayInt.replace(index, v1);
139 d->arrayInt.replace(index+1, v2);
140 d->arrayInt.replace(index+2, v3);
141 }
else if(d->arrayInt.size() == 3*index){
142 d->arrayInt.push_back(v1);
143 d->arrayInt.push_back(v2);
144 d->arrayInt.push_back(v3);
146 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
150 if(d->arrayFloat.size() >= 3*(index+1) ){
151 d->arrayFloat.replace(index, v1);
152 d->arrayFloat.replace(index+1, v2);
153 d->arrayFloat.replace(index+2, v3);
154 }
else if(d->arrayFloat.size() == 3*index){
155 d->arrayFloat.push_back(v1);
156 d->arrayFloat.push_back(v2);
157 d->arrayFloat.push_back(v3);
159 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
163 if(d->arrayDouble.size() >= 3*(index+1) ){
164 d->arrayDouble.replace(index, v1);
165 d->arrayDouble.replace(index+1, v2);
166 d->arrayDouble.replace(index+2, v3);
167 }
else if(d->arrayDouble.size() == 3*index){
168 d->arrayDouble.push_back(v1);
169 d->arrayDouble.push_back(v2);
170 d->arrayDouble.push_back(v3);
172 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
176 qDebug() << Q_FUNC_INFO <<
"This type doesn't exists";
189 qDebug() <<
"Setting tensor value on non tensor field.";
193 if(!(d->size%9 == 0) ){
194 qDebug() << Q_FUNC_INFO <<
"Error : cannot be divided by 9";
199 if(d->arrayInt.size() >= 9*(index+1)){
200 d->arrayInt.replace(index, v1);
201 d->arrayInt.replace(index+1, v2);
202 d->arrayInt.replace(index+2, v3);
203 d->arrayInt.replace(index+3, v4);
204 d->arrayInt.replace(index+4, v5);
205 d->arrayInt.replace(index+5, v6);
206 d->arrayInt.replace(index+6, v7);
207 d->arrayInt.replace(index+7, v8);
208 d->arrayInt.replace(index+8, v9);
209 }
else if(d->arrayInt.size() == 9*index){
210 d->arrayInt.push_back(v1);
211 d->arrayInt.push_back(v2);
212 d->arrayInt.push_back(v3);
213 d->arrayInt.push_back(v4);
214 d->arrayInt.push_back(v5);
215 d->arrayInt.push_back(v6);
216 d->arrayInt.push_back(v7);
217 d->arrayInt.push_back(v8);
218 d->arrayInt.push_back(v9);
221 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
225 if(d->arrayFloat.size() >= 9*(index+1) ){
226 d->arrayFloat.replace(index, v1);
227 d->arrayFloat.replace(index+1, v2);
228 d->arrayFloat.replace(index+2, v3);
229 d->arrayFloat.replace(index+3, v4);
230 d->arrayFloat.replace(index+4, v5);
231 d->arrayFloat.replace(index+5, v6);
232 d->arrayFloat.replace(index+6, v7);
233 d->arrayFloat.replace(index+7, v8);
234 d->arrayFloat.replace(index+8, v9);
235 }
else if(d->arrayFloat.size() == 9*index){
236 d->arrayFloat.push_back(v1);
237 d->arrayFloat.push_back(v2);
238 d->arrayFloat.push_back(v3);
239 d->arrayFloat.push_back(v4);
240 d->arrayFloat.push_back(v5);
241 d->arrayFloat.push_back(v6);
242 d->arrayFloat.push_back(v7);
243 d->arrayFloat.push_back(v8);
244 d->arrayFloat.push_back(v9);
246 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
250 if(d->arrayDouble.size() >= 9*(index+1) ){
251 d->arrayDouble.replace(index, v1);
252 d->arrayDouble.replace(index+1, v2);
253 d->arrayDouble.replace(index+2, v3);
254 d->arrayDouble.replace(index+3, v4);
255 d->arrayDouble.replace(index+4, v5);
256 d->arrayDouble.replace(index+5, v6);
257 d->arrayDouble.replace(index+6, v7);
258 d->arrayDouble.replace(index+7, v8);
259 d->arrayDouble.replace(index+8, v9);
260 }
else if(d->arrayDouble.size() == 9*index){
261 d->arrayDouble.push_back(v1);
262 d->arrayDouble.push_back(v2);
263 d->arrayDouble.push_back(v3);
264 d->arrayDouble.push_back(v4);
265 d->arrayDouble.push_back(v5);
266 d->arrayDouble.push_back(v6);
267 d->arrayDouble.push_back(v7);
268 d->arrayDouble.push_back(v8);
269 d->arrayDouble.push_back(v9);
272 qDebug() << Q_FUNC_INFO <<
"The array vector is not well filled";
276 qDebug() << Q_FUNC_INFO <<
"This type doesn't exists";
299 qDebug() <<
"Getting scalar value on non scalar field.";
304 return d->arrayInt.at(index);
306 return d->arrayFloat.at(index);
308 return d->arrayDouble.at(index);
310 qDebug() <<
"No return value.";
322 qDebug() <<
"Getting vector value on non vector field.";
326 double* result =
new double[3];
329 result[0] = d->arrayInt.at(index);
330 result[1] = d->arrayInt.at(index+1);
331 result[2] = d->arrayInt.at(index+2);
334 result[0] = d->arrayFloat.at(index);
335 result[1] = d->arrayFloat.at(index+1);
336 result[2] = d->arrayFloat.at(index+2);
339 result[0] = d->arrayDouble.at(index);
340 result[1] = d->arrayDouble.at(index+1);
341 result[2] = d->arrayDouble.at(index+2);
344 qDebug() <<
"No return value.";
356 qDebug() <<
"Getting tensor value on non tensor field.";
360 double* result =
new double[9];
363 result[0] = d->arrayInt.at(index);
364 result[1] = d->arrayInt.at(index+1);
365 result[2] = d->arrayInt.at(index+2);
366 result[3] = d->arrayInt.at(index+3);
367 result[4] = d->arrayInt.at(index+4);
368 result[5] = d->arrayInt.at(index+5);
369 result[6] = d->arrayInt.at(index+6);
370 result[7] = d->arrayInt.at(index+7);
371 result[8] = d->arrayInt.at(index+8);
374 result[0] = d->arrayFloat.at(index);
375 result[1] = d->arrayFloat.at(index+1);
376 result[2] = d->arrayFloat.at(index+2);
377 result[3] = d->arrayFloat.at(index+3);
378 result[4] = d->arrayFloat.at(index+4);
379 result[5] = d->arrayFloat.at(index+5);
380 result[6] = d->arrayFloat.at(index+6);
381 result[7] = d->arrayFloat.at(index+7);
382 result[8] = d->arrayFloat.at(index+8);
385 result[0] = d->arrayDouble.at(index);
386 result[1] = d->arrayDouble.at(index+1);
387 result[2] = d->arrayDouble.at(index+2);
388 result[3] = d->arrayDouble.at(index+3);
389 result[4] = d->arrayDouble.at(index+4);
390 result[5] = d->arrayDouble.at(index+5);
391 result[6] = d->arrayDouble.at(index+6);
392 result[7] = d->arrayDouble.at(index+7);
393 result[8] = d->arrayDouble.at(index+8);
396 qDebug() <<
"No return value.";
430 qDebug()<<
"axlFieldDiscrete::description";
435 qstr.append(
"Name : ");
436 qstr.append(this->objectName());
483 std::ostringstream oss;
489 qstr.append(
";Size : ");
491 qstr.append(QString::number(s));
503 return "axlFieldDiscrete";
dtkAbstractData * createaxlFieldDiscrete(void)
QString description(void) const
Returns the description of the field.
virtual void update(void)
Class axlAbstractFieldDiscrete defines an API for arrays of numeric data.
QString identifier(void) const
Returns the identifier "axlFieldDiscrete".
virtual void setVector(int index, double v1, double v2, double v3)
virtual ~axlFieldDiscrete(void)
Destroys the discrete field.
virtual void setScalar(int index, double v1)
static bool registered(void)
virtual void setSize(int size)
Class axlFieldDiscrete defines an API for arrays of numeric data.
virtual void setType(Type type)
Sets the type of the field which can be either int, float or double.
virtual double scalar(int index)
Returns the value at index location of the scalar array.
virtual void setSupport(Support support)
virtual void setTensor(int index, double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8, double v9)
virtual void setKind(Kind kind)
Sets the kind of the field which can be either scalar, vector or tensor.
virtual double * vector(int index)
Returns the value at index location of the vector array.
virtual double * tensor(int index)
Returns the value at index location of the tensor array.