Developer documentation | Axl-2.5.1

axlFieldParametricVolumeTangentVector.cpp
Go to the documentation of this file.
1 /* axlFieldParametricVolumeTangentVector.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 "axlPoint.h"
20 #include "axlMesh.h"
21 
22 #include <dtkCoreSupport/dtkGlobal.h>
23 
24 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
25 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
26 
28 
29 class axlFieldParametricVolumeTangentVectorPrivate
30 {
31 public:
35 
37 
38  //some direction parameters
39  double a;
40  double b;
41  double c;
42 };
43 
44 // /////////////////////////////////////////////////////////////////
45 // axlFieldParametricVolumeTangentVector implementation
46 // /////////////////////////////////////////////////////////////////
47 
49 
53 {
54  d->input = NULL;
55  this->setObjectName(this->identifier());
59  d->a = 0;
60  d->b = 0;
61  d->c = 0;
62 
63 
64 }
65 
66 
67 
69 
73 {
74  delete d;
75 
76  d = NULL;
77 }
78 
79 
81 
84 double *axlFieldParametricVolumeTangentVector::vector(double u, double v, double w)
85 {
86  // qDebug() << Q_FUNC_INFO << 1;
87  // if(!(this->kind() == Vector)) {
88  // qDebug() << "Getting vector value on non vector field.";
89  // return NULL;
90  // }
91  axlMesh mesh = d->input->eval(u,v,w,1);
92  //qDebug() << Q_FUNC_INFO << 2 << " "<< mesh.size();
93  axlPoint *deriv1u = new axlPoint() ;
94  mesh.vertex(1, deriv1u);
95  axlPoint *deriv1v = new axlPoint();
96  mesh.vertex(2, deriv1v);
97  axlPoint *deriv1w = new axlPoint();
98  mesh.vertex(3, deriv1w);
99 
100 
101  double x = d->a*deriv1u->x() + d->b*deriv1v->x() + d->c*deriv1w->x();
102  double y = d->a*deriv1u->y() + d->b*deriv1v->y()+ d->c*deriv1w->y();
103  double z = d->a*deriv1u->z() + d->b*deriv1v->z()+ d->c*deriv1w->z();
104  double *tangentTab = new double[3];
105  tangentTab[0] = x;
106  tangentTab[1] = y;
107  tangentTab[2] = z;
108 
109  //qDebug() << Q_FUNC_INFO << tangentTab[0] << " " << tangentTab[1] << " "<< tangentTab[2];
110  return tangentTab;
111 
112 }
113 
114 
115 
117 
121 {
122  return "axlFieldParametricVolumeTangentVector";
123 }
124 
125 
127 
131 {
132  QString qstr;
133 
134  qstr.append("axlFieldParametricVolumeTangentVector : \n");
135  qstr.append("Type : Double ");
136  qstr.append(";Kind : Vector ");
137  qstr.append(";Support : Point");
138 
139 
140  return qstr;
141 
142 }
143 
144 
146 
150  if(dynamic_cast<axlAbstractVolumeParametric*>(data))
151  d->input = dynamic_cast<axlAbstractVolumeParametric*>(data);
152 }
153 
154 
156 
159 void axlFieldParametricVolumeTangentVector::setParameter(double parameter, int channel){
160  if(channel == 0)
161  d->a = parameter;
162  else if(channel == 1)
163  d->b = parameter;
164  else if(channel ==2)
165  d->c = parameter;
166  else
167  qDebug() << "only three possible channel values : 0 to 2";
168 }
169 
171 
175  if(channel == 0)
176  return d->a;
177  else if(channel == 1)
178  return d->b;
179  else if(channel ==2)
180  return d->c;
181  else {
182  qDebug() << "only three possible channel values : 0 to 2";
183  return -1;
184  }
185 }
186 
187 
189 
193 
194  return d->input->startParam_u();
195 
196 }
197 
198 
200 
204  return d->input->startParam_v();
205 }
206 
208 
212  return d->input->startParam_w();
213 }
214 
215 
216 
218 
222 
223  return d->input->endParam_u();
224 }
225 
226 
228 
232 
233  return d->input->endParam_v();
234 }
235 
236 
237 
239 
243 
244  return d->input->endParam_w();
245 }
246 
247 
248 
250 
254 
255  return d->input->numSamples_u();
256 }
257 
259 
263  return d->input->numSamples_v();
264 }
265 
266 
268 
272  return d->input->numSamples_w();
273 }
274 
275 
277 
281  return d->input->numSamples_u()*d->input->numSamples_v()*d->input->numSamples_w();
282 }
283 
284 
285 
288 
292 {
293  emit updated();
294 }
295 
296 // /////////////////////////////////////////////////////////////////
297 // axlFieldParametricVolumeTangentVector documentation
298 // /////////////////////////////////////////////////////////////////
299 
306 // /////////////////////////////////////////////////////////////////
307 // Type instanciation
308 // /////////////////////////////////////////////////////////////////
309 
311 {
313 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
double end_v(void)
Returns the last parameter value of the field.
double start_w(void)
Returns the first parameter value of the field.
double end_w(void)
Returns the last parameter value of the field.
double start_v(void)
Returns the first parameter value of the field.
double numbersample_v(void)
Returns the number of parameters.
double end_u(void)
Returns the last parameter value of the field.
double start_u(void)
Returns the first parameter value of the field.
void setParameter(double parameter, int channel)
Sets the direction parameter for the tangentVector.
double numbersample_w(void)
Returns the number of parameters.
QString identifier(void) const
Returns the identifier of the field "axlFieldParametricVolumeTangentVector".
QString description(void) const
Returns the description of the field.
int size(void)
Returns the number of values evaluated for this BSpline field on each samples of the input BSpline...
axlMesh * mesh(void)
Return the mesh of that object is computed.
double * vector(double u, double v, double w)
Returns the value of the spatial field at the coordinates point entered.
dtkAbstractData * createaxlFieldParametricVolumeTangentVector(void)
double numbersample_u(void)
Returns the number of parameters.
void setVolume(axlAbstractData *data)
Sets the BSpline on which the BSpline field is applied.
void vertex(const int &ind, double vertex[3])
set vertex values of vertices with index ind.
Definition: axlMesh.cpp:322
virtual ~axlFieldParametricVolumeTangentVector(void)
Destroys a Bspline field.
double y
Definition: axlPoint.h:37
virtual void setType(Type type)
Sets the type of the field which can be either int, float or double.
Class axlAbstractFieldParametricVolume defines an API for parametric field.
virtual void setSupport(Support support)
double z
Definition: axlPoint.h:38
virtual void setKind(Kind kind)
Sets the kind of the field which can be either scalar, vector or tensor.
double x
Definition: axlPoint.h:37
double parameter(int channel)
Returns the direction parameter for the tangentVector, the channel-th one.
Class axlAbstractData defines an API for all type of axel data.
Class axlFieldParametricVolumeTangentVector defines an API for field which owns a BSpline Surface as ...
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41