File indexing completed on 2026-09-13 09:09:25
0001
0002
0003 namespace tools {
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 inline bool hatcher::check_polyline(vec3f* listPoints,unsigned int aNumber){
0016
0017 unsigned int firstOffset =0;
0018
0019 if ( listPoints[0].equals(listPoints[1],FLT_EPSILON*FLT_EPSILON*10)) {
0020 firstOffset =1;
0021 }
0022
0023 if ( listPoints[0].equals(listPoints[aNumber-1],FLT_EPSILON*FLT_EPSILON*10)) {
0024 aNumber --;
0025 }
0026
0027 if ((int)aNumber-firstOffset <3) {
0028 return false;
0029 }
0030
0031
0032
0033
0034 vec3f AB,AC;
0035 AB.setValue(listPoints[1+firstOffset].getValue()[0]-listPoints[0].getValue()[0],
0036 listPoints[1+firstOffset].getValue()[1]-listPoints[0].getValue()[1],
0037 listPoints[1+firstOffset].getValue()[2]-listPoints[0].getValue()[2]);
0038
0039
0040 fResolveResult = RESOLVE_COLINEAR;
0041 unsigned int test = aNumber;
0042 while ((fResolveResult !=0) && (test>2+firstOffset)) {
0043 test--;
0044 AC.setValue(listPoints[test].getValue()[0]-listPoints[0].getValue()[0],
0045 listPoints[test].getValue()[1]-listPoints[0].getValue()[1],
0046 listPoints[test].getValue()[2]-listPoints[0].getValue()[2]);
0047
0048
0049 resolve_system( AB,
0050 AC,
0051 vec3f(.0f,.0f,.0f));
0052 }
0053 if (fResolveResult == RESOLVE_COLINEAR) {
0054 return false;
0055 }
0056
0057
0058
0059
0060
0061 int falsePoints =0;
0062 for (unsigned int a=2+firstOffset;a<aNumber;a++) {
0063 resolve_system( AB,
0064 AC,
0065 vec3f((listPoints[a].getValue()[0]-listPoints[0].getValue()[0]),
0066 (listPoints[a].getValue()[1]-listPoints[0].getValue()[1]),
0067 (listPoints[a].getValue()[2]-listPoints[0].getValue()[2])));
0068 if (fResolveResult != 0){
0069 falsePoints++;
0070 }
0071 }
0072
0073 if (falsePoints !=0) {
0074 return false;
0075 }
0076
0077
0078 if (! ((fOffset[0] == FLT_MAX) && (fOffset[1] == FLT_MAX) && (fOffset[2] == FLT_MAX))){
0079 resolve_system( AB,
0080 AC,
0081 fOffset-listPoints[0]);
0082 if (fResolveResult != 0) {
0083 return false;
0084 }
0085 }
0086 return true;
0087 }
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
0143 std::vector<vec3f> firstComputePoints;
0144 std::vector<vec3f> secondComputePoints;
0145 std::vector<bool> firstComputePointsEnable;
0146 std::vector<bool> secondComputePointsEnable;
0147 std::vector< std::vector<int> > firstComputeConflictNumHatchLineTab;
0148
0149 int firstComputeFirstNumHatch =0;
0150 unsigned int firstComputeNumberHatchToDraw =0;
0151 float firstHatchShiftToMatchFirstPoint = FLT_MAX;
0152 float secondHatchShiftToMatchFirstPoint = FLT_MAX;
0153
0154 if ( !compute_single_polyline (tabPoints,aNumber))
0155 return false;
0156 if (fStripWidth ==0)
0157 return true;
0158
0159
0160
0161 for (unsigned int a =0;a<fPoints.size();a++){
0162 firstComputePoints.push_back(fPoints[a]);
0163 }
0164
0165 firstComputeConflictNumHatchLineTab.resize(fConflictNumHatchLineTab.size());
0166 for (unsigned int a=0;a<fConflictNumHatchLineTab.size();a++){
0167 firstComputeConflictNumHatchLineTab[a].clear();
0168 for (unsigned int b=0;b<fConflictNumHatchLineTab[a].size();b++){
0169 firstComputeConflictNumHatchLineTab[a].push_back(fConflictNumHatchLineTab[a][b]);
0170 }
0171 }
0172 firstComputeFirstNumHatch = fFirstNumHatch;
0173 firstComputeNumberHatchToDraw = fNumberHatchToDraw;
0174 firstHatchShiftToMatchFirstPoint = fHatchShiftToMatchPointVec[0];
0175
0176 fOffset = fOffset+fShiftVec*fStripWidth;
0177
0178
0179 if ( !compute_single_polyline (tabPoints,aNumber))
0180 return false;
0181
0182
0183 for (unsigned int a =0;a<fPoints.size();a++){
0184 secondComputePoints.push_back(fPoints[a]);
0185 }
0186
0187 secondHatchShiftToMatchFirstPoint = fHatchShiftToMatchPointVec[0];
0188
0189
0190
0191 fPoints.clear();
0192 fVertices.clear();
0193
0194 int specialCase=1;
0195
0196
0197 if ((firstComputeFirstNumHatch == fFirstNumHatch) && (firstComputeNumberHatchToDraw == fNumberHatchToDraw) && (firstComputeNumberHatchToDraw !=0)) {
0198 specialCase =1;
0199 }
0200
0201 else if ((firstComputeFirstNumHatch > fFirstNumHatch) && (firstComputeNumberHatchToDraw < fNumberHatchToDraw) && (firstComputeNumberHatchToDraw !=0)) {
0202
0203 firstComputeConflictNumHatchLineTab.insert(firstComputeConflictNumHatchLineTab.begin(), firstComputeConflictNumHatchLineTab.back());
0204 firstComputeConflictNumHatchLineTab[0].resize(0);
0205 firstComputeFirstNumHatch--;
0206 firstComputeNumberHatchToDraw ++;
0207 firstComputeConflictNumHatchLineTab[0].clear();
0208 specialCase =2;
0209
0210 }
0211 else if (((firstComputeFirstNumHatch > fFirstNumHatch) && (firstComputeNumberHatchToDraw == fNumberHatchToDraw)) && (firstComputeNumberHatchToDraw !=0)) {
0212
0213 firstComputeConflictNumHatchLineTab.insert(firstComputeConflictNumHatchLineTab.begin(),firstComputeConflictNumHatchLineTab.back());
0214 firstComputeConflictNumHatchLineTab[0].resize(0);
0215 firstComputeConflictNumHatchLineTab[0].clear();
0216
0217 fConflictNumHatchLineTab.push_back(firstComputeConflictNumHatchLineTab.back());
0218 fConflictNumHatchLineTab.back().resize(0);
0219 fConflictNumHatchLineTab.back().clear();
0220 firstComputeFirstNumHatch--;
0221 firstComputeNumberHatchToDraw ++;
0222 specialCase =3;
0223 }
0224 else if (((firstComputeFirstNumHatch == fFirstNumHatch) && (firstComputeNumberHatchToDraw > fNumberHatchToDraw)) && (firstComputeNumberHatchToDraw !=0)) {
0225
0226 fConflictNumHatchLineTab.push_back(firstComputeConflictNumHatchLineTab.back());
0227 fConflictNumHatchLineTab.back().resize(0);
0228 fConflictNumHatchLineTab.back().clear();
0229 specialCase =4;
0230
0231 }
0232 else if ((firstComputeNumberHatchToDraw ==0) && (fNumberHatchToDraw !=0)) {
0233
0234 firstComputeConflictNumHatchLineTab.insert(firstComputeConflictNumHatchLineTab.begin(),firstComputeConflictNumHatchLineTab.back());
0235 firstComputeConflictNumHatchLineTab[0].resize(0);
0236 firstComputeConflictNumHatchLineTab[0].clear();
0237 firstComputeNumberHatchToDraw ++;
0238 specialCase =5;
0239
0240 }
0241 else if (floorf(firstHatchShiftToMatchFirstPoint) != floorf(secondHatchShiftToMatchFirstPoint)) {
0242 specialCase =6;
0243
0244
0245 fVertices.push_back(aNumber);
0246 for (unsigned int a =0;a<aNumber;a++){
0247 fPoints.push_back(tabPoints[a]);
0248 }
0249 return true;
0250 }
0251 else if (floorf(firstHatchShiftToMatchFirstPoint) == floorf(secondHatchShiftToMatchFirstPoint)) {
0252 specialCase =7;
0253 return true;
0254 } else {
0255
0256 }
0257
0258
0259 bool result;
0260 bool find;
0261 int firstHatchComputePoint = 0;
0262 int secondHatchComputePoint = 0;
0263 unsigned int lineNumber;
0264 unsigned int firstPointTabInd =0;
0265 unsigned int secondPointTabInd=0;
0266 unsigned int currentHatch;
0267 unsigned int solution;
0268 unsigned int indTmp;
0269 unsigned int oldSolution;
0270 for (unsigned int indHatch =0;indHatch<firstComputeNumberHatchToDraw;indHatch++) {
0271
0272
0273 currentHatch =0;
0274 solution =99;
0275 indTmp = 0;
0276 lineNumber = 0;
0277 secondComputePointsEnable.clear();
0278 firstComputePointsEnable.clear();
0279 for (unsigned int a=0;a<firstComputeConflictNumHatchLineTab[indHatch].size();a++){
0280 firstComputePointsEnable.push_back(false);}
0281 for (unsigned int a=0;a<fConflictNumHatchLineTab[indHatch].size();a++){
0282 secondComputePointsEnable.push_back(false);}
0283
0284 if ((indHatch == 0) && ((specialCase ==2) || (specialCase ==3) || (specialCase ==5))) {
0285 for (unsigned int a=0;a<firstComputeConflictNumHatchLineTab[indHatch].size();a++){
0286 firstComputePointsEnable[a] = true;
0287 }
0288 }
0289 if ((indHatch == (firstComputeNumberHatchToDraw-1)) && ((specialCase ==3) || (specialCase ==4))) {
0290 for (unsigned int a=0;a<fConflictNumHatchLineTab[indHatch].size();a++){
0291 secondComputePointsEnable[a] = true;
0292 }
0293 }
0294
0295 result = false;
0296 while (result == false) {
0297
0298
0299
0300 result =true;
0301 unsigned int b=0;
0302 while ((result == true) && (b<firstComputeConflictNumHatchLineTab[indHatch].size())) {
0303 if (firstComputePointsEnable[b] == false) {
0304 result =false;
0305 firstHatchComputePoint = b;
0306 lineNumber = firstComputeConflictNumHatchLineTab[indHatch][b];
0307 fPoints.push_back(firstComputePoints[b+firstPointTabInd]);
0308 fVertices.push_back(1);
0309 firstComputePointsEnable[b] = true;
0310 currentHatch = 0;
0311 }
0312 b++;
0313 }
0314 if (result ==true) {
0315
0316
0317 while ((result == true) && (b<fConflictNumHatchLineTab[indHatch].size())) {
0318 if (secondComputePointsEnable[b] == false) {
0319 result =false;
0320 secondHatchComputePoint = b;
0321 lineNumber = fConflictNumHatchLineTab[indHatch][b];
0322 fPoints.push_back(secondComputePoints[b+secondPointTabInd]);
0323 fVertices.push_back(1);
0324 secondComputePointsEnable[b] = true;
0325 currentHatch = 1;
0326 }
0327 b++;
0328 }
0329 }
0330 if (result == true) {
0331 }
0332 solution =99;
0333 while (solution !=0) {
0334 oldSolution = solution;
0335 solution =0;
0336
0337
0338
0339
0340
0341
0342
0343 if (currentHatch != 1) {
0344
0345 if (oldSolution != 3) {
0346 int index =0;
0347 if ((firstHatchComputePoint % 2 == 0) && (firstComputePointsEnable[firstHatchComputePoint+1] == false)) index =1;
0348 else if ((firstHatchComputePoint % 2 != 0) && (firstComputePointsEnable[firstHatchComputePoint-1] == false)) index = -1;
0349 if (index !=0) {
0350 solution = 1;
0351 oldSolution = 0;
0352 firstHatchComputePoint = firstHatchComputePoint+index;
0353 fPoints.push_back(firstComputePoints[firstHatchComputePoint+firstPointTabInd]);
0354 fVertices.back() ++;
0355 firstComputePointsEnable[firstHatchComputePoint] = true;
0356 lineNumber = firstComputeConflictNumHatchLineTab[indHatch][firstHatchComputePoint];
0357 }
0358 }
0359 if (solution == 0) {
0360 indTmp = 0;
0361 while ((solution == 0) && (indTmp < fConflictNumHatchLineTab[indHatch].size())) {
0362 if ((fConflictNumHatchLineTab[indHatch][indTmp] == (int)lineNumber) && (secondComputePointsEnable[indTmp] == false)) {
0363 solution =2;
0364 oldSolution = 0;
0365 fPoints.push_back(secondComputePoints[indTmp+secondPointTabInd]);
0366 fVertices.back() ++;
0367 secondComputePointsEnable[indTmp] = true;
0368 lineNumber = fConflictNumHatchLineTab[indHatch][indTmp];
0369 secondHatchComputePoint = indTmp;
0370 currentHatch =1;
0371 }
0372 indTmp ++;
0373 }
0374 }
0375 if (solution == 0) {
0376 indTmp = 0;
0377 while ((solution == 0) && (indTmp < aNumber)) {
0378
0379 if ((fHatchShiftToMatchPointVec[indTmp] > ((float)firstComputeFirstNumHatch+(float)indHatch-fStripWidth))
0380 && (fHatchShiftToMatchPointVec[indTmp] < ((float)firstComputeFirstNumHatch+(float)indHatch))
0381 && ((indTmp == lineNumber) || (indTmp==lineNumber+1) || ((lineNumber == (aNumber-1)) && (indTmp ==0)))) {
0382 find = false;
0383 unsigned a =0;
0384 while ((a<fVertices.back()) && (find == false)) {
0385 if ((tabPoints[indTmp][0] == fPoints[a][0]) && (tabPoints[indTmp][1] == fPoints[a][1]) && (tabPoints[indTmp][2] == fPoints[a][2])) find = true;
0386 a++;
0387 }
0388 if (find == false){
0389 solution = 3;
0390 oldSolution = 0;
0391 currentHatch =2;
0392 fPoints.push_back(tabPoints[indTmp]);
0393 fVertices.back() ++;
0394 if (lineNumber == indTmp) {
0395 if (indTmp >0) lineNumber = indTmp-1;
0396 else lineNumber = aNumber-1;
0397 }
0398 else {
0399 if (indTmp < aNumber-1) lineNumber = indTmp;
0400 else lineNumber = 0;
0401 }
0402 }
0403 }
0404 indTmp++;
0405 }
0406 }
0407 }
0408
0409
0410 if ((oldSolution != 0) && (solution !=2) && (currentHatch !=0)) {
0411
0412 if (oldSolution != 3){
0413 int index =0;
0414 if ((secondHatchComputePoint % 2 == 0) && (secondComputePointsEnable[secondHatchComputePoint+1] == false)) index =1;
0415 else if ((secondHatchComputePoint % 2 != 0) && (secondComputePointsEnable[secondHatchComputePoint-1] == false)) index = -1;
0416 if (index !=0){
0417 solution = 1;
0418 secondHatchComputePoint = secondHatchComputePoint+index;
0419 fPoints.push_back(secondComputePoints[secondHatchComputePoint+secondPointTabInd]);
0420 fVertices.back() ++;
0421 secondComputePointsEnable[secondHatchComputePoint] = true;
0422 lineNumber = fConflictNumHatchLineTab[indHatch][secondHatchComputePoint];
0423 }
0424 }
0425 if (solution == 0) {
0426 indTmp = 0;
0427 while ((solution == 0) && (indTmp < firstComputeConflictNumHatchLineTab[indHatch].size())) {
0428 if ((firstComputeConflictNumHatchLineTab[indHatch][indTmp] == (int)lineNumber) && (firstComputePointsEnable[indTmp] == false)) {
0429 solution =2;
0430 fPoints.push_back(firstComputePoints[indTmp+firstPointTabInd]);
0431 fVertices.back() ++;
0432 firstComputePointsEnable[indTmp] = true;
0433 lineNumber = firstComputeConflictNumHatchLineTab[indHatch][indTmp];
0434 firstHatchComputePoint = indTmp;
0435 currentHatch =0;
0436 }
0437 indTmp ++;
0438 }
0439 }
0440 if (solution == 0) {
0441 indTmp = 0;
0442 while ((solution == 0) && (indTmp < aNumber)) {
0443
0444 if ((fHatchShiftToMatchPointVec[indTmp] > ((float)fFirstNumHatch+(float)indHatch-fStripWidth))
0445 && (fHatchShiftToMatchPointVec[indTmp] < ((float)fFirstNumHatch+(float)indHatch))
0446 && ((indTmp == lineNumber) || (indTmp==lineNumber+1) || ((lineNumber == (aNumber-1)) && (indTmp ==0)))) {
0447 find = false;
0448 unsigned a =0;
0449 while ((a<fVertices.back()) && (find == false)) {
0450 if ((tabPoints[indTmp][0] == fPoints[a][0]) && (tabPoints[indTmp][1] == fPoints[a][1]) && (tabPoints[indTmp][2] == fPoints[a][2])) find = true;
0451 a++;
0452 }
0453 if (find == false){
0454 currentHatch =2;
0455 solution = 3;
0456 fPoints.push_back(tabPoints[indTmp]);
0457 fVertices.back() ++;
0458 if (lineNumber == indTmp) {
0459 if (indTmp >0) lineNumber = indTmp-1;
0460 else lineNumber = aNumber-1;
0461 }
0462 else {
0463 if (indTmp < aNumber-1) lineNumber = indTmp;
0464 else lineNumber = 0;
0465 }
0466 }
0467 }
0468 indTmp++;
0469 }
0470 }
0471 }
0472 if (solution == 0) {
0473
0474
0475 fPoints.push_back(fPoints[fPoints.size()-fVertices.back()]);
0476 fVertices.back() ++;
0477 result =true;
0478 }
0479 }
0480
0481 }
0482 for (unsigned int a =0;a<fVertices.size();a++){
0483 }
0484
0485 firstPointTabInd += firstComputeConflictNumHatchLineTab[indHatch].size();
0486 secondPointTabInd += fConflictNumHatchLineTab[indHatch].size();
0487 }
0488 return true;
0489 }
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501 inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNumber) {
0502 std::vector<vec3f> listNormalVec;
0503 int numberOfPolylinePoints =0;
0504 fPoints.resize(0);
0505 fPoints.clear();
0506 int precisionError =0;
0507 unsigned int firstOffset =0;
0508 fFirstNumHatch =0;
0509 fNumberHatchToDraw =0;
0510 fVertices.resize(0);
0511 fVertices.clear();
0512
0513 if ( tabPoints[0].equals(tabPoints[1].getValue(),FLT_EPSILON*FLT_EPSILON*10)) {
0514 firstOffset =1; }
0515
0516 vec3f* listPoints = new vec3f[aNumber+1-firstOffset];
0517
0518 for (unsigned int i=0;i<aNumber;i++){
0519 if ((i==0) || (listPoints[i-1] !=tabPoints[i+firstOffset])) {
0520 listPoints[numberOfPolylinePoints] = tabPoints[i+firstOffset];
0521 numberOfPolylinePoints++;
0522 }
0523 }
0524
0525
0526 if ( ! listPoints[0].equals(listPoints[numberOfPolylinePoints-1].getValue(),FLT_EPSILON*FLT_EPSILON*10)) {
0527 listPoints[numberOfPolylinePoints]=listPoints[0];
0528 numberOfPolylinePoints ++;
0529 }
0530
0531
0532
0533 vec3f AB,AC;
0534 AB.setValue(listPoints[1].getValue()[0]-listPoints[0].getValue()[0],
0535 listPoints[1].getValue()[1]-listPoints[0].getValue()[1],
0536 listPoints[1].getValue()[2]-listPoints[0].getValue()[2]);
0537
0538 fResolveResult = RESOLVE_COLINEAR;
0539 unsigned int test = numberOfPolylinePoints-1;
0540 while ((fResolveResult !=0) && (test>1)) {
0541 test--;
0542 AC.setValue(listPoints[test].getValue()[0]-listPoints[0].getValue()[0],
0543 listPoints[test].getValue()[1]-listPoints[0].getValue()[1],
0544 listPoints[test].getValue()[2]-listPoints[0].getValue()[2]);
0545
0546
0547 resolve_system( AB,
0548 AC,
0549 vec3f(.0f,.0f,.0f));
0550 }
0551 if (fResolveResult == RESOLVE_COLINEAR) {
0552 delete [] listPoints;
0553 return false;
0554 }
0555
0556
0557
0558
0559
0560
0561
0562
0563 if (fFirstPolyline) {
0564
0565 fFirstPolyline = false;
0566
0567 fNormal.setValue(AB[1]*AC[2]-AB[2]*AC[1],
0568 AB[2]*AC[0]-AB[0]*AC[2],
0569 AB[0]*AC[1]-AB[1]*AC[0]);
0570
0571
0572
0573 vec3f ABPerpVector;
0574 ABPerpVector.setValue(fNormal[1]*AB[2]-fNormal[2]*AB[1],
0575 fNormal[2]*AB[0]-fNormal[0]*AB[2],
0576 fNormal[0]*AB[1]-fNormal[1]*AB[0]);
0577
0578 float normAB =(float)std::sqrt(std::pow(AB[0],2)+
0579 std::pow(AB[1],2)+
0580 std::pow(AB[2],2));
0581 float normABPerpVector =(float)std::sqrt(std::pow(ABPerpVector[0],2)+
0582 std::pow(ABPerpVector[1],2)+
0583 std::pow(ABPerpVector[2],2));
0584
0585 float j = std::tan(fDirAngle)*normAB/normABPerpVector;
0586
0587 if (normABPerpVector == 0){
0588 delete [] listPoints;
0589 return false;
0590 }
0591
0592 fDirVec = AB +(float)j*ABPerpVector;
0593
0594 if (fDirVec.getValue()[0] ==0){
0595 fDirVec[0] = fPrecisionFactor;
0596 fDirVec = fDirVec/fDirVec.getValue()[1];
0597 } else {
0598 fDirVec = fDirVec/fDirVec.getValue()[0];
0599 }
0600
0601
0602
0603
0604
0605 vec3f dirShiftVector;
0606 dirShiftVector.setValue(fNormal[1]*fDirVec.getValue()[2]-fNormal[2]*fDirVec.getValue()[1],
0607 fNormal[2]*fDirVec.getValue()[0]-fNormal[0]*fDirVec.getValue()[2],
0608 fNormal[0]*fDirVec.getValue()[1]-fNormal[1]*fDirVec.getValue()[0]);
0609
0610
0611 float param = 1.0f;
0612 param = (float)std::sqrt((std::pow(fShift,2))/(
0613 std::pow(dirShiftVector[0],2)+
0614 std::pow(dirShiftVector[1],2)+
0615 std::pow(dirShiftVector[2],2)));
0616 fShiftVec = dirShiftVector*param;
0617
0618
0619 if ((fOffset[0] == FLT_MAX) && (fOffset[1] == FLT_MAX) && (fOffset[2] == FLT_MAX)){
0620 fOffset = listPoints[0]+fShiftVec*fOffsetValue;
0621 }
0622 }
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640 fHatchShiftToMatchPointVec.resize(numberOfPolylinePoints+1);
0641 float minShiftHatch =FLT_MAX;
0642 float maxShiftHatch =-FLT_MAX;
0643 vec2f res;
0644
0645 for (int a=0;a<numberOfPolylinePoints;a++) {
0646 res = resolve_system(fDirVec.getValue(),
0647 fShiftVec,
0648 listPoints[a]-fOffset);
0649
0650 if (fResolveResult ==0 ) {
0651 fHatchShiftToMatchPointVec[a] = res[1];
0652 if (res[1]>maxShiftHatch) {
0653 maxShiftHatch = res[1];
0654 }
0655 if (res[1]<minShiftHatch) {
0656 minShiftHatch = res[1];
0657 }
0658 }
0659 else {
0660 delete [] listPoints;
0661 return false;
0662 }
0663 }
0664
0665 fHatchShiftToMatchPointVec[numberOfPolylinePoints] = fHatchShiftToMatchPointVec[0];
0666 fFirstNumHatch = (int)(ceilf(minShiftHatch));
0667 fNumberHatchToDraw = (int)(floorf(maxShiftHatch)-fFirstNumHatch+1);
0668 if ((int)(floorf(maxShiftHatch)-fFirstNumHatch+1) <0) fNumberHatchToDraw =0;
0669
0670 int moreNumberHatchToDraw = fNumberHatchToDraw+1;
0671 std::vector<vec3f> listHatchStartPoint;
0672 std::vector<vec3f> listHatchEndPoint;
0673 std::vector<int> numberOfStartEndPointsVec;
0674
0675 fConflictNumHatchLineTab.resize(moreNumberHatchToDraw);
0676
0677
0678 for (int a=0;a<moreNumberHatchToDraw;a++) {
0679 numberOfStartEndPointsVec.push_back(0);
0680 listHatchStartPoint.push_back(vec3f(.0f,.0f,.0f));
0681 listHatchEndPoint.push_back(vec3f(.0f,.0f,.0f));
0682 fConflictNumHatchLineTab[a].clear();
0683 }
0684
0685
0686
0687
0688
0689
0690 for (int a=0;a<numberOfPolylinePoints-1;a++) {
0691 res = resolve_system(fDirVec.getValue(),
0692 vec3f(listPoints[a].getValue()[0]-listPoints[a+1].getValue()[0],
0693 listPoints[a].getValue()[1]-listPoints[a+1].getValue()[1],
0694 listPoints[a].getValue()[2]-listPoints[a+1].getValue()[2]),
0695 -fShiftVec);
0696 if (fResolveResult ==0 ) {
0697 listNormalVec.push_back(vec3f(res[1]*(listPoints[a+1].getValue()[0]-listPoints[a].getValue()[0]),
0698 res[1]*(listPoints[a+1].getValue()[1]-listPoints[a].getValue()[1]),
0699 res[1]*(listPoints[a+1].getValue()[2]-listPoints[a].getValue()[2])
0700 ));
0701 }
0702 else if (fResolveResult == RESOLVE_Z_ERROR ) {
0703 delete [] listPoints;
0704 return false;
0705 }
0706 else{
0707 listNormalVec.push_back(vec3f(FLT_MAX,FLT_MAX,FLT_MAX));
0708 }
0709 }
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726 vec3f newPoint;
0727 int minHatch;
0728 int maxHatch;
0729 int hatchIndice =0;
0730
0731 for (int indPolyline=0;indPolyline<numberOfPolylinePoints-1;indPolyline++) {
0732 minHatch = (int)(ceilf(fHatchShiftToMatchPointVec[indPolyline]));
0733 maxHatch = (int)(floorf(fHatchShiftToMatchPointVec[indPolyline+1]));
0734
0735 if (fHatchShiftToMatchPointVec[indPolyline+1] <fHatchShiftToMatchPointVec[indPolyline]) {
0736 minHatch =(int)(ceilf(fHatchShiftToMatchPointVec[indPolyline+1]));
0737 maxHatch = (int)(floorf(fHatchShiftToMatchPointVec[indPolyline]));
0738 }
0739 for (int b=minHatch;b<=maxHatch;b++) {
0740
0741 hatchIndice = b-fFirstNumHatch;
0742
0743 newPoint.setValue(listPoints[indPolyline].getValue()[0]+
0744 listNormalVec[indPolyline][0]*(b-fHatchShiftToMatchPointVec[indPolyline]),
0745 listPoints[indPolyline].getValue()[1]+
0746 listNormalVec[indPolyline][1]*(b-fHatchShiftToMatchPointVec[indPolyline]),
0747 listPoints[indPolyline].getValue()[2]+
0748 listNormalVec[indPolyline][2]*(b-fHatchShiftToMatchPointVec[indPolyline]));
0749
0750 if (numberOfStartEndPointsVec[hatchIndice] == 0) {
0751
0752
0753
0754
0755
0756 if ( (listNormalVec[indPolyline][0] != FLT_MAX)
0757 && (listNormalVec[indPolyline][1] != FLT_MAX)
0758 && (listNormalVec[indPolyline][2] != FLT_MAX)) {
0759 listHatchStartPoint[hatchIndice] = vec3f(newPoint);
0760 fConflictNumHatchLineTab[hatchIndice].push_back(indPolyline);
0761 numberOfStartEndPointsVec[hatchIndice]++;
0762 }
0763 } else if (numberOfStartEndPointsVec[hatchIndice] == 1) {
0764
0765
0766
0767
0768
0769 if ((listNormalVec[indPolyline][0] != FLT_MAX)
0770 && (listNormalVec[indPolyline][1] != FLT_MAX)
0771 && (listNormalVec[indPolyline][2] != FLT_MAX)) {
0772 listHatchEndPoint[hatchIndice] = vec3f(newPoint);
0773 fConflictNumHatchLineTab[hatchIndice].push_back(indPolyline);
0774 numberOfStartEndPointsVec[hatchIndice]++;
0775 }
0776 } else {
0777
0778
0779
0780 fConflictNumHatchLineTab[hatchIndice].push_back(indPolyline);
0781 }
0782 }
0783 }
0784
0785
0786
0787
0788 std::vector<float> listCoefDirHatch(fNumberHatchToDraw);
0789 std::vector<vec3f> listConflictPoints(numberOfPolylinePoints);
0790
0791 vec3f ABVec,tempVec;
0792 int valid =false;
0793 bool drawEnabled = false;
0794 float temp=0;
0795 int tempInt =0;
0796 float nextPointConflictHatchNumber = -FLT_MAX;
0797 float currentPointConflictHatchNumber = -FLT_MAX;
0798 std::vector<unsigned int> orderConflictLineNumber;
0799
0800 for (unsigned int hatchNumber =0;hatchNumber<fNumberHatchToDraw;hatchNumber++) {
0801 if ( fConflictNumHatchLineTab[hatchNumber].size() <= 2) {
0802 if (!listHatchStartPoint[hatchNumber].equals(listHatchEndPoint[hatchNumber],FLT_EPSILON*FLT_EPSILON*10)) {
0803 fPoints.push_back(listHatchStartPoint[hatchNumber]);
0804 fPoints.push_back(listHatchEndPoint[hatchNumber]);
0805 fVertices.push_back(2);
0806 }
0807 } else {
0808
0809
0810
0811
0812
0813
0814
0815 listConflictPoints.clear();
0816 listCoefDirHatch.clear();
0817 std::vector <unsigned int> toRemove;
0818 for (unsigned int conflictLineNumber=0;conflictLineNumber<fConflictNumHatchLineTab[hatchNumber].size();conflictLineNumber++ )
0819 {
0820
0821 ABVec.setValue(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]+1].getValue()[0]-listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]].getValue()[0],
0822 listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]+1].getValue()[1]-listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]].getValue()[1],
0823 listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]+1].getValue()[2]-listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]].getValue()[2]);
0824
0825 res = resolve_system(fDirVec.getValue(),
0826 ABVec,
0827 vec3f(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]].getValue()[0]-fOffset[0]-((float)hatchNumber+(float)fFirstNumHatch)*fShiftVec[0],
0828 listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]].getValue()[1]-fOffset[1]-((float)hatchNumber+(float)fFirstNumHatch)*fShiftVec[1],
0829 listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]].getValue()[2]-fOffset[2]-((float)hatchNumber+(float)fFirstNumHatch)*fShiftVec[2]));
0830
0831 if (fResolveResult ==0 ) {
0832
0833 listCoefDirHatch.push_back(2);
0834 listCoefDirHatch.pop_back();
0835 listCoefDirHatch.push_back(res[0]);
0836 res[1] = -res[1];
0837 listConflictPoints.push_back(vec3f(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]]+ABVec*res[1]));
0838 }
0839 else if (fResolveResult != RESOLVE_COLINEAR){
0840 precisionError++;
0841 } else {
0842 toRemove.push_back(conflictLineNumber);
0843 }
0844 }
0845
0846 if (toRemove.size()) {
0847 for (unsigned int conflictLineNumber=0;conflictLineNumber<fConflictNumHatchLineTab[hatchNumber].size();conflictLineNumber++ ) {
0848 }
0849
0850 for (unsigned int aa=0;aa<toRemove.size();aa++) {
0851 unsigned int ind = 0;
0852 for (std::vector<int>::iterator it = fConflictNumHatchLineTab[hatchNumber].begin();it !=fConflictNumHatchLineTab[hatchNumber].end();it++) {
0853 if (ind == toRemove[aa]) {
0854 fConflictNumHatchLineTab[hatchNumber].erase(it);
0855 break;
0856 }
0857 ind++;
0858 }
0859 }
0860 for (unsigned int conflictLineNumber=0;conflictLineNumber<fConflictNumHatchLineTab[hatchNumber].size();conflictLineNumber++ ) {
0861 }
0862 }
0863 if (listCoefDirHatch.size() != 0) {
0864
0865
0866
0867
0868 valid = false;
0869 while (valid ==false )
0870 {
0871 valid = true;
0872 for (unsigned int sort =0;sort< listCoefDirHatch.size()-1;sort++)
0873 {
0874 if (listCoefDirHatch[sort]>listCoefDirHatch[sort+1]) {
0875
0876 temp = listCoefDirHatch[sort];
0877 listCoefDirHatch[sort] = listCoefDirHatch[sort+1];
0878 listCoefDirHatch[sort+1] =temp;
0879 tempVec = listConflictPoints[sort];
0880 listConflictPoints[sort] = listConflictPoints[sort+1];
0881 listConflictPoints[sort+1] = tempVec;
0882 tempInt = fConflictNumHatchLineTab[hatchNumber][sort];
0883 fConflictNumHatchLineTab[hatchNumber][sort] = fConflictNumHatchLineTab[hatchNumber][sort+1];
0884 fConflictNumHatchLineTab[hatchNumber][sort+1] = tempInt;
0885 valid= false;
0886 }
0887 }
0888 }
0889
0890
0891
0892 unsigned int conflictNumber =0;
0893 orderConflictLineNumber.clear();
0894
0895 drawEnabled = false;
0896 while (conflictNumber < fConflictNumHatchLineTab[hatchNumber].size()) {
0897 if (conflictNumber+1 == fConflictNumHatchLineTab[hatchNumber].size()) {
0898 if(drawEnabled) {
0899 drawEnabled = false;
0900 fPoints.push_back(listConflictPoints[conflictNumber].getValue());
0901 orderConflictLineNumber.push_back(fConflictNumHatchLineTab[hatchNumber][conflictNumber]);
0902 }
0903 }
0904 else {
0905
0906
0907
0908 if ( !(listConflictPoints[conflictNumber].equals(listConflictPoints[conflictNumber+1],FLT_EPSILON*FLT_EPSILON*10))) {
0909
0910 unsigned int follow=conflictNumber+1;
0911 bool overContour = false;
0912 while ((follow <fConflictNumHatchLineTab[hatchNumber].size()) &&
0913 (listConflictPoints[conflictNumber].equals(listConflictPoints[follow],FLT_EPSILON*FLT_EPSILON*10))) {
0914 follow++;
0915 }
0916
0917 if(follow < fConflictNumHatchLineTab[hatchNumber].size()) {
0918 if ((listConflictPoints[follow].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][follow]].getValue(),FLT_EPSILON*FLT_EPSILON*10))) {
0919 if ((fConflictNumHatchLineTab[hatchNumber][follow] != 0) &&
0920 (fConflictNumHatchLineTab[hatchNumber][follow] != numberOfPolylinePoints-1)) {
0921 if ((listConflictPoints[conflictNumber].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][follow]-1].getValue(),FLT_EPSILON*FLT_EPSILON*10)) ||
0922 (listConflictPoints[conflictNumber].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][follow]+1].getValue(),FLT_EPSILON*FLT_EPSILON*10))) {
0923 overContour = true;
0924 }
0925 }
0926 }
0927 }
0928 int previous=conflictNumber-1;
0929 while ((previous >=0) &&
0930 (listConflictPoints[conflictNumber].equals(listConflictPoints[previous],FLT_EPSILON*FLT_EPSILON*10))) {
0931 previous--;
0932 }
0933
0934 if(previous >= 0) {
0935 if ((listConflictPoints[conflictNumber].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber]].getValue(),FLT_EPSILON*FLT_EPSILON*10))) {
0936 if ((listConflictPoints[previous].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber]-1].getValue(),FLT_EPSILON*FLT_EPSILON*10)) ||
0937 (listConflictPoints[previous].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber]+1].getValue(),FLT_EPSILON*FLT_EPSILON*10))) {
0938 overContour = true;
0939 }
0940 }
0941 }
0942 if (!overContour) {
0943 fPoints.push_back(listConflictPoints[conflictNumber].getValue());
0944 orderConflictLineNumber.push_back(fConflictNumHatchLineTab[hatchNumber][conflictNumber]);
0945 drawEnabled = drawEnabled?false:true;
0946 if (drawEnabled) {
0947 fVertices.push_back(2);
0948 }
0949 } else {
0950 if (drawEnabled) {
0951 fPoints.push_back(listConflictPoints[conflictNumber].getValue());
0952 orderConflictLineNumber.push_back(fConflictNumHatchLineTab[hatchNumber][conflictNumber]);
0953 drawEnabled = false;
0954 }
0955 }
0956 }
0957 else {
0958 bool currentPointCrossLine = false;
0959 bool nextPointCrossLine = false;
0960
0961
0962
0963
0964 if (listConflictPoints[conflictNumber].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber]].getValue(),FLT_EPSILON*FLT_EPSILON*10)) {
0965
0966 currentPointConflictHatchNumber = fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber]+1];
0967 }
0968 else if (listConflictPoints[conflictNumber].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber]+1].getValue(),FLT_EPSILON*FLT_EPSILON*10)) {
0969
0970 currentPointConflictHatchNumber = fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber]];
0971 }
0972 else {
0973
0974 currentPointCrossLine = true;
0975 currentPointConflictHatchNumber =-1 ;
0976 }
0977
0978 if (listConflictPoints[conflictNumber+1].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber+1]].getValue(),FLT_EPSILON*FLT_EPSILON*10)) {
0979
0980 nextPointConflictHatchNumber = fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber+1]+1];
0981 }
0982 else if (listConflictPoints[conflictNumber+1].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber+1]+1].getValue(),FLT_EPSILON*FLT_EPSILON*10)) {
0983
0984 nextPointConflictHatchNumber = fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber+1]];
0985 }
0986 else {
0987
0988 nextPointConflictHatchNumber = -1;
0989 nextPointCrossLine = true;
0990 }
0991
0992
0993
0994
0995
0996 if (currentPointCrossLine && nextPointCrossLine) {
0997
0998
0999 }
1000
1001 else if ((!currentPointCrossLine && !nextPointCrossLine) && (currentPointConflictHatchNumber == nextPointConflictHatchNumber) && (currentPointConflictHatchNumber == fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber]])) {
1002 if (drawEnabled) {
1003 fPoints.push_back(listConflictPoints[conflictNumber].getValue());
1004 orderConflictLineNumber.push_back(fConflictNumHatchLineTab[hatchNumber][conflictNumber]);
1005 drawEnabled = false;
1006 }
1007 }
1008
1009 else if( ( (currentPointConflictHatchNumber -
1010 fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber]]) *
1011 (nextPointConflictHatchNumber -
1012 fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber]]))
1013 <=FLT_EPSILON) {
1014
1015 unsigned int follow=conflictNumber+1;
1016 bool overContour = false;
1017 while ((follow <fConflictNumHatchLineTab[hatchNumber].size()) &&
1018 (listConflictPoints[conflictNumber].equals(listConflictPoints[follow],FLT_EPSILON*FLT_EPSILON*10))) {
1019 follow++;
1020 }
1021 if(follow < fConflictNumHatchLineTab[hatchNumber].size()) {
1022 float alpha = 0;
1023 bool findAlpha = true;
1024 if (listConflictPoints[follow][0] != listConflictPoints[conflictNumber][0]) {
1025 alpha = (listPoints[fConflictNumHatchLineTab[hatchNumber][follow]][0]-listConflictPoints[conflictNumber][0])/(listConflictPoints[follow][0]-listConflictPoints[conflictNumber][0]);
1026 }
1027 else if (listConflictPoints[follow][1] != listConflictPoints[conflictNumber][1]) {
1028 alpha = (listPoints[fConflictNumHatchLineTab[hatchNumber][follow]][1]-listConflictPoints[conflictNumber][1])/(listConflictPoints[follow][1]-listConflictPoints[conflictNumber][1]);
1029 }
1030 else if (listConflictPoints[follow][2] != listConflictPoints[conflictNumber][2]) {
1031 alpha = (listPoints[fConflictNumHatchLineTab[hatchNumber][follow]][2]-listConflictPoints[conflictNumber][2])/(listConflictPoints[follow][2]-listConflictPoints[conflictNumber][2]);
1032 }
1033 else {
1034 findAlpha =false;
1035 }
1036 if (findAlpha) {
1037 if ((alpha*(listConflictPoints[follow]-listConflictPoints[conflictNumber])).equals(listPoints[fConflictNumHatchLineTab[hatchNumber][follow]]-listConflictPoints[conflictNumber],FLT_EPSILON*FLT_EPSILON*10)) {
1038 overContour = true;
1039 }
1040 }
1041 }
1042 if (!overContour) {
1043 fPoints.push_back(listConflictPoints[conflictNumber].getValue());
1044 orderConflictLineNumber.push_back(fConflictNumHatchLineTab[hatchNumber][conflictNumber]);
1045 drawEnabled = drawEnabled?false:true;
1046 if (drawEnabled) {
1047 fVertices.push_back(2);
1048 }
1049 } else {
1050 if (drawEnabled) {
1051 fPoints.push_back(listConflictPoints[conflictNumber].getValue());
1052 orderConflictLineNumber.push_back(fConflictNumHatchLineTab[hatchNumber][conflictNumber]);
1053 drawEnabled = false;
1054 }
1055 }
1056 }
1057 conflictNumber ++;
1058 }
1059 }
1060 conflictNumber ++;
1061 }
1062 if (drawEnabled) {
1063 fPoints.push_back(fPoints[fPoints.size()-1]);
1064 }
1065
1066 fConflictNumHatchLineTab[hatchNumber].clear();
1067 for(unsigned int a=0;a<orderConflictLineNumber.size();a++) {
1068 fConflictNumHatchLineTab[hatchNumber].push_back(orderConflictLineNumber[a]);}
1069
1070
1071 }
1072 }
1073 }
1074
1075 if (fPoints.size() >0){
1076
1077 if (precisionError == 0){
1078 delete [] listPoints;
1079 return true;
1080 }
1081 else {
1082 delete [] listPoints;
1083 return false;
1084 }
1085 }
1086 delete [] listPoints;
1087 return true;
1088 }
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103 inline vec2f hatcher::resolve_system(const vec3f& A,const vec3f& B,const vec3f& C) {
1104
1105 fResolveResult = RESOLVE_UNDEFINED;
1106
1107 double Ax = A[0];
1108 double Ay = A[1];
1109 double Az = A[2];
1110 double Bx = B[0];
1111 double By = B[1];
1112 double Bz = B[2];
1113 double Cx = C[0];
1114 double Cy = C[1];
1115 double Cz = C[2];
1116
1117 double bDiv = (By*Ax-Ay*Bx);
1118 if (ffabs(float(bDiv)) <=FLT_EPSILON) {
1119
1120 double tmp;
1121 tmp = Ax; Ax = Ay; Ay = Az; Az = tmp;
1122 tmp = Bx; Bx = By; By = Bz; Bz = tmp;
1123 tmp = Cx; Cx = Cy; Cy = Cz; Cz = tmp;
1124
1125 bDiv = (By*Ax-Ay*Bx);
1126
1127 if (ffabs(float(bDiv)) <=FLT_EPSILON) {
1128
1129 tmp = Ax; Ax = Ay; Ay = Az; Az = tmp;
1130 tmp = Bx; Bx = By; By = Bz; Bz = tmp;
1131 tmp = Cx; Cx = Cy; Cy = Cz; Cz = tmp;
1132
1133 bDiv = (By*Ax-Ay*Bx);
1134 if (ffabs(float(bDiv)) <=FLT_EPSILON) {
1135 fResolveResult = RESOLVE_COLINEAR;
1136 return vec2f(0,0);
1137 }
1138 }
1139 }
1140 double b= (Cy*Ax-Ay*Cx)/bDiv;
1141 double a= -(Cy*Bx-By*Cx)/bDiv;
1142 double bid = ffabs(float(a*Az+b*Bz - Cz));
1143
1144 if (bid <= FLT_EPSILON) {
1145 fResolveResult = RESOLVE_OK;
1146 return vec2f((float)a,(float)b);
1147 }
1148 else {
1149
1150 double minBoxValue = 1;
1151
1152 double minXValue =FLT_MAX;
1153 double minYValue =FLT_MAX;
1154 double minZValue =FLT_MAX;
1155 if ((A[0] !=0) && ((A[0]) <minXValue)) minXValue = (A[0]);
1156 if ((B[0] !=0) && ((B[0]) <minXValue)) minXValue = (B[0]);
1157 if ((C[0] !=0) && ((C[0]) <minXValue)) minXValue = (C[0]);
1158 if ((A[1] !=0) && ((A[1]) <minYValue)) minYValue = (A[1]);
1159 if ((B[1] !=0) && ((B[1]) <minYValue)) minYValue = (B[1]);
1160 if ((C[1] !=0) && ((C[1]) <minYValue)) minYValue = (C[1]);
1161 if ((A[2] !=0) && ((A[2]) <minZValue)) minZValue = (A[2]);
1162 if ((B[2] !=0) && ((B[2]) <minZValue)) minZValue = (B[2]);
1163 if ((C[2] !=0) && ((C[2]) <minZValue)) minZValue = (C[2]);
1164
1165
1166 double maxXValue =-FLT_MAX;
1167 double maxYValue =-FLT_MAX;
1168 double maxZValue =-FLT_MAX;
1169 if ((A[0] !=0) && ((A[0]) >maxXValue)) maxXValue = (A[0]);
1170 if ((B[0] !=0) && ((B[0]) >maxXValue)) maxXValue = (B[0]);
1171 if ((C[0] !=0) && ((C[0]) >maxXValue)) maxXValue = (C[0]);
1172 if ((A[1] !=0) && ((A[1]) >maxYValue)) maxYValue = (A[1]);
1173 if ((B[1] !=0) && ((B[1]) >maxYValue)) maxYValue = (B[1]);
1174 if ((C[1] !=0) && ((C[1]) >maxYValue)) maxYValue = (C[1]);
1175 if ((A[2] !=0) && ((A[2]) >maxZValue)) maxZValue = (A[2]);
1176 if ((B[2] !=0) && ((B[2]) >maxZValue)) maxZValue = (B[2]);
1177 if ((C[2] !=0) && ((C[2]) >maxZValue)) maxZValue = (C[2]);
1178
1179 if (((maxXValue-minXValue) <= (maxYValue-minYValue)) && ((maxXValue-minXValue) <= (maxZValue-minZValue))) { minBoxValue = maxXValue-minXValue; }
1180 else
1181 if (((maxYValue-minYValue) <= (maxXValue-minXValue)) && ((maxYValue-minYValue) <= (maxZValue-minZValue))) { minBoxValue = maxYValue-minYValue; }
1182 else
1183 { minBoxValue = maxZValue-minZValue; }
1184
1185 minBoxValue *= fPrecisionFactor;
1186
1187 if (bid <= minBoxValue) {
1188 fResolveResult = RESOLVE_OK;
1189 return vec2f((float)a,(float)b);
1190 }
1191 else {
1192 if (bid>100*minBoxValue) {
1193 fResolveResult = RESOLVE_Z_ERROR;
1194 }
1195 else
1196 {
1197 fResolveResult = RESOLVE_PRECISION_ERROR;
1198 }
1199 }
1200 }
1201 return vec2f(0,0);
1202 }
1203
1204 }
1205