Developer documentation | Axl-2.5.1

axlFieldParametricSurfaceTangentVector.cpp
Go to the documentation of this file.
1 /* axlFieldParametricSurfaceTangentVector.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 
29 
30 class axlFieldParametricSurfaceTangentVectorPrivate
31 {
32 public:
36 
38 
39  //some direction parameters
40  double a;
41  double b;
42 };
43 
44 // /////////////////////////////////////////////////////////////////
45 // axlFieldParametricSurfaceTangentVector implementation
46 // /////////////////////////////////////////////////////////////////
47 
49 
53 {
54  d->input = NULL;
55  this->setObjectName(this->identifier());
59  d->a = 0;
60  d->b = 0;
61 
62 
63 }
64 
65 
66 
68 
72 {
73  delete d;
74 
75  d = NULL;
76 }
77 
78 
80 
83 double *axlFieldParametricSurfaceTangentVector::vector(double u, double v, double w)
84 {
85  if(!(this->kind() == Vector)) {
86  qDebug() << "Getting vector value on non vector field.";
87  return NULL;
88  }
89  axlMesh mesh = d->input->eval(u,v,1);
90  axlPoint *deriv1u = new axlPoint() ;
91  mesh.vertex(1, deriv1u);
92  axlPoint *deriv1v = new axlPoint();
93  mesh.vertex(2, deriv1v);
94 
95  axlPoint tangent = new axlPoint();
96  double x = d->a*deriv1u->x() + d->b*deriv1v->x();
97  double y = d->a*deriv1u->y() + d->b*deriv1v->y();
98  double z = d->a*deriv1u->z() + d->b*deriv1v->z();
99  tangent.setCoordinates(x,y,z);
100 
101 
102  return tangent.coordinates();
103 
104 }
105 
106 
107 
109 
113 {
114  return "axlFieldParametricSurfaceTangentVector";
115 }
116 
117 
119 
123 {
124  QString qstr;
125 
126  qstr.append("axlFieldParametricSurfaceTangentVector : \n");
127  qstr.append("Type : Double ");
128  qstr.append(";Kind : Vector ");
129  qstr.append(";Support : Point");
130 
131 
132  return qstr;
133 
134 }
135 
136 
138 
142  if(dynamic_cast<axlAbstractSurfaceBSpline*>(data))
143  d->input = dynamic_cast<axlAbstractSurfaceBSpline*>(data);
144 }
145 
146 
148 
151 void axlFieldParametricSurfaceTangentVector::setParameter(double parameter, int channel){
152  if(channel == 0)
153  d->a = parameter;
154  else if(channel == 1)
155  d->b = parameter;
156  else
157  qDebug() << "only two possible channel values : 0 and 1";
158 }
159 
161 
165  if(channel == 0)
166  return d->a;
167  else if(channel == 1)
168  return d->b;
169  else {
170  qDebug() << "channel has only two values : 0 and 1.";
171  return -1;
172  }
173 
174 }
175 
176 
178 
182 
183  return d->input->startParam_u();
184 
185 }
186 
187 
189 
193  return d->input->startParam_v();
194 }
195 
196 
198 
202 
203  return d->input->endParam_u();
204 }
205 
206 
208 
212 
213  return d->input->endParam_v();
214 }
215 
216 
217 
219 
223 
224  return d->input->numSamples_u();
225 }
226 
228 
232  return d->input->numSamples_v();
233 }
234 
235 
236 
238 
242  return d->input->numSamples_u()*d->input->numSamples_v();
243 }
244 
245 
246 
249 
253 {
254  emit updated();
255 }
256 
257 // /////////////////////////////////////////////////////////////////
258 // axlFieldParametricSurfaceTangentVector documentation
259 // /////////////////////////////////////////////////////////////////
260 
267 // /////////////////////////////////////////////////////////////////
268 // Type instanciation
269 // /////////////////////////////////////////////////////////////////
270 
272 {
274 }
double end_u(void)
Returns the last parameter value of the field.
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
dtkAbstractData * createaxlFieldParametricSurfaceTangentVector(void)
double * vector(double u, double v, double w=0.)
Returns the value of the spatial field at the coordinates point entered.
double * coordinates(void) const
Returns coordinates of this point.
Definition: axlPoint.cpp:445
double numbersample_v(void)
Returns the number of parameters.
double parameter(int channel)
Returns the direction parameter for the tangentVector, for the channel-th.
QString identifier(void) const
Returns the identifier of the field "axlFieldParametricSurfaceTangentVector".
QString description(void) const
Returns the description of the field.
axlMesh * mesh(void)
Return the mesh of that object is computed.
virtual Kind kind(void)
double start_u(void)
Returns the first parameter value of the field.
double start_v(void)
Returns the first parameter value of the field.
void vertex(const int &ind, double vertex[3])
set vertex values of vertices with index ind.
Definition: axlMesh.cpp:322
virtual ~axlFieldParametricSurfaceTangentVector(void)
Destroys a Bspline field.
int size(void)
Returns the number of values evaluated for this BSpline field on each samples of the input BSpline...
Class axlFieldParametricSurfaceTangentVector defines an API for field which owns a BSpline Surface as...
void setSurface(axlAbstractData *data)
Sets the BSpline on which the BSpline field is applied.
void setParameter(double parameter, int channel)
Sets the direction parameter for the tangentVector.
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.
double end_v(void)
Returns the last parameter value of the field.
virtual void setSupport(Support support)
double z
Definition: axlPoint.h:38
double numbersample_u(void)
Returns the number of parameters.
Class axlAbstractFieldParametricSurface defines an API for parametric field.
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
void setCoordinates(double x, double y, double z)
Change coordinates of this point.
Definition: axlPoint.cpp:370
Class axlAbstractData defines an API for all type of axel data.
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41