Developer documentation | Axl-2.5.1

axlAbstractVolumeBSpline.cpp
Go to the documentation of this file.
1 /* axlAbstractVolumeBSpline.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2012 - Anais Ducoffe, Inria.
5  * Created:
6  * Version: $Id$
7  * Last-Updated:
8  * By:
9  * Update #:
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
21 
22 #include <dtkCoreSupport/dtkGlobal.h>
23 #include <QtCore/qmap.h>
24 #include <cmath>
25 #include <stdio.h>
26 
27 class axlAbstractVolumeBSplinePrivate
28 {
29 public:
30  QMap<axlPoint, double> scalar_values;// key axlPoint, value scalar
31  QHash<int, QList<int> >connect;
32 };
33 
35 {
36 
37 }
38 
40 {
41  delete d;
42  d = NULL;
43 }
44 
46 {
47  DTK_DEFAULT_IMPLEMENTATION;
48  return NULL;
49 }
50 
52 {
53  DTK_DEFAULT_IMPLEMENTATION;
54  return 0;
55 }
56 
58 {
59  DTK_DEFAULT_IMPLEMENTATION;
60  return 0;
61 }
62 
64 {
65  DTK_DEFAULT_IMPLEMENTATION;
66  return 0;
67 }
68 
70 {
71  DTK_DEFAULT_IMPLEMENTATION;
72  return 0;
73 }
74 
75 
77 {
78  DTK_DEFAULT_IMPLEMENTATION;
79  return 0;
80 }
81 
83 {
84  DTK_DEFAULT_IMPLEMENTATION;
85  return 0;
86 }
87 
89 {
90  DTK_DEFAULT_IMPLEMENTATION;
91  return 0;
92 }
93 
94 
96 {
97  DTK_DEFAULT_IMPLEMENTATION;
98  return 0;
99 }
100 
102 {
103  DTK_DEFAULT_IMPLEMENTATION;
104  return 0;
105 }
106 
108 {
109  DTK_DEFAULT_IMPLEMENTATION;
110  return 0;
111 }
112 
113 
115 {
116  DTK_DEFAULT_IMPLEMENTATION;
117  return 0;
118 }
119 
121 {
122  DTK_DEFAULT_IMPLEMENTATION;
123 }
124 
125 double axlAbstractVolumeBSpline::getCoord(int n, int m, int k, int v) const
126 {
127  DTK_DEFAULT_IMPLEMENTATION;
128  return 0;
129 }
130 
132 {
133  DTK_DEFAULT_IMPLEMENTATION;
134  return axlPoint();
135 }
136 
138 {
139  DTK_DEFAULT_IMPLEMENTATION;
140  DTK_UNUSED(n);
141  return axlPoint();
142 }
143 
144 double axlAbstractVolumeBSpline::getWeight(int n, int m, int k) const
145 {
146  DTK_DEFAULT_IMPLEMENTATION;
147  return 1.0;
148 }
149 
150 bool axlAbstractVolumeBSpline::setCoef(int n, int m, int k, int v, double c)
151 {
152  DTK_DEFAULT_IMPLEMENTATION;
153  return 0;
154 }
155 
156 bool axlAbstractVolumeBSpline::setCoef(int n, int m,int k, double *controlPoint)
157 {
158  DTK_DEFAULT_IMPLEMENTATION;
159  return 0;
160 }
161 
162 bool axlAbstractVolumeBSpline::setCoef(int n, double *controlPoint)
163 {
164  DTK_DEFAULT_IMPLEMENTATION;
165  return 0;
166 }
167 
169 {
170  DTK_DEFAULT_IMPLEMENTATION;
171  return 0;
172 }
173 
175 {
176  DTK_DEFAULT_IMPLEMENTATION;
177  return 0;
178 }
179 
181 {
182  DTK_DEFAULT_IMPLEMENTATION;
183  return 0;
184 }
185 
186 
188 {
189  DTK_DEFAULT_IMPLEMENTATION;
190  QVector<axlPoint *> qVect;
191  return qVect;
192 }
193 
194 void axlAbstractVolumeBSpline::gridEvaluator(int num_u, int num_v, int num_w, std::vector<double>& points,std::vector<double>& param_u, std::vector<double> &param_v, std::vector<double> &param_w)
195 {
196  DTK_DEFAULT_IMPLEMENTATION;
197 }
198 
199 void axlAbstractVolumeBSpline::setVolume(int pointsCount_u, int pointsCount_v,int pointsCount_w, int order_u, int order_v,int order_w, int dimension, double *knots_u, double *knots_v, double *knots_w,double *points, bool rational)
200 {
201  DTK_DEFAULT_IMPLEMENTATION;
202 }
203 
204 
206 {
207  Q_UNUSED(k);
208 }
209 
211 {
212  Q_UNUSED(k);
213 }
214 
216 {
217  Q_UNUSED(k);
218 }
219 
221 {
222  Q_UNUSED(k);
223 }
224 
226 {
227  Q_UNUSED(k);
228 }
229 
231 {
232  Q_UNUSED(k);
233 }
234 
235 QString axlAbstractVolumeBSpline::printCoeffs(bool print) const
236 {
237  DTK_DEFAULT_IMPLEMENTATION;
238  return "";
239 }
240 
242 {
243  DTK_DEFAULT_IMPLEMENTATION;
244  return "";
245 }
246 
248 {
249  DTK_DEFAULT_IMPLEMENTATION;
250  return "";
251 }
252 
253 double axlAbstractVolumeBSpline::scalarValue(double u, double v, double w)
254 {
255  axlPoint point;
256  point.setCoordinates(u,v,w);
257  return d->scalar_values.value(point);
258 }
259 
260 
261 void axlAbstractVolumeBSpline::setScalarValue(double u, double v,double w, double value)
262 {
263  axlPoint point;
264  point.setCoordinates(u,v,w);
265  d->scalar_values.insert(point, value);
266 }
267 
268 
270 
274  return !d->connect.isEmpty();
275 }
276 
278 
282 {
283  d->connect.clear();
284 }
285 
286 
288 
292  return d->connect.value(i);
293 }
294 
295 
297 
301  if(i==j){
302  qDebug() << "The two indices must be different.";
303  }else{
304  int mini = std::min(i,j);
305  int maxi = std::max(i,j);
306 
307  if(d->connect.keys().contains(mini)){
308  QList<int> list = d->connect.value(mini);
309 
310  if(!list.contains(maxi) ){
311  list << maxi;
312  d->connect.insert(mini, list);
313  }
314  }else{
315  QList<int> list;
316  list << maxi;
317  d->connect.insert(mini,list);
318  }
319  }
320 }
321 
322 
324  QVariantList list;
325  list.append(identifier());
326  QVariant nu = QVariant::fromValue(countControlPoints_u());
327  list.append(nu);
328  QVariant nv = QVariant::fromValue(countControlPoints_v());
329  list.append(nv);
330  QVariant nw = QVariant::fromValue(countControlPoints_w());
331  list.append(nw);
332  QVariant orderu = QVariant::fromValue(order_u());
333  list.append(orderu);
334  QVariant orderv = QVariant::fromValue(order_v());
335  list.append(orderv);
336  QVariant orderw = QVariant::fromValue(order_w());
337  list.append(orderw);
338  QVariant dimension = QVariant::fromValue(3);
339  list.append(dimension);
340  //append knots_u
341  for(int i = 0; i < nu.toInt()+ order_u();i++){
342  list.append(getKnot_u(i+1));
343  }
344  //append knots_v
345  for(int i = 0; i < nv.toInt()+ order_v();i++){
346  list.append(getKnot_v(i+1));
347  }
348  //append knots_w
349  for(int i = 0; i < nw.toInt()+ order_w();i++){
350  list.append(getKnot_w(i+1));
351  }
352  //append control points table
353  for(int i = 0; i < nu.toInt()*nv.toInt()*nw.toInt();i++){
354  list.append(getCoef(i+1).convertDataToQVariant());
355  }
356  QVariant name = QVariant::fromValue(objectName());
357  list.append(name);
358  return list;
359 }
360 
362  int nu = data.at(1).toInt();
363  int nv = data.at(2).toInt();
364  int nw = data.at(3).toInt();
365  int orderu = data.at(4).toInt();
366  int orderv = data.at(5).toInt();
367  int orderw = data.at(6).toInt();
368  int dimension = data.at(7).toInt();
369  //append knots_u
370  double *knotsU = new double[nu+orderu];
371  for(int i = 0; i < nu+orderu;i++){
372  knotsU[i] = data.at(i+8).toDouble();
373  //insertKnot_u(data.at(i+7).toDouble());
374  }
375  //append knots_v
376  double *knotsV = new double[nv+orderv];
377  for(int i = 0; i < nv+orderv;i++){
378  knotsV[i] = data.at(i+8 +nu+orderu).toDouble();
379  //insertKnot_v(data.at(i+8+nKu).toDouble());
380  }
381  //append knots_w
382  double *knotsW = new double[nw+orderw];
383  for(int i = 0; i < nw+orderw;i++){
384  knotsW[i] = data.at(i+8 +nu+orderu +nv+orderv).toDouble();
385  //insertKnot_v(data.at(i+8+nKu).toDouble());
386  }
387  //append control points table
388  int indice = 8 +nu+orderu +nv+orderv +nw+orderw;
389  double *CP = new double[3*nu*nv*nw];
390  for(int i = 0; i < nu*nv*nw;i++){
391  QVariantList list;
392  list.append(data.at(indice));
393  list.append(data.at(indice+1));
394  list.append(data.at(indice+2));
395  list.append(data.at(indice+3));
396  list.append(data.at(indice+4));
397  axlPoint* point = new axlPoint();
398  point->convertQVariantToData(list);
399  //double *controlPoint = point->coordinates();
400  CP[3*i] = point->x();
401  CP[3*i+1] = point->y();
402  CP[3*i+2] = point->z();
403  //setCoef(i,controlPoint);
404  indice = indice+5;
405  }
406  setVolume(nu,nv,nw ,orderu,orderv,orderw,dimension,knotsU, knotsV,knotsW,CP, false);// rational=false B-spline volume
407  setObjectName(data.last().toString());
408  return 1;
409 }
410 
411 
412 
413 
414 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
virtual double getKnot_v(int n) const
virtual void removeKnot_u(double k)
virtual int order_u(void) const
virtual int order_v(void) const
int convertQVariantToData(const QVariantList &data)
Modify properties and geometry variables of the axlAbstractData. Return 1 if the modification was suc...
virtual int countControlPoints_v(void) const
virtual void insertKnot_v(double k)
double scalarValue(double u, double v, double w)
virtual QString printCoeffs(bool print) const
QVariantList convertDataToQVariant(void) const
Convert an axlAbstractData into a QVariantList that specifies all properties of the axlAbstractData...
virtual int order_w(void) const
virtual axlPoint getCoef(int n, int m, int k) const
virtual void insertKnot_w(double k)
virtual int dimension(void) const
virtual int knotVectorSize_v(void) const
virtual void resetControlPointConnections(void)
Removes all control point connections.
virtual double getWeight(int n, int m, int k) const
virtual void insertKnot_u(double k)
virtual void removeKnot_v(double k)
virtual double getKnot_u(int n) const
void setScalarValue(double u, double v, double w, double value)
virtual int countControlPoints_u(void) const
virtual void gridEvaluator(int num_u, int num_v, int num_w, std::vector< double > &points, std::vector< double > &param_u, std::vector< double > &param_v, std::vector< double > &param_w)
virtual QVector< axlPoint * > sampling()
double y
Definition: axlPoint.h:37
virtual int knotVectorSize_w(void) const
virtual QString description(void) const
virtual int countControlPoints_w(void) const
virtual int countControlPoints(void) const
double z
Definition: axlPoint.h:38
virtual void removeKnot_w(double k)
virtual bool rational(void) const
virtual axlAbstractVolumeBSpline * copy(void) const
virtual bool connectionsAreDefined(void)
Return true if control points connections were defined by developers. False if there are default conn...
int convertQVariantToData(const QVariantList &data)
Modify properties and geometry variables of the axlAbstractData. Return 1 if the modification was suc...
Definition: axlPoint.cpp:588
virtual bool setCoef(int n, int m, int k, int v, double c)
double x
Definition: axlPoint.h:37
void setCoordinates(double x, double y, double z)
Change coordinates of this point.
Definition: axlPoint.cpp:370
virtual double getKnot_w(int n) const
virtual void defineControlPointConnection(int i, int j)
Define connection between the ith and the jth coefficient.
virtual double getCoord(int n, int m, int k, int v) const
virtual void setVolume(int pointsCount_u, int pointsCount_v, int pointsCount_w, int order_u, int order_v, int order_w, int dimension, double *knots_u, double *knots_v, double *knots_w, double *points, bool rational)
virtual int knotVectorSize_u(void) const
virtual QString printKnotsVector(bool print) const
virtual QList< int > getControlPointConnection(int i)
The list returned contains all indices of coefficients that are still to be connected to the ith coef...