Developer documentation | Axl-2.5.1

axlFieldParametricSurface.cpp
Go to the documentation of this file.
1 /* axlFieldParametricSurface.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013 - Anais Ducoffe, Inria.
5  */
6 
7 /* Commentary:
8  *
9  */
10 
11 /* Change log:
12  *
13  */
14 #include <sstream>
15 
17 #include "axlAbstractProcess.h"
18 
19 #include <dtkCoreSupport/dtkGlobal.h>
20 
21 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
22 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
23 
26 
27 class axlFieldParametricSurfacePrivate
28 {
29 public:
33 
36 };
37 
38 // /////////////////////////////////////////////////////////////////
39 // axlFieldParametricSurface implementation
40 // /////////////////////////////////////////////////////////////////
41 
43 
47 {
48  d->input = NULL;
49  d->function = NULL;
50  this->setObjectName(this->identifier());
51 }
52 
53 
54 
56 
60 {
61  delete d;
62 
63  d = NULL;
64 }
65 
66 
67 
70 // *
71 // */
72 //void axlFieldParametricSurface::setType(axlFieldParametricSurface::Type type)
73 //{
74 
75 // d->type = type;
76 //}
77 
80 // *
81 // */
82 //void axlFieldParametricSurface::setKind(axlFieldParametricSurface::Kind kind)
83 //{
84 
85 // d->kind = kind;
86 //}
87 
90 // *
91 // */
92 //void axlFieldParametricSurface::setSupport(axlFieldParametricSurface::Support support)
93 //{
94 // d->support = support;
95 //}
96 
97 
98 //axlFieldParametricSurface::Type axlFieldParametricSurface::type(void)
99 //{
100 // return d->type;
101 //}
102 
103 //axlFieldParametricSurface::Kind axlFieldParametricSurface::kind(void)
104 //{
105 // return d->kind;
106 //}
107 
108 //axlFieldParametricSurface::Support axlFieldParametricSurface::support(void)
109 //{
110 // return d->support;
111 //}
112 
114 
117 double axlFieldParametricSurface::scalar(double u, double v, double w)
118 {
119  if(!(this->kind() == Scalar)) {
120  qDebug() << "Getting scalar value on non scalar field.";
121  return 0;
122  }
123  if(d->function){
124  return d->function->eval(u,v).x();
125  } else
126  return 0;
127 }
128 
130 
133 double *axlFieldParametricSurface::vector(double u, double v, double w)
134 {
135  if(!(this->kind() == Vector)) {
136  qDebug() << "Getting vector value on non vector field.";
137  return NULL;
138  }
139  return d->function->eval(u,v).coordinates();
140 
141 }
142 
144 
147 double *axlFieldParametricSurface::tensor(double u, double v, double w)
148 {
149  if(!(this->kind() == Tensor)) {
150  qDebug() << "Getting tensor value on non tensor field.";
151  return NULL;
152  }
153  // TO DO
154  return NULL;
155 }
156 
159 // *
160 // */
161 //QString axlFieldParametricSurface::name(void)
162 //{
163 // return this->objectName() ;
164 //}
165 
168 // *
169 // */
170 //void axlFieldParametricSurface::setName(QString name)
171 //{
172 // this->setObjectName(name);
173 
174 //}
175 
176 
178 
182 {
183  return "axlFieldParametricSurface";
184 }
185 
187 
191 {
192  QString qstr;
193 
194  qstr.append("axlFieldParametricSurface : \n");
195 
196  switch(d->type){
198  qstr.append("Type : integer");
199  break;
201  qstr.append("Type : Float");
202  break;
204  qstr.append("Type : Double");
205  break;
206  default:
207  qDebug() << "Unsupported field type";
208  }
209 
210 
211  switch(d->kind) {
213  qstr.append(";Kind : Scalar");
214  break;
216  qstr.append(";Kind : Vector");
217  break;
219  qstr.append(";Kind : Tensor");
220  break;
221  default:
222  qDebug() << ";Unsupported field kind";
223  }
224 
225  switch(d->support) {
227  qstr.append(";Support : Point");
228  break;
230  qstr.append(";Support : Cell");
231  break;
233  qstr.append(";Support : Custom");
234  break;
235  default:
236  qDebug() << ";No support";
237  }
238 
239  return qstr;
240 
241 }
242 
244 
248  qDebug() << Q_FUNC_INFO << 1;
249  if(dynamic_cast<axlAbstractSurfaceParametric*>(data)){
250  qDebug() << Q_FUNC_INFO << 2;
251  d->function = dynamic_cast<axlAbstractSurfaceParametric*>(data);
252  }
253 }
254 
255 
257 
261  return d->function;
262 }
263 
265 
269  if(dynamic_cast<axlAbstractSurfaceBSpline*>(data))
270  d->input = dynamic_cast<axlAbstractSurfaceBSpline*>(data);
271 }
272 
273 
275 
279 
280  return d->input->startParam_u();
281 
282 }
283 
284 
286 
290  return d->input->startParam_v();
291 }
292 
293 
295 
299 
300  return d->input->endParam_u();
301 }
302 
303 
305 
309 
310  return d->input->endParam_v();
311 }
312 
313 
314 
316 
320 
321  return d->input->numSamples_u();
322 }
323 
325 
329  return d->input->numSamples_v();
330 }
331 
332 
333 
335 
339  return d->input->numSamples_u()*d->input->numSamples_v();
340 }
341 
342 
343 
346 
350 {
351  emit updated();
352 }
353 
354 // /////////////////////////////////////////////////////////////////
355 // axlFieldParametricSurface documentation
356 // /////////////////////////////////////////////////////////////////
357 
364 // /////////////////////////////////////////////////////////////////
365 // Type instanciation
366 // /////////////////////////////////////////////////////////////////
367 
368 dtkAbstractData *createaxlFieldParametricSurface(void)
369 {
370  return new axlFieldParametricSurface;
371 }
372 
373 
double numbersample_u(void)
Returns the number of parameters.
double end_v(void)
Returns the last parameter value of the field.
Class axlFieldParametricSurface defines an API for field which owns a BSpline Surface as a function a...
int size(void)
Returns the number of values evaluated for this BSpline field on each samples of the input BSpline...
axlAbstractData * getFunction(void)
Returns the Bspline function which determines the values of the parametric field. ...
void setSurface(axlAbstractData *data)
Sets the BSpline on which the BSpline field is applied.
double start_u(void)
Returns the first parameter value of the field.
virtual double * tensor(double u, double v, double w=0)
Returns the value of the spatial field at the coordinates point entered.
virtual QString identifier(void) const
Returns the identifier of the field "axlFieldParametricSurface".
virtual ~axlFieldParametricSurface(void)
Destroys a Bspline field.
virtual Kind kind(void)
void setFunction(axlAbstractData *data)
Sets the Bspline function which determines the values of the parametric field.
double end_u(void)
Returns the last parameter value of the field.
virtual double scalar(double u, double v, double w=0)
Returns the value of the spatial field at the coordinates point entered.
double start_v(void)
Returns the first parameter value of the field.
dtkAbstractData * createaxlFieldParametricSurface(void)
virtual double * vector(double u, double v, double w=0)
Returns the value of the spatial field at the coordinates point entered.
double numbersample_v(void)
Returns the number of parameters.
virtual QString description(void) const
Returns the description of the field.
Class axlAbstractFieldParametricSurface defines an API for parametric field.
Class axlAbstractData defines an API for all type of axel data.