Developer documentation | Axl-2.5.1

axlMesh.h
Go to the documentation of this file.
1 /* axlMesh.h ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Tue Nov 9 16:58:59 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Mon Dec 6 15:46:18 2010 (+0100)
8  * By: Meriadeg Perrinel
9  * Update #: 21
10  */
11 
12 /* Commentary:
13  * There is choice table for stock coordinate. But maybe that is not the good solution if algorithm behin use a lot of point.
14  * In this case, we have to create three double directly instead of table
15  */
16 
17 /* Change log:
18  *
19  */
20 
21 #ifndef AXLMESH_H
22 #define AXLMESH_H
23 
24 #include "axlCoreExport.h"
25 
26 #include <QtCore>
27 
29 #include <axlCore/axlPoint.h>
30 
31 //class axlPoint;
32 
33 class axlMeshPrivate;
34 
35 //enum Intepolation{
36 // FLAT,
37 // GOURAUD,
38 // PHONG
39 // };
40 
42 {
43  Q_OBJECT
44 public:
48  PHONG
49  };
50 public:
52  typedef axlPoint Point;
53 
55  typedef QVector<int> Edge;
56 
58  typedef QVector<int> Face;
59 
60  axlMesh(void);
61  ~axlMesh(void);
62 
63  virtual QString description(void) const;
64  virtual QString identifier(void) const;
65 
66 // QVector<int> selectedVertices(void);
67 // void setSelectedVertices(QVector<int> selected);
68 
69 //signals :
70 // void verticesSelected(void);
71 
72 public :
73 
74  int vertex_count(void) const;
75  int color_count(void) const;
76  int normal_count(void) const;
77  int face_count(void) const;
78  int edge_count(void) const;
79  int all_edge_count(void) const;
80 
81  bool vertex_show(void) const;
82  bool& vertex_show();
83 
84  bool normal_used(void) const;
85  bool& normal_used(void);
86 
87  bool color_used(void) const;
88  bool& color_used(void);
89 
90  bool edge_show(void) const;
91  bool& edge_show(void);
92  bool face_show(void) const;
93  bool& face_show(void);
94 
95  bool isPlanar(void) const;
96  bool& isPlanar(void);
97 
98  void setEpsilon(double epsilon);
99  double espilon(void);
100 
101  int interpolation(void) const;
102  void setInterpolation(int interpolation);
103 
104  //methods for vertices
105 
106  double vertexX(const int& ind) const;
107  double vertexY(const int& ind) const;
108  double vertexZ(const int& ind) const;
109 
110  void vertex(const int& ind, double vertex[3] );
111  void vertex(int ind, axlPoint& point) const;
112  void vertex(int ind, axlPoint *point) const;
113 
114  axlPoint operator[] (int i);
115  axlPoint *vertex2(int ind, axlPoint *point) const;
116  QVector<double> vertexSet(void) const;
117 
118  void push_back_vertex(const double &x,const double &y, const double &z);
119  void push_back_vertex(const double vertex[3]);
120  void push_back_vertex(const axlPoint& vertex);
121  void push_back_vertex(axlPoint *vertex);
122 
123  void set_vertex(axlPoint* point, const int &ind);
124 
125  void setVertices(const QVector<axlPoint*>& pointSet);
126 
127  // methods for normals
128 
129  double normalX(const int& ind) const;
130  double normalY(const int& ind) const;
131  double normalZ(const int& ind) const;
132 
133  void normal(const int& ind, double normal[3]);
134  void normal(int ind, axlPoint& normal);
135  void normal(int ind, axlPoint *normal);
136  axlPoint *normal2(int ind, axlPoint *normal);
137 
138  QVector<double> normalSet(void);
139 
140  void push_back_normal(axlPoint *normal);
141  void setNormals(const QList<axlPoint*>& pointSet);
142 
143  void push_back_normal(const double &x,const double &y, const double &z);
144  void push_back_normal(const double normal[3]);
145 
146  void clearNormals(void);
147 
148  // methods for colors
149 
150  int colorR(const int& ind);
151  int colorG(const int& ind);
152  int colorB(const int& ind);
153  double colorRF(const int& ind);
154  double colorGF(const int& ind);
155  double colorBF(const int& ind);
156  void getColor(const int& ind, int color[3] );
157  void push_back_color(const int &r,const int &g, const int &b);
158  void push_back_color(const int color[3]);
159 
160  //methods for edges
161 
162  Edge edge(int ind) const;
163  QVector<Edge> edgeSet(void) const;
164  int edgePointIndex(int i, int j) const;
165  int edgePointCount(int i) const;
166 
167  void push_back_edge(int, int);
168  void push_back_edge(const Edge& e);
169  int push_back_new_edge(void);
170  void edgePushBack(int, int);
171 
172  // methods for faces
173 
174  Face face(int ind) const;
175  QVector<Face> faceSet(void) const;
176  int facePointIndex(int i, int j) const;
177  int facePointCount(int i) const;
178 
179  void push_back_face(const Face& face);
180  void insert_face(const Face& face) {this->push_back_face(face);}
181  void push_back_face(int i1, int i2, int i3);
182 
183  // differents algorithms
184 
185  const QVector<double> boundingBoxVertex(void) const;
186  double meshVertexScaleFactor() const;
187 
188  void append(axlMesh *mesh);
189  void noDuplicateVertices(void);
190 
191  double distance(int ind1, int ind2);
192 
193 public:
194  // static axlMesh& fromCurve(axlAbstractCurveParametric *curve);
195  static QVector<QSet<int> > neighborsFace(const axlMesh& mesh);
196  static QVector<QSet<int> > VertexTofaceIndexes(const axlMesh &mesh);
197 
198  //IPC
199  QVariantList convertDataToQVariant(void) const;
200  int convertQVariantToData(const QVariantList &data);
201 
202 private:
203  axlMeshPrivate *d;
204 };
205 
206 //to be registered to the data factory.
207 dtkAbstractData *createaxlMesh(void);
208 
209 // /////////////////////////////////////////////////////////////////
210 // Debug operators
211 // /////////////////////////////////////////////////////////////////
212 
213 
214 #endif // AXLMESH_H
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
axlPoint Point
A point of the mesh is an axlPoint.
Definition: axlMesh.h:52
QVector< int > Edge
An edge is represented by a sequence of vertices.
Definition: axlMesh.h:55
void insert_face(const Face &face)
Definition: axlMesh.h:180
virtual int convertQVariantToData(const QVariantList &data)
Modify properties and geometry variables of the axlAbstractData. Return 1 if the modification was suc...
QVector< int > Face
A face is a polygon represented by a loop of vertices.
Definition: axlMesh.h:58
virtual QVariantList convertDataToQVariant(void) const
Convert an axlAbstractData into a QVariantList that specifies all properties of the axlAbstractData...
Intepolation
Definition: axlMesh.h:45
#define AXLCORE_EXPORT
dtkAbstractData * createaxlMesh(void)
Definition: axlMesh.cpp:1238
Class axlAbstractData defines an API for all type of axel data.
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41