00327 {
00328
00329
clearVectors();
00330
00331
00332
int rangeOfSamplesProfile =
profile.size();
00333
00334
00335
00336
int sampleRatio = (
int) (rangeOfSamplesProfile /
nbSections);
00337
00338
00339 vector<Point3D *> overSampleAxis;
00340
00341
00342
if (sampleRatio > 1)
00343 {
00344 sampleRatio++;
00345
00346
00347
for (
int i = 0; i <
nbSections - 1; i++)
00348 {
00349
double xStep = ( (*
axis[i + 1])[0] - (*axis[i])[0] ) / sampleRatio;
00350
double yStep = ( (*axis[i + 1])[1] - (*axis[i])[1] ) / sampleRatio;
00351
for (
int j = 0; j < sampleRatio; j++)
00352 {
00353
double x = (*axis[i])[0] + j * xStep;
00354
double y = (*axis[i])[1] + j * yStep;
00355 overSampleAxis.push_back(
new Point3D(x,y,0));
00356 }
00357 }
00358 overSampleAxis.push_back(axis[nbSections - 1]);
00359 nbSections = overSampleAxis.size();
00360
00361 axis = overSampleAxis;
00362 }
00363
00364
00365
00366 vector<Vector3D *> tangents =
calculateTangents();
00367
00368
00369
00370
00371
int index = 0;
00372
00373
00374
00375
double y_min = (*
profile[0])[1];
00376
double y_max = y_min;
00377
00378
00379
for (
int i = 0; i < rangeOfSamplesProfile; i++)
00380 {
00381
double y = (*profile[i])[1];
00382
if (y < y_min)
00383 {
00384 y_min = y;
00385 index = i;
00386 }
00387
if (y > y_max)
00388 y_max = y;
00389 }
00390
00391
00392
double diff_y = y_max - y_min;
00393
00394 vector<int> indexes;
00395 vector<double> radius;
00396
00397
for (
int i = 0; i < rangeOfSamplesProfile - 1; i++)
00398 {
00399
00400
int sense;
00401
00402
00403
float yVariation = (*profile[i + 1])[1] - (*profile[i])[1];
00404
00405
if (yVariation != 0.0)
00406 sense = (
int) (yVariation / abs(yVariation));
00407
else
00408 sense = 0;
00409
00410
double currentRadius = (*profile[i])[0];
00411
double nextRadius = (*profile[i + 1])[0];
00412
00413
00414
00415
int nbSectionsInter = (
int) (nbSections * abs(yVariation) / diff_y);
00416
00417
00418
if (nbSectionsInter < 2)
00419 nbSectionsInter = 2;
00420
00421
00422
int radiusStep = (
int) ( (nextRadius - currentRadius) / (nbSectionsInter - 1));
00423
00424
00425
for (
int j = 0; j < nbSectionsInter - 1; j++)
00426 {
00427 indexes.push_back(index);
00428 radius.push_back(currentRadius + j * radiusStep);
00429
00430
00431
00432
00433
if ( (index == 0) && (sense == -1) )
00434 sense = 0;
00435
if ( (index == nbSections - 1) && (sense == 1) )
00436 sense = 0;
00437
00438
00439 index += sense;
00440 }
00441 }
00442
00443
00444
calculateProfilePoints(points,tangents,radius,indexes);
00445
00446
00447 nbSections = radius.size();
00448
00449
00450
calculateFacets(facets);
00451 }