Developer documentation | Axl-2.5.1

axlShapeBSpline.h
Go to the documentation of this file.
1 #ifndef axlShapeBSpline_H
2 #define axlShapeBSpline_H
3 
4 #include "axlCoreExport.h"
7 
8 #include <list>
9 
10 class AXLCORE_EXPORT axlShapeBSplinePrivate;
11 
13 {
14  Q_OBJECT
15 
16 public :
17 
18  struct ControlPoint {
19  int index;
20  QVector<double> coordinates;
21  QVector<int> edges;
22  QVector<int> faces;
23 
24  ControlPoint(int ind, double x =0.0 , double y = 0.0, double z = 0.0) {
25  index = ind;
26  coordinates << x << y << z;
27  }
28 
29  void setCoord(double *newCoordinate){
30  coordinates.replace(0,newCoordinate[0]);
31  coordinates.replace(1,newCoordinate[1]);
32  coordinates.replace(2,newCoordinate[2]);
33  }
34 
35  void addEdge(int numEdge ){
36  edges.append(numEdge);
37  }
38 
39  void addFace(int numFace ){
40  faces.append(numFace);
41  }
42 
43  };
44 
45  struct Edge {
46  int index;
47  QVector<int> controlPointsIndices;
49  QString tag;
50 
51  Edge(int ind, QVector<int> p, axlAbstractCurveBSpline *curv){
52  index = ind;
53  controlPointsIndices = p;
54  support = curv;
55  tag = "interior";
56  }
57 
58  void setTag(QString t){
59  tag = t;
60  }
61 
62  bool containsControlPoint(int i){
63  return controlPointsIndices.contains(i);
64  }
65 
66  int firstPoint(void){
67  return controlPointsIndices.first();
68  }
69 
70  int lastPoint(void){
71  return controlPointsIndices.last();
72  }
73  };
74 
75  struct Face {
76  int index;
77  QVector<int> controlPointsIndices;
78  QVector<int> edgesIndices;
80  int nbpts_u;
81  int nbpts_v;
82 
83 
84  Face(int ind, int nu,int nv, QVector<int> p, axlAbstractSurfaceBSpline *surf){
85  index = ind;
86  controlPointsIndices = p;
87  sortControlPoints();
88  support = surf;
89  nbpts_u = nu;
90  nbpts_v = nv;
91  }
92 
93  bool containsControlPoint(int i){
94  return controlPointsIndices.contains(i);
95  }
96 
97  void sortControlPoints(void){
98  std::list<int> l;
99  l = controlPointsIndices.toList().toStdList();
100  l.sort();
101  controlPointsIndices = QVector<int>::fromList(QList<int>::fromStdList(l));
102 
103  }
104  };
105 
106 public:
107  axlShapeBSpline();
108  ~axlShapeBSpline();
109 
110 public :
111  static bool registered(void);
112  QString description(void) const;
113  QString identifier(void) const;
114 
115 public:
116  // using axlAbstractSurfaceBSpline::setSurface;
117  void setSurface(int order_u, int order_v,int nbpoints,int nbEdges, int nbFaces, double *points, QVector< QVector<int> > pe, QVector< QVector<int> >pf, QVector< QPair<int,int> >npf);
118  void setControlPoints(int nbpoints,double *points);
119  void setFace(int i, QVector<int> p, int order_u, int order_v, int nu, int nv);
120  void setFace(int i, QVector<int> p, axlAbstractSurfaceBSpline *surf);
121  void setEdge(int i, QVector<int> p, int order);
122  void setEdge(int i, QVector<int> p, axlAbstractCurveBSpline *curv);
123  void removeEdge(int i);
124 
125  void createSurfaceFromBSplineDataSet(QList<axlAbstractSurfaceBSpline *> dataSet);
126 
127  //getters
128  Edge *getEdge(int i);
129  Face *getFace(int i);
130  ControlPoint *getPoint(int i);
131 
132  //ControlPoints
133  axlPoint getCoef(int index) const;
134  bool setCoef(int index, double * newCoordinate);
135 
136  int countControlPoints() const;
137  int countBoundaryEdges() const;
138 
139  int order_u() const;
140  int order_v() const;
141 
142  int numSamples_u(int numCell);
143  int numSamples_v(int numCell);
144  void setNumSamples_u(int numSamples);
145  void setNumSamples_v(int numSamples);
146 
147  // -------------------------------
148 // int numSamples_u(void);
149 // int numSamples_v(void);
150 // double startParam_u(void);
151 // double startParam_v(void);
152 // double endParam_u(void);
153 // double endParam_v(void);
154 
155  int stripes(void);
156  void setStripes(int stripes);
157  void normal(axlPoint *normal, double u,double v);
158  void eval(axlPoint *point, double u,double v);
159 
160  bool connectionsAreDefined(void);
161  QList<int> getControlPointConnection(int i); // give all the connections that are still to be made for the ith coefficient.
162 
163  int countControlPoints_u(void) const;
164  int countControlPoints_v(void) const;
165 
166  void selectIndex(int i) { emit indexSelected(i); }
167  // -------------------------------
168  // Scalar values proof of concept
169  double scalarValue(double u, double v);
170  void setScalarValue(double u, double v, double value);
171  // -------------------------------
172 
173  double startParam_u(int i);
174  double startParam_v(int i);
175  double endParam_u(int i);
176  double endParam_v(int i);
177  void eval(axlPoint *point, double u, double v,int i);
178  void normal(axlPoint *currentNormal, double paramCourant_u, double paramCourant_v,int indice);
179 
180  bool hasFaces(void);
181  int countFaces(void);
182 
183  void insert_point(double x, double y, double z);
184  void insert_point(axlPoint *point);
185  void insert_edge(Edge *edge);
186  void insert_face(Face *face);
187 
188  void updateFaceEdges(int numFace);
189 
190  void emitEdgeSelected(int numEdge);
191 
192 // ----------------------
193 signals:
194  void indexSelected(int i);
195 
196 private :
197  double *fillCoordinates(QVector<int> p);
198  double *knots(int pointsCount, int order);
199  bool isContained(QList<axlPoint> list, axlPoint p, QVector<int>& pf);
200 
201 
202 private :
203  axlShapeBSplinePrivate *d;
204 };
205 
206 dtkAbstractData *createaxlShapeBSpline(void);
207 
208 #endif // axlShapeBSpline_H
void setCoord(double *newCoordinate)
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
QVector< int > edgesIndices
Face(int ind, int nu, int nv, QVector< int > p, axlAbstractSurfaceBSpline *surf)
QVector< int > controlPointsIndices
void sortControlPoints(void)
ControlPoint(int ind, double x=0.0, double y=0.0, double z=0.0)
void setTag(QString t)
dtkAbstractData * createaxlShapeBSpline(void)
bool containsControlPoint(int i)
void selectIndex(int i)
axlAbstractCurveBSpline * support
Edge(int ind, QVector< int > p, axlAbstractCurveBSpline *curv)
#define AXLCORE_EXPORT
Class axlShapeBSpline defines a set of boundary curves (Edges) and bspline surface patches (Face)...
axlAbstractSurfaceBSpline * support
Class axlAbstractData defines an API for all type of axel data.
QVector< int > controlPointsIndices
bool containsControlPoint(int i)