Developer documentation | Axl-2.5.1

axlFieldParametricNormalVector.cpp
Go to the documentation of this file.
1 /* axlFieldParametricNormalVector.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 axlFieldParametricNormalVectorPrivate
31 {
32 public:
36 
38 };
39 
40 // /////////////////////////////////////////////////////////////////
41 // axlFieldParametricNormalVector implementation
42 // /////////////////////////////////////////////////////////////////
43 
45 
49 {
50  d->input = NULL;
51  this->setObjectName(this->identifier());
55 }
56 
57 
58 
60 
64 {
65  delete d;
66 
67  d = NULL;
68 }
69 
70 
72 
75 double *axlFieldParametricNormalVector::vector(double u, double v, double w)
76 {
77  if(!(this->kind() == Vector)) {
78  qDebug() << "Getting vector value on non vector field.";
79  return NULL;
80  }
81  axlMesh mesh = d->input->eval(u,v,1);
82  axlPoint *deriv1u = new axlPoint() ;
83  mesh.vertex(1, deriv1u);
84  axlPoint *deriv1v = new axlPoint();
85  mesh.vertex(2, deriv1v);
86  axlPoint *normalPoint = axlPoint::crossProduct(deriv1u, deriv1v);
87  double *normal = normalPoint->coordinates();
88  //qDebug() << Q_FUNC_INFO << u << " " <<v << " " << normal[0] << " " << normal[1]<<" " << normal[2] ;
89 
90  return normal;
91 
92 }
93 
94 
95 
97 
101 {
102  return "axlFieldParametricNormalVector";
103 }
104 
105 
107 
111 {
112  QString qstr;
113 
114  qstr.append("axlFieldParametricNormalVector : \n");
115  qstr.append("Type : Double ");
116  qstr.append(";Kind : Vector ");
117  qstr.append(";Support : Point");
118 
119 
120  return qstr;
121 
122 }
123 
124 
126 
130  if(dynamic_cast<axlAbstractSurfaceBSpline*>(data))
131  d->input = dynamic_cast<axlAbstractSurfaceBSpline*>(data);
132 }
133 
134 
136 
140 
141  return d->input->startParam_u();
142 
143 }
144 
145 
147 
151  return d->input->startParam_v();
152 }
153 
154 
156 
160 
161  return d->input->endParam_u();
162 }
163 
164 
166 
170 
171  return d->input->endParam_v();
172 }
173 
174 
175 
177 
181 
182  return d->input->numSamples_u();
183 }
184 
186 
190  return d->input->numSamples_v();
191 }
192 
193 
194 
196 
200  return d->input->numSamples_u()*d->input->numSamples_v();
201 }
202 
203 
204 
207 
211 {
212  emit updated();
213 }
214 
215 // /////////////////////////////////////////////////////////////////
216 // axlFieldParametricNormalVector documentation
217 // /////////////////////////////////////////////////////////////////
218 
225 // /////////////////////////////////////////////////////////////////
226 // Type instanciation
227 // /////////////////////////////////////////////////////////////////
228 
230 {
232 }
233 
234 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
int size(void)
Returns the number of values evaluated for this BSpline field on each samples of the input BSpline...
double start_v(void)
Returns the first parameter value of the field.
double * coordinates(void) const
Returns coordinates of this point.
Definition: axlPoint.cpp:445
double numbersample_v(void)
Returns the number of parameters.
axlMesh * mesh(void)
Return the mesh of that object is computed.
double end_v(void)
Returns the last parameter value of the field.
void setSurface(axlAbstractData *data)
Sets the BSpline on which the BSpline field is applied.
virtual Kind kind(void)
void vertex(const int &ind, double vertex[3])
set vertex values of vertices with index ind.
Definition: axlMesh.cpp:322
dtkAbstractData * createaxlFieldParametricNormalVector(void)
double end_u(void)
Returns the last parameter value of the field.
virtual void setType(Type type)
Sets the type of the field which can be either int, float or double.
Class axlFieldParametricNormalVector defines an API for field which owns a BSpline Surface as a funct...
double * vector(double u, double v, double w=0.)
Returns the value of the spatial field at the coordinates point entered.
virtual void setSupport(Support support)
double start_u(void)
Returns the first parameter value of the field.
Class axlAbstractFieldParametricSurface defines an API for parametric field.
static axlPoint crossProduct(const axlPoint &lhs, const axlPoint &rhs)
Returns the cross product between lhs (coords) and rhs (coords).
Definition: axlPoint.cpp:485
virtual void setKind(Kind kind)
Sets the kind of the field which can be either scalar, vector or tensor.
QString identifier(void) const
Returns the identifier of the field "axlFieldParametricNormalVector".
double numbersample_u(void)
Returns the number of parameters.
virtual ~axlFieldParametricNormalVector(void)
Destroys a Bspline field.
Class axlAbstractData defines an API for all type of axel data.
QString description(void) const
Returns the description of the field.
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41