23 #include <dtkCoreSupport/dtkGlobal.h>
30 class axlShapePrivate {
36 QVector<axlPoint*> vertices;
37 QVector<axlShape::Edge*> edges;
38 QVector<axlShape::Face*> faces;
47 d(new axlShapePrivate) {
49 d->vertexCount = vertexCount;
50 d->edgeCount = edgeCount;
51 d->faceCount = faceCount;
53 d->vertices = QVector<axlPoint*>(vertexCount, NULL);
54 d->edges = QVector<Edge*>(edgeCount, NULL);
55 d->faces = QVector<Face*>(faceCount, NULL);
78 return d->vertexCount;
90 QString desc =
"axlShape:\n";
91 desc +=
" #Vertices: " + QString::number(d->vertexCount) +
"\n";
92 desc +=
" #Edges: " + QString::number(d->edgeCount) +
"\n";
93 desc +=
" #Faces: " + QString::number(d->faceCount) +
"\n\n";
95 for (
int k = 0; k < d->faceCount; k++) {
97 int nbLoops = d->faces.at(k)->loops.size();
98 desc +=
"\nFace\t#" + QString::number(k) +
":\t" + QString::number(nbLoops) +
" loop(s)\n";
99 for (
int i = 0; i < nbLoops; i++) {
100 int nbEdges = d->faces.at(k)->loops.at(i)->edges.size();
101 desc +=
" Loop\t#" + QString::number(i) +
":\t" + QString::number(nbEdges) +
" edge(s)\n";
102 for (
int j = 0; j < nbEdges; j++) {
103 int currIndexEdge = d->faces.at(k)->loops.at(i)->edges.at(j);
104 if (currIndexEdge > -1 && currIndexEdge < d->edges.size()) {
109 desc +=
" Edge\t#" + QString::number(j) +
":\t(" + currCurve->identifier() +
")\n";
111 desc +=
" Edge\t#" + QString::number(j) +
":\tcurve NULL\n";
113 desc +=
" Edge\t#" + QString::number(j) +
":\tNULL\n";
116 desc +=
" Index of Edge out of range:" + QString::number(currIndexEdge) +
"\n";
122 desc +=
" Surface\t:" + currSurf->identifier() +
"\n";
124 desc +=
" Surface is NULL\n";
135 d->vertices.replace(index, vertex);
139 d->edges.replace(index, edge);
144 d->edges.replace(index, edge);
149 QVector<int> edgesSorted;
150 QVector<bool> orientationsSorted;
153 QVector<int> edges = loop->
edges;
161 for (
int k = 0; k < edges.size()-1; k++) {
165 fstEdgeIndex = edges.at(k);
166 fstOrientation = orientations.at(k);
168 edgesSorted << fstEdgeIndex;
169 orientationsSorted << fstOrientation;
173 Edge* fstEdge = d->edges.at(fstEdgeIndex);
187 for (
int i = 1; i <= edges.size(); i++) {
189 int currIndex = (k+i)%edges.size();
191 sndEdgeIndex = edges.at(currIndex);
194 Edge* sndEdge = d->edges.at(sndEdgeIndex);
196 sndOrientation = orientations.at(currIndex);
210 edgesSorted << sndEdgeIndex;
211 orientationsSorted << sndOrientation;
213 fstEdgeIndex = sndEdgeIndex;
214 fstOrientation = sndOrientation;
220 }
else if (i == edges.size()) {
221 dtkError() <<
"Error within void axlShape::sortEdges";
228 loop->
edges = edgesSorted;
233 for (
int k = 0; k < face->
loops.size(); k++) {
240 QVector<axlShape::Loop *> loops;
242 for(
int k = 0;k < nbLoops;k++){
244 for(
int i=0;i < loopsSize[k];i++){
246 loops.at(k)->
edges << l[i];
247 loops.at(k)->orientations << orient[i];
249 loops.at(k)->edges << l[i+loopsSize[k-1]];
250 loops.at(k)->orientations << orient[i+loopsSize[k-1]];
254 face->
loops << loops;
256 d->faces.replace(index, face);
261 QVector<axlShape::Loop *> loops;
263 for(
int k = 0;k < nbLoops;k++){
265 for(
int i=0;i < loopsSize[k];i++){
267 loops.at(k)->
edges << l[i];
268 loops.at(k)->orientations << orient[i];
270 loops.at(k)->edges << l[i+loopsSize[k-1]];
271 loops.at(k)->orientations << orient[i+loopsSize[k-1]];
275 face->
loops << loops;
276 d->faces.replace(index, face);
283 for(
int i=0;i < sizel;i++){
286 for(
int j=0;j < sizeOrient;j++){
291 d->faces.replace(index, face);
298 for(
int i=0;i < sizel;i++){
301 for(
int j=0;j < sizeOrient;j++){
305 d->faces.replace(index, face);
310 d->faces.replace(index, face);
316 QVariant
id = QVariant::fromValue(
identifier());
317 QVariant vertexCount = QVariant::fromValue(d->vertexCount);
318 QVariant faceCount = QVariant::fromValue(d->faceCount);
319 QVariant edgeCount = QVariant::fromValue(d->edgeCount);
324 list.append(vertexCount);
325 list.append(faceCount);
326 list.append(edgeCount);
329 for(
int i = 0; i< d->vertexCount;i++){
330 list.append(d->vertices.at(i)->convertDataToQVariant());
334 for(
int i = 0; i< d->edgeCount;i++){
339 for(
int i = 0; i< d->faceCount;i++){
343 QVariant name = QVariant::fromValue(objectName());
357 for(
int i = 0; i< data.at(1).toInt();i++){
359 double x = data.at(4*i+1+newBegin).toDouble() ;
360 double y = data.at(4*i+2+newBegin).toDouble();
361 double z = data.at(4*i+3+newBegin).toDouble();
367 newBegin = (4*d->vertexCount)+newBegin;
392 setObjectName(data.last().toString());
Class axlPoint defines 3D points.
axlAbstractCurveParametric * curve
Pointer to the parametric curve supporting the edge, of type axlAbstractCurveParametric.
virtual QString identifier(void) const
int indexStartVertex
Index of the starting point of the edge in the array of vertices of the axlShape. ...
axlShape(int vertexCount, int edgeCount, int faceCount, axlShape *parent=0)
QVector< int > edges
Vector of indices of the edges of the loop in the array of edges of the axlShape. ...
QVector< Face * > getFaces(void) const
virtual QString description(void) const
void sortLoops(Face *face)
Sort loops.
QVector< Edge * > getEdges(void) const
int getFaceCount(void) const
int getEdgeCount(void) const
void insert_face(Face *face, int index)
int getVertexCount(void) const
void insert_edge(Edge *edge, int index)
Generic interface for parametric curve.
void sortEdges(Loop *loop)
Sort edges.
QVariantList convertDataToQVariant(void) const
int indexEndVertex
Index of the ending point of the edge in the array of vertices of the axlShape.
void insert_face_with_no_sort(axlAbstractSurfaceParametric *surf, int *l, int *orient, int sizel, int sizeOrient, int index)
QVector< bool > orientations
Vector of booleans of the same size as edges: true means the direct orientation, false is the reverse...
axlAbstractSurfaceParametric * surface
Pointer to the supporting surface of type axlAbstractSurfaceParametric.
int convertQVariantToData(const QVariantList &data)
QVector< Loop * > loops
Vector of all the loops defining the face.
void insert_vertex(axlPoint *vertex, int index)
QVector< axlPoint * > getVertices(void) const
Class axlAbstractData defines an API for all type of axel data.