Developer documentation | Axl-2.5.1

axlAbstractSurfaceBSpline.cpp
Go to the documentation of this file.
1 /* axlAbstractSurfaceBSpline.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: Fri Apr 8 13:45:39 2011 (+0200)
8  * By: Julien Wintz
9  * Update #: 31
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
21 
22 #include <dtkCoreSupport/dtkGlobal.h>
23 
24 #include <cmath>
25 #include <stdio.h>
26 
27 class axlAbstractSurfaceBSplinePrivate
28 {
29 public:
30  QMap<QPair<double, double>, double> scalar_values;
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 
69 
71 {
72  DTK_DEFAULT_IMPLEMENTATION;
73  return 0;
74 }
75 
77 {
78  DTK_DEFAULT_IMPLEMENTATION;
79  return 0;
80 }
81 
82 
84 {
85  DTK_DEFAULT_IMPLEMENTATION;
86  return 0;
87 }
88 
90 {
91  DTK_DEFAULT_IMPLEMENTATION;
92  return 0;
93 }
94 
95 
97 {
98  DTK_DEFAULT_IMPLEMENTATION;
99  return 0;
100 }
101 
102 double axlAbstractSurfaceBSpline::getCoord(int n, int m, int v) const
103 {
104  DTK_DEFAULT_IMPLEMENTATION;
105  return 0;
106 }
107 
109 {
110  DTK_DEFAULT_IMPLEMENTATION;
111  return axlPoint();
112 }
113 
115 {
116  DTK_DEFAULT_IMPLEMENTATION;
117  DTK_UNUSED(n);
118  return axlPoint();
119 }
120 
121 double axlAbstractSurfaceBSpline::getWeight(int n, int m) const
122 {
123  DTK_DEFAULT_IMPLEMENTATION;
124  return 1.0;
125 }
126 
127 bool axlAbstractSurfaceBSpline::setCoef(int n, int m, int v, double c)
128 {
129  DTK_DEFAULT_IMPLEMENTATION;
130  return 0;
131 }
132 
133 bool axlAbstractSurfaceBSpline::setCoef(int n, int m, double *controlPoint)
134 {
135  DTK_DEFAULT_IMPLEMENTATION;
136  return 0;
137 }
138 
139 bool axlAbstractSurfaceBSpline::setCoef(int n, double *controlPoint)
140 {
141  DTK_DEFAULT_IMPLEMENTATION;
142  return 0;
143 }
144 
146 {
147  DTK_DEFAULT_IMPLEMENTATION;
148  return 0;
149 }
150 
152 {
153  DTK_DEFAULT_IMPLEMENTATION;
154  return 0;
155 }
156 
157 
159 {
160  DTK_DEFAULT_IMPLEMENTATION;
161  QVector<axlPoint *> qVect;
162  return qVect;
163 }
164 
165 void axlAbstractSurfaceBSpline::gridEvaluator(int num_u, int num_v, std::vector<double>& points, std::vector<double>& param_u,std::vector<double>& param_v)
166 {
167  DTK_DEFAULT_IMPLEMENTATION;
168 }
188 void axlAbstractSurfaceBSpline::setSurface(int n_u, int n_v, int order_u, int order_v, int dimension, double *knots_u, double *knots_v, double *points, bool rational)
189 {
190  DTK_DEFAULT_IMPLEMENTATION;
191 }
192 
193 //Added
195 {
196  DTK_DEFAULT_IMPLEMENTATION;
197 }
198 
199 
201 {
202  Q_UNUSED(k);
203 }
204 
206 {
207  Q_UNUSED(k);
208 }
209 
211 {
212  Q_UNUSED(k);
213 }
214 
216 {
217  Q_UNUSED(k);
218 }
219 
220 QString axlAbstractSurfaceBSpline::printCoeffs(bool print) const
221 {
222  DTK_DEFAULT_IMPLEMENTATION;
223  return "";
224 }
225 
227 {
228  DTK_DEFAULT_IMPLEMENTATION;
229  return "";
230 }
231 
233 {
234  DTK_DEFAULT_IMPLEMENTATION;
235  return "";
236 }
237 
238 double axlAbstractSurfaceBSpline::scalarValue(double u, double v)
239 {
240  return d->scalar_values.value(qMakePair<double, double>(u, v));
241 }
242 
243 void axlAbstractSurfaceBSpline::setScalarValue(double u, double v, double value)
244 {
245  d->scalar_values.insert(qMakePair<double, double>(u, v), value);
246 }
247 
249 
253  return !d->connect.isEmpty();
254 }
255 
257 
261 {
262  d->connect.clear();
263 }
264 
266 
270  return d->connect.value(i);
271 }
272 
273 
275 
279  if(i==j){
280  qDebug() << "The two indices must be different.";
281  }else{
282  int mini = std::min(i,j);
283  int maxi = std::max(i,j);
284 
285  if(d->connect.keys().contains(mini)){
286  QList<int> list = d->connect.value(mini);
287 
288  if(!list.contains(maxi) ){
289  list << maxi;
290  d->connect.insert(mini, list);
291  }
292  }else{
293  QList<int> list;
294  list << maxi;
295  d->connect.insert(mini,list);
296  }
297  }
298 }
299 
300 
301 
302 // A BSpline surface is described with nu, nv,orderu,orderv,dimension,knotsu,knotsv and controlPoints.
304  dtkWarn()<<"axlAbstractSurfaceBSpline::convertDataToQVariant not working for rational";
305  QVariantList list;
306  list.append(identifier());
307  QVariant nu = QVariant::fromValue(countControlPoints_u());
308  list.append(nu);
309  QVariant nv = QVariant::fromValue(countControlPoints_v());
310  list.append(nv);
311  QVariant orderu = QVariant::fromValue(order_u());
312  list.append(orderu);
313  QVariant orderv = QVariant::fromValue(order_v());
314  list.append(orderv);
315  QVariant dimension = QVariant::fromValue(3);
316  list.append(dimension);
317 
318  //append knots_u
319  for(int i = 0; i < nu.toInt()+ order_u();i++){
320  list.append(getKnot_u(i+1));
321  }
322  //append knots_v
323  for(int i = 0; i < nv.toInt()+ order_v();i++){
324  list.append(getKnot_v(i+1));
325  }
326  //append control points table
327  for(int i = 0; i < nu.toInt()*nv.toInt();i++){
328  list.append(getCoef(i+1).convertDataToQVariant());
329  }
330  QVariant name = QVariant::fromValue(objectName());
331  list.append(name);
332  return list;
333 }
334 
336  dtkWarn()<<"axlAbstractSurfaceBSpline::convertQVariantToData not working for rational";
337  int nu = data.at(1).toInt();
338  int nv = data.at(2).toInt();
339  int orderu = data.at(3).toInt();
340  int orderv = data.at(4).toInt();
341  int dimension = data.at(5).toInt();
342 
343  //append knots_u
344  double *knotsU = new double[nu+orderu];
345  for(int i = 0; i < nu+orderu;i++){
346  knotsU[i] = data.at(i+6).toDouble();
347  //insertKnot_u(data.at(i+7).toDouble());
348  }
349  //append knots_v
350  double *knotsV = new double[nv+orderv];
351  for(int i = 0; i < nv+orderv;i++){
352  knotsV[i] = data.at(i+6 +nu+orderu).toDouble();
353  //insertKnot_v(data.at(i+8+nKu).toDouble());
354  }
355  //append control points table
356  int indice = 6 +nu+orderu +nv+orderv;
357  double *CP = new double[3*nu*nv];
358  for(int i = 0; i < nu*nv;i++){
359  QVariantList list;
360  list.append(data.at(indice));
361  list.append(data.at(indice+1));
362  list.append(data.at(indice+2));
363  list.append(data.at(indice+3));
364  list.append(data.at(indice+4));
365  axlPoint* point = new axlPoint();
366  point->convertQVariantToData(list);
367  //double *controlPoint = point->coordinates();
368  CP[3*i] = point->x();
369  CP[3*i+1] = point->y();
370  CP[3*i+2] = point->z();
371  //setCoef(i,controlPoint);
372  indice = indice+5;
373  }
374  setSurface(nu,nv ,orderu,orderv,dimension,knotsU, knotsV,CP,false);
375  QString name = data.last().toString();
376  setObjectName(name);
377  return 1;
378 }
virtual axlAbstractSurfaceBSpline * copy(void) const
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
QVariantList convertDataToQVariant(void) const
Convert an axlAbstractData into a QVariantList that specifies all properties of the axlAbstractData...
virtual void resetControlPointConnections(void)
Removes all control point connections.
virtual bool connectionsAreDefined(void)
Return true if control points connections were defined by developers. False if there are default conn...
virtual double getKnot_v(int n) const
virtual QString printCoeffs(bool print) const
virtual void defineControlPointConnection(int i, int j)
Define connection between the ith and the jth coefficient.
void setScalarValue(double u, double v, double value)
virtual void setSurface(int pointsCount_u, int pointsCount_v, int order_u, int order_v, int dimension, double *knots_u, double *knots_v, double *points, bool rational)
axlAbstractSurfaceBSpline::setSurface
int convertQVariantToData(const QVariantList &data)
Modify properties and geometry variables of the axlAbstractData. Return 1 if the modification was suc...
virtual int dimension(void) const
virtual double getCoord(int n, int m, int v) const
double scalarValue(double u, double v)
virtual int countControlPoints_u(void) const
virtual int countControlPoints_v(void) const
virtual double getWeight(int n, int m) const
virtual int knotVectorSize_u(void) const
virtual QVector< axlPoint * > sampling()
virtual QString printKnotsVector(bool print) const
double y
Definition: axlPoint.h:37
virtual bool rational(void) const
virtual int order_u(void) const
double z
Definition: axlPoint.h:38
virtual QString description(void) const
virtual int countControlPoints(void) const
virtual bool setCoef(int n, int m, int v, double c)
virtual QList< int > getControlPointConnection(int i)
The list returned contains all indices of coefficients that are still to be connected to the ith coef...
virtual axlPoint getCoef(int n, int m) const
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 void gridEvaluator(int num_u, int num_v, std::vector< double > &points, std::vector< double > &param_u, std::vector< double > &param_v)
double x
Definition: axlPoint.h:37
virtual int order_v(void) const
virtual int knotVectorSize_v(void) const
virtual double getKnot_u(int n) const