Developer documentation | Axl-2.5.1

axlAbstractSurfaceParametric.cpp
Go to the documentation of this file.
1 /* axlAbstractSurfaceParametric.cpp ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Tue Nov 9 17:03:56 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Tue Mar 29 09:43:31 2011 (+0200)
8  * By: Julien Wintz
9  * Update #: 36
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
21 
22 #include "axlMesh.h"
23 
24 #include <dtkCoreSupport/dtkGlobal.h>
25 
26 //#include <axlCore/axlAbstractVisitor.h>
27 
28 
29 class axlAbstractSurfaceParametricPrivate
30 {
31 public:
32  int samples_u;
33  int samples_v;
34  QVector<axlPoint> samples;
35 
36  //public :
37  // axlAbstractVisitorParametric *visitor;
38 };
39 
42  d(new axlAbstractSurfaceParametricPrivate) {
43 
44  d->samples_u = 0;
45  d->samples_v = 0;
46  //d->visitor = NULL;
47 }
48 
50 {
51  delete d;
52 
53  d = NULL;
54 }
55 
57 {
58  DTK_DEFAULT_IMPLEMENTATION;
59  DTK_UNUSED(u);
60  DTK_UNUSED(v);
61 
62  return axlPoint();
63 }
64 
65 
66 //axlAbstractVisitorParametric *axlAbstractSurfaceParametric::getVisitor(void){
67 // return d->visitor;
68 //}
69 
70 //void axlAbstractSurfaceParametric::setVisistor(axlAbstractVisitorParametric *visitor){
71 // d->visitor = visitor;
72 
73 //}
74 
75 void axlAbstractSurfaceParametric::eval(axlPoint *point, double u,double v)
76 {
77  DTK_DEFAULT_IMPLEMENTATION;
78  DTK_UNUSED(point);
79  DTK_UNUSED(u);
80  DTK_UNUSED(v);
81 
82 }
83 
84 
85 void axlAbstractSurfaceParametric::eval(axlPoint *point, double u,double v, int numCell)
86 {
87  DTK_DEFAULT_IMPLEMENTATION;
88  DTK_UNUSED(point);
89  DTK_UNUSED(u);
90  DTK_UNUSED(v);
91  DTK_UNUSED(numCell);
92 
93 }
94 
95 void axlAbstractSurfaceParametric::eval(double& x, double& y, double& z, double u,double v)
96 {
97  DTK_DEFAULT_IMPLEMENTATION;
98  DTK_UNUSED(x);DTK_UNUSED(y);DTK_UNUSED(z);
99  DTK_UNUSED(u);DTK_UNUSED(v);
100 }
101 
102 dtkDeprecated::dtkVector3D<double> axlAbstractSurfaceParametric::eval2(double u, double v)
103 {
104  DTK_DEFAULT_IMPLEMENTATION;
105  DTK_UNUSED(u);
106  DTK_UNUSED(v);
107 
108  return dtkDeprecated::dtkVector3D<double>();
109 }
110 
111 axlMesh axlAbstractSurfaceParametric::eval(double u, double v, int derivs, bool u_from_right, bool v_from_right, double resolution)
112 {
113  DTK_DEFAULT_IMPLEMENTATION;
114  DTK_UNUSED(u);
115  DTK_UNUSED(v);
116 
117  DTK_UNUSED(derivs);
118  DTK_UNUSED(u_from_right);
119  DTK_UNUSED(v_from_right);
120  DTK_UNUSED(resolution);
121 
122  return axlMesh();
123 }
124 
125 
126 void axlAbstractSurfaceParametric::parameterOf(const axlPoint& point, double& um, double& vm) {
127 
128  unsigned N = 200;
129 
130  double x, y, z;
131 
132  if (d->samples.size() == 0) {
133 
134  double u = this->startParam_u();
135  double du = (this->endParam_u() - this->startParam_u())/N;
136 
137  double v = this->startParam_v();
138  double dv = (this->endParam_v() - this->startParam_v())/N;
139 
140  for (unsigned i = 0; i <= N; i++, u += du) {
141  v = this->startParam_v();
142  for (unsigned j = 0; j <= N; j++, v += dv) {
143  this->eval(x,y,z, u, v);
144  d->samples << axlPoint(x,y,z);
145  }
146  }
147  }
148 
149  int m = 0;
150  double dm = axlPoint::distance(d->samples.at(0), point);
151  double dd = dm;
152  for (int k = 0; k < d->samples.size(); k++) {
153  if ((dd = axlPoint::distance(d->samples.at(k), point)) < dm) {
154  dm = dd;
155  m = k;
156  }
157  }
158 
159  um = this->startParam_u() + (this->endParam_u() - this->startParam_u())/N * (m/(N+1));
160  vm = this->startParam_v() + (this->endParam_v() - this->startParam_v())/N * (m%(N+1));
161 
162  dtkWarn() << "Closest parameter point:" << um << vm << "for" << point.x() << point.y() << point.z();
163 }
164 
165 
166 dtkDeprecated::dtkVector3D<double> axlAbstractSurfaceParametric::normal(double u, double v)
167 {
168  DTK_DEFAULT_IMPLEMENTATION;
169  DTK_UNUSED(u);
170  DTK_UNUSED(v);
171 
172  return dtkDeprecated::dtkVector3D<double>();
173 }
174 
175 void axlAbstractSurfaceParametric::normal(axlPoint *normal, double u,double v)
176 {
177  DTK_DEFAULT_IMPLEMENTATION;
178  DTK_UNUSED(normal);
179  DTK_UNUSED(u);
180  DTK_UNUSED(v);
181 
182 }
183 
184 void axlAbstractSurfaceParametric::normal(axlPoint *normal, double u,double v, int numCell)
185 {
186  DTK_DEFAULT_IMPLEMENTATION;
187  DTK_UNUSED(normal);
188  DTK_UNUSED(u);
189  DTK_UNUSED(v);
190  DTK_UNUSED(numCell);
191 
192 }
193 
194 void axlAbstractSurfaceParametric::normal(dtkDeprecated::dtkVector3D<double> *normal, double u,double v)
195 {
196  DTK_DEFAULT_IMPLEMENTATION;
197  DTK_UNUSED(normal);
198  DTK_UNUSED(u);
199  DTK_UNUSED(v);
200 
201 }
202 
203 
205 {
206  DTK_DEFAULT_IMPLEMENTATION;
207  DTK_UNUSED(tol);
208 
209  return 0;
210 }
211 
213 {
214  DTK_DEFAULT_IMPLEMENTATION;
215 
216  return 0.;
217 }
218 
220 {
221  DTK_DEFAULT_IMPLEMENTATION;
222 
223  return 1.;
224 }
225 
227 {
228  DTK_DEFAULT_IMPLEMENTATION;
229 
230  return 0.;
231 }
232 
234 {
235  DTK_DEFAULT_IMPLEMENTATION;
236 
237  return 1.;
238 }
239 
240 
242 {
243  DTK_DEFAULT_IMPLEMENTATION;
244 
245  return 0.;
246 }
247 
249 {
250  DTK_DEFAULT_IMPLEMENTATION;
251 
252  return 1.;
253 }
254 
256 {
257  DTK_DEFAULT_IMPLEMENTATION;
258 
259  return 0.;
260 }
261 
263 {
264  DTK_DEFAULT_IMPLEMENTATION;
265 
266  return 1.;
267 }
268 
270  DTK_DEFAULT_IMPLEMENTATION;
271  return false;
272 }
273 
275  DTK_DEFAULT_IMPLEMENTATION;
276  return 1;
277 }
278 
279 
280 
282 {
283  DTK_DEFAULT_IMPLEMENTATION;
284 
285  return 0;
286 }
287 
289 {
290  DTK_DEFAULT_IMPLEMENTATION;
291  DTK_UNUSED(numCell);
292 
293  return 0;
294 }
295 
297 {
298  DTK_DEFAULT_IMPLEMENTATION;
299 
300  return 0;
301 }
302 
304 {
305  DTK_DEFAULT_IMPLEMENTATION;
306  DTK_UNUSED(numCell);
307 
308  return 0;
309 }
310 
311 
312 
314 {
315  DTK_DEFAULT_IMPLEMENTATION;
316  DTK_UNUSED(numSamples);
317 }
318 
320 {
321  DTK_DEFAULT_IMPLEMENTATION;
322 
323  return 0;
324 }
325 
327 {
328  DTK_DEFAULT_IMPLEMENTATION;
329  DTK_UNUSED(stripes);
330 }
331 
332 
334 {
335  DTK_DEFAULT_IMPLEMENTATION;
336  DTK_UNUSED(numSamples);
337 }
338 
340 {
341  return d->samples_u;
342 }
343 
344 
346 {
347  d->samples_u = samples;
348 }
349 
351 {
352  return d->samples_v;
353 }
354 
355 
357 {
358  d->samples_v = samples;
359 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
virtual dtkDeprecated::dtkVector3D< double > eval2(double u, double v)
virtual void setNumSamples_v(int numSamples)
virtual axlPoint eval(double u, double v)
virtual void normal(axlPoint *normal, double u, double v)
virtual void parameterOf(const axlPoint &point, double &um, double &vm)
double y
Definition: axlPoint.h:37
double z
Definition: axlPoint.h:38
static double distance(const axlPoint &lhs, const axlPoint &rhs)
Returns the distance between lhs point and rhs point.
Definition: axlPoint.cpp:459
double x
Definition: axlPoint.h:37
virtual void setNumSamples_u(int numSamples)
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41