23 #include <dtkCoreSupport/dtkGlobal.h> 
   50     QVector<double>          vertices;
 
   51     QVector<double>          normals;
 
   53     QVector<axlMesh::Edge>   edges;
 
   54     QVector<axlMesh::Face>   faces;
 
   56     QVector<int> selectedVertices;
 
   82     d->normal_used = 
false;
 
   83     d->color_used = 
false;
 
   85     d->vertex_show = 
false;
 
   91     d->interpolation = 
FLAT;
 
  124     return d->vertex_count;
 
  129     return d->color_count;
 
  134     return d->normal_count;
 
  140     return d->face_count;
 
  145     return d->edge_count;
 
  151     for (
int k = 0; k < d->edge_count; k++) {
 
  152         res += d->edges.at(k).size() - 1;
 
  161     return d->vertex_show;
 
  166     return d->vertex_show;
 
  172     return d->normal_used;
 
  177     return d->normal_used;
 
  182     return d->color_used;
 
  187     return d->color_used;
 
  222     return d->interpolation;
 
  235     return axlPoint(d->vertices[3 * i], d->vertices[3 * i + 1], d->vertices[3 * i + 2]);
 
  244     point.
setCoordinates(d->vertices[3 * ind], d->vertices[3 * ind + 1], d->vertices[3 * ind + 2]);
 
  253     point->
setCoordinates(d->vertices[3 * ind], d->vertices[3 * ind + 1], d->vertices[3 * ind + 2]);
 
  262     point->
setCoordinates(d->vertices[3 * ind], d->vertices[3 * ind + 1], d->vertices[3 * ind + 2]);
 
  279     d->epsilon = epsilon;
 
  297     return d->vertices[3 * ind];
 
  306     return d->vertices[3 * ind + 1];
 
  315     return d->vertices[3 * ind + 2];
 
  324     vertex[0] = d->vertices[3 * ind];
 
  325     vertex[1] = d->vertices[3 * ind + 1];
 
  326     vertex[2] = d->vertices[3 * ind + 2];
 
  336     d->vertices.push_back(x);
 
  337     d->vertices.push_back(y);
 
  338     d->vertices.push_back(z);
 
  349     d->vertices.push_back(vertex[0]);
 
  350     d->vertices.push_back(vertex[1]);
 
  351     d->vertices.push_back(vertex[2]);
 
  362     d->vertices.push_back(vertex.
x());
 
  363     d->vertices.push_back(vertex.
y());
 
  364     d->vertices.push_back(vertex.
z());
 
  376     d->vertices.push_back(vertex->
x());
 
  377     d->vertices.push_back(vertex->
y());
 
  378     d->vertices.push_back(vertex->
z());
 
  391         dtkError()<< 
"axlMesh : specified index must be positive integer !";
 
  394         if(ind > d->vertex_count-1 )
 
  396             dtkError()<< 
"axlMesh : specified index out of mesh !";
 
  400             d->vertices.replace(3*ind,point->
x());
 
  401             d->vertices.replace(3*ind+1,point->
y());
 
  402             d->vertices.replace(3*ind+2,point->
z());
 
  413     return d->normals[3 * ind];
 
  422     return d->normals[3 * ind + 1];
 
  431     return d->normals[3 * ind + 2];
 
  440     normal[0] = d->normals[3 * ind];
 
  441     normal[1] = d->normals[3 * ind + 1];
 
  442     normal[2] = d->normals[3 * ind + 2];
 
  453     d->normals.push_back(x);
 
  454     d->normals.push_back(y);
 
  455     d->normals.push_back(z);
 
  465     d->normals.push_back(normal[0]);
 
  466     d->normals.push_back(normal[1]);
 
  467     d->normals.push_back(normal[2]);
 
  476     return d->colors[3 * ind];
 
  485     return d->colors[3 * ind] / 255.0 ;
 
  494     return d->colors[3 * ind + 1];
 
  503     return d->colors[3 * ind + 1] / 255.0 ;
 
  513     return d->colors[3 * ind + 2];
 
  522     return d->colors[3 * ind + 2] / 255.0 ;
 
  532     color[0] = d->colors[3 * ind];
 
  533     color[1] = d->colors[3 * ind + 1];
 
  534     color[2] = d->colors[3 * ind + 2];
 
  545     d->colors.push_back(r);
 
  546     d->colors.push_back(g);
 
  547     d->colors.push_back(b);
 
  558     d->colors.push_back(color[0]);
 
  559     d->colors.push_back(color[1]);
 
  560     d->colors.push_back(color[2]);
 
  570     for (
int i = 0 ; i < pointSet.size() ; i++)
 
  585     normal.
setCoordinates(d->normals[3 * ind], d->normals[3 * ind + 1], d->normals[3 * ind + 2]);
 
  594     normal->
setCoordinates(d->normals[3 * ind], d->normals[3 * ind + 1], d->normals[3 * ind + 2]);
 
  603     normal->
setCoordinates(d->normals[3 * ind], d->normals[3 * ind + 1], d->normals[3 * ind + 2]);
 
  616     d->normals.push_back(normal->
x());
 
  617     d->normals.push_back(normal->
y());
 
  618     d->normals.push_back(normal->
z());
 
  623     if(d->normal_count > 0)
 
  624         qDebug()<< 
" this axlMesh instance already have one vertex at less, This method cannot be use now. See push_back_vertex";
 
  627         for (
int i = 0 ; i < pointSet.size() ; i++)
 
  642     return d->edges.at(ind);
 
  656     return d->edges.at(i).at(j);
 
  665     return d->edges.at(i).size();
 
  673     d->edges.push_back(e);
 
  683     d->edges.push_back(e);
 
  694     d->edges.push_back(e);
 
  696     return d->edge_count-1;
 
  711     return d->faces.at(ind);
 
  724     return d->faces.at(i).at(j);
 
  732     return d->faces.at(i).size();
 
  738     d->faces.push_back(face);
 
  745     d->faces.push_back(face);
 
  760     QVector<double> bbox;
 
  762     bbox[0] =  d->vertices[0];
 
  763     bbox[1] =  d->vertices[0];
 
  764     bbox[2] =  d->vertices[1];
 
  765     bbox[3] =  d->vertices[1];
 
  766     bbox[4] =  d->vertices[2];
 
  767     bbox[5] =  d->vertices[2];
 
  771         if(bbox[0] >  d->vertices[3 * i])
 
  772             bbox[0] =  d->vertices[3 * i];
 
  774         if(bbox[1] < d->vertices[3 * i])
 
  775             bbox[1] = d->vertices[3 * i];
 
  777         if(bbox[2] > d->vertices[3 * i + 1])
 
  778             bbox[2] = d->vertices[3 * i + 1];
 
  780         if(bbox[3] < d->vertices[3 * i + 1])
 
  781             bbox[3] = d->vertices[3 * i + 1];
 
  783         if(bbox[4] > d->vertices[3 * i + 2])
 
  784             bbox[4] = d->vertices[3 * i + 2];
 
  786         if(bbox[5] < d->vertices[3 * i + 2])
 
  787             bbox[5] = d->vertices[3 * i + 2];
 
  801     double scale = bbox[1]- bbox[0];
 
  802     if(scale < bbox[3] - bbox[2])
 
  803         scale = bbox[3] - bbox[2];
 
  805     if(scale < bbox[5] - bbox[4])
 
  806         scale = bbox[5] - bbox[4];
 
  816     for (
int i = 0 ; i < mesh->
face_count() ; i++)
 
  819         for (
int j = 0 ; j < currentList.size() ; j ++)
 
  820             currentList.replace(j, currentList.at(j) + this->
vertex_count());
 
  825     for (
int i = 0 ; i < mesh->
edge_count() ; i++)
 
  829         for (
int j = 0; j< currentEdge.size(); j++)
 
  838         mesh->
vertex(i, ¤tPoint);
 
  845         mesh->
normal(i, ¤tNormal);
 
  865     QVector<int> verticesFirstIndexes;
 
  869     QVector<int> idx(d->vertex_count,0);
 
  871     int vertexUnique_count=0;
 
  873     for(
int i = 0 ; i < d->vertex_count ; i++)
 
  876         bool not_found = 
true;
 
  879         while(j < i && not_found)
 
  892             vertexUnique_count ++;
 
  893             verticesFirstIndexes <<  i;
 
  901         QVector<double> new_vertices;
 
  903         for(
int k=0; k< verticesFirstIndexes.size();k++)
 
  904             new_vertices << this->
vertexX(verticesFirstIndexes.at(k))
 
  905                          << this->
vertexY(verticesFirstIndexes.at(k))
 
  906                          << this->
vertexZ(verticesFirstIndexes.at(k));
 
  908         d->vertices = new_vertices;
 
  911         if(d->vertex_count==d->normal_count) {
 
  912             QVector<double> new_normals;
 
  913             for(
int k=0; k < verticesFirstIndexes.size();k++)
 
  914                 new_normals << this->
normalX(verticesFirstIndexes.at(k))
 
  915                             << this->
normalY(verticesFirstIndexes.at(k))
 
  916                             << this->
normalZ(verticesFirstIndexes.at(k));
 
  918             d->normals = new_normals;
 
  919             d->normal_count = new_normals.size()/3;
 
  922         if(d->vertex_count==d->color_count) {
 
  923             QVector<int> new_colors;
 
  924             for(
int k=0; k< verticesFirstIndexes.size();k++)
 
  925                 new_colors << this->
colorR(verticesFirstIndexes.at(k))
 
  926                            << this->
colorG(verticesFirstIndexes.at(k))
 
  927                            << this->
colorB(verticesFirstIndexes.at(k));
 
  929             d->colors = new_colors;
 
  930             d->color_count = new_colors.size()/3;
 
  933         d->vertex_count =  new_vertices.size()/3;
 
  935         QVector<Edge> new_edges;
 
  937         for(
int i = 0 ; i < d->edge_count ; i++)
 
  940             for(
int j=0;j<d->edges.at(i).size(); j++) {
 
  941                 j1 = idx[d->edges.at(i).at(j)];
 
  942                 if(j == 0 || (j1 != idx[d->edges.at(i).at(j-1)]))
 
  947                 new_edges << newEdge;
 
  950         d->edges = new_edges;
 
  951         d->edge_count = new_edges.size();
 
  953         QVector<Face> new_faces;
 
  954         for(
int i = 0 ; i < d->face_count ; i++)
 
  957             for(
int j = 0 ; j < d->faces.at(i).size() ; j ++) {
 
  958                 j1 = idx[d->faces.at(i)[j]];
 
  959                 if(!face.contains(j1))
 
  965         d->faces = new_faces;
 
  966         d->face_count = new_faces.size();
 
  977     if(ind1 >= d->vertex_count || ind2 >= d->vertex_count)
 
  980     return sqrt((d->vertices[3 * ind1]- d->vertices[3 * ind2]) * (d->vertices[3 * ind1]- d->vertices[3 * ind2]) + (d->vertices[3 * ind1 + 1]- d->vertices[3 * ind2 + 1]) * (d->vertices[3 * ind1 + 1]- d->vertices[3 * ind2 + 1]) + (d->vertices[3 * ind1 + 2]- d->vertices[3 * ind2 + 2]) * (d->vertices[3 * ind1 + 2]- d->vertices[3 * ind2 + 2]));
 
  987     QString result = 
"axlMesh";
 
  988     result.append(
"\nVertex count : "+QString::number(d->vertex_count));
 
  989     result.append(
"\nNormal count : "+QString::number(d->normal_count));
 
  990     result.append(
"\nEdge count : "+QString::number(d->edge_count));
 
  991     result.append(
"\nFace count : "+QString::number(d->face_count));
 
  992     result.append(
"\nVertex show : "+QString::number(d->vertex_show));
 
  993     result.append(
"\nNormal use : "+QString::number(d->normal_used));
 
  994     result.append(
"\nEdge show : "+QString::number(d->edge_show));
 
  995     result.append(
"\nFace show : "+QString::number(d->face_show));
 
 1017         int vfirst = mesh.
face(i).first();
 
 1018         int vatone = mesh.
face(i).at(1);
 
 1019         int vatlastminusone = mesh.
face(i).at(mesh.
face(i).count() -2);
 
 1020         int vlast = mesh.
face(i).last();
 
 1022         if(vfirst != vatone)
 
 1023             result[vfirst] << vatone;
 
 1026             result[vfirst] << vlast;
 
 1029             result[vlast] << vfirst;
 
 1031         if(vlast != vatlastminusone)
 
 1032             result[vlast] << vatlastminusone;
 
 1037         for (
int j = 1 ; j < mesh.
face(i).count() -1; j++)
 
 1039             vfirst = mesh.
face(i).at(j-1);
 
 1040             vatone = mesh.
face(i).at(j);
 
 1041             vlast = mesh.
face(i).at(j+1);
 
 1043             if(vatone != vfirst)
 
 1044                 result[vatone] << vfirst;
 
 1047                 result[vatone] << vlast;
 
 1072         result[mesh.
face(i).first()] << i;
 
 1073         result[mesh.
face(i).last()]  << i;
 
 1079         for (
int j = 1 ; j < mesh.
face(i).count() -1; j++)
 
 1080             result[mesh.
face(i).at(j)] << i;
 
 1091     QVariant 
id = QVariant::fromValue(
identifier());
 
 1092     QVariant vertexCount = QVariant::fromValue(d->vertex_count);
 
 1093     QVariant colorCount = QVariant::fromValue(d->color_count);
 
 1094     QVariant normalCount = QVariant::fromValue(d->normal_count);
 
 1095     QVariant faceCount = QVariant::fromValue(d->face_count);
 
 1096     QVariant edgeCount = QVariant::fromValue(d->edge_count);
 
 1097     QVariant epsilon = QVariant::fromValue(d->epsilon);
 
 1098     QVariant colorUsed = QVariant::fromValue(d->color_used);
 
 1099     QVariant colorRgb = QVariant::fromValue(d->color_rgb);
 
 1100     QVariant normalUsed = QVariant::fromValue(d->normal_used);
 
 1101     QVariant vertexShow = QVariant::fromValue(d->vertex_show);
 
 1102     QVariant faceShow = QVariant::fromValue(d->face_show);
 
 1103     QVariant edgeShow = QVariant::fromValue(d->edge_show);
 
 1104     QVariant planar = QVariant::fromValue(d->planar);
 
 1109     list.append(vertexCount);
 
 1110     list.append(colorCount);
 
 1111     list.append(normalCount);
 
 1112     list.append(faceCount);
 
 1113     list.append(edgeCount);
 
 1114     list.append(epsilon);
 
 1115     list.append(colorUsed);
 
 1116     list.append(colorRgb);
 
 1117     list.append(normalUsed);
 
 1118     list.append(vertexShow);
 
 1119     list.append(faceShow);
 
 1120     list.append(edgeShow);
 
 1121     list.append(planar);
 
 1124     for(
int i = 0; i< d->vertex_count;i++){
 
 1131     for(
int i = 0; i< d->normal_count;i++){
 
 1143     for(
int i = 0; i< d->edge_count;i++){
 
 1146             list.append(
edge(i).at(j));
 
 1151     for(
int i = 0; i< d->face_count;i++){
 
 1154             list.append(
face(i).at(j));
 
 1158     QVariant name = QVariant::fromValue(objectName());
 
 1172     d->epsilon = data.at(6).toDouble();
 
 1173     d->color_used = data.at(7).toBool();
 
 1174     d->color_rgb = data.at(8).toBool();
 
 1175     d->normal_used = data.at(9).toBool();
 
 1176     d->vertex_show = data.at(10).toBool();
 
 1177     d->face_show = data.at(11).toBool();
 
 1178     d->edge_show = data.at(12).toBool();
 
 1179     d->planar = data.at(13).toBool();
 
 1184     for(
int i = 0; i< data.at(1).toInt();i++){
 
 1185         double x = data.at(3*i+newBegin).toDouble() ;
 
 1186         double y = data.at(3*i+1+newBegin).toDouble();
 
 1187         double z = data.at(3*i+2+newBegin).toDouble();
 
 1190     newBegin = (3*d->vertex_count)+newBegin;
 
 1192     if(!d->normals.isEmpty()){
 
 1194         for(
int i = 0; i< d->normal_count;i++){
 
 1195             double x = data.at(3*i+newBegin).toDouble() ;
 
 1196             double y = data.at(3*i+1+newBegin).toDouble();
 
 1197             double z = data.at(3*i+2+newBegin).toDouble();
 
 1201         newBegin = (3*d->normal_count) + newBegin;
 
 1210     for(
int i = 0; i< data.at(5).toInt();i++){
 
 1211         int indiceEdge = newBegin+i;
 
 1212         int nb = data.at(indiceEdge).toInt();
 
 1213         push_back_edge(data.at(indiceEdge+1).toInt(), data.at(indiceEdge+2).toInt());
 
 1214         newBegin = newBegin+nb;
 
 1217     newBegin = newBegin+ d->edge_count;
 
 1220     for(
int i = 0; i< data.at(4).toInt();i++){
 
 1221         int indiceEdge = newBegin+i;
 
 1222         int nb = data.at(indiceEdge).toInt();
 
 1224         for(
int j=1;j <= nb;j++){
 
 1225             f.append(data.at(indiceEdge+j).toInt());
 
 1228         newBegin = newBegin+nb;
 
 1231     setObjectName(data.last().toString());
 
axlMesh(void)
Construct an axlMesh. 
const QVector< double > boundingBoxVertex(void) const 
Return the bounding box vector of the mesh. 
int facePointIndex(int i, int j) const 
Returns the index of the j-th point of the i-th face of the mesh. 
Class axlPoint defines 3D points. 
virtual QString description(void) const 
double vertexZ(const int &ind) const 
return Z coordinates of vertex with index ind. 
int face_count(void) const 
void noDuplicateVertices(void)
Remove duplicated vertices. 
QVector< Edge > edgeSet(void) const 
void edgePushBack(int, int)
Add to the edge i the index j. 
bool vertex_show(void) const 
void push_back_edge(int, int)
int facePointCount(int i) const 
Returns the number of vertex of a mesh face. 
void getColor(const int &ind, int color[3])
Set color values of colors with index ind. 
void setNormals(const QList< axlPoint * > &pointSet)
int colorG(const int &ind)
return int Green component of color with index ind. 
axlPoint * normal2(int ind, axlPoint *normal)
Set normal values of vertices with index ind and return it. 
dtkAbstractData * createaxlMesh(void)
double normalY(const int &ind) const 
return Y coordinates of normal with index ind. 
bool normal_used(void) const 
double colorGF(const int &ind)
Return double Green component of color with index ind. 
QVector< int > Edge
An edge is represented by a sequence of vertices. 
axlPoint operator[](int i)
Return the i th vertex of the mesh. 
int edgePointIndex(int i, int j) const 
Returns the index of the j-th point of the i-th edge of the mesh. 
double colorBF(const int &ind)
Return double Blue component of color with index ind. 
void append(axlMesh *mesh)
void normal(const int &ind, double normal[3])
set normal values of normals with index ind. 
void setEpsilon(double epsilon)
Set the precision parameter for point comparison. 
bool edge_show(void) const 
double distance(int ind1, int ind2)
Compute the distance in the 3d space between two points of indices ind1 and ind2. ...
int convertQVariantToData(const QVariantList &data)
Modify properties and geometry variables of the axlAbstractData. Return 1 if the modification was suc...
bool isPlanar(void) const 
virtual QString identifier(void) const 
static QVector< QSet< int > > VertexTofaceIndexes(const axlMesh &mesh)
Construct Faces Indexes Table. of all points of the mesh. 
double normalX(const int &ind) const 
return X coordinates of normal with index ind. 
void push_back_color(const int &r, const int &g, const int &b)
Add color to the mesh. 
QVector< int > Face
A face is a polygon represented by a loop of vertices. 
int edge_count(void) const 
void vertex(const int &ind, double vertex[3])
set vertex values of vertices with index ind. 
double normalZ(const int &ind) const 
return Z coordinates of normal with index ind. 
QVariantList convertDataToQVariant(void) const 
Convert an axlAbstractData into a QVariantList that specifies all properties of the axlAbstractData...
double vertexY(const int &ind) const 
return Y coordinates of vertex with index ind. 
void set_vertex(axlPoint *point, const int &ind)
Function to set a vertex. 
int edgePointCount(int i) const 
Return the number of point contained in the i-th edge of the mesh. 
int interpolation(void) const 
int colorR(const int &ind)
return int Red component of color with index ind. 
int all_edge_count(void) const 
QVector< double > vertexSet(void) const 
bool face_show(void) const 
int normal_count(void) const 
void setVertices(const QVector< axlPoint * > &pointSet)
int push_back_new_edge(void)
Add an empty edge to the mesh. 
axlPoint * vertex2(int ind, axlPoint *point) const 
Set vertex values of vertices with index ind and return it. 
void push_back_face(const Face &face)
bool color_used(void) const 
double espilon(void)
Return the parameter used to identify points. 
int colorB(const int &ind)
Return int Blue component of color with index ind. 
double meshVertexScaleFactor() const 
Return a scale factor based on the distance max founded with the bounding box. 
int color_count(void) const 
double colorRF(const int &ind)
return double Red component of color with index ind. 
QVector< double > normalSet(void)
double vertexX(const int &ind) const 
Return X coordinates of vertex with index ind. 
static double distance(const axlPoint &lhs, const axlPoint &rhs)
Returns the distance between lhs point and rhs point. 
void push_back_normal(axlPoint *normal)
void setInterpolation(int interpolation)
void setCoordinates(double x, double y, double z)
Change coordinates of this point. 
static QVector< QSet< int > > neighborsFace(const axlMesh &mesh)
Construct neighbors of all points of the mesh. 
int vertex_count(void) const 
~axlMesh(void)
Destroy the axlMesh. 
QVector< Face > faceSet(void) const 
Class axlAbstractData defines an API for all type of axel data. 
Class axlMesh defines a piecewise-linear 3D object. 
void push_back_vertex(const double &x, const double &y, const double &z)
Add a new vertex to the mesh.